diff --git a/epicardium/ble/ble.c b/epicardium/ble/ble.c index e678739a6196bdf805a27f117231a484b861e877..5f5ffda19a45bcb22229c305b01fe92eb65dd23d 100644 --- a/epicardium/ble/ble.c +++ b/epicardium/ble/ble.c @@ -309,7 +309,30 @@ static void ble_log_flush(void) } } } +static void ble_log_rotate(void) +{ + int i; + char filename_old[16]; + char filename_new[16]; + struct epic_stat stat; + + if (epic_file_stat("ble9.log", &stat) == 0) { + epic_file_unlink("ble9.log"); + } + for(i=8; i>0; i--) { + sprintf(filename_old, "ble%d.log", i); + sprintf(filename_new, "ble%d.log", i+1); + + if (epic_file_stat(filename_old, &stat) == 0) { + epic_file_rename(filename_old, filename_new); + } + } + + if (epic_file_stat("ble.log", &stat) == 0) { + epic_file_rename("ble.log", "ble1.log"); + } +} /*************************************************************************************************/ void vBleTask(void *pvParameters) { @@ -320,6 +343,7 @@ void vBleTask(void *pvParameters) */ vTaskDelay(pdMS_TO_TICKS(500)); + ble_log_rotate(); log_fd = epic_file_open("ble.log", "w"); epic_file_write(log_fd, log_header, sizeof(log_header)); /* We are going to execute FreeRTOS functions from callbacks