Update flip monitor
This commit is contained in:
@@ -93,6 +93,8 @@ typedef struct {
|
||||
ConnectionState conn_state;
|
||||
char ip_address[32];
|
||||
|
||||
uint32_t connecting_start_tick; // Time when INIT was sent or ACK received
|
||||
|
||||
volatile bool running;
|
||||
volatile bool send_init;
|
||||
} CanMonitorApp;
|
||||
@@ -344,6 +346,8 @@ static void process_line(CanMonitorApp* app, const char* line) {
|
||||
if(parse_ack(line, app->ip_address, sizeof(app->ip_address))) {
|
||||
FURI_LOG_I(TAG, "ACK received, IP: %s", app->ip_address);
|
||||
app->conn_state = StateConnected;
|
||||
// Reset tick for data waiting timeout
|
||||
app->connecting_start_tick = furi_get_tick();
|
||||
}
|
||||
} else if(app->conn_state == StateConnected) {
|
||||
// Parse PAGE or RESULT
|
||||
@@ -389,6 +393,7 @@ static int32_t worker_thread(void* ctx) {
|
||||
|
||||
furi_mutex_acquire(app->mutex, FuriWaitForever);
|
||||
app->conn_state = StateConnecting;
|
||||
app->connecting_start_tick = furi_get_tick();
|
||||
clear_page_content(&app->page);
|
||||
furi_mutex_release(app->mutex);
|
||||
view_port_update(app->view_port);
|
||||
@@ -423,7 +428,32 @@ static int32_t worker_thread(void* ctx) {
|
||||
furi_mutex_acquire(app->mutex, FuriWaitForever);
|
||||
if(app->conn_state == StateConnected && app->page.data_valid) {
|
||||
if((furi_get_tick() - app->page.last_update_tick) > 5000) {
|
||||
// Data timeout - RPi likely restarted, go back to disconnected state
|
||||
// This allows user to reconnect by pressing OK
|
||||
FURI_LOG_W(TAG, "Data timeout, disconnecting");
|
||||
app->conn_state = StateDisconnected;
|
||||
app->page.data_valid = false;
|
||||
clear_page_content(&app->page);
|
||||
view_port_update(app->view_port);
|
||||
}
|
||||
}
|
||||
|
||||
// Check connecting timeout (3 sec) - ACK not received
|
||||
if(app->conn_state == StateConnecting) {
|
||||
if((furi_get_tick() - app->connecting_start_tick) > 3000) {
|
||||
// Connection timeout - RPi not responding, go back to disconnected
|
||||
FURI_LOG_W(TAG, "Connection timeout, no ACK received");
|
||||
app->conn_state = StateDisconnected;
|
||||
view_port_update(app->view_port);
|
||||
}
|
||||
}
|
||||
|
||||
// Check initial data timeout (5 sec) - ACK received but no PAGE data yet
|
||||
if(app->conn_state == StateConnected && !app->page.data_valid) {
|
||||
if((furi_get_tick() - app->connecting_start_tick) > 5000) {
|
||||
// No data received after ACK - RPi not sending data
|
||||
FURI_LOG_W(TAG, "Data wait timeout, no PAGE received after ACK");
|
||||
app->conn_state = StateDisconnected;
|
||||
view_port_update(app->view_port);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user