modem.connected() not reliable
sslupsky opened this issue · 0 comments
While debugging a problem where I observed that from time to time a packet is not sent, I believe I uncovered an issue with the connected() method.
To address the packet not sending issue, I retry resending the packet and if that fails several times, I restart the modem by calling begin() again. begin() asserts a reset pin on the murata module which I assume is a hard reset. After the begin() (and corresponding reset), connected() is called to check the join status. However, I have noticed that the connected() method is not a reliable means of determining join status. Rather, this function appears to return true if there is room in the receive buffer, or, if not, then the join status from the last join. Since the join status after a module reset is not reset, if the module was joined before reset, it will return true.
Along the way, I found a private method getJoinStatus(). This method polls the module for its join status. I think this is likely more reliable than using the connected() method.
I propose that the getJoinStatus() method should be made public. Also, I think the network_joined variable should be reset when begin() is called.
Last, what is the purpose of the call to available() in the connected() method? Should this be removed?