Creating and Updating LORA Device Groups.
Home › Forums › Conduit: AEP Model › Creating and Updating LORA Device Groups.
Tagged: LORA Device Groups.
- This topic has 8 replies, 2 voices, and was last updated 3 years, 1 month ago by Jason Reiss.
-
AuthorPosts
-
August 18, 2021 at 11:11 am #32036Ajay KParticipant
Currently we are creating two custom device groups in the conduit and which can be typically viewed at the URL https://<conduit-ip>/lora/device-groups.
I am using the Conduit Web API, to create and update the device groups. Btw the conduit firmware version is 5.2.5.
Here is an example of creating a lora device group with an empty list of devices.
var payload = { "groupname": "FOTA_HIGHER_DR", "deveuis": [] }; var reqDoneEventEmitter = httpHandler.gatewayWebApiRequest("http://127.0.0.1/api/lora/groups", "POST", payload);
Everything works great during the creation of the device group, however when we add devices to the custom groups over time, it seems to create a duplicate of the device group. Are we supposed to change the API method type to “PUT” instead of “POST while updating an existing device group?
An example of how we are posting the updated device group.
var payload = {"deveuis":["00:80:00:00:00:01:02:2a"],"groupeui":"00-80-00-88-21-09-23-24","groupname":"FOTA_HIGHER_DR"} var reqDoneEventEmitter = httpHandler.gatewayWebApiRequest("http://127.0.0.1/api/lora/groups", "POST", payload);
Thanks,
AjayAugust 18, 2021 at 11:24 am #32037Jason ReissKeymasterIf I post a group with updated devices it will overwrite the group.
There is no call to add a single device, the entire group of euis must be provided.https://10.17.100.146/api/lora/groups?method=POST&data={%22deveuis%22:[%2200-80-00-00-00-01-58-34%22,%2212-31-23-23-12-31-23-23%22,%2212-31-23-23-12-31-23-25%22],%22groupeui%22:%2200-80-00-70-30-f8-ec-da%22,%22groupname%22:%22123123213%22}
August 18, 2021 at 11:47 am #32038Ajay KParticipantThanks Jason, However I am not just updating a single EUI. The example above shows just adding a new EUI to an empty list, over time the list will have more devices added and the deveuis array in the payload would have all the device eui’s that need to be in the group, not the one I am attempting to add or remove.
However I am wondering if the post request is causing the group to be re-created? Since I end up seeing duplicate groups in the device group screen. Also in your example you seem to be sending the data via the url, I send it via the body, hopefully that doesn’t make a difference?
Should I be using the PUT method to indicate that its an update, not creating a new group?
Thanks,
AjayAugust 18, 2021 at 12:20 pm #32039Jason ReissKeymasterOnly GET, POST, DELETE calls are handled by the UI
There is no PUT handler to add a single EUI.Providing the data in the body or URL should have the same effect.
Sending a POST with a groupeui will overwrite the group. Without an groupeui an new group will be created.
The API accesses the /var/config/lora/.groups folder containing the group lists.
These files can be modified locally to append devices to a group.August 18, 2021 at 12:24 pm #32040Ajay KParticipantI tried calling the post method repeatedly and couldn’t create duplicates. However I see the UX i.e. https://<conduit-ip>/lora/device-groups, seems to be completely un-synchronized with the changes. I am guessing the duplicate issues occurring in reality is an UX bug, rather than an API issue. I even used fiddler to see what the API was returning for the device groups calls and its returning no duplicates, however the UX at times doesn’t display the device groups at all even though there are devices in the device groups or shows them as duplicates.
I think the UX team needs to address this issue, when they get a chance. Its easy to reproduce this issue.
Thanks,
Ajay.August 19, 2021 at 3:28 pm #32054Ajay KParticipantSo the groups page completely errors out or is blank if the deveuis is set to null via code. An example JSON for which the UX is completely broken is as shown below and I see the following error in the browser console.
vendor.7e69a35f0ea1812ae2da.js:1 TypeError: Cannot read property ‘length’ of null
at 60.cfe321709b14c865ceb5.js:1
at a.kt [as _l] (vendor.7e69a35f0ea1812ae2da.js:1)
at a.render (60.cfe321709b14c865ceb5.js:1)
at a.t._render (vendor.7e69a35f0ea1812ae2da.js:6)
at a.r (vendor.7e69a35f0ea1812ae2da.js:1)
at za.get (vendor.7e69a35f0ea1812ae2da.js:6)
at za.run (vendor.7e69a35f0ea1812ae2da.js:6)
at Ee (vendor.7e69a35f0ea1812ae2da.js:1)
at Array.<anonymous> (vendor.7e69a35f0ea1812ae2da.js:1)
at ct (vendor.7e69a35f0ea1812ae2da.js:1){ "code" : 200, "result" : { "lora_groups" : [ { "deveuis" : [ "00:80:00:00:00:01:96:cd" ], "groupeui" : "00-80-00-88-21-09-23-24", "groupname" : "FOTA_HIGHER_DR" }, { "deveuis" : null, "groupeui" : "00-80-00-bb-cf-fe-6f-83", "groupname" : "FOTA_LOWER_DR" } ] }, "status" : "success" }
Thanks,
Ajay.August 19, 2021 at 3:45 pm #32055Jason ReissKeymasterWhy null and not [] for empty array?
August 21, 2021 at 8:50 pm #32061Ajay KParticipantIt could be an empty array, but the web page needs the ability to handle the scenario where the array is set to null and not error out like it is currently. The only thing missing in the above scenario is a valid list of EUI’s for that particular group. the web page should display every other device group that is in the list and not be blank page like it is currently. So it would be great eventually if not in 5.2.5 patch release, some other release this is addressed.
Thanks,
Ajay.August 23, 2021 at 8:38 am #32063Jason ReissKeymasterSure we can handle the null value, but what is the reason to create a group with no devices?
-
AuthorPosts
- You must be logged in to reply to this topic.