From 5db7593a4f9a96fafebb22e9c2736a13999654fe Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 21 Sep 2024 20:06:19 +0200 Subject: [PATCH] Ready to implement sync function on ESP32 device --- esp32_device/main/main.c | 16 ++++++++++++++++ esp32_device/main/secure_api.c | 6 ++++++ esp32_device/main/secure_api.h | 7 +++++++ 3 files changed, 29 insertions(+) diff --git a/esp32_device/main/main.c b/esp32_device/main/main.c index 0fc3759..a491b8c 100755 --- a/esp32_device/main/main.c +++ b/esp32_device/main/main.c @@ -164,7 +164,23 @@ void app_main(void) ESP_LOGI(TAG, "Current device certificate:\n%s", dev_certificate); free(dev_certificate); + // Main loop ESP_LOGI(TAG, "Starting main loop"); + + while (true) + { + if (!secure_api_sync_device()) + { + ESP_LOGE(TAG, "Failed to synchronise device!"); + } + else + { + ESP_LOGI(TAG, "Successfully synchronised device!"); + } + + system_sleep(10); + } + system_sleep(120); reboot(); diff --git a/esp32_device/main/secure_api.c b/esp32_device/main/secure_api.c index 156fd26..7200cc7 100644 --- a/esp32_device/main/secure_api.c +++ b/esp32_device/main/secure_api.c @@ -192,4 +192,10 @@ char *secure_api_get_dev_certificate() } return res; +} + +void *secure_api_sync_device() +{ + printf("here implement sync device logic\n"); + return NULL; } \ No newline at end of file diff --git a/esp32_device/main/secure_api.h b/esp32_device/main/secure_api.h index 9546095..4d486f2 100644 --- a/esp32_device/main/secure_api.h +++ b/esp32_device/main/secure_api.h @@ -40,6 +40,13 @@ extern "C" */ char *secure_api_get_dev_certificate(); + /** + * Synchronise device with central backend + * + * Returns NULL in case of failure + */ + void *secure_api_sync_device(); + #ifdef __cplusplus } #endif