Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

RPC.addHandler

I added the following code from the example to my init.js

RPC.addHandler('Example.Increment', function(args) {
    print(args);
    if (args !== undefined && args.num !== undefined) {
        return { num: args.num + 1 };
    } else {
        return { error: 'num is required' };
    }
}, null);

My ESP8266 is connected to iot.eclipse.org and I can send messages from my ESP and this works perfect. (I use hivemq)

When I send a message to my RPC channel (esp8266_XXXXXXX/rpc/Example.Increment, message: aaa, or {"a":2}
I get the following output in console. The message is not arriving ?

null 
[Jun 24 15:38:23.402]   at init.js:25
[Jun 24 15:38:23.402]   at api_rpc.js:35
[Jun 24 15:38:23.406] MJS callback error: type error

What is my mistake ?
Holger

Comments

Sign In or Register to comment.