Switching between COAP and HTTP via REST API?

What product/components do you use and which version/fix level?

Cumulocity IOT specifically LWM2M
Version: 1011.0.19

Are you using a free trial or a product with a customer license?

Product with a customer license

What are trying to achieve? Please describe in detail.

When I initially register my devices, I have to choose between the default of “HTTP” for file transfers or COAP using this field of the CSV file:
“fwUpdateSupportedDeviceProtocol”

As far as I can tell, there is no way to modify this setting once the device entry has been created.
Since I need to test both HTTP and COAP - if I have 10 devices, I need to create 20 device entries - 2 for each unit.

If there is a way to toggle this setting - it’s not visible via the dashboard.
I have attempted to modify this setting in the same fashion I used to modify all of the settings that appear in the
“LWM2M bootstrap parameters” section of the console - using the REST API.
Unfortunately, while I have not received any errors, the setting remains unchanged.

IS there a way to modify this setting on the fly? It would allow me to dispense with 50% of my configurations.

Do you get any error messages? Please provide a full error message screenshot and log file.

No Error messages.

thanks

Jim

Hi Jim,

can you give some details or an example how you tried to change the property?

Regards
Stefan

I attempted to modify it using Curl like this:

curl [actual proper link deleted for forum]
-X ‘PUT’
-H ‘Accept: application/json, text/plain, /
-H ‘Accept-Language: en-US,en;q=0.9,es;q=0.8’
-H ‘Authorization: Basic [deleted]I=’
-H ‘Connection: keep-alive’
-H ‘Content-Type: application/json;charset=UTF-8’
-H ‘DNT: 1’
-H 'Origin: [actual proper link deleted for forum]
-H 'Referer: [actual proper link deleted for forum]
-H ‘Sec-Fetch-Dest: empty’
-H ‘Sec-Fetch-Mode: cors’
-H ‘Sec-Fetch-Site: same-origin’
-H ‘UseXBasic: true’
-H ‘User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36’
-H ‘X-Cumulocity-Application-Key: devicemanagement-application-key’
-H ‘sec-ch-ua: " Not A;Brand";v=“99”, “Chromium”;v=“102”, “Google Chrome”;v=“102”’
-H ‘sec-ch-ua-mobile: ?0’
-H ‘sec-ch-ua-platform: “macOS”’
-H ‘sec-gpc: 1’
–data-raw ‘{“defaultMinimumPeriod”:null,“bootstrapId”:“jim_F3B4_HTTP”,“bootstrapKey”:“”,“securityInstanceOffset”:null,“secretKey”:null,“lwm2mShortServerId”:“2”,“disableTimeout”:null,“securityMode”:“PSK”,“notificationStoring”:null,“defaultMaximumPeriod”:null,“endpoint”:“jim_F3B4_HTTP”,“serverUri”:“coap://lwm2m.us.cumulocity.com:5783”,“bindingMode”:null,“bootstrapShortServerId”:“0”,“generateBootstrapServerConfig”:false,“serverPublicKey”:null,“publicKeyOrId”:“jim_F3B4_HTTP”,“registrationLifeTime”:null, “fwUpdateSupportedDeviceProtocol”: “COAP”}’
–compressed

Basically, this is a clone of what my browser sent during the last bootstrap config update I performed - I just appended

“fwUpdateSupportedDeviceProtocol”: “COAP”

to the JSON in an effort to modify it.

Why did I try it like this?

Since I performed a query and I saw “fwUpdateSupportedDeviceProtocol” was in the same area in the resultant JSON output as some of the bootstrap keys.

Here’s an excerpt from that query output:

‘lwm2m server uri’: ‘coap://lwm2m.us.cumulocity.com:5783’, ‘endpoint id’: ‘jim_F3B4_HTTP’, ‘c8y_Mobile’: {‘mnc’: ‘410’, ‘cellId’: ‘44827912’, ‘mcc’: ‘310’}, ‘c8y_ActiveAlarmsStatus’: {‘major’: 2, ‘warning’: 1}, ‘bootstrapShortServerId’: ‘0’, ‘generateBootstrapServerConfig’: False, ‘fwUpdateSupportedDeviceProtocol’: ‘HTTP’,

In this excerpt - I saw:

generateBootstrapServerConfig
bootstrapShotServerId
lwm2m server uri
endpoint id

All of these were familiar to me as coming from the " LWM2M bootstrap parameters" section of the webconsole,
so I was hoping to piggyback a modification for ‘fwUpdateSupportedDeviceProtocol’ in there also.

Whilst my modification generated no errors - ‘fwUpdateSupportedDeviceProtocol’ seems to be ignored.

So - I am now assuming this isn’t the proper spot to modify it - and hoping someone can tell me where the proper spot to modify it is.

thanks

Jim

Hi Jim,

normally it should be enough just to put the fragment “fwUpdateSupportedDeviceProtocol” of the managed object so the other ones are not touched.

PUT
{
    "fwUpdateSupportedDeviceProtocol": "COAP
}

So if you do a get afterwards the property is set in the managed object like this:

"fwUpdateSupportedDeviceProtocol": "COAP"

By “seems to be ignored” you mean that the lwm2m devices is ignoring this property even it is correctly set on the managed object?

I don’t know the lwm2m implementation details how & when this fragment is used by the lwm2m server. So if you don’t mind I would ask you to open a support ticket: https://getsupport.softwareag.com/
If the managed object is not updated properly try my approach by just using the fragment you want to add/update.

Regards
Stefan

Assuming this is what you were suggesting I try:

curl ‘https ://lairdconnect.us.cumulocity.com/service/lwm2m-agent/device/30296346/bootstrapParams’ \

-X ‘PUT’
-H ‘Accept: application/json, text/plain, /
-H ‘Accept-Language: en-US,en;q=0.9,es;q=0.8’
-H 'Authorization: Basic [deleted]
-H ‘Connection: keep-alive’
-H ‘Content-Type: application/json;charset=UTF-8’
-H ‘DNT: 1’
-H ‘Sec-Fetch-Dest: empty’
-H ‘Sec-Fetch-Mode: cors’
-H ‘Sec-Fetch-Site: same-origin’
-H ‘UseXBasic: true’
-H ‘X-Cumulocity-Application-Key: devicemanagement-application-key’
–data-raw ‘{“fwUpdateSupportedDeviceProtocol”: “COAP”}’
–compressed

The return code is 500, with this response:

{“error”:“LWM2M/Error”}

Is this a bug - or operator error?

Jim

(I’d edit the previous response if I could)

Just to be clear, I purposely inserted the space after the https to get the forum to allow the link - I’m not actually using a garbled URI)

