Hello
I’m working on implementing a MQTT-SN client on Arduino[1] and a MQTT-SN gateway[2] on raspberry pi, which communicate over a nRF24L01+ Transceivers. I now want to implement the sleep mode and have questions regarding the sleep mode I myself could find the answers in the MQTT-SN Protocol Specification:
1) How does the gateway send the buffered messages to the client when the client does a CONNECT out of the Asleep mode? I understood the sequence when the client does a PING REQ out of the Asleep mode, where the gateway sends all buffered messages and terminates them with a PING RES message. Does the gateways send the buffered message when he receives the CONNECT message and terminates them with a CONNACK message analogous to the PING REQ and PING RES sequence?
2) When a client send a CONNECT out of the Asleep mode which field are required or considered? Does the ClientId have to be included and what happens if it does not match the ClientId of the initial CONNECT? Can the Will flag be set and the gateway must do the WILLTOPICREQ and WILLTOPIC round-trips also when he receives the CONNECT out of the Asleep mode.
Thanks for any insight.
Regards
Franz
1) How does the gateway send the buffered messages to the client when the client does a CONNECT out of the Asleep mode? I understood the sequence when the client does a PING REQ out of the Asleep mode, where the gateway sends all buffered messages and terminates them with a PING RES message. Does the gateways send the buffered message when he receives the CONNECT message and terminates them with a CONNACK message analogous to the PING REQ and PING RES sequence?
When a client send a CONNECT out of the Asleep mode which field are required or considered? Does the ClientId have to be included and what happens if it does not match the ClientId of the initial CONNECT?
Can the Will flag be set and the gateway must do the WILLTOPICREQ and WILLTOPIC round-trips also when he receives the CONNECT out of the Asleep mode.
1) How does the gateway send the buffered messages to the client when the client does a CONNECT out of the Asleep mode? I understood the sequence when the client does a PING REQ out of the Asleep mode, where the gateway sends all buffered messages and terminates them with a PING RES message. Does the gateways send the buffered message when he receives the CONNECT message and terminates them with a CONNACK message analogous to the PING REQ and PING RES sequence?
I have asked the same question some time ago, but had never got an answer. I solved this problem exactly as you described: the gateway receives the CONNECT message, sends the buffered PUBLISH messages, and ends with the CONNACK message[1].
When a client send a CONNECT out of the Asleep mode which field are required or considered? Does the ClientId have to be included and what happens if it does not match the ClientId of the initial CONNECT?
I suppose the ClientId field have to be included, otherwise how does the gateway recognize the client?
Can the Will flag be set and the gateway must do the WILLTOPICREQ and WILLTOPIC round-trips also when he receives the CONNECT out of the Asleep mode.
If the client sets the Will flag in the CONNECT message the gateway have to send the WILLTOPICREQ and WILLTOPIC messages.
When a client send a CONNECT out of the Asleep mode which field are required or considered? Does the ClientId have to be included and what happens if it does not match the ClientId of the initial CONNECT?
I suppose the ClientId field have to be included, otherwise how does the gateway recognize the client?Since after a successful connect the other messages like PUBLISH or SUBSCRIBE also do not contain the ClientId i use the 'address' or 'node id' of the sensor network as the key to find the client. Therefore I thought I also could use that on the connect from sleep since in my sensor network the client keeps the same 'node id' even when it sleeps, but maybe that is not the case in all possible sensor networks. But I think at least as long as a client is in the Active state it should not change its 'address' or 'node id' since this is the only key to identify it.
I have another difficulty. My wireless sensors are based on the microcontrollers with a fairly limited ROM and RAM capacity. Therefore MQTT-SN client should be programmed as a simple state machine with the pre-defined states. This means that the client have to know what it should do each time it receives the message from the gateway: send the response message to the gateway or go to the sleep mode.
Everything seems ok, except the SUBACK message from the gateway. It is unclear whether the client may continue the initial connection procedure or it must wait for the PUBLISH messages from the gateway. I see two options to resolve this problem:
1. The SUBACK and PUBLISH messages should have some additional information about the number of buffered messages that a gateway has in its outbound queue.
2. The gateway should not send the PUBLISH messages in the same CONNECT-DISCONNECT session, where it receives the SUBSCRIBE message.
Have you another ideas?