From 2639b39faff160b0f8fa02d68c9ec919672f343e Mon Sep 17 00:00:00 2001 From: olafland Date: Fri, 12 Jun 2020 12:25:31 +0200 Subject: [PATCH] move to from u32_t to uint32_t and so one to make all compilers happy --- src/contacts.c | 22 +++++++++++----------- src/contacts.h | 4 ++-- src/covid.c | 6 +++--- src/gatt-service.c | 42 +++++++++++++++++++++--------------------- src/main.c | 4 ++-- 5 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/contacts.c b/src/contacts.c index ee62a14..6ecc39c 100644 --- a/src/contacts.c +++ b/src/contacts.c @@ -25,10 +25,10 @@ #include "covid.h" typedef struct contact { - u32_t most_recent_contact_time; //TODO: what is the correct type here? - u32_t first_contact_time; //TODO: what is the correct type here? - u16_t cnt; - s8_t max_rssi; + uint32_t most_recent_contact_time; //TODO: what is the correct type here? + uint32_t first_contact_time; //TODO: what is the correct type here? + uint16_t cnt; + int8_t max_rssi; rolling_proximity_identifier_t rolling_proximity_identifier; associated_encrypted_metadata_t associated_encrypted_metadata; } contact_t; @@ -36,7 +36,7 @@ typedef struct contact { #define MAX_CONTACTS 1000 static contact_t contacts[MAX_CONTACTS]; -static u32_t contact_count = 0; +static uint32_t contact_count = 0; void print_rpi(rolling_proximity_identifier_t* rpi){ @@ -63,7 +63,7 @@ contact_t* find_contact(rolling_proximity_identifier_t* rpi, associated_encrypte return NULL; } -int check_add_contact(u32_t contact_time, rolling_proximity_identifier_t* rpi, associated_encrypted_metadata_t* aem, s8_t rssi){ +int check_add_contact(uint32_t contact_time, rolling_proximity_identifier_t* rpi, associated_encrypted_metadata_t* aem, int8_t rssi){ contact_t* contact = find_contact(rpi, aem); if( contact == NULL ){ if( contact_count >= MAX_CONTACTS ){ @@ -101,9 +101,9 @@ int check_add_contact(u32_t contact_time, rolling_proximity_identifier_t* rpi, a } typedef struct period_contact { - u32_t duration; - u16_t cnt; - s8_t max_rssi; //TODO also store avg rssi? + uint32_t duration; + uint16_t cnt; + int8_t max_rssi; //TODO also store avg rssi? rolling_proximity_identifier_t rolling_proximity_identifier; associated_encrypted_metadata_t associated_encrypted_metadata; } period_contact_t; @@ -118,7 +118,7 @@ typedef struct period_contacts{ static period_contacts_t period_contacts[PERIODS]; static int period_index = 0; -static s32_t next_infected_key_id = 0; +static int32_t next_infected_key_id = 0; //10 minutes are over and we got new keys. Time to also sort our short term contacts and move them to long-term log //TODO: move long-term storage to flash, as we have limited space in RAM @@ -207,7 +207,7 @@ void add_infected_key(period_t* period){ } -u32_t get_next_infected_key_id(){ +uint32_t get_next_infected_key_id(){ return next_infected_key_id; } diff --git a/src/contacts.h b/src/contacts.h index 33c47cd..195eb46 100644 --- a/src/contacts.h +++ b/src/contacts.h @@ -14,11 +14,11 @@ #include "covid.h" void init_contacts(); -int check_add_contact(u32_t contact_time, rolling_proximity_identifier_t* rpi, associated_encrypted_metadata_t* aem, s8_t rssi); +int check_add_contact(uint32_t contact_time, rolling_proximity_identifier_t* rpi, associated_encrypted_metadata_t* aem, int8_t rssi); void key_change(int current_period_index); void add_infected_key(period_t* period); -u32_t get_next_infected_key_id(); +uint32_t get_next_infected_key_id(); void print_rpi(rolling_proximity_identifier_t* rpi); void print_aem(associated_encrypted_metadata_t* aem); diff --git a/src/covid.c b/src/covid.c index db12b9a..98e1e5c 100644 --- a/src/covid.c +++ b/src/covid.c @@ -44,13 +44,13 @@ static struct bt_data ad[] = { BT_DATA(BT_DATA_SVC_DATA16, &covid_adv_svd, sizeof(covid_adv_svd_t)) }; - static void scan_cb(const bt_addr_le_t *addr, s8_t rssi, u8_t adv_type, struct net_buf_simple *buf) + static void scan_cb(const bt_addr_le_t *addr, int8_t rssi, uint8_t adv_type, struct net_buf_simple *buf) { if( adv_type == 3 ){ - u8_t len = 0; + uint8_t len = 0; while (buf->len > 1) { - u8_t type; + uint8_t type; len = net_buf_simple_pull_u8(buf); if (!len) { diff --git a/src/gatt-service.c b/src/gatt-service.c index 93adb85..f05ba83 100644 --- a/src/gatt-service.c +++ b/src/gatt-service.c @@ -94,16 +94,16 @@ static const struct bt_data ad[] = { 0x98, 0x6A, 0x9F, 0x69, 0x79, 0x0D, 0x11, 0xF2), }; -static ssize_t read_next_key(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset){ - u32_t id = get_next_infected_key_id(); +static ssize_t read_next_key(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset){ + uint32_t id = get_next_infected_key_id(); return bt_gatt_attr_read(conn, attr, buf, len, offset, &id, sizeof(id)); } -static ssize_t read_key_cnt(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset){ +static ssize_t read_key_cnt(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset){ unsigned int cnt = get_period_cnt_if_infected(); return bt_gatt_attr_read(conn, attr, buf, len, offset, &cnt, sizeof(unsigned int)); } -static ssize_t read_key_0(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset){ +static ssize_t read_key_0(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset){ size_t size = 0; period_t* p = get_period_if_infected(0, &size); // printk("read key 0, size %u, pointer %p\n", size, p); @@ -111,67 +111,67 @@ static ssize_t read_key_0(struct bt_conn *conn, const struct bt_gatt_attr *attr, // printk("RPI: "); print_rpi((rolling_proximity_identifier_t*)&p->periodKey); printk("\n"); return bt_gatt_attr_read(conn, attr, buf, len, offset, p, size); } -static ssize_t read_key_1(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset){ +static ssize_t read_key_1(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset){ size_t size = 0; period_t* p = get_period_if_infected(1, &size); return bt_gatt_attr_read(conn, attr, buf, len, offset, p, size); } -static ssize_t read_key_2(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset){ +static ssize_t read_key_2(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset){ size_t size = 0; period_t* p = get_period_if_infected(2, &size); return bt_gatt_attr_read(conn, attr, buf, len, offset, p, size); } -static ssize_t read_key_3(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset){ +static ssize_t read_key_3(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset){ size_t size = 0; period_t* p = get_period_if_infected(3, &size); return bt_gatt_attr_read(conn, attr, buf, len, offset, p, size); } -static ssize_t read_key_4(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset){ +static ssize_t read_key_4(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset){ size_t size = 0; period_t* p = get_period_if_infected(4, &size); return bt_gatt_attr_read(conn, attr, buf, len, offset, p, size); } -static ssize_t read_key_5(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset){ +static ssize_t read_key_5(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset){ size_t size = 0; period_t* p = get_period_if_infected(5, &size); return bt_gatt_attr_read(conn, attr, buf, len, offset, p, size); } -static ssize_t read_key_6(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset){ +static ssize_t read_key_6(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset){ size_t size = 0; period_t* p = get_period_if_infected(6, &size); return bt_gatt_attr_read(conn, attr, buf, len, offset, p, size); } -static ssize_t read_key_7(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset){ +static ssize_t read_key_7(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset){ size_t size = 0; period_t* p = get_period_if_infected(7, &size); return bt_gatt_attr_read(conn, attr, buf, len, offset, p, size); } -static ssize_t read_key_8(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset){ +static ssize_t read_key_8(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset){ size_t size = 0; period_t* p = get_period_if_infected(8, &size); return bt_gatt_attr_read(conn, attr, buf, len, offset, p, size); } -static ssize_t read_key_9(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset){ +static ssize_t read_key_9(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset){ size_t size = 0; period_t* p = get_period_if_infected(9, &size); return bt_gatt_attr_read(conn, attr, buf, len, offset, p, size); } -static ssize_t read_key_10(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset){ +static ssize_t read_key_10(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset){ size_t size = 0; period_t* p = get_period_if_infected(10, &size); return bt_gatt_attr_read(conn, attr, buf, len, offset, &p, size); } -static ssize_t read_key_11(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset){ +static ssize_t read_key_11(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset){ size_t size = 0; period_t* p = get_period_if_infected(11, &size); return bt_gatt_attr_read(conn, attr, buf, len, offset, &p, size); } -static ssize_t read_key_12(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset){ +static ssize_t read_key_12(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset){ size_t size = 0; period_t* p = get_period_if_infected(12, &size); return bt_gatt_attr_read(conn, attr, buf, len, offset, &p, size); } -static ssize_t read_key_13(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset){ +static ssize_t read_key_13(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset){ size_t size = 0; period_t* p = get_period_if_infected(13, &size); return bt_gatt_attr_read(conn, attr, buf, len, offset, &p, size); @@ -180,8 +180,8 @@ static ssize_t read_key_13(struct bt_conn *conn, const struct bt_gatt_attr *attr //TODO: copy more than one key static ssize_t write_new_key(struct bt_conn *conn, const struct bt_gatt_attr *attr, - const void *buf, u16_t len, u16_t offset, - u8_t flags) + const void *buf, uint16_t len, uint16_t offset, + uint8_t flags) { //printk("write key\n"); if( offset != 0 ){ @@ -197,7 +197,7 @@ static ssize_t write_new_key(struct bt_conn *conn, return len; } -static void connected(struct bt_conn *conn, u8_t err) +static void connected(struct bt_conn *conn, uint8_t err) { if (err) { @@ -207,7 +207,7 @@ static void connected(struct bt_conn *conn, u8_t err) } } -static void disconnected(struct bt_conn *conn, u8_t reason) +static void disconnected(struct bt_conn *conn, uint8_t reason) { //printk("Disconnected (reason 0x%02x)\n", reason); } diff --git a/src/main.c b/src/main.c index fc4c2c0..2111c5d 100644 --- a/src/main.c +++ b/src/main.c @@ -91,13 +91,13 @@ static struct gpio_callback button_0_cb_data; static struct gpio_callback button_1_cb_data; -void button_0_pressed(struct device *dev, struct gpio_callback *cb, u32_t pins){ +void button_0_pressed(struct device *dev, struct gpio_callback *cb, uint32_t pins){ set_infection(true); gpio_pin_set(dev, PIN, (int)1); printk("Button 0 (=infected) pressed at %" PRIu32 "\n", k_cycle_get_32()); } -void button_1_pressed(struct device *dev, struct gpio_callback *cb, u32_t pins){ +void button_1_pressed(struct device *dev, struct gpio_callback *cb, uint32_t pins){ set_infection(false); gpio_pin_set(dev, PIN, (int)0); printk("Button 1 (=healthy) pressed at %" PRIu32 "\n", k_cycle_get_32());