Get/Set Network Server configuration in Node-Red
Home › Forums › Conduit: AEP Model › Get/Set Network Server configuration in Node-Red
- This topic has 3 replies, 2 voices, and was last updated 8 years, 1 month ago by Albert Beukman.
-
AuthorPosts
-
March 24, 2016 at 6:06 pm #11960Albert BeukmanParticipant
I am using a Conduit: AEP v1.1.2.
Is there any way to get/set the LoRa Network server configuration – specifically receive window 2 data rate – from the Node-Red environment?
Thanks and kind regards,
Albert.March 28, 2016 at 7:47 am #11966Jeff HatchKeymasterAlbert,
You can make an API request to get or set the rx2Datarate. You can use something very similar to the example at
http://www.multitech.net/developer/software/aep/node-red-and-rest-api-cloud-service/
Instead of going to some Xivley or M2X server you will go to localhost (127.0.0.1) and do PUT/GET to api/loraNetwork/lora/rx2Datarate.
Jeff
March 28, 2016 at 1:31 pm #11968Albert BeukmanParticipantThanks Jeff
The GET works like a treat. I will try the PUT next.
For forum reference, the Node-Red HTTP request node allows for basic authentication, which makes for a very simple flow when retrieving a param. You can also build these credentials up in the header as below.
var vUsername = "username";
var vPassword = "password";
var vHeader = vUsername + ":" + vPassword;msg.headers = {"Authorization": "Basic " + vHeader.toString('base64') };
msg.method = "GET";
msg.url = "https://127.0.0.1/api/loraNetwork/lora/rx2Datarate";return msg;
March 28, 2016 at 2:31 pm #11969Albert BeukmanParticipantJeff;
No cigar yet on the PUT/POST request.
I’ve tried 2 basic approaches without success and posted my results below. I’d appreciate input.
Node-Red setup as Inject-Function-HTTP Request-Debug. Function block setup and Debug output shown below.
Approach 1
var vUsername = "admin"; var vPassword = "password"; var vAuthHeader = vUsername + ":" + vPassword; var vPayload = {"rx2Datarate" : 10}; msg.headers = {"Authorization": "Basic " + vAuthHeader.toString('base64') }; msg.method = "PUT"; msg.url = "https://127.0.0.1/api/loraNetwork/lora/"; msg.payload = vPayload; return msg;
Output 1
{ "topic": "", "payload": "{\n \"code\" : 400,\n \"error\" : \"[rx2Datarate] property is not set\",\n \"status\" : \"fail\"\n}\n", "_msgid": "b29428dc.4d6bd8", "headers": { "cache-control": "no-cache", "content-type": "application/json", "transfer-encoding": "chunked", "date": "Mon, 28 Mar 2016 19:28:07 GMT", "server": "rcell" }, "method": "PUT", "url": "https://127.0.0.1/api/loraNetwork/lora/", "statusCode": 400 }
Approach 2
var vPayload = "10"; //Same Auth header construction as approach 1 msg.headers = {"Authorization": "Basic " + vAuthHeader.toString('base64') }; msg.method = "PUT"; msg.url = "https://127.0.0.1/api/loraNetwork/lora/rx2Datarate"; msg.payload = vPayload; return msg;
Output 2
{ "topic": "", "payload": "{\n \"code\" : 400,\n \"error\" : \"path [loraNetwork] leads to an incompatible element. Path Element Type [OBJECT] Update Data Element Type [NULL]\",\n \"status\" : \"fail\"\n}\n", "_msgid": "afd2e493.502d18", "headers": { "cache-control": "no-cache", "content-type": "application/json", "transfer-encoding": "chunked", "date": "Mon, 28 Mar 2016 19:30:55 GMT", "server": "rcell" }, "method": "PUT", "url": "https://127.0.0.1/api/loraNetwork/lora/rx2Datarate", "statusCode": 400 }
Exchanging the PUT with POST leads to different feedback, but failures nonetheless.
- This reply was modified 8 years, 1 month ago by Albert Beukman. Reason: Pedantic. Fix comment in approach 2
- This reply was modified 8 years, 1 month ago by Albert Beukman. Reason: Fix changed formatting after edit
-
AuthorPosts
- You must be logged in to reply to this topic.