From 78f95c5b7f05e40bcec4cf3493522044661728a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Kopy=C5=9Bci=C5=84ski?= Date: Thu, 5 Nov 2020 12:21:45 +0100 Subject: [PATCH] mesh: replace zephyr integer types with C99 types this is port of a1b77fd589dbe7284c17b029f251426a724abd47 --- apps/blemesh/src/main.c | 2 +- apps/blemesh_light/src/light_model.c | 30 +- apps/blemesh_light/src/light_model.h | 12 +- apps/blemesh_light/src/main.c | 4 +- apps/blemesh_models_example_1/src/main.c | 32 +- apps/blemesh_models_example_2/src/ble_mesh.c | 6 +- .../src/device_composition.c | 144 ++-- .../src/device_composition.h | 122 +-- apps/blemesh_models_example_2/src/main.c | 24 +- apps/blemesh_models_example_2/src/publisher.c | 8 +- .../src/state_binding.c | 42 +- .../src/state_binding.h | 10 +- apps/blemesh_models_example_2/src/storage.c | 14 +- apps/blemesh_models_example_2/src/storage.h | 4 +- .../blemesh_models_example_2/src/transition.c | 28 +- .../blemesh_models_example_2/src/transition.h | 30 +- apps/blemesh_shell/src/main.c | 10 +- apps/bttester/src/bttester.c | 44 +- apps/bttester/src/bttester.h | 754 +++++++++--------- apps/bttester/src/bttester_pipe.h | 6 +- apps/bttester/src/gap.c | 162 ++-- apps/bttester/src/gatt.c | 144 ++-- apps/bttester/src/glue.c | 4 +- apps/bttester/src/glue.h | 18 +- apps/bttester/src/l2cap.c | 46 +- apps/bttester/src/mesh.c | 144 ++-- apps/bttester/src/rtt_pipe.c | 8 +- apps/bttester/src/uart_pipe.c | 8 +- apps/mesh_badge/src/board.h | 6 +- apps/mesh_badge/src/gatt_svr.c | 10 +- apps/mesh_badge/src/mesh.c | 20 +- apps/mesh_badge/src/mesh.h | 4 +- apps/mesh_badge/src/reel_board.c | 32 +- nimble/host/mesh/include/mesh/access.h | 70 +- nimble/host/mesh/include/mesh/cdb.h | 48 +- nimble/host/mesh/include/mesh/cfg_cli.h | 226 +++--- nimble/host/mesh/include/mesh/cfg_srv.h | 40 +- nimble/host/mesh/include/mesh/glue.h | 59 +- nimble/host/mesh/include/mesh/health_cli.h | 34 +- nimble/host/mesh/include/mesh/health_srv.h | 18 +- nimble/host/mesh/include/mesh/main.h | 44 +- nimble/host/mesh/include/mesh/model_cli.h | 18 +- nimble/host/mesh/include/mesh/model_srv.h | 24 +- nimble/host/mesh/include/mesh/testing.h | 22 +- nimble/host/mesh/src/access.c | 70 +- nimble/host/mesh/src/access.h | 20 +- nimble/host/mesh/src/adv.c | 24 +- nimble/host/mesh/src/adv.h | 14 +- nimble/host/mesh/src/aes-ccm.c | 46 +- nimble/host/mesh/src/beacon.c | 30 +- nimble/host/mesh/src/cdb.c | 34 +- nimble/host/mesh/src/cfg_cli.c | 336 ++++---- nimble/host/mesh/src/cfg_srv.c | 276 +++---- nimble/host/mesh/src/crypto.c | 168 ++-- nimble/host/mesh/src/crypto.h | 138 ++-- nimble/host/mesh/src/foundation.h | 34 +- nimble/host/mesh/src/friend.c | 158 ++-- nimble/host/mesh/src/friend.h | 20 +- nimble/host/mesh/src/glue.c | 14 +- nimble/host/mesh/src/health_cli.c | 52 +- nimble/host/mesh/src/health_srv.c | 34 +- nimble/host/mesh/src/light_model.c | 22 +- nimble/host/mesh/src/light_model.h | 12 +- nimble/host/mesh/src/lpn.c | 34 +- nimble/host/mesh/src/lpn.h | 6 +- nimble/host/mesh/src/mesh.c | 16 +- nimble/host/mesh/src/model_cli.c | 30 +- nimble/host/mesh/src/model_srv.c | 16 +- nimble/host/mesh/src/net.c | 84 +- nimble/host/mesh/src/net.h | 172 ++-- nimble/host/mesh/src/pb_adv.c | 48 +- nimble/host/mesh/src/pb_gatt.c | 10 +- nimble/host/mesh/src/prov.c | 122 +-- nimble/host/mesh/src/prov.h | 8 +- nimble/host/mesh/src/prov_bearer.h | 4 +- nimble/host/mesh/src/proxy.c | 54 +- nimble/host/mesh/src/proxy.h | 8 +- nimble/host/mesh/src/settings.c | 124 +-- nimble/host/mesh/src/shell.c | 290 +++---- nimble/host/mesh/src/testing.c | 24 +- nimble/host/mesh/src/testing.h | 12 +- nimble/host/mesh/src/transport.c | 192 ++--- nimble/host/mesh/src/transport.h | 58 +- porting/examples/linux_blemesh/ble.c | 2 +- 84 files changed, 2671 insertions(+), 2680 deletions(-) diff --git a/apps/blemesh/src/main.c b/apps/blemesh/src/main.c index 24c9950e6..dd61574c4 100644 --- a/apps/blemesh/src/main.c +++ b/apps/blemesh/src/main.c @@ -385,7 +385,7 @@ static int output_number(bt_mesh_output_action_t action, uint32_t number) return 0; } -static void prov_complete(u16_t net_idx, u16_t addr) +static void prov_complete(uint16_t net_idx, uint16_t addr) { console_printf("Local node provisioned, primary address 0x%04x\n", addr); } diff --git a/apps/blemesh_light/src/light_model.c b/apps/blemesh_light/src/light_model.c index 8b00e2c04..f666fe263 100644 --- a/apps/blemesh_light/src/light_model.c +++ b/apps/blemesh_light/src/light_model.c @@ -48,10 +48,10 @@ static uint16_t top_val; static uint32_t neopixel[WS2812_NUM_LED]; #endif -static u8_t gen_onoff_state; -static s16_t gen_level_state; +static uint8_t gen_onoff_state; +static int16_t gen_level_state; -static void light_set_lightness(u8_t percentage) +static void light_set_lightness(uint8_t percentage) { #if (!MYNEWT_VAL(USE_NEOPIXEL)) int rc; @@ -76,10 +76,10 @@ static void light_set_lightness(u8_t percentage) #endif #else int i; - u32_t lightness; - u8_t max_lightness = 0x1f; + uint32_t lightness; + uint8_t max_lightness = 0x1f; - lightness = (u8_t) (percentage * max_lightness / 100); + lightness = (uint8_t) (percentage * max_lightness / 100); for (i = 0; i < WS2812_NUM_LED; i++) { neopixel[i] = (lightness | lightness << 8 | lightness << 16); @@ -90,7 +90,7 @@ static void light_set_lightness(u8_t percentage) static void update_light_state(void) { - u16_t level = (u16_t)gen_level_state; + uint16_t level = (uint16_t)gen_level_state; int percent = 100 * level / 0xffff; if (gen_onoff_state == 0) { @@ -99,44 +99,44 @@ static void update_light_state(void) light_set_lightness((uint8_t) percent); } -int light_model_gen_onoff_get(struct bt_mesh_model *model, u8_t *state) +int light_model_gen_onoff_get(struct bt_mesh_model *model, uint8_t *state) { *state = gen_onoff_state; return 0; } -int light_model_gen_onoff_set(struct bt_mesh_model *model, u8_t state) +int light_model_gen_onoff_set(struct bt_mesh_model *model, uint8_t state) { gen_onoff_state = state; update_light_state(); return 0; } -int light_model_gen_level_get(struct bt_mesh_model *model, s16_t *level) +int light_model_gen_level_get(struct bt_mesh_model *model, int16_t *level) { *level = gen_level_state; return 0; } -int light_model_gen_level_set(struct bt_mesh_model *model, s16_t level) +int light_model_gen_level_set(struct bt_mesh_model *model, int16_t level) { gen_level_state = level; - if ((u16_t)gen_level_state > 0x0000) { + if ((uint16_t)gen_level_state > 0x0000) { gen_onoff_state = 1; } - if ((u16_t)gen_level_state == 0x0000) { + if ((uint16_t)gen_level_state == 0x0000) { gen_onoff_state = 0; } update_light_state(); return 0; } -int light_model_light_lightness_get(struct bt_mesh_model *model, s16_t *lightness) +int light_model_light_lightness_get(struct bt_mesh_model *model, int16_t *lightness) { return light_model_gen_level_get(model, lightness); } -int light_model_light_lightness_set(struct bt_mesh_model *model, s16_t lightness) +int light_model_light_lightness_set(struct bt_mesh_model *model, int16_t lightness) { return light_model_gen_level_set(model, lightness); } diff --git a/apps/blemesh_light/src/light_model.h b/apps/blemesh_light/src/light_model.h index 7fcdd0c32..1f6f3c44a 100644 --- a/apps/blemesh_light/src/light_model.h +++ b/apps/blemesh_light/src/light_model.h @@ -26,12 +26,12 @@ #include "syscfg/syscfg.h" #include "mesh/mesh.h" -int light_model_gen_onoff_get(struct bt_mesh_model *model, u8_t *state); -int light_model_gen_onoff_set(struct bt_mesh_model *model, u8_t state); -int light_model_gen_level_get(struct bt_mesh_model *model, s16_t *level); -int light_model_gen_level_set(struct bt_mesh_model *model, s16_t level); -int light_model_light_lightness_get(struct bt_mesh_model *model, s16_t *lightness); -int light_model_light_lightness_set(struct bt_mesh_model *model, s16_t lightness); +int light_model_gen_onoff_get(struct bt_mesh_model *model, uint8_t *state); +int light_model_gen_onoff_set(struct bt_mesh_model *model, uint8_t state); +int light_model_gen_level_get(struct bt_mesh_model *model, int16_t *level); +int light_model_gen_level_set(struct bt_mesh_model *model, int16_t level); +int light_model_light_lightness_get(struct bt_mesh_model *model, int16_t *lightness); +int light_model_light_lightness_set(struct bt_mesh_model *model, int16_t lightness); int light_model_init(void); #endif diff --git a/apps/blemesh_light/src/main.c b/apps/blemesh_light/src/main.c index 51d86eb56..70deede10 100644 --- a/apps/blemesh_light/src/main.c +++ b/apps/blemesh_light/src/main.c @@ -31,8 +31,8 @@ #include "light_model.h" -static void model_bound_cb(u16_t addr, struct bt_mesh_model *model, - u16_t key_idx) +static void model_bound_cb(uint16_t addr, struct bt_mesh_model *model, + uint16_t key_idx) { int rc; diff --git a/apps/blemesh_models_example_1/src/main.c b/apps/blemesh_models_example_1/src/main.c index ef398c9f3..6040ab18d 100644 --- a/apps/blemesh_models_example_1/src/main.c +++ b/apps/blemesh_models_example_1/src/main.c @@ -213,9 +213,9 @@ static const struct bt_mesh_model_op gen_onoff_cli_op[] = { }; struct onoff_state { - u8_t current; - u8_t previous; - u8_t led_gpio_pin; + uint8_t current; + uint8_t previous; + uint8_t led_gpio_pin; }; /* @@ -320,20 +320,20 @@ static const struct bt_mesh_comp comp = { }; struct sw { - u8_t sw_num; - u8_t onoff_state; + uint8_t sw_num; + uint8_t onoff_state; struct os_callout button_work; struct os_callout button_timer; }; -static u8_t button_press_cnt; +static uint8_t button_press_cnt; static struct sw sw; -static u8_t trans_id; -static u32_t time, last_time; -static u16_t primary_addr; -static u16_t primary_net_idx; +static uint8_t trans_id; +static uint32_t time, last_time; +static uint16_t primary_addr; +static uint16_t primary_net_idx; /* * Generic OnOff Model Server Message Handlers @@ -416,7 +416,7 @@ static void gen_onoff_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t state; + uint8_t state; state = net_buf_simple_pull_u8(buf); @@ -424,7 +424,7 @@ static void gen_onoff_status(struct bt_mesh_model *model, bt_mesh_model_elem(model)->addr, ctx->addr, state); } -static int output_number(bt_mesh_output_action_t action, u32_t number) +static int output_number(bt_mesh_output_action_t action, uint32_t number) { BT_INFO("OOB Number %u", number); return 0; @@ -436,7 +436,7 @@ static int output_string(const char *str) return 0; } -static void prov_complete(u16_t net_idx, u16_t addr) +static void prov_complete(uint16_t net_idx, uint16_t addr) { BT_INFO("provisioning complete for net_idx 0x%04x addr 0x%04x", net_idx, addr); @@ -449,7 +449,7 @@ static void prov_reset(void) bt_mesh_prov_enable(BT_MESH_PROV_ADV | BT_MESH_PROV_GATT); } -static u8_t dev_uuid[16] = MYNEWT_VAL(BLE_MESH_DEV_UUID); +static uint8_t dev_uuid[16] = MYNEWT_VAL(BLE_MESH_DEV_UUID); #define BUTTON_DEBOUNCE_DELAY_MS 250 @@ -528,7 +528,7 @@ static void button_pressed_worker(struct os_event *work) struct bt_mesh_model *mod_cli, *mod_srv; struct bt_mesh_model_pub *pub_cli, *pub_srv; struct sw *sw = work->ev_arg; - u8_t sw_idx = sw->sw_num; + uint8_t sw_idx = sw->sw_num; int err; mod_cli = mod_cli_sw[sw_idx]; @@ -599,7 +599,7 @@ static const struct bt_mesh_prov prov = { .reset = prov_reset, }; -void init_led(u8_t dev) +void init_led(uint8_t dev) { hal_gpio_init_out(onoff_state_arr[dev].led_gpio_pin, 1); } diff --git a/apps/blemesh_models_example_2/src/ble_mesh.c b/apps/blemesh_models_example_2/src/ble_mesh.c index 86d4c5152..021d8e085 100644 --- a/apps/blemesh_models_example_2/src/ble_mesh.c +++ b/apps/blemesh_models_example_2/src/ble_mesh.c @@ -34,7 +34,7 @@ #ifdef OOB_AUTH_ENABLE -static int output_number(bt_mesh_output_action_t action, u32_t number) +static int output_number(bt_mesh_output_action_t action, uint32_t number) { printk("OOB Number: %lu\n", number); return 0; @@ -48,7 +48,7 @@ static int output_string(const char *str) #endif -static void prov_complete(u16_t net_idx, u16_t addr) +static void prov_complete(uint16_t net_idx, uint16_t addr) { printk("Local node provisioned, primary address 0x%04x\n", addr); } @@ -58,7 +58,7 @@ static void prov_reset(void) bt_mesh_prov_enable(BT_MESH_PROV_ADV | BT_MESH_PROV_GATT); } -static u8_t dev_uuid[16] = MYNEWT_VAL(BLE_MESH_DEV_UUID); +static uint8_t dev_uuid[16] = MYNEWT_VAL(BLE_MESH_DEV_UUID); static const struct bt_mesh_prov prov = { .uuid = dev_uuid, diff --git a/apps/blemesh_models_example_2/src/device_composition.c b/apps/blemesh_models_example_2/src/device_composition.c index b638b8610..72bda4b2c 100644 --- a/apps/blemesh_models_example_2/src/device_composition.c +++ b/apps/blemesh_models_example_2/src/device_composition.c @@ -224,8 +224,8 @@ static void gen_onoff_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t tid, onoff, tt, delay; - s64_t now; + uint8_t tid, onoff, tt, delay; + int64_t now; struct generic_onoff_state *state = model->user_data; onoff = net_buf_simple_pull_u8(buf); @@ -290,8 +290,8 @@ static void gen_onoff_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t tid, onoff, tt, delay; - s64_t now; + uint8_t tid, onoff, tt, delay; + int64_t now; struct generic_onoff_state *state = model->user_data; onoff = net_buf_simple_pull_u8(buf); @@ -422,12 +422,12 @@ static void gen_level_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t tid, tt, delay; - s16_t level; - s64_t now; + uint8_t tid, tt, delay; + int16_t level; + int64_t now; struct generic_level_state *state = model->user_data; - level = (s16_t) net_buf_simple_pull_le16(buf); + level = (int16_t) net_buf_simple_pull_le16(buf); tid = net_buf_simple_pull_u8(buf); now = k_uptime_get(); @@ -494,12 +494,12 @@ static void gen_level_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t tid, tt, delay; - s16_t level; - s64_t now; + uint8_t tid, tt, delay; + int16_t level; + int64_t now; struct generic_level_state *state = model->user_data; - level = (s16_t) net_buf_simple_pull_le16(buf); + level = (int16_t) net_buf_simple_pull_le16(buf); tid = net_buf_simple_pull_u8(buf); now = k_uptime_get(); @@ -569,12 +569,12 @@ static void gen_delta_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t tid, tt, delay; - s32_t tmp32, delta; - s64_t now; + uint8_t tid, tt, delay; + int32_t tmp32, delta; + int64_t now; struct generic_level_state *state = model->user_data; - delta = (s32_t) net_buf_simple_pull_le32(buf); + delta = (int32_t) net_buf_simple_pull_le32(buf); tid = net_buf_simple_pull_u8(buf); now = k_uptime_get(); @@ -658,12 +658,12 @@ static void gen_delta_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t tid, tt, delay; - s32_t tmp32, delta; - s64_t now; + uint8_t tid, tt, delay; + int32_t tmp32, delta; + int64_t now; struct generic_level_state *state = model->user_data; - delta = (s32_t) net_buf_simple_pull_le32(buf); + delta = (int32_t) net_buf_simple_pull_le32(buf); tid = net_buf_simple_pull_u8(buf); now = k_uptime_get(); @@ -805,13 +805,13 @@ static void gen_move_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t tid, tt, delay; - s16_t delta; - s32_t tmp32; - s64_t now; + uint8_t tid, tt, delay; + int16_t delta; + int32_t tmp32; + int64_t now; struct generic_level_state *state = model->user_data; - delta = (s16_t) net_buf_simple_pull_le16(buf); + delta = (int16_t) net_buf_simple_pull_le16(buf); tid = net_buf_simple_pull_u8(buf); now = k_uptime_get(); @@ -886,13 +886,13 @@ static void gen_move_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t tid, tt, delay; - s16_t delta; - s32_t tmp32; - s64_t now; + uint8_t tid, tt, delay; + int16_t delta; + int32_t tmp32; + int64_t now; struct generic_level_state *state = model->user_data; - delta = (s16_t) net_buf_simple_pull_le16(buf); + delta = (int16_t) net_buf_simple_pull_le16(buf); tid = net_buf_simple_pull_u8(buf); now = k_uptime_get(); @@ -1021,7 +1021,7 @@ static bool gen_def_trans_time_setunack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t tt; + uint8_t tt; struct gen_def_trans_time_state *state = model->user_data; tt = net_buf_simple_pull_u8(buf); @@ -1122,7 +1122,7 @@ static bool gen_onpowerup_setunack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t onpowerup; + uint8_t onpowerup; struct generic_onpowerup_state *state = model->user_data; onpowerup = net_buf_simple_pull_u8(buf); @@ -1187,9 +1187,9 @@ static void vnd_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t tid; + uint8_t tid; int current; - s64_t now; + int64_t now; struct vendor_state *state = model->user_data; current = net_buf_simple_pull_le16(buf); @@ -1290,9 +1290,9 @@ static void light_lightness_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t tid, tt, delay; - u16_t actual; - s64_t now; + uint8_t tid, tt, delay; + uint16_t actual; + int64_t now; struct light_lightness_state *state = model->user_data; actual = net_buf_simple_pull_le16(buf); @@ -1360,9 +1360,9 @@ static void light_lightness_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t tid, tt, delay; - u16_t actual; - s64_t now; + uint8_t tid, tt, delay; + uint16_t actual; + int64_t now; struct light_lightness_state *state = model->user_data; actual = net_buf_simple_pull_le16(buf); @@ -1483,9 +1483,9 @@ static void light_lightness_linear_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t tid, tt, delay; - u16_t linear; - s64_t now; + uint8_t tid, tt, delay; + uint16_t linear; + int64_t now; struct light_lightness_state *state = model->user_data; linear = net_buf_simple_pull_le16(buf); @@ -1546,9 +1546,9 @@ static void light_lightness_linear_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t tid, tt, delay; - u16_t linear; - s64_t now; + uint8_t tid, tt, delay; + uint16_t linear; + int64_t now; struct light_lightness_state *state = model->user_data; linear = net_buf_simple_pull_le16(buf); @@ -1690,7 +1690,7 @@ static void light_lightness_default_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u16_t lightness; + uint16_t lightness; struct light_lightness_state *state = model->user_data; lightness = net_buf_simple_pull_le16(buf); @@ -1741,7 +1741,7 @@ static bool light_lightness_range_setunack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u16_t min, max; + uint16_t min, max; struct light_lightness_state *state = model->user_data; min = net_buf_simple_pull_le16(buf); @@ -1908,15 +1908,15 @@ static void light_ctl_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t tid, tt, delay; - s16_t delta_uv; - u16_t lightness, temp; - s64_t now; + uint8_t tid, tt, delay; + int16_t delta_uv; + uint16_t lightness, temp; + int64_t now; struct light_ctl_state *state = model->user_data; lightness = net_buf_simple_pull_le16(buf); temp = net_buf_simple_pull_le16(buf); - delta_uv = (s16_t) net_buf_simple_pull_le16(buf); + delta_uv = (int16_t) net_buf_simple_pull_le16(buf); tid = net_buf_simple_pull_u8(buf); if (temp < TEMP_MIN || temp > TEMP_MAX) { @@ -1991,15 +1991,15 @@ static void light_ctl_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t tid, tt, delay; - s16_t delta_uv; - u16_t lightness, temp; - s64_t now; + uint8_t tid, tt, delay; + int16_t delta_uv; + uint16_t lightness, temp; + int64_t now; struct light_ctl_state *state = model->user_data; lightness = net_buf_simple_pull_le16(buf); temp = net_buf_simple_pull_le16(buf); - delta_uv = (s16_t) net_buf_simple_pull_le16(buf); + delta_uv = (int16_t) net_buf_simple_pull_le16(buf); tid = net_buf_simple_pull_u8(buf); if (temp < TEMP_MIN || temp > TEMP_MAX) { @@ -2140,13 +2140,13 @@ static bool light_ctl_default_setunack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u16_t lightness, temp; - s16_t delta_uv; + uint16_t lightness, temp; + int16_t delta_uv; struct light_ctl_state *state = model->user_data; lightness = net_buf_simple_pull_le16(buf); temp = net_buf_simple_pull_le16(buf); - delta_uv = (s16_t) net_buf_simple_pull_le16(buf); + delta_uv = (int16_t) net_buf_simple_pull_le16(buf); /* Here, Model specification is silent about tid implementation */ @@ -2216,7 +2216,7 @@ static bool light_ctl_temp_range_setunack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u16_t min, max; + uint16_t min, max; struct light_ctl_state *state = model->user_data; min = net_buf_simple_pull_le16(buf); @@ -2384,14 +2384,14 @@ static void light_ctl_temp_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t tid, tt, delay; - s16_t delta_uv; - u16_t temp; - s64_t now; + uint8_t tid, tt, delay; + int16_t delta_uv; + uint16_t temp; + int64_t now; struct light_ctl_state *state = model->user_data; temp = net_buf_simple_pull_le16(buf); - delta_uv = (s16_t) net_buf_simple_pull_le16(buf); + delta_uv = (int16_t) net_buf_simple_pull_le16(buf); tid = net_buf_simple_pull_u8(buf); if (temp < TEMP_MIN || temp > TEMP_MAX) { @@ -2463,14 +2463,14 @@ static void light_ctl_temp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t tid, tt, delay; - s16_t delta_uv; - u16_t temp; - s64_t now; + uint8_t tid, tt, delay; + int16_t delta_uv; + uint16_t temp; + int64_t now; struct light_ctl_state *state = model->user_data; temp = net_buf_simple_pull_le16(buf); - delta_uv = (s16_t) net_buf_simple_pull_le16(buf); + delta_uv = (int16_t) net_buf_simple_pull_le16(buf); tid = net_buf_simple_pull_u8(buf); if (temp < TEMP_MIN || temp > TEMP_MAX) { diff --git a/apps/blemesh_models_example_2/src/device_composition.h b/apps/blemesh_models_example_2/src/device_composition.h index 38507195f..d0f054ee2 100644 --- a/apps/blemesh_models_example_2/src/device_composition.h +++ b/apps/blemesh_models_example_2/src/device_composition.h @@ -46,109 +46,109 @@ #define CANNOT_SET_RANGE_MAX 0x02 struct generic_onoff_state { - u8_t onoff; - u8_t target_onoff; + uint8_t onoff; + uint8_t target_onoff; - u8_t last_tid; - u16_t last_src_addr; - u16_t last_dst_addr; - s64_t last_msg_timestamp; + uint8_t last_tid; + uint16_t last_src_addr; + uint16_t last_dst_addr; + int64_t last_msg_timestamp; - s32_t tt_delta; + int32_t tt_delta; struct transition *transition; }; struct generic_level_state { - s16_t level; - s16_t target_level; + int16_t level; + int16_t target_level; - s16_t last_level; - s32_t last_delta; + int16_t last_level; + int32_t last_delta; - u8_t last_tid; - u16_t last_src_addr; - u16_t last_dst_addr; - s64_t last_msg_timestamp; + uint8_t last_tid; + uint16_t last_src_addr; + uint16_t last_dst_addr; + int64_t last_msg_timestamp; - s32_t tt_delta; + int32_t tt_delta; struct transition *transition; }; struct generic_onpowerup_state { - u8_t onpowerup; + uint8_t onpowerup; }; struct gen_def_trans_time_state { - u8_t tt; + uint8_t tt; }; struct vendor_state { int current; - u32_t response; - u8_t last_tid; - u16_t last_src_addr; - u16_t last_dst_addr; - s64_t last_msg_timestamp; + uint32_t response; + uint8_t last_tid; + uint16_t last_src_addr; + uint16_t last_dst_addr; + int64_t last_msg_timestamp; }; struct light_lightness_state { - u16_t linear; - u16_t target_linear; + uint16_t linear; + uint16_t target_linear; - u16_t actual; - u16_t target_actual; + uint16_t actual; + uint16_t target_actual; - u16_t last; - u16_t def; + uint16_t last; + uint16_t def; - u8_t status_code; - u16_t light_range_min; - u16_t light_range_max; - u32_t lightness_range; + uint8_t status_code; + uint16_t light_range_min; + uint16_t light_range_max; + uint32_t lightness_range; - u8_t last_tid; - u16_t last_src_addr; - u16_t last_dst_addr; - s64_t last_msg_timestamp; + uint8_t last_tid; + uint16_t last_src_addr; + uint16_t last_dst_addr; + int64_t last_msg_timestamp; - s32_t tt_delta_actual; - s32_t tt_delta_linear; + int32_t tt_delta_actual; + int32_t tt_delta_linear; struct transition *transition; }; struct light_ctl_state { - u16_t lightness; - u16_t target_lightness; + uint16_t lightness; + uint16_t target_lightness; - u16_t temp; - u16_t target_temp; + uint16_t temp; + uint16_t target_temp; - s16_t delta_uv; - s16_t target_delta_uv; + int16_t delta_uv; + int16_t target_delta_uv; - u8_t status_code; - u16_t temp_range_min; - u16_t temp_range_max; - u32_t temperature_range; + uint8_t status_code; + uint16_t temp_range_min; + uint16_t temp_range_max; + uint32_t temperature_range; - u16_t lightness_def; - u16_t temp_def; - u32_t lightness_temp_def; - s16_t delta_uv_def; + uint16_t lightness_def; + uint16_t temp_def; + uint32_t lightness_temp_def; + int16_t delta_uv_def; - u32_t lightness_temp_last; + uint32_t lightness_temp_last; - u8_t last_tid; - u16_t last_src_addr; - u16_t last_dst_addr; - s64_t last_msg_timestamp; + uint8_t last_tid; + uint16_t last_src_addr; + uint16_t last_dst_addr; + int64_t last_msg_timestamp; - s32_t tt_delta_lightness; - s32_t tt_delta_temp; - s32_t tt_delta_duv; + int32_t tt_delta_lightness; + int32_t tt_delta_temp; + int32_t tt_delta_duv; struct transition *transition; }; diff --git a/apps/blemesh_models_example_2/src/main.c b/apps/blemesh_models_example_2/src/main.c index 7c8d65e6e..741367b40 100644 --- a/apps/blemesh_models_example_2/src/main.c +++ b/apps/blemesh_models_example_2/src/main.c @@ -59,14 +59,14 @@ static void light_default_var_init(void) light_ctl_srv_user_data.temp_def = TEMP_MIN; light_ctl_srv_user_data.lightness_temp_last = - (u32_t) ((LIGHTNESS_MAX << 16) | TEMP_MIN); + (uint32_t) ((LIGHTNESS_MAX << 16) | TEMP_MIN); } static void light_default_status_init(void) { - u16_t lightness; + uint16_t lightness; - lightness = (u16_t) (light_ctl_srv_user_data.lightness_temp_last >> 16); + lightness = (uint16_t) (light_ctl_srv_user_data.lightness_temp_last >> 16); if (lightness) { gen_onoff_srv_root_user_data.onoff = STATE_ON; @@ -77,10 +77,10 @@ static void light_default_status_init(void) /* Retrieve Default Lightness & Temperature Values */ if (light_ctl_srv_user_data.lightness_temp_def) { - light_ctl_srv_user_data.lightness_def = (u16_t) + light_ctl_srv_user_data.lightness_def = (uint16_t) (light_ctl_srv_user_data.lightness_temp_def >> 16); - light_ctl_srv_user_data.temp_def = (u16_t) + light_ctl_srv_user_data.temp_def = (uint16_t) (light_ctl_srv_user_data.lightness_temp_def); } @@ -92,18 +92,18 @@ static void light_default_status_init(void) /* Retrieve Range of Lightness & Temperature */ if (light_lightness_srv_user_data.lightness_range) { - light_lightness_srv_user_data.light_range_max = (u16_t) + light_lightness_srv_user_data.light_range_max = (uint16_t) (light_lightness_srv_user_data.lightness_range >> 16); - light_lightness_srv_user_data.light_range_min = (u16_t) + light_lightness_srv_user_data.light_range_min = (uint16_t) (light_lightness_srv_user_data.lightness_range); } if (light_ctl_srv_user_data.temperature_range) { - light_ctl_srv_user_data.temp_range_max = (u16_t) + light_ctl_srv_user_data.temp_range_max = (uint16_t) (light_ctl_srv_user_data.temperature_range >> 16); - light_ctl_srv_user_data.temp_range_min = (u16_t) + light_ctl_srv_user_data.temp_range_min = (uint16_t) (light_ctl_srv_user_data.temperature_range); } @@ -117,11 +117,11 @@ static void light_default_status_init(void) state_binding(ONOFF, ONOFF_TEMP); break; case STATE_RESTORE: - light_lightness_srv_user_data.last = (u16_t) + light_lightness_srv_user_data.last = (uint16_t) (light_ctl_srv_user_data.lightness_temp_last >> 16); light_ctl_srv_user_data.temp = - (u16_t) (light_ctl_srv_user_data.lightness_temp_last); + (uint16_t) (light_ctl_srv_user_data.lightness_temp_last); state_binding(ONPOWERUP, ONOFF_TEMP); break; @@ -132,7 +132,7 @@ static void light_default_status_init(void) void update_light_state(void) { - u8_t power, color; + uint8_t power, color; power = 100 * ((float) lightness / 65535); color = 100 * ((float) (temperature + 32768) / 65535); diff --git a/apps/blemesh_models_example_2/src/publisher.c b/apps/blemesh_models_example_2/src/publisher.c index 21364b81a..f8cf849da 100644 --- a/apps/blemesh_models_example_2/src/publisher.c +++ b/apps/blemesh_models_example_2/src/publisher.c @@ -41,12 +41,12 @@ static bool is_randomization_of_TIDs_done; #if (defined(ONOFF) || defined(ONOFF_TT)) -static u8_t tid_onoff; +static uint8_t tid_onoff; #elif defined(VND_MODEL_TEST) -static u8_t tid_vnd; +static uint8_t tid_vnd; #endif -static u8_t tid_level; +static uint8_t tid_level; void randomize_publishers_TID(void) { @@ -61,7 +61,7 @@ void randomize_publishers_TID(void) is_randomization_of_TIDs_done = true; } -static u32_t button_read(int button) +static uint32_t button_read(int button) { return (uint32_t) hal_gpio_read(button); } diff --git a/apps/blemesh_models_example_2/src/state_binding.c b/apps/blemesh_models_example_2/src/state_binding.c index ae539433c..0778f7877 100644 --- a/apps/blemesh_models_example_2/src/state_binding.c +++ b/apps/blemesh_models_example_2/src/state_binding.c @@ -32,14 +32,14 @@ #include "transition.h" -u16_t lightness, target_lightness; -s16_t temperature, target_temperature; +uint16_t lightness, target_lightness; +int16_t temperature, target_temperature; -static s32_t ceiling(float num) +static int32_t ceiling(float num) { - s32_t inum; + int32_t inum; - inum = (s32_t) num; + inum = (int32_t) num; if (num == (float) inum) { return inum; } @@ -47,21 +47,21 @@ static s32_t ceiling(float num) return inum + 1; } -u16_t actual_to_linear(u16_t val) +uint16_t actual_to_linear(uint16_t val) { float tmp; tmp = ((float) val / 65535); - return (u16_t) ceiling(65535 * tmp * tmp); + return (uint16_t) ceiling(65535 * tmp * tmp); } -u16_t linear_to_actual(u16_t val) +uint16_t linear_to_actual(uint16_t val) { - return (u16_t) (65535 * sqrt(((float) val / 65535))); + return (uint16_t) (65535 * sqrt(((float) val / 65535))); } -static void constrain_lightness(u16_t var) +static void constrain_lightness(uint16_t var) { if (var > 0 && var < light_lightness_srv_user_data.light_range_min) { var = light_lightness_srv_user_data.light_range_min; @@ -72,7 +72,7 @@ static void constrain_lightness(u16_t var) lightness = var; } -static void constrain_lightness2(u16_t var) +static void constrain_lightness2(uint16_t var) { /* This is as per Mesh Model Specification 3.3.2.2.3 */ if (var > 0 && var < light_lightness_srv_user_data.light_range_min) { @@ -88,7 +88,7 @@ static void constrain_lightness2(u16_t var) lightness = var; } -static void constrain_target_lightness(u16_t var) +static void constrain_target_lightness(uint16_t var) { if (var > 0 && var < light_lightness_srv_user_data.light_range_min) { @@ -100,7 +100,7 @@ static void constrain_target_lightness(u16_t var) target_lightness = var; } -static s16_t light_ctl_temp_to_level(u16_t temp) +static int16_t light_ctl_temp_to_level(uint16_t temp) { float tmp; @@ -111,14 +111,14 @@ static s16_t light_ctl_temp_to_level(u16_t temp) tmp = tmp / (light_ctl_srv_user_data.temp_range_max - light_ctl_srv_user_data.temp_range_min); - return (s16_t) (tmp - 32768); + return (int16_t) (tmp - 32768); /* 6.1.3.1.1 2nd formula end */ } -static u16_t level_to_light_ctl_temp(s16_t level) +static uint16_t level_to_light_ctl_temp(int16_t level) { - u16_t tmp; + uint16_t tmp; float diff; /* Mesh Model Specification 6.1.3.1.1 1st formula start */ @@ -126,14 +126,14 @@ static u16_t level_to_light_ctl_temp(s16_t level) light_ctl_srv_user_data.temp_range_min) / 65535; - tmp = (u16_t) ((level + 32768) * diff); + tmp = (uint16_t) ((level + 32768) * diff); return (light_ctl_srv_user_data.temp_range_min + tmp); /* 6.1.3.1.1 1st formula end */ } -void state_binding(u8_t light, u8_t temp) +void state_binding(uint8_t light, uint8_t temp) { switch (temp) { case ONOFF_TEMP: @@ -211,10 +211,10 @@ jump: light_ctl_srv_user_data.lightness = lightness; } -void calculate_lightness_target_values(u8_t type) +void calculate_lightness_target_values(uint8_t type) { bool set_light_ctl_temp_target_value; - u16_t tmp; + uint16_t tmp; set_light_ctl_temp_target_value = true; @@ -274,7 +274,7 @@ void calculate_lightness_target_values(u8_t type) } } -void calculate_temp_target_values(u8_t type) +void calculate_temp_target_values(uint8_t type) { bool set_light_ctl_delta_uv_target_value; diff --git a/apps/blemesh_models_example_2/src/state_binding.h b/apps/blemesh_models_example_2/src/state_binding.h index db1f2a2e9..0498e5c6f 100644 --- a/apps/blemesh_models_example_2/src/state_binding.h +++ b/apps/blemesh_models_example_2/src/state_binding.h @@ -43,11 +43,11 @@ enum state_binding { IGNORE_TEMP }; -extern u16_t lightness, target_lightness; -extern s16_t temperature, target_temperature; +extern uint16_t lightness, target_lightness; +extern int16_t temperature, target_temperature; -void state_binding(u8_t lightness, u8_t temperature); -void calculate_lightness_target_values(u8_t type); -void calculate_temp_target_values(u8_t type); +void state_binding(uint8_t lightness, uint8_t temperature); +void calculate_lightness_target_values(uint8_t type); +void calculate_temp_target_values(uint8_t type); #endif diff --git a/apps/blemesh_models_example_2/src/storage.c b/apps/blemesh_models_example_2/src/storage.c index 86fec7ccf..d0ef980a3 100644 --- a/apps/blemesh_models_example_2/src/storage.c +++ b/apps/blemesh_models_example_2/src/storage.c @@ -32,8 +32,8 @@ #include "device_composition.h" #include "storage.h" -static u8_t storage_id; -u8_t reset_counter; +static uint8_t storage_id; +uint8_t reset_counter; static void save_reset_counter(void) { @@ -76,7 +76,7 @@ static void save_lightness_temp_def_state(void) char buf[12]; light_ctl_srv_user_data.lightness_temp_def = - (u32_t) ((light_ctl_srv_user_data.lightness_def << 16) | + (uint32_t) ((light_ctl_srv_user_data.lightness_def << 16) | light_ctl_srv_user_data.temp_def); settings_str_from_bytes(&light_ctl_srv_user_data.lightness_temp_def, @@ -91,7 +91,7 @@ static void save_lightness_temp_last_state(void) char buf[12]; light_ctl_srv_user_data.lightness_temp_last = - (u32_t) ((light_ctl_srv_user_data.lightness << 16) | + (uint32_t) ((light_ctl_srv_user_data.lightness << 16) | light_ctl_srv_user_data.temp); settings_str_from_bytes(&light_ctl_srv_user_data.lightness_temp_last, @@ -108,7 +108,7 @@ static void save_lightness_range(void) char buf[12]; light_lightness_srv_user_data.lightness_range = - (u32_t) ((light_lightness_srv_user_data.light_range_max << 16) | + (uint32_t) ((light_lightness_srv_user_data.light_range_max << 16) | light_lightness_srv_user_data.light_range_min); settings_str_from_bytes(&light_lightness_srv_user_data.lightness_range, @@ -123,7 +123,7 @@ static void save_temperature_range(void) char buf[12]; light_ctl_srv_user_data.temperature_range = - (u32_t) ((light_ctl_srv_user_data.temp_range_max << 16) | + (uint32_t) ((light_ctl_srv_user_data.temp_range_max << 16) | light_ctl_srv_user_data.temp_range_min); settings_str_from_bytes(&light_ctl_srv_user_data.temperature_range, @@ -162,7 +162,7 @@ static void storage_work_handler(struct os_event *work) struct os_callout storage_work; -void save_on_flash(u8_t id) +void save_on_flash(uint8_t id) { storage_id = id; os_callout_reset(&storage_work, 0); diff --git a/apps/blemesh_models_example_2/src/storage.h b/apps/blemesh_models_example_2/src/storage.h index e2905048e..5e636f622 100644 --- a/apps/blemesh_models_example_2/src/storage.h +++ b/apps/blemesh_models_example_2/src/storage.h @@ -37,11 +37,11 @@ enum ps_variables_id { TEMPERATURE_RANGE }; -extern u8_t reset_counter; +extern uint8_t reset_counter; extern struct os_callout storage_work; int ps_settings_init(void); -void save_on_flash(u8_t id); +void save_on_flash(uint8_t id); #endif diff --git a/apps/blemesh_models_example_2/src/transition.c b/apps/blemesh_models_example_2/src/transition.c index c9463e100..e31af75de 100644 --- a/apps/blemesh_models_example_2/src/transition.c +++ b/apps/blemesh_models_example_2/src/transition.c @@ -40,8 +40,8 @@ struct os_callout light_ctl_temp_work; struct os_callout dummy_timer; -u8_t transition_type, default_tt; -u32_t *ptr_counter; +uint8_t transition_type, default_tt; +uint32_t *ptr_counter; struct os_callout *ptr_timer = &dummy_timer; struct transition lightness_transition, temp_transition; @@ -50,9 +50,9 @@ struct transition lightness_transition, temp_transition; void calculate_rt(struct transition *transition) { - u8_t steps, resolution; - s32_t duration_remainder; - s64_t now; + uint8_t steps, resolution; + int32_t duration_remainder; + int64_t now; if (transition->just_started) { transition->rt = transition->tt; @@ -88,7 +88,7 @@ void calculate_rt(struct transition *transition) /* Function to calculate Remaining Time (End) */ -static void bound_states_transition_type_reassignment(u8_t type) +static void bound_states_transition_type_reassignment(uint8_t type) { switch (type) { case ONOFF: @@ -113,7 +113,7 @@ static void bound_states_transition_type_reassignment(u8_t type) static void tt_values_calculator(struct transition *transition) { - u8_t steps_multiplier, resolution; + uint8_t steps_multiplier, resolution; resolution = (transition->tt >> 6); steps_multiplier = (transition->tt & 0x3F); @@ -142,7 +142,7 @@ static void tt_values_calculator(struct transition *transition) ptr_counter = &transition->counter; } -void onoff_tt_values(struct generic_onoff_state *state, u8_t tt, u8_t delay) +void onoff_tt_values(struct generic_onoff_state *state, uint8_t tt, uint8_t delay) { bound_states_transition_type_reassignment(ONOFF); calculate_lightness_target_values(ONOFF); @@ -162,7 +162,7 @@ void onoff_tt_values(struct generic_onoff_state *state, u8_t tt, u8_t delay) state->transition->counter); } -void level_tt_values(struct generic_level_state *state, u8_t tt, u8_t delay) +void level_tt_values(struct generic_level_state *state, uint8_t tt, uint8_t delay) { if (state == &gen_level_srv_root_user_data) { bound_states_transition_type_reassignment(LEVEL); @@ -188,7 +188,7 @@ void level_tt_values(struct generic_level_state *state, u8_t tt, u8_t delay) } void light_lightness_actual_tt_values(struct light_lightness_state *state, - u8_t tt, u8_t delay) + uint8_t tt, uint8_t delay) { bound_states_transition_type_reassignment(ACTUAL); calculate_lightness_target_values(ACTUAL); @@ -210,7 +210,7 @@ void light_lightness_actual_tt_values(struct light_lightness_state *state, } void light_lightness_linear_tt_values(struct light_lightness_state *state, - u8_t tt, u8_t delay) + uint8_t tt, uint8_t delay) { bound_states_transition_type_reassignment(LINEAR); calculate_lightness_target_values(LINEAR); @@ -231,7 +231,7 @@ void light_lightness_linear_tt_values(struct light_lightness_state *state, state->transition->counter); } -void light_ctl_tt_values(struct light_ctl_state *state, u8_t tt, u8_t delay) +void light_ctl_tt_values(struct light_ctl_state *state, uint8_t tt, uint8_t delay) { bound_states_transition_type_reassignment(CTL); calculate_lightness_target_values(CTL); @@ -261,7 +261,7 @@ void light_ctl_tt_values(struct light_ctl_state *state, u8_t tt, u8_t delay) } void light_ctl_temp_tt_values(struct light_ctl_state *state, - u8_t tt, u8_t delay) + uint8_t tt, uint8_t delay) { bound_states_transition_type_reassignment(CTL_TEMP); calculate_temp_target_values(CTL_TEMP); @@ -331,7 +331,7 @@ static void onoff_work_handler(struct os_event *work) static void level_lightness_work_handler(struct os_event *work) { - u8_t level; + uint8_t level; struct generic_level_state *state = &gen_level_srv_root_user_data; switch (transition_type) { diff --git a/apps/blemesh_models_example_2/src/transition.h b/apps/blemesh_models_example_2/src/transition.h index 841013958..dc3e8da16 100644 --- a/apps/blemesh_models_example_2/src/transition.h +++ b/apps/blemesh_models_example_2/src/transition.h @@ -42,19 +42,19 @@ enum level_transition_types { struct transition { bool just_started; - u8_t tt; - u8_t rt; - u8_t delay; - u32_t quo_tt; - u32_t counter; - u32_t total_duration; - s64_t start_timestamp; + uint8_t tt; + uint8_t rt; + uint8_t delay; + uint32_t quo_tt; + uint32_t counter; + uint32_t total_duration; + int64_t start_timestamp; struct os_callout timer; }; -extern u8_t transition_type, default_tt; -extern u32_t *ptr_counter; +extern uint8_t transition_type, default_tt; +extern uint32_t *ptr_counter; extern struct os_callout *ptr_timer; extern struct transition lightness_transition, temp_transition; @@ -64,15 +64,15 @@ extern struct os_callout dummy_timer; void calculate_rt(struct transition *transition); -void onoff_tt_values(struct generic_onoff_state *state, u8_t tt, u8_t delay); -void level_tt_values(struct generic_level_state *state, u8_t tt, u8_t delay); +void onoff_tt_values(struct generic_onoff_state *state, uint8_t tt, uint8_t delay); +void level_tt_values(struct generic_level_state *state, uint8_t tt, uint8_t delay); void light_lightness_actual_tt_values(struct light_lightness_state *state, - u8_t tt, u8_t delay); + uint8_t tt, uint8_t delay); void light_lightness_linear_tt_values(struct light_lightness_state *state, - u8_t tt, u8_t delay); -void light_ctl_tt_values(struct light_ctl_state *state, u8_t tt, u8_t delay); + uint8_t tt, uint8_t delay); +void light_ctl_tt_values(struct light_ctl_state *state, uint8_t tt, uint8_t delay); void light_ctl_temp_tt_values(struct light_ctl_state *state, - u8_t tt, u8_t delay); + uint8_t tt, uint8_t delay); void onoff_handler(struct generic_onoff_state *state); void level_lightness_handler(struct generic_level_state *state); diff --git a/apps/blemesh_shell/src/main.c b/apps/blemesh_shell/src/main.c index 4ad23e1d8..fcf80127f 100644 --- a/apps/blemesh_shell/src/main.c +++ b/apps/blemesh_shell/src/main.c @@ -44,21 +44,21 @@ void net_recv_ev(uint8_t ttl, uint8_t ctl, uint16_t src, uint16_t dst, payload_len); } -static void model_bound_cb(u16_t addr, struct bt_mesh_model *model, - u16_t key_idx) +static void model_bound_cb(uint16_t addr, struct bt_mesh_model *model, + uint16_t key_idx) { console_printf("Model bound: remote addr 0x%04x key_idx 0x%04x model %p\n", addr, key_idx, model); } -static void model_unbound_cb(u16_t addr, struct bt_mesh_model *model, - u16_t key_idx) +static void model_unbound_cb(uint16_t addr, struct bt_mesh_model *model, + uint16_t key_idx) { console_printf("Model unbound: remote addr 0x%04x key_idx 0x%04x " "model %p\n", addr, key_idx, model); } -static void invalid_bearer_cb(u8_t opcode) +static void invalid_bearer_cb(uint8_t opcode) { console_printf("Invalid bearer: opcode 0x%02x\n", opcode); } diff --git a/apps/bttester/src/bttester.c b/apps/bttester/src/bttester.c index 54b14daaa..5ddc29548 100644 --- a/apps/bttester/src/bttester.c +++ b/apps/bttester/src/bttester.c @@ -44,16 +44,16 @@ static struct os_event bttester_ev[CMD_QUEUED]; struct btp_buf { struct os_event *ev; union { - u8_t data[BTP_MTU]; + uint8_t data[BTP_MTU]; struct btp_hdr hdr; }; }; static struct btp_buf cmd_buf[CMD_QUEUED]; -static void supported_commands(u8_t *data, u16_t len) +static void supported_commands(uint8_t *data, uint16_t len) { - u8_t buf[1]; + uint8_t buf[1]; struct core_read_supported_commands_rp *rp = (void *) buf; memset(buf, 0, sizeof(buf)); @@ -64,12 +64,12 @@ static void supported_commands(u8_t *data, u16_t len) tester_set_bit(buf, CORE_UNREGISTER_SERVICE); tester_send(BTP_SERVICE_ID_CORE, CORE_READ_SUPPORTED_COMMANDS, - BTP_INDEX_NONE, (u8_t *) rp, sizeof(buf)); + BTP_INDEX_NONE, (uint8_t *) rp, sizeof(buf)); } -static void supported_services(u8_t *data, u16_t len) +static void supported_services(uint8_t *data, uint16_t len) { - u8_t buf[1]; + uint8_t buf[1]; struct core_read_supported_services_rp *rp = (void *) buf; memset(buf, 0, sizeof(buf)); @@ -85,13 +85,13 @@ static void supported_services(u8_t *data, u16_t len) #endif /* MYNEWT_VAL(BLE_MESH) */ tester_send(BTP_SERVICE_ID_CORE, CORE_READ_SUPPORTED_SERVICES, - BTP_INDEX_NONE, (u8_t *) rp, sizeof(buf)); + BTP_INDEX_NONE, (uint8_t *) rp, sizeof(buf)); } -static void register_service(u8_t *data, u16_t len) +static void register_service(uint8_t *data, uint16_t len) { struct core_register_service_cmd *cmd = (void *) data; - u8_t status; + uint8_t status; switch (cmd->id) { case BTP_SERVICE_ID_GAP: @@ -124,10 +124,10 @@ rsp: status); } -static void unregister_service(u8_t *data, u16_t len) +static void unregister_service(uint8_t *data, uint16_t len) { struct core_unregister_service_cmd *cmd = (void *) data; - u8_t status; + uint8_t status; switch (cmd->id) { case BTP_SERVICE_ID_GAP: @@ -155,8 +155,8 @@ static void unregister_service(u8_t *data, u16_t len) status); } -static void handle_core(u8_t opcode, u8_t index, u8_t *data, - u16_t len) +static void handle_core(uint8_t opcode, uint8_t index, uint8_t *data, + uint16_t len) { if (index != BTP_INDEX_NONE) { tester_rsp(BTP_SERVICE_ID_CORE, opcode, index, @@ -186,7 +186,7 @@ static void handle_core(u8_t opcode, u8_t index, u8_t *data, static void cmd_handler(struct os_event *ev) { - u16_t len; + uint16_t len; struct btp_buf *cmd; if (!ev || !ev->ev_arg) { @@ -241,12 +241,12 @@ static void cmd_handler(struct os_event *ev) os_eventq_put(&avail_queue, ev); } -static u8_t *recv_cb(u8_t *buf, size_t *off) +static uint8_t *recv_cb(uint8_t *buf, size_t *off) { struct btp_hdr *cmd = (void *) buf; struct os_event *new_ev; struct btp_buf *new_buf, *old_buf; - u16_t len; + uint16_t len; if (*off < sizeof(*cmd)) { return buf; @@ -319,7 +319,7 @@ void tester_init(void) NULL, 0); } -void tester_send(u8_t service, u8_t opcode, u8_t index, u8_t *data, +void tester_send(uint8_t service, uint8_t opcode, uint8_t index, uint8_t *data, size_t len) { struct btp_hdr msg; @@ -329,7 +329,7 @@ void tester_send(u8_t service, u8_t opcode, u8_t index, u8_t *data, msg.index = index; msg.len = len; - bttester_pipe_send((u8_t *)&msg, sizeof(msg)); + bttester_pipe_send((uint8_t *)&msg, sizeof(msg)); if (data && len) { bttester_pipe_send(data, len); } @@ -344,7 +344,7 @@ void tester_send(u8_t service, u8_t opcode, u8_t index, u8_t *data, } } -void tester_send_buf(u8_t service, u8_t opcode, u8_t index, +void tester_send_buf(uint8_t service, uint8_t opcode, uint8_t index, struct os_mbuf *data) { struct btp_hdr msg; @@ -354,13 +354,13 @@ void tester_send_buf(u8_t service, u8_t opcode, u8_t index, msg.index = index; msg.len = os_mbuf_len(data); - bttester_pipe_send((u8_t *)&msg, sizeof(msg)); + bttester_pipe_send((uint8_t *)&msg, sizeof(msg)); if (data && msg.len) { bttester_pipe_send_buf(data); } } -void tester_rsp(u8_t service, u8_t opcode, u8_t index, u8_t status) +void tester_rsp(uint8_t service, uint8_t opcode, uint8_t index, uint8_t status) { struct btp_status s; @@ -370,5 +370,5 @@ void tester_rsp(u8_t service, u8_t opcode, u8_t index, u8_t status) } s.code = status; - tester_send(service, BTP_STATUS, index, (u8_t *) &s, sizeof(s)); + tester_send(service, BTP_STATUS, index, (uint8_t *) &s, sizeof(s)); } diff --git a/apps/bttester/src/bttester.h b/apps/bttester/src/bttester.h index d77d03229..6761681e1 100644 --- a/apps/bttester/src/bttester.h +++ b/apps/bttester/src/bttester.h @@ -71,37 +71,37 @@ #define sys_cpu_to_le16 htole16 struct btp_hdr { - u8_t service; - u8_t opcode; - u8_t index; - u16_t len; - u8_t data[0]; + uint8_t service; + uint8_t opcode; + uint8_t index; + uint16_t len; + uint8_t data[0]; } __packed; #define BTP_STATUS 0x00 struct btp_status { - u8_t code; + uint8_t code; } __packed; /* Core Service */ #define CORE_READ_SUPPORTED_COMMANDS 0x01 struct core_read_supported_commands_rp { - u8_t data[0]; + uint8_t data[0]; } __packed; #define CORE_READ_SUPPORTED_SERVICES 0x02 struct core_read_supported_services_rp { - u8_t data[0]; + uint8_t data[0]; } __packed; #define CORE_REGISTER_SERVICE 0x03 struct core_register_service_cmd { - u8_t id; + uint8_t id; } __packed; #define CORE_UNREGISTER_SERVICE 0x04 struct core_unregister_service_cmd { - u8_t id; + uint8_t id; } __packed; /* events */ @@ -111,13 +111,13 @@ struct core_unregister_service_cmd { /* commands */ #define GAP_READ_SUPPORTED_COMMANDS 0x01 struct gap_read_supported_commands_rp { - u8_t data[0]; + uint8_t data[0]; } __packed; #define GAP_READ_CONTROLLER_INDEX_LIST 0x02 struct gap_read_controller_index_list_rp { - u8_t num; - u8_t index[0]; + uint8_t num; + uint8_t index[0]; } __packed; #define GAP_SETTINGS_POWERED 0 @@ -139,41 +139,41 @@ struct gap_read_controller_index_list_rp { #define GAP_READ_CONTROLLER_INFO 0x03 struct gap_read_controller_info_rp { - u8_t address[6]; - u32_t supported_settings; - u32_t current_settings; - u8_t cod[3]; - u8_t name[249]; - u8_t short_name[11]; + uint8_t address[6]; + uint32_t supported_settings; + uint32_t current_settings; + uint8_t cod[3]; + uint8_t name[249]; + uint8_t short_name[11]; } __packed; #define GAP_RESET 0x04 struct gap_reset_rp { - u32_t current_settings; + uint32_t current_settings; } __packed; #define GAP_SET_POWERED 0x05 struct gap_set_powered_cmd { - u8_t powered; + uint8_t powered; } __packed; struct gap_set_powered_rp { - u32_t current_settings; + uint32_t current_settings; } __packed; #define GAP_SET_CONNECTABLE 0x06 struct gap_set_connectable_cmd { - u8_t connectable; + uint8_t connectable; } __packed; struct gap_set_connectable_rp { - u32_t current_settings; + uint32_t current_settings; } __packed; #define GAP_SET_FAST_CONNECTABLE 0x07 struct gap_set_fast_connectable_cmd { - u8_t fast_connectable; + uint8_t fast_connectable; } __packed; struct gap_set_fast_connectable_rp { - u32_t current_settings; + uint32_t current_settings; } __packed; #define GAP_NON_DISCOVERABLE 0x00 @@ -182,34 +182,34 @@ struct gap_set_fast_connectable_rp { #define GAP_SET_DISCOVERABLE 0x08 struct gap_set_discoverable_cmd { - u8_t discoverable; + uint8_t discoverable; } __packed; struct gap_set_discoverable_rp { - u32_t current_settings; + uint32_t current_settings; } __packed; #define GAP_SET_BONDABLE 0x09 struct gap_set_bondable_cmd { - u8_t bondable; + uint8_t bondable; } __packed; struct gap_set_bondable_rp { - u32_t current_settings; + uint32_t current_settings; } __packed; #define GAP_START_ADVERTISING 0x0a struct gap_start_advertising_cmd { - u8_t adv_data_len; - u8_t scan_rsp_len; - u8_t adv_data[0]; - u8_t scan_rsp[0]; + uint8_t adv_data_len; + uint8_t scan_rsp_len; + uint8_t adv_data[0]; + uint8_t scan_rsp[0]; } __packed; struct gap_start_advertising_rp { - u32_t current_settings; + uint32_t current_settings; } __packed; #define GAP_STOP_ADVERTISING 0x0b struct gap_stop_advertising_rp { - u32_t current_settings; + uint32_t current_settings; } __packed; #define GAP_DISCOVERY_FLAG_LE 0x01 @@ -220,21 +220,21 @@ struct gap_stop_advertising_rp { #define GAP_START_DISCOVERY 0x0c struct gap_start_discovery_cmd { - u8_t flags; + uint8_t flags; } __packed; #define GAP_STOP_DISCOVERY 0x0d #define GAP_CONNECT 0x0e struct gap_connect_cmd { - u8_t address_type; - u8_t address[6]; + uint8_t address_type; + uint8_t address[6]; } __packed; #define GAP_DISCONNECT 0x0f struct gap_disconnect_cmd { - u8_t address_type; - u8_t address[6]; + uint8_t address_type; + uint8_t address[6]; } __packed; #define GAP_IO_CAP_DISPLAY_ONLY 0 @@ -245,85 +245,85 @@ struct gap_disconnect_cmd { #define GAP_SET_IO_CAP 0x10 struct gap_set_io_cap_cmd { - u8_t io_cap; + uint8_t io_cap; } __packed; #define GAP_PAIR 0x11 struct gap_pair_cmd { - u8_t address_type; - u8_t address[6]; + uint8_t address_type; + uint8_t address[6]; } __packed; #define GAP_UNPAIR 0x12 struct gap_unpair_cmd { - u8_t address_type; - u8_t address[6]; + uint8_t address_type; + uint8_t address[6]; } __packed; #define GAP_PASSKEY_ENTRY 0x13 struct gap_passkey_entry_cmd { - u8_t address_type; - u8_t address[6]; - u32_t passkey; + uint8_t address_type; + uint8_t address[6]; + uint32_t passkey; } __packed; #define GAP_PASSKEY_CONFIRM 0x14 struct gap_passkey_confirm_cmd { - u8_t address_type; - u8_t address[6]; - u8_t match; + uint8_t address_type; + uint8_t address[6]; + uint8_t match; } __packed; #define GAP_START_DIRECT_ADV 0x15 struct gap_start_direct_adv_cmd { - u8_t address_type; - u8_t address[6]; - u8_t high_duty; + uint8_t address_type; + uint8_t address[6]; + uint8_t high_duty; } __packed; #define GAP_CONN_PARAM_UPDATE 0x16 struct gap_conn_param_update_cmd { - u8_t address_type; - u8_t address[6]; - u16_t conn_itvl_min; - u16_t conn_itvl_max; - u16_t conn_latency; - u16_t supervision_timeout; + uint8_t address_type; + uint8_t address[6]; + uint16_t conn_itvl_min; + uint16_t conn_itvl_max; + uint16_t conn_latency; + uint16_t supervision_timeout; } __packed; #define GAP_PAIRING_CONSENT_RSP 0x17 struct gap_pairing_consent_rsp_cmd { - u8_t address_type; - u8_t address[6]; - u8_t consent; + uint8_t address_type; + uint8_t address[6]; + uint8_t consent; } __packed; #define GAP_OOB_LEGACY_SET_DATA 0x18 struct gap_oob_legacy_set_data_cmd { - u8_t oob_data[16]; + uint8_t oob_data[16]; } __packed; #define GAP_OOB_SC_GET_LOCAL_DATA 0x19 struct gap_oob_sc_get_local_data_rp { - u8_t r[16]; - u8_t c[16]; + uint8_t r[16]; + uint8_t c[16]; } __packed; #define GAP_OOB_SC_SET_REMOTE_DATA 0x1a struct gap_oob_sc_set_remote_data_cmd { - u8_t r[16]; - u8_t c[16]; + uint8_t r[16]; + uint8_t c[16]; } __packed; #define GAP_SET_MITM 0x1b struct gap_set_mitm_cmd { - u8_t mitm; + uint8_t mitm; } __packed; /* events */ #define GAP_EV_NEW_SETTINGS 0x80 struct gap_new_settings_ev { - u32_t current_settings; + uint32_t current_settings; } __packed; #define GAP_DEVICE_FOUND_FLAG_RSSI 0x01 @@ -332,84 +332,84 @@ struct gap_new_settings_ev { #define GAP_EV_DEVICE_FOUND 0x81 struct gap_device_found_ev { - u8_t address_type; - u8_t address[6]; - s8_t rssi; - u8_t flags; - u16_t eir_data_len; - u8_t eir_data[0]; + uint8_t address_type; + uint8_t address[6]; + int8_t rssi; + uint8_t flags; + uint16_t eir_data_len; + uint8_t eir_data[0]; } __packed; #define GAP_EV_DEVICE_CONNECTED 0x82 struct gap_device_connected_ev { - u8_t address_type; - u8_t address[6]; - u16_t conn_itvl; - u16_t conn_latency; - u16_t supervision_timeout; + uint8_t address_type; + uint8_t address[6]; + uint16_t conn_itvl; + uint16_t conn_latency; + uint16_t supervision_timeout; } __packed; #define GAP_EV_DEVICE_DISCONNECTED 0x83 struct gap_device_disconnected_ev { - u8_t address_type; - u8_t address[6]; + uint8_t address_type; + uint8_t address[6]; } __packed; #define GAP_EV_PASSKEY_DISPLAY 0x84 struct gap_passkey_display_ev { - u8_t address_type; - u8_t address[6]; - u32_t passkey; + uint8_t address_type; + uint8_t address[6]; + uint32_t passkey; } __packed; #define GAP_EV_PASSKEY_ENTRY_REQ 0x85 struct gap_passkey_entry_req_ev { - u8_t address_type; - u8_t address[6]; + uint8_t address_type; + uint8_t address[6]; } __packed; #define GAP_EV_PASSKEY_CONFIRM_REQ 0x86 struct gap_passkey_confirm_req_ev { - u8_t address_type; - u8_t address[6]; - u32_t passkey; + uint8_t address_type; + uint8_t address[6]; + uint32_t passkey; } __packed; #define GAP_EV_IDENTITY_RESOLVED 0x87 struct gap_identity_resolved_ev { - u8_t address_type; - u8_t address[6]; - u8_t identity_address_type; - u8_t identity_address[6]; + uint8_t address_type; + uint8_t address[6]; + uint8_t identity_address_type; + uint8_t identity_address[6]; } __packed; #define GAP_EV_CONN_PARAM_UPDATE 0x88 struct gap_conn_param_update_ev { - u8_t address_type; - u8_t address[6]; - u16_t conn_itvl; - u16_t conn_latency; - u16_t supervision_timeout; + uint8_t address_type; + uint8_t address[6]; + uint16_t conn_itvl; + uint16_t conn_latency; + uint16_t supervision_timeout; } __packed; #define GAP_EV_SEC_LEVEL_CHANGED 0x89 struct gap_sec_level_changed_ev { - u8_t address_type; - u8_t address[6]; - u8_t level; + uint8_t address_type; + uint8_t address[6]; + uint8_t level; } __packed; #define GAP_EV_PAIRING_CONSENT_REQ 0x8a struct gap_pairing_consent_req_ev { - u8_t address_type; - u8_t address[6]; + uint8_t address_type; + uint8_t address[6]; } __packed; /* GATT Service */ /* commands */ #define GATT_READ_SUPPORTED_COMMANDS 0x01 struct gatt_read_supported_commands_rp { - u8_t data[0]; + uint8_t data[0]; } __packed; #define GATT_SERVICE_PRIMARY 0x00 @@ -417,320 +417,320 @@ struct gatt_read_supported_commands_rp { #define GATT_ADD_SERVICE 0x02 struct gatt_add_service_cmd { - u8_t type; - u8_t uuid_length; - u8_t uuid[0]; + uint8_t type; + uint8_t uuid_length; + uint8_t uuid[0]; } __packed; struct gatt_add_service_rp { - u16_t svc_id; + uint16_t svc_id; } __packed; #define GATT_ADD_CHARACTERISTIC 0x03 struct gatt_add_characteristic_cmd { - u16_t svc_id; - u8_t properties; - u8_t permissions; - u8_t uuid_length; - u8_t uuid[0]; + uint16_t svc_id; + uint8_t properties; + uint8_t permissions; + uint8_t uuid_length; + uint8_t uuid[0]; } __packed; struct gatt_add_characteristic_rp { - u16_t char_id; + uint16_t char_id; } __packed; #define GATT_ADD_DESCRIPTOR 0x04 struct gatt_add_descriptor_cmd { - u16_t char_id; - u8_t permissions; - u8_t uuid_length; - u8_t uuid[0]; + uint16_t char_id; + uint8_t permissions; + uint8_t uuid_length; + uint8_t uuid[0]; } __packed; struct gatt_add_descriptor_rp { - u16_t desc_id; + uint16_t desc_id; } __packed; #define GATT_ADD_INCLUDED_SERVICE 0x05 struct gatt_add_included_service_cmd { - u16_t svc_id; + uint16_t svc_id; } __packed; struct gatt_add_included_service_rp { - u16_t included_service_id; + uint16_t included_service_id; } __packed; #define GATT_SET_VALUE 0x06 struct gatt_set_value_cmd { - u16_t attr_id; - u16_t len; - u8_t value[0]; + uint16_t attr_id; + uint16_t len; + uint8_t value[0]; } __packed; #define GATT_START_SERVER 0x07 struct gatt_start_server_rp { - u16_t db_attr_off; - u8_t db_attr_cnt; + uint16_t db_attr_off; + uint8_t db_attr_cnt; } __packed; #define GATT_SET_ENC_KEY_SIZE 0x09 struct gatt_set_enc_key_size_cmd { - u16_t attr_id; - u8_t key_size; + uint16_t attr_id; + uint8_t key_size; } __packed; /* Gatt Client */ struct gatt_service { - u16_t start_handle; - u16_t end_handle; - u8_t uuid_length; - u8_t uuid[0]; + uint16_t start_handle; + uint16_t end_handle; + uint8_t uuid_length; + uint8_t uuid[0]; } __packed; struct gatt_included { - u16_t included_handle; + uint16_t included_handle; struct gatt_service service; } __packed; struct gatt_characteristic { - u16_t characteristic_handle; - u16_t value_handle; - u8_t properties; - u8_t uuid_length; - u8_t uuid[0]; + uint16_t characteristic_handle; + uint16_t value_handle; + uint8_t properties; + uint8_t uuid_length; + uint8_t uuid[0]; } __packed; struct gatt_descriptor { - u16_t descriptor_handle; - u8_t uuid_length; - u8_t uuid[0]; + uint16_t descriptor_handle; + uint8_t uuid_length; + uint8_t uuid[0]; } __packed; #define GATT_EXCHANGE_MTU 0x0a #define GATT_DISC_ALL_PRIM_SVCS 0x0b struct gatt_disc_all_prim_svcs_cmd { - u8_t address_type; - u8_t address[6]; + uint8_t address_type; + uint8_t address[6]; } __packed; struct gatt_disc_all_prim_svcs_rp { - u8_t services_count; + uint8_t services_count; struct gatt_service services[0]; } __packed; #define GATT_DISC_PRIM_UUID 0x0c struct gatt_disc_prim_uuid_cmd { - u8_t address_type; - u8_t address[6]; - u8_t uuid_length; - u8_t uuid[0]; + uint8_t address_type; + uint8_t address[6]; + uint8_t uuid_length; + uint8_t uuid[0]; } __packed; struct gatt_disc_prim_uuid_rp { - u8_t services_count; + uint8_t services_count; struct gatt_service services[0]; } __packed; #define GATT_FIND_INCLUDED 0x0d struct gatt_find_included_cmd { - u8_t address_type; - u8_t address[6]; - u16_t start_handle; - u16_t end_handle; + uint8_t address_type; + uint8_t address[6]; + uint16_t start_handle; + uint16_t end_handle; } __packed; struct gatt_find_included_rp { - u8_t services_count; + uint8_t services_count; struct gatt_included included[0]; } __packed; #define GATT_DISC_ALL_CHRC 0x0e struct gatt_disc_all_chrc_cmd { - u8_t address_type; - u8_t address[6]; - u16_t start_handle; - u16_t end_handle; + uint8_t address_type; + uint8_t address[6]; + uint16_t start_handle; + uint16_t end_handle; } __packed; struct gatt_disc_chrc_rp { - u8_t characteristics_count; + uint8_t characteristics_count; struct gatt_characteristic characteristics[0]; } __packed; #define GATT_DISC_CHRC_UUID 0x0f struct gatt_disc_chrc_uuid_cmd { - u8_t address_type; - u8_t address[6]; - u16_t start_handle; - u16_t end_handle; - u8_t uuid_length; - u8_t uuid[0]; + uint8_t address_type; + uint8_t address[6]; + uint16_t start_handle; + uint16_t end_handle; + uint8_t uuid_length; + uint8_t uuid[0]; } __packed; #define GATT_DISC_ALL_DESC 0x10 struct gatt_disc_all_desc_cmd { - u8_t address_type; - u8_t address[6]; - u16_t start_handle; - u16_t end_handle; + uint8_t address_type; + uint8_t address[6]; + uint16_t start_handle; + uint16_t end_handle; } __packed; struct gatt_disc_all_desc_rp { - u8_t descriptors_count; + uint8_t descriptors_count; struct gatt_descriptor descriptors[0]; } __packed; #define GATT_READ 0x11 struct gatt_read_cmd { - u8_t address_type; - u8_t address[6]; - u16_t handle; + uint8_t address_type; + uint8_t address[6]; + uint16_t handle; } __packed; struct gatt_read_rp { - u8_t att_response; - u16_t data_length; - u8_t data[0]; + uint8_t att_response; + uint16_t data_length; + uint8_t data[0]; } __packed; #define GATT_READ_UUID 0x12 struct gatt_read_uuid_cmd { - u8_t address_type; - u8_t address[6]; - u16_t start_handle; - u16_t end_handle; - u8_t uuid_length; - u8_t uuid[0]; + uint8_t address_type; + uint8_t address[6]; + uint16_t start_handle; + uint16_t end_handle; + uint8_t uuid_length; + uint8_t uuid[0]; } __packed; #define GATT_READ_LONG 0x13 struct gatt_read_long_cmd { - u8_t address_type; - u8_t address[6]; - u16_t handle; - u16_t offset; + uint8_t address_type; + uint8_t address[6]; + uint16_t handle; + uint16_t offset; } __packed; #define GATT_READ_MULTIPLE 0x14 struct gatt_read_multiple_cmd { - u8_t address_type; - u8_t address[6]; - u8_t handles_count; - u16_t handles[0]; + uint8_t address_type; + uint8_t address[6]; + uint8_t handles_count; + uint16_t handles[0]; } __packed; #define GATT_WRITE_WITHOUT_RSP 0x15 struct gatt_write_without_rsp_cmd { - u8_t address_type; - u8_t address[6]; - u16_t handle; - u16_t data_length; - u8_t data[0]; + uint8_t address_type; + uint8_t address[6]; + uint16_t handle; + uint16_t data_length; + uint8_t data[0]; } __packed; #define GATT_SIGNED_WRITE_WITHOUT_RSP 0x16 struct gatt_signed_write_without_rsp_cmd { - u8_t address_type; - u8_t address[6]; - u16_t handle; - u16_t data_length; - u8_t data[0]; + uint8_t address_type; + uint8_t address[6]; + uint16_t handle; + uint16_t data_length; + uint8_t data[0]; } __packed; #define GATT_WRITE 0x17 struct gatt_write_cmd { - u8_t address_type; - u8_t address[6]; - u16_t handle; - u16_t data_length; - u8_t data[0]; + uint8_t address_type; + uint8_t address[6]; + uint16_t handle; + uint16_t data_length; + uint8_t data[0]; } __packed; #define GATT_WRITE_LONG 0x18 struct gatt_write_long_cmd { - u8_t address_type; - u8_t address[6]; - u16_t handle; - u16_t offset; - u16_t data_length; - u8_t data[0]; + uint8_t address_type; + uint8_t address[6]; + uint16_t handle; + uint16_t offset; + uint16_t data_length; + uint8_t data[0]; } __packed; #define GATT_RELIABLE_WRITE 0x19 struct gatt_reliable_write_cmd { - u8_t address_type; - u8_t address[6]; - u16_t handle; - u16_t offset; - u16_t data_length; - u8_t data[0]; + uint8_t address_type; + uint8_t address[6]; + uint16_t handle; + uint16_t offset; + uint16_t data_length; + uint8_t data[0]; } __packed; #define GATT_CFG_NOTIFY 0x1a #define GATT_CFG_INDICATE 0x1b struct gatt_cfg_notify_cmd { - u8_t address_type; - u8_t address[6]; - u8_t enable; - u16_t ccc_handle; + uint8_t address_type; + uint8_t address[6]; + uint8_t enable; + uint16_t ccc_handle; } __packed; #define GATT_GET_ATTRIBUTES 0x1c struct gatt_get_attributes_cmd { - u16_t start_handle; - u16_t end_handle; - u8_t type_length; - u8_t type[0]; + uint16_t start_handle; + uint16_t end_handle; + uint8_t type_length; + uint8_t type[0]; } __packed; struct gatt_get_attributes_rp { - u8_t attrs_count; - u8_t attrs[0]; + uint8_t attrs_count; + uint8_t attrs[0]; } __packed; struct gatt_attr { - u16_t handle; - u8_t permission; - u8_t type_length; - u8_t type[0]; + uint16_t handle; + uint8_t permission; + uint8_t type_length; + uint8_t type[0]; } __packed; #define GATT_GET_ATTRIBUTE_VALUE 0x1d struct gatt_get_attribute_value_cmd { - u8_t address_type; - u8_t address[6]; - u16_t handle; + uint8_t address_type; + uint8_t address[6]; + uint16_t handle; } __packed; struct gatt_get_attribute_value_rp { - u8_t att_response; - u16_t value_length; - u8_t value[0]; + uint8_t att_response; + uint16_t value_length; + uint8_t value[0]; } __packed; #define GATT_CHANGE_DATABASE 0x1e struct gatt_change_database { - u16_t start_handle; - u16_t end_handle; - u8_t visibility; + uint16_t start_handle; + uint16_t end_handle; + uint8_t visibility; } __packed; /* GATT events */ #define GATT_EV_NOTIFICATION 0x80 struct gatt_notification_ev { - u8_t address_type; - u8_t address[6]; - u8_t type; - u16_t handle; - u16_t data_length; - u8_t data[0]; + uint8_t address_type; + uint8_t address[6]; + uint8_t type; + uint16_t handle; + uint16_t data_length; + uint8_t data[0]; } __packed; #define GATT_EV_ATTR_VALUE_CHANGED 0x81 struct gatt_attr_value_changed_ev { - u16_t handle; - u16_t data_length; - u8_t data[0]; + uint16_t handle; + uint16_t data_length; + uint8_t data[0]; } __packed; -static inline void tester_set_bit(u8_t *addr, unsigned int bit) +static inline void tester_set_bit(uint8_t *addr, unsigned int bit) { - u8_t *p = addr + (bit / 8); + uint8_t *p = addr + (bit / 8); *p |= BIT(bit % 8); } -static inline u8_t tester_test_bit(const u8_t *addr, unsigned int bit) +static inline uint8_t tester_test_bit(const uint8_t *addr, unsigned int bit) { - const u8_t *p = addr + (bit / 8); + const uint8_t *p = addr + (bit / 8); return *p & BIT(bit % 8); } @@ -739,33 +739,33 @@ static inline u8_t tester_test_bit(const u8_t *addr, unsigned int bit) /* commands */ #define L2CAP_READ_SUPPORTED_COMMANDS 0x01 struct l2cap_read_supported_commands_rp { - u8_t data[0]; + uint8_t data[0]; } __packed; #define L2CAP_CONNECT 0x02 struct l2cap_connect_cmd { - u8_t address_type; - u8_t address[6]; - u16_t psm; - u16_t mtu; - u8_t num; + uint8_t address_type; + uint8_t address[6]; + uint16_t psm; + uint16_t mtu; + uint8_t num; } __packed; struct l2cap_connect_rp { - u8_t num; - u8_t chan_ids[0]; + uint8_t num; + uint8_t chan_ids[0]; } __packed; #define L2CAP_DISCONNECT 0x03 struct l2cap_disconnect_cmd { - u8_t chan_id; + uint8_t chan_id; } __packed; #define L2CAP_SEND_DATA 0x04 struct l2cap_send_data_cmd { - u8_t chan_id; - u16_t data_len; - u8_t data[]; + uint8_t chan_id; + uint16_t data_len; + uint8_t data[]; } __packed; #define L2CAP_TRANSPORT_BREDR 0x00 @@ -773,78 +773,78 @@ struct l2cap_send_data_cmd { #define L2CAP_LISTEN 0x05 struct l2cap_listen_cmd { - u16_t psm; - u8_t transport; - u16_t mtu; - u16_t response; + uint16_t psm; + uint8_t transport; + uint16_t mtu; + uint16_t response; } __packed; #define L2CAP_ACCEPT_CONNECTION 0x06 struct l2cap_accept_connection_cmd { - u8_t chan_id; - u16_t result; + uint8_t chan_id; + uint16_t result; } __packed; #define L2CAP_RECONFIGURE 0x07 struct l2cap_reconfigure_cmd { - u8_t address_type; - u8_t address[6]; - u16_t mtu; - u8_t num; - u8_t idxs[]; + uint8_t address_type; + uint8_t address[6]; + uint16_t mtu; + uint8_t num; + uint8_t idxs[]; } __packed; /* events */ #define L2CAP_EV_CONNECTION_REQ 0x80 struct l2cap_connection_req_ev { - u8_t chan_id; - u16_t psm; - u8_t address_type; - u8_t address[6]; + uint8_t chan_id; + uint16_t psm; + uint8_t address_type; + uint8_t address[6]; } __packed; #define L2CAP_EV_CONNECTED 0x81 struct l2cap_connected_ev { - u8_t chan_id; - u16_t psm; - u16_t peer_mtu; - u16_t peer_mps; - u16_t our_mtu; - u16_t our_mps; - u8_t address_type; - u8_t address[6]; + uint8_t chan_id; + uint16_t psm; + uint16_t peer_mtu; + uint16_t peer_mps; + uint16_t our_mtu; + uint16_t our_mps; + uint8_t address_type; + uint8_t address[6]; } __packed; #define L2CAP_EV_DISCONNECTED 0x82 struct l2cap_disconnected_ev { - u16_t result; - u8_t chan_id; - u16_t psm; - u8_t address_type; - u8_t address[6]; + uint16_t result; + uint8_t chan_id; + uint16_t psm; + uint8_t address_type; + uint8_t address[6]; } __packed; #define L2CAP_EV_DATA_RECEIVED 0x83 struct l2cap_data_received_ev { - u8_t chan_id; - u16_t data_length; - u8_t data[0]; + uint8_t chan_id; + uint16_t data_length; + uint8_t data[0]; } __packed; #define L2CAP_EV_RECONFIGURED 0x84 struct l2cap_reconfigured_ev { - u8_t chan_id; - u16_t peer_mtu; - u16_t peer_mps; - u16_t our_mtu; - u16_t our_mps; + uint8_t chan_id; + uint16_t peer_mtu; + uint16_t peer_mps; + uint16_t our_mtu; + uint16_t our_mps; } __packed; /* MESH Service */ /* commands */ #define MESH_READ_SUPPORTED_COMMANDS 0x01 struct mesh_read_supported_commands_rp { - u8_t data[0]; + uint8_t data[0]; } __packed; #define MESH_OUT_BLINK BIT(0) @@ -860,88 +860,88 @@ struct mesh_read_supported_commands_rp { #define MESH_CONFIG_PROVISIONING 0x02 struct mesh_config_provisioning_cmd { - u8_t uuid[16]; - u8_t static_auth[16]; - u8_t out_size; - u16_t out_actions; - u8_t in_size; - u16_t in_actions; + uint8_t uuid[16]; + uint8_t static_auth[16]; + uint8_t out_size; + uint16_t out_actions; + uint8_t in_size; + uint16_t in_actions; } __packed; #define MESH_PROVISION_NODE 0x03 struct mesh_provision_node_cmd { - u8_t net_key[16]; - u16_t net_key_idx; - u8_t flags; - u32_t iv_index; - u32_t seq_num; - u16_t addr; - u8_t dev_key[16]; + uint8_t net_key[16]; + uint16_t net_key_idx; + uint8_t flags; + uint32_t iv_index; + uint32_t seq_num; + uint16_t addr; + uint8_t dev_key[16]; } __packed; #define MESH_INIT 0x04 #define MESH_RESET 0x05 #define MESH_INPUT_NUMBER 0x06 struct mesh_input_number_cmd { - u32_t number; + uint32_t number; } __packed; #define MESH_INPUT_STRING 0x07 struct mesh_input_string_cmd { - u8_t string_len; - u8_t string[0]; + uint8_t string_len; + uint8_t string[0]; } __packed; #define MESH_IVU_TEST_MODE 0x08 struct mesh_ivu_test_mode_cmd { - u8_t enable; + uint8_t enable; } __packed; #define MESH_IVU_TOGGLE_STATE 0x09 #define MESH_NET_SEND 0x0a struct mesh_net_send_cmd { - u8_t ttl; - u16_t src; - u16_t dst; - u8_t payload_len; - u8_t payload[0]; + uint8_t ttl; + uint16_t src; + uint16_t dst; + uint8_t payload_len; + uint8_t payload[0]; } __packed; #define MESH_HEALTH_GENERATE_FAULTS 0x0b struct mesh_health_generate_faults_rp { - u8_t test_id; - u8_t cur_faults_count; - u8_t reg_faults_count; - u8_t current_faults[0]; - u8_t registered_faults[0]; + uint8_t test_id; + uint8_t cur_faults_count; + uint8_t reg_faults_count; + uint8_t current_faults[0]; + uint8_t registered_faults[0]; } __packed; #define MESH_HEALTH_CLEAR_FAULTS 0x0c #define MESH_LPN 0x0d struct mesh_lpn_set_cmd { - u8_t enable; + uint8_t enable; } __packed; #define MESH_LPN_POLL 0x0e #define MESH_MODEL_SEND 0x0f struct mesh_model_send_cmd { - u16_t src; - u16_t dst; - u8_t payload_len; - u8_t payload[0]; + uint16_t src; + uint16_t dst; + uint8_t payload_len; + uint8_t payload[0]; } __packed; #define MESH_LPN_SUBSCRIBE 0x10 struct mesh_lpn_subscribe_cmd { - u16_t address; + uint16_t address; } __packed; #define MESH_LPN_UNSUBSCRIBE 0x11 struct mesh_lpn_unsubscribe_cmd { - u16_t address; + uint16_t address; } __packed; #define MESH_RPL_CLEAR 0x12 @@ -950,20 +950,20 @@ struct mesh_lpn_unsubscribe_cmd { /* events */ #define MESH_EV_OUT_NUMBER_ACTION 0x80 struct mesh_out_number_action_ev { - u16_t action; - u32_t number; + uint16_t action; + uint32_t number; } __packed; #define MESH_EV_OUT_STRING_ACTION 0x81 struct mesh_out_string_action_ev { - u8_t string_len; - u8_t string[0]; + uint8_t string_len; + uint8_t string[0]; } __packed; #define MESH_EV_IN_ACTION 0x82 struct mesh_in_action_ev { - u16_t action; - u8_t size; + uint16_t action; + uint8_t size; } __packed; #define MESH_EV_PROVISIONED 0x83 @@ -972,63 +972,63 @@ struct mesh_in_action_ev { #define MESH_PROV_BEARER_PB_GATT 0x01 #define MESH_EV_PROV_LINK_OPEN 0x84 struct mesh_prov_link_open_ev { - u8_t bearer; + uint8_t bearer; } __packed; #define MESH_EV_PROV_LINK_CLOSED 0x85 struct mesh_prov_link_closed_ev { - u8_t bearer; + uint8_t bearer; } __packed; #define MESH_EV_NET_RECV 0x86 struct mesh_net_recv_ev { - u8_t ttl; - u8_t ctl; - u16_t src; - u16_t dst; - u8_t payload_len; - u8_t payload[0]; + uint8_t ttl; + uint8_t ctl; + uint16_t src; + uint16_t dst; + uint8_t payload_len; + uint8_t payload[0]; } __packed; #define MESH_EV_INVALID_BEARER 0x87 struct mesh_invalid_bearer_ev { - u8_t opcode; + uint8_t opcode; } __packed; #define MESH_EV_INCOMP_TIMER_EXP 0x88 void tester_init(void); -void tester_rsp(u8_t service, u8_t opcode, u8_t index, u8_t status); -void tester_send(u8_t service, u8_t opcode, u8_t index, u8_t *data, +void tester_rsp(uint8_t service, uint8_t opcode, uint8_t index, uint8_t status); +void tester_send(uint8_t service, uint8_t opcode, uint8_t index, uint8_t *data, size_t len); -void tester_send_buf(u8_t service, u8_t opcode, u8_t index, +void tester_send_buf(uint8_t service, uint8_t opcode, uint8_t index, struct os_mbuf *buf); -u8_t tester_init_gap(void); -u8_t tester_unregister_gap(void); -void tester_handle_gap(u8_t opcode, u8_t index, u8_t *data, - u16_t len); -u8_t tester_init_gatt(void); -u8_t tester_unregister_gatt(void); -void tester_handle_gatt(u8_t opcode, u8_t index, u8_t *data, - u16_t len); -int tester_gatt_notify_rx_ev(u16_t conn_handle, u16_t attr_handle, - u8_t indication, struct os_mbuf *om); -int tester_gatt_subscribe_ev(u16_t conn_handle, u16_t attr_handle, u8_t reason, - u8_t prev_notify, u8_t cur_notify, - u8_t prev_indicate, u8_t cur_indicate); +uint8_t tester_init_gap(void); +uint8_t tester_unregister_gap(void); +void tester_handle_gap(uint8_t opcode, uint8_t index, uint8_t *data, + uint16_t len); +uint8_t tester_init_gatt(void); +uint8_t tester_unregister_gatt(void); +void tester_handle_gatt(uint8_t opcode, uint8_t index, uint8_t *data, + uint16_t len); +int tester_gatt_notify_rx_ev(uint16_t conn_handle, uint16_t attr_handle, + uint8_t indication, struct os_mbuf *om); +int tester_gatt_subscribe_ev(uint16_t conn_handle, uint16_t attr_handle, uint8_t reason, + uint8_t prev_notify, uint8_t cur_notify, + uint8_t prev_indicate, uint8_t cur_indicate); #if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) -u8_t tester_init_l2cap(void); -u8_t tester_unregister_l2cap(void); -void tester_handle_l2cap(u8_t opcode, u8_t index, u8_t *data, - u16_t len); +uint8_t tester_init_l2cap(void); +uint8_t tester_unregister_l2cap(void); +void tester_handle_l2cap(uint8_t opcode, uint8_t index, uint8_t *data, + uint16_t len); #endif #if MYNEWT_VAL(BLE_MESH) -u8_t tester_init_mesh(void); -u8_t tester_unregister_mesh(void); -void tester_handle_mesh(u8_t opcode, u8_t index, u8_t *data, u16_t len); +uint8_t tester_init_mesh(void); +uint8_t tester_unregister_mesh(void); +void tester_handle_mesh(uint8_t opcode, uint8_t index, uint8_t *data, uint16_t len); #endif /* MYNEWT_VAL(BLE_MESH) */ void gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg); diff --git a/apps/bttester/src/bttester_pipe.h b/apps/bttester/src/bttester_pipe.h index c54d42dea..64b63cd6a 100644 --- a/apps/bttester/src/bttester_pipe.h +++ b/apps/bttester/src/bttester_pipe.h @@ -27,9 +27,9 @@ extern "C" { #endif -typedef u8_t *(*bttester_pipe_recv_cb)(u8_t *buf, size_t *off); -void bttester_pipe_register(u8_t *buf, size_t len, bttester_pipe_recv_cb cb); -int bttester_pipe_send(const u8_t *data, int len); +typedef uint8_t *(*bttester_pipe_recv_cb)(uint8_t *buf, size_t *off); +void bttester_pipe_register(uint8_t *buf, size_t len, bttester_pipe_recv_cb cb); +int bttester_pipe_send(const uint8_t *data, int len); int bttester_pipe_send_buf(struct os_mbuf *buf); int bttester_pipe_init(void); diff --git a/apps/bttester/src/gap.c b/apps/bttester/src/gap.c index 9d6de043b..acac9989f 100644 --- a/apps/bttester/src/gap.c +++ b/apps/bttester/src/gap.c @@ -51,7 +51,7 @@ static struct ble_sm_sc_oob_data oob_data_local; static struct ble_sm_sc_oob_data oob_data_remote; static uint16_t current_settings; -u8_t own_addr_type; +uint8_t own_addr_type; static ble_addr_t peer_id_addr; static ble_addr_t peer_ota_addr; static bool encrypted = false; @@ -109,9 +109,9 @@ static int gap_conn_find_by_addr(const ble_addr_t *dev_addr, static int gap_event_cb(struct ble_gap_event *event, void *arg); -static void supported_commands(u8_t *data, u16_t len) +static void supported_commands(uint8_t *data, uint16_t len) { - u8_t cmds[3]; + uint8_t cmds[3]; struct gap_read_supported_commands_rp *rp = (void *) &cmds; SYS_LOG_DBG(""); @@ -143,13 +143,13 @@ static void supported_commands(u8_t *data, u16_t len) tester_set_bit(cmds, GAP_SET_MITM); tester_send(BTP_SERVICE_ID_GAP, GAP_READ_SUPPORTED_COMMANDS, - CONTROLLER_INDEX, (u8_t *) rp, sizeof(cmds)); + CONTROLLER_INDEX, (uint8_t *) rp, sizeof(cmds)); } -static void controller_index_list(u8_t *data, u16_t len) +static void controller_index_list(uint8_t *data, uint16_t len) { struct gap_read_controller_index_list_rp *rp; - u8_t buf[sizeof(*rp) + 1]; + uint8_t buf[sizeof(*rp) + 1]; SYS_LOG_DBG(""); @@ -159,7 +159,7 @@ static void controller_index_list(u8_t *data, u16_t len) rp->index[0] = CONTROLLER_INDEX; tester_send(BTP_SERVICE_ID_GAP, GAP_READ_CONTROLLER_INDEX_LIST, - BTP_INDEX_NONE, (u8_t *) rp, sizeof(buf)); + BTP_INDEX_NONE, (uint8_t *) rp, sizeof(buf)); } static int check_pub_addr_unassigned(void) @@ -174,10 +174,10 @@ static int check_pub_addr_unassigned(void) #endif } -static void controller_info(u8_t *data, u16_t len) +static void controller_info(uint8_t *data, uint16_t len) { struct gap_read_controller_info_rp rp; - u32_t supported_settings = 0; + uint32_t supported_settings = 0; ble_addr_t addr; int rc; @@ -240,7 +240,7 @@ static void controller_info(u8_t *data, u16_t len) memcpy(rp.name, CONTROLLER_NAME, sizeof(CONTROLLER_NAME)); tester_send(BTP_SERVICE_ID_GAP, GAP_READ_CONTROLLER_INFO, - CONTROLLER_INDEX, (u8_t *) &rp, sizeof(rp)); + CONTROLLER_INDEX, (uint8_t *) &rp, sizeof(rp)); } static struct ble_gap_adv_params adv_params = { @@ -248,7 +248,7 @@ static struct ble_gap_adv_params adv_params = { .disc_mode = BLE_GAP_DISC_MODE_NON, }; -static void set_connectable(u8_t *data, u16_t len) +static void set_connectable(uint8_t *data, uint16_t len) { const struct gap_set_connectable_cmd *cmd = (void *) data; struct gap_set_connectable_rp rp; @@ -266,12 +266,12 @@ static void set_connectable(u8_t *data, u16_t len) rp.current_settings = sys_cpu_to_le32(current_settings); tester_send(BTP_SERVICE_ID_GAP, GAP_SET_CONNECTABLE, CONTROLLER_INDEX, - (u8_t *) &rp, sizeof(rp)); + (uint8_t *) &rp, sizeof(rp)); } -static u8_t ad_flags = BLE_HS_ADV_F_BREDR_UNSUP; +static uint8_t ad_flags = BLE_HS_ADV_F_BREDR_UNSUP; -static void set_discoverable(u8_t *data, u16_t len) +static void set_discoverable(uint8_t *data, uint16_t len) { const struct gap_set_discoverable_cmd *cmd = (void *) data; struct gap_set_discoverable_rp rp; @@ -305,10 +305,10 @@ static void set_discoverable(u8_t *data, u16_t len) rp.current_settings = sys_cpu_to_le32(current_settings); tester_send(BTP_SERVICE_ID_GAP, GAP_SET_DISCOVERABLE, CONTROLLER_INDEX, - (u8_t *) &rp, sizeof(rp)); + (uint8_t *) &rp, sizeof(rp)); } -static void set_bondable(const u8_t *data, u16_t len) +static void set_bondable(const uint8_t *data, uint16_t len) { const struct gap_set_bondable_cmd *cmd = (void *) data; struct gap_set_bondable_rp rp; @@ -325,7 +325,7 @@ static void set_bondable(const u8_t *data, u16_t len) rp.current_settings = sys_cpu_to_le32(current_settings); tester_send(BTP_SERVICE_ID_GAP, GAP_SET_BONDABLE, CONTROLLER_INDEX, - (u8_t *) &rp, sizeof(rp)); + (uint8_t *) &rp, sizeof(rp)); } static struct bt_data ad[10] = { @@ -334,7 +334,7 @@ static struct bt_data ad[10] = { static struct bt_data sd[10]; static int set_ad(const struct bt_data *ad, size_t ad_len, - u8_t *buf, u8_t *buf_len) + uint8_t *buf, uint8_t *buf_len) { int i; @@ -350,14 +350,14 @@ static int set_ad(const struct bt_data *ad, size_t ad_len, return 0; } -static void start_advertising(const u8_t *data, u16_t len) +static void start_advertising(const uint8_t *data, uint16_t len) { const struct gap_start_advertising_cmd *cmd = (void *) data; struct gap_start_advertising_rp rp; int32_t duration_ms = BLE_HS_FOREVER; uint8_t buf[BLE_HS_ADV_MAX_SZ]; uint8_t buf_len = 0; - u8_t adv_len, sd_len; + uint8_t adv_len, sd_len; int err; int i; @@ -429,14 +429,14 @@ static void start_advertising(const u8_t *data, u16_t len) rp.current_settings = sys_cpu_to_le32(current_settings); tester_send(BTP_SERVICE_ID_GAP, GAP_START_ADVERTISING, CONTROLLER_INDEX, - (u8_t *) &rp, sizeof(rp)); + (uint8_t *) &rp, sizeof(rp)); return; fail: tester_rsp(BTP_SERVICE_ID_GAP, GAP_START_ADVERTISING, CONTROLLER_INDEX, BTP_STATUS_FAILED); } -static void stop_advertising(const u8_t *data, u16_t len) +static void stop_advertising(const uint8_t *data, uint16_t len) { struct gap_stop_advertising_rp rp; @@ -452,12 +452,12 @@ static void stop_advertising(const u8_t *data, u16_t len) rp.current_settings = sys_cpu_to_le32(current_settings); tester_send(BTP_SERVICE_ID_GAP, GAP_STOP_ADVERTISING, CONTROLLER_INDEX, - (u8_t *) &rp, sizeof(rp)); + (uint8_t *) &rp, sizeof(rp)); } -static u8_t get_ad_flags(const u8_t *data, u8_t data_len) +static uint8_t get_ad_flags(const uint8_t *data, uint8_t data_len) { - u8_t len, i; + uint8_t len, i; /* Parse advertisement to get flags */ for (i = 0; i < data_len; i += len - 1) { @@ -482,11 +482,11 @@ static u8_t get_ad_flags(const u8_t *data, u8_t data_len) return 0; } -static u8_t discovery_flags; +static uint8_t discovery_flags; static struct os_mbuf *adv_buf; -static void store_adv(const ble_addr_t *addr, s8_t rssi, - const u8_t *data, u8_t len) +static void store_adv(const ble_addr_t *addr, int8_t rssi, + const uint8_t *data, uint8_t len) { struct gap_device_found_ev *ev; @@ -503,8 +503,8 @@ static void store_adv(const ble_addr_t *addr, s8_t rssi, memcpy(net_buf_simple_add(adv_buf, len), data, len); } -static void device_found(ble_addr_t *addr, s8_t rssi, u8_t evtype, - const u8_t *data, u8_t len) +static void device_found(ble_addr_t *addr, int8_t rssi, uint8_t evtype, + const uint8_t *data, uint8_t len) { struct gap_device_found_ev *ev; ble_addr_t a; @@ -512,7 +512,7 @@ static void device_found(ble_addr_t *addr, s8_t rssi, u8_t evtype, /* if General/Limited Discovery - parse Advertising data to get flags */ if (!(discovery_flags & GAP_DISCOVERY_FLAG_LE_OBSERVE) && (evtype != BLE_HCI_ADV_RPT_EVTYPE_SCAN_RSP)) { - u8_t flags = get_ad_flags(data, len); + uint8_t flags = get_ad_flags(data, len); /* ignore non-discoverable devices */ if (!(flags & BLE_AD_DISCOV_MASK)) { @@ -593,11 +593,11 @@ static int discovery_cb(struct ble_gap_event *event, void *arg) return 0; } -static void start_discovery(const u8_t *data, u16_t len) +static void start_discovery(const uint8_t *data, uint16_t len) { const struct gap_start_discovery_cmd *cmd = (void *) data; struct ble_gap_disc_params params = {0}; - u8_t status; + uint8_t status; SYS_LOG_DBG(""); @@ -626,9 +626,9 @@ reply: status); } -static void stop_discovery(const u8_t *data, u16_t len) +static void stop_discovery(const uint8_t *data, uint16_t len) { - u8_t status = BTP_STATUS_SUCCESS; + uint8_t status = BTP_STATUS_SUCCESS; SYS_LOG_DBG(""); @@ -680,13 +680,13 @@ static void device_connected_ev_send(struct os_event *ev) } tester_send(BTP_SERVICE_ID_GAP, GAP_EV_DEVICE_CONNECTED, - CONTROLLER_INDEX, (u8_t *) &connected_ev, + CONTROLLER_INDEX, (uint8_t *) &connected_ev, sizeof(connected_ev)); periph_privacy(desc); } -static void le_connected(u16_t conn_handle, int status) +static void le_connected(uint16_t conn_handle, int status) { struct ble_gap_conn_desc desc; ble_addr_t *addr; @@ -720,7 +720,7 @@ static void le_connected(u16_t conn_handle, int status) CONNECTED_EV_DELAY_MS(desc.conn_itvl))); #else tester_send(BTP_SERVICE_ID_GAP, GAP_EV_DEVICE_CONNECTED, - CONTROLLER_INDEX, (u8_t *) &connected_ev, + CONTROLLER_INDEX, (uint8_t *) &connected_ev, sizeof(connected_ev)); #endif } @@ -763,10 +763,10 @@ static void le_disconnected(struct ble_gap_conn_desc *conn, int reason) ev.address_type = addr->type; tester_send(BTP_SERVICE_ID_GAP, GAP_EV_DEVICE_DISCONNECTED, - CONTROLLER_INDEX, (u8_t *) &ev, sizeof(ev)); + CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev)); } -static void auth_passkey_oob(u16_t conn_handle) +static void auth_passkey_oob(uint16_t conn_handle) { struct ble_gap_conn_desc desc; struct ble_sm_io pk; @@ -786,7 +786,7 @@ static void auth_passkey_oob(u16_t conn_handle) assert(rc == 0); } -static void auth_passkey_display(u16_t conn_handle, unsigned int passkey) +static void auth_passkey_display(uint16_t conn_handle, unsigned int passkey) { struct ble_gap_conn_desc desc; struct gap_passkey_display_ev ev; @@ -817,10 +817,10 @@ static void auth_passkey_display(u16_t conn_handle, unsigned int passkey) ev.passkey = sys_cpu_to_le32(pk.passkey); tester_send(BTP_SERVICE_ID_GAP, GAP_EV_PASSKEY_DISPLAY, - CONTROLLER_INDEX, (u8_t *) &ev, sizeof(ev)); + CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev)); } -static void auth_passkey_entry(u16_t conn_handle) +static void auth_passkey_entry(uint16_t conn_handle) { struct ble_gap_conn_desc desc; struct gap_passkey_entry_req_ev ev; @@ -840,10 +840,10 @@ static void auth_passkey_entry(u16_t conn_handle) ev.address_type = addr->type; tester_send(BTP_SERVICE_ID_GAP, GAP_EV_PASSKEY_ENTRY_REQ, - CONTROLLER_INDEX, (u8_t *) &ev, sizeof(ev)); + CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev)); } -static void auth_passkey_numcmp(u16_t conn_handle, unsigned int passkey) +static void auth_passkey_numcmp(uint16_t conn_handle, unsigned int passkey) { struct ble_gap_conn_desc desc; struct gap_passkey_confirm_req_ev ev; @@ -864,10 +864,10 @@ static void auth_passkey_numcmp(u16_t conn_handle, unsigned int passkey) ev.passkey = sys_cpu_to_le32(passkey); tester_send(BTP_SERVICE_ID_GAP, GAP_EV_PASSKEY_CONFIRM_REQ, - CONTROLLER_INDEX, (u8_t *) &ev, sizeof(ev)); + CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev)); } -static void auth_passkey_oob_sc(u16_t conn_handle) +static void auth_passkey_oob_sc(uint16_t conn_handle) { int rc; struct ble_sm_io pk; @@ -889,7 +889,7 @@ static void auth_passkey_oob_sc(u16_t conn_handle) } } -static void le_passkey_action(u16_t conn_handle, +static void le_passkey_action(uint16_t conn_handle, struct ble_gap_passkey_params *params) { SYS_LOG_DBG(""); @@ -917,7 +917,7 @@ static void le_passkey_action(u16_t conn_handle, } } -static void le_identity_resolved(u16_t conn_handle) +static void le_identity_resolved(uint16_t conn_handle) { struct ble_gap_conn_desc desc; struct gap_identity_resolved_ev ev; @@ -941,7 +941,7 @@ static void le_identity_resolved(u16_t conn_handle) sizeof(ev.identity_address)); tester_send(BTP_SERVICE_ID_GAP, GAP_EV_IDENTITY_RESOLVED, - CONTROLLER_INDEX, (u8_t *) &ev, sizeof(ev)); + CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev)); } static void le_conn_param_update(struct ble_gap_conn_desc *desc) @@ -958,7 +958,7 @@ static void le_conn_param_update(struct ble_gap_conn_desc *desc) ev.supervision_timeout = desc->supervision_timeout; tester_send(BTP_SERVICE_ID_GAP, GAP_EV_CONN_PARAM_UPDATE, - CONTROLLER_INDEX, (u8_t *) &ev, sizeof(ev)); + CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev)); } static void le_encryption_changed(struct ble_gap_conn_desc *desc) @@ -986,7 +986,7 @@ static void le_encryption_changed(struct ble_gap_conn_desc *desc) } tester_send(BTP_SERVICE_ID_GAP, GAP_EV_SEC_LEVEL_CHANGED, - CONTROLLER_INDEX, (u8_t *) &ev, sizeof(ev)); + CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev)); } static void print_bytes(const uint8_t *bytes, int len) @@ -1055,7 +1055,7 @@ static void adv_complete(void) ev.current_settings = sys_cpu_to_le32(current_settings); tester_send(BTP_SERVICE_ID_GAP, GAP_EV_NEW_SETTINGS, CONTROLLER_INDEX, - (u8_t *) &ev, sizeof(ev)); + (uint8_t *) &ev, sizeof(ev)); } static int gap_event_cb(struct ble_gap_event *event, void *arg) @@ -1197,9 +1197,9 @@ static int gap_event_cb(struct ble_gap_event *event, void *arg) return 0; } -static void connect(const u8_t *data, u16_t len) +static void connect(const uint8_t *data, uint16_t len) { - u8_t status = BTP_STATUS_SUCCESS; + uint8_t status = BTP_STATUS_SUCCESS; SYS_LOG_DBG(""); @@ -1211,10 +1211,10 @@ static void connect(const u8_t *data, u16_t len) tester_rsp(BTP_SERVICE_ID_GAP, GAP_CONNECT, CONTROLLER_INDEX, status); } -static void disconnect(const u8_t *data, u16_t len) +static void disconnect(const uint8_t *data, uint16_t len) { struct ble_gap_conn_desc desc; - u8_t status; + uint8_t status; int rc; SYS_LOG_DBG(""); @@ -1236,10 +1236,10 @@ rsp: status); } -static void set_io_cap(const u8_t *data, u16_t len) +static void set_io_cap(const uint8_t *data, uint16_t len) { const struct gap_set_io_cap_cmd *cmd = (void *) data; - u8_t status; + uint8_t status; SYS_LOG_DBG(""); @@ -1276,10 +1276,10 @@ rsp: status); } -static void pair(const u8_t *data, u16_t len) +static void pair(const uint8_t *data, uint16_t len) { struct ble_gap_conn_desc desc; - u8_t status; + uint8_t status; int rc; SYS_LOG_DBG(""); @@ -1301,9 +1301,9 @@ rsp: tester_rsp(BTP_SERVICE_ID_GAP, GAP_PAIR, CONTROLLER_INDEX, status); } -static void unpair(const u8_t *data, u16_t len) +static void unpair(const uint8_t *data, uint16_t len) { - u8_t status; + uint8_t status; int err; SYS_LOG_DBG(""); @@ -1313,12 +1313,12 @@ static void unpair(const u8_t *data, u16_t len) tester_rsp(BTP_SERVICE_ID_GAP, GAP_UNPAIR, CONTROLLER_INDEX, status); } -static void passkey_entry(const u8_t *data, u16_t len) +static void passkey_entry(const uint8_t *data, uint16_t len) { const struct gap_passkey_entry_cmd *cmd = (void *) data; struct ble_gap_conn_desc desc; struct ble_sm_io pk; - u8_t status; + uint8_t status; int rc; SYS_LOG_DBG(""); @@ -1345,12 +1345,12 @@ rsp: status); } -static void passkey_confirm(const u8_t *data, u16_t len) +static void passkey_confirm(const uint8_t *data, uint16_t len) { const struct gap_passkey_confirm_cmd *cmd = (void *) data; struct ble_gap_conn_desc desc; struct ble_sm_io pk; - u8_t status; + uint8_t status; int rc; SYS_LOG_DBG(""); @@ -1378,7 +1378,7 @@ rsp: status); } -static void start_direct_adv(const u8_t *data, u16_t len) +static void start_direct_adv(const uint8_t *data, uint16_t len) { const struct gap_start_direct_adv_cmd *cmd = (void *) data; struct gap_start_advertising_rp rp; @@ -1403,7 +1403,7 @@ static void start_direct_adv(const u8_t *data, u16_t len) rp.current_settings = sys_cpu_to_le32(current_settings); tester_send(BTP_SERVICE_ID_GAP, GAP_START_DIRECT_ADV, CONTROLLER_INDEX, - (u8_t *) &rp, sizeof(rp)); + (uint8_t *) &rp, sizeof(rp)); return; fail: tester_rsp(BTP_SERVICE_ID_GAP, GAP_START_DIRECT_ADV, CONTROLLER_INDEX, @@ -1416,7 +1416,7 @@ static void conn_param_update_cb(uint16_t conn_handle, int status, void *arg) conn_handle, status); } -static int conn_param_update_slave(u16_t conn_handle, +static int conn_param_update_slave(uint16_t conn_handle, const struct gap_conn_param_update_cmd *cmd) { int rc; @@ -1436,7 +1436,7 @@ static int conn_param_update_slave(u16_t conn_handle, return 0; } -static int conn_param_update_master(u16_t conn_handle, +static int conn_param_update_master(uint16_t conn_handle, const struct gap_conn_param_update_cmd *cmd) { int rc; @@ -1489,7 +1489,7 @@ rsp: SYS_LOG_ERR("Conn param update fail; rc=%d", rc); } -static void conn_param_update_async(const u8_t *data, u16_t len) +static void conn_param_update_async(const uint8_t *data, uint16_t len) { const struct gap_conn_param_update_cmd *cmd = (void *) data; update_params = *cmd; @@ -1500,7 +1500,7 @@ static void conn_param_update_async(const u8_t *data, u16_t len) BTP_STATUS_SUCCESS); } -static void oob_legacy_set_data(const u8_t *data, u16_t len) +static void oob_legacy_set_data(const uint8_t *data, uint16_t len) { const struct gap_oob_legacy_set_data_cmd *cmd = (void *) data; @@ -1511,7 +1511,7 @@ static void oob_legacy_set_data(const u8_t *data, u16_t len) CONTROLLER_INDEX, BTP_STATUS_SUCCESS); } -static void oob_sc_get_local_data(const u8_t *data, u16_t len) +static void oob_sc_get_local_data(const uint8_t *data, uint16_t len) { struct gap_oob_sc_get_local_data_rp rp; @@ -1519,10 +1519,10 @@ static void oob_sc_get_local_data(const u8_t *data, u16_t len) memcpy(rp.c, oob_data_local.c, 16); tester_send(BTP_SERVICE_ID_GAP, GAP_OOB_SC_GET_LOCAL_DATA, - CONTROLLER_INDEX, (u8_t *) &rp, sizeof(rp)); + CONTROLLER_INDEX, (uint8_t *) &rp, sizeof(rp)); } -static void oob_sc_set_remote_data(const u8_t *data, u16_t len) +static void oob_sc_set_remote_data(const uint8_t *data, uint16_t len) { const struct gap_oob_sc_set_remote_data_cmd *cmd = (void *) data; @@ -1534,7 +1534,7 @@ static void oob_sc_set_remote_data(const u8_t *data, u16_t len) CONTROLLER_INDEX, BTP_STATUS_SUCCESS); } -static void set_mitm(const u8_t *data, u16_t len) +static void set_mitm(const uint8_t *data, uint16_t len) { const struct gap_set_mitm_cmd *cmd = (void *) data; @@ -1544,8 +1544,8 @@ static void set_mitm(const u8_t *data, u16_t len) CONTROLLER_INDEX, BTP_STATUS_SUCCESS); } -void tester_handle_gap(u8_t opcode, u8_t index, u8_t *data, - u16_t len) +void tester_handle_gap(uint8_t opcode, uint8_t index, uint8_t *data, + uint16_t len) { switch (opcode) { case GAP_READ_SUPPORTED_COMMANDS: @@ -1664,7 +1664,7 @@ static void tester_init_gap_cb(int err) BTP_STATUS_SUCCESS); } -u8_t tester_init_gap(void) +uint8_t tester_init_gap(void) { #if MYNEWT_VAL(BLE_SM_SC) int rc; @@ -1682,7 +1682,7 @@ u8_t tester_init_gap(void) return BTP_STATUS_SUCCESS; } -u8_t tester_unregister_gap(void) +uint8_t tester_unregister_gap(void) { return BTP_STATUS_SUCCESS; } diff --git a/apps/bttester/src/gatt.c b/apps/bttester/src/gatt.c index 7e7d1d3b6..d40de262b 100644 --- a/apps/bttester/src/gatt.c +++ b/apps/bttester/src/gatt.c @@ -76,8 +76,8 @@ static uint8_t gatt_svr_pts_static_long_val[300]; static uint8_t gatt_svr_pts_static_val[30]; static uint8_t gatt_svr_pts_static_short_val; -static u8_t notify_state; -static u8_t indicate_state; +static uint8_t notify_state; +static uint8_t indicate_state; static uint16_t myconn_handle; static struct os_callout notify_tx_timer; uint16_t notify_handle; @@ -253,7 +253,7 @@ static const struct ble_gatt_svc_def gatt_svr_svcs[] = { }, }; -static void attr_value_changed_ev(u16_t handle, struct os_mbuf *data) +static void attr_value_changed_ev(uint16_t handle, struct os_mbuf *data) { struct gatt_attr_value_changed_ev *ev; struct os_mbuf *buf = os_msys_get(0, 0); @@ -569,7 +569,7 @@ gatt_svr_rel_write_test(uint16_t conn_handle, uint16_t attr_handle, } } -static void start_server(u8_t *data, u16_t len) +static void start_server(uint8_t *data, uint16_t len) { struct gatt_start_server_rp rp; @@ -583,14 +583,14 @@ static void start_server(u8_t *data, u16_t len) rp.db_attr_cnt = 0; tester_send(BTP_SERVICE_ID_GATT, GATT_START_SERVER, CONTROLLER_INDEX, - (u8_t *) &rp, sizeof(rp)); + (uint8_t *) &rp, sizeof(rp)); } /* Convert UUID from BTP command to bt_uuid */ -static u8_t btp2bt_uuid(const u8_t *uuid, u8_t len, +static uint8_t btp2bt_uuid(const uint8_t *uuid, uint8_t len, ble_uuid_any_t *bt_uuid) { - u16_t le16; + uint16_t le16; switch (len) { case 0x02: /* UUID 16 */ @@ -614,8 +614,8 @@ static u8_t btp2bt_uuid(const u8_t *uuid, u8_t len, * It is not intended to be used by client and server at the same time. */ static struct { - u16_t len; - u8_t buf[MAX_BUFFER_SIZE]; + uint16_t len; + uint8_t buf[MAX_BUFFER_SIZE]; } gatt_buf; static void *gatt_buf_add(const void *data, size_t len) @@ -665,7 +665,7 @@ static int read_cb(uint16_t conn_handle, void *arg) { struct gatt_read_rp *rp = (void *) gatt_buf.buf; - u8_t btp_opcode = (uint8_t) (int) arg; + uint8_t btp_opcode = (uint8_t) (int) arg; SYS_LOG_DBG("status=%d", error->status); @@ -692,7 +692,7 @@ static int read_cb(uint16_t conn_handle, return 0; } -static void read(u8_t *data, u16_t len) +static void read(uint8_t *data, uint16_t len) { const struct gatt_read_cmd *cmd = (void *) data; struct ble_gap_conn_desc conn; @@ -731,7 +731,7 @@ static int read_long_cb(uint16_t conn_handle, void *arg) { struct gatt_read_rp *rp = (void *) gatt_buf.buf; - u8_t btp_opcode = (uint8_t) (int) arg; + uint8_t btp_opcode = (uint8_t) (int) arg; SYS_LOG_DBG("status=%d", error->status); @@ -762,7 +762,7 @@ static int read_long_cb(uint16_t conn_handle, return 0; } -static void read_long(u8_t *data, u16_t len) +static void read_long(uint8_t *data, uint16_t len) { const struct gatt_read_long_cmd *cmd = (void *) data; struct ble_gap_conn_desc conn; @@ -797,10 +797,10 @@ fail: BTP_STATUS_FAILED); } -static void read_multiple(u8_t *data, u16_t len) +static void read_multiple(uint8_t *data, uint16_t len) { const struct gatt_read_multiple_cmd *cmd = (void *) data; - u16_t handles[cmd->handles_count]; + uint16_t handles[cmd->handles_count]; struct ble_gap_conn_desc conn; int rc, i; @@ -836,11 +836,11 @@ fail: BTP_STATUS_FAILED); } -static void write_without_rsp(u8_t *data, u16_t len, u8_t op, bool sign) +static void write_without_rsp(uint8_t *data, uint16_t len, uint8_t op, bool sign) { const struct gatt_write_without_rsp_cmd *cmd = (void *) data; struct ble_gap_conn_desc conn; - u8_t status = BTP_STATUS_SUCCESS; + uint8_t status = BTP_STATUS_SUCCESS; int rc; SYS_LOG_DBG(""); @@ -866,7 +866,7 @@ static int write_rsp(uint16_t conn_handle, const struct ble_gatt_error *error, void *arg) { uint8_t err = (uint8_t) error->status; - u8_t btp_opcode = (uint8_t) (int) arg; + uint8_t btp_opcode = (uint8_t) (int) arg; SYS_LOG_DBG(""); @@ -875,7 +875,7 @@ static int write_rsp(uint16_t conn_handle, const struct ble_gatt_error *error, return 0; } -static void write(u8_t *data, u16_t len) +static void write(uint8_t *data, uint16_t len) { const struct gatt_write_cmd *cmd = (void *) data; struct ble_gap_conn_desc conn; @@ -901,7 +901,7 @@ fail: BTP_STATUS_FAILED); } -static void write_long(u8_t *data, u16_t len) +static void write_long(uint8_t *data, uint16_t len) { const struct gatt_write_long_cmd *cmd = (void *) data; struct ble_gap_conn_desc conn; @@ -952,7 +952,7 @@ static int reliable_write_rsp(uint16_t conn_handle, return 0; } -static void reliable_write(u8_t *data, u16_t len) +static void reliable_write(uint8_t *data, uint16_t len) { const struct gatt_reliable_write_cmd *cmd = (void *) data; struct ble_gap_conn_desc conn; @@ -994,12 +994,12 @@ fail: } static struct bt_gatt_subscribe_params { - u16_t ccc_handle; - u16_t value; - u16_t value_handle; + uint16_t ccc_handle; + uint16_t value; + uint16_t value_handle; } subscribe_params; -static void read_uuid(u8_t *data, u16_t len) +static void read_uuid(uint8_t *data, uint16_t len) { const struct gatt_read_uuid_cmd *cmd = (void *) data; struct ble_gap_conn_desc conn; @@ -1046,8 +1046,8 @@ static int disc_prim_uuid_cb(uint16_t conn_handle, struct gatt_disc_prim_uuid_rp *rp = (void *) gatt_buf.buf; struct gatt_service *service; const ble_uuid_any_t *uuid; - u8_t uuid_length; - u8_t opcode = (u8_t) (int) arg; + uint8_t uuid_length; + uint8_t opcode = (uint8_t) (int) arg; SYS_LOG_DBG(""); @@ -1081,7 +1081,7 @@ static int disc_prim_uuid_cb(uint16_t conn_handle, service->uuid_length = uuid_length; if (uuid->u.type == BLE_UUID_TYPE_16) { - u16_t u16 = sys_cpu_to_le16(BLE_UUID16(uuid)->value); + uint16_t u16 = sys_cpu_to_le16(BLE_UUID16(uuid)->value); memcpy(service->uuid, &u16, uuid_length); } else { memcpy(service->uuid, BLE_UUID128(uuid)->value, @@ -1102,7 +1102,7 @@ static int disc_all_desc_cb(uint16_t conn_handle, struct gatt_disc_all_desc_rp *rp = (void *) gatt_buf.buf; struct gatt_descriptor *dsc; const ble_uuid_any_t *uuid; - u8_t uuid_length; + uint8_t uuid_length; SYS_LOG_DBG(""); @@ -1135,7 +1135,7 @@ static int disc_all_desc_cb(uint16_t conn_handle, dsc->uuid_length = uuid_length; if (uuid->u.type == BLE_UUID_TYPE_16) { - u16_t u16 = sys_cpu_to_le16(BLE_UUID16(uuid)->value); + uint16_t u16 = sys_cpu_to_le16(BLE_UUID16(uuid)->value); memcpy(dsc->uuid, &u16, uuid_length); } else { memcpy(dsc->uuid, BLE_UUID128(uuid)->value, uuid_length); @@ -1146,7 +1146,7 @@ static int disc_all_desc_cb(uint16_t conn_handle, return 0; } -static void disc_all_prim_svcs(u8_t *data, u16_t len) +static void disc_all_prim_svcs(uint8_t *data, uint16_t len) { struct ble_gap_conn_desc conn; int rc; @@ -1175,7 +1175,7 @@ fail: CONTROLLER_INDEX, BTP_STATUS_FAILED); } -static void disc_all_desc(u8_t *data, u16_t len) +static void disc_all_desc(uint8_t *data, uint16_t len) { const struct gatt_disc_all_desc_cmd *cmd = (void *) data; struct ble_gap_conn_desc conn; @@ -1221,7 +1221,7 @@ static int find_included_cb(uint16_t conn_handle, struct gatt_included *included; const ble_uuid_any_t *uuid; int service_handle = (int) arg; - u8_t uuid_length; + uint8_t uuid_length; SYS_LOG_DBG(""); @@ -1259,7 +1259,7 @@ static int find_included_cb(uint16_t conn_handle, included->service.uuid_length = uuid_length; if (uuid->u.type == BLE_UUID_TYPE_16) { - u16_t u16 = sys_cpu_to_le16(BLE_UUID16(uuid)->value); + uint16_t u16 = sys_cpu_to_le16(BLE_UUID16(uuid)->value); memcpy(included->service.uuid, &u16, uuid_length); } else { memcpy(included->service.uuid, BLE_UUID128(uuid)->value, @@ -1278,8 +1278,8 @@ static int disc_chrc_cb(uint16_t conn_handle, struct gatt_disc_chrc_rp *rp = (void *) gatt_buf.buf; struct gatt_characteristic *chrc; const ble_uuid_any_t *uuid; - u8_t btp_opcode = (uint8_t) (int) arg; - u8_t uuid_length; + uint8_t btp_opcode = (uint8_t) (int) arg; + uint8_t uuid_length; SYS_LOG_DBG(""); @@ -1314,7 +1314,7 @@ static int disc_chrc_cb(uint16_t conn_handle, chrc->uuid_length = uuid_length; if (uuid->u.type == BLE_UUID_TYPE_16) { - u16_t u16 = sys_cpu_to_le16(BLE_UUID16(uuid)->value); + uint16_t u16 = sys_cpu_to_le16(BLE_UUID16(uuid)->value); memcpy(chrc->uuid, &u16, uuid_length); } else { memcpy(chrc->uuid, BLE_UUID128(uuid)->value, @@ -1326,7 +1326,7 @@ static int disc_chrc_cb(uint16_t conn_handle, return 0; } -static void disc_chrc_uuid(u8_t *data, u16_t len) +static void disc_chrc_uuid(uint8_t *data, uint16_t len) { const struct gatt_disc_chrc_uuid_cmd *cmd = (void *) data; struct ble_gap_conn_desc conn; @@ -1366,7 +1366,7 @@ fail: BTP_STATUS_FAILED); } -static void disc_prim_uuid(u8_t *data, u16_t len) +static void disc_prim_uuid(uint8_t *data, uint16_t len) { const struct gatt_disc_prim_uuid_cmd *cmd = (void *) data; struct ble_gap_conn_desc conn; @@ -1402,7 +1402,7 @@ fail: BTP_STATUS_FAILED); } -static void disc_all_chrc(u8_t *data, u16_t len) +static void disc_all_chrc(uint8_t *data, uint16_t len) { const struct gatt_disc_all_chrc_cmd *cmd = (void *) data; struct ble_gap_conn_desc conn; @@ -1439,7 +1439,7 @@ fail: BTP_STATUS_FAILED); } -static void find_included(u8_t *data, u16_t len) +static void find_included(uint8_t *data, uint16_t len) { const struct gatt_find_included_cmd *cmd = (void *) data; struct ble_gap_conn_desc conn; @@ -1495,7 +1495,7 @@ static int exchange_func(uint16_t conn_handle, return 0; } -static void exchange_mtu(u8_t *data, u16_t len) +static void exchange_mtu(uint8_t *data, uint16_t len) { struct ble_gap_conn_desc conn; int rc; @@ -1517,10 +1517,10 @@ fail: CONTROLLER_INDEX, BTP_STATUS_FAILED); } -static int enable_subscription(u16_t conn_handle, u16_t ccc_handle, - u16_t value) +static int enable_subscription(uint16_t conn_handle, uint16_t ccc_handle, + uint16_t value) { - u8_t op; + uint8_t op; SYS_LOG_DBG(""); @@ -1538,9 +1538,9 @@ static int enable_subscription(u16_t conn_handle, u16_t ccc_handle, return 0; } -static int disable_subscription(u16_t conn_handle, u16_t ccc_handle) +static int disable_subscription(uint16_t conn_handle, uint16_t ccc_handle) { - u16_t value = 0x00; + uint16_t value = 0x00; SYS_LOG_DBG(""); @@ -1559,12 +1559,12 @@ static int disable_subscription(u16_t conn_handle, u16_t ccc_handle) return 0; } -static void config_subscription(u8_t *data, u16_t len, u8_t op) +static void config_subscription(uint8_t *data, uint16_t len, uint8_t op) { const struct gatt_cfg_notify_cmd *cmd = (void *) data; struct ble_gap_conn_desc conn; - u16_t ccc_handle = sys_le16_to_cpu(cmd->ccc_handle); - u8_t status; + uint16_t ccc_handle = sys_le16_to_cpu(cmd->ccc_handle); + uint8_t status; int rc; SYS_LOG_DBG(""); @@ -1577,7 +1577,7 @@ static void config_subscription(u8_t *data, u16_t len, u8_t op) } if (cmd->enable) { - u16_t value; + uint16_t value; if (op == GATT_CFG_NOTIFY) { value = 0x0001; @@ -1625,10 +1625,10 @@ static int flags_hs2btp_map[] = { BTP_PERM_F_WRITE_AUTHOR, }; -static u8_t flags_hs2btp(u8_t flags) +static uint8_t flags_hs2btp(uint8_t flags) { int i; - u8_t ret = 0; + uint8_t ret = 0; for (i = 0; i < 8; ++i) { if (flags & BIT(i)) { @@ -1639,17 +1639,17 @@ static u8_t flags_hs2btp(u8_t flags) return ret; } -static void get_attrs(u8_t *data, u16_t len) +static void get_attrs(uint8_t *data, uint16_t len) { const struct gatt_get_attributes_cmd *cmd = (void *) data; struct gatt_get_attributes_rp *rp; struct gatt_attr *gatt_attr; struct os_mbuf *buf = os_msys_get(0, 0); - u16_t start_handle, end_handle; + uint16_t start_handle, end_handle; struct ble_att_svr_entry *entry = NULL; ble_uuid_any_t uuid; ble_uuid_t *uuid_ptr = NULL; - u8_t count = 0; + uint8_t count = 0; char str[BLE_UUID_STR_LEN]; SYS_LOG_DBG(""); @@ -1718,13 +1718,13 @@ free: os_mbuf_free_chain(buf); } -static void get_attr_val(u8_t *data, u16_t len) +static void get_attr_val(uint8_t *data, uint16_t len) { const struct gatt_get_attribute_value_cmd *cmd = (void *) data; struct gatt_get_attribute_value_rp *rp; struct ble_gap_conn_desc conn; struct os_mbuf *buf = os_msys_get(0, 0); - u16_t handle = sys_cpu_to_le16(cmd->handle); + uint16_t handle = sys_cpu_to_le16(cmd->handle); uint8_t out_att_err; int conn_status; @@ -1766,7 +1766,7 @@ free: os_mbuf_free_chain(buf); } -static void change_database(u8_t *data, u16_t len) +static void change_database(uint8_t *data, uint16_t len) { const struct gatt_change_database *cmd = (void *) data; @@ -1782,9 +1782,9 @@ static void change_database(u8_t *data, u16_t len) return; } -static void supported_commands(u8_t *data, u16_t len) +static void supported_commands(uint8_t *data, uint16_t len) { - u8_t cmds[4]; + uint8_t cmds[4]; struct gatt_read_supported_commands_rp *rp = (void *) cmds; SYS_LOG_DBG(""); @@ -1816,7 +1816,7 @@ static void supported_commands(u8_t *data, u16_t len) tester_set_bit(cmds, GATT_CHANGE_DATABASE); tester_send(BTP_SERVICE_ID_GATT, GATT_READ_SUPPORTED_COMMANDS, - CONTROLLER_INDEX, (u8_t *) rp, sizeof(cmds)); + CONTROLLER_INDEX, (uint8_t *) rp, sizeof(cmds)); } enum attr_type { @@ -1825,8 +1825,8 @@ enum attr_type { BLE_GATT_ATTR_DSC, }; -void tester_handle_gatt(u8_t opcode, u8_t index, u8_t *data, - u16_t len) +void tester_handle_gatt(uint8_t opcode, uint8_t index, uint8_t *data, + uint16_t len) { switch (opcode) { case GATT_READ_SUPPORTED_COMMANDS: @@ -1905,8 +1905,8 @@ void tester_handle_gatt(u8_t opcode, u8_t index, u8_t *data, } } -int tester_gatt_notify_rx_ev(u16_t conn_handle, u16_t attr_handle, - u8_t indication, struct os_mbuf *om) +int tester_gatt_notify_rx_ev(uint16_t conn_handle, uint16_t attr_handle, + uint8_t indication, struct os_mbuf *om) { struct gatt_notification_ev *ev; struct ble_gap_conn_desc conn; @@ -1930,7 +1930,7 @@ int tester_gatt_notify_rx_ev(u16_t conn_handle, u16_t attr_handle, ev->address_type = addr->type; memcpy(ev->address, addr->val, sizeof(ev->address)); - ev->type = (u8_t) (indication ? 0x02 : 0x01); + ev->type = (uint8_t) (indication ? 0x02 : 0x01); ev->handle = sys_cpu_to_le16(attr_handle); ev->data_length = sys_cpu_to_le16(os_mbuf_len(om)); os_mbuf_appendfrom(buf, om, 0, os_mbuf_len(om)); @@ -1988,9 +1988,9 @@ void notify_test(struct os_event *ev) } } -int tester_gatt_subscribe_ev(u16_t conn_handle, u16_t attr_handle, u8_t reason, - u8_t prev_notify, u8_t cur_notify, - u8_t prev_indicate, u8_t cur_indicate) +int tester_gatt_subscribe_ev(uint16_t conn_handle, uint16_t attr_handle, uint8_t reason, + uint8_t prev_notify, uint8_t cur_notify, + uint8_t prev_indicate, uint8_t cur_indicate) { SYS_LOG_DBG(""); myconn_handle = conn_handle; @@ -2084,7 +2084,7 @@ int gatt_svr_init(void) return 0; } -u8_t tester_init_gatt(void) +uint8_t tester_init_gatt(void) { os_callout_init(¬ify_tx_timer, os_eventq_dflt_get(), notify_test, NULL); @@ -2092,7 +2092,7 @@ u8_t tester_init_gatt(void) return BTP_STATUS_SUCCESS; } -u8_t tester_unregister_gatt(void) +uint8_t tester_unregister_gatt(void) { return BTP_STATUS_SUCCESS; } diff --git a/apps/bttester/src/glue.c b/apps/bttester/src/glue.c index 6cd7643c0..3e606062a 100644 --- a/apps/bttester/src/glue.c +++ b/apps/bttester/src/glue.c @@ -33,8 +33,8 @@ const char *bt_hex(const void *buf, size_t len) { static const char hex[] = "0123456789abcdef"; static char hexbufs[4][137]; - static u8_t curbuf; - const u8_t *b = buf; + static uint8_t curbuf; + const uint8_t *b = buf; char *str; int i; diff --git a/apps/bttester/src/glue.h b/apps/bttester/src/glue.h index e563331ed..650856015 100644 --- a/apps/bttester/src/glue.h +++ b/apps/bttester/src/glue.h @@ -22,11 +22,11 @@ #include "os/endian.h" -#define u8_t uint8_t -#define s8_t int8_t -#define u16_t uint16_t -#define u32_t uint32_t -#define s32_t int32_t +#define uint8_t uint8_t +#define int8_t int8_t +#define uint16_t uint16_t +#define uint32_t uint32_t +#define int32_t int32_t #ifndef BIT #define BIT(n) (1UL << (n)) @@ -37,16 +37,16 @@ #define sys_le16_to_cpu le16toh struct bt_data { - u8_t type; - u8_t data_len; - const u8_t *data; + uint8_t type; + uint8_t data_len; + const uint8_t *data; }; #define BT_DATA(_type, _data, _data_len) \ { \ .type = (_type), \ .data_len = (_data_len), \ - .data = (const u8_t *)(_data), \ + .data = (const uint8_t *)(_data), \ } struct os_mbuf * NET_BUF_SIMPLE(uint16_t size); diff --git a/apps/bttester/src/l2cap.c b/apps/bttester/src/l2cap.c index 77a2a8c73..5c4fc7129 100644 --- a/apps/bttester/src/l2cap.c +++ b/apps/bttester/src/l2cap.c @@ -50,16 +50,16 @@ struct os_mbuf_pool sdu_os_mbuf_pool; static struct os_mempool sdu_coc_mbuf_mempool; static struct channel { - u8_t chan_id; /* Internal number that identifies L2CAP channel. */ - u8_t state; + uint8_t chan_id; /* Internal number that identifies L2CAP channel. */ + uint8_t state; struct ble_l2cap_chan *chan; } channels[CHANNELS]; -static u8_t recv_cb_buf[TESTER_COC_MTU + sizeof(struct l2cap_data_received_ev)]; +static uint8_t recv_cb_buf[TESTER_COC_MTU + sizeof(struct l2cap_data_received_ev)]; static struct channel *get_free_channel(void) { - u8_t i; + uint8_t i; struct channel *chan; for (i = 0; i < CHANNELS; i++) { @@ -166,7 +166,7 @@ static void reconfigured_ev(uint16_t conn_handle, struct ble_l2cap_chan *chan, ev.our_mps = chan_info->our_l2cap_mtu; tester_send(BTP_SERVICE_ID_L2CAP, L2CAP_EV_RECONFIGURED, - CONTROLLER_INDEX, (u8_t *) &ev, sizeof(ev)); + CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev)); } static void connected_cb(uint16_t conn_handle, struct ble_l2cap_chan *chan, @@ -196,7 +196,7 @@ static void connected_cb(uint16_t conn_handle, struct ble_l2cap_chan *chan, } tester_send(BTP_SERVICE_ID_L2CAP, L2CAP_EV_CONNECTED, CONTROLLER_INDEX, - (u8_t *) &ev, sizeof(ev)); + (uint8_t *) &ev, sizeof(ev)); } static void disconnected_cb(uint16_t conn_handle, struct ble_l2cap_chan *chan, @@ -223,7 +223,7 @@ static void disconnected_cb(uint16_t conn_handle, struct ble_l2cap_chan *chan, } tester_send(BTP_SERVICE_ID_L2CAP, L2CAP_EV_DISCONNECTED, - CONTROLLER_INDEX, (u8_t *) &ev, sizeof(ev)); + CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev)); } static int accept_cb(uint16_t conn_handle, uint16_t peer_mtu, @@ -364,10 +364,10 @@ tester_l2cap_event(struct ble_l2cap_event *event, void *arg) } } -static void connect(u8_t *data, u16_t len) +static void connect(uint8_t *data, uint16_t len) { const struct l2cap_connect_cmd *cmd = (void *) data; - u8_t rp_buf[sizeof(struct l2cap_connect_rp) + cmd->num]; + uint8_t rp_buf[sizeof(struct l2cap_connect_rp) + cmd->num]; struct l2cap_connect_rp *rp = (void *) rp_buf; struct ble_gap_conn_desc desc; struct channel *chan; @@ -427,7 +427,7 @@ static void connect(u8_t *data, u16_t len) } tester_send(BTP_SERVICE_ID_L2CAP, L2CAP_CONNECT, CONTROLLER_INDEX, - (u8_t *) rp, sizeof(rp_buf)); + (uint8_t *) rp, sizeof(rp_buf)); return; @@ -436,11 +436,11 @@ fail: BTP_STATUS_FAILED); } -static void disconnect(const u8_t *data, u16_t len) +static void disconnect(const uint8_t *data, uint16_t len) { const struct l2cap_disconnect_cmd *cmd = (void *) data; struct channel *chan; - u8_t status; + uint8_t status; int err; SYS_LOG_DBG(""); @@ -461,12 +461,12 @@ rsp: status); } -static void send_data(const u8_t *data, u16_t len) +static void send_data(const uint8_t *data, uint16_t len) { const struct l2cap_send_data_cmd *cmd = (void *) data; struct os_mbuf *sdu_tx = NULL; int rc; - u16_t data_len = sys_le16_to_cpu(cmd->data_len); + uint16_t data_len = sys_le16_to_cpu(cmd->data_len); struct channel *chan = get_channel(cmd->chan_id); SYS_LOG_DBG("cmd->chan_id=%d", cmd->chan_id); @@ -530,7 +530,7 @@ l2cap_coc_err2hs_err(uint16_t coc_err) } -static void listen(const u8_t *data, u16_t len) +static void listen(const uint8_t *data, uint16_t len) { const struct l2cap_listen_cmd *cmd = (void *) data; uint16_t mtu = htole16(cmd->mtu); @@ -561,7 +561,7 @@ fail: BTP_STATUS_FAILED); } -static void reconfigure(const u8_t *data, u16_t len) +static void reconfigure(const uint8_t *data, uint16_t len) { const struct l2cap_reconfigure_cmd *cmd = (void *) data; uint16_t mtu = htole16(cmd->mtu); @@ -606,9 +606,9 @@ fail: BTP_STATUS_FAILED); } -static void supported_commands(u8_t *data, u16_t len) +static void supported_commands(uint8_t *data, uint16_t len) { - u8_t cmds[1]; + uint8_t cmds[1]; struct l2cap_read_supported_commands_rp *rp = (void *) cmds; memset(cmds, 0, sizeof(cmds)); @@ -621,11 +621,11 @@ static void supported_commands(u8_t *data, u16_t len) tester_set_bit(cmds, L2CAP_RECONFIGURE); tester_send(BTP_SERVICE_ID_L2CAP, L2CAP_READ_SUPPORTED_COMMANDS, - CONTROLLER_INDEX, (u8_t *) rp, sizeof(cmds)); + CONTROLLER_INDEX, (uint8_t *) rp, sizeof(cmds)); } -void tester_handle_l2cap(u8_t opcode, u8_t index, u8_t *data, - u16_t len) +void tester_handle_l2cap(uint8_t opcode, uint8_t index, uint8_t *data, + uint16_t len) { switch (opcode) { case L2CAP_READ_SUPPORTED_COMMANDS: @@ -653,7 +653,7 @@ void tester_handle_l2cap(u8_t opcode, u8_t index, u8_t *data, } } -u8_t tester_init_l2cap(void) +uint8_t tester_init_l2cap(void) { int rc; @@ -670,7 +670,7 @@ u8_t tester_init_l2cap(void) return BTP_STATUS_SUCCESS; } -u8_t tester_unregister_l2cap(void) +uint8_t tester_unregister_l2cap(void) { return BTP_STATUS_SUCCESS; } diff --git a/apps/bttester/src/mesh.c b/apps/bttester/src/mesh.c index e18a2a4ed..2fe9fb5fc 100644 --- a/apps/bttester/src/mesh.c +++ b/apps/bttester/src/mesh.c @@ -38,7 +38,7 @@ #include "bttester.h" -extern u8_t own_addr_type; +extern uint8_t own_addr_type; #define CONTROLLER_INDEX 0 #define CID_LOCAL 0xffff @@ -47,21 +47,21 @@ extern u8_t own_addr_type; #define CUR_FAULTS_MAX 4 #define HEALTH_TEST_ID 0x00 -static u8_t cur_faults[CUR_FAULTS_MAX]; -static u8_t reg_faults[CUR_FAULTS_MAX * 2]; +static uint8_t cur_faults[CUR_FAULTS_MAX]; +static uint8_t reg_faults[CUR_FAULTS_MAX * 2]; /* Provision node data */ -static u8_t net_key[16]; -static u16_t net_key_idx; -static u8_t flags; -static u32_t iv_index; -static u16_t addr; -static u8_t dev_key[16]; -static u8_t input_size; +static uint8_t net_key[16]; +static uint16_t net_key_idx; +static uint8_t flags; +static uint32_t iv_index; +static uint16_t addr; +static uint8_t dev_key[16]; +static uint8_t input_size; /* Configured provisioning data */ -static u8_t dev_uuid[16]; -static u8_t static_auth[16]; +static uint8_t dev_uuid[16]; +static uint8_t static_auth[16]; /* Vendor Model data */ #define VND_MODEL_ID_1 0x1234 @@ -71,20 +71,20 @@ static u8_t static_auth[16]; static struct model_data { struct bt_mesh_model *model; - u16_t addr; - u16_t appkey_idx; + uint16_t addr; + uint16_t appkey_idx; } model_bound[MODEL_BOUNDS_MAX]; static struct { - u16_t local; - u16_t dst; - u16_t net_idx; + uint16_t local; + uint16_t dst; + uint16_t net_idx; } net = { .local = BT_MESH_ADDR_UNASSIGNED, .dst = BT_MESH_ADDR_UNASSIGNED, }; -static void supported_commands(u8_t *data, u16_t len) +static void supported_commands(uint8_t *data, uint16_t len) { struct os_mbuf *buf = NET_BUF_SIMPLE(BTP_DATA_MAX_SIZE); @@ -141,9 +141,9 @@ static struct bt_mesh_cfg_srv cfg_srv = { .relay_retransmit = BT_MESH_TRANSMIT(2, 20), }; -static void get_faults(u8_t *faults, u8_t faults_size, u8_t *dst, u8_t *count) +static void get_faults(uint8_t *faults, uint8_t faults_size, uint8_t *dst, uint8_t *count) { - u8_t i, limit = *count; + uint8_t i, limit = *count; for (i = 0, *count = 0; i < faults_size && *count < limit; i++) { if (faults[i]) { @@ -153,8 +153,8 @@ static void get_faults(u8_t *faults, u8_t faults_size, u8_t *dst, u8_t *count) } } -static int fault_get_cur(struct bt_mesh_model *model, u8_t *test_id, - u16_t *company_id, u8_t *faults, u8_t *fault_count) +static int fault_get_cur(struct bt_mesh_model *model, uint8_t *test_id, + uint16_t *company_id, uint8_t *faults, uint8_t *fault_count) { SYS_LOG_DBG(""); @@ -166,8 +166,8 @@ static int fault_get_cur(struct bt_mesh_model *model, u8_t *test_id, return 0; } -static int fault_get_reg(struct bt_mesh_model *model, u16_t company_id, - u8_t *test_id, u8_t *faults, u8_t *fault_count) +static int fault_get_reg(struct bt_mesh_model *model, uint16_t company_id, + uint8_t *test_id, uint8_t *faults, uint8_t *fault_count) { SYS_LOG_DBG("company_id 0x%04x", company_id); @@ -229,7 +229,7 @@ health_pub_init(void) static struct bt_mesh_cfg_cli cfg_cli = { }; -void show_faults(u8_t test_id, u16_t cid, u8_t *faults, size_t fault_count) +void show_faults(uint8_t test_id, uint16_t cid, uint8_t *faults, size_t fault_count) { size_t i; @@ -247,8 +247,8 @@ void show_faults(u8_t test_id, u16_t cid, u8_t *faults, size_t fault_count) } } -static void health_current_status(struct bt_mesh_health_cli *cli, u16_t addr, - u8_t test_id, u16_t cid, u8_t *faults, +static void health_current_status(struct bt_mesh_health_cli *cli, uint16_t addr, + uint8_t test_id, uint16_t cid, uint8_t *faults, size_t fault_count) { SYS_LOG_DBG("Health Current Status from 0x%04x", addr); @@ -295,7 +295,7 @@ static void link_open(bt_mesh_prov_bearer_t bearer) } tester_send(BTP_SERVICE_ID_MESH, MESH_EV_PROV_LINK_OPEN, - CONTROLLER_INDEX, (u8_t *) &ev, sizeof(ev)); + CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev)); } static void link_close(bt_mesh_prov_bearer_t bearer) @@ -318,10 +318,10 @@ static void link_close(bt_mesh_prov_bearer_t bearer) } tester_send(BTP_SERVICE_ID_MESH, MESH_EV_PROV_LINK_CLOSED, - CONTROLLER_INDEX, (u8_t *) &ev, sizeof(ev)); + CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev)); } -static int output_number(bt_mesh_output_action_t action, u32_t number) +static int output_number(bt_mesh_output_action_t action, uint32_t number) { struct mesh_out_number_action_ev ev; @@ -331,7 +331,7 @@ static int output_number(bt_mesh_output_action_t action, u32_t number) ev.number = sys_cpu_to_le32(number); tester_send(BTP_SERVICE_ID_MESH, MESH_EV_OUT_NUMBER_ACTION, - CONTROLLER_INDEX, (u8_t *) &ev, sizeof(ev)); + CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev)); return 0; } @@ -357,7 +357,7 @@ static int output_string(const char *str) return 0; } -static int input(bt_mesh_input_action_t action, u8_t size) +static int input(bt_mesh_input_action_t action, uint8_t size) { struct mesh_in_action_ev ev; @@ -369,12 +369,12 @@ static int input(bt_mesh_input_action_t action, u8_t size) ev.size = size; tester_send(BTP_SERVICE_ID_MESH, MESH_EV_IN_ACTION, CONTROLLER_INDEX, - (u8_t *) &ev, sizeof(ev)); + (uint8_t *) &ev, sizeof(ev)); return 0; } -static void prov_complete(u16_t net_idx, u16_t addr) +static void prov_complete(uint16_t net_idx, uint16_t addr) { SYS_LOG_DBG("net_idx 0x%04x addr 0x%04x", net_idx, addr); @@ -412,7 +412,7 @@ static struct bt_mesh_prov prov = { .reset = prov_reset, }; -static void config_prov(u8_t *data, u16_t len) +static void config_prov(uint8_t *data, uint16_t len) { const struct mesh_config_provisioning_cmd *cmd = (void *) data; @@ -430,7 +430,7 @@ static void config_prov(u8_t *data, u16_t len) CONTROLLER_INDEX, BTP_STATUS_SUCCESS); } -static void provision_node(u8_t *data, u16_t len) +static void provision_node(uint8_t *data, uint16_t len) { const struct mesh_provision_node_cmd *cmd = (void *) data; @@ -448,9 +448,9 @@ static void provision_node(u8_t *data, u16_t len) CONTROLLER_INDEX, BTP_STATUS_SUCCESS); } -static void init(u8_t *data, u16_t len) +static void init(uint8_t *data, uint16_t len) { - u8_t status = BTP_STATUS_SUCCESS; + uint8_t status = BTP_STATUS_SUCCESS; int err; SYS_LOG_DBG(""); @@ -483,7 +483,7 @@ rsp: status); } -static void reset(u8_t *data, u16_t len) +static void reset(uint8_t *data, uint16_t len) { SYS_LOG_DBG(""); @@ -493,11 +493,11 @@ static void reset(u8_t *data, u16_t len) BTP_STATUS_SUCCESS); } -static void input_number(u8_t *data, u16_t len) +static void input_number(uint8_t *data, uint16_t len) { const struct mesh_input_number_cmd *cmd = (void *) data; - u8_t status = BTP_STATUS_SUCCESS; - u32_t number; + uint8_t status = BTP_STATUS_SUCCESS; + uint32_t number; int err; number = sys_le32_to_cpu(cmd->number); @@ -513,11 +513,11 @@ static void input_number(u8_t *data, u16_t len) status); } -static void input_string(u8_t *data, u16_t len) +static void input_string(uint8_t *data, uint16_t len) { const struct mesh_input_string_cmd *cmd = (void *) data; - u8_t status = BTP_STATUS_SUCCESS; - u8_t str_auth[16]; + uint8_t status = BTP_STATUS_SUCCESS; + uint8_t str_auth[16]; int err; SYS_LOG_DBG(""); @@ -544,7 +544,7 @@ rsp: status); } -static void ivu_test_mode(u8_t *data, u16_t len) +static void ivu_test_mode(uint8_t *data, uint16_t len) { const struct mesh_ivu_test_mode_cmd *cmd = (void *) data; @@ -556,7 +556,7 @@ static void ivu_test_mode(u8_t *data, u16_t len) BTP_STATUS_SUCCESS); } -static void ivu_toggle_state(u8_t *data, u16_t len) +static void ivu_toggle_state(uint8_t *data, uint16_t len) { bool result; @@ -571,7 +571,7 @@ static void ivu_toggle_state(u8_t *data, u16_t len) result ? BTP_STATUS_SUCCESS : BTP_STATUS_FAILED); } -static void lpn(u8_t *data, u16_t len) +static void lpn(uint8_t *data, uint16_t len) { struct mesh_lpn_set_cmd *cmd = (void *) data; bool enable; @@ -589,7 +589,7 @@ static void lpn(u8_t *data, u16_t len) err ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS); } -static void lpn_poll(u8_t *data, u16_t len) +static void lpn_poll(uint8_t *data, uint16_t len) { int err; @@ -604,7 +604,7 @@ static void lpn_poll(u8_t *data, u16_t len) err ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS); } -static void net_send(u8_t *data, u16_t len) +static void net_send(uint8_t *data, uint16_t len) { struct mesh_net_send_cmd *cmd = (void *) data; struct os_mbuf *msg = NET_BUF_SIMPLE(UINT8_MAX); @@ -632,13 +632,13 @@ static void net_send(u8_t *data, u16_t len) os_mbuf_free_chain(msg); } -static void health_generate_faults(u8_t *data, u16_t len) +static void health_generate_faults(uint8_t *data, uint16_t len) { struct mesh_health_generate_faults_rp *rp; struct os_mbuf *buf = NET_BUF_SIMPLE(sizeof(*rp) + sizeof(cur_faults) + sizeof(reg_faults)); - u8_t some_faults[] = { 0x01, 0x02, 0x03, 0xff, 0x06 }; - u8_t cur_faults_count, reg_faults_count; + uint8_t some_faults[] = { 0x01, 0x02, 0x03, 0xff, 0x06 }; + uint8_t cur_faults_count, reg_faults_count; rp = net_buf_simple_add(buf, sizeof(*rp)); @@ -658,7 +658,7 @@ static void health_generate_faults(u8_t *data, u16_t len) CONTROLLER_INDEX, buf); } -static void health_clear_faults(u8_t *data, u16_t len) +static void health_clear_faults(uint8_t *data, uint16_t len) { SYS_LOG_DBG(""); @@ -671,7 +671,7 @@ static void health_clear_faults(u8_t *data, u16_t len) CONTROLLER_INDEX, BTP_STATUS_SUCCESS); } -static void model_send(u8_t *data, u16_t len) +static void model_send(uint8_t *data, uint16_t len) { struct mesh_model_send_cmd *cmd = (void *) data; struct os_mbuf *msg = NET_BUF_SIMPLE(UINT8_MAX); @@ -683,7 +683,7 @@ static void model_send(u8_t *data, u16_t len) }; struct bt_mesh_model *model = NULL; int err, i; - u16_t src = sys_le16_to_cpu(cmd->src); + uint16_t src = sys_le16_to_cpu(cmd->src); /* Lookup source address */ for (i = 0; i < ARRAY_SIZE(model_bound); i++) { @@ -720,10 +720,10 @@ fail: } #if MYNEWT_VAL(BLE_MESH_TESTING) -static void lpn_subscribe(u8_t *data, u16_t len) +static void lpn_subscribe(uint8_t *data, uint16_t len) { struct mesh_lpn_subscribe_cmd *cmd = (void *) data; - u16_t address = sys_le16_to_cpu(cmd->address); + uint16_t address = sys_le16_to_cpu(cmd->address); int err; SYS_LOG_DBG("address 0x%04x", address); @@ -737,10 +737,10 @@ static void lpn_subscribe(u8_t *data, u16_t len) err ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS); } -static void lpn_unsubscribe(u8_t *data, u16_t len) +static void lpn_unsubscribe(uint8_t *data, uint16_t len) { struct mesh_lpn_unsubscribe_cmd *cmd = (void *) data; - u16_t address = sys_le16_to_cpu(cmd->address); + uint16_t address = sys_le16_to_cpu(cmd->address); int err; SYS_LOG_DBG("address 0x%04x", address); @@ -754,7 +754,7 @@ static void lpn_unsubscribe(u8_t *data, u16_t len) err ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS); } -static void rpl_clear(u8_t *data, u16_t len) +static void rpl_clear(uint8_t *data, uint16_t len) { int err; @@ -770,7 +770,7 @@ static void rpl_clear(u8_t *data, u16_t len) } #endif /* MYNEWT_VAL(BLE_MESH_TESTING) */ -static void proxy_identity_enable(u8_t *data, u16_t len) +static void proxy_identity_enable(uint8_t *data, uint16_t len) { int err; @@ -785,7 +785,7 @@ static void proxy_identity_enable(u8_t *data, u16_t len) err ? BTP_STATUS_FAILED : BTP_STATUS_SUCCESS); } -void tester_handle_mesh(u8_t opcode, u8_t index, u8_t *data, u16_t len) +void tester_handle_mesh(uint8_t opcode, uint8_t index, uint8_t *data, uint16_t len) { switch (opcode) { case MESH_READ_SUPPORTED_COMMANDS: @@ -854,7 +854,7 @@ void tester_handle_mesh(u8_t opcode, u8_t index, u8_t *data, u16_t len) } } -void net_recv_ev(u8_t ttl, u8_t ctl, u16_t src, u16_t dst, const void *payload, +void net_recv_ev(uint8_t ttl, uint8_t ctl, uint16_t src, uint16_t dst, const void *payload, size_t payload_len) { struct os_mbuf *buf = NET_BUF_SIMPLE(UINT8_MAX); @@ -883,8 +883,8 @@ done: os_mbuf_free_chain(buf); } -static void model_bound_cb(u16_t addr, struct bt_mesh_model *model, - u16_t key_idx) +static void model_bound_cb(uint16_t addr, struct bt_mesh_model *model, + uint16_t key_idx) { int i; @@ -904,8 +904,8 @@ static void model_bound_cb(u16_t addr, struct bt_mesh_model *model, SYS_LOG_ERR("model_bound is full"); } -static void model_unbound_cb(u16_t addr, struct bt_mesh_model *model, - u16_t key_idx) +static void model_unbound_cb(uint16_t addr, struct bt_mesh_model *model, + uint16_t key_idx) { int i; @@ -925,7 +925,7 @@ static void model_unbound_cb(u16_t addr, struct bt_mesh_model *model, SYS_LOG_INF("model not found"); } -static void invalid_bearer_cb(u8_t opcode) +static void invalid_bearer_cb(uint8_t opcode) { struct mesh_invalid_bearer_ev ev = { .opcode = opcode, @@ -934,7 +934,7 @@ static void invalid_bearer_cb(u8_t opcode) SYS_LOG_DBG("opcode 0x%02x", opcode); tester_send(BTP_SERVICE_ID_MESH, MESH_EV_INVALID_BEARER, - CONTROLLER_INDEX, (u8_t *) &ev, sizeof(ev)); + CONTROLLER_INDEX, (uint8_t *) &ev, sizeof(ev)); } static void incomp_timer_exp_cb(void) @@ -951,7 +951,7 @@ static struct bt_test_cb bt_test_cb = { .mesh_trans_incomp_timer_exp = incomp_timer_exp_cb, }; -u8_t tester_init_mesh(void) +uint8_t tester_init_mesh(void) { health_pub_init(); @@ -962,7 +962,7 @@ u8_t tester_init_mesh(void) return BTP_STATUS_SUCCESS; } -u8_t tester_unregister_mesh(void) +uint8_t tester_unregister_mesh(void) { return BTP_STATUS_SUCCESS; } diff --git a/apps/bttester/src/rtt_pipe.c b/apps/bttester/src/rtt_pipe.c index 379345a00..4e6677092 100644 --- a/apps/bttester/src/rtt_pipe.c +++ b/apps/bttester/src/rtt_pipe.c @@ -31,7 +31,7 @@ static struct hal_timer rtt_timer; static bttester_pipe_recv_cb app_cb; -static u8_t *recv_buf; +static uint8_t *recv_buf; static size_t recv_buf_len; static size_t recv_off; @@ -74,7 +74,7 @@ rtt_pipe_poll_func(void *arg) itvl_ms = min(itvl_ms, RTT_INPUT_POLL_INTERVAL_MAX); } else { while (key >= 0 && avail > 0) { - recv_buf[recv_off] = (u8_t) key; + recv_buf[recv_off] = (uint8_t) key; recv_off++; avail = recv_buf_len - recv_off; key = rtt_pipe_get_char((unsigned int) rtt_index_down); @@ -93,14 +93,14 @@ rtt_pipe_poll_func(void *arg) } int -bttester_pipe_send(const u8_t *data, int len) +bttester_pipe_send(const uint8_t *data, int len) { SEGGER_RTT_Write((unsigned int) rtt_index_up, data, (unsigned int) len); return 0; } void -bttester_pipe_register(u8_t *buf, size_t len, bttester_pipe_recv_cb cb) +bttester_pipe_register(uint8_t *buf, size_t len, bttester_pipe_recv_cb cb) { recv_buf = buf; recv_buf_len = len; diff --git a/apps/bttester/src/uart_pipe.c b/apps/bttester/src/uart_pipe.c index ecbefa025..1118d9af5 100644 --- a/apps/bttester/src/uart_pipe.c +++ b/apps/bttester/src/uart_pipe.c @@ -26,7 +26,7 @@ #include "bttester_pipe.h" -static u8_t *recv_buf; +static uint8_t *recv_buf; static size_t recv_buf_len; static bttester_pipe_recv_cb app_cb; static size_t recv_off; @@ -144,7 +144,7 @@ uart_console_rx_char(void *arg, uint8_t byte) static int uart_pipe_handle_char(int key) { - recv_buf[recv_off] = (u8_t) key; + recv_buf[recv_off] = (uint8_t) key; recv_off++; return 0; @@ -194,7 +194,7 @@ uart_console_rx_char_event(struct os_event *ev) } int -bttester_pipe_send(const u8_t *data, int len) +bttester_pipe_send(const uint8_t *data, int len) { int i; @@ -272,7 +272,7 @@ bttester_pipe_init(void) } void -bttester_pipe_register(u8_t *buf, size_t len, bttester_pipe_recv_cb cb) +bttester_pipe_register(uint8_t *buf, size_t len, bttester_pipe_recv_cb cb) { recv_buf = buf; recv_buf_len = len; diff --git a/apps/mesh_badge/src/board.h b/apps/mesh_badge/src/board.h index f1f3c377c..af77e0b4e 100644 --- a/apps/mesh_badge/src/board.h +++ b/apps/mesh_badge/src/board.h @@ -8,8 +8,8 @@ #include "mesh/mesh.h" void board_refresh_display(void); -void board_show_text(const char *text, bool center, s32_t duration); +void board_show_text(const char *text, bool center, int32_t duration); void board_blink_leds(void); -void board_add_hello(u16_t addr, const char *name); -void board_add_heartbeat(u16_t addr, u8_t hops); +void board_add_hello(uint16_t addr, const char *name); +void board_add_heartbeat(uint16_t addr, uint8_t hops); int board_init(void); diff --git a/apps/mesh_badge/src/gatt_svr.c b/apps/mesh_badge/src/gatt_svr.c index 85dca09de..c6005a68a 100644 --- a/apps/mesh_badge/src/gatt_svr.c +++ b/apps/mesh_badge/src/gatt_svr.c @@ -36,15 +36,15 @@ static const ble_uuid16_t gatt_cpf_uuid = BLE_UUID16_INIT(0x2904); /** @brief GATT Characteristic Presentation Format Attribute Value. */ struct bt_gatt_cpf { /** Format of the value of the characteristic */ - u8_t format; + uint8_t format; /** Exponent field to determine how the value of this characteristic is further formatted */ - s8_t exponent; + int8_t exponent; /** Unit of the characteristic */ - u16_t unit; + uint16_t unit; /** Name space of the description */ - u8_t name_space; + uint8_t name_space; /** Description of the characteristic as defined in a higher layer profile */ - u16_t description; + uint16_t description; } __packed; #define CPF_FORMAT_UTF8 0x19 diff --git a/apps/mesh_badge/src/mesh.c b/apps/mesh_badge/src/mesh.c index 80a174cb0..7299b9585 100644 --- a/apps/mesh_badge/src/mesh.c +++ b/apps/mesh_badge/src/mesh.c @@ -27,7 +27,7 @@ static struct ble_npl_callout hello_work; static struct ble_npl_callout mesh_start_work; -static void heartbeat(u8_t hops, u16_t feat) +static void heartbeat(uint8_t hops, uint16_t feat) { board_show_text("Heartbeat Received", false, K_SECONDS(2)); } @@ -106,7 +106,7 @@ static void vnd_heartbeat(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t init_ttl, hops; + uint8_t init_ttl, hops; /* Ignore messages from self */ if (ctx->addr == bt_mesh_model_elem(model)->addr) { @@ -204,23 +204,23 @@ void mesh_send_hello(void) static int provision_and_configure(void) { - static const u8_t net_key[16] = { + static const uint8_t net_key[16] = { 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, }; - static const u8_t app_key[16] = { + static const uint8_t app_key[16] = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, }; - static const u16_t iv_index; + static const uint16_t iv_index; struct bt_mesh_cfg_mod_pub pub = { .addr = GROUP_ADDR, .app_idx = APP_IDX, .ttl = DEFAULT_TTL, .period = BT_MESH_PUB_PERIOD_SEC(10), }; - u8_t dev_key[16]; - u16_t addr; + uint8_t dev_key[16]; + uint16_t addr; int err; err = bt_rand(dev_key, sizeof(dev_key)); @@ -296,14 +296,14 @@ bool mesh_is_initialized(void) return bt_mesh_is_provisioned(); } -u16_t mesh_get_addr(void) +uint16_t mesh_get_addr(void) { return elements[0].addr; } -int mesh_init(u8_t addr_type) +int mesh_init(uint8_t addr_type) { - static const u8_t dev_uuid[16] = { 0xc0, 0xff, 0xee }; + static const uint8_t dev_uuid[16] = { 0xc0, 0xff, 0xee }; static const struct bt_mesh_prov prov = { .uuid = dev_uuid, }; diff --git a/apps/mesh_badge/src/mesh.h b/apps/mesh_badge/src/mesh.h index 2c94de0e6..33ee7cd25 100644 --- a/apps/mesh_badge/src/mesh.h +++ b/apps/mesh_badge/src/mesh.h @@ -8,7 +8,7 @@ void mesh_send_hello(void); -u16_t mesh_get_addr(void); +uint16_t mesh_get_addr(void); bool mesh_is_initialized(void); void mesh_start(void); -int mesh_init(u8_t addr_type); +int mesh_init(uint8_t addr_type); diff --git a/apps/mesh_badge/src/reel_board.c b/apps/mesh_badge/src/reel_board.c index b144a8395..bc8229377 100644 --- a/apps/mesh_badge/src/reel_board.c +++ b/apps/mesh_badge/src/reel_board.c @@ -27,7 +27,7 @@ enum font_size { }; struct font_info { - u8_t columns; + uint8_t columns; } fonts[] = { [FONT_BIG] = { .columns = 12 }, [FONT_MEDIUM] = { .columns = 16 }, @@ -66,7 +66,7 @@ struct k_delayed_work led_timer; static size_t print_line(enum font_size font_size, int row, const char *text, size_t len, bool center) { - u8_t font_height, font_width; + uint8_t font_height, font_width; char line[fonts[FONT_SMALL].columns + 1]; int pad; @@ -124,7 +124,7 @@ void board_blink_leds(void) k_delayed_work_submit(&led_timer, K_MSEC(100)); } -void board_show_text(const char *text, bool center, s32_t duration) +void board_show_text(const char *text, bool center, int32_t duration) { int i; @@ -156,12 +156,12 @@ void board_show_text(const char *text, bool center, s32_t duration) } static struct stat { - u16_t addr; + uint16_t addr; char name[9]; - u8_t min_hops; - u8_t max_hops; - u16_t hello_count; - u16_t heartbeat_count; + uint8_t min_hops; + uint8_t max_hops; + uint16_t hello_count; + uint16_t heartbeat_count; } stats[STAT_COUNT] = { [0 ... (STAT_COUNT - 1)] = { .min_hops = BT_MESH_TTL_MAX, @@ -169,11 +169,11 @@ static struct stat { }, }; -static u32_t stat_count; +static uint32_t stat_count; #define NO_UPDATE -1 -static int add_hello(u16_t addr, const char *name) +static int add_hello(uint16_t addr, const char *name) { int i; @@ -204,7 +204,7 @@ static int add_hello(u16_t addr, const char *name) return NO_UPDATE; } -static int add_heartbeat(u16_t addr, u8_t hops) +static int add_heartbeat(uint16_t addr, uint8_t hops) { int i; @@ -239,18 +239,18 @@ static int add_heartbeat(u16_t addr, u8_t hops) return NO_UPDATE; } -void board_add_hello(u16_t addr, const char *name) +void board_add_hello(uint16_t addr, const char *name) { - u32_t sort_i; + uint32_t sort_i; sort_i = add_hello(addr, name); if (sort_i != NO_UPDATE) { } } -void board_add_heartbeat(u16_t addr, u8_t hops) +void board_add_heartbeat(uint16_t addr, uint8_t hops) { - u32_t sort_i; + uint32_t sort_i; sort_i = add_heartbeat(addr, hops); if (sort_i != NO_UPDATE) { @@ -362,7 +362,7 @@ static void long_press(struct ble_npl_event *work) static bool button_is_pressed(void) { - u32_t val; + uint32_t val; val = (uint32_t) hal_gpio_read(BUTTON_1); diff --git a/nimble/host/mesh/include/mesh/access.h b/nimble/host/mesh/include/mesh/access.h index a718e588e..86beb1885 100644 --- a/nimble/host/mesh/include/mesh/access.h +++ b/nimble/host/mesh/include/mesh/access.h @@ -57,13 +57,13 @@ extern "C" { /** Abstraction that describes a Mesh Element */ struct bt_mesh_elem { /* Unicast Address. Set at runtime during provisioning. */ - u16_t addr; + uint16_t addr; /* Location Descriptor (GATT Bluetooth Namespace Descriptors) */ - const u16_t loc; + const uint16_t loc; - const u8_t model_count; - const u8_t vnd_model_count; + const uint8_t model_count; + const uint8_t vnd_model_count; struct bt_mesh_model * const models; struct bt_mesh_model * const vnd_models; @@ -132,33 +132,33 @@ struct bt_mesh_elem { /** Message sending context. */ struct bt_mesh_msg_ctx { /** NetKey Index of the subnet to send the message on. */ - u16_t net_idx; + uint16_t net_idx; /** AppKey Index to encrypt the message with. */ - u16_t app_idx; + uint16_t app_idx; /** Remote address. */ - u16_t addr; + uint16_t addr; /** Destination address of a received message. Not used for sending. */ - u16_t recv_dst; + uint16_t recv_dst; /** RSSI of received packet. Not used for sending. */ - s8_t recv_rssi; + int8_t recv_rssi; /** Received TTL value. Not used for sending. */ - u8_t recv_ttl; + uint8_t recv_ttl; /** Force sending reliably by using segment acknowledgement */ bool send_rel; /** TTL, or BT_MESH_TTL_DEFAULT for default TTL. */ - u8_t send_ttl; + uint8_t send_ttl; }; struct bt_mesh_model_op { /* OpCode encoded using the BT_MESH_MODEL_OP_* macros */ - const u32_t opcode; + const uint32_t opcode; /* Minimum required message length */ const size_t min_len; @@ -324,7 +324,7 @@ struct bt_mesh_model_op { * * @return Transmission count (actual transmissions is N + 1). */ -#define BT_MESH_TRANSMIT_COUNT(transmit) (((transmit) & (u8_t)BIT_MASK(3))) +#define BT_MESH_TRANSMIT_COUNT(transmit) (((transmit) & (uint8_t)BIT_MASK(3))) /** @def BT_MESH_TRANSMIT_INT * @@ -375,19 +375,19 @@ struct bt_mesh_model_pub { /** The model the context belongs to. Initialized by the stack. */ struct bt_mesh_model *mod; - u16_t addr; /**< Publish Address. */ - u16_t key; /**< Publish AppKey Index. */ + uint16_t addr; /**< Publish Address. */ + uint16_t key; /**< Publish AppKey Index. */ - u8_t ttl; /**< Publish Time to Live. */ - u8_t retransmit; /**< Retransmit Count & Interval Steps. */ - u8_t period; /**< Publish Period. */ - u8_t period_div:4, /**< Divisor for the Period. */ + uint8_t ttl; /**< Publish Time to Live. */ + uint8_t retransmit; /**< Retransmit Count & Interval Steps. */ + uint8_t period; /**< Publish Period. */ + uint8_t period_div:4, /**< Divisor for the Period. */ cred:1, /**< Friendship Credentials Flag. */ send_rel:1, fast_period:1,/**< Use FastPeriodDivisor */ count:3; /**< Retransmissions left. */ - u32_t period_start; /**< Start of the current period. */ + uint32_t period_start; /**< Start of the current period. */ /** @brief Publication buffer, containing the publication message. * @@ -484,26 +484,26 @@ struct bt_mesh_model_cb { /** Abstraction that describes a Mesh Model instance */ struct bt_mesh_model { union { - const u16_t id; + const uint16_t id; struct { - u16_t company; - u16_t id; + uint16_t company; + uint16_t id; } vnd; }; /* Internal information, mainly for persistent storage */ - u8_t elem_idx; /* Belongs to Nth element */ - u8_t mod_idx; /* Is the Nth model in the element */ - u16_t flags; /* Model flags for internal bookkeeping */ + uint8_t elem_idx; /* Belongs to Nth element */ + uint8_t mod_idx; /* Is the Nth model in the element */ + uint16_t flags; /* Model flags for internal bookkeeping */ /* Model Publication */ struct bt_mesh_model_pub * const pub; /* AppKey List */ - u16_t keys[CONFIG_BT_MESH_MODEL_KEY_COUNT]; + uint16_t keys[CONFIG_BT_MESH_MODEL_KEY_COUNT]; /* Subscription List (group or virtual addresses) */ - u16_t groups[CONFIG_BT_MESH_MODEL_GROUP_COUNT]; + uint16_t groups[CONFIG_BT_MESH_MODEL_GROUP_COUNT]; const struct bt_mesh_model_op * const op; @@ -521,11 +521,11 @@ struct bt_mesh_model { }; struct bt_mesh_send_cb { - void (*start)(u16_t duration, int err, void *cb_data); + void (*start)(uint16_t duration, int err, void *cb_data); void (*end)(int err, void *cb_data); }; -void bt_mesh_model_msg_init(struct os_mbuf *msg, u32_t opcode); +void bt_mesh_model_msg_init(struct os_mbuf *msg, uint32_t opcode); /** Special TTL value to request using configured default TTL */ #define BT_MESH_TTL_DEFAULT 0xff @@ -584,7 +584,7 @@ struct bt_mesh_elem *bt_mesh_model_elem(struct bt_mesh_model *mod); * if no SIG model with the given ID exists in the given element. */ struct bt_mesh_model *bt_mesh_model_find(const struct bt_mesh_elem *elem, - u16_t id); + uint16_t id); /** @brief Find a vendor model. * @@ -596,7 +596,7 @@ struct bt_mesh_model *bt_mesh_model_find(const struct bt_mesh_elem *elem, * if no vendor model with the given ID exists in the given element. */ struct bt_mesh_model *bt_mesh_model_find_vnd(const struct bt_mesh_elem *elem, - u16_t company, u16_t id); + uint16_t company, uint16_t id); /** @brief Get whether the model is in the primary element of the device. * @@ -647,9 +647,9 @@ int bt_mesh_model_extend(struct bt_mesh_model *mod, /** Node Composition */ struct bt_mesh_comp { - u16_t cid; - u16_t pid; - u16_t vid; + uint16_t cid; + uint16_t pid; + uint16_t vid; size_t elem_count; struct bt_mesh_elem *elem; diff --git a/nimble/host/mesh/include/mesh/cdb.h b/nimble/host/mesh/include/mesh/cdb.h index f5be8c920..220e02329 100644 --- a/nimble/host/mesh/include/mesh/cdb.h +++ b/nimble/host/mesh/include/mesh/cdb.h @@ -26,32 +26,32 @@ enum { }; struct bt_mesh_cdb_node { - u8_t uuid[16]; - u16_t addr; - u16_t net_idx; - u8_t num_elem; - u8_t dev_key[16]; + uint8_t uuid[16]; + uint16_t addr; + uint16_t net_idx; + uint8_t num_elem; + uint8_t dev_key[16]; ATOMIC_DEFINE(flags, BT_MESH_CDB_NODE_FLAG_COUNT); }; struct bt_mesh_cdb_subnet { - u16_t net_idx; + uint16_t net_idx; bool kr_flag; - u8_t kr_phase; + uint8_t kr_phase; struct { - u8_t net_key[16]; + uint8_t net_key[16]; } keys[2]; }; struct bt_mesh_cdb_app_key { - u16_t net_idx; - u16_t app_idx; + uint16_t net_idx; + uint16_t app_idx; struct { - u8_t app_key[16]; + uint8_t app_key[16]; } keys[2]; }; @@ -66,7 +66,7 @@ enum { }; struct bt_mesh_cdb { - u32_t iv_index; + uint32_t iv_index; ATOMIC_DEFINE(flags, BT_MESH_CDB_FLAG_COUNT); @@ -87,7 +87,7 @@ extern struct bt_mesh_cdb bt_mesh_cdb; * * @return 0 on success or negative error code on failure. */ -int bt_mesh_cdb_create(const u8_t key[16]); +int bt_mesh_cdb_create(const uint8_t key[16]); /** @brief Clear the Mesh Configuration Database. * @@ -108,7 +108,7 @@ void bt_mesh_cdb_clear(void); * @param iv_index The new IV Index to use. * @param iv_update True if there is an ongoing IV Update procedure. */ -void bt_mesh_cdb_iv_update(u32_t iv_index, bool iv_update); +void bt_mesh_cdb_iv_update(uint32_t iv_index, bool iv_update); /** @brief Allocate a node. * @@ -122,8 +122,8 @@ void bt_mesh_cdb_iv_update(u32_t iv_index, bool iv_update); * * @return The new node or NULL if it cannot be allocated. */ -struct bt_mesh_cdb_node *bt_mesh_cdb_node_alloc(const u8_t uuid[16], u16_t addr, - u8_t num_elem, u16_t net_idx); +struct bt_mesh_cdb_node *bt_mesh_cdb_node_alloc(const uint8_t uuid[16], uint16_t addr, + uint8_t num_elem, uint16_t net_idx); /** @brief Delete a node. * @@ -144,7 +144,7 @@ void bt_mesh_cdb_node_del(struct bt_mesh_cdb_node *node, bool store); * @return The node that has an element with address addr or NULL if no such * node exists. */ -struct bt_mesh_cdb_node *bt_mesh_cdb_node_get(u16_t addr); +struct bt_mesh_cdb_node *bt_mesh_cdb_node_get(uint16_t addr); /** @brief Store node to persistent storage. * @@ -166,7 +166,7 @@ enum { * @return BT_MESH_CDB_ITER_CONTINUE to continue to iterate through the nodes * or BT_MESH_CDB_ITER_STOP to stop. */ -typedef u8_t (*bt_mesh_cdb_node_func_t)(struct bt_mesh_cdb_node *node, +typedef uint8_t (*bt_mesh_cdb_node_func_t)(struct bt_mesh_cdb_node *node, void *user_data); /** @brief Node iterator. @@ -187,7 +187,7 @@ void bt_mesh_cdb_node_foreach(bt_mesh_cdb_node_func_t func, void *user_data); * * @return The new subnet or NULL if it cannot be allocated. */ -struct bt_mesh_cdb_subnet *bt_mesh_cdb_subnet_alloc(u16_t net_idx); +struct bt_mesh_cdb_subnet *bt_mesh_cdb_subnet_alloc(uint16_t net_idx); /** @brief Delete a subnet. * @@ -207,7 +207,7 @@ void bt_mesh_cdb_subnet_del(struct bt_mesh_cdb_subnet *sub, bool store); * @return The subnet with the specified NetIdx or NULL if no such subnet * exists. */ -struct bt_mesh_cdb_subnet *bt_mesh_cdb_subnet_get(u16_t net_idx); +struct bt_mesh_cdb_subnet *bt_mesh_cdb_subnet_get(uint16_t net_idx); /** @brief Store subnet to persistent storage. * @@ -221,7 +221,7 @@ void bt_mesh_cdb_subnet_store(const struct bt_mesh_cdb_subnet *sub); * * @return The flags for the subnet. */ -u8_t bt_mesh_cdb_subnet_flags(const struct bt_mesh_cdb_subnet *sub); +uint8_t bt_mesh_cdb_subnet_flags(const struct bt_mesh_cdb_subnet *sub); /** @brief Allocate an application key. @@ -233,8 +233,8 @@ u8_t bt_mesh_cdb_subnet_flags(const struct bt_mesh_cdb_subnet *sub); * * @return The new application key or NULL if it cannot be allocated. */ -struct bt_mesh_cdb_app_key *bt_mesh_cdb_app_key_alloc(u16_t net_idx, - u16_t app_idx); +struct bt_mesh_cdb_app_key *bt_mesh_cdb_app_key_alloc(uint16_t net_idx, + uint16_t app_idx); /** @brief Delete an application key. * @@ -254,7 +254,7 @@ void bt_mesh_cdb_app_key_del(struct bt_mesh_cdb_app_key *key, bool store); * @return The application key with the specified AppIdx or NULL if no such key * exists. */ -struct bt_mesh_cdb_app_key *bt_mesh_cdb_app_key_get(u16_t app_idx); +struct bt_mesh_cdb_app_key *bt_mesh_cdb_app_key_get(uint16_t app_idx); /** @brief Store application key to persistent storage. * diff --git a/nimble/host/mesh/include/mesh/cfg_cli.h b/nimble/host/mesh/include/mesh/cfg_cli.h index eb64fe5fc..3caf7f9da 100644 --- a/nimble/host/mesh/include/mesh/cfg_cli.h +++ b/nimble/host/mesh/include/mesh/cfg_cli.h @@ -26,7 +26,7 @@ struct bt_mesh_cfg_cli { struct bt_mesh_model *model; struct k_sem op_sync; - u32_t op_pending; + uint32_t op_pending; void *op_param; }; @@ -37,73 +37,73 @@ extern const struct bt_mesh_model_cb bt_mesh_cfg_cli_cb; BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_CFG_CLI, bt_mesh_cfg_cli_op, NULL, \ cli_data, &bt_mesh_cfg_cli_cb) -int bt_mesh_cfg_comp_data_get(u16_t net_idx, u16_t addr, u8_t page, - u8_t *status, struct os_mbuf *comp); +int bt_mesh_cfg_comp_data_get(uint16_t net_idx, uint16_t addr, uint8_t page, + uint8_t *status, struct os_mbuf *comp); -int bt_mesh_cfg_beacon_get(u16_t net_idx, u16_t addr, u8_t *status); +int bt_mesh_cfg_beacon_get(uint16_t net_idx, uint16_t addr, uint8_t *status); -int bt_mesh_cfg_beacon_set(u16_t net_idx, u16_t addr, u8_t val, u8_t *status); +int bt_mesh_cfg_beacon_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *status); -int bt_mesh_cfg_ttl_get(u16_t net_idx, u16_t addr, u8_t *ttl); +int bt_mesh_cfg_ttl_get(uint16_t net_idx, uint16_t addr, uint8_t *ttl); -int bt_mesh_cfg_ttl_set(u16_t net_idx, u16_t addr, u8_t val, u8_t *ttl); +int bt_mesh_cfg_ttl_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *ttl); -int bt_mesh_cfg_friend_get(u16_t net_idx, u16_t addr, u8_t *status); +int bt_mesh_cfg_friend_get(uint16_t net_idx, uint16_t addr, uint8_t *status); -int bt_mesh_cfg_friend_set(u16_t net_idx, u16_t addr, u8_t val, u8_t *status); +int bt_mesh_cfg_friend_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *status); -int bt_mesh_cfg_gatt_proxy_get(u16_t net_idx, u16_t addr, u8_t *status); +int bt_mesh_cfg_gatt_proxy_get(uint16_t net_idx, uint16_t addr, uint8_t *status); -int bt_mesh_cfg_gatt_proxy_set(u16_t net_idx, u16_t addr, u8_t val, - u8_t *status); +int bt_mesh_cfg_gatt_proxy_set(uint16_t net_idx, uint16_t addr, uint8_t val, + uint8_t *status); -int bt_mesh_cfg_relay_get(u16_t net_idx, u16_t addr, u8_t *status, - u8_t *transmit); +int bt_mesh_cfg_relay_get(uint16_t net_idx, uint16_t addr, uint8_t *status, + uint8_t *transmit); -int bt_mesh_cfg_relay_set(u16_t net_idx, u16_t addr, u8_t new_relay, - u8_t new_transmit, u8_t *status, u8_t *transmit); +int bt_mesh_cfg_relay_set(uint16_t net_idx, uint16_t addr, uint8_t new_relay, + uint8_t new_transmit, uint8_t *status, uint8_t *transmit); -int bt_mesh_cfg_net_key_add(u16_t net_idx, u16_t addr, u16_t key_net_idx, - const u8_t net_key[16], u8_t *status); +int bt_mesh_cfg_net_key_add(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, + const uint8_t net_key[16], uint8_t *status); -int bt_mesh_cfg_net_key_get(u16_t net_idx, u16_t addr, u16_t *keys, +int bt_mesh_cfg_net_key_get(uint16_t net_idx, uint16_t addr, uint16_t *keys, size_t *key_cnt); int bt_mesh_cfg_net_key_del(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, uint8_t *status); -int bt_mesh_cfg_app_key_add(u16_t net_idx, u16_t addr, u16_t key_net_idx, - u16_t key_app_idx, const u8_t app_key[16], - u8_t *status); +int bt_mesh_cfg_app_key_add(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, + uint16_t key_app_idx, const uint8_t app_key[16], + uint8_t *status); -int bt_mesh_cfg_app_key_get(u16_t net_idx, u16_t addr, u16_t key_net_idx, - u8_t *status, u16_t *keys, size_t *key_cnt); +int bt_mesh_cfg_app_key_get(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, + uint8_t *status, uint16_t *keys, size_t *key_cnt); int bt_mesh_cfg_app_key_del(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, uint16_t key_app_idx, uint8_t *status); -int bt_mesh_cfg_mod_app_bind(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_app_idx, u16_t mod_id, u8_t *status); +int bt_mesh_cfg_mod_app_bind(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_app_idx, uint16_t mod_id, uint8_t *status); int bt_mesh_cfg_mod_app_unbind(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, uint16_t mod_app_idx, uint16_t mod_id, uint8_t *status); -int bt_mesh_cfg_mod_app_bind_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_app_idx, u16_t mod_id, u16_t cid, - u8_t *status); +int bt_mesh_cfg_mod_app_bind_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_app_idx, uint16_t mod_id, uint16_t cid, + uint8_t *status); int bt_mesh_cfg_mod_app_unbind_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, uint16_t mod_app_idx, uint16_t mod_id, uint16_t cid, uint8_t *status); -int bt_mesh_cfg_mod_app_get(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, u8_t *status, u16_t *apps, +int bt_mesh_cfg_mod_app_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint8_t *status, uint16_t *apps, size_t *app_cnt); -int bt_mesh_cfg_mod_app_get_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, u16_t cid, u8_t *status, - u16_t *apps, size_t *app_cnt); +int bt_mesh_cfg_mod_app_get_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint16_t cid, uint8_t *status, + uint16_t *apps, size_t *app_cnt); /** @def BT_MESH_PUB_PERIOD_100MS * @@ -148,117 +148,117 @@ int bt_mesh_cfg_mod_app_get_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, #define BT_MESH_PUB_PERIOD_10MIN(steps) (((steps) & BIT_MASK(6)) | (3 << 6)) struct bt_mesh_cfg_mod_pub { - u16_t addr; - u16_t app_idx; + uint16_t addr; + uint16_t app_idx; bool cred_flag; - u8_t ttl; - u8_t period; - u8_t transmit; + uint8_t ttl; + uint8_t period; + uint8_t transmit; }; -int bt_mesh_cfg_mod_pub_get(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, struct bt_mesh_cfg_mod_pub *pub, - u8_t *status); +int bt_mesh_cfg_mod_pub_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, struct bt_mesh_cfg_mod_pub *pub, + uint8_t *status); -int bt_mesh_cfg_mod_pub_get_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, u16_t cid, - struct bt_mesh_cfg_mod_pub *pub, u8_t *status); +int bt_mesh_cfg_mod_pub_get_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint16_t cid, + struct bt_mesh_cfg_mod_pub *pub, uint8_t *status); -int bt_mesh_cfg_mod_pub_set(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, struct bt_mesh_cfg_mod_pub *pub, - u8_t *status); +int bt_mesh_cfg_mod_pub_set(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, struct bt_mesh_cfg_mod_pub *pub, + uint8_t *status); -int bt_mesh_cfg_mod_pub_set_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, u16_t cid, - struct bt_mesh_cfg_mod_pub *pub, u8_t *status); +int bt_mesh_cfg_mod_pub_set_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint16_t cid, + struct bt_mesh_cfg_mod_pub *pub, uint8_t *status); -int bt_mesh_cfg_mod_sub_add(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t sub_addr, u16_t mod_id, u8_t *status); +int bt_mesh_cfg_mod_sub_add(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t sub_addr, uint16_t mod_id, uint8_t *status); -int bt_mesh_cfg_mod_sub_add_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t sub_addr, u16_t mod_id, u16_t cid, - u8_t *status); +int bt_mesh_cfg_mod_sub_add_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t sub_addr, uint16_t mod_id, uint16_t cid, + uint8_t *status); -int bt_mesh_cfg_mod_sub_del(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t sub_addr, u16_t mod_id, u8_t *status); +int bt_mesh_cfg_mod_sub_del(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t sub_addr, uint16_t mod_id, uint8_t *status); -int bt_mesh_cfg_mod_sub_del_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t sub_addr, u16_t mod_id, u16_t cid, - u8_t *status); +int bt_mesh_cfg_mod_sub_del_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t sub_addr, uint16_t mod_id, uint16_t cid, + uint8_t *status); -int bt_mesh_cfg_mod_sub_overwrite(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t sub_addr, u16_t mod_id, u8_t *status); +int bt_mesh_cfg_mod_sub_overwrite(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t sub_addr, uint16_t mod_id, uint8_t *status); -int bt_mesh_cfg_mod_sub_overwrite_vnd(u16_t net_idx, u16_t addr, - u16_t elem_addr, u16_t sub_addr, - u16_t mod_id, u16_t cid, u8_t *status); +int bt_mesh_cfg_mod_sub_overwrite_vnd(uint16_t net_idx, uint16_t addr, + uint16_t elem_addr, uint16_t sub_addr, + uint16_t mod_id, uint16_t cid, uint8_t *status); -int bt_mesh_cfg_mod_sub_va_add(u16_t net_idx, u16_t addr, u16_t elem_addr, - const u8_t label[16], u16_t mod_id, - u16_t *virt_addr, u8_t *status); +int bt_mesh_cfg_mod_sub_va_add(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + const uint8_t label[16], uint16_t mod_id, + uint16_t *virt_addr, uint8_t *status); -int bt_mesh_cfg_mod_sub_va_add_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - const u8_t label[16], u16_t mod_id, - u16_t cid, u16_t *virt_addr, u8_t *status); +int bt_mesh_cfg_mod_sub_va_add_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + const uint8_t label[16], uint16_t mod_id, + uint16_t cid, uint16_t *virt_addr, uint8_t *status); -int bt_mesh_cfg_mod_sub_va_del(u16_t net_idx, u16_t addr, u16_t elem_addr, - const u8_t label[16], u16_t mod_id, - u16_t *virt_addr, u8_t *status); +int bt_mesh_cfg_mod_sub_va_del(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + const uint8_t label[16], uint16_t mod_id, + uint16_t *virt_addr, uint8_t *status); -int bt_mesh_cfg_mod_sub_va_del_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - const u8_t label[16], u16_t mod_id, - u16_t cid, u16_t *virt_addr, u8_t *status); +int bt_mesh_cfg_mod_sub_va_del_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + const uint8_t label[16], uint16_t mod_id, + uint16_t cid, uint16_t *virt_addr, uint8_t *status); -int bt_mesh_cfg_mod_sub_va_overwrite(u16_t net_idx, u16_t addr, - u16_t elem_addr, const u8_t label[16], - u16_t mod_id, u16_t *virt_addr, - u8_t *status); +int bt_mesh_cfg_mod_sub_va_overwrite(uint16_t net_idx, uint16_t addr, + uint16_t elem_addr, const uint8_t label[16], + uint16_t mod_id, uint16_t *virt_addr, + uint8_t *status); -int bt_mesh_cfg_mod_sub_va_overwrite_vnd(u16_t net_idx, u16_t addr, - u16_t elem_addr, const u8_t label[16], - u16_t mod_id, u16_t cid, - u16_t *virt_addr, u8_t *status); +int bt_mesh_cfg_mod_sub_va_overwrite_vnd(uint16_t net_idx, uint16_t addr, + uint16_t elem_addr, const uint8_t label[16], + uint16_t mod_id, uint16_t cid, + uint16_t *virt_addr, uint8_t *status); -int bt_mesh_cfg_mod_sub_get(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, u8_t *status, u16_t *subs, +int bt_mesh_cfg_mod_sub_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint8_t *status, uint16_t *subs, size_t *sub_cnt); -int bt_mesh_cfg_mod_sub_get_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, u16_t cid, u8_t *status, - u16_t *subs, size_t *sub_cnt); +int bt_mesh_cfg_mod_sub_get_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint16_t cid, uint8_t *status, + uint16_t *subs, size_t *sub_cnt); struct bt_mesh_cfg_hb_sub { - u16_t src; - u16_t dst; - u8_t period; - u8_t count; - u8_t min; - u8_t max; + uint16_t src; + uint16_t dst; + uint8_t period; + uint8_t count; + uint8_t min; + uint8_t max; }; -int bt_mesh_cfg_hb_sub_set(u16_t net_idx, u16_t addr, - struct bt_mesh_cfg_hb_sub *sub, u8_t *status); +int bt_mesh_cfg_hb_sub_set(uint16_t net_idx, uint16_t addr, + struct bt_mesh_cfg_hb_sub *sub, uint8_t *status); -int bt_mesh_cfg_hb_sub_get(u16_t net_idx, u16_t addr, - struct bt_mesh_cfg_hb_sub *sub, u8_t *status); +int bt_mesh_cfg_hb_sub_get(uint16_t net_idx, uint16_t addr, + struct bt_mesh_cfg_hb_sub *sub, uint8_t *status); struct bt_mesh_cfg_hb_pub { - u16_t dst; - u8_t count; - u8_t period; - u8_t ttl; - u16_t feat; - u16_t net_idx; + uint16_t dst; + uint8_t count; + uint8_t period; + uint8_t ttl; + uint16_t feat; + uint16_t net_idx; }; -int bt_mesh_cfg_hb_pub_set(u16_t net_idx, u16_t addr, - const struct bt_mesh_cfg_hb_pub *pub, u8_t *status); +int bt_mesh_cfg_hb_pub_set(uint16_t net_idx, uint16_t addr, + const struct bt_mesh_cfg_hb_pub *pub, uint8_t *status); -int bt_mesh_cfg_hb_pub_get(u16_t net_idx, u16_t addr, - struct bt_mesh_cfg_hb_pub *pub, u8_t *status); +int bt_mesh_cfg_hb_pub_get(uint16_t net_idx, uint16_t addr, + struct bt_mesh_cfg_hb_pub *pub, uint8_t *status); -s32_t bt_mesh_cfg_cli_timeout_get(void); -void bt_mesh_cfg_cli_timeout_set(s32_t timeout); +int32_t bt_mesh_cfg_cli_timeout_get(void); +void bt_mesh_cfg_cli_timeout_set(int32_t timeout); #ifdef __cplusplus } diff --git a/nimble/host/mesh/include/mesh/cfg_srv.h b/nimble/host/mesh/include/mesh/cfg_srv.h index 14d8a2956..f7adcec84 100644 --- a/nimble/host/mesh/include/mesh/cfg_srv.h +++ b/nimble/host/mesh/include/mesh/cfg_srv.h @@ -25,38 +25,38 @@ extern "C" { struct bt_mesh_cfg_srv { struct bt_mesh_model *model; - u8_t net_transmit; /* Network Transmit state */ - u8_t relay; /* Relay Mode state */ - u8_t relay_retransmit; /* Relay Retransmit state */ - u8_t beacon; /* Secure Network Beacon state */ - u8_t gatt_proxy; /* GATT Proxy state */ - u8_t frnd; /* Friend state */ - u8_t default_ttl; /* Default TTL */ + uint8_t net_transmit; /* Network Transmit state */ + uint8_t relay; /* Relay Mode state */ + uint8_t relay_retransmit; /* Relay Retransmit state */ + uint8_t beacon; /* Secure Network Beacon state */ + uint8_t gatt_proxy; /* GATT Proxy state */ + uint8_t frnd; /* Friend state */ + uint8_t default_ttl; /* Default TTL */ /* Heartbeat Publication */ struct bt_mesh_hb_pub { struct k_delayed_work timer; - u16_t dst; - u16_t count; - u8_t period; - u8_t ttl; - u16_t feat; - u16_t net_idx; + uint16_t dst; + uint16_t count; + uint8_t period; + uint8_t ttl; + uint16_t feat; + uint16_t net_idx; } hb_pub; /* Heartbeat Subscription */ struct bt_mesh_hb_sub { - s64_t expiry; + int64_t expiry; - u16_t src; - u16_t dst; - u16_t count; - u8_t min_hops; - u8_t max_hops; + uint16_t src; + uint16_t dst; + uint16_t count; + uint8_t min_hops; + uint8_t max_hops; /* Optional subscription tracking function */ - void (*func)(u8_t hops, u16_t feat); + void (*func)(uint8_t hops, uint16_t feat); } hb_sub; }; diff --git a/nimble/host/mesh/include/mesh/glue.h b/nimble/host/mesh/include/mesh/glue.h index 3ee742814..651bdea53 100644 --- a/nimble/host/mesh/include/mesh/glue.h +++ b/nimble/host/mesh/include/mesh/glue.h @@ -51,15 +51,6 @@ extern "C" { #endif -#define u8_t uint8_t -#define s8_t int8_t -#define u16_t uint16_t -#define s16_t int16_t -#define u32_t uint32_t -#define u64_t uint64_t -#define s64_t int64_t -#define s32_t int32_t - /** @brief Helper to declare elements of bt_data arrays * * This macro is mainly for creating an array of struct bt_data @@ -73,7 +64,7 @@ extern "C" { { \ .type = (_type), \ .data_len = (_data_len), \ - .data = (const u8_t *)(_data), \ + .data = (const uint8_t *)(_data), \ } /** @brief Helper to declare elements of bt_data arrays @@ -85,8 +76,8 @@ extern "C" { * @param _bytes Variable number of single-byte parameters */ #define BT_DATA_BYTES(_type, _bytes...) \ - BT_DATA(_type, ((u8_t []) { _bytes }), \ - sizeof((u8_t []) { _bytes })) + BT_DATA(_type, ((uint8_t []) { _bytes }), \ + sizeof((uint8_t []) { _bytes })) /* EIR/AD data type definitions */ #define BT_DATA_FLAGS 0x01 /* AD flags */ @@ -200,9 +191,9 @@ typedef ble_addr_t bt_addr_le_t; struct net_buf_simple_state { /** Offset of the data pointer from the beginning of the storage */ - u16_t offset; + uint16_t offset; /** Length of data */ - u16_t len; + uint16_t len; }; static inline struct os_mbuf * NET_BUF_SIMPLE(uint16_t size) @@ -275,7 +266,7 @@ void *net_buf_simple_pull(struct os_mbuf *om, uint8_t len); void *net_buf_simple_pull_mem(struct os_mbuf *om, uint8_t len); void *net_buf_simple_add(struct os_mbuf *om, uint8_t len); bool k_fifo_is_empty(struct ble_npl_eventq *q); -void *net_buf_get(struct ble_npl_eventq *fifo,s32_t t); +void *net_buf_get(struct ble_npl_eventq *fifo,int32_t t); uint8_t *net_buf_simple_push(struct os_mbuf *om, uint8_t len); void net_buf_reserve(struct os_mbuf *om, size_t reserve); @@ -301,9 +292,9 @@ void net_buf_reserve(struct os_mbuf *om, size_t reserve); * bt_le_adv_start() function. */ struct bt_data { - u8_t type; - u8_t data_len; - const u8_t *data; + uint8_t type; + uint8_t data_len; + const uint8_t *data; }; struct bt_pub_key_cb { @@ -315,24 +306,24 @@ struct bt_pub_key_cb { * * @param key The local public key, or NULL in case of no key. */ - void (*func)(const u8_t key[64]); + void (*func)(const uint8_t key[64]); struct bt_pub_key_cb *_next; }; -typedef void (*bt_dh_key_cb_t)(const u8_t key[32]); -int bt_dh_key_gen(const u8_t remote_pk[64], bt_dh_key_cb_t cb); +typedef void (*bt_dh_key_cb_t)(const uint8_t key[32]); +int bt_dh_key_gen(const uint8_t remote_pk[64], bt_dh_key_cb_t cb); int bt_pub_key_gen(struct bt_pub_key_cb *new_cb); uint8_t *bt_pub_key_get(void); int bt_rand(void *buf, size_t len); const char * bt_hex(const void *buf, size_t len); int bt_encrypt_be(const uint8_t *key, const uint8_t *plaintext, uint8_t *enc_data); -int bt_ccm_decrypt(const u8_t key[16], u8_t nonce[13], const u8_t *enc_data, - size_t len, const u8_t *aad, size_t aad_len, - u8_t *plaintext, size_t mic_size); -int bt_ccm_encrypt(const u8_t key[16], u8_t nonce[13], const u8_t *enc_data, - size_t len, const u8_t *aad, size_t aad_len, - u8_t *plaintext, size_t mic_size); +int bt_ccm_decrypt(const uint8_t key[16], uint8_t nonce[13], const uint8_t *enc_data, + size_t len, const uint8_t *aad, size_t aad_len, + uint8_t *plaintext, size_t mic_size); +int bt_ccm_encrypt(const uint8_t key[16], uint8_t nonce[13], const uint8_t *enc_data, + size_t len, const uint8_t *aad, size_t aad_len, + uint8_t *plaintext, size_t mic_size); void bt_mesh_register_gatt(void); int bt_le_adv_start(const struct ble_gap_adv_params *param, const struct bt_data *ad, size_t ad_len, @@ -348,7 +339,7 @@ void k_delayed_work_init(struct k_delayed_work *w, ble_npl_event_fn *f); void k_delayed_work_cancel(struct k_delayed_work *w); void k_delayed_work_submit(struct k_delayed_work *w, uint32_t ms); int64_t k_uptime_get(void); -u32_t k_uptime_get_32(void); +uint32_t k_uptime_get_32(void); void k_sleep(int32_t duration); void k_work_submit(struct ble_npl_callout *w); void k_work_add_arg(struct ble_npl_callout *w, void *arg); @@ -378,18 +369,18 @@ static inline void sys_memcpy_swap(void *dst, const void *src, size_t length) src += length - 1; for (; length > 0; length--) { - *((u8_t *)dst++) = *((u8_t *)src--); + *((uint8_t *)dst++) = *((uint8_t *)src--); } } #define popcount(x) __builtin_popcount(x) -static inline unsigned int find_lsb_set(u32_t op) +static inline unsigned int find_lsb_set(uint32_t op) { return __builtin_ffs(op); } -static inline unsigned int find_msb_set(u32_t op) +static inline unsigned int find_msb_set(uint32_t op) { if (!op) return 0; @@ -455,7 +446,7 @@ static inline void k_sem_init(struct k_sem *sem, unsigned int initial_count, ble_npl_sem_init(sem, initial_count); } -static inline int k_sem_take(struct k_sem *sem, s32_t timeout) +static inline int k_sem_take(struct k_sem *sem, int32_t timeout) { uint32_t ticks; @@ -477,8 +468,8 @@ static inline void k_sem_give(struct k_sem *sem) static inline int net_buf_id(struct os_mbuf *buf) { struct os_mbuf_pool *pool = buf->om_omp; - u8_t *pool_start = (u8_t *)pool->omp_pool->mp_membuf_addr; - u8_t *buf_ptr = (u8_t *)buf; + uint8_t *pool_start = (uint8_t *)pool->omp_pool->mp_membuf_addr; + uint8_t *buf_ptr = (uint8_t *)buf; return (buf_ptr - pool_start) / BUF_SIZE(pool); } diff --git a/nimble/host/mesh/include/mesh/health_cli.h b/nimble/host/mesh/include/mesh/health_cli.h index 9c175e31a..e9efe4b1f 100644 --- a/nimble/host/mesh/include/mesh/health_cli.h +++ b/nimble/host/mesh/include/mesh/health_cli.h @@ -25,12 +25,12 @@ extern "C" { struct bt_mesh_health_cli { struct bt_mesh_model *model; - void (*current_status)(struct bt_mesh_health_cli *cli, u16_t addr, - u8_t test_id, u16_t cid, u8_t *faults, + void (*current_status)(struct bt_mesh_health_cli *cli, uint16_t addr, + uint8_t test_id, uint16_t cid, uint8_t *faults, size_t fault_count); struct k_sem op_sync; - u32_t op_pending; + uint32_t op_pending; void *op_param; }; @@ -43,30 +43,30 @@ extern const struct bt_mesh_model_cb bt_mesh_health_cli_cb; int bt_mesh_health_cli_set(struct bt_mesh_model *model); -int bt_mesh_health_fault_get(u16_t addr, u16_t app_idx, u16_t cid, - u8_t *test_id, u8_t *faults, +int bt_mesh_health_fault_get(uint16_t addr, uint16_t app_idx, uint16_t cid, + uint8_t *test_id, uint8_t *faults, size_t *fault_count); -int bt_mesh_health_fault_clear(u16_t addr, u16_t app_idx, u16_t cid, - u8_t *test_id, u8_t *faults, +int bt_mesh_health_fault_clear(uint16_t addr, uint16_t app_idx, uint16_t cid, + uint8_t *test_id, uint8_t *faults, size_t *fault_count); -int bt_mesh_health_fault_test(u16_t addr, u16_t app_idx, u16_t cid, - u8_t test_id, u8_t *faults, +int bt_mesh_health_fault_test(uint16_t addr, uint16_t app_idx, uint16_t cid, + uint8_t test_id, uint8_t *faults, size_t *fault_count); -int bt_mesh_health_period_get(u16_t addr, u16_t app_idx, u8_t *divisor); +int bt_mesh_health_period_get(uint16_t addr, uint16_t app_idx, uint8_t *divisor); -int bt_mesh_health_period_set(u16_t addr, u16_t app_idx, u8_t divisor, - u8_t *updated_divisor); +int bt_mesh_health_period_set(uint16_t addr, uint16_t app_idx, uint8_t divisor, + uint8_t *updated_divisor); -int bt_mesh_health_attention_get(u16_t addr, u16_t app_idx, u8_t *attention); +int bt_mesh_health_attention_get(uint16_t addr, uint16_t app_idx, uint8_t *attention); -int bt_mesh_health_attention_set(u16_t addr, u16_t app_idx, u8_t attention, - u8_t *updated_attention); +int bt_mesh_health_attention_set(uint16_t addr, uint16_t app_idx, uint8_t attention, + uint8_t *updated_attention); -s32_t bt_mesh_health_cli_timeout_get(void); -void bt_mesh_health_cli_timeout_set(s32_t timeout); +int32_t bt_mesh_health_cli_timeout_get(void); +void bt_mesh_health_cli_timeout_set(int32_t timeout); #ifdef __cplusplus } diff --git a/nimble/host/mesh/include/mesh/health_srv.h b/nimble/host/mesh/include/mesh/health_srv.h index 83982376f..5d1c0de01 100644 --- a/nimble/host/mesh/include/mesh/health_srv.h +++ b/nimble/host/mesh/include/mesh/health_srv.h @@ -23,21 +23,21 @@ extern "C" { struct bt_mesh_health_srv_cb { /* Fetch current faults */ - int (*fault_get_cur)(struct bt_mesh_model *model, u8_t *test_id, - u16_t *company_id, u8_t *faults, - u8_t *fault_count); + int (*fault_get_cur)(struct bt_mesh_model *model, uint8_t *test_id, + uint16_t *company_id, uint8_t *faults, + uint8_t *fault_count); /* Fetch registered faults */ - int (*fault_get_reg)(struct bt_mesh_model *model, u16_t company_id, - u8_t *test_id, u8_t *faults, - u8_t *fault_count); + int (*fault_get_reg)(struct bt_mesh_model *model, uint16_t company_id, + uint8_t *test_id, uint8_t *faults, + uint8_t *fault_count); /* Clear registered faults */ - int (*fault_clear)(struct bt_mesh_model *model, u16_t company_id); + int (*fault_clear)(struct bt_mesh_model *model, uint16_t company_id); /* Run a specific test */ - int (*fault_test)(struct bt_mesh_model *model, u8_t test_id, - u16_t company_id); + int (*fault_test)(struct bt_mesh_model *model, uint8_t test_id, + uint16_t company_id); /* Attention on */ void (*attn_on)(struct bt_mesh_model *model); diff --git a/nimble/host/mesh/include/mesh/main.h b/nimble/host/mesh/include/mesh/main.h index 7966043a2..042b59a5a 100644 --- a/nimble/host/mesh/include/mesh/main.h +++ b/nimble/host/mesh/include/mesh/main.h @@ -62,7 +62,7 @@ typedef enum { /** Provisioning properties & capabilities. */ struct bt_mesh_prov { /** The UUID that's used when advertising as unprovisioned */ - const u8_t *uuid; + const uint8_t *uuid; /** Optional URI. This will be advertised separately from the * unprovisioned beacon, however the unprovisioned beacon will @@ -75,19 +75,19 @@ struct bt_mesh_prov { bt_mesh_prov_oob_info_t oob_info; /** Static OOB value */ - const u8_t *static_val; + const uint8_t *static_val; /** Static OOB value length */ - u8_t static_val_len; + uint8_t static_val_len; /** Maximum size of Output OOB supported */ - u8_t output_size; + uint8_t output_size; /** Supported Output OOB Actions */ - u16_t output_actions; + uint16_t output_actions; /* Maximum size of Input OOB supported */ - u8_t input_size; + uint8_t input_size; /** Supported Input OOB Actions */ - u16_t input_actions; + uint16_t input_actions; /** @brief Output of a number is requested. * @@ -99,7 +99,7 @@ struct bt_mesh_prov { * * @return Zero on success or negative error code otherwise */ - int (*output_number)(bt_mesh_output_action_t act, u32_t num); + int (*output_number)(bt_mesh_output_action_t act, uint32_t num); /** @brief Output of a string is requested. * @@ -126,7 +126,7 @@ struct bt_mesh_prov { * * @return Zero on success or negative error code otherwise */ - int (*input)(bt_mesh_input_action_t act, u8_t size); + int (*input)(bt_mesh_input_action_t act, uint8_t size); /** @brief The other device finished their OOB input. * @@ -146,9 +146,9 @@ struct bt_mesh_prov { * @param uri_hash Pointer to URI Hash value. NULL if no hash was * present in the beacon. */ - void (*unprovisioned_beacon)(u8_t uuid[16], + void (*unprovisioned_beacon)(uint8_t uuid[16], bt_mesh_prov_oob_info_t oob_info, - u32_t *uri_hash); + uint32_t *uri_hash); /** @brief Provisioning link has been opened. * @@ -177,7 +177,7 @@ struct bt_mesh_prov { * @param net_idx NetKeyIndex given during provisioning. * @param addr Primary element address. */ - void (*complete)(u16_t net_idx, u16_t addr); + void (*complete)(uint16_t net_idx, uint16_t addr); /** @brief A new node has been added to the provisioning database. * @@ -190,8 +190,8 @@ struct bt_mesh_prov { * @param addr Primary element address. * @param num_elem Number of elements that this node has. */ - void (*node_added)(u16_t net_idx, u8_t uuid[16], u16_t addr, - u8_t num_elem); + void (*node_added)(uint16_t net_idx, uint8_t uuid[16], uint16_t addr, + uint8_t num_elem); /** @brief Node has been reset. * @@ -224,7 +224,7 @@ int bt_mesh_input_string(const char *str); * * @return Zero on success or (negative) error code otherwise. */ -int bt_mesh_input_number(u32_t num); +int bt_mesh_input_number(uint32_t num); /** @brief Enable specific provisioning bearers * @@ -301,7 +301,7 @@ int bt_mesh_prov_disable(bt_mesh_prov_bearer_t bearers); * * @return Zero on success or (negative) error code otherwise. */ -int bt_mesh_init(u8_t own_addr_type, +int bt_mesh_init(uint8_t own_addr_type, const struct bt_mesh_prov *prov, const struct bt_mesh_comp *comp); @@ -353,9 +353,9 @@ int bt_mesh_resume(void); * * @return Zero on success or (negative) error code otherwise. */ -int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx, - u8_t flags, u32_t iv_index, u16_t addr, - const u8_t dev_key[16]); +int bt_mesh_provision(const uint8_t net_key[16], uint16_t net_idx, + uint8_t flags, uint32_t iv_index, uint16_t addr, + const uint8_t dev_key[16]); /** @brief Provision a Mesh Node using PB-ADV * @@ -367,8 +367,8 @@ int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx, * * @return Zero on success or (negative) error code otherwise. */ -int bt_mesh_provision_adv(const u8_t uuid[16], u16_t net_idx, u16_t addr, - u8_t attention_duration); +int bt_mesh_provision_adv(const uint8_t uuid[16], uint16_t net_idx, uint16_t addr, + uint8_t attention_duration); /** @brief Check if the local node has been provisioned. * @@ -430,7 +430,7 @@ int bt_mesh_lpn_poll(void); * * @param cb Function to call when the Friendship status changes. */ -void bt_mesh_lpn_set_cb(void (*cb)(u16_t friend_addr, bool established)); +void bt_mesh_lpn_set_cb(void (*cb)(uint16_t friend_addr, bool established)); #ifdef __cplusplus } diff --git a/nimble/host/mesh/include/mesh/model_cli.h b/nimble/host/mesh/include/mesh/model_cli.h index f2e77a47f..87e2dd2be 100644 --- a/nimble/host/mesh/include/mesh/model_cli.h +++ b/nimble/host/mesh/include/mesh/model_cli.h @@ -15,7 +15,7 @@ struct bt_mesh_gen_model_cli { struct bt_mesh_model *model; struct k_sem op_sync; - u32_t op_pending; + uint32_t op_pending; void *op_param; }; @@ -33,14 +33,14 @@ extern const struct bt_mesh_model_cb bt_mesh_gen_level_cli_cb; BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_GEN_LEVEL_CLI, gen_level_cli_op, pub,\ cli_data, &bt_mesh_gen_level_cli_cb) -int bt_mesh_gen_onoff_get(u16_t net_idx, u16_t addr, u16_t app_idx, - u8_t *state); -int bt_mesh_gen_onoff_set(u16_t net_idx, u16_t addr, u16_t app_idx, - u8_t val, u8_t *state); -int bt_mesh_gen_level_get(u16_t net_idx, u16_t addr, u16_t app_idx, - s16_t *level); -int bt_mesh_gen_level_set(u16_t net_idx, u16_t addr, u16_t app_idx, - s16_t val, s16_t *state); +int bt_mesh_gen_onoff_get(uint16_t net_idx, uint16_t addr, uint16_t app_idx, + uint8_t *state); +int bt_mesh_gen_onoff_set(uint16_t net_idx, uint16_t addr, uint16_t app_idx, + uint8_t val, uint8_t *state); +int bt_mesh_gen_level_get(uint16_t net_idx, uint16_t addr, uint16_t app_idx, + int16_t *level); +int bt_mesh_gen_level_set(uint16_t net_idx, uint16_t addr, uint16_t app_idx, + int16_t val, int16_t *state); #ifdef __cplusplus } diff --git a/nimble/host/mesh/include/mesh/model_srv.h b/nimble/host/mesh/include/mesh/model_srv.h index e498ad346..a23296b83 100644 --- a/nimble/host/mesh/include/mesh/model_srv.h +++ b/nimble/host/mesh/include/mesh/model_srv.h @@ -14,8 +14,8 @@ extern "C" { struct bt_mesh_gen_onoff_srv { struct bt_mesh_model *model; - int (*get)(struct bt_mesh_model *model, u8_t *state); - int (*set)(struct bt_mesh_model *model, u8_t state); + int (*get)(struct bt_mesh_model *model, uint8_t *state); + int (*set)(struct bt_mesh_model *model, uint8_t state); }; extern const struct bt_mesh_model_op gen_onoff_srv_op[]; @@ -28,8 +28,8 @@ extern const struct bt_mesh_model_cb gen_onoff_srv_cb; struct bt_mesh_gen_level_srv { struct bt_mesh_model *model; - int (*get)(struct bt_mesh_model *model, s16_t *level); - int (*set)(struct bt_mesh_model *model, s16_t level); + int (*get)(struct bt_mesh_model *model, int16_t *level); + int (*set)(struct bt_mesh_model *model, int16_t level); }; extern const struct bt_mesh_model_op gen_level_srv_op[]; @@ -42,8 +42,8 @@ extern const struct bt_mesh_model_cb gen_level_srv_cb; struct bt_mesh_light_lightness_srv { struct bt_mesh_model *model; - int (*get)(struct bt_mesh_model *model, s16_t *level); - int (*set)(struct bt_mesh_model *model, s16_t level); + int (*get)(struct bt_mesh_model *model, int16_t *level); + int (*set)(struct bt_mesh_model *model, int16_t level); }; extern const struct bt_mesh_model_op light_lightness_srv_op[]; @@ -53,12 +53,12 @@ extern const struct bt_mesh_model_cb light_lightness_srv_cb; BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV, \ light_lightness_srv_op, pub, srv, &light_lightness_srv_cb) -void bt_mesh_set_gen_onoff_srv_cb(int (*get)(struct bt_mesh_model *model, u8_t *state), - int (*set)(struct bt_mesh_model *model, u8_t state)); -void bt_mesh_set_gen_level_srv_cb(int (*get)(struct bt_mesh_model *model, s16_t *level), - int (*set)(struct bt_mesh_model *model, s16_t level)); -void bt_mesh_set_light_lightness_srv_cb(int (*get)(struct bt_mesh_model *model, s16_t *level), - int (*set)(struct bt_mesh_model *model, s16_t level)); +void bt_mesh_set_gen_onoff_srv_cb(int (*get)(struct bt_mesh_model *model, uint8_t *state), + int (*set)(struct bt_mesh_model *model, uint8_t state)); +void bt_mesh_set_gen_level_srv_cb(int (*get)(struct bt_mesh_model *model, int16_t *level), + int (*set)(struct bt_mesh_model *model, int16_t level)); +void bt_mesh_set_light_lightness_srv_cb(int (*get)(struct bt_mesh_model *model, int16_t *level), + int (*set)(struct bt_mesh_model *model, int16_t level)); #ifdef __cplusplus } diff --git a/nimble/host/mesh/include/mesh/testing.h b/nimble/host/mesh/include/mesh/testing.h index 4c2b2a619..580aafe41 100644 --- a/nimble/host/mesh/include/mesh/testing.h +++ b/nimble/host/mesh/include/mesh/testing.h @@ -33,13 +33,13 @@ extern "C" { * Allows access to Bluetooth stack internals, not exposed by public API. */ struct bt_test_cb { - void (*mesh_net_recv)(u8_t ttl, u8_t ctl, u16_t src, u16_t dst, + void (*mesh_net_recv)(uint8_t ttl, uint8_t ctl, uint16_t src, uint16_t dst, const void *payload, size_t payload_len); - void (*mesh_model_bound)(u16_t addr, struct bt_mesh_model *model, - u16_t key_idx); - void (*mesh_model_unbound)(u16_t addr, struct bt_mesh_model *model, - u16_t key_idx); - void (*mesh_prov_invalid_bearer)(u8_t opcode); + void (*mesh_model_bound)(uint16_t addr, struct bt_mesh_model *model, + uint16_t key_idx); + void (*mesh_model_unbound)(uint16_t addr, struct bt_mesh_model *model, + uint16_t key_idx); + void (*mesh_prov_invalid_bearer)(uint8_t opcode); void (*mesh_trans_incomp_timer_exp)(void); sys_snode_t node; @@ -66,7 +66,7 @@ void bt_test_cb_unregister(struct bt_test_cb *cb); * * @return Zero on success or (negative) error code otherwise. */ -int bt_test_mesh_lpn_group_add(u16_t group); +int bt_test_mesh_lpn_group_add(uint16_t group); /** Send Friend Subscription List Remove message. * @@ -79,7 +79,7 @@ int bt_test_mesh_lpn_group_add(u16_t group); * * @return Zero on success or (negative) error code otherwise. */ -int bt_test_mesh_lpn_group_remove(u16_t *groups, size_t groups_count); +int bt_test_mesh_lpn_group_remove(uint16_t *groups, size_t groups_count); /** Clear replay protection list cache. * @@ -87,12 +87,12 @@ int bt_test_mesh_lpn_group_remove(u16_t *groups, size_t groups_count); */ int bt_test_mesh_rpl_clear(void); -u8_t mod_bind(struct bt_mesh_model *model, u16_t key_idx); -u8_t mod_unbind(struct bt_mesh_model *model, u16_t key_idx, bool store); +uint8_t mod_bind(struct bt_mesh_model *model, uint16_t key_idx); +uint8_t mod_unbind(struct bt_mesh_model *model, uint16_t key_idx, bool store); int cmd_mesh_init(int argc, char *argv[]); int bt_test_shell_init(void); -int bt_test_bind_app_key_to_model(struct bt_mesh_model *model, u16_t key_idx, u16_t id); +int bt_test_bind_app_key_to_model(struct bt_mesh_model *model, uint16_t key_idx, uint16_t id); /** * @} diff --git a/nimble/host/mesh/src/access.c b/nimble/host/mesh/src/access.c index a4b748867..e87151de9 100644 --- a/nimble/host/mesh/src/access.c +++ b/nimble/host/mesh/src/access.c @@ -26,7 +26,7 @@ #endif static const struct bt_mesh_comp *dev_comp; -static u16_t dev_primary_addr; +static uint16_t dev_primary_addr; void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod, struct bt_mesh_elem *elem, @@ -53,7 +53,7 @@ void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod, } } -s32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod) +int32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod) { int period; @@ -89,10 +89,10 @@ s32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod) } } -static s32_t next_period(struct bt_mesh_model *mod) +static int32_t next_period(struct bt_mesh_model *mod) { struct bt_mesh_model_pub *pub = mod->pub; - u32_t elapsed, period; + uint32_t elapsed, period; period = bt_mesh_model_pub_period_get(mod); if (!period) { @@ -115,7 +115,7 @@ static s32_t next_period(struct bt_mesh_model *mod) static void publish_sent(int err, void *user_data) { struct bt_mesh_model *mod = user_data; - s32_t delay; + int32_t delay; BT_DBG("err %d", err); @@ -131,7 +131,7 @@ static void publish_sent(int err, void *user_data) } } -static void publish_start(u16_t duration, int err, void *user_data) +static void publish_start(uint16_t duration, int err, void *user_data) { struct bt_mesh_model *mod = user_data; struct bt_mesh_model_pub *pub = mod->pub; @@ -203,7 +203,7 @@ static void publish_retransmit_end(int err, struct bt_mesh_model_pub *pub) static void mod_publish(struct ble_npl_event *work) { struct bt_mesh_model_pub *pub = ble_npl_event_get_arg(work); - s32_t period_ms; + int32_t period_ms; int err; BT_DBG(""); @@ -253,7 +253,7 @@ struct bt_mesh_elem *bt_mesh_model_elem(struct bt_mesh_model *mod) return &dev_comp->elem[mod->elem_idx]; } -struct bt_mesh_model *bt_mesh_model_get(bool vnd, u8_t elem_idx, u8_t mod_idx) +struct bt_mesh_model *bt_mesh_model_get(bool vnd, uint8_t elem_idx, uint8_t mod_idx) { struct bt_mesh_elem *elem; @@ -330,7 +330,7 @@ int bt_mesh_comp_register(const struct bt_mesh_comp *comp) return err; } -void bt_mesh_comp_provision(u16_t addr) +void bt_mesh_comp_provision(uint16_t addr) { int i; @@ -355,12 +355,12 @@ void bt_mesh_comp_unprovision(void) dev_primary_addr = BT_MESH_ADDR_UNASSIGNED; } -u16_t bt_mesh_primary_addr(void) +uint16_t bt_mesh_primary_addr(void) { return dev_primary_addr; } -static u16_t *model_group_get(struct bt_mesh_model *mod, u16_t addr) +static uint16_t *model_group_get(struct bt_mesh_model *mod, uint16_t addr) { int i; @@ -374,13 +374,13 @@ static u16_t *model_group_get(struct bt_mesh_model *mod, u16_t addr) } struct find_group_visitor_ctx { - u16_t *entry; + uint16_t *entry; struct bt_mesh_model *mod; - u16_t addr; + uint16_t addr; }; static enum bt_mesh_walk find_group_mod_visitor(struct bt_mesh_model *mod, - u32_t depth, void *user_data) + uint32_t depth, void *user_data) { struct find_group_visitor_ctx *ctx = user_data; @@ -397,7 +397,7 @@ static enum bt_mesh_walk find_group_mod_visitor(struct bt_mesh_model *mod, return BT_MESH_WALK_CONTINUE; } -u16_t *bt_mesh_model_find_group(struct bt_mesh_model **mod, u16_t addr) +uint16_t *bt_mesh_model_find_group(struct bt_mesh_model **mod, uint16_t addr) { struct find_group_visitor_ctx ctx = { .mod = *mod, @@ -413,10 +413,10 @@ u16_t *bt_mesh_model_find_group(struct bt_mesh_model **mod, u16_t addr) } static struct bt_mesh_model *bt_mesh_elem_find_group(struct bt_mesh_elem *elem, - u16_t group_addr) + uint16_t group_addr) { struct bt_mesh_model *model; - u16_t *match; + uint16_t *match; int i; for (i = 0; i < elem->model_count; i++) { @@ -440,9 +440,9 @@ static struct bt_mesh_model *bt_mesh_elem_find_group(struct bt_mesh_elem *elem, return NULL; } -struct bt_mesh_elem *bt_mesh_elem_find(u16_t addr) +struct bt_mesh_elem *bt_mesh_elem_find(uint16_t addr) { - u16_t index; + uint16_t index; if (BT_MESH_ADDR_IS_UNICAST(addr)) { index = (addr - dev_comp->elem[0].addr); @@ -464,12 +464,12 @@ struct bt_mesh_elem *bt_mesh_elem_find(u16_t addr) return NULL; } -u8_t bt_mesh_elem_count(void) +uint8_t bt_mesh_elem_count(void) { return dev_comp->elem_count; } -static bool model_has_key(struct bt_mesh_model *mod, u16_t key) +static bool model_has_key(struct bt_mesh_model *mod, uint16_t key) { int i; @@ -484,7 +484,7 @@ static bool model_has_key(struct bt_mesh_model *mod, u16_t key) return false; } -static bool model_has_dst(struct bt_mesh_model *mod, u16_t dst) +static bool model_has_dst(struct bt_mesh_model *mod, uint16_t dst) { if (BT_MESH_ADDR_IS_UNICAST(dst)) { return (dev_comp->elem[mod->elem_idx].addr == dst); @@ -496,10 +496,10 @@ static bool model_has_dst(struct bt_mesh_model *mod, u16_t dst) } static const struct bt_mesh_model_op *find_op(struct bt_mesh_model *models, - u8_t model_count, u32_t opcode, + uint8_t model_count, uint32_t opcode, struct bt_mesh_model **model) { - u8_t i; + uint8_t i; for (i = 0; i < model_count; i++) { const struct bt_mesh_model_op *op; @@ -517,7 +517,7 @@ static const struct bt_mesh_model_op *find_op(struct bt_mesh_model *models, return NULL; } -static int get_opcode(struct os_mbuf *buf, u32_t *opcode) +static int get_opcode(struct os_mbuf *buf, uint32_t *opcode) { switch (buf->om_data[0] >> 6) { case 0x00: @@ -555,7 +555,7 @@ static int get_opcode(struct os_mbuf *buf, u32_t *opcode) CODE_UNREACHABLE; } -bool bt_mesh_fixed_group_match(u16_t addr) +bool bt_mesh_fixed_group_match(uint16_t addr) { /* Check for fixed group addresses */ switch (addr) { @@ -576,8 +576,8 @@ void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct os_mbuf *buf) { struct bt_mesh_model *models, *model; const struct bt_mesh_model_op *op; - u32_t opcode; - u8_t count; + uint32_t opcode; + uint8_t count; int i; BT_DBG("app_idx 0x%04x src 0x%04x dst 0x%04x", rx->ctx.app_idx, @@ -636,7 +636,7 @@ void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct os_mbuf *buf) } } -void bt_mesh_model_msg_init(struct os_mbuf *msg, u32_t opcode) +void bt_mesh_model_msg_init(struct os_mbuf *msg, uint32_t opcode) { net_buf_simple_init(msg, 0); @@ -792,9 +792,9 @@ done: } struct bt_mesh_model *bt_mesh_model_find_vnd(const struct bt_mesh_elem *elem, - u16_t company, u16_t id) + uint16_t company, uint16_t id) { - u8_t i; + uint8_t i; for (i = 0; i < elem->vnd_model_count; i++) { if (elem->vnd_models[i].vnd.company == company && @@ -807,9 +807,9 @@ struct bt_mesh_model *bt_mesh_model_find_vnd(const struct bt_mesh_elem *elem, } struct bt_mesh_model *bt_mesh_model_find(const struct bt_mesh_elem *elem, - u16_t id) + uint16_t id) { - u8_t i; + uint8_t i; for (i = 0; i < elem->model_count; i++) { if (elem->models[i].id == id) { @@ -837,12 +837,12 @@ struct bt_mesh_model *bt_mesh_model_root(struct bt_mesh_model *mod) void bt_mesh_model_tree_walk(struct bt_mesh_model *root, enum bt_mesh_walk (*cb)(struct bt_mesh_model *mod, - u32_t depth, + uint32_t depth, void *user_data), void *user_data) { struct bt_mesh_model *m = root; - u32_t depth = 0; + uint32_t depth = 0; do { if (cb(m, depth, user_data) == BT_MESH_WALK_STOP) { diff --git a/nimble/host/mesh/src/access.h b/nimble/host/mesh/src/access.h index 48514983f..0852a9eba 100644 --- a/nimble/host/mesh/src/access.h +++ b/nimble/host/mesh/src/access.h @@ -26,23 +26,23 @@ enum bt_mesh_walk { BT_MESH_WALK_CONTINUE, }; -void bt_mesh_elem_register(struct bt_mesh_elem *elem, u8_t count); +void bt_mesh_elem_register(struct bt_mesh_elem *elem, uint8_t count); -u8_t bt_mesh_elem_count(void); +uint8_t bt_mesh_elem_count(void); /* Find local element based on unicast or group address */ -struct bt_mesh_elem *bt_mesh_elem_find(u16_t addr); +struct bt_mesh_elem *bt_mesh_elem_find(uint16_t addr); struct bt_mesh_model *bt_mesh_model_root(struct bt_mesh_model *mod); void bt_mesh_model_tree_walk(struct bt_mesh_model *root, enum bt_mesh_walk (*cb)(struct bt_mesh_model *mod, - u32_t depth, + uint32_t depth, void *user_data), void *user_data); -u16_t *bt_mesh_model_find_group(struct bt_mesh_model **mod, u16_t addr); +uint16_t *bt_mesh_model_find_group(struct bt_mesh_model **mod, uint16_t addr); -bool bt_mesh_fixed_group_match(u16_t addr); +bool bt_mesh_fixed_group_match(uint16_t addr); void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod, struct bt_mesh_elem *elem, @@ -50,16 +50,16 @@ void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod, void *user_data), void *user_data); -s32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod); +int32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod); -void bt_mesh_comp_provision(u16_t addr); +void bt_mesh_comp_provision(uint16_t addr); void bt_mesh_comp_unprovision(void); -u16_t bt_mesh_primary_addr(void); +uint16_t bt_mesh_primary_addr(void); const struct bt_mesh_comp *bt_mesh_comp_get(void); -struct bt_mesh_model *bt_mesh_model_get(bool vnd, u8_t elem_idx, u8_t mod_idx); +struct bt_mesh_model *bt_mesh_model_get(bool vnd, uint8_t elem_idx, uint8_t mod_idx); void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct os_mbuf *buf); diff --git a/nimble/host/mesh/src/adv.c b/nimble/host/mesh/src/adv.c index 0a6c71ee7..5cb0aa6a7 100644 --- a/nimble/host/mesh/src/adv.c +++ b/nimble/host/mesh/src/adv.c @@ -38,7 +38,7 @@ #define ADV_INT_DEFAULT_MS 100 #define ADV_INT_FAST_MS 20 -static s32_t adv_int_min = ADV_INT_DEFAULT_MS; +static int32_t adv_int_min = ADV_INT_DEFAULT_MS; /* TinyCrypt PRNG consumes a lot of stack space, so we need to have * an increased call stack whenever it's used. @@ -49,7 +49,7 @@ struct os_task adv_task; #endif static struct ble_npl_eventq adv_queue; -extern u8_t g_mesh_addr_type; +extern uint8_t g_mesh_addr_type; static int adv_initialized = false; static os_membuf_t adv_buf_mem[OS_MEMPOOL_SIZE( @@ -66,7 +66,7 @@ static struct bt_mesh_adv *adv_alloc(int id) return &adv_pool[id]; } -static inline void adv_send_start(u16_t duration, int err, +static inline void adv_send_start(uint16_t duration, int err, const struct bt_mesh_send_cb *cb, void *cb_data) { @@ -85,7 +85,7 @@ static inline void adv_send_end(int err, const struct bt_mesh_send_cb *cb, static inline void adv_send(struct os_mbuf *buf) { - static const u8_t adv_type[] = { + static const uint8_t adv_type[] = { [BT_MESH_ADV_PROV] = BLE_HS_ADV_TYPE_MESH_PROV, [BT_MESH_ADV_DATA] = BLE_HS_ADV_TYPE_MESH_MESSAGE, [BT_MESH_ADV_BEACON] = BLE_HS_ADV_TYPE_MESH_BEACON, @@ -95,7 +95,7 @@ static inline void adv_send(struct os_mbuf *buf) const struct bt_mesh_send_cb *cb = BT_MESH_ADV(buf)->cb; void *cb_data = BT_MESH_ADV(buf)->cb_data; struct ble_gap_adv_params param = { 0 }; - u16_t duration, adv_int; + uint16_t duration, adv_int; struct bt_data ad; int err; @@ -152,7 +152,7 @@ mesh_adv_thread(void *args) static struct ble_npl_event *ev; struct os_mbuf *buf; #if (MYNEWT_VAL(BLE_MESH_PROXY)) - s32_t timeout; + int32_t timeout; #endif BT_DBG("started"); @@ -206,7 +206,7 @@ void bt_mesh_adv_update(void) struct os_mbuf *bt_mesh_adv_create_from_pool(struct os_mbuf_pool *pool, bt_mesh_adv_alloc_t get_id, enum bt_mesh_adv_type type, - u8_t xmit, s32_t timeout) + uint8_t xmit, int32_t timeout) { struct bt_mesh_adv *adv; struct os_mbuf *buf; @@ -235,8 +235,8 @@ struct os_mbuf *bt_mesh_adv_create_from_pool(struct os_mbuf_pool *pool, return buf; } -struct os_mbuf *bt_mesh_adv_create(enum bt_mesh_adv_type type, u8_t xmit, - s32_t timeout) +struct os_mbuf *bt_mesh_adv_create(enum bt_mesh_adv_type type, uint8_t xmit, + int32_t timeout) { return bt_mesh_adv_create_from_pool(&adv_os_mbuf_pool, adv_alloc, type, xmit, timeout); @@ -255,8 +255,8 @@ void bt_mesh_adv_send(struct os_mbuf *buf, const struct bt_mesh_send_cb *cb, net_buf_put(&adv_queue, net_buf_ref(buf)); } -static void bt_mesh_scan_cb(const bt_addr_le_t *addr, s8_t rssi, - u8_t adv_type, struct os_mbuf *buf) +static void bt_mesh_scan_cb(const bt_addr_le_t *addr, int8_t rssi, + uint8_t adv_type, struct os_mbuf *buf) { if (adv_type != BLE_HCI_ADV_TYPE_ADV_NONCONN_IND) { return; @@ -268,7 +268,7 @@ static void bt_mesh_scan_cb(const bt_addr_le_t *addr, s8_t rssi, while (buf->om_len > 1) { struct net_buf_simple_state state; - u8_t len, type; + uint8_t len, type; len = net_buf_simple_pull_u8(buf); /* Check for early termination */ diff --git a/nimble/host/mesh/src/adv.h b/nimble/host/mesh/src/adv.h index f50f4fbd8..779ee58ed 100644 --- a/nimble/host/mesh/src/adv.h +++ b/nimble/host/mesh/src/adv.h @@ -31,18 +31,18 @@ enum bt_mesh_adv_type BT_MESH_ADV_URI, }; -typedef void (*bt_mesh_adv_func_t)(struct os_mbuf *buf, u16_t duration, +typedef void (*bt_mesh_adv_func_t)(struct os_mbuf *buf, uint16_t duration, int err, void *user_data); struct bt_mesh_adv { const struct bt_mesh_send_cb *cb; void *cb_data; - u8_t type:2, + uint8_t type:2, busy:1; - u8_t xmit; + uint8_t xmit; - u8_t flags; + uint8_t flags; int ref_cnt; struct ble_npl_event ev; @@ -51,13 +51,13 @@ struct bt_mesh_adv { typedef struct bt_mesh_adv *(*bt_mesh_adv_alloc_t)(int id); /* xmit_count: Number of retransmissions, i.e. 0 == 1 transmission */ -struct os_mbuf *bt_mesh_adv_create(enum bt_mesh_adv_type type, u8_t xmit, - s32_t timeout); +struct os_mbuf *bt_mesh_adv_create(enum bt_mesh_adv_type type, uint8_t xmit, + int32_t timeout); struct os_mbuf *bt_mesh_adv_create_from_pool(struct os_mbuf_pool *pool, bt_mesh_adv_alloc_t get_id, enum bt_mesh_adv_type type, - u8_t xmit, s32_t timeout); + uint8_t xmit, int32_t timeout); void bt_mesh_adv_send(struct os_mbuf *buf, const struct bt_mesh_send_cb *cb, void *cb_data); diff --git a/nimble/host/mesh/src/aes-ccm.c b/nimble/host/mesh/src/aes-ccm.c index dd21549ac..c0772889c 100644 --- a/nimble/host/mesh/src/aes-ccm.c +++ b/nimble/host/mesh/src/aes-ccm.c @@ -7,7 +7,7 @@ #include "crypto.h" -static inline void xor16(u8_t *dst, const u8_t *a, const u8_t *b) +static inline void xor16(uint8_t *dst, const uint8_t *a, const uint8_t *b) { dst[0] = a[0] ^ b[0]; dst[1] = a[1] ^ b[1]; @@ -28,9 +28,9 @@ static inline void xor16(u8_t *dst, const u8_t *a, const u8_t *b) } /* pmsg is assumed to have the nonce already present in bytes 1-13 */ -static int ccm_calculate_X0(const u8_t key[16], const u8_t *aad, u8_t aad_len, - size_t mic_size, u8_t msg_len, u8_t b[16], - u8_t X0[16]) +static int ccm_calculate_X0(const uint8_t key[16], const uint8_t *aad, uint8_t aad_len, + size_t mic_size, uint8_t msg_len, uint8_t b[16], + uint8_t X0[16]) { int i, j, err; @@ -48,12 +48,12 @@ static int ccm_calculate_X0(const u8_t key[16], const u8_t *aad, u8_t aad_len, if (aad_len) { sys_put_be16(aad_len, b); - for (i = 0; i < sizeof(u16_t); i++) { + for (i = 0; i < sizeof(uint16_t); i++) { b[i] = X0[i] ^ b[i]; } j = 0; - aad_len += sizeof(u16_t); + aad_len += sizeof(uint16_t); while (aad_len > 16) { do { b[i] = X0[i] ^ aad[j]; @@ -86,12 +86,12 @@ static int ccm_calculate_X0(const u8_t key[16], const u8_t *aad, u8_t aad_len, return 0; } -static int ccm_auth(const u8_t key[16], u8_t nonce[13], - const u8_t *cleartext_msg, size_t msg_len, const u8_t *aad, - size_t aad_len, u8_t *mic, size_t mic_size) +static int ccm_auth(const uint8_t key[16], uint8_t nonce[13], + const uint8_t *cleartext_msg, size_t msg_len, const uint8_t *aad, + size_t aad_len, uint8_t *mic, size_t mic_size) { - u8_t b[16], Xn[16], s0[16]; - u16_t blk_cnt, last_blk; + uint8_t b[16], Xn[16], s0[16]; + uint16_t blk_cnt, last_blk; int err, j, i; last_blk = msg_len % 16; @@ -139,11 +139,11 @@ static int ccm_auth(const u8_t key[16], u8_t nonce[13], return 0; } -static int ccm_crypt(const u8_t key[16], const u8_t nonce[13], - const u8_t *in_msg, u8_t *out_msg, size_t msg_len) +static int ccm_crypt(const uint8_t key[16], const uint8_t nonce[13], + const uint8_t *in_msg, uint8_t *out_msg, size_t msg_len) { - u8_t a_i[16], s_i[16]; - u16_t last_blk, blk_cnt; + uint8_t a_i[16], s_i[16]; + uint16_t last_blk, blk_cnt; size_t i, j; int err; @@ -178,11 +178,11 @@ static int ccm_crypt(const u8_t key[16], const u8_t nonce[13], return 0; } -int bt_ccm_decrypt(const u8_t key[16], u8_t nonce[13], const u8_t *enc_msg, - size_t msg_len, const u8_t *aad, size_t aad_len, - u8_t *out_msg, size_t mic_size) +int bt_ccm_decrypt(const uint8_t key[16], uint8_t nonce[13], const uint8_t *enc_msg, + size_t msg_len, const uint8_t *aad, size_t aad_len, + uint8_t *out_msg, size_t mic_size) { - u8_t mic[16]; + uint8_t mic[16]; if (aad_len >= 0xff00 || mic_size > sizeof(mic)) { return -EINVAL; @@ -199,11 +199,11 @@ int bt_ccm_decrypt(const u8_t key[16], u8_t nonce[13], const u8_t *enc_msg, return 0; } -int bt_ccm_encrypt(const u8_t key[16], u8_t nonce[13], const u8_t *msg, - size_t msg_len, const u8_t *aad, size_t aad_len, - u8_t *out_msg, size_t mic_size) +int bt_ccm_encrypt(const uint8_t key[16], uint8_t nonce[13], const uint8_t *msg, + size_t msg_len, const uint8_t *aad, size_t aad_len, + uint8_t *out_msg, size_t mic_size) { - u8_t *mic = out_msg + msg_len; + uint8_t *mic = out_msg + msg_len; BT_DBG("key %s", bt_hex(key, 16)); BT_DBG("nonce %s", bt_hex(nonce, 13)); diff --git a/nimble/host/mesh/src/beacon.c b/nimble/host/mesh/src/beacon.c index dcc19a80c..2db03cf93 100644 --- a/nimble/host/mesh/src/beacon.c +++ b/nimble/host/mesh/src/beacon.c @@ -36,7 +36,7 @@ static struct k_delayed_work beacon_timer; -static struct bt_mesh_subnet *cache_check(u8_t data[21]) +static struct bt_mesh_subnet *cache_check(uint8_t data[21]) { int i; @@ -55,7 +55,7 @@ static struct bt_mesh_subnet *cache_check(u8_t data[21]) return NULL; } -static void cache_add(u8_t data[21], struct bt_mesh_subnet *sub) +static void cache_add(uint8_t data[21], struct bt_mesh_subnet *sub) { memcpy(sub->beacon_cache, data, 21); } @@ -72,7 +72,7 @@ static void beacon_complete(int err, void *user_data) void bt_mesh_beacon_create(struct bt_mesh_subnet *sub, struct os_mbuf *buf) { - u8_t flags = bt_mesh_net_flags(sub); + uint8_t flags = bt_mesh_net_flags(sub); struct bt_mesh_subnet_keys *keys; net_buf_simple_add_u8(buf, BEACON_TYPE_SECURE); @@ -108,7 +108,7 @@ static int secure_beacon_send(void) static const struct bt_mesh_send_cb send_cb = { .end = beacon_complete, }; - u32_t now = k_uptime_get_32(); + uint32_t now = k_uptime_get_32(); int i; BT_DBG(""); @@ -116,7 +116,7 @@ static int secure_beacon_send(void) for (i = 0; i < ARRAY_SIZE(bt_mesh.sub); i++) { struct bt_mesh_subnet *sub = &bt_mesh.sub[i]; struct os_mbuf *buf; - u32_t time_diff; + uint32_t time_diff; if (sub->net_idx == BT_MESH_KEY_UNUSED) { continue; @@ -147,9 +147,9 @@ static int secure_beacon_send(void) static int unprovisioned_beacon_send(void) { const struct bt_mesh_prov *prov; - u8_t uri_hash[16] = { 0 }; + uint8_t uri_hash[16] = { 0 }; struct os_mbuf *buf; - u16_t oob_info; + uint16_t oob_info; BT_DBG("unprovisioned_beacon_send"); @@ -203,10 +203,10 @@ static int unprovisioned_beacon_send(void) static void unprovisioned_beacon_recv(struct os_mbuf *buf) { const struct bt_mesh_prov *prov; - u8_t *uuid; - u16_t oob_info; - u32_t uri_hash_val; - u32_t *uri_hash = NULL; + uint8_t *uuid; + uint16_t oob_info; + uint32_t uri_hash_val; + uint32_t *uri_hash = NULL; if (buf->om_len != 18 && buf->om_len != 22) { BT_ERR("Invalid unprovisioned beacon length (%u)", buf->om_len); @@ -292,11 +292,11 @@ static void beacon_send(struct ble_npl_event *work) static void secure_beacon_recv(struct os_mbuf *buf) { - u8_t *data, *net_id, *auth; + uint8_t *data, *net_id, *auth; struct bt_mesh_subnet *sub; - u32_t iv_index; + uint32_t iv_index; bool new_key, kr_change, iv_change; - u8_t flags; + uint8_t flags; if (buf->om_len < 21) { BT_ERR("Too short secure beacon (len %u)", buf->om_len); @@ -372,7 +372,7 @@ update_stats: void bt_mesh_beacon_recv(struct os_mbuf *buf) { - u8_t type; + uint8_t type; BT_DBG("%u bytes: %s", buf->om_len, bt_hex(buf->om_data, buf->om_len)); diff --git a/nimble/host/mesh/src/cdb.c b/nimble/host/mesh/src/cdb.c index 4cb21b229..2a8b44ecd 100644 --- a/nimble/host/mesh/src/cdb.c +++ b/nimble/host/mesh/src/cdb.c @@ -38,10 +38,10 @@ struct bt_mesh_cdb bt_mesh_cdb = { * free for use. When a conflict is found, next will be set to the next address * available after the conflicting range and -EAGAIN will be returned. */ -static int addr_is_free(u16_t addr_start, u8_t num_elem, u16_t *next) +static int addr_is_free(uint16_t addr_start, uint8_t num_elem, uint16_t *next) { - u16_t addr_end = addr_start + num_elem - 1; - u16_t other_start, other_end; + uint16_t addr_end = addr_start + num_elem - 1; + uint16_t other_start, other_end; int i; if (!BT_MESH_ADDR_IS_UNICAST(addr_start) || @@ -81,9 +81,9 @@ static int addr_is_free(u16_t addr_start, u8_t num_elem, u16_t *next) * through the array of nodes N+2 times. A more effective algorithm * could be used if the nodes were stored in a sorted list. */ -static u16_t find_lowest_free_addr(u8_t num_elem) +static uint16_t find_lowest_free_addr(uint8_t num_elem) { - u16_t addr = 1, next; + uint16_t addr = 1, next; int err, i; /* @@ -106,7 +106,7 @@ static u16_t find_lowest_free_addr(u8_t num_elem) return addr; } -int bt_mesh_cdb_create(const u8_t key[16]) +int bt_mesh_cdb_create(const uint8_t key[16]) { struct bt_mesh_cdb_subnet *sub; @@ -160,7 +160,7 @@ void bt_mesh_cdb_clear(void) } } -void bt_mesh_cdb_iv_update(u32_t iv_index, bool iv_update) +void bt_mesh_cdb_iv_update(uint32_t iv_index, bool iv_update) { BT_DBG("Updating IV index to %d\n", iv_index); @@ -174,7 +174,7 @@ void bt_mesh_cdb_iv_update(u32_t iv_index, bool iv_update) } } -struct bt_mesh_cdb_subnet *bt_mesh_cdb_subnet_alloc(u16_t net_idx) +struct bt_mesh_cdb_subnet *bt_mesh_cdb_subnet_alloc(uint16_t net_idx) { struct bt_mesh_cdb_subnet *sub; int i; @@ -210,7 +210,7 @@ void bt_mesh_cdb_subnet_del(struct bt_mesh_cdb_subnet *sub, bool store) memset(sub->keys, 0, sizeof(sub->keys)); } -struct bt_mesh_cdb_subnet *bt_mesh_cdb_subnet_get(u16_t net_idx) +struct bt_mesh_cdb_subnet *bt_mesh_cdb_subnet_get(uint16_t net_idx) { int i; @@ -230,9 +230,9 @@ void bt_mesh_cdb_subnet_store(const struct bt_mesh_cdb_subnet *sub) } } -u8_t bt_mesh_cdb_subnet_flags(const struct bt_mesh_cdb_subnet *sub) +uint8_t bt_mesh_cdb_subnet_flags(const struct bt_mesh_cdb_subnet *sub) { - u8_t flags = 0x00; + uint8_t flags = 0x00; if (sub && sub->kr_flag) { flags |= BT_MESH_NET_FLAG_KR; @@ -245,8 +245,8 @@ u8_t bt_mesh_cdb_subnet_flags(const struct bt_mesh_cdb_subnet *sub) return flags; } -struct bt_mesh_cdb_node *bt_mesh_cdb_node_alloc(const u8_t uuid[16], u16_t addr, - u8_t num_elem, u16_t net_idx) +struct bt_mesh_cdb_node *bt_mesh_cdb_node_alloc(const uint8_t uuid[16], uint16_t addr, + uint8_t num_elem, uint16_t net_idx) { int i; @@ -289,7 +289,7 @@ void bt_mesh_cdb_node_del(struct bt_mesh_cdb_node *node, bool store) memset(node->dev_key, 0, sizeof(node->dev_key)); } -struct bt_mesh_cdb_node *bt_mesh_cdb_node_get(u16_t addr) +struct bt_mesh_cdb_node *bt_mesh_cdb_node_get(uint16_t addr) { int i; @@ -328,8 +328,8 @@ void bt_mesh_cdb_node_foreach(bt_mesh_cdb_node_func_t func, void *user_data) } } -struct bt_mesh_cdb_app_key *bt_mesh_cdb_app_key_alloc(u16_t net_idx, - u16_t app_idx) +struct bt_mesh_cdb_app_key *bt_mesh_cdb_app_key_alloc(uint16_t net_idx, + uint16_t app_idx) { struct bt_mesh_cdb_app_key *key; int i; @@ -362,7 +362,7 @@ void bt_mesh_cdb_app_key_del(struct bt_mesh_cdb_app_key *key, bool store) memset(key->keys, 0, sizeof(key->keys)); } -struct bt_mesh_cdb_app_key *bt_mesh_cdb_app_key_get(u16_t app_idx) +struct bt_mesh_cdb_app_key *bt_mesh_cdb_app_key_get(uint16_t app_idx) { int i; diff --git a/nimble/host/mesh/src/cfg_cli.c b/nimble/host/mesh/src/cfg_cli.c index e60199c58..bf3bf4579 100644 --- a/nimble/host/mesh/src/cfg_cli.c +++ b/nimble/host/mesh/src/cfg_cli.c @@ -25,11 +25,11 @@ #define DUMMY_2_BYTE_OP BT_MESH_MODEL_OP_2(0xff, 0xff) struct comp_data { - u8_t *status; + uint8_t *status; struct os_mbuf *comp; }; -static s32_t msg_timeout = K_SECONDS(5); +static int32_t msg_timeout = K_SECONDS(5); static struct bt_mesh_cfg_cli *cli; @@ -61,9 +61,9 @@ static void comp_data_status(struct bt_mesh_model *model, static void state_status_u8(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf*buf, - u32_t expect_status) + uint32_t expect_status) { - u8_t *status; + uint8_t *status; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, @@ -110,8 +110,8 @@ static void gatt_proxy_status(struct bt_mesh_model *model, } struct relay_param { - u8_t *status; - u8_t *transmit; + uint8_t *status; + uint8_t *transmit; }; static void relay_status(struct bt_mesh_model *model, @@ -137,8 +137,8 @@ static void relay_status(struct bt_mesh_model *model, } struct net_key_param { - u8_t *status; - u16_t net_idx; + uint8_t *status; + uint16_t net_idx; }; static void net_key_status(struct bt_mesh_model *model, @@ -146,8 +146,8 @@ static void net_key_status(struct bt_mesh_model *model, struct os_mbuf *buf) { struct net_key_param *param; - u16_t net_idx; - u8_t status; + uint16_t net_idx; + uint8_t status; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, @@ -175,7 +175,7 @@ static void net_key_status(struct bt_mesh_model *model, } struct net_key_list_param { - u16_t *keys; + uint16_t *keys; size_t *key_cnt; }; @@ -211,9 +211,9 @@ static void net_key_list(struct bt_mesh_model *model, } struct app_key_param { - u8_t *status; - u16_t net_idx; - u16_t app_idx; + uint8_t *status; + uint16_t net_idx; + uint16_t app_idx; }; static void app_key_status(struct bt_mesh_model *model, @@ -221,8 +221,8 @@ static void app_key_status(struct bt_mesh_model *model, struct os_mbuf*buf) { struct app_key_param *param; - u16_t net_idx, app_idx; - u8_t status; + uint16_t net_idx, app_idx; + uint8_t status; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, @@ -250,9 +250,9 @@ static void app_key_status(struct bt_mesh_model *model, } struct app_key_list_param { - u16_t net_idx; - u8_t *status; - u16_t *keys; + uint16_t net_idx; + uint8_t *status; + uint16_t *keys; size_t *key_cnt; }; @@ -261,8 +261,8 @@ static void app_key_list(struct bt_mesh_model *model, struct os_mbuf *buf) { struct app_key_list_param *param; - u16_t net_idx; - u8_t status; + uint16_t net_idx; + uint8_t status; int i; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", @@ -300,20 +300,20 @@ static void app_key_list(struct bt_mesh_model *model, } struct mod_app_param { - u8_t *status; - u16_t elem_addr; - u16_t mod_app_idx; - u16_t mod_id; - u16_t cid; + uint8_t *status; + uint16_t elem_addr; + uint16_t mod_app_idx; + uint16_t mod_id; + uint16_t cid; }; static void mod_app_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf*buf) { - u16_t elem_addr, mod_app_idx, mod_id, cid; + uint16_t elem_addr, mod_app_idx, mod_id, cid; struct mod_app_param *param; - u8_t status; + uint8_t status; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, @@ -352,11 +352,11 @@ static void mod_app_status(struct bt_mesh_model *model, } struct mod_member_list_param { - u8_t *status; - u16_t elem_addr; - u16_t mod_id; - u16_t cid; - u16_t *members; + uint8_t *status; + uint16_t elem_addr; + uint16_t mod_id; + uint16_t cid; + uint16_t *members; size_t *member_cnt; }; @@ -364,8 +364,8 @@ static void mod_member_list_handle(struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf, bool vnd) { struct mod_member_list_param *param; - u16_t elem_addr, mod_id, cid; - u8_t status; + uint16_t elem_addr, mod_id, cid; + uint8_t status; int i; status = net_buf_simple_pull_u8(buf); @@ -433,10 +433,10 @@ static void mod_app_list_vnd(struct bt_mesh_model *model, } struct mod_pub_param { - u16_t mod_id; - u16_t cid; - u16_t elem_addr; - u8_t *status; + uint16_t mod_id; + uint16_t cid; + uint16_t elem_addr; + uint8_t *status; struct bt_mesh_cfg_mod_pub *pub; }; @@ -444,9 +444,9 @@ static void mod_pub_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf*buf) { - u16_t mod_id, cid, elem_addr; + uint16_t mod_id, cid, elem_addr; struct mod_pub_param *param; - u8_t status; + uint8_t status; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, @@ -508,21 +508,21 @@ static void mod_pub_status(struct bt_mesh_model *model, } struct mod_sub_param { - u8_t *status; - u16_t elem_addr; - u16_t *sub_addr; - u16_t *expect_sub; - u16_t mod_id; - u16_t cid; + uint8_t *status; + uint16_t elem_addr; + uint16_t *sub_addr; + uint16_t *expect_sub; + uint16_t mod_id; + uint16_t cid; }; static void mod_sub_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf*buf) { - u16_t elem_addr, sub_addr, mod_id, cid; + uint16_t elem_addr, sub_addr, mod_id, cid; struct mod_sub_param *param; - u8_t status; + uint8_t status; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, @@ -597,7 +597,7 @@ static void mod_sub_list_vnd(struct bt_mesh_model *model, } struct hb_sub_param { - u8_t *status; + uint8_t *status; struct bt_mesh_cfg_hb_sub *sub; }; @@ -631,7 +631,7 @@ static void hb_sub_status(struct bt_mesh_model *model, } struct hb_pub_param { - u8_t *status; + uint8_t *status; struct bt_mesh_cfg_hb_pub *pub; }; @@ -721,7 +721,7 @@ const struct bt_mesh_model_cb bt_mesh_cfg_cli_cb = { .init = cfg_cli_init, }; -static int cli_prepare(void *param, u32_t op) +static int cli_prepare(void *param, uint32_t op) { if (!cli) { BT_ERR("No available Configuration Client context!"); @@ -756,8 +756,8 @@ static int cli_wait(void) return err; } -int bt_mesh_cfg_comp_data_get(u16_t net_idx, u16_t addr, u8_t page, - u8_t *status, struct os_mbuf *comp) +int bt_mesh_cfg_comp_data_get(uint16_t net_idx, uint16_t addr, uint8_t page, + uint8_t *status, struct os_mbuf *comp) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_DEV_COMP_DATA_GET, 1); struct bt_mesh_msg_ctx ctx = { @@ -793,8 +793,8 @@ done: return err; } -static int get_state_u8(u16_t net_idx, u16_t addr, u32_t op, u32_t rsp, - u8_t *val) +static int get_state_u8(uint16_t net_idx, uint16_t addr, uint32_t op, uint32_t rsp, + uint8_t *val) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(DUMMY_2_BYTE_OP, 0); struct bt_mesh_msg_ctx ctx = { @@ -825,8 +825,8 @@ done: return err; } -static int set_state_u8(u16_t net_idx, u16_t addr, u32_t op, u32_t rsp, - u8_t new_val, u8_t *val) +static int set_state_u8(uint16_t net_idx, uint16_t addr, uint32_t op, uint32_t rsp, + uint8_t new_val, uint8_t *val) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(DUMMY_2_BYTE_OP, 1); struct bt_mesh_msg_ctx ctx = { @@ -858,57 +858,57 @@ done: return err; } -int bt_mesh_cfg_beacon_get(u16_t net_idx, u16_t addr, u8_t *status) +int bt_mesh_cfg_beacon_get(uint16_t net_idx, uint16_t addr, uint8_t *status) { return get_state_u8(net_idx, addr, OP_BEACON_GET, OP_BEACON_STATUS, status); } -int bt_mesh_cfg_beacon_set(u16_t net_idx, u16_t addr, u8_t val, u8_t *status) +int bt_mesh_cfg_beacon_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *status) { return set_state_u8(net_idx, addr, OP_BEACON_SET, OP_BEACON_STATUS, val, status); } -int bt_mesh_cfg_ttl_get(u16_t net_idx, u16_t addr, u8_t *ttl) +int bt_mesh_cfg_ttl_get(uint16_t net_idx, uint16_t addr, uint8_t *ttl) { return get_state_u8(net_idx, addr, OP_DEFAULT_TTL_GET, OP_DEFAULT_TTL_STATUS, ttl); } -int bt_mesh_cfg_ttl_set(u16_t net_idx, u16_t addr, u8_t val, u8_t *ttl) +int bt_mesh_cfg_ttl_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *ttl) { return set_state_u8(net_idx, addr, OP_DEFAULT_TTL_SET, OP_DEFAULT_TTL_STATUS, val, ttl); } -int bt_mesh_cfg_friend_get(u16_t net_idx, u16_t addr, u8_t *status) +int bt_mesh_cfg_friend_get(uint16_t net_idx, uint16_t addr, uint8_t *status) { return get_state_u8(net_idx, addr, OP_FRIEND_GET, OP_FRIEND_STATUS, status); } -int bt_mesh_cfg_friend_set(u16_t net_idx, u16_t addr, u8_t val, u8_t *status) +int bt_mesh_cfg_friend_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *status) { return set_state_u8(net_idx, addr, OP_FRIEND_SET, OP_FRIEND_STATUS, val, status); } -int bt_mesh_cfg_gatt_proxy_get(u16_t net_idx, u16_t addr, u8_t *status) +int bt_mesh_cfg_gatt_proxy_get(uint16_t net_idx, uint16_t addr, uint8_t *status) { return get_state_u8(net_idx, addr, OP_GATT_PROXY_GET, OP_GATT_PROXY_STATUS, status); } -int bt_mesh_cfg_gatt_proxy_set(u16_t net_idx, u16_t addr, u8_t val, - u8_t *status) +int bt_mesh_cfg_gatt_proxy_set(uint16_t net_idx, uint16_t addr, uint8_t val, + uint8_t *status) { return set_state_u8(net_idx, addr, OP_GATT_PROXY_SET, OP_GATT_PROXY_STATUS, val, status); } -int bt_mesh_cfg_relay_get(u16_t net_idx, u16_t addr, u8_t *status, - u8_t *transmit) +int bt_mesh_cfg_relay_get(uint16_t net_idx, uint16_t addr, uint8_t *status, + uint8_t *transmit) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_RELAY_GET, 0); struct bt_mesh_msg_ctx ctx = { @@ -943,8 +943,8 @@ done: return err; } -int bt_mesh_cfg_relay_set(u16_t net_idx, u16_t addr, u8_t new_relay, - u8_t new_transmit, u8_t *status, u8_t *transmit) +int bt_mesh_cfg_relay_set(uint16_t net_idx, uint16_t addr, uint8_t new_relay, + uint8_t new_transmit, uint8_t *status, uint8_t *transmit) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_RELAY_SET, 2); struct bt_mesh_msg_ctx ctx = { @@ -981,8 +981,8 @@ done: return err; } -int bt_mesh_cfg_net_key_add(u16_t net_idx, u16_t addr, u16_t key_net_idx, - const u8_t net_key[16], u8_t *status) +int bt_mesh_cfg_net_key_add(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, + const uint8_t net_key[16], uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_NET_KEY_ADD, 18); struct bt_mesh_msg_ctx ctx = { @@ -1024,7 +1024,7 @@ done: return err; } -int bt_mesh_cfg_net_key_get(u16_t net_idx, u16_t addr, u16_t *keys, +int bt_mesh_cfg_net_key_get(uint16_t net_idx, uint16_t addr, uint16_t *keys, size_t *key_cnt) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_NET_KEY_GET, 0); @@ -1096,9 +1096,9 @@ int bt_mesh_cfg_net_key_del(uint16_t net_idx, uint16_t addr, return cli_wait(); } -int bt_mesh_cfg_app_key_add(u16_t net_idx, u16_t addr, u16_t key_net_idx, - u16_t key_app_idx, const u8_t app_key[16], - u8_t *status) +int bt_mesh_cfg_app_key_add(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, + uint16_t key_app_idx, const uint8_t app_key[16], + uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_APP_KEY_ADD, 19); struct bt_mesh_msg_ctx ctx = { @@ -1141,8 +1141,8 @@ done: return err; } -int bt_mesh_cfg_app_key_get(u16_t net_idx, u16_t addr, u16_t key_net_idx, - u8_t *status, u16_t *keys, size_t *key_cnt) +int bt_mesh_cfg_app_key_get(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, + uint8_t *status, uint16_t *keys, size_t *key_cnt) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_APP_KEY_GET, 2); struct bt_mesh_msg_ctx ctx = { @@ -1217,9 +1217,9 @@ int bt_mesh_cfg_app_key_del(uint16_t net_idx, uint16_t addr, return cli_wait(); } -static int mod_app_bind(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_app_idx, u16_t mod_id, u16_t cid, - u8_t *status) +static int mod_app_bind(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_app_idx, uint16_t mod_id, uint16_t cid, + uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_MOD_APP_BIND, 8); struct bt_mesh_msg_ctx ctx = { @@ -1270,16 +1270,16 @@ done: return err; } -int bt_mesh_cfg_mod_app_bind(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_app_idx, u16_t mod_id, u8_t *status) +int bt_mesh_cfg_mod_app_bind(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_app_idx, uint16_t mod_id, uint8_t *status) { return mod_app_bind(net_idx, addr, elem_addr, mod_app_idx, mod_id, CID_NVAL, status); } -int bt_mesh_cfg_mod_app_bind_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_app_idx, u16_t mod_id, u16_t cid, - u8_t *status) +int bt_mesh_cfg_mod_app_bind_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_app_idx, uint16_t mod_id, uint16_t cid, + uint8_t *status) { if (cid == CID_NVAL) { return -EINVAL; @@ -1359,9 +1359,9 @@ int bt_mesh_cfg_mod_app_unbind_vnd(uint16_t net_idx, uint16_t addr, mod_id, cid, status); } -static int mod_member_list_get(u32_t op, u32_t expect_op, u16_t net_idx, - u16_t addr, u16_t elem_addr, u16_t mod_id, - u16_t cid, u8_t *status, u16_t *apps, +static int mod_member_list_get(uint32_t op, uint32_t expect_op, uint16_t net_idx, + uint16_t addr, uint16_t elem_addr, uint16_t mod_id, + uint16_t cid, uint8_t *status, uint16_t *apps, size_t *app_cnt) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(DUMMY_2_BYTE_OP, 6); @@ -1409,8 +1409,8 @@ static int mod_member_list_get(u32_t op, u32_t expect_op, u16_t net_idx, return cli_wait(); } -int bt_mesh_cfg_mod_app_get(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, u8_t *status, u16_t *apps, +int bt_mesh_cfg_mod_app_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint8_t *status, uint16_t *apps, size_t *app_cnt) { return mod_member_list_get(OP_SIG_MOD_APP_GET, OP_SIG_MOD_APP_LIST, @@ -1418,9 +1418,9 @@ int bt_mesh_cfg_mod_app_get(u16_t net_idx, u16_t addr, u16_t elem_addr, status, apps, app_cnt); } -int bt_mesh_cfg_mod_app_get_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, u16_t cid, u8_t *status, - u16_t *apps, size_t *app_cnt) +int bt_mesh_cfg_mod_app_get_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint16_t cid, uint8_t *status, + uint16_t *apps, size_t *app_cnt) { if (cid == CID_NVAL) { return -EINVAL; @@ -1431,8 +1431,8 @@ int bt_mesh_cfg_mod_app_get_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, status, apps, app_cnt); } -static int mod_sub(u32_t op, u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t sub_addr, u16_t mod_id, u16_t cid, u8_t *status) +static int mod_sub(uint32_t op, uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t sub_addr, uint16_t mod_id, uint16_t cid, uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(DUMMY_2_BYTE_OP, 8); struct bt_mesh_msg_ctx ctx = { @@ -1478,16 +1478,16 @@ done: return err; } -int bt_mesh_cfg_mod_sub_add(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t sub_addr, u16_t mod_id, u8_t *status) +int bt_mesh_cfg_mod_sub_add(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t sub_addr, uint16_t mod_id, uint8_t *status) { return mod_sub(OP_MOD_SUB_ADD, net_idx, addr, elem_addr, sub_addr, mod_id, CID_NVAL, status); } -int bt_mesh_cfg_mod_sub_add_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t sub_addr, u16_t mod_id, u16_t cid, - u8_t *status) +int bt_mesh_cfg_mod_sub_add_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t sub_addr, uint16_t mod_id, uint16_t cid, + uint8_t *status) { if (cid == CID_NVAL) { return -EINVAL; @@ -1497,16 +1497,16 @@ int bt_mesh_cfg_mod_sub_add_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, mod_id, cid, status); } -int bt_mesh_cfg_mod_sub_del(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t sub_addr, u16_t mod_id, u8_t *status) +int bt_mesh_cfg_mod_sub_del(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t sub_addr, uint16_t mod_id, uint8_t *status) { return mod_sub(OP_MOD_SUB_DEL, net_idx, addr, elem_addr, sub_addr, mod_id, CID_NVAL, status); } -int bt_mesh_cfg_mod_sub_del_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t sub_addr, u16_t mod_id, u16_t cid, - u8_t *status) +int bt_mesh_cfg_mod_sub_del_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t sub_addr, uint16_t mod_id, uint16_t cid, + uint8_t *status) { if (cid == CID_NVAL) { return -EINVAL; @@ -1516,16 +1516,16 @@ int bt_mesh_cfg_mod_sub_del_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, mod_id, cid, status); } -int bt_mesh_cfg_mod_sub_overwrite(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t sub_addr, u16_t mod_id, u8_t *status) +int bt_mesh_cfg_mod_sub_overwrite(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t sub_addr, uint16_t mod_id, uint8_t *status) { return mod_sub(OP_MOD_SUB_OVERWRITE, net_idx, addr, elem_addr, sub_addr, mod_id, CID_NVAL, status); } -int bt_mesh_cfg_mod_sub_overwrite_vnd(u16_t net_idx, u16_t addr, - u16_t elem_addr, u16_t sub_addr, - u16_t mod_id, u16_t cid, u8_t *status) +int bt_mesh_cfg_mod_sub_overwrite_vnd(uint16_t net_idx, uint16_t addr, + uint16_t elem_addr, uint16_t sub_addr, + uint16_t mod_id, uint16_t cid, uint8_t *status) { if (cid == CID_NVAL) { return -EINVAL; @@ -1535,9 +1535,9 @@ int bt_mesh_cfg_mod_sub_overwrite_vnd(u16_t net_idx, u16_t addr, sub_addr, mod_id, cid, status); } -static int mod_sub_va(u32_t op, u16_t net_idx, u16_t addr, u16_t elem_addr, - const u8_t label[16], u16_t mod_id, u16_t cid, - u16_t *virt_addr, u8_t *status) +static int mod_sub_va(uint32_t op, uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + const uint8_t label[16], uint16_t mod_id, uint16_t cid, + uint16_t *virt_addr, uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(DUMMY_2_BYTE_OP, 22); struct bt_mesh_msg_ctx ctx = { @@ -1592,17 +1592,17 @@ done: return err; } -int bt_mesh_cfg_mod_sub_va_add(u16_t net_idx, u16_t addr, u16_t elem_addr, - const u8_t label[16], u16_t mod_id, - u16_t *virt_addr, u8_t *status) +int bt_mesh_cfg_mod_sub_va_add(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + const uint8_t label[16], uint16_t mod_id, + uint16_t *virt_addr, uint8_t *status) { return mod_sub_va(OP_MOD_SUB_VA_ADD, net_idx, addr, elem_addr, label, mod_id, CID_NVAL, virt_addr, status); } -int bt_mesh_cfg_mod_sub_va_add_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - const u8_t label[16], u16_t mod_id, - u16_t cid, u16_t *virt_addr, u8_t *status) +int bt_mesh_cfg_mod_sub_va_add_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + const uint8_t label[16], uint16_t mod_id, + uint16_t cid, uint16_t *virt_addr, uint8_t *status) { if (cid == CID_NVAL) { return -EINVAL; @@ -1612,17 +1612,17 @@ int bt_mesh_cfg_mod_sub_va_add_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, mod_id, cid, virt_addr, status); } -int bt_mesh_cfg_mod_sub_va_del(u16_t net_idx, u16_t addr, u16_t elem_addr, - const u8_t label[16], u16_t mod_id, - u16_t *virt_addr, u8_t *status) +int bt_mesh_cfg_mod_sub_va_del(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + const uint8_t label[16], uint16_t mod_id, + uint16_t *virt_addr, uint8_t *status) { return mod_sub_va(OP_MOD_SUB_VA_DEL, net_idx, addr, elem_addr, label, mod_id, CID_NVAL, virt_addr, status); } -int bt_mesh_cfg_mod_sub_va_del_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - const u8_t label[16], u16_t mod_id, - u16_t cid, u16_t *virt_addr, u8_t *status) +int bt_mesh_cfg_mod_sub_va_del_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + const uint8_t label[16], uint16_t mod_id, + uint16_t cid, uint16_t *virt_addr, uint8_t *status) { if (cid == CID_NVAL) { return -EINVAL; @@ -1632,19 +1632,19 @@ int bt_mesh_cfg_mod_sub_va_del_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, mod_id, cid, virt_addr, status); } -int bt_mesh_cfg_mod_sub_va_overwrite(u16_t net_idx, u16_t addr, - u16_t elem_addr, const u8_t label[16], - u16_t mod_id, u16_t *virt_addr, - u8_t *status) +int bt_mesh_cfg_mod_sub_va_overwrite(uint16_t net_idx, uint16_t addr, + uint16_t elem_addr, const uint8_t label[16], + uint16_t mod_id, uint16_t *virt_addr, + uint8_t *status) { return mod_sub_va(OP_MOD_SUB_VA_OVERWRITE, net_idx, addr, elem_addr, label, mod_id, CID_NVAL, virt_addr, status); } -int bt_mesh_cfg_mod_sub_va_overwrite_vnd(u16_t net_idx, u16_t addr, - u16_t elem_addr, const u8_t label[16], - u16_t mod_id, u16_t cid, - u16_t *virt_addr, u8_t *status) +int bt_mesh_cfg_mod_sub_va_overwrite_vnd(uint16_t net_idx, uint16_t addr, + uint16_t elem_addr, const uint8_t label[16], + uint16_t mod_id, uint16_t cid, + uint16_t *virt_addr, uint8_t *status) { if (cid == CID_NVAL) { return -EINVAL; @@ -1654,8 +1654,8 @@ int bt_mesh_cfg_mod_sub_va_overwrite_vnd(u16_t net_idx, u16_t addr, label, mod_id, cid, virt_addr, status); } -int bt_mesh_cfg_mod_sub_get(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, u8_t *status, u16_t *subs, +int bt_mesh_cfg_mod_sub_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint8_t *status, uint16_t *subs, size_t *sub_cnt) { return mod_member_list_get(OP_MOD_SUB_GET, OP_MOD_SUB_LIST, net_idx, @@ -1663,9 +1663,9 @@ int bt_mesh_cfg_mod_sub_get(u16_t net_idx, u16_t addr, u16_t elem_addr, subs, sub_cnt); } -int bt_mesh_cfg_mod_sub_get_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, u16_t cid, u8_t *status, - u16_t *subs, size_t *sub_cnt) +int bt_mesh_cfg_mod_sub_get_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint16_t cid, uint8_t *status, + uint16_t *subs, size_t *sub_cnt) { if (cid == CID_NVAL) { return -EINVAL; @@ -1676,9 +1676,9 @@ int bt_mesh_cfg_mod_sub_get_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, status, subs, sub_cnt); } -static int mod_pub_get(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, u16_t cid, - struct bt_mesh_cfg_mod_pub *pub, u8_t *status) +static int mod_pub_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint16_t cid, + struct bt_mesh_cfg_mod_pub *pub, uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_MOD_PUB_GET, 6); struct bt_mesh_msg_ctx ctx = { @@ -1729,17 +1729,17 @@ done: return err; } -int bt_mesh_cfg_mod_pub_get(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, struct bt_mesh_cfg_mod_pub *pub, - u8_t *status) +int bt_mesh_cfg_mod_pub_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, struct bt_mesh_cfg_mod_pub *pub, + uint8_t *status) { return mod_pub_get(net_idx, addr, elem_addr, mod_id, CID_NVAL, pub, status); } -int bt_mesh_cfg_mod_pub_get_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, u16_t cid, - struct bt_mesh_cfg_mod_pub *pub, u8_t *status) +int bt_mesh_cfg_mod_pub_get_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint16_t cid, + struct bt_mesh_cfg_mod_pub *pub, uint8_t *status) { if (cid == CID_NVAL) { return -EINVAL; @@ -1748,9 +1748,9 @@ int bt_mesh_cfg_mod_pub_get_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, return mod_pub_get(net_idx, addr, elem_addr, mod_id, cid, pub, status); } -static int mod_pub_set(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, u16_t cid, - struct bt_mesh_cfg_mod_pub *pub, u8_t *status) +static int mod_pub_set(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint16_t cid, + struct bt_mesh_cfg_mod_pub *pub, uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_MOD_PUB_SET, 13); struct bt_mesh_msg_ctx ctx = { @@ -1806,17 +1806,17 @@ done: return err; } -int bt_mesh_cfg_mod_pub_set(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, struct bt_mesh_cfg_mod_pub *pub, - u8_t *status) +int bt_mesh_cfg_mod_pub_set(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, struct bt_mesh_cfg_mod_pub *pub, + uint8_t *status) { return mod_pub_set(net_idx, addr, elem_addr, mod_id, CID_NVAL, pub, status); } -int bt_mesh_cfg_mod_pub_set_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, - u16_t mod_id, u16_t cid, - struct bt_mesh_cfg_mod_pub *pub, u8_t *status) +int bt_mesh_cfg_mod_pub_set_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, + uint16_t mod_id, uint16_t cid, + struct bt_mesh_cfg_mod_pub *pub, uint8_t *status) { if (cid == CID_NVAL) { return -EINVAL; @@ -1825,8 +1825,8 @@ int bt_mesh_cfg_mod_pub_set_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, return mod_pub_set(net_idx, addr, elem_addr, mod_id, cid, pub, status); } -int bt_mesh_cfg_hb_sub_set(u16_t net_idx, u16_t addr, - struct bt_mesh_cfg_hb_sub *sub, u8_t *status) +int bt_mesh_cfg_hb_sub_set(uint16_t net_idx, uint16_t addr, + struct bt_mesh_cfg_hb_sub *sub, uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_HEARTBEAT_SUB_SET, 5); struct bt_mesh_msg_ctx ctx = { @@ -1869,8 +1869,8 @@ done: return err; } -int bt_mesh_cfg_hb_sub_get(u16_t net_idx, u16_t addr, - struct bt_mesh_cfg_hb_sub *sub, u8_t *status) +int bt_mesh_cfg_hb_sub_get(uint16_t net_idx, uint16_t addr, + struct bt_mesh_cfg_hb_sub *sub, uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_HEARTBEAT_SUB_GET, 0); struct bt_mesh_msg_ctx ctx = { @@ -1910,8 +1910,8 @@ done: return err; } -int bt_mesh_cfg_hb_pub_set(u16_t net_idx, u16_t addr, - const struct bt_mesh_cfg_hb_pub *pub, u8_t *status) +int bt_mesh_cfg_hb_pub_set(uint16_t net_idx, uint16_t addr, + const struct bt_mesh_cfg_hb_pub *pub, uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_HEARTBEAT_PUB_SET, 9); struct bt_mesh_msg_ctx ctx = { @@ -1956,8 +1956,8 @@ done: return err; } -int bt_mesh_cfg_hb_pub_get(u16_t net_idx, u16_t addr, - struct bt_mesh_cfg_hb_pub *pub, u8_t *status) +int bt_mesh_cfg_hb_pub_get(uint16_t net_idx, uint16_t addr, + struct bt_mesh_cfg_hb_pub *pub, uint8_t *status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_HEARTBEAT_PUB_GET, 0); struct bt_mesh_msg_ctx ctx = { @@ -1997,12 +1997,12 @@ done: return err; } -s32_t bt_mesh_cfg_cli_timeout_get(void) +int32_t bt_mesh_cfg_cli_timeout_get(void) { return msg_timeout; } -void bt_mesh_cfg_cli_timeout_set(s32_t timeout) +void bt_mesh_cfg_cli_timeout_set(int32_t timeout) { msg_timeout = timeout; } diff --git a/nimble/host/mesh/src/cfg_srv.c b/nimble/host/mesh/src/cfg_srv.c index 74b4741d6..9b1433e86 100644 --- a/nimble/host/mesh/src/cfg_srv.c +++ b/nimble/host/mesh/src/cfg_srv.c @@ -73,7 +73,7 @@ static int comp_add_elem(struct os_mbuf *buf, struct bt_mesh_elem *elem, static int comp_get_page_0(struct os_mbuf *buf) { - u16_t feat = 0; + uint16_t feat = 0; const struct bt_mesh_comp *comp; int i; @@ -118,7 +118,7 @@ static void dev_comp_data_get(struct bt_mesh_model *model, struct os_mbuf *buf) { struct os_mbuf *sdu = NET_BUF_SIMPLE(BT_MESH_TX_SDU_MAX); - u8_t page; + uint8_t page; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, @@ -150,7 +150,7 @@ static struct bt_mesh_model *get_model(struct bt_mesh_elem *elem, struct os_mbuf *buf, bool *vnd) { if (buf->om_len < 4) { - u16_t id; + uint16_t id; id = net_buf_simple_pull_le16(buf); @@ -160,7 +160,7 @@ static struct bt_mesh_model *get_model(struct bt_mesh_elem *elem, return bt_mesh_model_find(elem, id); } else { - u16_t company, id; + uint16_t company, id; company = net_buf_simple_pull_le16(buf); id = net_buf_simple_pull_le16(buf); @@ -174,7 +174,7 @@ static struct bt_mesh_model *get_model(struct bt_mesh_elem *elem, } } -static bool app_key_is_valid(u16_t app_idx) +static bool app_key_is_valid(uint16_t app_idx) { int i; @@ -190,9 +190,9 @@ static bool app_key_is_valid(u16_t app_idx) return false; } -static u8_t _mod_pub_set(struct bt_mesh_model *model, u16_t pub_addr, - u16_t app_idx, u8_t cred_flag, u8_t ttl, u8_t period, - u8_t retransmit, bool store) +static uint8_t _mod_pub_set(struct bt_mesh_model *model, uint16_t pub_addr, + uint16_t app_idx, uint8_t cred_flag, uint8_t ttl, uint8_t period, + uint8_t retransmit, bool store) { if (!model->pub) { return STATUS_NVAL_PUB_PARAM; @@ -252,7 +252,7 @@ static u8_t _mod_pub_set(struct bt_mesh_model *model, u16_t pub_addr, model->pub->retransmit = retransmit; if (model->pub->update) { - s32_t period_ms; + int32_t period_ms; period_ms = bt_mesh_model_pub_period_get(model); BT_DBG("period %u ms", (unsigned) period_ms); @@ -271,7 +271,7 @@ static u8_t _mod_pub_set(struct bt_mesh_model *model, u16_t pub_addr, return STATUS_SUCCESS; } -u8_t mod_bind(struct bt_mesh_model *model, u16_t key_idx) +uint8_t mod_bind(struct bt_mesh_model *model, uint16_t key_idx) { int i; @@ -303,7 +303,7 @@ u8_t mod_bind(struct bt_mesh_model *model, u16_t key_idx) return STATUS_INSUFF_RESOURCES; } -u8_t mod_unbind(struct bt_mesh_model *model, u16_t key_idx, bool store) +uint8_t mod_unbind(struct bt_mesh_model *model, uint16_t key_idx, bool store) { int i; @@ -333,7 +333,7 @@ u8_t mod_unbind(struct bt_mesh_model *model, u16_t key_idx, bool store) return STATUS_SUCCESS; } -struct bt_mesh_app_key *bt_mesh_app_key_alloc(u16_t app_idx) +struct bt_mesh_app_key *bt_mesh_app_key_alloc(uint16_t app_idx) { int i; @@ -348,7 +348,7 @@ struct bt_mesh_app_key *bt_mesh_app_key_alloc(u16_t app_idx) return NULL; } -static u8_t app_key_set(u16_t net_idx, u16_t app_idx, const u8_t val[16], +static uint8_t app_key_set(uint16_t net_idx, uint16_t app_idx, const uint8_t val[16], bool update) { struct bt_mesh_app_keys *keys; @@ -442,8 +442,8 @@ static void app_key_add(struct bt_mesh_model *model, struct os_mbuf *buf) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_APP_KEY_STATUS, 4); - u16_t key_net_idx, key_app_idx; - u8_t status; + uint16_t key_net_idx, key_app_idx; + uint8_t status; key_idx_unpack(buf, &key_net_idx, &key_app_idx); @@ -469,8 +469,8 @@ static void app_key_update(struct bt_mesh_model *model, struct os_mbuf *buf) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_APP_KEY_STATUS, 4); - u16_t key_net_idx, key_app_idx; - u8_t status; + uint16_t key_net_idx, key_app_idx; + uint8_t status; key_idx_unpack(buf, &key_net_idx, &key_app_idx); @@ -492,7 +492,7 @@ static void app_key_update(struct bt_mesh_model *model, } struct unbind_data { - u16_t app_idx; + uint16_t app_idx; bool store; }; @@ -525,9 +525,9 @@ static void app_key_del(struct bt_mesh_model *model, struct os_mbuf *buf) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_APP_KEY_STATUS, 4); - u16_t key_net_idx, key_app_idx; + uint16_t key_net_idx, key_app_idx; struct bt_mesh_app_key *key; - u8_t status; + uint8_t status; key_idx_unpack(buf, &key_net_idx, &key_app_idx); @@ -579,8 +579,8 @@ static void app_key_get(struct bt_mesh_model *model, struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_APP_KEY_LIST, 3 + IDX_LEN(CONFIG_BT_MESH_APP_KEY_COUNT)); - u16_t get_idx, i, prev; - u8_t status; + uint16_t get_idx, i, prev; + uint8_t status; get_idx = net_buf_simple_pull_le16(buf); if (get_idx > 0xfff) { @@ -955,9 +955,9 @@ done: static void send_mod_pub_status(struct bt_mesh_model *cfg_mod, struct bt_mesh_msg_ctx *ctx, - u16_t elem_addr, u16_t pub_addr, + uint16_t elem_addr, uint16_t pub_addr, bool vnd, struct bt_mesh_model *mod, - u8_t status, u8_t *mod_id) + uint8_t status, uint8_t *mod_id) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_MOD_PUB_STATUS, 14); @@ -969,11 +969,11 @@ static void send_mod_pub_status(struct bt_mesh_model *cfg_mod, if (status != STATUS_SUCCESS) { memset(net_buf_simple_add(msg, 7), 0, 7); } else { - u16_t idx_cred; + uint16_t idx_cred; net_buf_simple_add_le16(msg, pub_addr); - idx_cred = mod->pub->key | (u16_t)mod->pub->cred << 12; + idx_cred = mod->pub->key | (uint16_t)mod->pub->cred << 12; net_buf_simple_add_le16(msg, idx_cred); net_buf_simple_add_u8(msg, mod->pub->ttl); net_buf_simple_add_u8(msg, mod->pub->period); @@ -997,10 +997,10 @@ static void mod_pub_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u16_t elem_addr, pub_addr = 0; + uint16_t elem_addr, pub_addr = 0; struct bt_mesh_model *mod; struct bt_mesh_elem *elem; - u8_t *mod_id, status; + uint8_t *mod_id, status; bool vnd; elem_addr = net_buf_simple_pull_le16(buf); @@ -1044,11 +1044,11 @@ static void mod_pub_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t retransmit, status, pub_ttl, pub_period, cred_flag; - u16_t elem_addr, pub_addr, pub_app_idx; + uint8_t retransmit, status, pub_ttl, pub_period, cred_flag; + uint16_t elem_addr, pub_addr, pub_app_idx; struct bt_mesh_model *mod; struct bt_mesh_elem *elem; - u8_t *mod_id; + uint8_t *mod_id; bool vnd; elem_addr = net_buf_simple_pull_le16(buf); @@ -1102,7 +1102,7 @@ send_status: status, mod_id); } -struct label *get_label(u16_t index) +struct label *get_label(uint16_t index) { if (index >= ARRAY_SIZE(labels)) { return NULL; @@ -1120,7 +1120,7 @@ static inline void va_store(struct label *store) } } -static struct label *va_find(const u8_t *label_uuid, +static struct label *va_find(const uint8_t *label_uuid, struct label **free_slot) { struct label *match = NULL; @@ -1146,7 +1146,7 @@ static struct label *va_find(const u8_t *label_uuid, return match; } -static u8_t va_add(u8_t *label_uuid, u16_t *addr) +static uint8_t va_add(uint8_t *label_uuid, uint16_t *addr) { struct label *update, *free_slot = NULL; @@ -1173,7 +1173,7 @@ static u8_t va_add(u8_t *label_uuid, u16_t *addr) return STATUS_SUCCESS; } -static u8_t va_del(u8_t *label_uuid, u16_t *addr) +static uint8_t va_del(uint8_t *label_uuid, uint16_t *addr) { struct label *update; @@ -1198,7 +1198,7 @@ static u8_t va_del(u8_t *label_uuid, u16_t *addr) static size_t mod_sub_list_clear(struct bt_mesh_model *mod) { - u8_t *label_uuid; + uint8_t *label_uuid; size_t clear_count; int i; @@ -1232,12 +1232,12 @@ static void mod_pub_va_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t retransmit, status, pub_ttl, pub_period, cred_flag; - u16_t elem_addr, pub_addr, pub_app_idx; + uint8_t retransmit, status, pub_ttl, pub_period, cred_flag; + uint16_t elem_addr, pub_addr, pub_app_idx; struct bt_mesh_model *mod; struct bt_mesh_elem *elem; - u8_t *label_uuid; - u8_t *mod_id; + uint8_t *label_uuid; + uint8_t *mod_id; bool vnd; elem_addr = net_buf_simple_pull_le16(buf); @@ -1322,10 +1322,10 @@ static void mod_pub_va_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t *mod_id, status; + uint8_t *mod_id, status; struct bt_mesh_model *mod; struct bt_mesh_elem *elem; - u16_t elem_addr, pub_addr = 0; + uint16_t elem_addr, pub_addr = 0; bool vnd; elem_addr = net_buf_simple_pull_le16(buf); @@ -1368,8 +1368,8 @@ send_status: #endif /* MYNEWT_VAL(BLE_MESH_LABEL_COUNT) > 0 */ static void send_mod_sub_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, u8_t status, - u16_t elem_addr, u16_t sub_addr, u8_t *mod_id, + struct bt_mesh_msg_ctx *ctx, uint8_t status, + uint16_t elem_addr, uint16_t sub_addr, uint8_t *mod_id, bool vnd) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_MOD_SUB_STATUS, 9); @@ -1400,12 +1400,12 @@ static void mod_sub_add(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u16_t elem_addr, sub_addr; + uint16_t elem_addr, sub_addr; struct bt_mesh_model *mod; struct bt_mesh_elem *elem; - u8_t *mod_id; - u8_t status; - u16_t *entry; + uint8_t *mod_id; + uint8_t status; + uint16_t *entry; bool vnd; elem_addr = net_buf_simple_pull_le16(buf); @@ -1473,12 +1473,12 @@ static void mod_sub_del(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u16_t elem_addr, sub_addr; + uint16_t elem_addr, sub_addr; struct bt_mesh_model *mod; struct bt_mesh_elem *elem; - u8_t *mod_id; - u16_t *match; - u8_t status; + uint8_t *mod_id; + uint16_t *match; + uint8_t status; bool vnd; elem_addr = net_buf_simple_pull_le16(buf); @@ -1536,7 +1536,7 @@ send_status: } static enum bt_mesh_walk mod_sub_clear_visitor(struct bt_mesh_model *mod, - u32_t depth, void *user_data) + uint32_t depth, void *user_data) { if (IS_ENABLED(CONFIG_BT_MESH_LOW_POWER)) { bt_mesh_lpn_group_del(mod->groups, ARRAY_SIZE(mod->groups)); @@ -1551,11 +1551,11 @@ static void mod_sub_overwrite(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u16_t elem_addr, sub_addr; + uint16_t elem_addr, sub_addr; struct bt_mesh_model *mod; struct bt_mesh_elem *elem; - u8_t *mod_id; - u8_t status; + uint8_t *mod_id; + uint8_t status; bool vnd; elem_addr = net_buf_simple_pull_le16(buf); @@ -1619,9 +1619,9 @@ static void mod_sub_del_all(struct bt_mesh_model *model, { struct bt_mesh_model *mod; struct bt_mesh_elem *elem; - u16_t elem_addr; - u8_t *mod_id; - u8_t status; + uint16_t elem_addr; + uint8_t *mod_id; + uint8_t status; bool vnd; elem_addr = net_buf_simple_pull_le16(buf); @@ -1663,12 +1663,12 @@ send_status: } struct mod_sub_list_ctx { - u16_t elem_idx; + uint16_t elem_idx; struct os_mbuf *msg; }; static enum bt_mesh_walk mod_sub_list_visitor(struct bt_mesh_model *mod, - u32_t depth, void *ctx) + uint32_t depth, void *ctx) { struct mod_sub_list_ctx *visit = ctx; int count = 0; @@ -1707,7 +1707,7 @@ static void mod_sub_get(struct bt_mesh_model *model, struct mod_sub_list_ctx visit_ctx; struct bt_mesh_model *mod; struct bt_mesh_elem *elem; - u16_t addr, id; + uint16_t addr, id; addr = net_buf_simple_pull_le16(buf); if (!BT_MESH_ADDR_IS_UNICAST(addr)) { @@ -1765,7 +1765,7 @@ static void mod_sub_get_vnd(struct bt_mesh_model *model, struct mod_sub_list_ctx visit_ctx; struct bt_mesh_model *mod; struct bt_mesh_elem *elem; - u16_t company, addr, id; + uint16_t company, addr, id; addr = net_buf_simple_pull_le16(buf); if (!BT_MESH_ADDR_IS_UNICAST(addr)) { @@ -1824,13 +1824,13 @@ static void mod_sub_va_add(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u16_t elem_addr, sub_addr; + uint16_t elem_addr, sub_addr; struct bt_mesh_model *mod; struct bt_mesh_elem *elem; - u8_t *label_uuid; - u8_t *mod_id; - u16_t *entry; - u8_t status; + uint8_t *label_uuid; + uint8_t *mod_id; + uint16_t *entry; + uint8_t status; bool vnd; elem_addr = net_buf_simple_pull_le16(buf); @@ -1901,13 +1901,13 @@ static void mod_sub_va_del(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u16_t elem_addr, sub_addr; + uint16_t elem_addr, sub_addr; struct bt_mesh_model *mod; struct bt_mesh_elem *elem; - u8_t *label_uuid; - u8_t *mod_id; - u16_t *match; - u8_t status; + uint8_t *label_uuid; + uint8_t *mod_id; + uint16_t *match; + uint8_t status; bool vnd; elem_addr = net_buf_simple_pull_le16(buf); @@ -1969,12 +1969,12 @@ static void mod_sub_va_overwrite(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u16_t elem_addr, sub_addr = BT_MESH_ADDR_UNASSIGNED; + uint16_t elem_addr, sub_addr = BT_MESH_ADDR_UNASSIGNED; struct bt_mesh_model *mod; struct bt_mesh_elem *elem; - u8_t *label_uuid; - u8_t *mod_id; - u8_t status; + uint8_t *label_uuid; + uint8_t *mod_id; + uint8_t status; bool vnd; elem_addr = net_buf_simple_pull_le16(buf); @@ -2033,9 +2033,9 @@ static void mod_sub_va_add(struct bt_mesh_model *model, { struct bt_mesh_model *mod; struct bt_mesh_elem *elem; - u16_t elem_addr; - u8_t *mod_id; - u8_t status; + uint16_t elem_addr; + uint8_t *mod_id; + uint8_t status; bool vnd; elem_addr = net_buf_simple_pull_le16(buf); @@ -2074,9 +2074,9 @@ static void mod_sub_va_del(struct bt_mesh_model *model, struct os_mbuf *buf) { struct bt_mesh_elem *elem; - u16_t elem_addr; - u8_t *mod_id; - u8_t status; + uint16_t elem_addr; + uint8_t *mod_id; + uint8_t status; bool vnd; elem_addr = net_buf_simple_pull_le16(buf); @@ -2113,9 +2113,9 @@ static void mod_sub_va_overwrite(struct bt_mesh_model *model, struct os_mbuf *buf) { struct bt_mesh_elem *elem; - u16_t elem_addr; - u8_t *mod_id; - u8_t status; + uint16_t elem_addr; + uint8_t *mod_id; + uint8_t status; bool vnd; elem_addr = net_buf_simple_pull_le16(buf); @@ -2150,7 +2150,7 @@ send_status: static void send_net_key_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - u16_t idx, u8_t status) + uint16_t idx, uint8_t status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_NET_KEY_STATUS, 3); @@ -2171,7 +2171,7 @@ static void net_key_add(struct bt_mesh_model *model, struct os_mbuf *buf) { struct bt_mesh_subnet *sub; - u16_t idx; + uint16_t idx; int err; idx = net_buf_simple_pull_le16(buf); @@ -2202,7 +2202,7 @@ static void net_key_add(struct bt_mesh_model *model, /* Check for already existing subnet */ if (sub->net_idx == idx) { - u8_t status; + uint8_t status; if (memcmp(buf->om_data, sub->keys[0].net, 16)) { status = STATUS_IDX_ALREADY_STORED; @@ -2246,7 +2246,7 @@ static void net_key_update(struct bt_mesh_model *model, struct os_mbuf *buf) { struct bt_mesh_subnet *sub; - u16_t idx; + uint16_t idx; int err; idx = net_buf_simple_pull_le16(buf); @@ -2327,8 +2327,8 @@ static void net_key_del(struct bt_mesh_model *model, struct os_mbuf *buf) { struct bt_mesh_subnet *sub; - u16_t del_idx; - u8_t status; + uint16_t del_idx; + uint8_t status; del_idx = net_buf_simple_pull_le16(buf); if (del_idx > 0xfff) { @@ -2369,7 +2369,7 @@ static void net_key_get(struct bt_mesh_model *model, struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_NET_KEY_LIST, IDX_LEN(CONFIG_BT_MESH_SUBNET_COUNT)); - u16_t prev, i; + uint16_t prev, i; bt_mesh_model_msg_init(msg, OP_NET_KEY_LIST); @@ -2407,8 +2407,8 @@ static void node_identity_get(struct bt_mesh_model *model, { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_NODE_IDENTITY_STATUS, 4); struct bt_mesh_subnet *sub; - u8_t node_id; - u16_t idx; + uint8_t node_id; + uint16_t idx; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, @@ -2448,8 +2448,8 @@ static void node_identity_set(struct bt_mesh_model *model, { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_NODE_IDENTITY_STATUS, 4); struct bt_mesh_subnet *sub; - u8_t node_id; - u16_t idx; + uint8_t node_id; + uint16_t idx; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, @@ -2501,8 +2501,8 @@ done: static void create_mod_app_status(struct os_mbuf *msg, struct bt_mesh_model *mod, bool vnd, - u16_t elem_addr, u16_t app_idx, - u8_t status, u8_t *mod_id) + uint16_t elem_addr, uint16_t app_idx, + uint8_t status, uint8_t *mod_id) { bt_mesh_model_msg_init(msg, OP_MOD_APP_STATUS); @@ -2522,10 +2522,10 @@ static void mod_app_bind(struct bt_mesh_model *model, struct os_mbuf *buf) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_MOD_APP_STATUS, 9); - u16_t elem_addr, key_app_idx; + uint16_t elem_addr, key_app_idx; struct bt_mesh_model *mod; struct bt_mesh_elem *elem; - u8_t *mod_id, status; + uint8_t *mod_id, status; bool vnd; elem_addr = net_buf_simple_pull_le16(buf); @@ -2583,10 +2583,10 @@ static void mod_app_unbind(struct bt_mesh_model *model, struct os_mbuf *buf) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_MOD_APP_STATUS, 9); - u16_t elem_addr, key_app_idx; + uint16_t elem_addr, key_app_idx; struct bt_mesh_model *mod; struct bt_mesh_elem *elem; - u8_t *mod_id, status; + uint8_t *mod_id, status; bool vnd; elem_addr = net_buf_simple_pull_le16(buf); @@ -2644,8 +2644,8 @@ static void mod_app_get(struct bt_mesh_model *model, struct bt_mesh_model *mod; struct bt_mesh_elem *elem; - u8_t *mod_id, status; - u16_t elem_addr; + uint8_t *mod_id, status; + uint16_t elem_addr; bool vnd; elem_addr = net_buf_simple_pull_le16(buf); @@ -2805,8 +2805,8 @@ static void lpn_timeout_get(struct bt_mesh_model *model, { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_LPN_TIMEOUT_STATUS, 5); struct bt_mesh_friend *frnd; - u16_t lpn_addr; - s32_t timeout; + uint16_t lpn_addr; + int32_t timeout; lpn_addr = net_buf_simple_pull_le16(buf); @@ -2848,7 +2848,7 @@ done: static void send_krp_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - u16_t idx, u8_t phase, u8_t status) + uint16_t idx, uint8_t phase, uint8_t status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_KRP_STATUS, 4); @@ -2869,7 +2869,7 @@ static void krp_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { struct bt_mesh_subnet *sub; - u16_t idx; + uint16_t idx; idx = net_buf_simple_pull_le16(buf); if (idx > 0xfff) { @@ -2892,8 +2892,8 @@ static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { struct bt_mesh_subnet *sub; - u8_t phase; - u16_t idx; + uint8_t phase; + uint16_t idx; idx = net_buf_simple_pull_le16(buf); phase = net_buf_simple_pull_u8(buf); @@ -2946,7 +2946,7 @@ static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, send_krp_status(model, ctx, idx, sub->kr_phase, STATUS_SUCCESS); } -static u8_t hb_log(u16_t val) +static uint8_t hb_log(uint16_t val) { if (!val) { return 0x00; @@ -2957,7 +2957,7 @@ static u8_t hb_log(u16_t val) } } -static u8_t hb_pub_count_log(u16_t val) +static uint8_t hb_pub_count_log(uint16_t val) { if (!val) { return 0x00; @@ -2970,7 +2970,7 @@ static u8_t hb_pub_count_log(u16_t val) } } -static u16_t hb_pwr2(u8_t val, u8_t sub) +static uint16_t hb_pwr2(uint8_t val, uint8_t sub) { if (!val) { return 0x0000; @@ -2982,16 +2982,16 @@ static u16_t hb_pwr2(u8_t val, u8_t sub) } struct hb_pub_param { - u16_t dst; - u8_t count_log; - u8_t period_log; - u8_t ttl; - u16_t feat; - u16_t net_idx; + uint16_t dst; + uint8_t count_log; + uint8_t period_log; + uint8_t ttl; + uint16_t feat; + uint16_t net_idx; } __packed; static void hb_pub_send_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, u8_t status, + struct bt_mesh_msg_ctx *ctx, uint8_t status, struct hb_pub_param *orig_msg) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_HEARTBEAT_PUB_STATUS, 10); @@ -3039,8 +3039,8 @@ static void heartbeat_pub_set(struct bt_mesh_model *model, { struct hb_pub_param *param = (void *)buf->om_data; struct bt_mesh_cfg_srv *cfg = model->user_data; - u16_t dst, feat, idx; - u8_t status; + uint16_t dst, feat, idx; + uint8_t status; BT_DBG("src 0x%04x", ctx->addr); @@ -3117,12 +3117,12 @@ failed: } static void hb_sub_send_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, u8_t status) + struct bt_mesh_msg_ctx *ctx, uint8_t status) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_HEARTBEAT_SUB_STATUS, 9); struct bt_mesh_cfg_srv *cfg = model->user_data; - u16_t period; - s64_t uptime; + uint16_t period; + int64_t uptime; BT_DBG("src 0x%04x status 0x%02x", ctx->addr, status); @@ -3167,9 +3167,9 @@ static void heartbeat_sub_set(struct bt_mesh_model *model, struct os_mbuf *buf) { struct bt_mesh_cfg_srv *cfg = model->user_data; - u16_t sub_src, sub_dst; - u8_t sub_period; - s32_t period_ms; + uint16_t sub_src, sub_dst; + uint8_t sub_period; + int32_t period_ms; BT_DBG("src 0x%04x", ctx->addr); @@ -3484,7 +3484,7 @@ void bt_mesh_cfg_reset(void) memset(labels, 0, sizeof(labels)); } -void bt_mesh_heartbeat(u16_t src, u16_t dst, u8_t hops, u16_t feat) +void bt_mesh_heartbeat(uint16_t src, uint16_t dst, uint8_t hops, uint16_t feat) { struct bt_mesh_cfg_srv *cfg = conf; @@ -3514,7 +3514,7 @@ void bt_mesh_heartbeat(u16_t src, u16_t dst, u8_t hops, u16_t feat) } } -u8_t bt_mesh_net_transmit_get(void) +uint8_t bt_mesh_net_transmit_get(void) { if (conf) { return conf->net_transmit; @@ -3523,7 +3523,7 @@ u8_t bt_mesh_net_transmit_get(void) return 0; } -u8_t bt_mesh_relay_get(void) +uint8_t bt_mesh_relay_get(void) { if (conf) { return conf->relay; @@ -3532,7 +3532,7 @@ u8_t bt_mesh_relay_get(void) return BT_MESH_RELAY_NOT_SUPPORTED; } -u8_t bt_mesh_friend_get(void) +uint8_t bt_mesh_friend_get(void) { if (conf) { BT_DBG("conf %p conf->frnd 0x%02x", conf, conf->frnd); @@ -3542,7 +3542,7 @@ u8_t bt_mesh_friend_get(void) return BT_MESH_FRIEND_NOT_SUPPORTED; } -u8_t bt_mesh_relay_retransmit_get(void) +uint8_t bt_mesh_relay_retransmit_get(void) { if (conf) { return conf->relay_retransmit; @@ -3551,7 +3551,7 @@ u8_t bt_mesh_relay_retransmit_get(void) return 0; } -u8_t bt_mesh_beacon_get(void) +uint8_t bt_mesh_beacon_get(void) { if (conf) { return conf->beacon; @@ -3560,7 +3560,7 @@ u8_t bt_mesh_beacon_get(void) return BT_MESH_BEACON_DISABLED; } -u8_t bt_mesh_gatt_proxy_get(void) +uint8_t bt_mesh_gatt_proxy_get(void) { if (conf) { return conf->gatt_proxy; @@ -3569,7 +3569,7 @@ u8_t bt_mesh_gatt_proxy_get(void) return BT_MESH_GATT_PROXY_NOT_SUPPORTED; } -u8_t bt_mesh_default_ttl_get(void) +uint8_t bt_mesh_default_ttl_get(void) { if (conf) { return conf->default_ttl; @@ -3578,7 +3578,7 @@ u8_t bt_mesh_default_ttl_get(void) return DEFAULT_TTL; } -u8_t *bt_mesh_label_uuid_get(u16_t addr) +uint8_t *bt_mesh_label_uuid_get(uint16_t addr) { int i; diff --git a/nimble/host/mesh/src/crypto.c b/nimble/host/mesh/src/crypto.c index aef4757b8..c9bf41ecc 100644 --- a/nimble/host/mesh/src/crypto.c +++ b/nimble/host/mesh/src/crypto.c @@ -24,8 +24,8 @@ #define NET_MIC_LEN(pdu) (((pdu)[1] & 0x80) ? 8 : 4) #define APP_MIC_LEN(aszmic) ((aszmic) ? 8 : 4) -int bt_mesh_aes_cmac(const u8_t key[16], struct bt_mesh_sg *sg, - size_t sg_len, u8_t mac[16]) +int bt_mesh_aes_cmac(const uint8_t key[16], struct bt_mesh_sg *sg, + size_t sg_len, uint8_t mac[16]) { struct tc_aes_key_sched_struct sched; struct tc_cmac_struct state; @@ -48,8 +48,8 @@ int bt_mesh_aes_cmac(const u8_t key[16], struct bt_mesh_sg *sg, return 0; } -int bt_mesh_k1(const u8_t *ikm, size_t ikm_len, const u8_t salt[16], - const char *info, u8_t okm[16]) +int bt_mesh_k1(const uint8_t *ikm, size_t ikm_len, const uint8_t salt[16], + const char *info, uint8_t okm[16]) { int err; @@ -61,14 +61,14 @@ int bt_mesh_k1(const u8_t *ikm, size_t ikm_len, const u8_t salt[16], return bt_mesh_aes_cmac_one(okm, info, strlen(info), okm); } -int bt_mesh_k2(const u8_t n[16], const u8_t *p, size_t p_len, - u8_t net_id[1], u8_t enc_key[16], u8_t priv_key[16]) +int bt_mesh_k2(const uint8_t n[16], const uint8_t *p, size_t p_len, + uint8_t net_id[1], uint8_t enc_key[16], uint8_t priv_key[16]) { struct bt_mesh_sg sg[3]; - u8_t salt[16]; - u8_t out[16]; - u8_t t[16]; - u8_t pad; + uint8_t salt[16]; + uint8_t out[16]; + uint8_t t[16]; + uint8_t pad; int err; BT_DBG("n %s", bt_hex(n, 16)); @@ -126,11 +126,11 @@ int bt_mesh_k2(const u8_t n[16], const u8_t *p, size_t p_len, return 0; } -int bt_mesh_k3(const u8_t n[16], u8_t out[8]) +int bt_mesh_k3(const uint8_t n[16], uint8_t out[8]) { - u8_t id64[] = { 'i', 'd', '6', '4', 0x01 }; - u8_t tmp[16]; - u8_t t[16]; + uint8_t id64[] = { 'i', 'd', '6', '4', 0x01 }; + uint8_t tmp[16]; + uint8_t t[16]; int err; err = bt_mesh_s1("smk3", tmp); @@ -153,11 +153,11 @@ int bt_mesh_k3(const u8_t n[16], u8_t out[8]) return 0; } -int bt_mesh_k4(const u8_t n[16], u8_t out[1]) +int bt_mesh_k4(const uint8_t n[16], uint8_t out[1]) { - u8_t id6[] = { 'i', 'd', '6', 0x01 }; - u8_t tmp[16]; - u8_t t[16]; + uint8_t id6[] = { 'i', 'd', '6', 0x01 }; + uint8_t tmp[16]; + uint8_t t[16]; int err; err = bt_mesh_s1("smk4", tmp); @@ -180,10 +180,10 @@ int bt_mesh_k4(const u8_t n[16], u8_t out[1]) return 0; } -int bt_mesh_id128(const u8_t n[16], const char *s, u8_t out[16]) +int bt_mesh_id128(const uint8_t n[16], const char *s, uint8_t out[16]) { const char *id128 = "id128\x01"; - u8_t salt[16]; + uint8_t salt[16]; int err; err = bt_mesh_s1(s, salt); @@ -194,8 +194,8 @@ int bt_mesh_id128(const u8_t n[16], const char *s, u8_t out[16]) return bt_mesh_k1(n, 16, salt, id128, out); } -static void create_proxy_nonce(u8_t nonce[13], const u8_t *pdu, - u32_t iv_index) +static void create_proxy_nonce(uint8_t nonce[13], const uint8_t *pdu, + uint32_t iv_index) { /* Nonce Type */ nonce[0] = 0x03; @@ -220,8 +220,8 @@ static void create_proxy_nonce(u8_t nonce[13], const u8_t *pdu, sys_put_be32(iv_index, &nonce[9]); } -static void create_net_nonce(u8_t nonce[13], const u8_t *pdu, - u32_t iv_index) +static void create_net_nonce(uint8_t nonce[13], const uint8_t *pdu, + uint32_t iv_index) { /* Nonce Type */ nonce[0] = 0x00; @@ -246,11 +246,11 @@ static void create_net_nonce(u8_t nonce[13], const u8_t *pdu, sys_put_be32(iv_index, &nonce[9]); } -int bt_mesh_net_obfuscate(u8_t *pdu, u32_t iv_index, - const u8_t privacy_key[16]) +int bt_mesh_net_obfuscate(uint8_t *pdu, uint32_t iv_index, + const uint8_t privacy_key[16]) { - u8_t priv_rand[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, }; - u8_t tmp[16]; + uint8_t priv_rand[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, }; + uint8_t tmp[16]; int err, i; BT_DBG("IVIndex %u, PrivacyKey %s", (unsigned) iv_index, @@ -273,11 +273,11 @@ int bt_mesh_net_obfuscate(u8_t *pdu, u32_t iv_index, return 0; } -int bt_mesh_net_encrypt(const u8_t key[16], struct os_mbuf *buf, - u32_t iv_index, bool proxy) +int bt_mesh_net_encrypt(const uint8_t key[16], struct os_mbuf *buf, + uint32_t iv_index, bool proxy) { - u8_t mic_len = NET_MIC_LEN(buf->om_data); - u8_t nonce[13]; + uint8_t mic_len = NET_MIC_LEN(buf->om_data); + uint8_t nonce[13]; int err; BT_DBG("IVIndex %u EncKey %s mic_len %u", (unsigned) iv_index, @@ -301,11 +301,11 @@ int bt_mesh_net_encrypt(const u8_t key[16], struct os_mbuf *buf, return err; } -int bt_mesh_net_decrypt(const u8_t key[16], struct os_mbuf *buf, - u32_t iv_index, bool proxy) +int bt_mesh_net_decrypt(const uint8_t key[16], struct os_mbuf *buf, + uint32_t iv_index, bool proxy) { - u8_t mic_len = NET_MIC_LEN(buf->om_data); - u8_t nonce[13]; + uint8_t mic_len = NET_MIC_LEN(buf->om_data); + uint8_t nonce[13]; BT_DBG("PDU (%u bytes) %s", buf->om_len, bt_hex(buf->om_data, buf->om_len)); BT_DBG("iv_index %u, key %s mic_len %u", (unsigned) iv_index, @@ -325,9 +325,9 @@ int bt_mesh_net_decrypt(const u8_t key[16], struct os_mbuf *buf, NULL, 0, &buf->om_data[7], mic_len); } -static void create_app_nonce(u8_t nonce[13], bool dev_key, u8_t aszmic, - u16_t src, u16_t dst, u32_t seq_num, - u32_t iv_index) +static void create_app_nonce(uint8_t nonce[13], bool dev_key, uint8_t aszmic, + uint16_t src, uint16_t dst, uint32_t seq_num, + uint32_t iv_index) { if (dev_key) { nonce[0] = 0x02; @@ -335,7 +335,7 @@ static void create_app_nonce(u8_t nonce[13], bool dev_key, u8_t aszmic, nonce[0] = 0x01; } - sys_put_be32((seq_num | ((u32_t)aszmic << 31)), &nonce[1]); + sys_put_be32((seq_num | ((uint32_t)aszmic << 31)), &nonce[1]); sys_put_be16(src, &nonce[5]); sys_put_be16(dst, &nonce[7]); @@ -343,11 +343,11 @@ static void create_app_nonce(u8_t nonce[13], bool dev_key, u8_t aszmic, sys_put_be32(iv_index, &nonce[9]); } -static int mesh_app_encrypt(const u8_t key[16], bool dev_key, u8_t aszmic, - struct os_mbuf *buf, const u8_t *ad, - u16_t src, u16_t dst, u32_t seq_num, u32_t iv_index) +static int mesh_app_encrypt(const uint8_t key[16], bool dev_key, uint8_t aszmic, + struct os_mbuf *buf, const uint8_t *ad, + uint16_t src, uint16_t dst, uint32_t seq_num, uint32_t iv_index) { - u8_t nonce[13]; + uint8_t nonce[13]; BT_DBG("AppKey %s", bt_hex(key, 16)); BT_DBG("dev_key %u src 0x%04x dst 0x%04x", dev_key, src, dst); @@ -364,9 +364,9 @@ static int mesh_app_encrypt(const u8_t key[16], bool dev_key, u8_t aszmic, APP_MIC_LEN(aszmic)); } -int bt_mesh_app_encrypt_in_place(const u8_t key[16], bool dev_key, u8_t aszmic, - struct os_mbuf *buf, const u8_t *ad, u16_t src, - u16_t dst, u32_t seq_num, u32_t iv_index) +int bt_mesh_app_encrypt_in_place(const uint8_t key[16], bool dev_key, uint8_t aszmic, + struct os_mbuf *buf, const uint8_t *ad, uint16_t src, + uint16_t dst, uint32_t seq_num, uint32_t iv_index) { int err; @@ -379,9 +379,9 @@ int bt_mesh_app_encrypt_in_place(const u8_t key[16], bool dev_key, u8_t aszmic, return err; } -int bt_mesh_app_encrypt(const u8_t key[16], bool dev_key, u8_t aszmic, - struct os_mbuf *buf, const u8_t *ad, - u16_t src, u16_t dst, u32_t seq_num, u32_t iv_index) +int bt_mesh_app_encrypt(const uint8_t key[16], bool dev_key, uint8_t aszmic, + struct os_mbuf *buf, const uint8_t *ad, + uint16_t src, uint16_t dst, uint32_t seq_num, uint32_t iv_index) { int err; @@ -396,12 +396,12 @@ int bt_mesh_app_encrypt(const u8_t key[16], bool dev_key, u8_t aszmic, return err; } -static int mesh_app_decrypt(const u8_t key[16], bool dev_key, u8_t aszmic, +static int mesh_app_decrypt(const uint8_t key[16], bool dev_key, uint8_t aszmic, struct os_mbuf *buf, struct os_mbuf *out, - const u8_t *ad, u16_t src, u16_t dst, - u32_t seq_num, u32_t iv_index) + const uint8_t *ad, uint16_t src, uint16_t dst, + uint32_t seq_num, uint32_t iv_index) { - u8_t nonce[13]; + uint8_t nonce[13]; BT_DBG("EncData (len %u) %s", buf->om_len, bt_hex(buf->om_data, buf->om_len)); @@ -416,18 +416,18 @@ static int mesh_app_decrypt(const u8_t key[16], bool dev_key, u8_t aszmic, APP_MIC_LEN(aszmic)); } -int bt_mesh_app_decrypt_in_place(const u8_t key[16], bool dev_key, u8_t aszmic, - struct os_mbuf *buf, const u8_t *ad, u16_t src, - u16_t dst, u32_t seq_num, u32_t iv_index) +int bt_mesh_app_decrypt_in_place(const uint8_t key[16], bool dev_key, uint8_t aszmic, + struct os_mbuf *buf, const uint8_t *ad, uint16_t src, + uint16_t dst, uint32_t seq_num, uint32_t iv_index) { return mesh_app_decrypt(key, dev_key, aszmic, buf, buf, ad, src, dst, seq_num, iv_index); } -int bt_mesh_app_decrypt(const u8_t key[16], bool dev_key, u8_t aszmic, +int bt_mesh_app_decrypt(const uint8_t key[16], bool dev_key, uint8_t aszmic, struct os_mbuf *buf, struct os_mbuf *out, - const u8_t *ad, u16_t src, u16_t dst, u32_t seq_num, - u32_t iv_index) + const uint8_t *ad, uint16_t src, uint16_t dst, uint32_t seq_num, + uint32_t iv_index) { int err; @@ -441,7 +441,7 @@ int bt_mesh_app_decrypt(const u8_t key[16], bool dev_key, u8_t aszmic, } /* reversed, 8-bit, poly=0x07 */ -static const u8_t crc_table[256] = { +static const uint8_t crc_table[256] = { 0x00, 0x91, 0xe3, 0x72, 0x07, 0x96, 0xe4, 0x75, 0x0e, 0x9f, 0xed, 0x7c, 0x09, 0x98, 0xea, 0x7b, 0x1c, 0x8d, 0xff, 0x6e, 0x1b, 0x8a, 0xf8, 0x69, @@ -483,9 +483,9 @@ static const u8_t crc_table[256] = { 0xba, 0x2b, 0x59, 0xc8, 0xbd, 0x2c, 0x5e, 0xcf }; -u8_t bt_mesh_fcs_calc(const u8_t *data, u8_t data_len) +uint8_t bt_mesh_fcs_calc(const uint8_t *data, uint8_t data_len) { - u8_t fcs = 0xff; + uint8_t fcs = 0xff; while (data_len--) { fcs = crc_table[fcs ^ *data++]; @@ -496,11 +496,11 @@ u8_t bt_mesh_fcs_calc(const u8_t *data, u8_t data_len) return 0xff - fcs; } -bool bt_mesh_fcs_check(struct os_mbuf *buf, u8_t received_fcs) +bool bt_mesh_fcs_check(struct os_mbuf *buf, uint8_t received_fcs) { - const u8_t *data = buf->om_data; - u16_t data_len = buf->om_len; - u8_t fcs = 0xff; + const uint8_t *data = buf->om_data; + uint16_t data_len = buf->om_len; + uint8_t fcs = 0xff; while (data_len--) { fcs = crc_table[fcs ^ *data++]; @@ -509,10 +509,10 @@ bool bt_mesh_fcs_check(struct os_mbuf *buf, u8_t received_fcs) return crc_table[fcs ^ received_fcs] == 0xcf; } -int bt_mesh_virtual_addr(const u8_t virtual_label[16], u16_t *addr) +int bt_mesh_virtual_addr(const uint8_t virtual_label[16], uint16_t *addr) { - u8_t salt[16]; - u8_t tmp[16]; + uint8_t salt[16]; + uint8_t tmp[16]; int err; err = bt_mesh_s1("vtad", salt); @@ -530,21 +530,21 @@ int bt_mesh_virtual_addr(const u8_t virtual_label[16], u16_t *addr) return 0; } -int bt_mesh_prov_conf_salt(const u8_t conf_inputs[145], u8_t salt[16]) +int bt_mesh_prov_conf_salt(const uint8_t conf_inputs[145], uint8_t salt[16]) { - const u8_t conf_salt_key[16] = { 0 }; + const uint8_t conf_salt_key[16] = { 0 }; return bt_mesh_aes_cmac_one(conf_salt_key, conf_inputs, 145, salt); } -int bt_mesh_prov_conf_key(const u8_t dhkey[32], const u8_t conf_salt[16], - u8_t conf_key[16]) +int bt_mesh_prov_conf_key(const uint8_t dhkey[32], const uint8_t conf_salt[16], + uint8_t conf_key[16]) { return bt_mesh_k1(dhkey, 32, conf_salt, "prck", conf_key); } -int bt_mesh_prov_conf(const u8_t conf_key[16], const u8_t rand[16], - const u8_t auth[16], u8_t conf[16]) +int bt_mesh_prov_conf(const uint8_t conf_key[16], const uint8_t rand[16], + const uint8_t auth[16], uint8_t conf[16]) { struct bt_mesh_sg sg[] = { { rand, 16 }, { auth, 16 } }; @@ -555,23 +555,23 @@ int bt_mesh_prov_conf(const u8_t conf_key[16], const u8_t rand[16], return bt_mesh_aes_cmac(conf_key, sg, ARRAY_SIZE(sg), conf); } -int bt_mesh_prov_decrypt(const u8_t key[16], u8_t nonce[13], - const u8_t data[25 + 8], u8_t out[25]) +int bt_mesh_prov_decrypt(const uint8_t key[16], uint8_t nonce[13], + const uint8_t data[25 + 8], uint8_t out[25]) { return bt_ccm_decrypt(key, nonce, data, 25, NULL, 0, out, 8); } -int bt_mesh_prov_encrypt(const u8_t key[16], u8_t nonce[13], - const u8_t data[25], u8_t out[25 + 8]) +int bt_mesh_prov_encrypt(const uint8_t key[16], uint8_t nonce[13], + const uint8_t data[25], uint8_t out[25 + 8]) { return bt_ccm_encrypt(key, nonce, data, 25, NULL, 0, out, 8); } -int bt_mesh_beacon_auth(const u8_t beacon_key[16], u8_t flags, - const u8_t net_id[8], u32_t iv_index, - u8_t auth[8]) +int bt_mesh_beacon_auth(const uint8_t beacon_key[16], uint8_t flags, + const uint8_t net_id[8], uint32_t iv_index, + uint8_t auth[8]) { - u8_t msg[13], tmp[16]; + uint8_t msg[13], tmp[16]; int err; BT_DBG("BeaconKey %s", bt_hex(beacon_key, 16)); diff --git a/nimble/host/mesh/src/crypto.h b/nimble/host/mesh/src/crypto.h index 745cf324a..35fabe509 100644 --- a/nimble/host/mesh/src/crypto.h +++ b/nimble/host/mesh/src/crypto.h @@ -15,81 +15,81 @@ struct bt_mesh_sg { size_t len; }; -int bt_mesh_aes_cmac(const u8_t key[16], struct bt_mesh_sg *sg, - size_t sg_len, u8_t mac[16]); +int bt_mesh_aes_cmac(const uint8_t key[16], struct bt_mesh_sg *sg, + size_t sg_len, uint8_t mac[16]); -static inline int bt_mesh_aes_cmac_one(const u8_t key[16], const void *m, - size_t len, u8_t mac[16]) +static inline int bt_mesh_aes_cmac_one(const uint8_t key[16], const void *m, + size_t len, uint8_t mac[16]) { struct bt_mesh_sg sg = { m, len }; return bt_mesh_aes_cmac(key, &sg, 1, mac); } -static inline bool bt_mesh_s1(const char *m, u8_t salt[16]) +static inline bool bt_mesh_s1(const char *m, uint8_t salt[16]) { - const u8_t zero[16] = { 0 }; + const uint8_t zero[16] = { 0 }; return bt_mesh_aes_cmac_one(zero, m, strlen(m), salt); } -int bt_mesh_k1(const u8_t *ikm, size_t ikm_len, const u8_t salt[16], - const char *info, u8_t okm[16]); +int bt_mesh_k1(const uint8_t *ikm, size_t ikm_len, const uint8_t salt[16], + const char *info, uint8_t okm[16]); #define bt_mesh_k1_str(ikm, ikm_len, salt_str, info, okm) \ ({ \ - const u8_t salt[16] = salt_str; \ + const uint8_t salt[16] = salt_str; \ bt_mesh_k1(ikm, ikm_len, salt, info, okm); \ }) -int bt_mesh_k2(const u8_t n[16], const u8_t *p, size_t p_len, - u8_t net_id[1], u8_t enc_key[16], u8_t priv_key[16]); +int bt_mesh_k2(const uint8_t n[16], const uint8_t *p, size_t p_len, + uint8_t net_id[1], uint8_t enc_key[16], uint8_t priv_key[16]); -int bt_mesh_k3(const u8_t n[16], u8_t out[8]); +int bt_mesh_k3(const uint8_t n[16], uint8_t out[8]); -int bt_mesh_k4(const u8_t n[16], u8_t out[1]); +int bt_mesh_k4(const uint8_t n[16], uint8_t out[1]); -int bt_mesh_id128(const u8_t n[16], const char *s, u8_t out[16]); +int bt_mesh_id128(const uint8_t n[16], const char *s, uint8_t out[16]); -static inline int bt_mesh_id_resolving_key(const u8_t net_key[16], - u8_t resolving_key[16]) +static inline int bt_mesh_id_resolving_key(const uint8_t net_key[16], + uint8_t resolving_key[16]) { return bt_mesh_k1_str(net_key, 16, "smbt", "smbi", resolving_key); } -static inline int bt_mesh_identity_key(const u8_t net_key[16], - u8_t identity_key[16]) +static inline int bt_mesh_identity_key(const uint8_t net_key[16], + uint8_t identity_key[16]) { return bt_mesh_id128(net_key, "nkik", identity_key); } -static inline int bt_mesh_beacon_key(const u8_t net_key[16], - u8_t beacon_key[16]) +static inline int bt_mesh_beacon_key(const uint8_t net_key[16], + uint8_t beacon_key[16]) { return bt_mesh_id128(net_key, "nkbk", beacon_key); } -int bt_mesh_beacon_auth(const u8_t beacon_key[16], u8_t flags, - const u8_t net_id[16], u32_t iv_index, - u8_t auth[8]); +int bt_mesh_beacon_auth(const uint8_t beacon_key[16], uint8_t flags, + const uint8_t net_id[16], uint32_t iv_index, + uint8_t auth[8]); -static inline int bt_mesh_app_id(const u8_t app_key[16], u8_t app_id[1]) +static inline int bt_mesh_app_id(const uint8_t app_key[16], uint8_t app_id[1]) { return bt_mesh_k4(app_key, app_id); } -static inline int bt_mesh_session_key(const u8_t dhkey[32], - const u8_t prov_salt[16], - u8_t session_key[16]) +static inline int bt_mesh_session_key(const uint8_t dhkey[32], + const uint8_t prov_salt[16], + uint8_t session_key[16]) { return bt_mesh_k1(dhkey, 32, prov_salt, "prsk", session_key); } -static inline int bt_mesh_prov_nonce(const u8_t dhkey[32], - const u8_t prov_salt[16], - u8_t nonce[13]) +static inline int bt_mesh_prov_nonce(const uint8_t dhkey[32], + const uint8_t prov_salt[16], + uint8_t nonce[13]) { - u8_t tmp[16]; + uint8_t tmp[16]; int err; err = bt_mesh_k1(dhkey, 32, prov_salt, "prsn", tmp); @@ -100,19 +100,19 @@ static inline int bt_mesh_prov_nonce(const u8_t dhkey[32], return err; } -static inline int bt_mesh_dev_key(const u8_t dhkey[32], - const u8_t prov_salt[16], - u8_t dev_key[16]) +static inline int bt_mesh_dev_key(const uint8_t dhkey[32], + const uint8_t prov_salt[16], + uint8_t dev_key[16]) { return bt_mesh_k1(dhkey, 32, prov_salt, "prdk", dev_key); } -static inline int bt_mesh_prov_salt(const u8_t conf_salt[16], - const u8_t prov_rand[16], - const u8_t dev_rand[16], - u8_t prov_salt[16]) +static inline int bt_mesh_prov_salt(const uint8_t conf_salt[16], + const uint8_t prov_rand[16], + const uint8_t dev_rand[16], + uint8_t prov_salt[16]) { - const u8_t prov_salt_key[16] = { 0 }; + const uint8_t prov_salt_key[16] = { 0 }; struct bt_mesh_sg sg[] = { { conf_salt, 16 }, { prov_rand, 16 }, @@ -122,49 +122,49 @@ static inline int bt_mesh_prov_salt(const u8_t conf_salt[16], return bt_mesh_aes_cmac(prov_salt_key, sg, ARRAY_SIZE(sg), prov_salt); } -int bt_mesh_net_obfuscate(u8_t *pdu, u32_t iv_index, - const u8_t privacy_key[16]); +int bt_mesh_net_obfuscate(uint8_t *pdu, uint32_t iv_index, + const uint8_t privacy_key[16]); -int bt_mesh_net_encrypt(const u8_t key[16], struct os_mbuf *buf, - u32_t iv_index, bool proxy); +int bt_mesh_net_encrypt(const uint8_t key[16], struct os_mbuf *buf, + uint32_t iv_index, bool proxy); -int bt_mesh_net_decrypt(const u8_t key[16], struct os_mbuf *buf, - u32_t iv_index, bool proxy); +int bt_mesh_net_decrypt(const uint8_t key[16], struct os_mbuf *buf, + uint32_t iv_index, bool proxy); -int bt_mesh_app_encrypt_in_place(const u8_t key[16], bool dev_key, u8_t aszmic, - struct os_mbuf*buf, const u8_t *ad, u16_t src, - u16_t dst, u32_t seq_num, u32_t iv_index); +int bt_mesh_app_encrypt_in_place(const uint8_t key[16], bool dev_key, uint8_t aszmic, + struct os_mbuf*buf, const uint8_t *ad, uint16_t src, + uint16_t dst, uint32_t seq_num, uint32_t iv_index); -int bt_mesh_app_encrypt(const u8_t key[16], bool dev_key, u8_t aszmic, - struct os_mbuf*buf, const u8_t *ad, - u16_t src, u16_t dst, u32_t seq_num, u32_t iv_index); +int bt_mesh_app_encrypt(const uint8_t key[16], bool dev_key, uint8_t aszmic, + struct os_mbuf*buf, const uint8_t *ad, + uint16_t src, uint16_t dst, uint32_t seq_num, uint32_t iv_index); -int bt_mesh_app_decrypt_in_place(const u8_t key[16], bool dev_key, u8_t aszmic, - struct os_mbuf *buf, const u8_t *ad, u16_t src, - u16_t dst, u32_t seq_num, u32_t iv_index); +int bt_mesh_app_decrypt_in_place(const uint8_t key[16], bool dev_key, uint8_t aszmic, + struct os_mbuf *buf, const uint8_t *ad, uint16_t src, + uint16_t dst, uint32_t seq_num, uint32_t iv_index); -int bt_mesh_app_decrypt(const u8_t key[16], bool dev_key, u8_t aszmic, +int bt_mesh_app_decrypt(const uint8_t key[16], bool dev_key, uint8_t aszmic, struct os_mbuf*buf, struct os_mbuf*out, - const u8_t *ad, u16_t src, u16_t dst, u32_t seq_num, - u32_t iv_index); + const uint8_t *ad, uint16_t src, uint16_t dst, uint32_t seq_num, + uint32_t iv_index); -u8_t bt_mesh_fcs_calc(const u8_t *data, u8_t data_len); +uint8_t bt_mesh_fcs_calc(const uint8_t *data, uint8_t data_len); -bool bt_mesh_fcs_check(struct os_mbuf *buf, u8_t received_fcs); +bool bt_mesh_fcs_check(struct os_mbuf *buf, uint8_t received_fcs); -int bt_mesh_virtual_addr(const u8_t virtual_label[16], u16_t *addr); +int bt_mesh_virtual_addr(const uint8_t virtual_label[16], uint16_t *addr); -int bt_mesh_prov_conf_salt(const u8_t conf_inputs[145], u8_t salt[16]); +int bt_mesh_prov_conf_salt(const uint8_t conf_inputs[145], uint8_t salt[16]); -int bt_mesh_prov_conf_key(const u8_t dhkey[32], const u8_t conf_salt[16], - u8_t conf_key[16]); +int bt_mesh_prov_conf_key(const uint8_t dhkey[32], const uint8_t conf_salt[16], + uint8_t conf_key[16]); -int bt_mesh_prov_conf(const u8_t conf_key[16], const u8_t rand[16], - const u8_t auth[16], u8_t conf[16]); +int bt_mesh_prov_conf(const uint8_t conf_key[16], const uint8_t rand[16], + const uint8_t auth[16], uint8_t conf[16]); -int bt_mesh_prov_decrypt(const u8_t key[16], u8_t nonce[13], - const u8_t data[25 + 8], u8_t out[25]); +int bt_mesh_prov_decrypt(const uint8_t key[16], uint8_t nonce[13], + const uint8_t data[25 + 8], uint8_t out[25]); -int bt_mesh_prov_encrypt(const u8_t key[16], u8_t nonce[13], - const u8_t data[25], u8_t out[25 + 8]); +int bt_mesh_prov_encrypt(const uint8_t key[16], uint8_t nonce[13], + const uint8_t data[25], uint8_t out[25 + 8]); #endif diff --git a/nimble/host/mesh/src/foundation.h b/nimble/host/mesh/src/foundation.h index ee615ae9e..2679bdfc7 100644 --- a/nimble/host/mesh/src/foundation.h +++ b/nimble/host/mesh/src/foundation.h @@ -120,48 +120,48 @@ enum { }; struct label { - u16_t ref; - u16_t addr; - u8_t uuid[16]; + uint16_t ref; + uint16_t addr; + uint8_t uuid[16]; atomic_t flags[1]; }; void bt_mesh_cfg_reset(void); -void bt_mesh_heartbeat(u16_t src, u16_t dst, u8_t hops, u16_t feat); +void bt_mesh_heartbeat(uint16_t src, uint16_t dst, uint8_t hops, uint16_t feat); -void bt_mesh_attention(struct bt_mesh_model *model, u8_t time); +void bt_mesh_attention(struct bt_mesh_model *model, uint8_t time); -struct label *get_label(u16_t index); +struct label *get_label(uint16_t index); -u8_t *bt_mesh_label_uuid_get(u16_t addr); +uint8_t *bt_mesh_label_uuid_get(uint16_t addr); struct bt_mesh_hb_pub *bt_mesh_hb_pub_get(void); void bt_mesh_hb_pub_disable(void); struct bt_mesh_cfg_srv *bt_mesh_cfg_get(void); -u8_t bt_mesh_net_transmit_get(void); -u8_t bt_mesh_relay_get(void); -u8_t bt_mesh_friend_get(void); -u8_t bt_mesh_relay_retransmit_get(void); -u8_t bt_mesh_beacon_get(void); -u8_t bt_mesh_gatt_proxy_get(void); -u8_t bt_mesh_default_ttl_get(void); +uint8_t bt_mesh_net_transmit_get(void); +uint8_t bt_mesh_relay_get(void); +uint8_t bt_mesh_friend_get(void); +uint8_t bt_mesh_relay_retransmit_get(void); +uint8_t bt_mesh_beacon_get(void); +uint8_t bt_mesh_gatt_proxy_get(void); +uint8_t bt_mesh_default_ttl_get(void); void bt_mesh_subnet_del(struct bt_mesh_subnet *sub, bool store); -struct bt_mesh_app_key *bt_mesh_app_key_alloc(u16_t app_idx); +struct bt_mesh_app_key *bt_mesh_app_key_alloc(uint16_t app_idx); void bt_mesh_app_key_del(struct bt_mesh_app_key *key, bool store); static inline void key_idx_pack(struct os_mbuf *buf, - u16_t idx1, u16_t idx2) + uint16_t idx1, uint16_t idx2) { net_buf_simple_add_le16(buf, idx1 | ((idx2 & 0x00f) << 12)); net_buf_simple_add_u8(buf, idx2 >> 4); } static inline void key_idx_unpack(struct os_mbuf *buf, - u16_t *idx1, u16_t *idx2) + uint16_t *idx1, uint16_t *idx2) { *idx1 = sys_get_le16(&buf->om_data[0]) & 0xfff; *idx2 = sys_get_le16(&buf->om_data[1]) >> 4; diff --git a/nimble/host/mesh/src/friend.c b/nimble/host/mesh/src/friend.c index 8ab4f5895..43fa5fd14 100644 --- a/nimble/host/mesh/src/friend.c +++ b/nimble/host/mesh/src/friend.c @@ -48,20 +48,20 @@ static struct os_mempool friend_buf_mempool; #define FRIEND_XMIT BT_MESH_TRANSMIT(0, 20) struct friend_pdu_info { - u16_t src; - u16_t dst; + uint16_t src; + uint16_t dst; - u8_t seq[3]; + uint8_t seq[3]; - u8_t ttl:7, + uint8_t ttl:7, ctl:1; - u32_t iv_index; + uint32_t iv_index; }; static struct friend_adv { struct bt_mesh_adv adv; - u16_t app_idx; + uint16_t app_idx; } adv_pool[FRIEND_BUF_COUNT]; static struct bt_mesh_adv *adv_alloc(int id) @@ -70,7 +70,7 @@ static struct bt_mesh_adv *adv_alloc(int id) return &adv_pool[id].adv; } -static bool is_lpn_unicast(struct bt_mesh_friend *frnd, u16_t addr) +static bool is_lpn_unicast(struct bt_mesh_friend *frnd, uint16_t addr) { if (frnd->lpn == BT_MESH_ADDR_UNASSIGNED) { return false; @@ -79,7 +79,7 @@ static bool is_lpn_unicast(struct bt_mesh_friend *frnd, u16_t addr) return (addr >= frnd->lpn && addr < (frnd->lpn + frnd->num_elem)); } -struct bt_mesh_friend *bt_mesh_friend_find(u16_t net_idx, u16_t lpn_addr, +struct bt_mesh_friend *bt_mesh_friend_find(uint16_t net_idx, uint16_t lpn_addr, bool valid, bool established) { int i; @@ -125,10 +125,10 @@ static void purge_buffers(struct net_buf_slist_t *list) * like the PTS, where the receiver might not have sufficiently compensated * for internal latencies required to start scanning. */ -static s32_t recv_delay(struct bt_mesh_friend *frnd) +static int32_t recv_delay(struct bt_mesh_friend *frnd) { #if CONFIG_BT_MESH_FRIEND_RECV_WIN > 50 - return (s32_t)frnd->recv_delay + (CONFIG_BT_MESH_FRIEND_RECV_WIN / 5); + return (int32_t)frnd->recv_delay + (CONFIG_BT_MESH_FRIEND_RECV_WIN / 5); #else return frnd->recv_delay; #endif @@ -172,7 +172,7 @@ static void friend_clear(struct bt_mesh_friend *frnd) memset(frnd->sub_list, 0, sizeof(frnd->sub_list)); } -void bt_mesh_friend_clear_net_idx(u16_t net_idx) +void bt_mesh_friend_clear_net_idx(uint16_t net_idx) { int i; @@ -191,9 +191,9 @@ void bt_mesh_friend_clear_net_idx(u16_t net_idx) } } -static void enqueue_update(struct bt_mesh_friend *frnd, u8_t md); +static void enqueue_update(struct bt_mesh_friend *frnd, uint8_t md); -void bt_mesh_friend_sec_update(u16_t net_idx) +void bt_mesh_friend_sec_update(uint16_t net_idx) { int i; @@ -216,7 +216,7 @@ int bt_mesh_friend_clear(struct bt_mesh_net_rx *rx, struct os_mbuf *buf) { struct bt_mesh_ctl_friend_clear *msg = (void *)buf->om_data; struct bt_mesh_friend *frnd; - u16_t lpn_addr, lpn_counter; + uint16_t lpn_addr, lpn_counter; struct bt_mesh_net_tx tx = { .sub = rx->sub, .ctx = &rx->ctx, @@ -266,7 +266,7 @@ int bt_mesh_friend_clear(struct bt_mesh_net_rx *rx, struct os_mbuf *buf) return 0; } -static void friend_sub_add(struct bt_mesh_friend *frnd, u16_t addr) +static void friend_sub_add(struct bt_mesh_friend *frnd, uint16_t addr) { int i; @@ -280,7 +280,7 @@ static void friend_sub_add(struct bt_mesh_friend *frnd, u16_t addr) BT_WARN("No space in friend subscription list"); } -static void friend_sub_rem(struct bt_mesh_friend *frnd, u16_t addr) +static void friend_sub_rem(struct bt_mesh_friend *frnd, uint16_t addr) { int i; @@ -325,18 +325,18 @@ static struct os_mbuf *create_friend_pdu(struct bt_mesh_friend *frnd, struct unseg_app_sdu_meta { struct bt_mesh_net_rx net; - const u8_t *key; + const uint8_t *key; struct bt_mesh_subnet *subnet; bool is_dev_key; - u8_t aid; - u8_t *ad; + uint8_t aid; + uint8_t *ad; }; static int unseg_app_sdu_unpack(struct bt_mesh_friend *frnd, struct os_mbuf *buf, struct unseg_app_sdu_meta *meta) { - u16_t app_idx = FRIEND_ADV(buf)->app_idx; + uint16_t app_idx = FRIEND_ADV(buf)->app_idx; int err; meta->subnet = bt_mesh_subnet_get(frnd->net_idx); @@ -447,10 +447,10 @@ static int encrypt_friend_pdu(struct bt_mesh_friend *frnd, struct os_mbuf *buf, bool master_cred) { struct bt_mesh_subnet *sub = bt_mesh_subnet_get(frnd->net_idx); - const u8_t *enc, *priv; - u32_t iv_index; - u16_t src; - u8_t nid; + const uint8_t *enc, *priv; + uint32_t iv_index; + uint16_t src; + uint8_t nid; int err; if (master_cred) { @@ -467,7 +467,7 @@ static int encrypt_friend_pdu(struct bt_mesh_friend *frnd, struct os_mbuf *buf, src = sys_get_be16(&buf->om_data[5]); if (bt_mesh_elem_find(src)) { - u32_t seq; + uint32_t seq; if (FRIEND_ADV(buf)->app_idx != BT_MESH_KEY_UNUSED) { err = unseg_app_sdu_prepare(frnd, buf); @@ -482,7 +482,7 @@ static int encrypt_friend_pdu(struct bt_mesh_friend *frnd, struct os_mbuf *buf, iv_index = BT_MESH_NET_IVI_TX; FRIEND_ADV(buf)->app_idx = BT_MESH_KEY_UNUSED; } else { - u8_t ivi = (buf->om_data[0] >> 7); + uint8_t ivi = (buf->om_data[0] >> 7); iv_index = (bt_mesh.iv_index - ((bt_mesh.iv_index & 1) != ivi)); } @@ -502,7 +502,7 @@ static int encrypt_friend_pdu(struct bt_mesh_friend *frnd, struct os_mbuf *buf, } static struct os_mbuf *encode_friend_ctl(struct bt_mesh_friend *frnd, - u8_t ctl_op, + uint8_t ctl_op, struct os_mbuf *sdu) { struct friend_pdu_info info; @@ -524,7 +524,7 @@ static struct os_mbuf *encode_friend_ctl(struct bt_mesh_friend *frnd, return create_friend_pdu(frnd, &info, sdu); } -static struct os_mbuf *encode_update(struct bt_mesh_friend *frnd, u8_t md) +static struct os_mbuf *encode_update(struct bt_mesh_friend *frnd, uint8_t md) { struct bt_mesh_ctl_friend_update *upd; struct os_mbuf *sdu = NET_BUF_SIMPLE(1 + sizeof(*upd)); @@ -548,7 +548,7 @@ static struct os_mbuf *encode_update(struct bt_mesh_friend *frnd, u8_t md) return buf; } -static void enqueue_sub_cfm(struct bt_mesh_friend *frnd, u8_t xact) +static void enqueue_sub_cfm(struct bt_mesh_friend *frnd, uint8_t xact) { struct bt_mesh_ctl_friend_sub_confirm *cfm; struct os_mbuf *sdu = NET_BUF_SIMPLE(1 + sizeof(*cfm)); @@ -594,7 +594,7 @@ int bt_mesh_friend_sub_add(struct bt_mesh_net_rx *rx, struct os_mbuf *buf) { struct bt_mesh_friend *frnd; - u8_t xact; + uint8_t xact; if (buf->om_len < BT_MESH_FRIEND_SUB_MIN_LEN) { BT_WARN("Too short Friend Subscription Add"); @@ -629,7 +629,7 @@ int bt_mesh_friend_sub_rem(struct bt_mesh_net_rx *rx, struct os_mbuf *buf) { struct bt_mesh_friend *frnd; - u8_t xact; + uint8_t xact; if (buf->om_len < BT_MESH_FRIEND_SUB_MIN_LEN) { BT_WARN("Too short Friend Subscription Remove"); @@ -666,7 +666,7 @@ static void enqueue_buf(struct bt_mesh_friend *frnd, struct os_mbuf *buf) frnd->queue_size++; } -static void enqueue_update(struct bt_mesh_friend *frnd, u8_t md) +static void enqueue_update(struct bt_mesh_friend *frnd, uint8_t md) { struct os_mbuf *buf; @@ -734,7 +734,7 @@ int bt_mesh_friend_poll(struct bt_mesh_net_rx *rx, struct os_mbuf *buf) return 0; } -static struct bt_mesh_friend *find_clear(u16_t prev_friend) +static struct bt_mesh_friend *find_clear(uint16_t prev_friend) { int i; @@ -790,7 +790,7 @@ static void send_friend_clear(struct bt_mesh_friend *frnd) static void clear_timeout(struct ble_npl_event *work) { struct bt_mesh_friend *frnd = ble_npl_event_get_arg(work); - u32_t duration; + uint32_t duration; BT_DBG("LPN 0x%04x (old) Friend 0x%04x", frnd->lpn, frnd->clear.frnd); @@ -819,7 +819,7 @@ int bt_mesh_friend_clear_cfm(struct bt_mesh_net_rx *rx, { struct bt_mesh_ctl_friend_clear_confirm *msg = (void *)buf->om_data; struct bt_mesh_friend *frnd; - u16_t lpn_addr, lpn_counter; + uint16_t lpn_addr, lpn_counter; BT_DBG(""); @@ -854,7 +854,7 @@ int bt_mesh_friend_clear_cfm(struct bt_mesh_net_rx *rx, return 0; } -static void enqueue_offer(struct bt_mesh_friend *frnd, s8_t rssi) +static void enqueue_offer(struct bt_mesh_friend *frnd, int8_t rssi) { struct bt_mesh_ctl_friend_offer *off; struct os_mbuf *sdu = NET_BUF_SIMPLE(1 + sizeof(*off)); @@ -896,26 +896,26 @@ done: } #define RECV_WIN CONFIG_BT_MESH_FRIEND_RECV_WIN -#define RSSI_FACT(crit) (((crit) >> 5) & (u8_t)BIT_MASK(2)) -#define RECV_WIN_FACT(crit) (((crit) >> 3) & (u8_t)BIT_MASK(2)) -#define MIN_QUEUE_SIZE_LOG(crit) ((crit) & (u8_t)BIT_MASK(3)) -#define MIN_QUEUE_SIZE(crit) ((u32_t)BIT(MIN_QUEUE_SIZE_LOG(crit))) +#define RSSI_FACT(crit) (((crit) >> 5) & (uint8_t)BIT_MASK(2)) +#define RECV_WIN_FACT(crit) (((crit) >> 3) & (uint8_t)BIT_MASK(2)) +#define MIN_QUEUE_SIZE_LOG(crit) ((crit) & (uint8_t)BIT_MASK(3)) +#define MIN_QUEUE_SIZE(crit) ((uint32_t)BIT(MIN_QUEUE_SIZE_LOG(crit))) -static s32_t offer_delay(struct bt_mesh_friend *frnd, s8_t rssi, u8_t crit) +static int32_t offer_delay(struct bt_mesh_friend *frnd, int8_t rssi, uint8_t crit) { /* Scaling factors. The actual values are 1, 1.5, 2 & 2.5, but we * want to avoid floating-point arithmetic. */ - static const u8_t fact[] = { 10, 15, 20, 25 }; - s32_t delay; + static const uint8_t fact[] = { 10, 15, 20, 25 }; + int32_t delay; BT_DBG("ReceiveWindowFactor %u ReceiveWindow %u RSSIFactor %u RSSI %d", fact[RECV_WIN_FACT(crit)], RECV_WIN, fact[RSSI_FACT(crit)], rssi); /* Delay = ReceiveWindowFactor * ReceiveWindow - RSSIFactor * RSSI */ - delay = (s32_t)fact[RECV_WIN_FACT(crit)] * RECV_WIN; - delay -= (s32_t)fact[RSSI_FACT(crit)] * rssi; + delay = (int32_t)fact[RECV_WIN_FACT(crit)] * RECV_WIN; + delay -= (int32_t)fact[RSSI_FACT(crit)] * rssi; delay /= 10; BT_DBG("Local Delay calculated as %d ms", (int) delay); @@ -931,7 +931,7 @@ int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct os_mbuf *buf) { struct bt_mesh_ctl_friend_req *msg = (void *)buf->om_data; struct bt_mesh_friend *frnd = NULL; - u32_t poll_to; + uint32_t poll_to; int i; if (rx->net_if == BT_MESH_NET_IF_LOCAL) { @@ -1028,12 +1028,12 @@ init_friend: return 0; } -static bool is_seg(struct bt_mesh_friend_seg *seg, u16_t src, u16_t seq_zero) +static bool is_seg(struct bt_mesh_friend_seg *seg, uint16_t src, uint16_t seq_zero) { struct os_mbuf *buf = (void *)net_buf_slist_peek_head(&seg->queue); struct net_buf_simple_state state; - u16_t buf_seq_zero; - u16_t buf_src; + uint16_t buf_seq_zero; + uint16_t buf_src; if (!buf) { return false; @@ -1050,8 +1050,8 @@ static bool is_seg(struct bt_mesh_friend_seg *seg, u16_t src, u16_t seq_zero) } static struct bt_mesh_friend_seg *get_seg(struct bt_mesh_friend *frnd, - u16_t src, u16_t seq_zero, - u8_t seg_count) + uint16_t src, uint16_t seq_zero, + uint8_t seg_count) { struct bt_mesh_friend_seg *unassigned = NULL; int i; @@ -1077,7 +1077,7 @@ static struct bt_mesh_friend_seg *get_seg(struct bt_mesh_friend *frnd, static void enqueue_friend_pdu(struct bt_mesh_friend *frnd, enum bt_mesh_friend_pdu_type type, - u16_t src, u8_t seg_count, + uint16_t src, uint8_t seg_count, struct os_mbuf *buf) { struct bt_mesh_friend_seg *seg; @@ -1089,7 +1089,7 @@ static void enqueue_friend_pdu(struct bt_mesh_friend *frnd, return; } - u16_t seq_zero = (((buf->om_data[10] << 8 | buf->om_data[11]) >> 2) & TRANS_SEQ_ZERO_MASK); + uint16_t seq_zero = (((buf->om_data[10] << 8 | buf->om_data[11]) >> 2) & TRANS_SEQ_ZERO_MASK); seg = get_seg(frnd, src, seq_zero, seg_count); if (!seg) { @@ -1111,7 +1111,7 @@ static void enqueue_friend_pdu(struct bt_mesh_friend *frnd, } } -static void buf_send_start(u16_t duration, int err, void *user_data) +static void buf_send_start(uint16_t duration, int err, void *user_data) { struct bt_mesh_friend *frnd = user_data; @@ -1148,7 +1148,7 @@ static void buf_send_end(int err, void *user_data) } } -static void update_overwrite(struct os_mbuf *buf, u8_t md) +static void update_overwrite(struct os_mbuf *buf, uint8_t md) { struct net_buf_simple_state state; struct bt_mesh_ctl_friend_update *upd; @@ -1167,7 +1167,7 @@ static void update_overwrite(struct os_mbuf *buf, u8_t md) net_buf_skip(buf, 7); /* skip seqnum src dec*/ - if (TRANS_CTL_OP((u8_t *) net_buf_pull_mem(buf, 1)) + if (TRANS_CTL_OP((uint8_t *) net_buf_pull_mem(buf, 1)) != TRANS_CTL_OP_FRIEND_UPDATE) { goto end; } @@ -1188,7 +1188,7 @@ static void friend_timeout(struct ble_npl_event *work) .end = buf_send_end, }; - u8_t md; + uint8_t md; __ASSERT_NO_MSG(frnd->pending_buf == 0); @@ -1215,7 +1215,7 @@ static void friend_timeout(struct ble_npl_event *work) return; } - md = (u8_t)(net_buf_slist_peek_head(&frnd->queue) != NULL); + md = (uint8_t)(net_buf_slist_peek_head(&frnd->queue) != NULL); update_overwrite(frnd->last, md); @@ -1272,7 +1272,7 @@ int bt_mesh_friend_init(void) return 0; } -static bool is_segack(struct os_mbuf *buf, u64_t *seqauth, u16_t src) +static bool is_segack(struct os_mbuf *buf, uint64_t *seqauth, uint16_t src) { struct net_buf_simple_state state; bool found = false; @@ -1297,7 +1297,7 @@ static bool is_segack(struct os_mbuf *buf, u64_t *seqauth, u16_t src) net_buf_skip(buf, 2); /* skip dst */ - if (TRANS_CTL_OP((u8_t *) net_buf_pull_mem(buf, 1)) != TRANS_CTL_OP_ACK) { + if (TRANS_CTL_OP((uint8_t *) net_buf_pull_mem(buf, 1)) != TRANS_CTL_OP_ACK) { goto end; } @@ -1308,8 +1308,8 @@ end: return found; } -static void friend_purge_old_ack(struct bt_mesh_friend *frnd, u64_t *seq_auth, - u16_t src) +static void friend_purge_old_ack(struct bt_mesh_friend *frnd, uint64_t *seq_auth, + uint16_t src) { struct os_mbuf *cur, *prev = NULL; @@ -1334,7 +1334,7 @@ static void friend_purge_old_ack(struct bt_mesh_friend *frnd, u64_t *seq_auth, static void friend_lpn_enqueue_rx(struct bt_mesh_friend *frnd, struct bt_mesh_net_rx *rx, enum bt_mesh_friend_pdu_type type, - u64_t *seq_auth, u8_t seg_count, + uint64_t *seq_auth, uint8_t seg_count, struct os_mbuf *sbuf) { struct friend_pdu_info info; @@ -1385,7 +1385,7 @@ static void friend_lpn_enqueue_rx(struct bt_mesh_friend *frnd, static void friend_lpn_enqueue_tx(struct bt_mesh_friend *frnd, struct bt_mesh_net_tx *tx, enum bt_mesh_friend_pdu_type type, - u64_t *seq_auth, u8_t seg_count, + uint64_t *seq_auth, uint8_t seg_count, struct os_mbuf *sbuf) { struct friend_pdu_info info; @@ -1426,8 +1426,8 @@ static void friend_lpn_enqueue_tx(struct bt_mesh_friend *frnd, BT_DBG("Queued message for LPN 0x%04x", frnd->lpn); } -static bool friend_lpn_matches(struct bt_mesh_friend *frnd, u16_t net_idx, - u16_t addr) +static bool friend_lpn_matches(struct bt_mesh_friend *frnd, uint16_t net_idx, + uint16_t addr) { int i; @@ -1452,7 +1452,7 @@ static bool friend_lpn_matches(struct bt_mesh_friend *frnd, u16_t net_idx, return false; } -bool bt_mesh_friend_match(u16_t net_idx, u16_t addr) +bool bt_mesh_friend_match(uint16_t net_idx, uint16_t addr) { int i; @@ -1471,10 +1471,10 @@ bool bt_mesh_friend_match(u16_t net_idx, u16_t addr) return false; } -static bool friend_queue_has_space(struct bt_mesh_friend *frnd, u16_t addr, - u64_t *seq_auth, u8_t seg_count) +static bool friend_queue_has_space(struct bt_mesh_friend *frnd, uint16_t addr, + uint64_t *seq_auth, uint8_t seg_count) { - u32_t total = 0; + uint32_t total = 0; int i; if (seg_count > CONFIG_BT_MESH_FRIEND_QUEUE_SIZE) { @@ -1502,8 +1502,8 @@ static bool friend_queue_has_space(struct bt_mesh_friend *frnd, u16_t addr, return (CONFIG_BT_MESH_FRIEND_QUEUE_SIZE - total) > seg_count; } -bool bt_mesh_friend_queue_has_space(u16_t net_idx, u16_t src, u16_t dst, - u64_t *seq_auth, u8_t seg_count) +bool bt_mesh_friend_queue_has_space(uint16_t net_idx, uint16_t src, uint16_t dst, + uint64_t *seq_auth, uint8_t seg_count) { bool someone_has_space = false, friend_match = false; int i; @@ -1537,11 +1537,11 @@ bool bt_mesh_friend_queue_has_space(u16_t net_idx, u16_t src, u16_t dst, return someone_has_space; } -static bool friend_queue_prepare_space(struct bt_mesh_friend *frnd, u16_t addr, - u64_t *seq_auth, u8_t seg_count) +static bool friend_queue_prepare_space(struct bt_mesh_friend *frnd, uint16_t addr, + uint64_t *seq_auth, uint8_t seg_count) { bool pending_segments; - u8_t avail_space; + uint8_t avail_space; if (!friend_queue_has_space(frnd, addr, seq_auth, seg_count)) { return false; @@ -1575,7 +1575,7 @@ static bool friend_queue_prepare_space(struct bt_mesh_friend *frnd, u16_t addr, void bt_mesh_friend_enqueue_rx(struct bt_mesh_net_rx *rx, enum bt_mesh_friend_pdu_type type, - u64_t *seq_auth, u8_t seg_count, + uint64_t *seq_auth, uint8_t seg_count, struct os_mbuf *sbuf) { int i; @@ -1610,7 +1610,7 @@ void bt_mesh_friend_enqueue_rx(struct bt_mesh_net_rx *rx, bool bt_mesh_friend_enqueue_tx(struct bt_mesh_net_tx *tx, enum bt_mesh_friend_pdu_type type, - u64_t *seq_auth, u8_t seg_count, + uint64_t *seq_auth, uint8_t seg_count, struct os_mbuf *sbuf) { bool matched = false; @@ -1645,8 +1645,8 @@ bool bt_mesh_friend_enqueue_tx(struct bt_mesh_net_tx *tx, return matched; } -void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, u16_t src, - u16_t dst, u64_t *seq_auth) +void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, uint16_t src, + uint16_t dst, uint64_t *seq_auth) { int i; diff --git a/nimble/host/mesh/src/friend.h b/nimble/host/mesh/src/friend.h index 10ffa8190..48acc2278 100644 --- a/nimble/host/mesh/src/friend.h +++ b/nimble/host/mesh/src/friend.h @@ -17,29 +17,29 @@ enum bt_mesh_friend_pdu_type { BT_MESH_FRIEND_PDU_COMPLETE, }; -bool bt_mesh_friend_match(u16_t net_idx, u16_t addr); +bool bt_mesh_friend_match(uint16_t net_idx, uint16_t addr); -struct bt_mesh_friend *bt_mesh_friend_find(u16_t net_idx, u16_t lpn_addr, +struct bt_mesh_friend *bt_mesh_friend_find(uint16_t net_idx, uint16_t lpn_addr, bool valid, bool established); -bool bt_mesh_friend_queue_has_space(u16_t net_idx, u16_t src, u16_t dst, - u64_t *seq_auth, u8_t seg_count); +bool bt_mesh_friend_queue_has_space(uint16_t net_idx, uint16_t src, uint16_t dst, + uint64_t *seq_auth, uint8_t seg_count); void bt_mesh_friend_enqueue_rx(struct bt_mesh_net_rx *rx, enum bt_mesh_friend_pdu_type type, - u64_t *seq_auth, u8_t seg_count, + uint64_t *seq_auth, uint8_t seg_count, struct os_mbuf *sbuf); bool bt_mesh_friend_enqueue_tx(struct bt_mesh_net_tx *tx, enum bt_mesh_friend_pdu_type type, - u64_t *seq_auth, u8_t seg_count, + uint64_t *seq_auth, uint8_t seg_count, struct os_mbuf *sbuf); -void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, u16_t src, - u16_t dst, u64_t *seq_auth); +void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, uint16_t src, + uint16_t dst, uint64_t *seq_auth); -void bt_mesh_friend_sec_update(u16_t net_idx); +void bt_mesh_friend_sec_update(uint16_t net_idx); -void bt_mesh_friend_clear_net_idx(u16_t net_idx); +void bt_mesh_friend_clear_net_idx(uint16_t net_idx); int bt_mesh_friend_poll(struct bt_mesh_net_rx *rx, struct os_mbuf *buf); int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct os_mbuf *buf); diff --git a/nimble/host/mesh/src/glue.c b/nimble/host/mesh/src/glue.c index 82025bd55..6d046eb59 100644 --- a/nimble/host/mesh/src/glue.c +++ b/nimble/host/mesh/src/glue.c @@ -30,7 +30,7 @@ #include "base64/base64.h" #endif -extern u8_t g_mesh_addr_type; +extern uint8_t g_mesh_addr_type; #if MYNEWT_VAL(BLE_EXT_ADV) /* Store configuration for different bearers */ @@ -44,8 +44,8 @@ bt_hex(const void *buf, size_t len) { static const char hex[] = "0123456789abcdef"; static char hexbufs[4][137]; - static u8_t curbuf; - const u8_t *b = buf; + static uint8_t curbuf; + const uint8_t *b = buf; char *str; int i; @@ -357,7 +357,7 @@ k_fifo_is_empty(struct ble_npl_eventq *q) return ble_npl_eventq_is_empty(q); } -void * net_buf_get(struct ble_npl_eventq *fifo, s32_t t) +void * net_buf_get(struct ble_npl_eventq *fifo, int32_t t) { struct ble_npl_event *ev = ble_npl_eventq_get(fifo, 0); @@ -464,7 +464,7 @@ int64_t k_uptime_get(void) return ble_npl_time_ticks_to_ms32(ble_npl_time_get()); } -u32_t k_uptime_get_32(void) +uint32_t k_uptime_get_32(void) { return k_uptime_get(); } @@ -483,7 +483,7 @@ static uint8_t priv[32]; static bool has_pub = false; int -bt_dh_key_gen(const u8_t remote_pk[64], bt_dh_key_cb_t cb) +bt_dh_key_gen(const uint8_t remote_pk[64], bt_dh_key_cb_t cb) { uint8_t dh[32]; @@ -534,7 +534,7 @@ bt_pub_key_get(void) } static int -set_ad(const struct bt_data *ad, size_t ad_len, u8_t *buf, u8_t *buf_len) +set_ad(const struct bt_data *ad, size_t ad_len, uint8_t *buf, uint8_t *buf_len) { int i; diff --git a/nimble/host/mesh/src/health_cli.c b/nimble/host/mesh/src/health_cli.c index 3d90b4336..1f6c8ddfa 100644 --- a/nimble/host/mesh/src/health_cli.c +++ b/nimble/host/mesh/src/health_cli.c @@ -21,15 +21,15 @@ #include "foundation.h" #include "mesh/health_cli.h" -static s32_t msg_timeout = K_SECONDS(5); +static int32_t msg_timeout = K_SECONDS(5); static struct bt_mesh_health_cli *health_cli; struct health_fault_param { - u16_t cid; - u8_t *expect_test_id; - u8_t *test_id; - u8_t *faults; + uint16_t cid; + uint8_t *expect_test_id; + uint8_t *test_id; + uint8_t *faults; size_t *fault_count; }; @@ -38,8 +38,8 @@ static void health_fault_status(struct bt_mesh_model *model, struct os_mbuf *buf) { struct health_fault_param *param; - u8_t test_id; - u16_t cid; + uint8_t test_id; + uint16_t cid; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, @@ -84,8 +84,8 @@ static void health_current_status(struct bt_mesh_model *model, struct os_mbuf *buf) { struct bt_mesh_health_cli *cli = model->user_data; - u8_t test_id; - u16_t cid; + uint8_t test_id; + uint16_t cid; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", ctx->net_idx, ctx->app_idx, ctx->addr, buf->om_len, @@ -106,7 +106,7 @@ static void health_current_status(struct bt_mesh_model *model, } struct health_period_param { - u8_t *divisor; + uint8_t *divisor; }; static void health_period_status(struct bt_mesh_model *model, @@ -132,7 +132,7 @@ static void health_period_status(struct bt_mesh_model *model, } struct health_attention_param { - u8_t *attention; + uint8_t *attention; }; static void health_attention_status(struct bt_mesh_model *model, @@ -167,7 +167,7 @@ const struct bt_mesh_model_op bt_mesh_health_cli_op[] = { BT_MESH_MODEL_OP_END, }; -static int cli_prepare(void *param, u32_t op) +static int cli_prepare(void *param, uint32_t op) { if (!health_cli) { BT_ERR("No available Health Client context!"); @@ -202,7 +202,7 @@ static int cli_wait(void) return err; } -int bt_mesh_health_attention_get(u16_t addr, u16_t app_idx, u8_t *attention) +int bt_mesh_health_attention_get(uint16_t addr, uint16_t app_idx, uint8_t *attention) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_ATTENTION_GET, 0); struct bt_mesh_msg_ctx ctx = { @@ -235,8 +235,8 @@ done: return err; } -int bt_mesh_health_attention_set(u16_t addr, u16_t app_idx, u8_t attention, - u8_t *updated_attention) +int bt_mesh_health_attention_set(uint16_t addr, uint16_t app_idx, uint8_t attention, + uint8_t *updated_attention) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_ATTENTION_SET, 1); struct bt_mesh_msg_ctx ctx = { @@ -280,7 +280,7 @@ done: return err; } -int bt_mesh_health_period_get(u16_t addr, u16_t app_idx, u8_t *divisor) +int bt_mesh_health_period_get(uint16_t addr, uint16_t app_idx, uint8_t *divisor) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_HEALTH_PERIOD_GET, 0); struct bt_mesh_msg_ctx ctx = { @@ -313,8 +313,8 @@ done: return err; } -int bt_mesh_health_period_set(u16_t addr, u16_t app_idx, u8_t divisor, - u8_t *updated_divisor) +int bt_mesh_health_period_set(uint16_t addr, uint16_t app_idx, uint8_t divisor, + uint8_t *updated_divisor) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_HEALTH_PERIOD_SET, 1); struct bt_mesh_msg_ctx ctx = { @@ -358,8 +358,8 @@ done: return err; } -int bt_mesh_health_fault_test(u16_t addr, u16_t app_idx, u16_t cid, - u8_t test_id, u8_t *faults, +int bt_mesh_health_fault_test(uint16_t addr, uint16_t app_idx, uint16_t cid, + uint8_t test_id, uint8_t *faults, size_t *fault_count) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_HEALTH_FAULT_TEST, 3); @@ -408,8 +408,8 @@ done: return err; } -int bt_mesh_health_fault_clear(u16_t addr, u16_t app_idx, u16_t cid, - u8_t *test_id, u8_t *faults, +int bt_mesh_health_fault_clear(uint16_t addr, uint16_t app_idx, uint16_t cid, + uint8_t *test_id, uint8_t *faults, size_t *fault_count) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_HEALTH_FAULT_CLEAR, 2); @@ -457,8 +457,8 @@ done: return err; } -int bt_mesh_health_fault_get(u16_t addr, u16_t app_idx, u16_t cid, - u8_t *test_id, u8_t *faults, +int bt_mesh_health_fault_get(uint16_t addr, uint16_t app_idx, uint16_t cid, + uint8_t *test_id, uint8_t *faults, size_t *fault_count) { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_HEALTH_FAULT_GET, 2); @@ -496,12 +496,12 @@ done: return err; } -s32_t bt_mesh_health_cli_timeout_get(void) +int32_t bt_mesh_health_cli_timeout_get(void) { return msg_timeout; } -void bt_mesh_health_cli_timeout_set(s32_t timeout) +void bt_mesh_health_cli_timeout_set(int32_t timeout) { msg_timeout = timeout; } diff --git a/nimble/host/mesh/src/health_srv.c b/nimble/host/mesh/src/health_srv.c index 7f9cff54b..dd90533be 100644 --- a/nimble/host/mesh/src/health_srv.c +++ b/nimble/host/mesh/src/health_srv.c @@ -27,11 +27,11 @@ struct bt_mesh_health_srv *health_srv; static void health_get_registered(struct bt_mesh_model *mod, - u16_t company_id, + uint16_t company_id, struct os_mbuf *msg) { struct bt_mesh_health_srv *srv = mod->user_data; - u8_t *test_id; + uint8_t *test_id; BT_DBG("Company ID 0x%04x", company_id); @@ -41,7 +41,7 @@ static void health_get_registered(struct bt_mesh_model *mod, net_buf_simple_add_le16(msg, company_id); if (srv->cb && srv->cb->fault_get_reg) { - u8_t fault_count = net_buf_simple_tailroom(msg) - 4; + uint8_t fault_count = net_buf_simple_tailroom(msg) - 4; int err; err = srv->cb->fault_get_reg(mod, company_id, test_id, @@ -64,9 +64,9 @@ static size_t health_get_current(struct bt_mesh_model *mod, { struct bt_mesh_health_srv *srv = mod->user_data; const struct bt_mesh_comp *comp; - u8_t *test_id, *company_ptr; - u16_t company_id; - u8_t fault_count; + uint8_t *test_id, *company_ptr; + uint16_t company_id; + uint8_t fault_count; int err; bt_mesh_model_msg_init(msg, OP_HEALTH_CURRENT_STATUS); @@ -104,7 +104,7 @@ static void health_fault_get(struct bt_mesh_model *model, struct os_mbuf *buf) { struct os_mbuf *sdu = NET_BUF_SIMPLE(BT_MESH_TX_SDU_MAX); - u16_t company_id; + uint16_t company_id; company_id = net_buf_simple_pull_le16(buf); @@ -124,7 +124,7 @@ static void health_fault_clear_unrel(struct bt_mesh_model *model, struct os_mbuf *buf) { struct bt_mesh_health_srv *srv = model->user_data; - u16_t company_id; + uint16_t company_id; company_id = net_buf_simple_pull_le16(buf); @@ -141,7 +141,7 @@ static void health_fault_clear(struct bt_mesh_model *model, { struct os_mbuf *sdu = NET_BUF_SIMPLE(BT_MESH_TX_SDU_MAX); struct bt_mesh_health_srv *srv = model->user_data; - u16_t company_id; + uint16_t company_id; company_id = net_buf_simple_pull_le16(buf); @@ -165,8 +165,8 @@ static void health_fault_test_unrel(struct bt_mesh_model *model, struct os_mbuf *buf) { struct bt_mesh_health_srv *srv = model->user_data; - u16_t company_id; - u8_t test_id; + uint16_t company_id; + uint8_t test_id; test_id = net_buf_simple_pull_u8(buf); company_id = net_buf_simple_pull_le16(buf); @@ -184,8 +184,8 @@ static void health_fault_test(struct bt_mesh_model *model, { struct os_mbuf *sdu = NET_BUF_SIMPLE(BT_MESH_TX_SDU_MAX); struct bt_mesh_health_srv *srv = model->user_data; - u16_t company_id; - u8_t test_id; + uint16_t company_id; + uint8_t test_id; BT_DBG(""); @@ -219,7 +219,7 @@ static void send_attention_status(struct bt_mesh_model *model, { struct os_mbuf *msg = BT_MESH_MODEL_BUF(OP_ATTENTION_STATUS, 1); struct bt_mesh_health_srv *srv = model->user_data; - u8_t time; + uint8_t time; time = k_delayed_work_remaining_get(&srv->attn_timer) / 1000; BT_DBG("%u second%s", time, (time == 1) ? "" : "s"); @@ -248,7 +248,7 @@ static void attention_set_unrel(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t time; + uint8_t time; time = net_buf_simple_pull_u8(buf); @@ -297,7 +297,7 @@ static void health_period_set_unrel(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { - u8_t period; + uint8_t period; period = net_buf_simple_pull_u8(buf); if (period > 15) { @@ -416,7 +416,7 @@ const struct bt_mesh_model_cb bt_mesh_health_srv_cb = { .init = health_srv_init, }; -void bt_mesh_attention(struct bt_mesh_model *model, u8_t time) +void bt_mesh_attention(struct bt_mesh_model *model, uint8_t time) { struct bt_mesh_health_srv *srv; diff --git a/nimble/host/mesh/src/light_model.c b/nimble/host/mesh/src/light_model.c index b6d838188..bc4792c63 100644 --- a/nimble/host/mesh/src/light_model.c +++ b/nimble/host/mesh/src/light_model.c @@ -6,52 +6,52 @@ #include "light_model.h" -static u8_t gen_onoff_state; -static s16_t gen_level_state; +static uint8_t gen_onoff_state; +static int16_t gen_level_state; static void update_light_state(void) { - console_printf("Light state: onoff=%d lvl=0x%04x\n", gen_onoff_state, (u16_t)gen_level_state); + console_printf("Light state: onoff=%d lvl=0x%04x\n", gen_onoff_state, (uint16_t)gen_level_state); } -int light_model_gen_onoff_get(struct bt_mesh_model *model, u8_t *state) +int light_model_gen_onoff_get(struct bt_mesh_model *model, uint8_t *state) { *state = gen_onoff_state; return 0; } -int light_model_gen_onoff_set(struct bt_mesh_model *model, u8_t state) +int light_model_gen_onoff_set(struct bt_mesh_model *model, uint8_t state) { gen_onoff_state = state; update_light_state(); return 0; } -int light_model_gen_level_get(struct bt_mesh_model *model, s16_t *level) +int light_model_gen_level_get(struct bt_mesh_model *model, int16_t *level) { *level = gen_level_state; return 0; } -int light_model_gen_level_set(struct bt_mesh_model *model, s16_t level) +int light_model_gen_level_set(struct bt_mesh_model *model, int16_t level) { gen_level_state = level; - if ((u16_t)gen_level_state > 0x0000) { + if ((uint16_t)gen_level_state > 0x0000) { gen_onoff_state = 1; } - if ((u16_t)gen_level_state == 0x0000) { + if ((uint16_t)gen_level_state == 0x0000) { gen_onoff_state = 0; } update_light_state(); return 0; } -int light_model_light_lightness_get(struct bt_mesh_model *model, s16_t *lightness) +int light_model_light_lightness_get(struct bt_mesh_model *model, int16_t *lightness) { return light_model_gen_level_get(model, lightness); } -int light_model_light_lightness_set(struct bt_mesh_model *model, s16_t lightness) +int light_model_light_lightness_set(struct bt_mesh_model *model, int16_t lightness) { return light_model_gen_level_set(model, lightness); } diff --git a/nimble/host/mesh/src/light_model.h b/nimble/host/mesh/src/light_model.h index 95fcdb786..d5f959433 100644 --- a/nimble/host/mesh/src/light_model.h +++ b/nimble/host/mesh/src/light_model.h @@ -9,11 +9,11 @@ #include "syscfg/syscfg.h" #include "mesh/mesh.h" -int light_model_gen_onoff_get(struct bt_mesh_model *model, u8_t *state); -int light_model_gen_onoff_set(struct bt_mesh_model *model, u8_t state); -int light_model_gen_level_get(struct bt_mesh_model *model, s16_t *level); -int light_model_gen_level_set(struct bt_mesh_model *model, s16_t level); -int light_model_light_lightness_get(struct bt_mesh_model *model, s16_t *lightness); -int light_model_light_lightness_set(struct bt_mesh_model *model, s16_t lightness); +int light_model_gen_onoff_get(struct bt_mesh_model *model, uint8_t *state); +int light_model_gen_onoff_set(struct bt_mesh_model *model, uint8_t state); +int light_model_gen_level_get(struct bt_mesh_model *model, int16_t *level); +int light_model_gen_level_set(struct bt_mesh_model *model, int16_t level); +int light_model_light_lightness_get(struct bt_mesh_model *model, int16_t *lightness); +int light_model_light_lightness_set(struct bt_mesh_model *model, int16_t lightness); #endif diff --git a/nimble/host/mesh/src/lpn.c b/nimble/host/mesh/src/lpn.c index 49c366e8d..783e03127 100644 --- a/nimble/host/mesh/src/lpn.c +++ b/nimble/host/mesh/src/lpn.c @@ -60,13 +60,13 @@ (MYNEWT_VAL(BLE_MESH_LPN_RSSI_FACTOR) << 3) | \ (MYNEWT_VAL(BLE_MESH_LPN_RECV_WIN_FACTOR) << 5)) -#define POLL_TO(to) { (u8_t)((to) >> 16), (u8_t)((to) >> 8), (u8_t)(to) } +#define POLL_TO(to) { (uint8_t)((to) >> 16), (uint8_t)((to) >> 8), (uint8_t)(to) } #define LPN_POLL_TO POLL_TO(MYNEWT_VAL(BLE_MESH_LPN_POLL_TIMEOUT)) /* 2 transmissions, 20ms interval */ #define POLL_XMIT BT_MESH_TRANSMIT(1, 20) -static void (*lpn_cb)(u16_t friend_addr, bool established); +static void (*lpn_cb)(uint16_t friend_addr, bool established); #if MYNEWT_VAL(BLE_MESH_LOW_POWER_LOG_LVL) == LOG_LEVEL_DEBUG static const char *state2str(int state) @@ -256,7 +256,7 @@ static void clear_friendship(bool force, bool disable) k_delayed_work_submit(&lpn->timer, FRIEND_REQ_RETRY_TIMEOUT); } -static void friend_req_sent(u16_t duration, int err, void *user_data) +static void friend_req_sent(uint16_t duration, int err, void *user_data) { struct bt_mesh_lpn *lpn = &bt_mesh.lpn; @@ -311,7 +311,7 @@ static int send_friend_req(struct bt_mesh_lpn *lpn) sizeof(req), &friend_req_sent_cb, NULL); } -static void req_sent(u16_t duration, int err, void *user_data) +static void req_sent(uint16_t duration, int err, void *user_data) { struct bt_mesh_lpn *lpn = &bt_mesh.lpn; @@ -364,7 +364,7 @@ static int send_friend_poll(void) .friend_cred = true, }; struct bt_mesh_lpn *lpn = &bt_mesh.lpn; - u8_t fsn = lpn->fsn; + uint8_t fsn = lpn->fsn; int err; BT_DBG("lpn->sent_req 0x%02x", lpn->sent_req); @@ -485,7 +485,7 @@ int bt_mesh_lpn_friend_offer(struct bt_mesh_net_rx *rx, struct bt_mesh_lpn *lpn = &bt_mesh.lpn; struct bt_mesh_subnet *sub = rx->sub; struct friend_cred *cred; - u16_t frnd_counter; + uint16_t frnd_counter; int err; if (buf->om_len < sizeof(*msg)) { @@ -543,7 +543,7 @@ int bt_mesh_lpn_friend_clear_cfm(struct bt_mesh_net_rx *rx, { struct bt_mesh_ctl_friend_clear_confirm *msg = (void *)buf->om_data; struct bt_mesh_lpn *lpn = &bt_mesh.lpn; - u16_t addr, counter; + uint16_t addr, counter; if (buf->om_len < sizeof(*msg)) { BT_WARN("Too short Friend Clear Confirm"); @@ -571,10 +571,10 @@ int bt_mesh_lpn_friend_clear_cfm(struct bt_mesh_net_rx *rx, return 0; } -static void lpn_group_add(u16_t group) +static void lpn_group_add(uint16_t group) { struct bt_mesh_lpn *lpn = &bt_mesh.lpn; - u16_t *free_slot = NULL; + uint16_t *free_slot = NULL; int i; for (i = 0; i < ARRAY_SIZE(lpn->groups); i++) { @@ -597,7 +597,7 @@ static void lpn_group_add(u16_t group) lpn->groups_changed = 1; } -static void lpn_group_del(u16_t group) +static void lpn_group_del(uint16_t group) { struct bt_mesh_lpn *lpn = &bt_mesh.lpn; int i; @@ -628,7 +628,7 @@ static inline int group_popcount(atomic_t *target) #endif } -static bool sub_update(u8_t op) +static bool sub_update(uint8_t op) { struct bt_mesh_lpn *lpn = &bt_mesh.lpn; int added_count = group_popcount(lpn->added); @@ -767,7 +767,7 @@ static void lpn_timeout(struct ble_npl_event *work) break; case BT_MESH_LPN_ESTABLISHED: if (lpn->req_attempts < REQ_ATTEMPTS(lpn)) { - u8_t req = lpn->sent_req; + uint8_t req = lpn->sent_req; lpn->sent_req = 0; @@ -801,7 +801,7 @@ static void lpn_timeout(struct ble_npl_event *work) } } -void bt_mesh_lpn_group_add(u16_t group) +void bt_mesh_lpn_group_add(uint16_t group) { BT_DBG("group 0x%04x", group); @@ -814,7 +814,7 @@ void bt_mesh_lpn_group_add(u16_t group) sub_update(TRANS_CTL_OP_FRIEND_SUB_ADD); } -void bt_mesh_lpn_group_del(u16_t *groups, size_t group_count) +void bt_mesh_lpn_group_del(uint16_t *groups, size_t group_count) { int i; @@ -832,7 +832,7 @@ void bt_mesh_lpn_group_del(u16_t *groups, size_t group_count) sub_update(TRANS_CTL_OP_FRIEND_SUB_REM); } -static s32_t poll_timeout(struct bt_mesh_lpn *lpn) +static int32_t poll_timeout(struct bt_mesh_lpn *lpn) { /* If we're waiting for segment acks keep polling at high freq */ if (bt_mesh_tx_in_progress()) { @@ -921,7 +921,7 @@ int bt_mesh_lpn_friend_update(struct bt_mesh_net_rx *rx, struct bt_mesh_ctl_friend_update *msg = (void *)buf->om_data; struct bt_mesh_lpn *lpn = &bt_mesh.lpn; struct bt_mesh_subnet *sub = rx->sub; - u32_t iv_index; + uint32_t iv_index; if (buf->om_len < sizeof(*msg)) { BT_WARN("Too short Friend Update"); @@ -1020,7 +1020,7 @@ int bt_mesh_lpn_poll(void) return send_friend_poll(); } -void bt_mesh_lpn_set_cb(void (*cb)(u16_t friend_addr, bool established)) +void bt_mesh_lpn_set_cb(void (*cb)(uint16_t friend_addr, bool established)) { lpn_cb = cb; } diff --git a/nimble/host/mesh/src/lpn.h b/nimble/host/mesh/src/lpn.h index 0ff6c9cfd..90de2ca08 100644 --- a/nimble/host/mesh/src/lpn.h +++ b/nimble/host/mesh/src/lpn.h @@ -28,7 +28,7 @@ static inline bool bt_mesh_lpn_established(void) #endif } -static inline bool bt_mesh_lpn_match(u16_t addr) +static inline bool bt_mesh_lpn_match(uint16_t addr) { #if (MYNEWT_VAL(BLE_MESH_LOW_POWER)) if (bt_mesh_lpn_established()) { @@ -58,8 +58,8 @@ static inline bool bt_mesh_lpn_timer(void) void bt_mesh_lpn_msg_received(struct bt_mesh_net_rx *rx); -void bt_mesh_lpn_group_add(u16_t group); -void bt_mesh_lpn_group_del(u16_t *groups, size_t group_count); +void bt_mesh_lpn_group_add(uint16_t group); +void bt_mesh_lpn_group_del(uint16_t *groups, size_t group_count); void bt_mesh_lpn_disable(bool force); diff --git a/nimble/host/mesh/src/mesh.c b/nimble/host/mesh/src/mesh.c index e0fae8d09..da688840e 100644 --- a/nimble/host/mesh/src/mesh.c +++ b/nimble/host/mesh/src/mesh.c @@ -32,12 +32,12 @@ #include "settings.h" -u8_t g_mesh_addr_type; +uint8_t g_mesh_addr_type; static struct ble_gap_event_listener mesh_event_listener; -int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx, - u8_t flags, u32_t iv_index, u16_t addr, - const u8_t dev_key[16]) +int bt_mesh_provision(const uint8_t net_key[16], uint16_t net_idx, + uint8_t flags, uint32_t iv_index, uint16_t addr, + const uint8_t dev_key[16]) { bool pb_gatt_enabled; int err; @@ -141,8 +141,8 @@ int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx, return 0; } -int bt_mesh_provision_adv(const u8_t uuid[16], u16_t net_idx, u16_t addr, - u8_t attention_duration) +int bt_mesh_provision_adv(const uint8_t uuid[16], uint16_t net_idx, uint16_t addr, + uint8_t attention_duration) { if (!atomic_test_bit(bt_mesh.flags, BT_MESH_VALID)) { return -EINVAL; @@ -183,7 +183,7 @@ void bt_mesh_reset(void) if ((MYNEWT_VAL(BLE_MESH_LOW_POWER))) { if (IS_ENABLED(CONFIG_BT_MESH_LPN_SUB_ALL_NODES_ADDR)) { - u16_t group = BT_MESH_ADDR_ALL_NODES; + uint16_t group = BT_MESH_ADDR_ALL_NODES; bt_mesh_lpn_group_del(&group, 1); } @@ -279,7 +279,7 @@ static void model_resume(struct bt_mesh_model *mod, struct bt_mesh_elem *elem, bool vnd, bool primary, void *user_data) { if (mod->pub && mod->pub->update) { - s32_t period_ms = bt_mesh_model_pub_period_get(mod); + int32_t period_ms = bt_mesh_model_pub_period_get(mod); if (period_ms) { k_delayed_work_submit(&mod->pub->timer, period_ms); diff --git a/nimble/host/mesh/src/model_cli.c b/nimble/host/mesh/src/model_cli.c index b00cfa520..9755ec1fd 100644 --- a/nimble/host/mesh/src/model_cli.c +++ b/nimble/host/mesh/src/model_cli.c @@ -11,19 +11,19 @@ #include "mesh/model_cli.h" #include "mesh_priv.h" -static s32_t msg_timeout = K_SECONDS(5); +static int32_t msg_timeout = K_SECONDS(5); static struct bt_mesh_gen_model_cli *gen_onoff_cli; static struct bt_mesh_gen_model_cli *gen_level_cli; -static u8_t transaction_id = 0; +static uint8_t transaction_id = 0; struct gen_onoff_param { - u8_t *state; + uint8_t *state; }; struct gen_level_param { - s16_t *level; + int16_t *level; }; static void gen_onoff_status(struct bt_mesh_model *model, @@ -32,7 +32,7 @@ static void gen_onoff_status(struct bt_mesh_model *model, { struct bt_mesh_gen_model_cli *cli = model->user_data; struct gen_onoff_param *param; - u8_t state; + uint8_t state; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", @@ -62,7 +62,7 @@ static void gen_level_status(struct bt_mesh_model *model, { struct bt_mesh_gen_model_cli *cli = model->user_data; struct gen_level_param *param; - s16_t level; + int16_t level; BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s", @@ -138,7 +138,7 @@ const struct bt_mesh_model_cb bt_mesh_gen_level_cli_cb = { .init = level_cli_init, }; -static int cli_wait(struct bt_mesh_gen_model_cli *cli, void *param, u32_t op) +static int cli_wait(struct bt_mesh_gen_model_cli *cli, void *param, uint32_t op) { int err; @@ -155,8 +155,8 @@ static int cli_wait(struct bt_mesh_gen_model_cli *cli, void *param, u32_t op) return err; } -int bt_mesh_gen_onoff_get(u16_t net_idx, u16_t addr, u16_t app_idx, - u8_t *state) +int bt_mesh_gen_onoff_get(uint16_t net_idx, uint16_t addr, uint16_t app_idx, + uint8_t *state) { struct os_mbuf *msg = NET_BUF_SIMPLE(2 + 0 + 4); struct bt_mesh_msg_ctx ctx = { @@ -184,8 +184,8 @@ done: return err; } -int bt_mesh_gen_onoff_set(u16_t net_idx, u16_t addr, u16_t app_idx, - u8_t val, u8_t *state) +int bt_mesh_gen_onoff_set(uint16_t net_idx, uint16_t addr, uint16_t app_idx, + uint8_t val, uint8_t *state) { struct os_mbuf *msg = NET_BUF_SIMPLE(2 + 2 + 4); struct bt_mesh_msg_ctx ctx = { @@ -227,8 +227,8 @@ done: return err; } -int bt_mesh_gen_level_get(u16_t net_idx, u16_t addr, u16_t app_idx, - s16_t *level) +int bt_mesh_gen_level_get(uint16_t net_idx, uint16_t addr, uint16_t app_idx, + int16_t *level) { struct os_mbuf *msg = NET_BUF_SIMPLE(2 + 0 + 4); struct bt_mesh_msg_ctx ctx = { @@ -256,8 +256,8 @@ done: return err; } -int bt_mesh_gen_level_set(u16_t net_idx, u16_t addr, u16_t app_idx, - s16_t val, s16_t *state) +int bt_mesh_gen_level_set(uint16_t net_idx, uint16_t addr, uint16_t app_idx, + int16_t val, int16_t *state) { struct os_mbuf *msg = NET_BUF_SIMPLE(2 + 3 + 4); struct bt_mesh_msg_ctx ctx = { diff --git a/nimble/host/mesh/src/model_srv.c b/nimble/host/mesh/src/model_srv.c index 5f5a8df42..b6f34360a 100644 --- a/nimble/host/mesh/src/model_srv.c +++ b/nimble/host/mesh/src/model_srv.c @@ -20,7 +20,7 @@ static void gen_onoff_status(struct bt_mesh_model *model, { struct bt_mesh_gen_onoff_srv *cb = model->user_data; struct os_mbuf *msg = NET_BUF_SIMPLE(3); - u8_t *state; + uint8_t *state; bt_mesh_model_msg_init(msg, OP_GEN_ONOFF_STATUS); state = net_buf_simple_add(msg, 1); @@ -51,7 +51,7 @@ static void gen_onoff_set_unack(struct bt_mesh_model *model, struct os_mbuf *buf) { struct bt_mesh_gen_onoff_srv *cb = model->user_data; - u8_t state; + uint8_t state; state = buf->om_data[0]; @@ -77,7 +77,7 @@ static void gen_level_status(struct bt_mesh_model *model, { struct bt_mesh_gen_level_srv *cb = model->user_data; struct os_mbuf *msg = NET_BUF_SIMPLE(4); - s16_t *level; + int16_t *level; bt_mesh_model_msg_init(msg, OP_GEN_LEVEL_STATUS); level = net_buf_simple_add(msg, 2); @@ -107,9 +107,9 @@ static void gen_level_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { struct bt_mesh_gen_level_srv *cb = model->user_data; - s16_t level; + int16_t level; - level = (s16_t) net_buf_simple_pull_le16(buf); + level = (int16_t) net_buf_simple_pull_le16(buf); BT_DBG("level: %d", level); if (cb && cb->set) { @@ -130,7 +130,7 @@ static void light_lightness_status(struct bt_mesh_model *model, { struct bt_mesh_light_lightness_srv *cb = model->user_data; struct os_mbuf *msg = NET_BUF_SIMPLE(4); - s16_t *lightness; + int16_t *lightness; bt_mesh_model_msg_init(msg, OP_LIGHT_LIGHTNESS_STATUS); lightness = net_buf_simple_add(msg, 2); @@ -160,9 +160,9 @@ static void light_lightness_set_unack(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct os_mbuf *buf) { struct bt_mesh_light_lightness_srv *cb = model->user_data; - s16_t lightness; + int16_t lightness; - lightness = (s16_t) net_buf_simple_pull_le16(buf); + lightness = (int16_t) net_buf_simple_pull_le16(buf); BT_DBG("lightness: %d", lightness); if (cb && cb->set) { diff --git a/nimble/host/mesh/src/net.c b/nimble/host/mesh/src/net.c index afffbf530..7e7cc939e 100644 --- a/nimble/host/mesh/src/net.c +++ b/nimble/host/mesh/src/net.c @@ -68,10 +68,10 @@ static struct friend_cred friend_cred[FRIEND_CRED_COUNT]; static struct { - u32_t src : 15, /* MSb of source is always 0 */ + uint32_t src : 15, /* MSb of source is always 0 */ seq : 17; } msg_cache[MYNEWT_VAL(BLE_MESH_MSG_CACHE_SIZE)]; -static u16_t msg_cache_next; +static uint16_t msg_cache_next; /* Singleton network context (the implementation only supports one) */ struct bt_mesh_net bt_mesh = { @@ -91,13 +91,13 @@ struct bt_mesh_net bt_mesh = { static struct os_mempool loopback_buf_pool_mem; static struct os_mbuf_pool loopback_buf_pool; -static u32_t dup_cache[MYNEWT_VAL(BLE_MESH_MSG_CACHE_SIZE)]; +static uint32_t dup_cache[MYNEWT_VAL(BLE_MESH_MSG_CACHE_SIZE)]; static int dup_cache_next; static bool check_dup(struct os_mbuf *data) { - const u8_t *tail = net_buf_simple_tail(data); - u32_t val; + const uint8_t *tail = net_buf_simple_tail(data); + uint32_t val; int i; val = sys_get_be32(tail - 4) ^ sys_get_be32(tail - 8); @@ -116,7 +116,7 @@ static bool check_dup(struct os_mbuf *data) static bool msg_cache_match(struct os_mbuf *pdu) { - u16_t i; + uint16_t i; for (i = 0; i < ARRAY_SIZE(msg_cache); i++) { if (msg_cache[i].src == SRC(pdu->om_data) && @@ -137,7 +137,7 @@ static void msg_cache_add(struct bt_mesh_net_rx *rx) msg_cache_next %= ARRAY_SIZE(msg_cache); } -struct bt_mesh_subnet *bt_mesh_subnet_get(u16_t net_idx) +struct bt_mesh_subnet *bt_mesh_subnet_get(uint16_t net_idx) { int i; @@ -155,10 +155,10 @@ struct bt_mesh_subnet *bt_mesh_subnet_get(u16_t net_idx) } int bt_mesh_net_keys_create(struct bt_mesh_subnet_keys *keys, - const u8_t key[16]) + const uint8_t key[16]) { - u8_t p[] = { 0 }; - u8_t nid; + uint8_t p[] = { 0 }; + uint8_t nid; int err; err = bt_mesh_k2(key, p, sizeof(p), &nid, keys->enc, keys->privacy); @@ -203,11 +203,11 @@ int bt_mesh_net_keys_create(struct bt_mesh_subnet_keys *keys, return 0; } -int friend_cred_set(struct friend_cred *cred, u8_t idx, const u8_t net_key[16]) +int friend_cred_set(struct friend_cred *cred, uint8_t idx, const uint8_t net_key[16]) { - u16_t lpn_addr, frnd_addr; + uint16_t lpn_addr, frnd_addr; int err; - u8_t p[9]; + uint8_t p[9]; #if (MYNEWT_VAL(BLE_MESH_LOW_POWER)) if (cred->addr == bt_mesh.lpn.frnd) { @@ -246,7 +246,7 @@ int friend_cred_set(struct friend_cred *cred, u8_t idx, const u8_t net_key[16]) return 0; } -void friend_cred_refresh(u16_t net_idx) +void friend_cred_refresh(uint16_t net_idx) { int i; @@ -284,8 +284,8 @@ int friend_cred_update(struct bt_mesh_subnet *sub) return 0; } -struct friend_cred *friend_cred_create(struct bt_mesh_subnet *sub, u16_t addr, - u16_t lpn_counter, u16_t frnd_counter) +struct friend_cred *friend_cred_create(struct bt_mesh_subnet *sub, uint16_t addr, + uint16_t lpn_counter, uint16_t frnd_counter) { struct friend_cred *cred; int i, err; @@ -337,7 +337,7 @@ void friend_cred_clear(struct friend_cred *cred) memset(cred->cred, 0, sizeof(cred->cred)); } -int friend_cred_del(u16_t net_idx, u16_t addr) +int friend_cred_del(uint16_t net_idx, uint16_t addr) { int i; @@ -353,8 +353,8 @@ int friend_cred_del(u16_t net_idx, u16_t addr) return -ENOENT; } -int friend_cred_get(struct bt_mesh_subnet *sub, u16_t addr, u8_t *nid, - const u8_t **enc, const u8_t **priv) +int friend_cred_get(struct bt_mesh_subnet *sub, uint16_t addr, uint8_t *nid, + const uint8_t **enc, const uint8_t **priv) { int i; @@ -389,9 +389,9 @@ int friend_cred_get(struct bt_mesh_subnet *sub, u16_t addr, u8_t *nid, return -ENOENT; } -u8_t bt_mesh_net_flags(struct bt_mesh_subnet *sub) +uint8_t bt_mesh_net_flags(struct bt_mesh_subnet *sub) { - u8_t flags = 0x00; + uint8_t flags = 0x00; if (sub && sub->kr_flag) { flags |= BT_MESH_NET_FLAG_KR; @@ -406,7 +406,7 @@ u8_t bt_mesh_net_flags(struct bt_mesh_subnet *sub) int bt_mesh_net_beacon_update(struct bt_mesh_subnet *sub) { - u8_t flags = bt_mesh_net_flags(sub); + uint8_t flags = bt_mesh_net_flags(sub); struct bt_mesh_subnet_keys *keys; if (sub->kr_flag) { @@ -423,8 +423,8 @@ int bt_mesh_net_beacon_update(struct bt_mesh_subnet *sub) bt_mesh.iv_index, sub->auth); } -int bt_mesh_net_create(u16_t idx, u8_t flags, const u8_t key[16], - u32_t iv_index) +int bt_mesh_net_create(uint16_t idx, uint8_t flags, const uint8_t key[16], + uint32_t iv_index) { struct bt_mesh_subnet *sub; int err; @@ -506,7 +506,7 @@ void bt_mesh_net_revoke_keys(struct bt_mesh_subnet *sub) } } -bool bt_mesh_kr_update(struct bt_mesh_subnet *sub, u8_t new_kr, bool new_key) +bool bt_mesh_kr_update(struct bt_mesh_subnet *sub, uint8_t new_kr, bool new_key) { if (new_kr != sub->kr_flag && sub->kr_phase == BT_MESH_KR_NORMAL) { BT_WARN("KR change in normal operation. Are we blacklisted?"); @@ -595,7 +595,7 @@ void bt_mesh_net_sec_update(struct bt_mesh_subnet *sub) } } -bool bt_mesh_net_iv_update(u32_t iv_index, bool iv_update) +bool bt_mesh_net_iv_update(uint32_t iv_index, bool iv_update) { int i; @@ -699,9 +699,9 @@ do_update: return true; } -u32_t bt_mesh_next_seq(void) +uint32_t bt_mesh_next_seq(void) { - u32_t seq = bt_mesh.seq++; + uint32_t seq = bt_mesh.seq++; if (IS_ENABLED(CONFIG_BT_SETTINGS)) { bt_mesh_store_seq(); @@ -957,10 +957,10 @@ void bt_mesh_net_loopback_clear(uint16_t net_idx) } static bool auth_match(struct bt_mesh_subnet_keys *keys, - const u8_t net_id[8], u8_t flags, - u32_t iv_index, const u8_t auth[8]) + const uint8_t net_id[8], uint8_t flags, + uint32_t iv_index, const uint8_t auth[8]) { - u8_t net_auth[8]; + uint8_t net_auth[8]; if (memcmp(net_id, keys->net_id, 8)) { return false; @@ -978,8 +978,8 @@ static bool auth_match(struct bt_mesh_subnet_keys *keys, return true; } -struct bt_mesh_subnet *bt_mesh_subnet_find(const u8_t net_id[8], u8_t flags, - u32_t iv_index, const u8_t auth[8], +struct bt_mesh_subnet *bt_mesh_subnet_find(const uint8_t net_id[8], uint8_t flags, + uint32_t iv_index, const uint8_t auth[8], bool *new_key) { int i; @@ -1009,8 +1009,8 @@ struct bt_mesh_subnet *bt_mesh_subnet_find(const u8_t net_id[8], u8_t flags, return NULL; } -static int net_decrypt(struct bt_mesh_subnet *sub, const u8_t *enc, - const u8_t *priv, const u8_t *data, +static int net_decrypt(struct bt_mesh_subnet *sub, const uint8_t *enc, + const uint8_t *priv, const uint8_t *data, size_t data_len, struct bt_mesh_net_rx *rx, struct os_mbuf *buf) { @@ -1054,7 +1054,7 @@ static int net_decrypt(struct bt_mesh_subnet *sub, const u8_t *enc, return bt_mesh_net_decrypt(enc, buf, BT_MESH_NET_IVI_RX(rx), false); } -static int friend_decrypt(struct bt_mesh_subnet *sub, const u8_t *data, +static int friend_decrypt(struct bt_mesh_subnet *sub, const uint8_t *data, size_t data_len, struct bt_mesh_net_rx *rx, struct os_mbuf *buf) { @@ -1090,7 +1090,7 @@ static int friend_decrypt(struct bt_mesh_subnet *sub, const u8_t *data, return -ENOENT; } -static bool net_find_and_decrypt(const u8_t *data, size_t data_len, +static bool net_find_and_decrypt(const uint8_t *data, size_t data_len, struct bt_mesh_net_rx *rx, struct os_mbuf *buf) { @@ -1159,9 +1159,9 @@ static bool relay_to_adv(enum bt_mesh_net_if net_if) static void bt_mesh_net_relay(struct os_mbuf *sbuf, struct bt_mesh_net_rx *rx) { - const u8_t *enc, *priv; + const uint8_t *enc, *priv; struct os_mbuf *buf; - u8_t nid, transmit; + uint8_t nid, transmit; if (rx->ctx.recv_ttl <= 1U) { return; @@ -1315,7 +1315,7 @@ int bt_mesh_net_decode(struct os_mbuf *data, enum bt_mesh_net_if net_if, return 0; } -void bt_mesh_net_recv(struct os_mbuf *data, s8_t rssi, +void bt_mesh_net_recv(struct os_mbuf *data, int8_t rssi, enum bt_mesh_net_if net_if) { struct os_mbuf *buf = NET_BUF_SIMPLE(29); @@ -1428,8 +1428,8 @@ void bt_mesh_net_start(void) } if (IS_ENABLED(CONFIG_BT_MESH_PROV)) { - u16_t net_idx = bt_mesh.sub[0].net_idx; - u16_t addr = bt_mesh_primary_addr(); + uint16_t net_idx = bt_mesh.sub[0].net_idx; + uint16_t addr = bt_mesh_primary_addr(); bt_mesh_prov_complete(net_idx, addr); } diff --git a/nimble/host/mesh/src/net.h b/nimble/host/mesh/src/net.h index 63381e5a8..1f73e59d3 100644 --- a/nimble/host/mesh/src/net.h +++ b/nimble/host/mesh/src/net.h @@ -32,53 +32,53 @@ #define BT_MESH_IVU_TIMEOUT K_HOURS(BT_MESH_IVU_HOURS) struct bt_mesh_app_key { - u16_t net_idx; - u16_t app_idx; + uint16_t net_idx; + uint16_t app_idx; bool updated; struct bt_mesh_app_keys { - u8_t id; - u8_t val[16]; + uint8_t id; + uint8_t val[16]; } keys[2]; }; struct bt_mesh_node { - u16_t addr; - u16_t net_idx; - u8_t dev_key[16]; - u8_t num_elem; + uint16_t addr; + uint16_t net_idx; + uint8_t dev_key[16]; + uint8_t num_elem; }; struct bt_mesh_subnet { - u32_t beacon_sent; /* Timestamp of last sent beacon */ - u8_t beacons_last; /* Number of beacons during last + uint32_t beacon_sent; /* Timestamp of last sent beacon */ + uint8_t beacons_last; /* Number of beacons during last * observation window */ - u8_t beacons_cur; /* Number of beaconds observed during + uint8_t beacons_cur; /* Number of beaconds observed during * currently ongoing window. */ - u8_t beacon_cache[21]; /* Cached last authenticated beacon */ + uint8_t beacon_cache[21]; /* Cached last authenticated beacon */ - u16_t net_idx; /* NetKeyIndex */ + uint16_t net_idx; /* NetKeyIndex */ bool kr_flag; /* Key Refresh Flag */ - u8_t kr_phase; /* Key Refresh Phase */ + uint8_t kr_phase; /* Key Refresh Phase */ - u8_t node_id; /* Node Identity State */ - u32_t node_id_start; /* Node Identity started timestamp */ + uint8_t node_id; /* Node Identity State */ + uint32_t node_id_start; /* Node Identity started timestamp */ - u8_t auth[8]; /* Beacon Authentication Value */ + uint8_t auth[8]; /* Beacon Authentication Value */ struct bt_mesh_subnet_keys { - u8_t net[16]; /* NetKey */ - u8_t nid; /* NID */ - u8_t enc[16]; /* EncKey */ - u8_t net_id[8]; /* Network ID */ + uint8_t net[16]; /* NetKey */ + uint8_t nid; /* NID */ + uint8_t enc[16]; /* EncKey */ + uint8_t net_id[8]; /* Network ID */ #if (MYNEWT_VAL(BLE_MESH_GATT_PROXY)) - u8_t identity[16]; /* IdentityKey */ + uint8_t identity[16]; /* IdentityKey */ #endif - u8_t privacy[16]; /* PrivacyKey */ - u8_t beacon[16]; /* BeaconKey */ + uint8_t privacy[16]; /* PrivacyKey */ + uint8_t beacon[16]; /* BeaconKey */ } keys[2]; }; @@ -91,22 +91,22 @@ struct bt_mesh_subnet { #endif struct bt_mesh_friend { - u16_t lpn; - u8_t recv_delay; - u8_t fsn:1, + uint16_t lpn; + uint8_t recv_delay; + uint8_t fsn:1, send_last:1, pending_req:1, pending_buf:1, valid:1, established:1; - s32_t poll_to; - u8_t num_elem; - u16_t lpn_counter; - u16_t counter; + int32_t poll_to; + uint8_t num_elem; + uint16_t lpn_counter; + uint16_t counter; - u16_t net_idx; + uint16_t net_idx; - u16_t sub_list[FRIEND_SUB_LIST_SIZE]; + uint16_t sub_list[FRIEND_SUB_LIST_SIZE]; struct k_delayed_work timer; @@ -117,19 +117,19 @@ struct bt_mesh_friend { * the current number of segments, in the queue. This is * used for Friend Queue free space calculations. */ - u8_t seg_count; + uint8_t seg_count; } seg[FRIEND_SEG_RX]; struct os_mbuf *last; struct net_buf_slist_t queue; - u32_t queue_size; + uint32_t queue_size; /* Friend Clear Procedure */ struct { - u32_t start; /* Clear Procedure start */ - u16_t frnd; /* Previous Friend's address */ - u16_t repeat_sec; /* Repeat timeout in seconds */ + uint32_t start; /* Clear Procedure start */ + uint16_t frnd; /* Previous Friend's address */ + uint16_t repeat_sec; /* Repeat timeout in seconds */ struct k_delayed_work timer; /* Repeat timer */ } clear; }; @@ -155,23 +155,23 @@ struct bt_mesh_lpn { } state; /* Transaction Number (used for subscription list) */ - u8_t xact_next; - u8_t xact_pending; - u8_t sent_req; + uint8_t xact_next; + uint8_t xact_pending; + uint8_t sent_req; /* Address of our Friend when we're a LPN. Unassigned if we don't * have a friend yet. */ - u16_t frnd; + uint16_t frnd; /* Value from the friend offer */ - u8_t recv_win; + uint8_t recv_win; - u8_t req_attempts; /* Number of Request attempts */ + uint8_t req_attempts; /* Number of Request attempts */ - s32_t poll_timeout; + int32_t poll_timeout; - u8_t groups_changed:1, /* Friend Subscription List needs updating */ + uint8_t groups_changed:1, /* Friend Subscription List needs updating */ pending_poll:1, /* Poll to be sent after subscription */ disable:1, /* Disable LPN after clearing */ fsn:1, /* Friend Sequence Number */ @@ -179,22 +179,22 @@ struct bt_mesh_lpn { clear_success:1; /* Friend Clear Confirm received */ /* Friend Queue Size */ - u8_t queue_size; + uint8_t queue_size; /* LPNCounter */ - u16_t counter; + uint16_t counter; /* Previous Friend of this LPN */ - u16_t old_friend; + uint16_t old_friend; /* Duration reported for last advertising packet */ - u16_t adv_duration; + uint16_t adv_duration; /* Next LPN related action timer */ struct k_delayed_work timer; /* Subscribed groups */ - u16_t groups[LPN_GROUPS]; + uint16_t groups[LPN_GROUPS]; /* Bit fields for tracking which groups the Friend knows about */ ATOMIC_DEFINE(added, LPN_GROUPS); @@ -227,8 +227,8 @@ enum { }; struct bt_mesh_net { - u32_t iv_index; /* Current IV Index */ - u32_t seq; /* Next outgoing sequence number (24 bits) */ + uint32_t iv_index; /* Current IV Index */ + uint32_t seq; /* Next outgoing sequence number (24 bits) */ ATOMIC_DEFINE(flags, BT_MESH_FLAG_COUNT); @@ -246,12 +246,12 @@ struct bt_mesh_net { #endif /* Number of hours in current IV Update state */ - u8_t ivu_duration; + uint8_t ivu_duration; /* Timer to track duration in current IV Update state */ struct k_delayed_work ivu_timer; - u8_t dev_key[16]; + uint8_t dev_key[16]; struct bt_mesh_app_key app_keys[MYNEWT_VAL(BLE_MESH_APP_KEY_COUNT)]; @@ -270,24 +270,24 @@ enum bt_mesh_net_if { struct bt_mesh_net_rx { struct bt_mesh_subnet *sub; struct bt_mesh_msg_ctx ctx; - u32_t seq; /* Sequence Number */ - u8_t old_iv:1, /* iv_index - 1 was used */ + uint32_t seq; /* Sequence Number */ + uint8_t old_iv:1, /* iv_index - 1 was used */ new_key:1, /* Data was encrypted with updated key */ friend_cred:1, /* Data was encrypted with friend cred */ ctl:1, /* Network Control */ net_if:2, /* Network interface */ local_match:1, /* Matched a local element */ friend_match:1; /* Matched an LPN we're friends for */ - u16_t msg_cache_idx; /* Index of entry in message cache */ + uint16_t msg_cache_idx; /* Index of entry in message cache */ }; /* Encoding context for Network/Transport data */ struct bt_mesh_net_tx { struct bt_mesh_subnet *sub; struct bt_mesh_msg_ctx *ctx; - u16_t src; - u8_t xmit; - u8_t friend_cred:1, + uint16_t src; + uint8_t xmit; + uint8_t friend_cred:1, aszmic:1, aid:6; }; @@ -307,27 +307,27 @@ static inline void *net_buf_user_data(const struct os_mbuf *buf) } int bt_mesh_net_keys_create(struct bt_mesh_subnet_keys *keys, - const u8_t key[16]); + const uint8_t key[16]); -int bt_mesh_net_create(u16_t idx, u8_t flags, const u8_t key[16], - u32_t iv_index); +int bt_mesh_net_create(uint16_t idx, uint8_t flags, const uint8_t key[16], + uint32_t iv_index); -u8_t bt_mesh_net_flags(struct bt_mesh_subnet *sub); +uint8_t bt_mesh_net_flags(struct bt_mesh_subnet *sub); -bool bt_mesh_kr_update(struct bt_mesh_subnet *sub, u8_t new_kr, bool new_key); +bool bt_mesh_kr_update(struct bt_mesh_subnet *sub, uint8_t new_kr, bool new_key); void bt_mesh_net_revoke_keys(struct bt_mesh_subnet *sub); int bt_mesh_net_beacon_update(struct bt_mesh_subnet *sub); -bool bt_mesh_net_iv_update(u32_t iv_index, bool iv_update); +bool bt_mesh_net_iv_update(uint32_t iv_index, bool iv_update); void bt_mesh_net_sec_update(struct bt_mesh_subnet *sub); -struct bt_mesh_subnet *bt_mesh_subnet_get(u16_t net_idx); +struct bt_mesh_subnet *bt_mesh_subnet_get(uint16_t net_idx); -struct bt_mesh_subnet *bt_mesh_subnet_find(const u8_t net_id[8], u8_t flags, - u32_t iv_index, const u8_t auth[8], +struct bt_mesh_subnet *bt_mesh_subnet_find(const uint8_t net_id[8], uint8_t flags, + uint32_t iv_index, const uint8_t auth[8], bool *new_key); int bt_mesh_net_encode(struct bt_mesh_net_tx *tx, struct os_mbuf *buf, @@ -339,12 +339,12 @@ int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct os_mbuf *buf, int bt_mesh_net_decode(struct os_mbuf *data, enum bt_mesh_net_if net_if, struct bt_mesh_net_rx *rx, struct os_mbuf *buf); -void bt_mesh_net_recv(struct os_mbuf *data, s8_t rssi, +void bt_mesh_net_recv(struct os_mbuf *data, int8_t rssi, enum bt_mesh_net_if net_if); void bt_mesh_net_loopback_clear(uint16_t net_idx); -u32_t bt_mesh_next_seq(void); +uint32_t bt_mesh_next_seq(void); void bt_mesh_net_start(void); @@ -354,28 +354,28 @@ void bt_mesh_net_header_parse(struct os_mbuf *buf, /* Friendship Credential Management */ struct friend_cred { - u16_t net_idx; - u16_t addr; + uint16_t net_idx; + uint16_t addr; - u16_t lpn_counter; - u16_t frnd_counter; + uint16_t lpn_counter; + uint16_t frnd_counter; struct { - u8_t nid; /* NID */ - u8_t enc[16]; /* EncKey */ - u8_t privacy[16]; /* PrivacyKey */ + uint8_t nid; /* NID */ + uint8_t enc[16]; /* EncKey */ + uint8_t privacy[16]; /* PrivacyKey */ } cred[2]; }; -int friend_cred_get(struct bt_mesh_subnet *sub, u16_t addr, u8_t *nid, - const u8_t **enc, const u8_t **priv); -int friend_cred_set(struct friend_cred *cred, u8_t idx, const u8_t net_key[16]); -void friend_cred_refresh(u16_t net_idx); +int friend_cred_get(struct bt_mesh_subnet *sub, uint16_t addr, uint8_t *nid, + const uint8_t **enc, const uint8_t **priv); +int friend_cred_set(struct friend_cred *cred, uint8_t idx, const uint8_t net_key[16]); +void friend_cred_refresh(uint16_t net_idx); int friend_cred_update(struct bt_mesh_subnet *sub); -struct friend_cred *friend_cred_create(struct bt_mesh_subnet *sub, u16_t addr, - u16_t lpn_counter, u16_t frnd_counter); +struct friend_cred *friend_cred_create(struct bt_mesh_subnet *sub, uint16_t addr, + uint16_t lpn_counter, uint16_t frnd_counter); void friend_cred_clear(struct friend_cred *cred); -int friend_cred_del(u16_t net_idx, u16_t addr); +int friend_cred_del(uint16_t net_idx, uint16_t addr); static inline void send_cb_finalize(const struct bt_mesh_send_cb *cb, void *cb_data) diff --git a/nimble/host/mesh/src/pb_adv.c b/nimble/host/mesh/src/pb_adv.c index ab48e7d19..473ea90bd 100644 --- a/nimble/host/mesh/src/pb_adv.c +++ b/nimble/host/mesh/src/pb_adv.c @@ -72,7 +72,7 @@ enum { }; struct pb_adv { - u32_t id; /* Link ID */ + uint32_t id; /* Link ID */ ATOMIC_DEFINE(flags, NUM_FLAGS); @@ -80,22 +80,22 @@ struct pb_adv { void *cb_data; struct { - u8_t id; /* Most recent transaction ID */ - u8_t seg; /* Bit-field of unreceived segments */ - u8_t last_seg; /* Last segment (to check length) */ - u8_t fcs; /* Expected FCS value */ + uint8_t id; /* Most recent transaction ID */ + uint8_t seg; /* Bit-field of unreceived segments */ + uint8_t last_seg; /* Last segment (to check length) */ + uint8_t fcs; /* Expected FCS value */ struct os_mbuf *buf; } rx; struct { /* Start timestamp of the transaction */ - s64_t start; + int64_t start; /* Transaction id */ - u8_t id; + uint8_t id; /* Current ack id */ - u8_t pending_ack; + uint8_t pending_ack; /* Pending outgoing buffer(s) */ struct os_mbuf *buf[3]; @@ -113,16 +113,16 @@ struct pb_adv { }; struct prov_rx { - u32_t link_id; - u8_t xact_id; - u8_t gpc; + uint32_t link_id; + uint8_t xact_id; + uint8_t gpc; }; static struct os_mbuf rx_buf = { .om_len = 65 }; static struct pb_adv link = { .rx = { .buf = &rx_buf } }; -static void gen_prov_ack_send(u8_t xact_id); +static void gen_prov_ack_send(uint8_t xact_id); static void link_open(struct prov_rx *rx, struct os_mbuf *buf); static void link_ack(struct prov_rx *rx, struct os_mbuf *buf); static void link_close(struct prov_rx *rx, struct os_mbuf *buf); @@ -140,7 +140,7 @@ static struct bt_mesh_send_cb buf_sent_cb = { .end = buf_sent, }; -static u8_t last_seg(u8_t len) +static uint8_t last_seg(uint8_t len) { if (len <= START_PAYLOAD_MAX) { return 0; @@ -169,7 +169,7 @@ static void free_segments(void) } } -static u8_t next_transaction_id(u8_t id) +static uint8_t next_transaction_id(uint8_t id) { return (((id + 1) & XACT_ID_MAX) | (id & (XACT_ID_MAX+1))); } @@ -217,7 +217,7 @@ static void close_link(enum prov_bearer_link_status reason) cb->link_closed(&pb_adv, cb_data, reason); } -static struct os_mbuf *adv_buf_create(u8_t retransmits) +static struct os_mbuf *adv_buf_create(uint8_t retransmits) { struct os_mbuf *buf; @@ -232,9 +232,9 @@ static struct os_mbuf *adv_buf_create(u8_t retransmits) return buf; } -static void ack_complete(u16_t duration, int err, void *user_data) +static void ack_complete(uint16_t duration, int err, void *user_data) { - BT_DBG("xact 0x%x complete", (u8_t)link.tx.pending_ack); + BT_DBG("xact 0x%x complete", (uint8_t)link.tx.pending_ack); atomic_clear_bit(link.flags, ACK_PENDING); } @@ -243,7 +243,7 @@ static bool ack_pending(void) return atomic_test_bit(link.flags, ACK_PENDING); } -static void prov_failed(u8_t err) +static void prov_failed(uint8_t err) { BT_DBG("%u", err); link.cb->error(&pb_adv, link.cb_data, err); @@ -282,7 +282,7 @@ static void protocol_timeout(struct ble_npl_event *work) * Generic provisioning ******************************************************************************/ -static void gen_prov_ack_send(u8_t xact_id) +static void gen_prov_ack_send(uint8_t xact_id) { static const struct bt_mesh_send_cb cb = { .start = ack_complete, @@ -321,7 +321,7 @@ static void gen_prov_ack_send(u8_t xact_id) static void gen_prov_cont(struct prov_rx *rx, struct os_mbuf *buf) { - u8_t seg = CONT_SEG_INDEX(rx->gpc); + uint8_t seg = CONT_SEG_INDEX(rx->gpc); BT_DBG("len %u, seg_index %u", buf->om_len, seg); @@ -506,7 +506,7 @@ static void gen_prov_ctl(struct prov_rx *rx, struct os_mbuf *buf) static const struct { void (*func)(struct prov_rx *rx, struct os_mbuf *buf); bool require_link; - u8_t min_len; + uint8_t min_len; } gen_prov[] = { { gen_prov_start, true, 3 }, { gen_prov_ack, true, 0 }, @@ -609,7 +609,7 @@ static void prov_retransmit(struct ble_npl_event *work) } } -static int bearer_ctl_send(u8_t op, const void *data, u8_t data_len, +static int bearer_ctl_send(uint8_t op, const void *data, uint8_t data_len, bool reliable) { struct os_mbuf *buf; @@ -646,7 +646,7 @@ static int prov_send_adv(struct os_mbuf *msg, prov_bearer_send_complete_t cb, void *cb_data) { struct os_mbuf *start, *buf; - u8_t seg_len, seg_id; + uint8_t seg_len, seg_id; prov_clear_tx(); k_delayed_work_submit(&link.prot_timer, PROTOCOL_TIMEOUT); @@ -803,7 +803,7 @@ void bt_mesh_pb_adv_recv(struct os_mbuf *buf) gen_prov_recv(&rx, buf); } -static int prov_link_open(const u8_t uuid[16], s32_t timeout, +static int prov_link_open(const uint8_t uuid[16], int32_t timeout, const struct prov_bearer_cb *cb, void *cb_data) { BT_DBG("uuid %s", bt_hex(uuid, 16)); diff --git a/nimble/host/mesh/src/pb_gatt.c b/nimble/host/mesh/src/pb_gatt.c index d842d5078..d1a03b7ff 100644 --- a/nimble/host/mesh/src/pb_gatt.c +++ b/nimble/host/mesh/src/pb_gatt.c @@ -22,11 +22,11 @@ struct prov_link { const struct prov_bearer_cb *cb; void *cb_data; struct { - u8_t id; /* Transaction ID */ - u8_t prev_id; /* Previous Transaction ID */ - u8_t seg; /* Bit-field of unreceived segments */ - u8_t last_seg; /* Last segment (to check length) */ - u8_t fcs; /* Expected FCS value */ + uint8_t id; /* Transaction ID */ + uint8_t prev_id; /* Previous Transaction ID */ + uint8_t seg; /* Bit-field of unreceived segments */ + uint8_t last_seg; /* Last segment (to check length) */ + uint8_t fcs; /* Expected FCS value */ struct os_mbuf *buf; } rx; struct k_delayed_work prot_timer; diff --git a/nimble/host/mesh/src/prov.c b/nimble/host/mesh/src/prov.c index 13d7d0b74..c673f6cae 100644 --- a/nimble/host/mesh/src/prov.c +++ b/nimble/host/mesh/src/prov.c @@ -81,31 +81,31 @@ enum { struct provisioner_link { struct bt_mesh_cdb_node *node; - u16_t addr; - u16_t net_idx; - u8_t attention_duration; - u8_t uuid[16]; + uint16_t addr; + uint16_t net_idx; + uint8_t attention_duration; + uint8_t uuid[16]; }; struct prov_link { ATOMIC_DEFINE(flags, NUM_FLAGS); struct provisioner_link provisioner[PROVISIONER_LINK]; - u8_t dhkey[32]; /* Calculated DHKey */ - u8_t expect; /* Next expected PDU */ + uint8_t dhkey[32]; /* Calculated DHKey */ + uint8_t expect; /* Next expected PDU */ - u8_t oob_method; - u8_t oob_action; - u8_t oob_size; + uint8_t oob_method; + uint8_t oob_action; + uint8_t oob_size; - u8_t conf[16]; /* Remote Confirmation */ - u8_t rand[16]; /* Local Random */ - u8_t auth[16]; /* Authentication Value */ + uint8_t conf[16]; /* Remote Confirmation */ + uint8_t rand[16]; /* Local Random */ + uint8_t auth[16]; /* Authentication Value */ - u8_t conf_salt[16]; /* ConfirmationSalt */ - u8_t conf_key[16]; /* ConfirmationKey */ - u8_t conf_inputs[145]; /* ConfirmationInputs */ - u8_t prov_salt[16]; /* Provisioning Salt */ + uint8_t conf_salt[16]; /* ConfirmationSalt */ + uint8_t conf_key[16]; /* ConfirmationKey */ + uint8_t conf_inputs[145]; /* ConfirmationInputs */ + uint8_t prov_salt[16]; /* Provisioning Salt */ const struct prov_bearer *bearer; }; @@ -117,7 +117,7 @@ static struct prov_link link; static const struct bt_mesh_prov *prov; static void send_pub_key(void); -static void pub_key_ready(const u8_t *pkey); +static void pub_key_ready(const uint8_t *pkey); static void start_sent(int err, void *cb_data); static int reset_state(void) @@ -154,7 +154,7 @@ static inline int prov_send(struct os_mbuf *buf, return link.bearer->send(buf, cb, NULL); } -static void prov_buf_init(struct os_mbuf *buf, u8_t type) +static void prov_buf_init(struct os_mbuf *buf, uint8_t type) { net_buf_simple_init(buf, PROV_BEARER_BUF_HEADROOM); net_buf_simple_add_u8(buf, type); @@ -168,7 +168,7 @@ static void prov_link_close(enum prov_bearer_link_status status) link.bearer->link_close(status); } -static void prov_send_fail_msg(u8_t err) +static void prov_send_fail_msg(uint8_t err) { struct os_mbuf *buf = PROV_BUF(2); @@ -186,7 +186,7 @@ static void prov_send_fail_msg(u8_t err) os_mbuf_free_chain(buf); } -static void prov_fail(u8_t reason) +static void prov_fail(uint8_t reason) { /* According to Bluetooth Mesh Specification v1.0.1, Section 5.4.4, the * provisioner just closes the link when something fails, while the @@ -200,7 +200,7 @@ static void prov_fail(u8_t reason) } } -static void prov_invite(const u8_t *data) +static void prov_invite(const uint8_t *data) { struct os_mbuf *buf = PROV_BUF(12); @@ -310,9 +310,9 @@ static void start_sent(int err, void *cb_data) } } -static void prov_capabilities(const u8_t *data) +static void prov_capabilities(const uint8_t *data) { - u16_t algorithms, output_action, input_action; + uint16_t algorithms, output_action, input_action; if (!IS_ENABLED(CONFIG_BT_MESH_PROVISIONER)) { return; @@ -356,7 +356,7 @@ static void prov_capabilities(const u8_t *data) send_start(); } -static bt_mesh_output_action_t output_action(u8_t action) +static bt_mesh_output_action_t output_action(uint8_t action) { switch (action) { case OUTPUT_OOB_BLINK: @@ -374,7 +374,7 @@ static bt_mesh_output_action_t output_action(u8_t action) } } -static bt_mesh_input_action_t input_action(u8_t action) +static bt_mesh_input_action_t input_action(uint8_t action) { switch (action) { case INPUT_OOB_PUSH: @@ -390,7 +390,7 @@ static bt_mesh_input_action_t input_action(u8_t action) } } -static int prov_auth(u8_t method, u8_t action, u8_t size) +static int prov_auth(uint8_t method, uint8_t action, uint8_t size) { bt_mesh_output_action_t output; bt_mesh_input_action_t input; @@ -431,7 +431,7 @@ static int prov_auth(u8_t method, u8_t action, u8_t size) if (output == BT_MESH_DISPLAY_STRING) { unsigned char str[9]; - u8_t i; + uint8_t i; bt_rand(str, size); @@ -451,9 +451,9 @@ static int prov_auth(u8_t method, u8_t action, u8_t size) return prov->output_string((char *)str); } else { - u32_t div[8] = { 10, 100, 1000, 10000, 100000, + uint32_t div[8] = { 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000 }; - u32_t num; + uint32_t num; bt_rand(&num, sizeof(num)); num %= div[size - 1]; @@ -491,7 +491,7 @@ static int prov_auth(u8_t method, u8_t action, u8_t size) } } -static void prov_start(const u8_t *data) +static void prov_start(const uint8_t *data) { BT_DBG("Algorithm: 0x%02x", data[0]); BT_DBG("Public Key: 0x%02x", data[1]); @@ -593,7 +593,7 @@ static void send_input_complete(void) os_mbuf_free_chain(buf); } -int bt_mesh_input_number(u32_t num) +int bt_mesh_input_number(uint32_t num) { BT_DBG("%u", (unsigned) num); @@ -626,7 +626,7 @@ int bt_mesh_input_string(const char *str) static void send_pub_key(void) { struct os_mbuf *buf = PROV_BUF(65); - const u8_t *key; + const uint8_t *key; key = bt_pub_key_get(); if (!key) { @@ -671,7 +671,7 @@ done: os_mbuf_free_chain(buf); } -static void prov_dh_key_cb(const u8_t dhkey[32]) +static void prov_dh_key_cb(const uint8_t dhkey[32]) { BT_DBG("%p", dhkey); @@ -694,7 +694,7 @@ static void prov_dh_key_cb(const u8_t dhkey[32]) static void prov_dh_key_gen(void) { - u8_t remote_pk_le[64], *remote_pk; + uint8_t remote_pk_le[64], *remote_pk; if (atomic_test_bit(link.flags, PROVISIONER)) { remote_pk = &link.conf_inputs[81]; @@ -715,7 +715,7 @@ static void prov_dh_key_gen(void) } } -static void prov_pub_key(const u8_t *data) +static void prov_pub_key(const uint8_t *data) { BT_DBG("Remote Public Key: %s", bt_hex(data, 64)); @@ -742,7 +742,7 @@ static void prov_pub_key(const u8_t *data) } -static void pub_key_ready(const u8_t *pkey) +static void pub_key_ready(const uint8_t *pkey) { if (!pkey) { BT_WARN("Public key not available"); @@ -768,7 +768,7 @@ static void notify_input_complete(void) } } -static void prov_input_complete(const u8_t *data) +static void prov_input_complete(const uint8_t *data) { BT_DBG(""); notify_input_complete(); @@ -778,8 +778,8 @@ static void send_prov_data(void) { struct os_mbuf *pdu = PROV_BUF(34); struct bt_mesh_cdb_subnet *sub; - u8_t session_key[16]; - u8_t nonce[13]; + uint8_t session_key[16]; + uint8_t nonce[13]; int err; err = bt_mesh_session_key(link.dhkey, link.prov_salt, session_key); @@ -849,7 +849,7 @@ done: os_mbuf_free_chain(pdu); } -static void prov_complete(const u8_t *data) +static void prov_complete(const uint8_t *data) { if (!IS_ENABLED(CONFIG_BT_MESH_PROVISIONER)) { return; @@ -895,10 +895,10 @@ done: os_mbuf_free_chain(rnd); } -static void prov_random(const u8_t *data) +static void prov_random(const uint8_t *data) { - u8_t conf_verify[16]; - const u8_t *prov_rand, *dev_rand; + uint8_t conf_verify[16]; + const uint8_t *prov_rand, *dev_rand; BT_DBG("Remote Random: %s", bt_hex(data, 16)); @@ -941,7 +941,7 @@ static void prov_random(const u8_t *data) } } -static void prov_confirm(const u8_t *data) +static void prov_confirm(const uint8_t *data) { BT_DBG("Remote Confirm: %s", bt_hex(data, 16)); @@ -961,17 +961,17 @@ static inline bool is_pb_gatt(void) return link.bearer && link.bearer->type == BT_MESH_PROV_GATT; } -static void prov_data(const u8_t *data) +static void prov_data(const uint8_t *data) { struct os_mbuf *msg = PROV_BUF(1); - u8_t session_key[16]; - u8_t nonce[13]; - u8_t dev_key[16]; - u8_t pdu[25]; - u8_t flags; - u32_t iv_index; - u16_t addr; - u16_t net_idx; + uint8_t session_key[16]; + uint8_t nonce[13]; + uint8_t dev_key[16]; + uint8_t pdu[25]; + uint8_t flags; + uint32_t iv_index; + uint16_t addr; + uint16_t net_idx; int err; bool identity_enable; @@ -1052,15 +1052,15 @@ done: os_mbuf_free_chain(msg); } -static void prov_failed(const u8_t *data) +static void prov_failed(const uint8_t *data) { BT_WARN("Error: 0x%02x", data[0]); reset_state(); } static const struct { - void (*func)(const u8_t *data); - u16_t len; + void (*func)(const uint8_t *data); + uint16_t len; } prov_handlers[] = { { prov_invite, 1 }, { prov_capabilities, 11 }, @@ -1077,7 +1077,7 @@ static const struct { static void prov_recv(const struct prov_bearer *bearer, void *cb_data, struct os_mbuf *buf) { - u8_t type = buf->om_data[0]; + uint8_t type = buf->om_data[0]; BT_DBG("type 0x%02x len %u", type, buf->om_len); if (type != PROV_FAILED && type != link.expect) { @@ -1132,7 +1132,7 @@ static void prov_link_closed(const struct prov_bearer *bearer, void *cb_data, } static void prov_bearer_error(const struct prov_bearer *bearer, void *cb_data, - u8_t err) + uint8_t err) { prov_fail(err); } @@ -1145,8 +1145,8 @@ static const struct prov_bearer_cb prov_bearer_cb = { }; #if defined(CONFIG_BT_MESH_PB_ADV) -int bt_mesh_pb_adv_open(const u8_t uuid[16], u16_t net_idx, u16_t addr, - u8_t attention_duration) +int bt_mesh_pb_adv_open(const uint8_t uuid[16], uint16_t net_idx, uint16_t addr, + uint8_t attention_duration) { int err; @@ -1247,7 +1247,7 @@ int bt_mesh_prov_disable(bt_mesh_prov_bearer_t bearers) return 0; } -void bt_mesh_prov_complete(u16_t net_idx, u16_t addr) +void bt_mesh_prov_complete(uint16_t net_idx, uint16_t addr) { if (prov->complete) { prov->complete(net_idx, addr); diff --git a/nimble/host/mesh/src/prov.h b/nimble/host/mesh/src/prov.h index 22560a749..96e5f3c86 100644 --- a/nimble/host/mesh/src/prov.h +++ b/nimble/host/mesh/src/prov.h @@ -23,8 +23,8 @@ #define PROV_ERR_UNEXP_ERR 0x07 #define PROV_ERR_ADDR 0x08 -int bt_mesh_pb_adv_open(const u8_t uuid[16], u16_t net_idx, u16_t addr, - u8_t attention_duration); +int bt_mesh_pb_adv_open(const uint8_t uuid[16], uint16_t net_idx, uint16_t addr, + uint8_t attention_duration); void bt_mesh_pb_adv_recv(struct os_mbuf *buf); @@ -40,8 +40,8 @@ int bt_mesh_prov_init(const struct bt_mesh_prov *prov); void bt_mesh_prov_reset_link(void); -void bt_mesh_prov_complete(u16_t net_idx, u16_t addr); -void bt_mesh_prov_node_added(u16_t net_idx, u16_t addr, u8_t num_elem); +void bt_mesh_prov_complete(uint16_t net_idx, uint16_t addr); +void bt_mesh_prov_node_added(uint16_t net_idx, uint16_t addr, uint8_t num_elem); void bt_mesh_prov_reset(void); #endif diff --git a/nimble/host/mesh/src/prov_bearer.h b/nimble/host/mesh/src/prov_bearer.h index 699c3880b..d927d1101 100644 --- a/nimble/host/mesh/src/prov_bearer.h +++ b/nimble/host/mesh/src/prov_bearer.h @@ -35,7 +35,7 @@ struct prov_bearer_cb { enum prov_bearer_link_status reason); void (*error)(const struct prov_bearer *bearer, void *cb_data, - u8_t err); + uint8_t err); void (*recv)(const struct prov_bearer *bearer, void *cb_data, struct os_mbuf *buf); @@ -93,7 +93,7 @@ struct prov_bearer { * * @return Zero on success, or (negative) error code otherwise. */ - int (*link_open)(const u8_t uuid[16], s32_t timeout, + int (*link_open)(const uint8_t uuid[16], int32_t timeout, const struct prov_bearer_cb *cb, void *cb_data); /** @brief Close the current link. diff --git a/nimble/host/mesh/src/proxy.c b/nimble/host/mesh/src/proxy.c index afd264b4f..0c040916e 100644 --- a/nimble/host/mesh/src/proxy.c +++ b/nimble/host/mesh/src/proxy.c @@ -111,14 +111,14 @@ static bool prov_fast_adv; static struct bt_mesh_proxy_client { uint16_t conn_handle; - u16_t filter[MYNEWT_VAL(BLE_MESH_PROXY_FILTER_SIZE)]; + uint16_t filter[MYNEWT_VAL(BLE_MESH_PROXY_FILTER_SIZE)]; enum __packed { NONE, WHITELIST, BLACKLIST, PROV, } filter_type; - u8_t msg_type; + uint8_t msg_type; #if (MYNEWT_VAL(BLE_MESH_GATT_PROXY)) struct ble_npl_callout send_beacons; #endif @@ -198,13 +198,13 @@ static struct bt_mesh_proxy_client *find_client(uint16_t conn_handle) /* Next subnet in queue to be advertised */ static int next_idx; -static int proxy_segment_and_send(uint16_t conn_handle, u8_t type, +static int proxy_segment_and_send(uint16_t conn_handle, uint8_t type, struct os_mbuf *msg); static int filter_set(struct bt_mesh_proxy_client *client, struct os_mbuf *buf) { - u8_t type; + uint8_t type; if (buf->om_len < 1) { BT_WARN("Too short Filter Set message"); @@ -231,7 +231,7 @@ static int filter_set(struct bt_mesh_proxy_client *client, return 0; } -static void filter_add(struct bt_mesh_proxy_client *client, u16_t addr) +static void filter_add(struct bt_mesh_proxy_client *client, uint16_t addr) { int i; @@ -255,7 +255,7 @@ static void filter_add(struct bt_mesh_proxy_client *client, u16_t addr) } } -static void filter_remove(struct bt_mesh_proxy_client *client, u16_t addr) +static void filter_remove(struct bt_mesh_proxy_client *client, uint16_t addr) { int i; @@ -282,7 +282,7 @@ static void send_filter_status(struct bt_mesh_proxy_client *client, .ctx = &rx->ctx, .src = bt_mesh_primary_addr(), }; - u16_t filter_size; + uint16_t filter_size; int i, err; /* Configuration messages always have dst unassigned */ @@ -324,7 +324,7 @@ static void proxy_cfg(struct bt_mesh_proxy_client *client) { struct os_mbuf *buf = NET_BUF_SIMPLE(29); struct bt_mesh_net_rx rx; - u8_t opcode; + uint8_t opcode; int err; err = bt_mesh_net_decode(client->buf, BT_MESH_NET_IF_PROXY_CFG, @@ -352,7 +352,7 @@ static void proxy_cfg(struct bt_mesh_proxy_client *client) break; case CFG_FILTER_ADD: while (buf->om_len >= 2) { - u16_t addr; + uint16_t addr; addr = net_buf_simple_pull_be16(buf); filter_add(client, addr); @@ -361,7 +361,7 @@ static void proxy_cfg(struct bt_mesh_proxy_client *client) break; case CFG_FILTER_REMOVE: while (buf->om_len >= 2) { - u16_t addr; + uint16_t addr; addr = net_buf_simple_pull_be16(buf); filter_remove(client, addr); @@ -530,8 +530,8 @@ static int proxy_recv(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) { struct bt_mesh_proxy_client *client; - const u8_t *data = ctxt->om->om_data; - u16_t len = ctxt->om->om_len; + const uint8_t *data = ctxt->om->om_data; + uint16_t len = ctxt->om->om_len; client = find_client(conn_handle); @@ -888,7 +888,7 @@ int bt_mesh_proxy_gatt_disable(void) return 0; } -void bt_mesh_proxy_addr_add(struct os_mbuf *buf, u16_t addr) +void bt_mesh_proxy_addr_add(struct os_mbuf *buf, uint16_t addr) { struct bt_mesh_proxy_client *client = NULL; int i; @@ -912,7 +912,7 @@ void bt_mesh_proxy_addr_add(struct os_mbuf *buf, u16_t addr) } static bool client_filter_match(struct bt_mesh_proxy_client *client, - u16_t addr) + uint16_t addr) { int i; @@ -943,7 +943,7 @@ static bool client_filter_match(struct bt_mesh_proxy_client *client, return false; } -bool bt_mesh_proxy_relay(struct os_mbuf *buf, u16_t dst) +bool bt_mesh_proxy_relay(struct os_mbuf *buf, uint16_t dst) { bool relayed = false; int i; @@ -979,7 +979,7 @@ bool bt_mesh_proxy_relay(struct os_mbuf *buf, u16_t dst) #endif /* MYNEWT_VAL(BLE_MESH_GATT_PROXY) */ -static int proxy_send(uint16_t conn_handle, const void *data, u16_t len) +static int proxy_send(uint16_t conn_handle, const void *data, uint16_t len) { struct os_mbuf *om; @@ -1004,10 +1004,10 @@ static int proxy_send(uint16_t conn_handle, const void *data, u16_t len) return 0; } -static int proxy_segment_and_send(uint16_t conn_handle, u8_t type, +static int proxy_segment_and_send(uint16_t conn_handle, uint8_t type, struct os_mbuf *msg) { - u16_t mtu; + uint16_t mtu; BT_DBG("conn_handle %d type 0x%02x len %u: %s", conn_handle, type, msg->om_len, bt_hex(msg->om_data, msg->om_len)); @@ -1038,7 +1038,7 @@ static int proxy_segment_and_send(uint16_t conn_handle, u8_t type, return 0; } -int bt_mesh_proxy_send(uint16_t conn_handle, u8_t type, +int bt_mesh_proxy_send(uint16_t conn_handle, uint8_t type, struct os_mbuf *msg) { struct bt_mesh_proxy_client *client = find_client(conn_handle); @@ -1057,7 +1057,7 @@ int bt_mesh_proxy_send(uint16_t conn_handle, u8_t type, } #if (MYNEWT_VAL(BLE_MESH_PB_GATT)) -static u8_t prov_svc_data[20] = { 0x27, 0x18, }; +static uint8_t prov_svc_data[20] = { 0x27, 0x18, }; static const struct bt_data prov_ad[] = { BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), @@ -1076,7 +1076,7 @@ static const struct bt_data prov_ad[] = { #define NODE_ID_TIMEOUT K_SECONDS(CONFIG_BT_MESH_NODE_ID_TIMEOUT) -static u8_t proxy_svc_data[NODE_ID_LEN] = { 0x28, 0x18, }; +static uint8_t proxy_svc_data[NODE_ID_LEN] = { 0x28, 0x18, }; static const struct bt_data node_id_ad[] = { BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), @@ -1092,7 +1092,7 @@ static const struct bt_data net_id_ad[] = { static int node_id_adv(struct bt_mesh_subnet *sub) { - u8_t tmp[16]; + uint8_t tmp[16]; int err; BT_DBG(""); @@ -1194,9 +1194,9 @@ static int sub_count(void) return count; } -static s32_t gatt_proxy_advertise(struct bt_mesh_subnet *sub) +static int32_t gatt_proxy_advertise(struct bt_mesh_subnet *sub) { - s32_t remaining = K_FOREVER; + int32_t remaining = K_FOREVER; int subnet_count; BT_DBG(""); @@ -1212,7 +1212,7 @@ static s32_t gatt_proxy_advertise(struct bt_mesh_subnet *sub) } if (sub->node_id == BT_MESH_NODE_IDENTITY_RUNNING) { - u32_t active = k_uptime_get_32() - sub->node_id_start; + uint32_t active = k_uptime_get_32() - sub->node_id_start; if (active < NODE_ID_TIMEOUT) { remaining = NODE_ID_TIMEOUT - active; @@ -1232,7 +1232,7 @@ static s32_t gatt_proxy_advertise(struct bt_mesh_subnet *sub) subnet_count = sub_count(); BT_DBG("sub_count %u", subnet_count); if (subnet_count > 1) { - s32_t max_timeout; + int32_t max_timeout; /* We use NODE_ID_TIMEOUT as a starting point since it may * be less than 60 seconds. Divide this period into at least @@ -1300,7 +1300,7 @@ static size_t gatt_prov_adv_create(struct bt_data prov_sd[2]) } #endif /* PB_GATT */ -s32_t bt_mesh_proxy_adv_start(void) +int32_t bt_mesh_proxy_adv_start(void) { BT_DBG(""); diff --git a/nimble/host/mesh/src/proxy.h b/nimble/host/mesh/src/proxy.h index 64338a0a3..fe0fdf961 100644 --- a/nimble/host/mesh/src/proxy.h +++ b/nimble/host/mesh/src/proxy.h @@ -16,7 +16,7 @@ #include "mesh/mesh.h" -int bt_mesh_proxy_send(uint16_t conn_handle, u8_t type, struct os_mbuf *msg); +int bt_mesh_proxy_send(uint16_t conn_handle, uint8_t type, struct os_mbuf *msg); int bt_mesh_proxy_prov_enable(void); int bt_mesh_proxy_prov_disable(bool disconnect); @@ -29,14 +29,14 @@ void bt_mesh_proxy_beacon_send(struct bt_mesh_subnet *sub); struct os_mbuf *bt_mesh_proxy_get_buf(void); -s32_t bt_mesh_proxy_adv_start(void); +int32_t bt_mesh_proxy_adv_start(void); void bt_mesh_proxy_adv_stop(void); void bt_mesh_proxy_identity_start(struct bt_mesh_subnet *sub); void bt_mesh_proxy_identity_stop(struct bt_mesh_subnet *sub); -bool bt_mesh_proxy_relay(struct os_mbuf *buf, u16_t dst); -void bt_mesh_proxy_addr_add(struct os_mbuf *buf, u16_t addr); +bool bt_mesh_proxy_relay(struct os_mbuf *buf, uint16_t dst); +void bt_mesh_proxy_addr_add(struct os_mbuf *buf, uint16_t addr); int bt_mesh_proxy_init(void); diff --git a/nimble/host/mesh/src/settings.c b/nimble/host/mesh/src/settings.c index 87988f6d0..9980ea544 100644 --- a/nimble/host/mesh/src/settings.c +++ b/nimble/host/mesh/src/settings.c @@ -31,7 +31,7 @@ * gets deleted its struct becomes invalid and may be reused for other keys. */ struct key_update { - u16_t key_idx:12, /* AppKey or NetKey Index */ + uint16_t key_idx:12, /* AppKey or NetKey Index */ valid:1, /* 1 if this entry is valid, 0 if not */ app_key:1, /* 1 if this is an AppKey, 0 if a NetKey */ clear:1; /* 1 if key needs clearing, 0 if storing */ @@ -44,97 +44,97 @@ static struct k_delayed_work pending_store; /* Mesh network storage information */ struct net_val { - u16_t primary_addr; - u8_t dev_key[16]; + uint16_t primary_addr; + uint8_t dev_key[16]; } __packed; /* Sequence number storage */ struct seq_val { - u8_t val[3]; + uint8_t val[3]; } __packed; /* Heartbeat Publication storage */ struct hb_pub_val { - u16_t dst; - u8_t period; - u8_t ttl; - u16_t feat; - u16_t net_idx:12, + uint16_t dst; + uint8_t period; + uint8_t ttl; + uint16_t feat; + uint16_t net_idx:12, indefinite:1; }; /* Miscelaneous configuration server model states */ struct cfg_val { - u8_t net_transmit; - u8_t relay; - u8_t relay_retransmit; - u8_t beacon; - u8_t gatt_proxy; - u8_t frnd; - u8_t default_ttl; + uint8_t net_transmit; + uint8_t relay; + uint8_t relay_retransmit; + uint8_t beacon; + uint8_t gatt_proxy; + uint8_t frnd; + uint8_t default_ttl; }; /* IV Index & IV Update storage */ struct iv_val { - u32_t iv_index; - u8_t iv_update:1, + uint32_t iv_index; + uint8_t iv_update:1, iv_duration:7; } __packed; /* Replay Protection List storage */ struct rpl_val { - u32_t seq:24, + uint32_t seq:24, old_iv:1; }; /* NetKey storage information */ struct net_key_val { - u8_t kr_flag:1, + uint8_t kr_flag:1, kr_phase:7; - u8_t val[2][16]; + uint8_t val[2][16]; } __packed; /* AppKey storage information */ struct app_key_val { - u16_t net_idx; + uint16_t net_idx; bool updated; - u8_t val[2][16]; + uint8_t val[2][16]; } __packed; struct mod_pub_val { - u16_t addr; - u16_t key; - u8_t ttl; - u8_t retransmit; - u8_t period; - u8_t period_div:4, + uint16_t addr; + uint16_t key; + uint8_t ttl; + uint8_t retransmit; + uint8_t period; + uint8_t period_div:4, cred:1; }; /* Virtual Address information */ struct va_val { - u16_t ref; - u16_t addr; - u8_t uuid[16]; + uint16_t ref; + uint16_t addr; + uint8_t uuid[16]; } __packed; struct cdb_net_val { - u32_t iv_index; + uint32_t iv_index; bool iv_update; } __packed; /* Node storage information */ struct node_val { - u16_t net_idx; - u8_t num_elem; - u8_t flags; + uint16_t net_idx; + uint8_t num_elem; + uint8_t flags; #define F_NODE_CONFIGURED 0x01 - u8_t uuid[16]; - u8_t dev_key[16]; + uint8_t uuid[16]; + uint8_t dev_key[16]; } __packed; struct node_update { - u16_t addr; + uint16_t addr; bool clear; }; @@ -303,7 +303,7 @@ static int rpl_set(int argc, char **argv, char *val) struct bt_mesh_rpl *entry; struct rpl_val rpl; int len, err; - u16_t src; + uint16_t src; if (argc < 1) { BT_ERR("Invalid argc (%d)", argc); @@ -359,7 +359,7 @@ static int net_key_set(int argc, char **argv, char *val) struct bt_mesh_subnet *sub; struct net_key_val key; int len, i, err; - u16_t net_idx; + uint16_t net_idx; BT_DBG("argv[0] %s val %s", argv[0], val ? val : "(null)"); @@ -427,7 +427,7 @@ static int app_key_set(int argc, char **argv, char *val) { struct bt_mesh_app_key *app; struct app_key_val key; - u16_t app_idx; + uint16_t app_idx; int len, err; BT_DBG("argv[0] %s val %s", argv[0], val ? val : "(null)"); @@ -671,8 +671,8 @@ static int mod_set_pub(struct bt_mesh_model *mod, char *val) static int mod_set(bool vnd, int argc, char **argv, char *val) { struct bt_mesh_model *mod; - u8_t elem_idx, mod_idx; - u16_t mod_key; + uint8_t elem_idx, mod_idx; + uint16_t mod_key; if (argc < 2) { BT_ERR("Too small argc (%d)", argc); @@ -732,7 +732,7 @@ static int va_set(int argc, char **argv, char *val) { struct va_val va; struct label *lab; - u16_t index; + uint16_t index; int len, err; if (argc < 1) { @@ -808,7 +808,7 @@ static int cdb_node_set(int argc, char *str) { struct bt_mesh_cdb_node *node; struct node_val val; - u16_t addr; + uint16_t addr; int len, err; if (argc < 1) { @@ -869,7 +869,7 @@ static int cdb_subnet_set(int argc, char *name) { struct bt_mesh_cdb_subnet *sub; struct net_key_val key; - u16_t net_idx; + uint16_t net_idx; int len, len_rd, err; if (!name) { @@ -931,7 +931,7 @@ static int cdb_app_key_set(int argc, char *name) { struct bt_mesh_cdb_app_key *app; struct app_key_val key; - u16_t app_idx; + uint16_t app_idx; int len_rd, err; app_idx = strtol(name, NULL, 16); @@ -1095,7 +1095,7 @@ static void commit_mod(struct bt_mesh_model *mod, struct bt_mesh_elem *elem, { if (mod->pub && mod->pub->update && mod->pub->addr != BT_MESH_ADDR_UNASSIGNED) { - s32_t ms = bt_mesh_model_pub_period_get(mod); + int32_t ms = bt_mesh_model_pub_period_get(mod); if (ms) { BT_DBG("Starting publish timer (period %u ms)", (unsigned) ms); @@ -1189,7 +1189,7 @@ static int mesh_commit(void) static void schedule_store(int flag) { - s32_t timeout, remaining; + int32_t timeout, remaining; atomic_set_bit(bt_mesh.flags, flag); @@ -1490,7 +1490,7 @@ static void clear_cfg(void) } } -static void clear_app_key(u16_t app_idx) +static void clear_app_key(uint16_t app_idx) { char path[20]; int err; @@ -1506,7 +1506,7 @@ static void clear_app_key(u16_t app_idx) } } -static void clear_net_key(u16_t net_idx) +static void clear_net_key(uint16_t net_idx) { char path[20]; int err; @@ -1705,7 +1705,7 @@ static void store_cdb_node(const struct bt_mesh_cdb_node *node) } } -static void clear_cdb_node(u16_t addr) +static void clear_cdb_node(uint16_t addr) { char path[30]; int err; @@ -1783,7 +1783,7 @@ static void store_cdb_subnet(const struct bt_mesh_cdb_subnet *sub) } } -static void clear_cdb_subnet(u16_t net_idx) +static void clear_cdb_subnet(uint16_t net_idx) { char path[30]; int err; @@ -1823,7 +1823,7 @@ static void store_cdb_app_key(const struct bt_mesh_cdb_app_key *app) } } -static void clear_cdb_app_key(u16_t app_idx) +static void clear_cdb_app_key(uint16_t app_idx) { char path[30]; int err; @@ -1882,7 +1882,7 @@ static void store_pending_cdb_keys(void) } } -static struct node_update *cdb_node_update_find(u16_t addr, +static struct node_update *cdb_node_update_find(uint16_t addr, struct node_update **free_slot) { struct node_update *match; @@ -1910,7 +1910,7 @@ static struct node_update *cdb_node_update_find(u16_t addr, static void encode_mod_path(struct bt_mesh_model *mod, bool vnd, const char *key, char *path, size_t path_len) { - u16_t mod_key = (((u16_t)mod->elem_idx << 8) | mod->mod_idx); + uint16_t mod_key = (((uint16_t)mod->elem_idx << 8) | mod->mod_idx); if (vnd) { snprintk(path, path_len, "bt_mesh/v/%x/%s", mod_key, key); @@ -1921,7 +1921,7 @@ static void encode_mod_path(struct bt_mesh_model *mod, bool vnd, static void store_pending_mod_bind(struct bt_mesh_model *mod, bool vnd) { - u16_t keys[CONFIG_BT_MESH_MODEL_KEY_COUNT]; + uint16_t keys[CONFIG_BT_MESH_MODEL_KEY_COUNT]; char buf[BT_SETTINGS_SIZE(sizeof(keys))]; char path[20]; int i, count, err; @@ -1957,7 +1957,7 @@ static void store_pending_mod_bind(struct bt_mesh_model *mod, bool vnd) static void store_pending_mod_sub(struct bt_mesh_model *mod, bool vnd) { - u16_t groups[CONFIG_BT_MESH_MODEL_GROUP_COUNT]; + uint16_t groups[CONFIG_BT_MESH_MODEL_GROUP_COUNT]; char buf[BT_SETTINGS_SIZE(sizeof(groups))]; char path[20]; int i, count, err; @@ -2061,7 +2061,7 @@ static void store_pending_va(void) struct va_val va; char path[18]; char *val; - u16_t i; + uint16_t i; int err = 0; for (i = 0; (lab = get_label(i)) != NULL; i++) { @@ -2184,7 +2184,7 @@ void bt_mesh_store_rpl(struct bt_mesh_rpl *entry) schedule_store(BT_MESH_RPL_PENDING); } -static struct key_update *key_update_find(bool app_key, u16_t key_idx, +static struct key_update *key_update_find(bool app_key, uint16_t key_idx, struct key_update **free_slot) { struct key_update *match; @@ -2423,7 +2423,7 @@ void bt_mesh_clear_cdb_node(struct bt_mesh_cdb_node *node) } /* TODO: Could be shared with key_update_find? */ -static struct key_update *cdb_key_update_find(bool app_key, u16_t key_idx, +static struct key_update *cdb_key_update_find(bool app_key, uint16_t key_idx, struct key_update **free_slot) { struct key_update *match; diff --git a/nimble/host/mesh/src/shell.c b/nimble/host/mesh/src/shell.c index eecd90708..d51ee093e 100644 --- a/nimble/host/mesh/src/shell.c +++ b/nimble/host/mesh/src/shell.c @@ -56,16 +56,16 @@ static struct os_eventq mesh_shell_queue; #define VND_MODEL_ID_1 0x1234 /* Default net, app & dev key values, unless otherwise specified */ -static const u8_t default_key[16] = { +static const uint8_t default_key[16] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, }; static struct { - u16_t local; - u16_t dst; - u16_t net_idx; - u16_t app_idx; + uint16_t local; + uint16_t dst; + uint16_t net_idx; + uint16_t app_idx; } net = { .local = BT_MESH_ADDR_UNASSIGNED, .dst = BT_MESH_ADDR_UNASSIGNED, @@ -94,12 +94,12 @@ static struct bt_mesh_cfg_srv cfg_srv = { #define CUR_FAULTS_MAX 4 -static u8_t cur_faults[CUR_FAULTS_MAX]; -static u8_t reg_faults[CUR_FAULTS_MAX * 2]; +static uint8_t cur_faults[CUR_FAULTS_MAX]; +static uint8_t reg_faults[CUR_FAULTS_MAX * 2]; -static void get_faults(u8_t *faults, u8_t faults_size, u8_t *dst, u8_t *count) +static void get_faults(uint8_t *faults, uint8_t faults_size, uint8_t *dst, uint8_t *count) { - u8_t i, limit = *count; + uint8_t i, limit = *count; for (i = 0, *count = 0; i < faults_size && *count < limit; i++) { if (faults[i]) { @@ -109,8 +109,8 @@ static void get_faults(u8_t *faults, u8_t faults_size, u8_t *dst, u8_t *count) } } -static int fault_get_cur(struct bt_mesh_model *model, u8_t *test_id, - u16_t *company_id, u8_t *faults, u8_t *fault_count) +static int fault_get_cur(struct bt_mesh_model *model, uint8_t *test_id, + uint16_t *company_id, uint8_t *faults, uint8_t *fault_count) { printk("Sending current faults\n"); @@ -122,8 +122,8 @@ static int fault_get_cur(struct bt_mesh_model *model, u8_t *test_id, return 0; } -static int fault_get_reg(struct bt_mesh_model *model, u16_t cid, - u8_t *test_id, u8_t *faults, u8_t *fault_count) +static int fault_get_reg(struct bt_mesh_model *model, uint16_t cid, + uint8_t *test_id, uint8_t *faults, uint8_t *fault_count) { if (cid != CID_VENDOR) { printk("Faults requested for unknown Company ID 0x%04x\n", cid); @@ -190,7 +190,7 @@ static struct bt_mesh_cfg_cli cfg_cli = { #endif /* MYNEWT_VAL(BLE_MESH_CFG_CLI) */ #if MYNEWT_VAL(BLE_MESH_HEALTH_CLI) -void show_faults(u8_t test_id, u16_t cid, u8_t *faults, size_t fault_count) +void show_faults(uint8_t test_id, uint16_t cid, uint8_t *faults, size_t fault_count) { size_t i; @@ -208,8 +208,8 @@ void show_faults(u8_t test_id, u16_t cid, u8_t *faults, size_t fault_count) } } -static void health_current_status(struct bt_mesh_health_cli *cli, u16_t addr, - u8_t test_id, u16_t cid, u8_t *faults, +static void health_current_status(struct bt_mesh_health_cli *cli, uint16_t addr, + uint8_t test_id, uint16_t cid, uint8_t *faults, size_t fault_count) { printk("Health Current Status from 0x%04x\n", addr); @@ -243,22 +243,22 @@ static struct bt_mesh_light_lightness_srv light_lightness_srv = { .set = light_model_light_lightness_set, }; -void bt_mesh_set_gen_onoff_srv_cb(int (*get)(struct bt_mesh_model *model, u8_t *state), - int (*set)(struct bt_mesh_model *model, u8_t state)) +void bt_mesh_set_gen_onoff_srv_cb(int (*get)(struct bt_mesh_model *model, uint8_t *state), + int (*set)(struct bt_mesh_model *model, uint8_t state)) { gen_onoff_srv.get = get; gen_onoff_srv.set = set; } -void bt_mesh_set_gen_level_srv_cb(int (*get)(struct bt_mesh_model *model, s16_t *level), - int (*set)(struct bt_mesh_model *model, s16_t level)) +void bt_mesh_set_gen_level_srv_cb(int (*get)(struct bt_mesh_model *model, int16_t *level), + int (*set)(struct bt_mesh_model *model, int16_t level)) { gen_level_srv.get = get; gen_level_srv.set = set; } -void bt_mesh_set_light_lightness_srv_cb(int (*get)(struct bt_mesh_model *model, s16_t *level), - int (*set)(struct bt_mesh_model *model, s16_t level)) +void bt_mesh_set_light_lightness_srv_cb(int (*get)(struct bt_mesh_model *model, int16_t *level), + int (*set)(struct bt_mesh_model *model, int16_t level)) { light_lightness_srv.get = get; light_lightness_srv.set = set; @@ -298,7 +298,7 @@ static const struct bt_mesh_comp comp = { .elem_count = ARRAY_SIZE(elements), }; -static u8_t hex2val(char c) +static uint8_t hex2val(char c) { if (c >= '0' && c <= '9') { return c - '0'; @@ -358,7 +358,7 @@ size_t bin2hex(const uint8_t *buf, size_t buflen, char *hex, size_t hexlen) return 2 * buflen; } -static size_t hex2bin(const char *hex, u8_t *bin, size_t bin_len) +static size_t hex2bin(const char *hex, uint8_t *bin, size_t bin_len) { size_t len = 0; @@ -376,7 +376,7 @@ static size_t hex2bin(const char *hex, u8_t *bin, size_t bin_len) return len; } -static void prov_complete(u16_t net_idx, u16_t addr) +static void prov_complete(uint16_t net_idx, uint16_t addr) { printk("Local node provisioned, net_idx 0x%04x address 0x%04x\n", net_idx, addr); @@ -385,8 +385,8 @@ static void prov_complete(u16_t net_idx, u16_t addr) net.dst = addr; } -static void prov_node_added(u16_t net_idx, u8_t uuid[16], u16_t addr, - u8_t num_elem) +static void prov_node_added(uint16_t net_idx, uint8_t uuid[16], uint16_t addr, + uint8_t num_elem) { printk("Node provisioned, net_idx 0x%04x address " "0x%04x elements %d", net_idx, addr, num_elem); @@ -418,7 +418,7 @@ static int output_string(const char *str) } static bt_mesh_input_action_t input_act; -static u8_t input_size; +static uint8_t input_size; static int cmd_input_num(int argc, char *argv[]) { @@ -486,7 +486,7 @@ struct shell_cmd_help cmd_input_str_help = { NULL, "", NULL }; -static int input(bt_mesh_input_action_t act, u8_t size) +static int input(bt_mesh_input_action_t act, uint8_t size) { switch (act) { case BT_MESH_ENTER_NUMBER: @@ -530,9 +530,9 @@ static void link_close(bt_mesh_prov_bearer_t bearer) printk("Provisioning link closed on %s\n", bearer2str(bearer)); } -static u8_t dev_uuid[16] = MYNEWT_VAL(BLE_MESH_DEV_UUID); +static uint8_t dev_uuid[16] = MYNEWT_VAL(BLE_MESH_DEV_UUID); -static u8_t static_val[16]; +static uint8_t static_val[16]; static struct bt_mesh_prov prov = { .uuid = dev_uuid, @@ -583,7 +583,7 @@ struct shell_cmd_help cmd_static_oob_help = { static int cmd_uuid(int argc, char *argv[]) { - u8_t uuid[16]; + uint8_t uuid[16]; size_t len; if (argc < 2) { @@ -614,7 +614,7 @@ static int cmd_reset(int argc, char *argv[]) return 0; } -static u8_t str2u8(const char *str) +static uint8_t str2u8(const char *str) { if (isdigit(str[0])) { return strtoul(str, NULL, 0); @@ -680,7 +680,7 @@ static int cmd_poll(int argc, char *argv[]) return 0; } -static void lpn_cb(u16_t friend_addr, bool established) +static void lpn_cb(uint16_t friend_addr, bool established) { if (established) { printk("Friendship (as LPN) established to Friend 0x%04x\n", @@ -877,7 +877,7 @@ static int cmd_rpl_clear(int argc, char *argv[]) #if MYNEWT_VAL(BLE_MESH_LOW_POWER) static int cmd_lpn_subscribe(int argc, char *argv[]) { - u16_t address; + uint16_t address; if (argc < 2) { return -EINVAL; @@ -898,7 +898,7 @@ struct shell_cmd_help cmd_lpn_subscribe_help = { static int cmd_lpn_unsubscribe(int argc, char *argv[]) { - u16_t address; + uint16_t address; if (argc < 2) { return -EINVAL; @@ -961,7 +961,7 @@ struct shell_cmd_help cmd_iv_update_test_help = { int cmd_timeout(int argc, char *argv[]) { - s32_t timeout; + int32_t timeout; if (argc < 2) { timeout = bt_mesh_cfg_cli_timeout_get(); @@ -1001,7 +1001,7 @@ struct shell_cmd_help cmd_timeout_help = { static int cmd_get_comp(int argc, char *argv[]) { struct os_mbuf *comp = NET_BUF_SIMPLE(32); - u8_t status, page = 0x00; + uint8_t status, page = 0x00; int err = 0; if (argc > 1) { @@ -1029,8 +1029,8 @@ static int cmd_get_comp(int argc, char *argv[]) printk("\tFeatures 0x%04x\n", net_buf_simple_pull_le16(comp)); while (comp->om_len > 4) { - u8_t sig, vnd; - u16_t loc; + uint8_t sig, vnd; + uint16_t loc; int i; loc = net_buf_simple_pull_le16(comp); @@ -1051,7 +1051,7 @@ static int cmd_get_comp(int argc, char *argv[]) } for (i = 0; i < sig; i++) { - u16_t mod_id = net_buf_simple_pull_le16(comp); + uint16_t mod_id = net_buf_simple_pull_le16(comp); printk("\t\t\t0x%04x\n", mod_id); } @@ -1063,8 +1063,8 @@ static int cmd_get_comp(int argc, char *argv[]) } for (i = 0; i < vnd; i++) { - u16_t cid = net_buf_simple_pull_le16(comp); - u16_t mod_id = net_buf_simple_pull_le16(comp); + uint16_t cid = net_buf_simple_pull_le16(comp); + uint16_t mod_id = net_buf_simple_pull_le16(comp); printk("\t\t\tCompany 0x%04x: 0x%04x\n", cid, mod_id); } @@ -1081,13 +1081,13 @@ struct shell_cmd_help cmd_get_comp_help = { static int cmd_beacon(int argc, char *argv[]) { - u8_t status; + uint8_t status; int err; if (argc < 2) { err = bt_mesh_cfg_beacon_get(net.net_idx, net.dst, &status); } else { - u8_t val = str2u8(argv[1]); + uint8_t val = str2u8(argv[1]); err = bt_mesh_cfg_beacon_set(net.net_idx, net.dst, val, &status); @@ -1103,9 +1103,9 @@ static int cmd_beacon(int argc, char *argv[]) return 0; } -static void print_unprovisioned_beacon(u8_t uuid[16], +static void print_unprovisioned_beacon(uint8_t uuid[16], bt_mesh_prov_oob_info_t oob_info, - u32_t *uri_hash) + uint32_t *uri_hash) { char uuid_hex_str[32 + 1]; @@ -1118,7 +1118,7 @@ static void print_unprovisioned_beacon(u8_t uuid[16], static int cmd_beacon_listen(int argc, char *argv[]) { - u8_t val = str2u8(argv[1]); + uint8_t val = str2u8(argv[1]); if (val) { prov.unprovisioned_beacon = print_unprovisioned_beacon; @@ -1139,13 +1139,13 @@ struct shell_cmd_help cmd_beacon_listen_help = { static int cmd_ttl(int argc, char *argv[]) { - u8_t ttl; + uint8_t ttl; int err; if (argc < 2) { err = bt_mesh_cfg_ttl_get(net.net_idx, net.dst, &ttl); } else { - u8_t val = strtoul(argv[1], NULL, 0); + uint8_t val = strtoul(argv[1], NULL, 0); err = bt_mesh_cfg_ttl_set(net.net_idx, net.dst, val, &ttl); } @@ -1166,13 +1166,13 @@ struct shell_cmd_help cmd_ttl_help = { static int cmd_friend(int argc, char *argv[]) { - u8_t frnd; + uint8_t frnd; int err; if (argc < 2) { err = bt_mesh_cfg_friend_get(net.net_idx, net.dst, &frnd); } else { - u8_t val = str2u8(argv[1]); + uint8_t val = str2u8(argv[1]); err = bt_mesh_cfg_friend_set(net.net_idx, net.dst, val, &frnd); } @@ -1193,13 +1193,13 @@ struct shell_cmd_help cmd_friend_help = { static int cmd_gatt_proxy(int argc, char *argv[]) { - u8_t proxy; + uint8_t proxy; int err; if (argc < 2) { err = bt_mesh_cfg_gatt_proxy_get(net.net_idx, net.dst, &proxy); } else { - u8_t val = str2u8(argv[1]); + uint8_t val = str2u8(argv[1]); err = bt_mesh_cfg_gatt_proxy_set(net.net_idx, net.dst, val, &proxy); @@ -1221,15 +1221,15 @@ struct shell_cmd_help cmd_gatt_proxy_help = { static int cmd_relay(int argc, char *argv[]) { - u8_t relay, transmit; + uint8_t relay, transmit; int err; if (argc < 2) { err = bt_mesh_cfg_relay_get(net.net_idx, net.dst, &relay, &transmit); } else { - u8_t val = str2u8(argv[1]); - u8_t count, interval, new_transmit; + uint8_t val = str2u8(argv[1]); + uint8_t count, interval, new_transmit; if (val) { if (argc > 2) { @@ -1272,9 +1272,9 @@ struct shell_cmd_help cmd_relay_help = { static int cmd_net_key_add(int argc, char *argv[]) { bool has_key_val = (argc > 2); - u8_t key_val[16]; - u16_t key_net_idx; - u8_t status; + uint8_t key_val[16]; + uint16_t key_net_idx; + uint8_t status; int err; if (argc < 2) { @@ -1337,7 +1337,7 @@ struct shell_cmd_help cmd_net_key_add_help = { static int cmd_net_key_get(int argc, char *argv[]) { - u16_t keys[16]; + uint16_t keys[16]; size_t cnt; int err, i; @@ -1392,10 +1392,10 @@ struct shell_cmd_help cmd_net_key_del_help = { static int cmd_app_key_add(int argc, char *argv[]) { - u8_t key_val[16]; - u16_t key_net_idx, key_app_idx; + uint8_t key_val[16]; + uint16_t key_net_idx, key_app_idx; bool has_key_val = (argc > 3); - u8_t status; + uint8_t status; int err; if (argc < 3) { @@ -1461,10 +1461,10 @@ struct shell_cmd_help cmd_app_key_add_help = { static int cmd_app_key_get(int argc, char *argv[]) { - u16_t net_idx; - u16_t keys[16]; + uint16_t net_idx; + uint16_t keys[16]; size_t cnt; - u8_t status; + uint8_t status; int err, i; net_idx = strtoul(argv[1], NULL, 0); @@ -1534,8 +1534,8 @@ struct shell_cmd_help cmd_app_key_del_help = { static int cmd_mod_app_bind(int argc, char *argv[]) { - u16_t elem_addr, mod_app_idx, mod_id, cid; - u8_t status; + uint16_t elem_addr, mod_app_idx, mod_id, cid; + uint8_t status; int err; if (argc < 4) { @@ -1621,9 +1621,9 @@ struct shell_cmd_help cmd_mod_app_unbind_help = { static int cmd_mod_app_get(int argc, char *argv[]) { - u16_t elem_addr, mod_id, cid; - u16_t apps[16]; - u8_t status; + uint16_t elem_addr, mod_id, cid; + uint16_t apps[16]; + uint8_t status; size_t cnt; int err, i; @@ -1673,8 +1673,8 @@ struct shell_cmd_help cmd_mod_app_get_help = { static int cmd_mod_sub_add(int argc, char *argv[]) { - u16_t elem_addr, sub_addr, mod_id, cid; - u8_t status; + uint16_t elem_addr, sub_addr, mod_id, cid; + uint8_t status; int err; if (argc < 4) { @@ -1716,8 +1716,8 @@ struct shell_cmd_help cmd_mod_sub_add_help = { static int cmd_mod_sub_del(int argc, char *argv[]) { - u16_t elem_addr, sub_addr, mod_id, cid; - u8_t status; + uint16_t elem_addr, sub_addr, mod_id, cid; + uint8_t status; int err; if (argc < 4) { @@ -1760,9 +1760,9 @@ struct shell_cmd_help cmd_mod_sub_del_help = { static int cmd_mod_sub_add_va(int argc, char *argv[]) { - u16_t elem_addr, sub_addr, mod_id, cid; - u8_t label[16]; - u8_t status; + uint16_t elem_addr, sub_addr, mod_id, cid; + uint8_t label[16]; + uint8_t status; size_t len; int err; @@ -1810,9 +1810,9 @@ struct shell_cmd_help cmd_mod_sub_add_va_help = { static int cmd_mod_sub_del_va(int argc, char *argv[]) { - u16_t elem_addr, sub_addr, mod_id, cid; - u8_t label[16]; - u8_t status; + uint16_t elem_addr, sub_addr, mod_id, cid; + uint8_t label[16]; + uint8_t status; size_t len; int err; @@ -1862,9 +1862,9 @@ struct shell_cmd_help cmd_mod_sub_del_va_help = { static int cmd_mod_sub_get(int argc, char *argv[]) { - u16_t elem_addr, mod_id, cid; - u16_t subs[16]; - u8_t status; + uint16_t elem_addr, mod_id, cid; + uint16_t subs[16]; + uint8_t status; size_t cnt; int err, i; @@ -1913,10 +1913,10 @@ struct shell_cmd_help cmd_mod_sub_get_help = { NULL, " [Company ID]", NULL }; -static int mod_pub_get(u16_t addr, u16_t mod_id, u16_t cid) +static int mod_pub_get(uint16_t addr, uint16_t mod_id, uint16_t cid) { struct bt_mesh_cfg_mod_pub pub; - u8_t status; + uint8_t status; int err; if (cid == CID_NVAL) { @@ -1953,11 +1953,11 @@ static int mod_pub_get(u16_t addr, u16_t mod_id, u16_t cid) return 0; } -static int mod_pub_set(u16_t addr, u16_t mod_id, u16_t cid, char *argv[]) +static int mod_pub_set(uint16_t addr, uint16_t mod_id, uint16_t cid, char *argv[]) { struct bt_mesh_cfg_mod_pub pub; - u8_t status, count; - u16_t interval; + uint8_t status, count; + uint16_t interval; int err; pub.addr = strtoul(argv[0], NULL, 0); @@ -2005,7 +2005,7 @@ static int mod_pub_set(u16_t addr, u16_t mod_id, u16_t cid, char *argv[]) static int cmd_mod_pub(int argc, char *argv[]) { - u16_t addr, mod_id, cid; + uint16_t addr, mod_id, cid; if (argc < 3) { return -EINVAL; @@ -2057,7 +2057,7 @@ static void hb_sub_print(struct bt_mesh_cfg_hb_sub *sub) static int hb_sub_get(int argc, char *argv[]) { struct bt_mesh_cfg_hb_sub sub; - u8_t status; + uint8_t status; int err; err = bt_mesh_cfg_hb_sub_get(net.net_idx, net.dst, &sub, &status); @@ -2079,7 +2079,7 @@ static int hb_sub_get(int argc, char *argv[]) static int hb_sub_set(int argc, char *argv[]) { struct bt_mesh_cfg_hb_sub sub; - u8_t status; + uint8_t status; int err; sub.src = strtoul(argv[1], NULL, 0); @@ -2122,7 +2122,7 @@ struct shell_cmd_help cmd_hb_sub_help = { static int hb_pub_get(int argc, char *argv[]) { struct bt_mesh_cfg_hb_pub pub; - u8_t status; + uint8_t status; int err; err = bt_mesh_cfg_hb_pub_get(net.net_idx, net.dst, &pub, &status); @@ -2149,7 +2149,7 @@ static int hb_pub_get(int argc, char *argv[]) static int hb_pub_set(int argc, char *argv[]) { struct bt_mesh_cfg_hb_pub pub; - u8_t status; + uint8_t status; int err; pub.dst = strtoul(argv[1], NULL, 0); @@ -2240,10 +2240,10 @@ static int cmd_pb_adv(int argc, char *argv[]) #if MYNEWT_VAL(BLE_MESH_PROVISIONER) static int cmd_provision_adv(int argc, char *argv[]) { - u8_t uuid[16]; - u8_t attention_duration; - u16_t net_idx; - u16_t addr; + uint8_t uuid[16]; + uint8_t attention_duration; + uint16_t net_idx; + uint16_t addr; size_t len; int err; @@ -2278,9 +2278,9 @@ static int cmd_pb_gatt(int argc, char *argv[]) static int cmd_provision(int argc, char *argv[]) { - const u8_t *net_key = default_key; - u16_t net_idx, addr; - u32_t iv_index; + const uint8_t *net_key = default_key; + uint16_t net_idx, addr; + uint32_t iv_index; int err; if (argc < 3) { @@ -2325,10 +2325,10 @@ struct shell_cmd_help cmd_provision_help = { static int cmd_fault_get(int argc, char *argv[]) { - u8_t faults[32]; + uint8_t faults[32]; size_t fault_count; - u8_t test_id; - u16_t cid; + uint8_t test_id; + uint16_t cid; int err; if (argc < 2) { @@ -2355,10 +2355,10 @@ struct shell_cmd_help cmd_fault_get_help = { static int cmd_fault_clear(int argc, char *argv[]) { - u8_t faults[32]; + uint8_t faults[32]; size_t fault_count; - u8_t test_id; - u16_t cid; + uint8_t test_id; + uint16_t cid; int err; if (argc < 2) { @@ -2385,7 +2385,7 @@ struct shell_cmd_help cmd_fault_clear_help = { static int cmd_fault_clear_unack(int argc, char *argv[]) { - u16_t cid; + uint16_t cid; int err; if (argc < 2) { @@ -2410,10 +2410,10 @@ struct shell_cmd_help cmd_fault_clear_unack_help = { static int cmd_fault_test(int argc, char *argv[]) { - u8_t faults[32]; + uint8_t faults[32]; size_t fault_count; - u8_t test_id; - u16_t cid; + uint8_t test_id; + uint16_t cid; int err; if (argc < 3) { @@ -2441,8 +2441,8 @@ struct shell_cmd_help cmd_fault_test_help = { static int cmd_fault_test_unack(int argc, char *argv[]) { - u16_t cid; - u8_t test_id; + uint16_t cid; + uint8_t test_id; int err; if (argc < 3) { @@ -2468,7 +2468,7 @@ struct shell_cmd_help cmd_fault_test_unack_help = { static int cmd_period_get(int argc, char *argv[]) { - u8_t divisor; + uint8_t divisor; int err; err = bt_mesh_health_period_get(net.dst, net.app_idx, &divisor); @@ -2483,7 +2483,7 @@ static int cmd_period_get(int argc, char *argv[]) static int cmd_period_set(int argc, char *argv[]) { - u8_t divisor, updated_divisor; + uint8_t divisor, updated_divisor; int err; if (argc < 2) { @@ -2509,7 +2509,7 @@ struct shell_cmd_help cmd_period_set_help = { static int cmd_period_set_unack(int argc, char *argv[]) { - u8_t divisor; + uint8_t divisor; int err; if (argc < 2) { @@ -2532,7 +2532,7 @@ struct shell_cmd_help cmd_period_set_unack_help = { static int cmd_attention_get(int argc, char *argv[]) { - u8_t attention; + uint8_t attention; int err; err = bt_mesh_health_attention_get(net.dst, net.app_idx, @@ -2548,7 +2548,7 @@ static int cmd_attention_get(int argc, char *argv[]) static int cmd_attention_set(int argc, char *argv[]) { - u8_t attention, updated_attention; + uint8_t attention, updated_attention; int err; if (argc < 2) { @@ -2574,7 +2574,7 @@ struct shell_cmd_help cmd_attention_set_help = { static int cmd_attention_set_unack(int argc, char *argv[]) { - u8_t attention; + uint8_t attention; int err; if (argc < 2) { @@ -2600,8 +2600,8 @@ struct shell_cmd_help cmd_attention_set_unack_help = { static int cmd_add_fault(int argc, char *argv[]) { - u8_t fault_id; - u8_t i; + uint8_t fault_id; + uint8_t i; if (argc < 2) { return -EINVAL; @@ -2647,8 +2647,8 @@ struct shell_cmd_help cmd_add_fault_help = { static int cmd_del_fault(int argc, char *argv[]) { - u8_t fault_id; - u8_t i; + uint8_t fault_id; + uint8_t i; if (argc < 2) { memset(cur_faults, 0, sizeof(cur_faults)); @@ -2711,7 +2711,7 @@ struct shell_cmd_help cmd_cdb_app_key_del_help = { static int cmd_cdb_create(int argc, char *argv[]) { - u8_t net_key[16]; + uint8_t net_key[16]; size_t len; int err; @@ -2838,9 +2838,9 @@ static int cmd_cdb_show(int argc, char *argv[]) static int cmd_cdb_node_add(int argc, char *argv[]) { struct bt_mesh_cdb_node *node; - u8_t uuid[16], dev_key[16]; - u16_t addr, net_idx; - u8_t num_elem; + uint8_t uuid[16], dev_key[16]; + uint16_t addr, net_idx; + uint8_t num_elem; size_t len; len = hex2bin(argv[1], uuid, sizeof(uuid)); @@ -2877,7 +2877,7 @@ static int cmd_cdb_node_add(int argc, char *argv[]) static int cmd_cdb_node_del(int argc, char *argv[]) { struct bt_mesh_cdb_node *node; - u16_t addr; + uint16_t addr; addr = strtoul(argv[1], NULL, 0); @@ -2898,8 +2898,8 @@ static int cmd_cdb_subnet_add(int argc, char *argv[]) { struct bt_mesh_cdb_subnet *sub; - u8_t net_key[16]; - u16_t net_idx; + uint8_t net_key[16]; + uint16_t net_idx; size_t len; net_idx = strtoul(argv[1], NULL, 0); @@ -2932,7 +2932,7 @@ static int cmd_cdb_subnet_del(int argc, char *argv[]) { struct bt_mesh_cdb_subnet *sub; - u16_t net_idx; + uint16_t net_idx; net_idx = strtoul(argv[1], NULL, 0); @@ -2953,8 +2953,8 @@ static int cmd_cdb_app_key_add(int argc, char *argv[]) { struct bt_mesh_cdb_app_key *key; - u16_t net_idx, app_idx; - u8_t app_key[16]; + uint16_t net_idx, app_idx; + uint8_t app_key[16]; size_t len; net_idx = strtoul(argv[1], NULL, 0); @@ -2988,7 +2988,7 @@ static int cmd_cdb_app_key_del(int argc, char *argv[]) { struct bt_mesh_cdb_app_key *key; - u16_t app_idx; + uint16_t app_idx; app_idx = strtoul(argv[1], NULL, 0); @@ -3009,7 +3009,7 @@ static int cmd_cdb_app_key_del(int argc, #if MYNEWT_VAL(BLE_MESH_SHELL_MODELS) static int cmd_gen_onoff_get(int argc, char *argv[]) { - u8_t state; + uint8_t state; int err; err = bt_mesh_gen_onoff_get(net.net_idx, net.dst, net.app_idx, @@ -3025,8 +3025,8 @@ static int cmd_gen_onoff_get(int argc, char *argv[]) static int cmd_gen_onoff_set(int argc, char *argv[]) { - u8_t state; - u8_t val; + uint8_t state; + uint8_t val; int err; if (argc < 2) { @@ -3052,7 +3052,7 @@ struct shell_cmd_help cmd_gen_onoff_set_help = { static int cmd_gen_onoff_set_unack(int argc, char *argv[]) { - u8_t val; + uint8_t val; int err; if (argc < 2) { @@ -3076,7 +3076,7 @@ struct shell_cmd_help cmd_gen_onoff_set_unack_help = { static int cmd_gen_level_get(int argc, char *argv[]) { - s16_t state; + int16_t state; int err; err = bt_mesh_gen_level_get(net.net_idx, net.dst, net.app_idx, @@ -3092,15 +3092,15 @@ static int cmd_gen_level_get(int argc, char *argv[]) static int cmd_gen_level_set(int argc, char *argv[]) { - s16_t state; - s16_t val; + int16_t state; + int16_t val; int err; if (argc < 2) { return -EINVAL; } - val = (s16_t)strtoul(argv[1], NULL, 0); + val = (int16_t)strtoul(argv[1], NULL, 0); err = bt_mesh_gen_level_set(net.net_idx, net.dst, net.app_idx, val, &state); @@ -3119,14 +3119,14 @@ struct shell_cmd_help cmd_gen_level_set_help = { static int cmd_gen_level_set_unack(int argc, char *argv[]) { - s16_t val; + int16_t val; int err; if (argc < 2) { return -EINVAL; } - val = (s16_t)strtoul(argv[1], NULL, 0); + val = (int16_t)strtoul(argv[1], NULL, 0); err = bt_mesh_gen_level_set(net.net_idx, net.dst, net.app_idx, val, NULL); diff --git a/nimble/host/mesh/src/testing.c b/nimble/host/mesh/src/testing.c index 54d32adc1..c9e3e09b9 100644 --- a/nimble/host/mesh/src/testing.c +++ b/nimble/host/mesh/src/testing.c @@ -32,7 +32,7 @@ void bt_test_cb_unregister(struct bt_test_cb *cb) sys_slist_find_and_remove(&cb_slist, &cb->node); } -void bt_test_mesh_net_recv(u8_t ttl, u8_t ctl, u16_t src, u16_t dst, +void bt_test_mesh_net_recv(uint8_t ttl, uint8_t ctl, uint16_t src, uint16_t dst, const void *payload, size_t payload_len) { struct bt_test_cb *cb; @@ -45,8 +45,8 @@ void bt_test_mesh_net_recv(u8_t ttl, u8_t ctl, u16_t src, u16_t dst, } } -void bt_test_mesh_model_bound(u16_t addr, struct bt_mesh_model *model, - u16_t key_idx) +void bt_test_mesh_model_bound(uint16_t addr, struct bt_mesh_model *model, + uint16_t key_idx) { struct bt_test_cb *cb; @@ -57,8 +57,8 @@ void bt_test_mesh_model_bound(u16_t addr, struct bt_mesh_model *model, } } -void bt_test_mesh_model_unbound(u16_t addr, struct bt_mesh_model *model, - u16_t key_idx) +void bt_test_mesh_model_unbound(uint16_t addr, struct bt_mesh_model *model, + uint16_t key_idx) { struct bt_test_cb *cb; @@ -69,7 +69,7 @@ void bt_test_mesh_model_unbound(u16_t addr, struct bt_mesh_model *model, } } -void bt_test_mesh_prov_invalid_bearer(u8_t opcode) +void bt_test_mesh_prov_invalid_bearer(uint8_t opcode) { struct bt_test_cb *cb; @@ -91,14 +91,14 @@ void bt_test_mesh_trans_incomp_timer_exp(void) } } -int bt_test_mesh_lpn_group_add(u16_t group) +int bt_test_mesh_lpn_group_add(uint16_t group) { bt_mesh_lpn_group_add(group); return 0; } -int bt_test_mesh_lpn_group_remove(u16_t *groups, size_t groups_count) +int bt_test_mesh_lpn_group_remove(uint16_t *groups, size_t groups_count) { bt_mesh_lpn_group_del(groups, groups_count); @@ -115,9 +115,9 @@ int bt_test_mesh_rpl_clear(void) void bt_test_print_credentials(void) { int i; - u8_t nid; - const u8_t *enc; - const u8_t *priv; + uint8_t nid; + const uint8_t *enc; + const uint8_t *priv; struct bt_mesh_subnet *sub; struct bt_mesh_app_key *app_key; @@ -188,7 +188,7 @@ int bt_test_shell_init(void) #endif } -int bt_test_bind_app_key_to_model(struct bt_mesh_model *model, u16_t key_idx, u16_t id) +int bt_test_bind_app_key_to_model(struct bt_mesh_model *model, uint16_t key_idx, uint16_t id) { struct bt_mesh_model *found_model; diff --git a/nimble/host/mesh/src/testing.h b/nimble/host/mesh/src/testing.h index 166a9eea6..68f7fd723 100644 --- a/nimble/host/mesh/src/testing.h +++ b/nimble/host/mesh/src/testing.h @@ -12,12 +12,12 @@ #include "mesh/glue.h" #include "mesh/access.h" -void bt_test_mesh_model_bound(u16_t addr, struct bt_mesh_model *model, - u16_t key_idx); -void bt_test_mesh_model_unbound(u16_t addr, struct bt_mesh_model *model, - u16_t key_idx); -void bt_test_mesh_prov_invalid_bearer(u8_t opcode); -void bt_test_mesh_net_recv(u8_t ttl, u8_t ctl, u16_t src, u16_t dst, +void bt_test_mesh_model_bound(uint16_t addr, struct bt_mesh_model *model, + uint16_t key_idx); +void bt_test_mesh_model_unbound(uint16_t addr, struct bt_mesh_model *model, + uint16_t key_idx); +void bt_test_mesh_prov_invalid_bearer(uint8_t opcode); +void bt_test_mesh_net_recv(uint8_t ttl, uint8_t ctl, uint16_t src, uint16_t dst, const void *payload, size_t payload_len); void bt_test_mesh_trans_incomp_timer_exp(void); void bt_test_print_credentials(void); diff --git a/nimble/host/mesh/src/transport.c b/nimble/host/mesh/src/transport.c index bccc2c954..ffdc7270a 100644 --- a/nimble/host/mesh/src/transport.c +++ b/nimble/host/mesh/src/transport.c @@ -28,7 +28,7 @@ #include "transport.h" #include "testing.h" -#define AID_MASK ((u8_t)(BIT_MASK(6))) +#define AID_MASK ((uint8_t)(BIT_MASK(6))) #define SEG(data) ((data)[0] >> 7) #define AKF(data) (((data)[0] >> 6) & 0x01) @@ -40,9 +40,9 @@ #define UNSEG_HDR(akf, aid) ((akf << 6) | (aid & AID_MASK)) #define SEG_HDR(akf, aid) (UNSEG_HDR(akf, aid) | 0x80) -#define BLOCK_COMPLETE(seg_n) (u32_t)(((u64_t)1 << (seg_n + 1)) - 1) +#define BLOCK_COMPLETE(seg_n) (uint32_t)(((uint64_t)1 << (seg_n + 1)) - 1) -#define SEQ_AUTH(iv_index, seq) (((u64_t)iv_index) << 24 | (u64_t)seq) +#define SEQ_AUTH(iv_index, seq) (((uint64_t)iv_index) << 24 | (uint64_t)seq) /* Number of retransmit attempts (after the initial transmit) per segment */ #define SEG_RETRANSMIT_ATTEMPTS (MYNEWT_VAL(BLE_MESH_SEG_RETRANSMIT_ATTEMPTS)) @@ -68,22 +68,22 @@ static struct seg_tx { struct bt_mesh_subnet *sub; void *seg[CONFIG_BT_MESH_TX_SEG_MAX]; - u64_t seq_auth; - u16_t src; - u16_t dst; - u16_t len; - u8_t hdr; - u8_t xmit; - u8_t seg_n:5, /* Last segment index */ + uint64_t seq_auth; + uint16_t src; + uint16_t dst; + uint16_t len; + uint8_t hdr; + uint8_t xmit; + uint8_t seg_n:5, /* Last segment index */ ctl:1, aszmic:1, friend_cred:1; - u8_t seg_o; /* Segment being sent. */ - u8_t nack_count; /* Number of unacked segs */ - u8_t ttl; - u8_t seg_pending; /* Number of segments pending */ - u8_t attempts; /* Transmit attempts */ - u8_t started:1, /* Start cb called */ + uint8_t seg_o; /* Segment being sent. */ + uint8_t nack_count; /* Number of unacked segs */ + uint8_t ttl; + uint8_t seg_pending; /* Number of segments pending */ + uint8_t attempts; /* Transmit attempts */ + uint8_t started:1, /* Start cb called */ sending:1, /* Sending is in progress */ blocked:1; /* Blocked by ongoing tx */ const struct bt_mesh_send_cb *cb; @@ -94,33 +94,33 @@ static struct seg_tx { static struct seg_rx { struct bt_mesh_subnet *sub; void *seg[CONFIG_BT_MESH_TX_SEG_MAX]; - u64_t seq_auth; - u16_t src; - u16_t dst; - u16_t len; - u8_t hdr; - u8_t seg_n:5, + uint64_t seq_auth; + uint16_t src; + uint16_t dst; + uint16_t len; + uint8_t hdr; + uint8_t seg_n:5, ctl:1, in_use:1, obo:1; - u8_t ttl; - u32_t block; - u32_t last; + uint8_t ttl; + uint32_t block; + uint32_t last; struct k_delayed_work ack; } seg_rx[CONFIG_BT_MESH_RX_SEG_MSG_COUNT]; K_MEM_SLAB_DEFINE(segs, BT_MESH_APP_SEG_SDU_MAX, CONFIG_BT_MESH_SEG_BUFS, 4); -static u16_t hb_sub_dst = BT_MESH_ADDR_UNASSIGNED; +static uint16_t hb_sub_dst = BT_MESH_ADDR_UNASSIGNED; -void bt_mesh_set_hb_sub_dst(u16_t addr) +void bt_mesh_set_hb_sub_dst(uint16_t addr) { hb_sub_dst = addr; } static int send_unseg(struct bt_mesh_net_tx *tx, struct os_mbuf *sdu, const struct bt_mesh_send_cb *cb, void *cb_data, - const u8_t *ctl_op) + const uint8_t *ctl_op) { struct os_mbuf *buf; @@ -172,7 +172,7 @@ send: return bt_mesh_net_send(tx, buf, cb, cb_data); } -static inline u8_t seg_len(bool ctl) +static inline uint8_t seg_len(bool ctl) { if (ctl) { return BT_MESH_CTL_SEG_SDU_MAX; @@ -194,14 +194,14 @@ bool bt_mesh_tx_in_progress(void) return false; } -static void seg_tx_done(struct seg_tx *tx, u8_t seg_idx) +static void seg_tx_done(struct seg_tx *tx, uint8_t seg_idx) { k_mem_slab_free(&segs, (void **)&tx->seg[seg_idx]); tx->seg[seg_idx] = NULL; tx->nack_count--; } -static bool seg_tx_blocks(struct seg_tx *tx, u16_t src, u16_t dst) +static bool seg_tx_blocks(struct seg_tx *tx, uint16_t src, uint16_t dst) { return (tx->src == src) && (tx->dst == dst); } @@ -223,7 +223,7 @@ static void seg_tx_unblock_check(struct seg_tx *tx) if (blocked) { BT_DBG("Unblocked 0x%04x", - (u16_t)(blocked->seq_auth & TRANS_SEQ_ZERO_MASK)); + (uint16_t)(blocked->seq_auth & TRANS_SEQ_ZERO_MASK)); blocked->blocked = false; k_delayed_work_submit(&blocked->retransmit, 0); } @@ -319,7 +319,7 @@ static void schedule_retransmit(struct seg_tx *tx) 0); } -static void seg_send_start(u16_t duration, int err, void *user_data) +static void seg_send_start(uint16_t duration, int err, void *user_data) { struct seg_tx *tx = user_data; @@ -349,11 +349,11 @@ static const struct bt_mesh_send_cb seg_sent_cb = { .end = seg_sent, }; -static void seg_tx_buf_build(struct seg_tx *tx, u8_t seg_o, +static void seg_tx_buf_build(struct seg_tx *tx, uint8_t seg_o, struct os_mbuf *buf) { - u16_t seq_zero = tx->seq_auth & TRANS_SEQ_ZERO_MASK; - u8_t len = MIN(seg_len(tx->ctl), tx->len - (seg_len(tx->ctl) * seg_o)); + uint16_t seq_zero = tx->seq_auth & TRANS_SEQ_ZERO_MASK; + uint8_t len = MIN(seg_len(tx->ctl), tx->len - (seg_len(tx->ctl) * seg_o)); net_buf_simple_add_u8(buf, tx->hdr); net_buf_simple_add_u8(buf, (tx->aszmic << 7) | seq_zero >> 6); @@ -388,7 +388,7 @@ static void seg_tx_send_unacked(struct seg_tx *tx) } BT_DBG("SeqZero: 0x%04x Attempts: %u", - (u16_t)(tx->seq_auth & TRANS_SEQ_ZERO_MASK), tx->attempts); + (uint16_t)(tx->seq_auth & TRANS_SEQ_ZERO_MASK), tx->attempts); tx->sending = 1U; @@ -442,12 +442,12 @@ static void seg_retransmit(struct ble_npl_event *work) static int send_seg(struct bt_mesh_net_tx *net_tx, struct os_mbuf *sdu, const struct bt_mesh_send_cb *cb, void *cb_data, - u8_t *ctl_op) + uint8_t *ctl_op) { { bool blocked = false; struct seg_tx *tx; - u8_t seg_o; + uint8_t seg_o; int i; BT_DBG("src 0x%04x dst 0x%04x app_idx 0x%04x aszmic %u sdu_len %u", @@ -502,7 +502,7 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct os_mbuf *sdu, } BT_DBG("SeqZero 0x%04x (segs: %u)", - (u16_t)(tx->seq_auth & TRANS_SEQ_ZERO_MASK), tx->nack_count); + (uint16_t)(tx->seq_auth & TRANS_SEQ_ZERO_MASK), tx->nack_count); if (IS_ENABLED(CONFIG_BT_MESH_FRIEND) && !bt_mesh_friend_queue_has_space(tx->sub->net_idx, net_tx->src, @@ -517,7 +517,7 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct os_mbuf *sdu, for (seg_o = 0; sdu->om_len; seg_o++) { void *buf; - u16_t len; + uint16_t len; int err; err = k_mem_slab_alloc(&segs, &buf); @@ -593,7 +593,7 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct os_mbuf *sdu, return 0; } -struct bt_mesh_app_key *bt_mesh_app_key_find(u16_t app_idx) +struct bt_mesh_app_key *bt_mesh_app_key_find(uint16_t app_idx) { int i; @@ -612,9 +612,9 @@ struct bt_mesh_app_key *bt_mesh_app_key_find(u16_t app_idx) int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct os_mbuf *msg, const struct bt_mesh_send_cb *cb, void *cb_data) { - const u8_t *key; - u8_t *ad; - u8_t aid; + const uint8_t *key; + uint8_t *ad; + uint8_t aid; int err; if (msg->om_len < 1) { @@ -678,7 +678,7 @@ int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct os_mbuf *msg, } static void seg_rx_assemble(struct seg_rx *rx, struct os_mbuf *buf, - u8_t aszmic) + uint8_t aszmic) { int i; @@ -696,8 +696,8 @@ static void seg_rx_assemble(struct seg_rx *rx, struct os_mbuf *buf, } } -static int remote_devkey_decrypt(struct bt_mesh_net_rx *rx, u32_t seq, u8_t *ad, - u8_t aszmic, struct os_mbuf *buf, +static int remote_devkey_decrypt(struct bt_mesh_net_rx *rx, uint32_t seq, uint8_t *ad, + uint8_t aszmic, struct os_mbuf *buf, struct os_mbuf *sdu) { struct bt_mesh_cdb_node *node; @@ -735,8 +735,8 @@ static int remote_devkey_decrypt(struct bt_mesh_net_rx *rx, u32_t seq, u8_t *ad, } static int app_key_decrypt(struct bt_mesh_net_rx *rx, - struct bt_mesh_app_key *key, u32_t seq, u8_t *ad, - u8_t hdr, u8_t aszmic, struct os_mbuf *buf, + struct bt_mesh_app_key *key, uint32_t seq, uint8_t *ad, + uint8_t hdr, uint8_t aszmic, struct os_mbuf *buf, struct os_mbuf *sdu) { struct bt_mesh_app_keys *keys; @@ -768,13 +768,13 @@ static int app_key_decrypt(struct bt_mesh_net_rx *rx, return err; } -static int sdu_recv_unseg(struct bt_mesh_net_rx *rx, u8_t hdr, +static int sdu_recv_unseg(struct bt_mesh_net_rx *rx, uint8_t hdr, struct os_mbuf *buf) { struct os_mbuf *sdu = NET_BUF_SIMPLE(BT_MESH_SDU_UNSEG_MAX); - u8_t *ad; - u16_t i; + uint8_t *ad; + uint16_t i; int err = 0; BT_DBG("AKF %u AID 0x%02x", AKF(&hdr), AID(&hdr)); @@ -851,14 +851,14 @@ static int sdu_recv_unseg(struct bt_mesh_net_rx *rx, u8_t hdr, return 0; } -static int sdu_recv_seg(struct seg_rx *seg, u8_t hdr, u8_t aszmic, +static int sdu_recv_seg(struct seg_rx *seg, uint8_t hdr, uint8_t aszmic, struct bt_mesh_net_rx *rx) { struct os_mbuf *buf = NET_BUF_SIMPLE(BT_MESH_RX_SDU_MAX); struct os_mbuf *sdu; - u32_t seq = (seg->seq_auth & 0xffffff); - u8_t *ad; - u16_t i; + uint32_t seq = (seg->seq_auth & 0xffffff); + uint8_t *ad; + uint16_t i; int err; BT_DBG("ASZMIC %u AKF %u AID 0x%02x", aszmic, AKF(&hdr), AID(&hdr)); @@ -950,7 +950,7 @@ static int sdu_recv_seg(struct seg_rx *seg, u8_t hdr, u8_t aszmic, return 0; } -static struct seg_tx *seg_tx_lookup(u16_t seq_zero, u8_t obo, u16_t addr) +static struct seg_tx *seg_tx_lookup(uint16_t seq_zero, uint8_t obo, uint16_t addr) { struct seg_tx *tx; int i; @@ -980,14 +980,14 @@ static struct seg_tx *seg_tx_lookup(u16_t seq_zero, u8_t obo, u16_t addr) return NULL; } -static int trans_ack(struct bt_mesh_net_rx *rx, u8_t hdr, - struct os_mbuf *buf, u64_t *seq_auth) +static int trans_ack(struct bt_mesh_net_rx *rx, uint8_t hdr, + struct os_mbuf *buf, uint64_t *seq_auth) { struct seg_tx *tx; unsigned int bit; - u32_t ack; - u16_t seq_zero; - u8_t obo; + uint32_t ack; + uint16_t seq_zero; + uint8_t obo; if (buf->om_len < 6) { BT_ERR("Too short ack message"); @@ -1058,8 +1058,8 @@ static int trans_ack(struct bt_mesh_net_rx *rx, u8_t hdr, static int trans_heartbeat(struct bt_mesh_net_rx *rx, struct os_mbuf *buf) { - u8_t init_ttl, hops; - u16_t feat; + uint8_t init_ttl, hops; + uint16_t feat; if (buf->om_len < 3) { BT_ERR("Too short heartbeat message"); @@ -1085,10 +1085,10 @@ static int trans_heartbeat(struct bt_mesh_net_rx *rx, return 0; } -static int ctl_recv(struct bt_mesh_net_rx *rx, u8_t hdr, - struct os_mbuf *buf, u64_t *seq_auth) +static int ctl_recv(struct bt_mesh_net_rx *rx, uint8_t hdr, + struct os_mbuf *buf, uint64_t *seq_auth) { - u8_t ctl_op = TRANS_CTL_OP(&hdr); + uint8_t ctl_op = TRANS_CTL_OP(&hdr); BT_DBG("OpCode 0x%02x len %u", ctl_op, buf->om_len); @@ -1151,9 +1151,9 @@ static int ctl_recv(struct bt_mesh_net_rx *rx, u8_t hdr, } static int trans_unseg(struct os_mbuf *buf, struct bt_mesh_net_rx *rx, - u64_t *seq_auth) + uint64_t *seq_auth) { - u8_t hdr; + uint8_t hdr; BT_DBG("AFK %u AID 0x%02x", AKF(buf->om_data), AID(buf->om_data)); @@ -1182,10 +1182,10 @@ static int trans_unseg(struct os_mbuf *buf, struct bt_mesh_net_rx *rx, } } -static inline s32_t ack_timeout(struct seg_rx *rx) +static inline int32_t ack_timeout(struct seg_rx *rx) { - s32_t to; - u8_t ttl; + int32_t to; + uint8_t ttl; if (rx->ttl == BT_MESH_TTL_DEFAULT) { ttl = bt_mesh_default_ttl_get(); @@ -1207,7 +1207,7 @@ static inline s32_t ack_timeout(struct seg_rx *rx) return max(to, K_MSEC(400)); } -int bt_mesh_ctl_send(struct bt_mesh_net_tx *tx, u8_t ctl_op, void *data, +int bt_mesh_ctl_send(struct bt_mesh_net_tx *tx, uint8_t ctl_op, void *data, size_t data_len, const struct bt_mesh_send_cb *cb, void *cb_data) { struct os_mbuf *buf; @@ -1231,8 +1231,8 @@ int bt_mesh_ctl_send(struct bt_mesh_net_tx *tx, u8_t ctl_op, void *data, } } -static int send_ack(struct bt_mesh_subnet *sub, u16_t src, u16_t dst, - u8_t ttl, u64_t *seq_auth, u32_t block, u8_t obo) +static int send_ack(struct bt_mesh_subnet *sub, uint16_t src, uint16_t dst, + uint8_t ttl, uint64_t *seq_auth, uint32_t block, uint8_t obo) { struct bt_mesh_msg_ctx ctx = { .net_idx = sub->net_idx, @@ -1246,8 +1246,8 @@ static int send_ack(struct bt_mesh_subnet *sub, u16_t src, u16_t dst, .src = obo ? bt_mesh_primary_addr() : src, .xmit = bt_mesh_net_transmit_get(), }; - u16_t seq_zero = *seq_auth & TRANS_SEQ_ZERO_MASK; - u8_t buf[6]; + uint16_t seq_zero = *seq_auth & TRANS_SEQ_ZERO_MASK; + uint8_t buf[6]; BT_DBG("SeqZero 0x%04x Block 0x%08x OBO %u", seq_zero, (unsigned) block, obo); @@ -1333,13 +1333,13 @@ static void seg_ack(struct ble_npl_event *work) k_delayed_work_submit(&rx->ack, ack_timeout(rx)); } -static inline bool sdu_len_is_ok(bool ctl, u8_t seg_n) +static inline bool sdu_len_is_ok(bool ctl, uint8_t seg_n) { return (seg_n < CONFIG_BT_MESH_RX_SEG_MAX); } static struct seg_rx *seg_rx_find(struct bt_mesh_net_rx *net_rx, - const u64_t *seq_auth) + const uint64_t *seq_auth) { int i; @@ -1376,7 +1376,7 @@ static struct seg_rx *seg_rx_find(struct bt_mesh_net_rx *net_rx, } static bool seg_rx_is_valid(struct seg_rx *rx, struct bt_mesh_net_rx *net_rx, - const u8_t *hdr, u8_t seg_n) + const uint8_t *hdr, uint8_t seg_n) { if (rx->hdr != *hdr || rx->seg_n != seg_n) { BT_ERR("Invalid segment for ongoing session"); @@ -1397,8 +1397,8 @@ static bool seg_rx_is_valid(struct seg_rx *rx, struct bt_mesh_net_rx *net_rx, } static struct seg_rx *seg_rx_alloc(struct bt_mesh_net_rx *net_rx, - const u8_t *hdr, const u64_t *seq_auth, - u8_t seg_n) + const uint8_t *hdr, const uint64_t *seq_auth, + uint8_t seg_n) { int i; @@ -1438,15 +1438,15 @@ static struct seg_rx *seg_rx_alloc(struct bt_mesh_net_rx *net_rx, } static int trans_seg(struct os_mbuf *buf, struct bt_mesh_net_rx *net_rx, - enum bt_mesh_friend_pdu_type *pdu_type, u64_t *seq_auth, - u8_t *seg_count) + enum bt_mesh_friend_pdu_type *pdu_type, uint64_t *seq_auth, + uint8_t *seg_count) { struct bt_mesh_rpl *rpl = NULL; struct seg_rx *rx; - u8_t *hdr = buf->om_data; - u16_t seq_zero; - u8_t seg_n; - u8_t seg_o; + uint8_t *hdr = buf->om_data; + uint16_t seq_zero; + uint8_t seg_n; + uint8_t seg_o; int err; if (buf->om_len < 5) { @@ -1662,10 +1662,10 @@ found_rx: int bt_mesh_trans_recv(struct os_mbuf *buf, struct bt_mesh_net_rx *rx) { - u64_t seq_auth = TRANS_SEQ_AUTH_NVAL; + uint64_t seq_auth = TRANS_SEQ_AUTH_NVAL; enum bt_mesh_friend_pdu_type pdu_type = BT_MESH_FRIEND_PDU_SINGLE; struct net_buf_simple_state state; - u8_t seg_count = 0; + uint8_t seg_count = 0; int err; if (IS_ENABLED(CONFIG_BT_MESH_FRIEND)) { @@ -1796,10 +1796,10 @@ void bt_mesh_trans_init(void) int bt_mesh_heartbeat_send(const struct bt_mesh_send_cb *cb, void *cb_data) { struct bt_mesh_cfg_srv *cfg = bt_mesh_cfg_get(); - u16_t feat = 0U; + uint16_t feat = 0U; struct __packed { - u8_t init_ttl; - u16_t feat; + uint8_t init_ttl; + uint16_t feat; } hb; struct bt_mesh_msg_ctx ctx = { .net_idx = cfg->hb_pub.net_idx, @@ -1845,8 +1845,8 @@ int bt_mesh_heartbeat_send(const struct bt_mesh_send_cb *cb, void *cb_data) cb, cb_data); } -int bt_mesh_app_key_get(const struct bt_mesh_subnet *subnet, u16_t app_idx, - u16_t addr, const u8_t **key, u8_t *aid) +int bt_mesh_app_key_get(const struct bt_mesh_subnet *subnet, uint16_t app_idx, + uint16_t addr, const uint8_t **key, uint8_t *aid) { struct bt_mesh_app_key *app_key; diff --git a/nimble/host/mesh/src/transport.h b/nimble/host/mesh/src/transport.h index 17a1ae042..76af1542b 100644 --- a/nimble/host/mesh/src/transport.h +++ b/nimble/host/mesh/src/transport.h @@ -18,8 +18,8 @@ #define BT_MESH_RX_SDU_MAX (CONFIG_BT_MESH_RX_SEG_MAX * BT_MESH_APP_SEG_SDU_MAX) #define BT_MESH_RX_CTL_MAX (CONFIG_BT_MESH_RX_SEG_MAX * BT_MESH_CTL_SEG_SDU_MAX) -#define TRANS_SEQ_ZERO_MASK ((u16_t)BIT_MASK(13)) -#define TRANS_CTL_OP_MASK ((u8_t)BIT_MASK(7)) +#define TRANS_SEQ_ZERO_MASK ((uint16_t)BIT_MASK(13)) +#define TRANS_CTL_OP_MASK ((uint8_t)BIT_MASK(7)) #define TRANS_CTL_OP(data) ((data)[0] & TRANS_CTL_OP_MASK) #define TRANS_CTL_HDR(op, seg) ((op & TRANS_CTL_OP_MASK) | (seg << 7)) @@ -36,62 +36,62 @@ #define TRANS_CTL_OP_HEARTBEAT 0x0a struct bt_mesh_ctl_friend_poll { - u8_t fsn; + uint8_t fsn; }__attribute__((__packed__)); struct bt_mesh_ctl_friend_update { - u8_t flags; - u32_t iv_index; - u8_t md; + uint8_t flags; + uint32_t iv_index; + uint8_t md; }__attribute__((__packed__)); struct bt_mesh_ctl_friend_req { - u8_t criteria; - u8_t recv_delay; - u8_t poll_to[3]; - u16_t prev_addr; - u8_t num_elem; - u16_t lpn_counter; + uint8_t criteria; + uint8_t recv_delay; + uint8_t poll_to[3]; + uint16_t prev_addr; + uint8_t num_elem; + uint16_t lpn_counter; }__attribute__((__packed__)); struct bt_mesh_ctl_friend_offer { - u8_t recv_win; - u8_t queue_size; - u8_t sub_list_size; - s8_t rssi; - u16_t frnd_counter; + uint8_t recv_win; + uint8_t queue_size; + uint8_t sub_list_size; + int8_t rssi; + uint16_t frnd_counter; }__attribute__((__packed__)); struct bt_mesh_ctl_friend_clear { - u16_t lpn_addr; - u16_t lpn_counter; + uint16_t lpn_addr; + uint16_t lpn_counter; }__attribute__((__packed__)); struct bt_mesh_ctl_friend_clear_confirm { - u16_t lpn_addr; - u16_t lpn_counter; + uint16_t lpn_addr; + uint16_t lpn_counter; }__attribute__((__packed__)); #define BT_MESH_FRIEND_SUB_MIN_LEN (1 + 2) struct bt_mesh_ctl_friend_sub { - u8_t xact; - u16_t addr_list[5]; + uint8_t xact; + uint16_t addr_list[5]; }__attribute__((__packed__)); struct bt_mesh_ctl_friend_sub_confirm { - u8_t xact; + uint8_t xact; }__attribute__((__packed__)); -void bt_mesh_set_hb_sub_dst(u16_t addr); +void bt_mesh_set_hb_sub_dst(uint16_t addr); -struct bt_mesh_app_key *bt_mesh_app_key_find(u16_t app_idx); +struct bt_mesh_app_key *bt_mesh_app_key_find(uint16_t app_idx); bool bt_mesh_tx_in_progress(void); void bt_mesh_rx_reset(void); void bt_mesh_tx_reset(void); -int bt_mesh_ctl_send(struct bt_mesh_net_tx *tx, u8_t ctl_op, void *data, +int bt_mesh_ctl_send(struct bt_mesh_net_tx *tx, uint8_t ctl_op, void *data, size_t data_len, const struct bt_mesh_send_cb *cb, void *cb_data); int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct os_mbuf *msg, @@ -103,5 +103,5 @@ void bt_mesh_trans_init(void); int bt_mesh_heartbeat_send(const struct bt_mesh_send_cb *cb, void *cb_data); -int bt_mesh_app_key_get(const struct bt_mesh_subnet *subnet, u16_t app_idx, - u16_t addr, const u8_t **key, u8_t *aid); +int bt_mesh_app_key_get(const struct bt_mesh_subnet *subnet, uint16_t app_idx, + uint16_t addr, const uint8_t **key, uint8_t *aid); diff --git a/porting/examples/linux_blemesh/ble.c b/porting/examples/linux_blemesh/ble.c index 22a9e71d5..8e40998f5 100644 --- a/porting/examples/linux_blemesh/ble.c +++ b/porting/examples/linux_blemesh/ble.c @@ -381,7 +381,7 @@ static int output_number(bt_mesh_output_action_t action, uint32_t number) return 0; } -static void prov_complete(u16_t net_idx, u16_t addr) +static void prov_complete(uint16_t net_idx, uint16_t addr) { console_printf("Local node provisioned, primary address 0x%04x\n", addr); }