RPC.call(RPC.LOCAL) sends method call to MQTT broker

  1. My goal is to get the output from Sys.GetInfo for further work within the code
  2. My actions were to follow the example from the documentation and here:
Event.on(Event.CLOUD_CONNECTED, function () {
  RPC.call(device_id, 'Sys.GetInfo', null, function (resp, err_code, err_msg, ud) {
    if (err_code !== 0) {
      Log.debug("Error: (" + JSON.stringify(err_code) + ') ' + err_msg);
    } else {
      Log.debug('Result: ' + JSON.stringify(resp));
    }
  }, null);
}, null);
  1. The result I see is that I get a message with the content {"src":"my_device_id","dst":"my_device_id","id":4069,"method":"Sys.GetInfo","params":} at the MQTT broker in the response topic.
  2. My expectation & question is that I would get the output of the response from the RPC.LOCAL call within the callback. I suspect, that RPC-MQTT redirects the RPC.call method directly to the MQTT broker.

I would really love to understand how I can redirect the output into the callback function.

Thanks a lot for your support.

Hey @nlsrchtr , I’m not sure I understand what you’re asking.

It sounds like you’re saying you want to intercept the call to Sys.GetInfo and do some extra stuff in that callback function. I’m not 100% sure but sounds to me like that wouldn’t be possible.

Not sure of your intention, but seems like it would be easier to replicate the RPC call in your own custom function and call that.

Hi @klimbot,

thanks for getting back to me and sorry, when my question was not clear enough. The problem is, that every call of:

sends the response to the connected MQTT broker. So the expected and correct answer can be found in the MQTT topic, but this was not my intention. I need the response of “Sys.GetInfo” within my code to work with the values further.

That’s why I tried with RPC.call(RPC.LOCAL) as well, but there was not change at all.

Any idea?

Thanks for your support.

Regards,

Do not try, just read the docs and do what they say.