Flood Mesh Getting Stuck in Central Mode where State is "DISCONNECTED"
Solution and Explanation Below
The error begins at this line in ble_process.c:
centralStartedTime = WatchDog_CurrentCount();
In the instance that centralStartedTime is set to a count of over 65490, we remain in Central until the power is shut off. This is because the following line will never be true:
(WatchDog_CurrentCount() - centralStartedTime > CENTRAL_STATE_SPAN)
If central started time is 65490 and the watchdog meets it's maximum value, 65535, the difference will only be 45. Since the central_state_span is exactly 45, and we are testing for greater than Central_State_Span, the statement will always be false. From there, it only gets worse, since the watchdog counter resets back to 0 and the centralStartedTime is never updated.
To remedy this, I have added the below code:
// This line is the current cypress example code (ble_process.c)
centralStartedTime = WatchDog_CurrentCount();
// The below have been added as a solution
if(centralStartedTime >= 65480){
current_watchdog_counter = 0;
centralStartedTime = 45;
}
I hope this fix is useful to someone in the future!
Best Regards,
Andy York
Director of Technology
The Lockout Co., LLC