static void Main() { var p = new Program(); var client = new Lassie.Client(); p.MainLoop(client); }
public async Task TestUpdateGatewayAsync() { var c = new Lassie.Client(); var template = new Lassie.Gateway { GatewayEUI = NewRandomEUI().ToString(), IP = "127.0.0.1", StrictIP = false, }; var gw = await c.CreateGatewayAsync(template); gw.Tags["name"] = "bar"; gw.Tags["foo"] = "bar"; gw.Latitude = 1.0f; gw.Longitude = 2.0f; gw.Altitude = 3.0f; var updated = await c.UpdateGatewayAsync(gw); Assert.NotNull(updated); Assert.Equal(updated.Tags["name"], "bar"); Assert.Equal(updated.Tags["foo"], "bar"); Assert.Equal(updated.Latitude, 1.0f); Assert.Equal(updated.Longitude, 2.0f); Assert.Equal(updated.Altitude, 3.0f); await c.DeleteGateway(gw.GatewayEUI); }
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); }
public async Task TestCreateAndDeleteApplicationAsync() { var c = new Lassie.Client(); var app = await c.CreateApplicationAsync(new Lassie.Application()); Assert.NotNull((app)); await c.DeleteApplicationAsync(app.ApplicationEUI); }
static void Main(string[] args) { Console.WriteLine("Getting applications...."); var client = new Lassie.Client(); var t = Task.Run(() => ListApps(client)); t.Wait(); }
static async Task ListApps(Lassie.Client client) { var apps = await client.ListApplicationsAsync(); foreach (Lassie.Application app in apps.Applications) { Console.WriteLine("App EUI: {0} name: {1}", app.ApplicationEUI, app.Tags["name"]); } }
public async Task TestUpdateApplicationAsync() { var c = new Lassie.Client(); var app = await c.CreateApplicationAsync(new Lassie.Application()); app.Tags["name"] = "foo"; var updated = await c.UpdateApplicationAsync(app); Assert.Equal(app.ApplicationEUI, updated.ApplicationEUI); Assert.Equal("foo", updated.Tags["name"]); await c.DeleteApplicationAsync(updated.ApplicationEUI); }
public async Task TestAddRemoveDevice() { 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.OTAA }); Assert.NotNull(device); await c.DeleteDeviceAsync(app.ApplicationEUI, device.DeviceEUI); }
void MainLoop(Lassie.Client client) { var ctx = new NodeTree(client); while (true) { Console.Write("[congress:{0}]: ", ctx.CurrentEntry.FullPath); var cmd = Console.ReadLine().ToLower(); var param = cmd.Split(' ', StringSplitOptions.RemoveEmptyEntries); switch (param[0]) { case "quit": return; case "exit": return; case "ls": foreach (Node entry in ctx.CurrentEntry.Children()) { Console.WriteLine("{0}/", entry.Name); } Console.WriteLine(); foreach (string attr in ctx.CurrentEntry.Attributes()) { Console.WriteLine("{0}", attr); } break; case "cd": var newEntry = ctx.ChangeEntry(cmd.Substring(param[0].Length)); if (newEntry == null) { Console.WriteLine("Couldn't cd to {0}", cmd.Substring(param[0].Length)); } break; case "help": Console.WriteLine("{0,-20}: Show help (you figured out this one)", "help"); Console.WriteLine("{0,-20}: List applications, deviecs and gateways", "ls"); Console.WriteLine("{0,-20}: Select resource", "cd <resource>"); break; default: Console.WriteLine("**** Don't know how to {0}", cmd); break; } } }
public async Task TestCreateAndDeleteGatewayAsync() { var c = new Lassie.Client(); var template = new Lassie.Gateway { GatewayEUI = NewRandomEUI().ToString(), IP = "127.0.0.1", StrictIP = false, }; var gw = await c.CreateGatewayAsync(template); Assert.NotNull((gw)); Assert.Equal(gw.GatewayEUI.ToLower(), template.GatewayEUI.ToLower()); Assert.Equal(gw.IP, template.IP); await c.DeleteGateway(gw.GatewayEUI); }
public NodeTree(Lassie.Client c) { client = c; Path = "/"; CurrentEntry = Root; var apps = new Node { Parent = Root, Name = "applications" }; var gateways = new Node { Parent = Root, Name = "gateways" }; Root.Children = () => { var ret = new List <Node>(); ret.Add(apps); ret.Add(gateways); return(ret); }; Root.Attributes = () => new List <string>(); apps.Children = () => { var a = new List <Node>(); var al = client.ListApplicationsAsync(); al.Wait(); foreach (Lassie.Application app in al.Result.Applications) { a.Add(AppNodeFromApplication(app, apps)); } return(a); }; gateways.Children = () => { var g = new List <Node>(); var gl = client.ListGatewaysAsync(); gl.Wait(); foreach (Lassie.Gateway gw in gl.Result.Gateways) { g.Add(GwNodeFromGateway(gw, gateways)); } return(g); }; apps.Attributes = () => new List <string>(); gateways.Attributes = () => new List <string>(); }