sfranzyshen wrote: the node timeout value isn't being applied to the equation as expected ...
lastrecieved (4289636273) + timeout (10000000) = 4299636273 ... but that doesn't match the results ...
because 4299636273 is NOT less than 4289641320 (but 4289636273 is) ...
@sfranzyshen:
I think the answer to this problem comes in the max value of uint32_t which is 4,294,967,295.
However, as you pointed out 'lastreceieved+timeout' yielded 4,299,636,273 which is greater than the max of uint32_t.
Hence, the comparison operation: "connection->lastRecieved + NODE_TIMEOUT" can roll-over uint32_t and yield unwieldy results. I would use the following:
void ICACHE_FLASH_ATTR easyMesh::manageConnections( void ) {
debugMsg( GENERAL, "manageConnections():\n");
uint32_t nowNodeTime;
uint32_t timeOut=NODE_TIMEOUT/1000; // Resolves it to a milli-second count
uint32_t _lastReceived;
SimpleList<meshConnectionType>::iterator connection = _connections.begin();
while ( connection != _connections.end() ) {
_lastReceived=connection->lastRecieved/1000; // Resolves it to a milli-second count
nowNodeTime = getNodeTime()/1000; // Resolves it to a milli-second count
if ( ( _lastReceived+timeOut ) < nowNodeTime ) {
debugMsg( CONNECTION, "manageConnections(): dropping %d timeout=%u + last=%u (%u) <
now=%u\n", connection->chipId, NODE_TIMEOUT, connection->lastRecieved,
connection->lastRecieved+NODE_TIMEOUT, nowNodeTime );
connection = closeConnection( connection );
continue;
}
}
}
The above code would detect time-outs on a milli-second basis and serves the purpose quite well. This prevents the disrupts caused by the roll-overs.
EDIT: Had this reply typed in early in the day, forgot to post