Node DeviceNodeFromDevice(string appEUI, Lassie.Device device, Node parent) { var deviceNode = new Node { Parent = parent, Name = device.DeviceEUI }; deviceNode.Children = () => { var ret = new List <Node>(); ret.Add(DataNodeFromDevice(appEUI, device, deviceNode)); return(ret); }; deviceNode.Attributes = () => { var attrs = new List <string>(); attrs.Add(String.Format("DeviceType: {0}", device.DeviceType)); attrs.Add(String.Format("DeviceEUI: {0}", device.DeviceAddress)); attrs.Add(String.Format("DevAddr: {0}", device.DeviceAddress)); attrs.Add(String.Format("AppSKey: {0}", device.ApplicationSessionKey)); attrs.Add(String.Format("NwkSKey: {0}", device.NetworkSessionKey)); attrs.Add(String.Format("AppKey: {0}", device.ApplicationKey)); attrs.Add(String.Format("FCntUp: {0}", device.FrameCounterUp)); attrs.Add(String.Format("FCntDn: {0}", device.FrameCounterDown)); attrs.Add(String.Format("RelaxedCounter: {0}", device.RelaxedCounter)); attrs.Add(String.Format("KeyWarning: {0}", device.KeyWarning)); return(attrs); }; return(deviceNode); }
Node DataNodeFromDevice(string appEUI, Lassie.Device device, Node parent) { var dataNode = new Node { Parent = parent, Name = "messages" }; dataNode.Children = () => new List <Node>(); dataNode.Attributes = () => { var attrs = new List <string>(); var data = client.GetDeviceDataAsync(appEUI, device.DeviceEUI); data.Wait(); attrs.Add(String.Format("{0:-40} {1:-20} {2:-10} {3:-10}", "Data", "RSSI", "SNR", "Freq")); foreach (Lassie.DeviceData d in data.Result.Messages) { attrs.Add(String.Format("{0:-40} {1:-20} {2:-10} {3:-10}", d.HexData, d.RSSI, d.SNR, d.Frequency)); } return(attrs); }; return(dataNode); }