Exemplo n.º 1
0
        public async Task TestUpdateDevice()
        {
            var c   = new Lassie.Client();
            var app = await c.CreateApplicationAsync(new Lassie.Application());

            var device = await c.CreateDeviceAsync(app.ApplicationEUI, new Lassie.Device {
                DeviceType = Lassie.Device.ABP
            });

            Assert.NotNull(device);
            Assert.Equal(Lassie.Device.ABP, device.DeviceType);

            device.Tags["name"]   = "foo";
            device.RelaxedCounter = true;
            device.ApplicationKey = "01020304aabbccdd01020304aabbccdd";
            var updated = await c.UpdateDeviceAsync(app.ApplicationEUI, device);

            Assert.Equal(device.RelaxedCounter, updated.RelaxedCounter);
            Assert.Equal(device.ApplicationKey, updated.ApplicationKey);
            Assert.Equal("foo", device.Tags["name"]);

            var dd = await c.GetDeviceDataAsync(app.ApplicationEUI, device.DeviceEUI);

            Assert.Equal(0, dd.Messages.Length);
            await c.DeleteDeviceAsync(app.ApplicationEUI, device.DeviceEUI);
        }
Exemplo n.º 2
0
        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);
        }