Skip to content
Snippets Groups Projects
Commit 7af9b7ec authored by schneider's avatar schneider
Browse files

feat(ble): Rotate log

parent 87c87cf3
No related branches found
No related tags found
No related merge requests found
...@@ -309,7 +309,30 @@ static void ble_log_flush(void) ...@@ -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) void vBleTask(void *pvParameters)
{ {
...@@ -320,6 +343,7 @@ void vBleTask(void *pvParameters) ...@@ -320,6 +343,7 @@ void vBleTask(void *pvParameters)
*/ */
vTaskDelay(pdMS_TO_TICKS(500)); vTaskDelay(pdMS_TO_TICKS(500));
ble_log_rotate();
log_fd = epic_file_open("ble.log", "w"); log_fd = epic_file_open("ble.log", "w");
epic_file_write(log_fd, log_header, sizeof(log_header)); epic_file_write(log_fd, log_header, sizeof(log_header));
/* We are going to execute FreeRTOS functions from callbacks /* We are going to execute FreeRTOS functions from callbacks
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment