Open tommasogiannoni opened 4 years ago
Hi @tommasogiannoni FTF, without seeing any code it's hard to guess exactly what's going on, also I couldn't understand well your second sentence, can you clarify what you cannot do? If you mean to say: 1) I want to see what the nodes receives from some specific mqtt-sn topic, you just need to subscribe to the topic and publish on the broker as a normal MQTT req. 2) You want to print what's coming from some topic, the built-in functions implemented does that like a charm Ps.: You DON'T run the cb function, callback stands for automatically triggered function that'll be called by the OS in the appropriate time.
Hi @aignacio, thanks for reply.
my question is about the mqtt_sn_callback(char *topic, char *message)
function:
void mqtt_sn_callback(char *topic, char *message) {
printf("\nMessage received:");
printf("\nTopic:%s Message:%s",topic,message);
}
My Mote publisher-subscriber do this:
mqtt_sn_init();
mqtt_sn_create_sck(mqtt_sn_connection, all_topics, ss(all_topics), mqtt_sn_callback);
mqtt_sn_sub('/topic_1',0);
and in the process main function, in a while(1)
loop:
mqtt_sn_pub("/topic_1", msg_to_snd, true, 0);
where msg_to_snd
is a simple string like "MSG[NODE ID: %d]"
So the second Mote that is only a subscriber:
mqtt_sn_init();
mqtt_sn_sub('/topic_1', 0);
and do nothing in the process main function.
there is also a border-router rpl mote, that print 'msg_to_snd'
every time.
So the function mqtt_sn_callback(char *topic, char *message)
is NEVER called.
I followed your guide, by starting rpl by doing this:
sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64
and start mqtt by doing this:
sudo ./broker_mqtts config.mqtt
where do I have to change to have the subscriber mote, subscribed to that topic ('/topic_1') automatically run callback function?
Thanks to for the help
R u sure that the first mote is publishing the messages in the brokers? Pls attached the log of the mqtt-sn broker to see if everything goes well in the pub side.
This is the Log:
https://ibb.co/GQY2VxK https://ibb.co/Sm3N20V
3 Mote: Mote 1 is the rpl-border.router Mote 2 is the publisher main_core.c Mote 3 is the subscriber.
The rpl-border router print message that was sent by mote 2, but the mote 3 don't run callback never.
@tommasogiannoni can you provide the BROKER log as well? I wanna check if the publisher is pub. properly as it meant to be
@aignacio How can i log the broker? You mean the rpl-border-router ?
Thanks for help !
This is what the command sudo ./broker_mqtts config.mqtt
log to terminal during simulation:
https://ibb.co/DVD5DX4
Hi @tommasogiannoni can you confirm if the device_id is different for the two motes? I'm asking this cause in your log seems to have a dupplicate attempt connection. Also, in the fw of both motes r u registering all topics that you use in this structure? This needs to be done because in the MQTT-SN protocol, we don't use the full topic name, we use topic ids that must be previously registered and this is done in this line and this ones
How can i show message received by subscriber ?
I have 1
rpl-border-router
and 2 mqtt-publisher-subscriber:main_core.c
When i start simulation i read message received by border router but i want that the subscriber mote show
'Message received..'
read from specific topic every clock time.I found this function:
mqtt_sn_recv_parser
But it never called. So how can i run callback function on subscriber and show message received from other mqtt-mote ?Thanks