Am I seeing double?
When I publish a RPC message via MQTT I see two messages in system log , I don’t see the same issue when I send via http (curl)
curl “http://192.168.0.103/rpc/relay” -d “{“name”:“RELAY1”, “cmd”: “SWITCH”}”
{“msg”:“ok”,“status”:“true”}
eg
mosquitto_pub -h mybroker -t esp32_8AD88C/rpc -m '{“method”:“relay”,“args”:{“name”:“TEST1”}}'
system log:
[Sep 19 13:07:41.718] mg_rpc.c:310 relay via MQTT
[Sep 19 13:07:41.718] args: {"name":"TEST1"}
[Sep 19 13:07:41.718] mg_rpc.c:310 relay via MQTT
[Sep 19 13:07:41.718] args: {"name":"TEST1"}
mjs : program …
// Load Mongoose OS API
load('api_timer.js');
load('api_gpio.js');
load('api_mqtt.js');
load('api_net.js');
load('api_config.js');
load('api_rpc.js');
RPC.addHandler('relay', function(args) {
let rc=true;
print("args:",JSON.stringify(args));
return {"status": rc };
});
// check if MQTT connection establised and sent init
MQTT.setEventHandler(function(conn, ev, edata) {
//check if connection to MQTT established
if(ev === MQTT.EV_CONNACK) {
print('MQTT Connected');
}
}, null);