If you are asking a question, please follow this template:
- My goal is: [Accessing device info and transfer it over MQTT]
- My actions are:
So basically I want to access Sys.GetInfo RPC locally and send its response over mqtt and here is code I try :-
`
let deviceInfo = "test" ;
RPC.addHandler('Token_verify', function(args) {
RPC.call(RPC.LOCAL, 'Sys.GetInfo', null, function(resp, ud) {
deviceInfo = JSON.stringify(resp);
}, null);
if (typeof(args) === 'object' && typeof(args.token) === 'number') {
MQTT.pub('my/topic',args.token );
MQTT.pub('my/topic',deviceInfo );
return deviceInfo;
} else {
return "Fail"
}
})
`
-
The result I see is:
First time I call this RPC it returns test and second time it return device structure. -
My expectation & question is: So here expectation is result should be returned correctly at first time.
Thanks
PS: I am new to js.