Ok this was a misunderstanding from my side: I thought you are updating the managed object and not using the lwm2m-agent//bootstrapParams

But I guess your way is the one supposed to be working and not updating the managed object only.
I’ll see if I get some internal infos on that.

Regards
Stefan

Hi @jim.veneskey ,

I just got feedback and my assumed way seems to be the correct one. The /service/lwm2m-agent//bootstrapParams endpoint is not meant for the configuration you wanted to do.

Here are the details what you’ve to do:

  1. Use the endpoint {{url}}/inventory/managedObjects/{internal device ID}
PUT {{url}}/inventory/managedObjects/{internal device ID}
{
    "fwUpdateSupportedDeviceProtocol": "COAP
}
  1. Afterwards you should see the managed object of the devices updated:
GET {{url}}/inventory/managedObjects/{internal device ID}

Regards
Stefan

Here are the results. (quick answer - no change)
(only modifications I’m making for the forum are suppressing my auth key and munging the URLs a bit)

BEFORE Attempting the modification - delivery method = HTTP

curl ‘(URL)/inventory/managedObjects/30296346’ \

-H ‘Accept: application/json, text/plain, /
-H ‘Accept-Language: en-US,en;q=0.9,es;q=0.8’
-H ‘Authorization: Basic Authen key here’
-H ‘Connection: keep-alive’
-H ‘DNT: 1’
-H ‘Referer: Device management
-H ‘Sec-Fetch-Dest: empty’
-H ‘Sec-Fetch-Mode: cors’
-H ‘Sec-Fetch-Site: same-origin’
-H ‘UseXBasic: true’
-H ‘User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36’
-H ‘X-Cumulocity-Application-Key: devicemanagement-application-key’
-H ‘sec-ch-ua: " Not A;Brand";v=“99”, “Chromium”;v=“102”, “Google Chrome”;v=“102”’
-H ‘sec-ch-ua-mobile: ?0’
-H ‘sec-ch-ua-platform: “macOS”’
-H ‘sec-gpc: 1’
–compressed
{“additionParents”:{“references”:,“self”:“(URL)/inventory/managedObjects/30296346/additionParents”},“owner”:“device_jim_F3B4_HTTP”,“childDevices”:{“references”:,“self”:“(URL)/inventory/managedObjects/30296346/childDevices”},“childAssets”:{“references”:,“self”:“(URL)inventory/managedObjects/30296346/childAssets”},“creationTime”:“2022-07-14T15:42:37.533Z”,“type”:“c8y_lwm2m”,“lastUpdated”:“2022-07-20T18:41:08.915Z”,“childAdditions”:{“references”:,“self”:“(URL)/inventory/managedObjects/30296346/childAdditions”},“name”:“LwM2M Laird Connectivity, Inc. jim_F3B4_HTTP”,“assetParents”:{“references”:,“self”:“(URL)/inventory/managedObjects/30296346/assetParents”},“deviceParents”:{“references”:,“self”:“(URL)inventory/managedObjects/30296346/deviceParents”},“self”:“https://t220788092.us.cumulocity.com/inventory/managedObjects/30296346",“id”:“30296346”,“c8y_Lwm2m_0!1”:{“instance”:“1”,“operations”:true},“c8y_Lwm2m_1!0”:{“instance”:“0”,“operations”:true},“c8y_Firmware”:{“name”:"IG60LL non-SD”,“version”:“10.40.0.10”,“url”:“(URL)/inventory/binaries/31920571”},“defaultMinimumPeriod”:35,“c8y_Availability”:{“lastMessage”:“2022-07-20T18:41:08.957Z”,“status”:“UNAVAILABLE”},“c8y_Lwm2m_0!0”:{“instance”:“0”,“operations”:true},“c8y_Lwm2m_5!0”:{“1”:“”,“2”:“”,“instance”:“0”,“operations”:true,“3”:0,“5”:0,“9”:2},“c8y_Lwm2m_4!0”:{“0”:41,“1”:“{"0":41}”,“12”:[68,112],“2”:-82,“instance”:“0”,“operations”:true,“4”:“"192.168.1.174"”,“7”:“"iot0119.com.attz.mnc170.mcc310.gprs"”,“8”:44827912,“9”:410,“10”:310},“lwm2m psk_id”:“jim_F3B4_HTTP”,“c8y_Lwm2m_3!0”:{“12”:“”,“13”:1658334940000,“instance”:“0”,“14”:“UTC+00:00”,“0”:“Laird Connectivity, Inc.”,“1”:“Sentrius IG60”,“operations”:true,“3”:“10.40.0.10”,“4”:“”,“5”:“”,“6”:“{"0":0}”,“21”:257699,“10”:117559},“c8y_Lwm2m_9!0”:{“0”:“lwm2m-python-client”,“11”:“”,“1”:“0.2”,“instance”:“0”,“operations”:true,“4”:“”,“6”:“”,“10”:“”},“lwm2m server uri”:“coap://lwm2m.us.cumulocity.com:5784”,“registrationLifetime”:35,“endpoint id”:“jim_F3B4_HTTP”,“c8y_Mobile”:{“mnc”:“410”,“cellId”:“44827912”,“mcc”:“310”},“c8y_ActiveAlarmsStatus”:{“major”:3,“warning”:2},“bootstrapShortServerId”:“0”,“generateBootstrapServerConfig”:true,“fwUpdateSupportedDeviceProtocol”:“HTTP”,“c8y_lwm2m_commons_model_fwupdate_Lwm2mFirmwareUpdate”:{“result”:“UPDATE_SUCCESSFUL”,“protocol”:“HTTP”,“deliveryMethod”:“PULL_AND_PUSH_SUPPORTED”,“currentStatus”:“SUCCESS”,“endpointUrl”:“(URL):8773/firmware/bf77f8c6-9505-45be-8220-0ef595864e61”,“history”:[{“date”:“2022-07-20T11:35:48.577Z”,“status”:“STARTED”},{“date”:“2022-07-20T11:35:48.619Z”,“status”:“READING_DEVICE_CONFIG”},{“date”:“2022-07-20T11:35:48.960Z”,“status”:“DEVICE_CONFIG_READY”},{“date”:“2022-07-20T11:35:49.732Z”,“status”:“DELIVERING_FIRMWARE”},{“date”:“2022-07-20T11:36:11.444Z”,“status”:“FIRMWARE_DELIVERED”},{“date”:“2022-07-20T11:36:11.491Z”,“status”:“TRIGGERING_UPDATE”},{“date”:“2022-07-20T11:36:11.522Z”,“status”:“FIRMWARE_DELIVERED”},{“date”:“2022-07-20T11:36:12.205Z”,“status”:“TRIGGERING_UPDATE”},{“date”:“2022-07-20T11:36:12.409Z”,“status”:“UPDATE_TRIGGERED”},{“date”:“2022-07-20T11:36:34.193Z”,“status”:“SUCCESS”}],“endpointUuid”:“bf77f8c6-9505-45be-8220-0ef595864e61”,“firmware”:{“name”:“IG60LL non-SD”,“version”:“10.40.0.10”,“url”:“(URL)/inventory/binaries/31920571”},“startDate”:“2022-07-20T11:35:48.577Z”},“c8y_Lwm2m_10259!0”:{“instance”:“0”,“operations”:true},“bootstrap psk_id”:“jim_F3B4_HTTP”,“c8y_GenericUi”:{},“com_cumulocity_model_Agent”:{},“c8y_Connection”:{“status”:“CONNECTED”},“c8y_RequiredAvailability”:{“responseInterval”:2},“c8y_Lwm2m_13!0”:{“instance”:“0”,“operations”:true},“c8y_SupportedOperations”:[“c8y_Command”,“c8y_Restart”,“c8y_Firmware”,“c8y_Software”],“lwm2m psk_key”:“123456789012345678901234567890ab”,“lwm2mShortServerId”:“1”,“c8y_Lwm2m_12!0”:{“0”:“wlan0”,“instance”:“0”,“operations”:true},“securityMode”:“PSK”,“c8y_Hardware”:{“serialNumber”:null,“model”:“Sentrius IG60”,“revision”:“10.40.0.10”},“c8y_IsDevice”:{},“bootstrap psk_key”:“098765432109876543210987654321cc”}

Excerpt from blob above:

“generateBootstrapServerConfig”:true,“fwUpdateSupportedDeviceProtocol”:“HTTP”,“c8y_lwm2m_commons_model_fwupdate_Lwm2mFirmwareUpdate”

Attempting the modification - delivery method to COAP

curl ‘(URL)/inventory/managedObjects/30296346’ \

-X ‘PUT’
-H ‘Accept: application/json, text/plain, /
-H ‘Accept-Language: en-US,en;q=0.9,es;q=0.8’
-H ‘Authorization: Basic Authen key here’
-H ‘Connection: keep-alive’
-H ‘Content-Type: application/json;charset=UTF-8’
-H ‘DNT: 1’
-H ‘Origin: (URL)’
-H ‘Referer: (URL)/apps/devicemanagement/index.html’
-H ‘Sec-Fetch-Dest: empty’
-H ‘Sec-Fetch-Mode: cors’
-H ‘Sec-Fetch-Site: same-origin’
-H ‘UseXBasic: true’
-H ‘User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36’
-H ‘X-Cumulocity-Application-Key: devicemanagement-application-key’
-H ‘sec-ch-ua: " Not A;Brand";v=“99”, “Chromium”;v=“102”, “Google Chrome”;v=“102”’
-H ‘sec-ch-ua-mobile: ?0’
-H ‘sec-ch-ua-platform: “macOS”’
-H ‘sec-gpc: 1’
–data-raw ‘{“fwUpdateSupportedDeviceProtocol”: “COAP”}’
–compressed

Querying to see if there was any change

curl ‘(URL)/inventory/managedObjects/30296346’ \

-H ‘Accept: application/json, text/plain, /
-H ‘Accept-Language: en-US,en;q=0.9,es;q=0.8’
-H ‘Authorization: Basic Authen Key’
-H ‘Connection: keep-alive’
-H ‘DNT: 1’
-H ‘Referer: (URL)/apps/devicemanagement/index.html’
-H ‘Sec-Fetch-Dest: empty’
-H ‘Sec-Fetch-Mode: cors’
-H ‘Sec-Fetch-Site: same-origin’
-H ‘UseXBasic: true’
-H ‘User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36’
-H ‘X-Cumulocity-Application-Key: devicemanagement-application-key’
-H ‘sec-ch-ua: " Not A;Brand";v=“99”, “Chromium”;v=“102”, “Google Chrome”;v=“102”’
-H ‘sec-ch-ua-mobile: ?0’
-H ‘sec-ch-ua-platform: “macOS”’
-H ‘sec-gpc: 1’
–compressed
{“additionParents”:{“references”:,“self”:“(URL)/inventory/managedObjects/30296346/additionParents”},“owner”:“device_jim_F3B4_HTTP”,“childDevices”:{“references”:,“self”:“(URL)/inventory/managedObjects/30296346/childDevices”},“childAssets”:{“references”:,“self”:“(URL)/inventory/managedObjects/30296346/childAssets”},“creationTime”:“2022-07-14T15:42:37.533Z”,“type”:“c8y_lwm2m”,“lastUpdated”:“2022-07-20T18:41:08.915Z”,“childAdditions”:{“references”:,“self”:“(URL)/inventory/managedObjects/30296346/childAdditions”},“name”:“LwM2M Laird Connectivity, Inc. jim_F3B4_HTTP”,“assetParents”:{“references”:,“self”:“(URL)/inventory/managedObjects/30296346/assetParents”},“deviceParents”:{“references”:,“self”:“(URL)/inventory/managedObjects/30296346/deviceParents”},“self”:“https://t220788092.us.cumulocity.com/inventory/managedObjects/30296346",“id”:“30296346”,“c8y_Lwm2m_0!1”:{“instance”:“1”,“operations”:true},“c8y_Lwm2m_1!0”:{“instance”:“0”,“operations”:true},“c8y_Firmware”:{“name”:"IG60LL non-SD”,“version”:“10.40.0.10”,“url”:“(URL)/inventory/binaries/31920571”},“defaultMinimumPeriod”:35,“c8y_Availability”:{“lastMessage”:“2022-07-20T18:41:08.957Z”,“status”:“UNAVAILABLE”},“c8y_Lwm2m_0!0”:{“instance”:“0”,“operations”:true},“c8y_Lwm2m_5!0”:{“1”:“”,“2”:“”,“instance”:“0”,“operations”:true,“3”:0,“5”:0,“9”:2},“c8y_Lwm2m_4!0”:{“0”:41,“1”:“{"0":41}”,“12”:[68,112],“2”:-82,“instance”:“0”,“operations”:true,“4”:“"192.168.1.174"”,“7”:“"iot0119.com.attz.mnc170.mcc310.gprs"”,“8”:44827912,“9”:410,“10”:310},“lwm2m psk_id”:“jim_F3B4_HTTP”,“c8y_Lwm2m_3!0”:{“12”:“”,“13”:1658334940000,“instance”:“0”,“14”:“UTC+00:00”,“0”:“Laird Connectivity, Inc.”,“1”:“Sentrius IG60”,“operations”:true,“3”:“10.40.0.10”,“4”:“”,“5”:“”,“6”:“{"0":0}”,“21”:257699,“10”:117559},“c8y_Lwm2m_9!0”:{“0”:“lwm2m-python-client”,“11”:“”,“1”:“0.2”,“instance”:“0”,“operations”:true,“4”:“”,“6”:“”,“10”:“”},“lwm2m server uri”:“coap://lwm2m.us.cumulocity.com:5784”,“registrationLifetime”:35,“endpoint id”:“jim_F3B4_HTTP”,“c8y_Mobile”:{“mnc”:“410”,“cellId”:“44827912”,“mcc”:“310”},“c8y_ActiveAlarmsStatus”:{“major”:3,“warning”:2},“bootstrapShortServerId”:“0”,“generateBootstrapServerConfig”:true,“fwUpdateSupportedDeviceProtocol”:“HTTP”,“c8y_lwm2m_commons_model_fwupdate_Lwm2mFirmwareUpdate”:{“result”:“UPDATE_SUCCESSFUL”,“protocol”:“HTTP”,“deliveryMethod”:“PULL_AND_PUSH_SUPPORTED”,“currentStatus”:“SUCCESS”,“endpointUrl”:“(URL):8773/firmware/bf77f8c6-9505-45be-8220-0ef595864e61”,“history”:[{“date”:“2022-07-20T11:35:48.577Z”,“status”:“STARTED”},{“date”:“2022-07-20T11:35:48.619Z”,“status”:“READING_DEVICE_CONFIG”},{“date”:“2022-07-20T11:35:48.960Z”,“status”:“DEVICE_CONFIG_READY”},{“date”:“2022-07-20T11:35:49.732Z”,“status”:“DELIVERING_FIRMWARE”},{“date”:“2022-07-20T11:36:11.444Z”,“status”:“FIRMWARE_DELIVERED”},{“date”:“2022-07-20T11:36:11.491Z”,“status”:“TRIGGERING_UPDATE”},{“date”:“2022-07-20T11:36:11.522Z”,“status”:“FIRMWARE_DELIVERED”},{“date”:“2022-07-20T11:36:12.205Z”,“status”:“TRIGGERING_UPDATE”},{“date”:“2022-07-20T11:36:12.409Z”,“status”:“UPDATE_TRIGGERED”},{“date”:“2022-07-20T11:36:34.193Z”,“status”:“SUCCESS”}],“endpointUuid”:“bf77f8c6-9505-45be-8220-0ef595864e61”,“firmware”:{“name”:“IG60LL non-SD”,“version”:“10.40.0.10”,“url”:“(URL)/inventory/binaries/31920571”},“startDate”:“2022-07-20T11:35:48.577Z”},“c8y_Lwm2m_10259!0”:{“instance”:“0”,“operations”:true},“bootstrap psk_id”:“jim_F3B4_HTTP”,“c8y_GenericUi”:{},“com_cumulocity_model_Agent”:{},“c8y_Connection”:{“status”:“DISCONNECTED”},“c8y_RequiredAvailability”:{“responseInterval”:2},“c8y_Lwm2m_13!0”:{“instance”:“0”,“operations”:true},“c8y_SupportedOperations”:[“c8y_Command”,“c8y_Restart”,“c8y_Firmware”,“c8y_Software”],“lwm2m psk_key”:“123456789012345678901234567890ab”,“lwm2mShortServerId”:“1”,“c8y_Lwm2m_12!0”:{“0”:“wlan0”,“instance”:“0”,“operations”:true},“securityMode”:“PSK”,“c8y_Hardware”:{“serialNumber”:null,“model”:“Sentrius IG60”,“revision”:“10.40.0.10”},“c8y_IsDevice”:{},“bootstrap psk_key”:“098765432109876543210987654321cc”}

Excerpt from blob above:

“generateBootstrapServerConfig”:true,“fwUpdateSupportedDeviceProtocol”:“HTTP”,"c8y_lwm2m_commons_model_fwupdate_Lwm2mFirmwareUpdate

No change.

Hi Jim,

I tested it with Postman and it works fine with this data-raw line:
–data-raw ‘{
“fwUpdateSupportedDeviceProtocol”: “COAP”
}’

Please check:

  1. your quotation marks. In your text I see “ and ” , these are not recognized by my Postman test.
    I use " (windows character map U+0022)
  2. which response do you get when you send your PUT request? It should be “200 OK”

Regards, Christian

1 Like

Hi,
I believe the final issue I was seeing was indeed those funky quote marks.
I went back and overwrote them with the standard (22) character and it seems to be updating correctly now.

So - I was making two mistakes - attempting to update it via the bootstrap parameters (I could see it in there - so I assumed I could update it from there) and those silly quote marks.

Thanks for your help!

Jim

1 Like