/* main.c - Application main entry point */ /* * Copyright (c) 2020 Olaf Landsiedel * * SPDX-License-Identifier: Apache-2.0 */ #include #include #include #include #include "record_storage.h" #include "tek_storage.h" #include "sync_service.h" #include "tracing.h" void main(void) { int err = 0; printk("Starting Contact-Tracing Wristband...\n"); // Use custom randomization as the mbdet_tls context initialization messes with the Zeyhr BLE stack. err = en_init(sys_csrand_get); if (err) { printk("Crypto init failed (err %d)\n", err); return; } err = record_storage_init(false); if (err) { printk("init record storage failed (err %d)\n", err); return; } err = tek_storage_init(false); if (err) { printk("init key storage failed (err %d)\n", err); return; } /* Initialize the Bluetooth Subsystem */ err = bt_enable(NULL); if (err) { printk("Bluetooth init failed (err %d)\n", err); return; } /* Initialize the Tracing Subsystem */ err = tracing_init(); if (err) { printk("Tracing init failed (err %d)\n", err); return; } /* Initialize the Gatt Subsystem */ err = sync_service_init(); if (err) { printk("Sync Service init failed (err %d)\n", err); return; } printk("Components initialized! Starting Tracing and Gatt...\n"); // We sleep for one second just k_sleep(K_MSEC(1000)); do { uint32_t tracing_sleep_ms = tracing_run(); uint32_t sync_sleep_ms = sync_service_run(); uint32_t sleep_ms = MIN(tracing_sleep_ms, sync_sleep_ms); //printk("Sleeping a bit (%u ms)...\n", sleep_ms); k_sleep(K_MSEC(sleep_ms)); // TODO: what to put here? } while (1); }