NODEMANAGER OTA CONFIGURATION per java script



  • Hello everybody,

    I'm new here. At first big thanks for the great mycontroller!!!

    I want to use the Nodemanager OTA configuration feature. I think the right methode is mcApi.sensor().sendRawMessage(message). But I haven't any idea how define the message. The Syntax of the mesesage looks like: <node_id>;<configuration_child_id>;<req>;0;<V_CUSTOM>;<child_id>,<function_id>,<value>
    for example: 100;200;2;0;48;0,4,10

    Have any one an example script?

    Best regards,
    TRex-600



  • @TRex-600 Welcome to MyController community. I will report an example soon.



  • @jkandasa
    That sounds great! I'm really looking forward to an example. Thank you in advance for your effort.



  • @TRex-600 Sorry for the delayed response.

    This script might help you. But I didn't test this. Please let me know if you see an issue.
    Type and SubType details are available in mycontroller source code

    var myImports = new JavaImporter(java.lang, java.util, org.mycontroller.standalone.utils.McUtils, org.mycontroller.standalone.message.IMessage);
    
    with(myImports) {
      // get your gateway via uuid
      var myGateway = mcApi.uidTag().getByUid("my-test-gateway").getResource();
      
      // Import message type
      var Message = Java.type("org.mycontroller.standalone.message.IMessage")
      
      // create message object
      var message = Message.getInstance()
      
      // set gateway id.
      message.setGatewayId(myGateway.id)
      
      // set node EUI
      message.setNodeEui("100")
        
      // set sensor id
      message.setSensorId("200")
      
      // set message type
      message.setType("Request")
      
      // set message sub type
      message.setSubType("Custom")
      
      // set acknowledgement
      message.setAck(0)
      
      // set payload
      message.setPayload("0,4,10")
      
      // send Raw Message
      mcApi.sensor().sendRawMessage(message);
    }
    
    


  • @jkandasa Thanks a lot for the example. The delay doesn't matter. I had already found a solution. But I didn't think this was good enough to publish. I take advantage of the fact that the mysensors nodes do not necessarily need a request message for the Ota function. So I got along with mcApi.sensor (). SendPayload ().

    When I have time again I'll try your better solution.


Log in to reply
 

Suggested Topics

3
Online

584
Users

472
Topics

2.9k
Posts