Get/Set Network Server configuration in Node-Red

Home Forums Conduit: AEP Model Get/Set Network Server configuration in Node-Red

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #11960
    Albert Beukman
    Participant

    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.

    #11966
    Jeff Hatch
    Keymaster

    Albert,

    You can make an API request to get or set the rx2Datarate. You can use something very similar to the example at

    Connect Node-RED to Any Cloud Service’s REST API

    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

    #11968
    Albert Beukman
    Participant

    Thanks 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;

    #11969
    Albert Beukman
    Participant

    Jeff;

    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, 8 months ago by Albert Beukman. Reason: Pedantic. Fix comment in approach 2
    • This reply was modified 8 years, 8 months ago by Albert Beukman. Reason: Fix changed formatting after edit
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.