Creating and Updating LORA Device Groups.

Home Forums Conduit: AEP Model Creating and Updating LORA Device Groups.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #32036
    Ajay K
    Participant

    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,
    Ajay

    #32037
    Jason Reiss
    Keymaster

    If 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}

    #32038
    Ajay K
    Participant

    Thanks 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,
    Ajay

    #32039
    Jason Reiss
    Keymaster

    Only 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.

    #32040
    Ajay K
    Participant

    I 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.

    #32054
    Ajay K
    Participant

    So 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.

    #32055
    Jason Reiss
    Keymaster

    Why null and not [] for empty array?

    #32061
    Ajay K
    Participant

    It 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.

    #32063
    Jason Reiss
    Keymaster

    Sure we can handle the null value, but what is the reason to create a group with no devices?

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.