From 2f955851e115c95d5b95942459c164de7be00951 Mon Sep 17 00:00:00 2001 From: Patrick Rathje Date: Thu, 16 Feb 2023 17:39:42 +0100 Subject: [PATCH] add variables for bloom test --- src/main.c | 79 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 34 deletions(-) diff --git a/src/main.c b/src/main.c index ebc5b6d..2783c10 100644 --- a/src/main.c +++ b/src/main.c @@ -21,6 +21,10 @@ #include "mbedtls/platform.h" +#define BLOOM_TEST 0 +#define CLEAN_INIT (BLOOM_TEST) + + #if BLOOM_TEST /** * Fill the bloom filter with all stored records. */ @@ -40,40 +44,7 @@ void fill_bloom_with_stored_records(bloom_filter_t* bloom) { } } -void main(void) { - - int err = 0; - printk("Starting Contact-Tracing Wristband...\n"); - - int ret = 0; - - if((ret = mbedtls_platform_setup(NULL)) != 0) { - mbedtls_printf("Platform initialization failed with error %d\r\n", ret); - return 1; - } - - // 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(true); - 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; - } - - k_msleep(10000); - +void bloom_test() { printk("Filling record storage...\n"); reset_record_storage(); @@ -149,4 +120,44 @@ void main(void) { } k_sleep(K_MSEC(2000)); } while (1); +} +#endif + +void main(void) { + + int err = 0; + printk("Starting Contact-Tracing Wristband...\n"); + + int ret = 0; + + if((ret = mbedtls_platform_setup(NULL)) != 0) { + mbedtls_printf("Platform initialization failed with error %d\r\n", ret); + return; + } + + // 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(CLEAN_INIT); + if (err) { + printk("init record storage failed (err %d)\n", err); + return; + } + + + err = tek_storage_init(CLEAN_INIT); + if (err) { + printk("init key storage failed (err %d)\n", err); + return; + } + + #if BLOOM_TEST + k_msleep(10000); + bloom_test(); + return; + #endif } \ No newline at end of file