Skip to content

Commit 5dcc6f5

Browse files
committed
Implement syncstart command
1 parent d6fb02b commit 5dcc6f5

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

command_interface.c

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ extern volatile bool update_rtc;
2828

2929
extern volatile bool log_file_active;
3030

31+
static bool cat_in_progress = false;
3132
static lfs_file_t file_command_interface;
3233
static uint8_t lfs_file_buf[4096]; // Must be cache size
3334
static struct lfs_file_config lfs_file_config;
@@ -189,7 +190,7 @@ void command_interface_process_byte(char incoming)
189190
sprintf((char *)command_response_buffer, "cat,%s", filename);
190191
m_ble_tx_logbuffer(command_response_buffer, (size_t)strlen((const char *)command_response_buffer));
191192
bytes_sent = 0;
192-
sync_in_progress = true;
193+
cat_in_progress = true;
193194
}
194195
}
195196
else if(strncmp(command_input_buffer, "rm ", 3) == 0 && strlen(command_input_buffer) > 3)
@@ -241,7 +242,7 @@ void command_interface_process_byte(char incoming)
241242
}
242243
else if(strncmp(command_input_buffer, "version", 7) == 0)
243244
{
244-
sprintf((char *)command_response_buffer, "version,0.9.1,beta");
245+
sprintf((char *)command_response_buffer, "version,0.10.0,beta");
245246
m_ble_tx_logbuffer(command_response_buffer, strlen((const char *)command_response_buffer));
246247
}
247248
else if(strncmp(command_input_buffer, "getcfg", 6) == 0)
@@ -346,21 +347,40 @@ void command_interface_process_byte(char incoming)
346347

347348
m_ble_tx_logbuffer(command_response_buffer, strlen((const char *)command_response_buffer));
348349
}
350+
else if(strncmp(command_input_buffer, "syncstart", 9) == 0)
351+
{
352+
// Sync process is starting
353+
NRF_LOG_INFO("syncstart command received");
354+
NRF_LOG_FLUSH();
355+
if (!sync_in_progress)
356+
{
357+
sync_in_progress = true;
358+
NRF_LOG_INFO("sync_in_progress is now true");
359+
NRF_LOG_FLUSH();
360+
} else {
361+
NRF_LOG_INFO("sync_in_progress was already true");
362+
NRF_LOG_FLUSH();
363+
}
364+
}
349365
else if(strncmp(command_input_buffer, "syncstop", 8) == 0)
350366
{
351367
// Sync process was aborted by the user
352368
NRF_LOG_INFO("syncstop command received");
353369
NRF_LOG_FLUSH();
354370
if (sync_in_progress)
355371
{
356-
int close_result = lfs_file_close(m_lfs, &file_command_interface);
357-
NRF_LOG_INFO("lfs close result: %d", close_result);
358-
NRF_LOG_FLUSH();
359372
sync_in_progress = false;
360373
} else {
361374
NRF_LOG_INFO("sync_in_progress was false");
362375
NRF_LOG_FLUSH();
363376
}
377+
if (cat_in_progress)
378+
{
379+
int close_result = lfs_file_close(m_lfs, &file_command_interface);
380+
NRF_LOG_INFO("lfs close result: %d", close_result);
381+
NRF_LOG_FLUSH();
382+
cat_in_progress = false;
383+
}
364384
}
365385
else if(strncmp(command_input_buffer, "snooze,", 7) == 0)
366386
{
@@ -439,7 +459,7 @@ void command_interface_continue_transfer(char* command)
439459
NRF_LOG_INFO("cat close result: %d", close_result);
440460
NRF_LOG_FLUSH();
441461

442-
sync_in_progress = false;
462+
cat_in_progress = false;
443463
}
444464
else if(bytes_sent < file_command_interface.ctz.size)
445465
{

main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,6 +1866,13 @@ static void logging_timer_handler(void *p_context) {
18661866
static void telemetry_timer_handler(void *p_context) {
18671867
(void)p_context;
18681868

1869+
if (sync_in_progress)
1870+
{
1871+
NRF_LOG_INFO("Skipping telemetry");
1872+
NRF_LOG_FLUSH();
1873+
return;
1874+
}
1875+
18691876
// Set flag to write data when a response is received
18701877
write_logdata_now = true;
18711878

0 commit comments

Comments
 (0)