CovidBracelet/src/main.c

71 lines
1.5 KiB
C
Raw Normal View History

/* main.c - Application main entry point */
/*
* Copyright (c) 2020 Olaf Landsiedel
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include <bluetooth/hci.h>
#include <random/rand32.h>
2021-01-26 16:14:58 +01:00
#include <sys/printk.h>
2021-04-12 19:52:06 +02:00
#include "record_storage.h"
#include "tek_storage.h"
#include "sync_service.h"
#include "tracing.h"
2021-06-14 15:44:07 +02:00
2021-01-26 16:14:58 +01:00
void main(void) {
2021-01-26 16:14:58 +01:00
int err = 0;
printk("Starting Contact-Tracing Wristband...\n");
2021-01-26 16:14:58 +01:00
// Use custom randomization as the mbdet_tls context initialization messes with the Zeyhr BLE stack.
err = en_init(sys_csrand_get);
2021-01-26 16:14:58 +01:00
if (err) {
printk("Crypto init failed (err %d)\n", err);
2021-01-26 16:14:58 +01:00
return;
}
err = record_storage_init(false);
2021-04-12 19:20:15 +02:00
if (err) {
printk("init record storage failed (err %d)\n", err);
2021-04-12 19:20:15 +02:00
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();
2021-01-26 16:14:58 +01:00
if (err) {
printk("Sync Service init failed (err %d)\n", err);
2021-01-26 16:14:58 +01:00
return;
}
printk("Components initialized! Starting Tracing and Gatt...\n");
2021-06-22 15:48:03 +02:00
do {
tracing_run();
sync_service_run();
} while (1);
}