diff --git a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h index db908edbb9..e033fd2db8 100644 --- a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h +++ b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h @@ -367,10 +367,10 @@ typedef struct { /** Parameters of Generic Battery Status. */ typedef struct { - u32_t battery_level : 8; /*!< Value of Generic Battery Level state */ - u32_t time_to_discharge : 24; /*!< Value of Generic Battery Time to Discharge state */ - u32_t time_to_charge : 24; /*!< Value of Generic Battery Time to Charge state */ - u32_t flags : 8; /*!< Value of Generic Battery Flags state */ + uint32_t battery_level : 8; /*!< Value of Generic Battery Level state */ + uint32_t time_to_discharge : 24; /*!< Value of Generic Battery Time to Discharge state */ + uint32_t time_to_charge : 24; /*!< Value of Generic Battery Time to Charge state */ + uint32_t flags : 8; /*!< Value of Generic Battery Flags state */ } esp_ble_mesh_gen_battery_status_cb_t; /** Parameters of Generic Location Global Status. */ diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c index 637252f6f3..22dccaa7b2 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c @@ -128,7 +128,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des { esp_ble_mesh_cfg_client_cb_param_t *p_dest_data = (esp_ble_mesh_cfg_client_cb_param_t *)p_dest; esp_ble_mesh_cfg_client_cb_param_t *p_src_data = (esp_ble_mesh_cfg_client_cb_param_t *)p_src; - u16_t length = 0U; + uint16_t length = 0U; if (!msg || !p_src_data || !p_dest_data) { BT_ERR("%s, Invalid parameter", __func__); @@ -310,10 +310,10 @@ static void btc_ble_mesh_config_client_callback(esp_ble_mesh_cfg_client_cb_param btc_ble_mesh_config_client_copy_req_data); } -void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, +void bt_mesh_config_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len) + const uint8_t *val, size_t len) { esp_ble_mesh_cfg_client_cb_param_t cb_params = {0}; esp_ble_mesh_client_common_param_t params = {0}; @@ -364,7 +364,7 @@ void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, return; } -void btc_ble_mesh_config_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, +void btc_ble_mesh_config_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { @@ -713,9 +713,9 @@ static void btc_ble_mesh_config_server_callback(esp_ble_mesh_cfg_server_cb_param btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_cfg_server_cb_param_t), NULL); } -void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model, +void bt_mesh_config_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len) + const uint8_t *val, size_t len) { esp_ble_mesh_cfg_server_cb_param_t cb_params = {0}; uint8_t act = 0U; diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c index 6f588ab078..c73b43155e 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c @@ -37,7 +37,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi { btc_ble_mesh_generic_client_args_t *dst = (btc_ble_mesh_generic_client_args_t *)p_dest; btc_ble_mesh_generic_client_args_t *src = (btc_ble_mesh_generic_client_args_t *)p_src; - u16_t length = 0U; + uint16_t length = 0U; if (!msg || !dst || !src) { BT_ERR("%s, Invalid parameter", __func__); @@ -164,7 +164,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de { esp_ble_mesh_generic_client_cb_param_t *p_dest_data = (esp_ble_mesh_generic_client_cb_param_t *)p_dest; esp_ble_mesh_generic_client_cb_param_t *p_src_data = (esp_ble_mesh_generic_client_cb_param_t *)p_src; - u16_t length = 0U; + uint16_t length = 0U; if (!msg || !p_src_data || !p_dest_data) { BT_ERR("%s, Invalid parameter", __func__); @@ -380,10 +380,10 @@ static void btc_ble_mesh_generic_client_callback(esp_ble_mesh_generic_client_cb_ btc_ble_mesh_generic_client_copy_req_data); } -void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, +void bt_mesh_generic_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len) + const uint8_t *val, size_t len) { esp_ble_mesh_generic_client_cb_param_t cb_params = {0}; esp_ble_mesh_client_common_param_t params = {0}; @@ -434,7 +434,7 @@ void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, return; } -void btc_ble_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, +void btc_ble_mesh_generic_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { @@ -552,7 +552,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de { esp_ble_mesh_generic_server_cb_param_t *p_dest_data = (esp_ble_mesh_generic_server_cb_param_t *)p_dest; esp_ble_mesh_generic_server_cb_param_t *p_src_data = (esp_ble_mesh_generic_server_cb_param_t *)p_src; - u16_t length = 0U; + uint16_t length = 0U; if (!msg || !p_src_data || !p_dest_data) { BT_ERR("%s, Invalid parameter", __func__); @@ -697,9 +697,9 @@ static void btc_ble_mesh_generic_server_callback(esp_ble_mesh_generic_server_cb_ btc_ble_mesh_generic_server_copy_req_data); } -void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model, +void bt_mesh_generic_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len) + const uint8_t *val, size_t len) { esp_ble_mesh_generic_server_cb_param_t cb_params = {0}; uint8_t act = 0U; diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c index 39a5b295a0..2cc8dcf778 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c @@ -121,7 +121,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des { esp_ble_mesh_health_client_cb_param_t *p_dest_data = (esp_ble_mesh_health_client_cb_param_t *)p_dest; esp_ble_mesh_health_client_cb_param_t *p_src_data = (esp_ble_mesh_health_client_cb_param_t *)p_src; - u16_t length = 0U; + uint16_t length = 0U; if (!msg || !p_src_data || !p_dest_data) { BT_ERR("%s, Invalid parameter", __func__); @@ -243,10 +243,10 @@ static void btc_ble_mesh_health_client_callback(esp_ble_mesh_health_client_cb_pa btc_ble_mesh_health_client_copy_req_data); } -void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, +void bt_mesh_health_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, u16_t len) + const uint8_t *val, uint16_t len) { esp_ble_mesh_health_client_cb_param_t cb_params = {0}; esp_ble_mesh_client_common_param_t params = {0}; @@ -297,7 +297,7 @@ void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, return; } -void btc_ble_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model, +void btc_ble_mesh_health_publish_callback(uint32_t opcode, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { @@ -602,7 +602,7 @@ void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg) return; } -void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t company_id) +void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, uint16_t company_id) { esp_ble_mesh_health_server_cb_param_t param = {0}; @@ -613,7 +613,7 @@ void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t c } void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model, - u8_t test_id, u16_t company_id) + uint8_t test_id, uint16_t company_id) { esp_ble_mesh_health_server_cb_param_t param = {0}; @@ -624,7 +624,7 @@ void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model, btc_ble_mesh_health_server_callback(¶m, ESP_BLE_MESH_HEALTH_SERVER_FAULT_TEST_EVT); } -void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, u8_t time) +void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, uint8_t time) { esp_ble_mesh_health_server_cb_param_t param = {0}; diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c index b6dce6cec5..8ece595a99 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c @@ -120,7 +120,7 @@ static void btc_ble_mesh_lighting_client_copy_req_data(btc_msg_t *msg, void *p_d { esp_ble_mesh_light_client_cb_param_t *p_dest_data = (esp_ble_mesh_light_client_cb_param_t *)p_dest; esp_ble_mesh_light_client_cb_param_t *p_src_data = (esp_ble_mesh_light_client_cb_param_t *)p_src; - u16_t length = 0U; + uint16_t length = 0U; if (!msg || !p_src_data || !p_dest_data) { BT_ERR("%s, Invalid parameter", __func__); @@ -224,10 +224,10 @@ static void btc_ble_mesh_lighting_client_callback(esp_ble_mesh_light_client_cb_p btc_ble_mesh_lighting_client_copy_req_data); } -void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, +void bt_mesh_lighting_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len) + const uint8_t *val, size_t len) { esp_ble_mesh_light_client_cb_param_t cb_params = {0}; esp_ble_mesh_client_common_param_t params = {0}; @@ -278,7 +278,7 @@ void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, return; } -void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, +void btc_ble_mesh_lighting_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { @@ -396,7 +396,7 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d { esp_ble_mesh_lighting_server_cb_param_t *p_dest_data = (esp_ble_mesh_lighting_server_cb_param_t *)p_dest; esp_ble_mesh_lighting_server_cb_param_t *p_src_data = (esp_ble_mesh_lighting_server_cb_param_t *)p_src; - u16_t length = 0U; + uint16_t length = 0U; if (!msg || !p_src_data || !p_dest_data) { BT_ERR("%s, Invalid parameter", __func__); @@ -509,9 +509,9 @@ static void btc_ble_mesh_lighting_server_callback(esp_ble_mesh_lighting_server_c btc_ble_mesh_lighting_server_copy_req_data); } -void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model, +void bt_mesh_lighting_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len) + const uint8_t *val, size_t len) { esp_ble_mesh_lighting_server_cb_param_t cb_params = {0}; uint8_t act = 0U; diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c index 5732805298..19e0732f31 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c @@ -467,7 +467,7 @@ static void btc_ble_mesh_client_model_timeout_cb(struct k_work *work) static void btc_ble_mesh_model_send_comp_cb(esp_ble_mesh_model_t *model, esp_ble_mesh_msg_ctx_t *ctx, - u32_t opcode, int err) + uint32_t opcode, int err) { esp_ble_mesh_model_cb_param_t mesh_param = {0}; @@ -552,7 +552,7 @@ static void btc_ble_mesh_oob_pub_key_cb(void) return; } -static int btc_ble_mesh_output_number_cb(bt_mesh_output_action_t act, u32_t num) +static int btc_ble_mesh_output_number_cb(bt_mesh_output_action_t act, uint32_t num) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; bt_status_t ret = BT_STATUS_SUCCESS; @@ -580,7 +580,7 @@ static int btc_ble_mesh_output_string_cb(const char *str) return (ret == BT_STATUS_SUCCESS) ? 0 : -1; } -static int btc_ble_mesh_input_cb(bt_mesh_input_action_t act, u8_t size) +static int btc_ble_mesh_input_cb(bt_mesh_input_action_t act, uint8_t size) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; bt_status_t ret = BT_STATUS_SUCCESS; @@ -618,8 +618,8 @@ static void btc_ble_mesh_link_close_cb(bt_mesh_prov_bearer_t bearer) return; } -static void btc_ble_mesh_complete_cb(u16_t net_idx, const u8_t net_key[16], - u16_t addr, u8_t flags, u32_t iv_index) +static void btc_ble_mesh_complete_cb(uint16_t net_idx, const uint8_t net_key[16], + uint16_t addr, uint8_t flags, uint32_t iv_index) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -675,10 +675,10 @@ static void btc_ble_mesh_prov_set_complete_cb(esp_ble_mesh_prov_cb_param_t *para } #if CONFIG_BLE_MESH_PROVISIONER -static void btc_ble_mesh_provisioner_recv_unprov_adv_pkt_cb(const u8_t addr[6], const u8_t addr_type, - const u8_t adv_type, const u8_t dev_uuid[16], - u16_t oob_info, bt_mesh_prov_bearer_t bearer, - s8_t rssi) +static void btc_ble_mesh_provisioner_recv_unprov_adv_pkt_cb(const uint8_t addr[6], const uint8_t addr_type, + const uint8_t adv_type, const uint8_t dev_uuid[16], + uint16_t oob_info, bt_mesh_prov_bearer_t bearer, + int8_t rssi) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -702,7 +702,7 @@ static void btc_ble_mesh_provisioner_recv_unprov_adv_pkt_cb(const u8_t addr[6], return; } -static int btc_ble_mesh_provisioner_prov_read_oob_pub_key_cb(u8_t link_idx) +static int btc_ble_mesh_provisioner_prov_read_oob_pub_key_cb(uint8_t link_idx) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; bt_status_t ret = BT_STATUS_SUCCESS; @@ -715,8 +715,8 @@ static int btc_ble_mesh_provisioner_prov_read_oob_pub_key_cb(u8_t link_idx) return (ret == BT_STATUS_SUCCESS) ? 0 : -1; } -static int btc_ble_mesh_provisioner_prov_input_cb(u8_t method, bt_mesh_output_action_t act, - u8_t size, u8_t link_idx) +static int btc_ble_mesh_provisioner_prov_input_cb(uint8_t method, bt_mesh_output_action_t act, + uint8_t size, uint8_t link_idx) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; bt_status_t ret = BT_STATUS_SUCCESS; @@ -732,8 +732,8 @@ static int btc_ble_mesh_provisioner_prov_input_cb(u8_t method, bt_mesh_output_ac return (ret == BT_STATUS_SUCCESS) ? 0 : -1; } -static int btc_ble_mesh_provisioner_prov_output_cb(u8_t method, bt_mesh_input_action_t act, - void *data, u8_t size, u8_t link_idx) +static int btc_ble_mesh_provisioner_prov_output_cb(uint8_t method, bt_mesh_input_action_t act, + void *data, uint8_t size, uint8_t link_idx) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; bt_status_t ret = BT_STATUS_SUCCESS; @@ -747,7 +747,7 @@ static int btc_ble_mesh_provisioner_prov_output_cb(u8_t method, bt_mesh_input_ac if (act == BLE_MESH_ENTER_STRING) { strncpy(mesh_param.provisioner_prov_output.string, (char *)data, size); } else { - mesh_param.provisioner_prov_output.number = sys_get_le32((u8_t *)data); + mesh_param.provisioner_prov_output.number = sys_get_le32((uint8_t *)data); } ret = btc_ble_mesh_prov_callback(&mesh_param, ESP_BLE_MESH_PROVISIONER_PROV_OUTPUT_EVT); @@ -766,7 +766,7 @@ static void btc_ble_mesh_provisioner_link_open_cb(bt_mesh_prov_bearer_t bearer) return; } -static void btc_ble_mesh_provisioner_link_close_cb(bt_mesh_prov_bearer_t bearer, u8_t reason) +static void btc_ble_mesh_provisioner_link_close_cb(bt_mesh_prov_bearer_t bearer, uint8_t reason) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -779,9 +779,9 @@ static void btc_ble_mesh_provisioner_link_close_cb(bt_mesh_prov_bearer_t bearer, return; } -static void btc_ble_mesh_provisioner_prov_complete_cb(u16_t node_idx, const u8_t device_uuid[16], - u16_t unicast_addr, u8_t element_num, - u16_t netkey_idx) +static void btc_ble_mesh_provisioner_prov_complete_cb(uint16_t node_idx, const uint8_t device_uuid[16], + uint16_t unicast_addr, uint8_t element_num, + uint16_t netkey_idx) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -812,7 +812,7 @@ esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_name(const char *nam return (esp_ble_mesh_node_t *)bt_mesh_provisioner_get_node_with_name(name); } -u16_t btc_ble_mesh_provisioner_get_prov_node_count(void) +uint16_t btc_ble_mesh_provisioner_get_prov_node_count(void) { return bt_mesh_provisioner_get_node_count(); } @@ -823,9 +823,9 @@ const esp_ble_mesh_node_t **btc_ble_mesh_provisioner_get_node_table_entry(void) } #if CONFIG_BLE_MESH_PROVISIONER_RECV_HB -static void btc_ble_mesh_provisioner_recv_heartbeat_cb(u16_t hb_src, u16_t hb_dst, - u8_t init_ttl, u8_t rx_ttl, - u8_t hops, u16_t feat, s8_t rssi) +static void btc_ble_mesh_provisioner_recv_heartbeat_cb(uint16_t hb_src, uint16_t hb_dst, + uint8_t init_ttl, uint8_t rx_ttl, + uint8_t hops, uint16_t feat, int8_t rssi) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -860,7 +860,7 @@ uint8_t btc_ble_mesh_provisioner_get_free_settings_count(void) #endif /* CONFIG_BLE_MESH_PROVISIONER */ -static void btc_ble_mesh_node_recv_heartbeat_cb(u8_t hops, u16_t feature) +static void btc_ble_mesh_node_recv_heartbeat_cb(uint8_t hops, uint16_t feature) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -874,10 +874,10 @@ static void btc_ble_mesh_node_recv_heartbeat_cb(u8_t hops, u16_t feature) } #if CONFIG_BLE_MESH_LOW_POWER -static void btc_ble_mesh_lpn_cb(u16_t friend_addr, bool established) +static void btc_ble_mesh_lpn_cb(uint16_t friend_addr, bool established) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; - u8_t act = 0U; + uint8_t act = 0U; BT_DBG("%s", __func__); @@ -895,10 +895,10 @@ static void btc_ble_mesh_lpn_cb(u16_t friend_addr, bool established) #endif /* CONFIG_BLE_MESH_LOW_POWER */ #if CONFIG_BLE_MESH_FRIEND -void btc_ble_mesh_friend_cb(bool establish, u16_t lpn_addr, u8_t reason) +void btc_ble_mesh_friend_cb(bool establish, uint16_t lpn_addr, uint8_t reason) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; - u8_t act = 0U; + uint8_t act = 0U; BT_DBG("%s", __func__); @@ -922,8 +922,8 @@ void btc_ble_mesh_friend_cb(bool establish, u16_t lpn_addr, u8_t reason) #endif /* CONFIG_BLE_MESH_FRIEND */ #if CONFIG_BLE_MESH_GATT_PROXY_CLIENT -static void btc_ble_mesh_proxy_client_adv_recv_cb(const bt_mesh_addr_t *addr, u8_t type, - bt_mesh_proxy_adv_ctx_t *ctx, s8_t rssi) +static void btc_ble_mesh_proxy_client_adv_recv_cb(const bt_mesh_addr_t *addr, uint8_t type, + bt_mesh_proxy_adv_ctx_t *ctx, int8_t rssi) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -945,7 +945,7 @@ static void btc_ble_mesh_proxy_client_adv_recv_cb(const bt_mesh_addr_t *addr, u8 } static void btc_ble_mesh_proxy_client_connect_cb(const bt_mesh_addr_t *addr, - u8_t conn_handle, u16_t net_idx) + uint8_t conn_handle, uint16_t net_idx) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -965,8 +965,8 @@ static void btc_ble_mesh_proxy_client_connect_cb(const bt_mesh_addr_t *addr, return; } -static void btc_ble_mesh_proxy_client_disconnect_cb(const bt_mesh_addr_t *addr, u8_t conn_handle, - u16_t net_idx, u8_t reason) +static void btc_ble_mesh_proxy_client_disconnect_cb(const bt_mesh_addr_t *addr, uint8_t conn_handle, + uint16_t net_idx, uint8_t reason) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -987,8 +987,8 @@ static void btc_ble_mesh_proxy_client_disconnect_cb(const bt_mesh_addr_t *addr, return; } -static void btc_ble_mesh_proxy_client_filter_status_recv_cb(u8_t conn_handle, u16_t src, u16_t net_idx, - u8_t filter_type, u16_t list_size) +static void btc_ble_mesh_proxy_client_filter_status_recv_cb(uint8_t conn_handle, uint16_t src, uint16_t net_idx, + uint8_t filter_type, uint16_t list_size) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -1048,7 +1048,7 @@ uint16_t *btc_ble_mesh_model_find_group(esp_ble_mesh_model_t *mod, uint16_t addr return bt_mesh_model_find_group((struct bt_mesh_model *)mod, addr); } -esp_ble_mesh_elem_t *btc_ble_mesh_elem_find(u16_t addr) +esp_ble_mesh_elem_t *btc_ble_mesh_elem_find(uint16_t addr) { return (esp_ble_mesh_elem_t *)bt_mesh_elem_find(addr); } @@ -1873,13 +1873,15 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) act = ESP_BLE_MESH_PROVISIONER_PROV_INPUT_STRING_COMP_EVT; param.provisioner_prov_input_str_comp.err_code = bt_mesh_provisioner_set_oob_input_data(arg->provisioner_input_str.link_idx, - (const u8_t *)&arg->provisioner_input_str.string, false); + (const uint8_t *)&arg->provisioner_input_str.string, + false); break; case BTC_BLE_MESH_ACT_PROVISIONER_INPUT_NUM: act = ESP_BLE_MESH_PROVISIONER_PROV_INPUT_NUMBER_COMP_EVT; param.provisioner_prov_input_num_comp.err_code = bt_mesh_provisioner_set_oob_input_data(arg->provisioner_input_num.link_idx, - (const u8_t *)&arg->provisioner_input_num.number, true); + (const uint8_t *)&arg->provisioner_input_num.number, + true); break; case BTC_BLE_MESH_ACT_PROVISIONER_ENABLE: act = ESP_BLE_MESH_PROVISIONER_PROV_ENABLE_COMP_EVT; @@ -1964,8 +1966,8 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) bt_mesh_provisioner_set_node_name(arg->set_node_name.index, arg->set_node_name.name); break; case BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_APP_KEY: { - const u8_t *app_key = NULL; - const u8_t zero[16] = {0}; + const uint8_t *app_key = NULL; + const uint8_t zero[16] = {0}; if (memcmp(arg->add_local_app_key.app_key, zero, 16)) { app_key = arg->add_local_app_key.app_key; } @@ -1998,8 +2000,8 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) arg->local_mod_app_bind.app_idx); break; case BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_NET_KEY: { - const u8_t *net_key = NULL; - const u8_t zero[16] = {0}; + const uint8_t *net_key = NULL; + const uint8_t zero[16] = {0}; if (memcmp(arg->add_local_net_key.net_key, zero, 16)) { net_key = arg->add_local_net_key.net_key; } diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c index 65ddec0d02..9e6c1ae3b7 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c @@ -37,7 +37,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void { btc_ble_mesh_sensor_client_args_t *dst = (btc_ble_mesh_sensor_client_args_t *)p_dest; btc_ble_mesh_sensor_client_args_t *src = (btc_ble_mesh_sensor_client_args_t *)p_src; - u16_t length = 0U; + uint16_t length = 0U; if (!msg || !dst || !src) { BT_ERR("%s, Invalid parameter", __func__); @@ -248,7 +248,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des { esp_ble_mesh_sensor_client_cb_param_t *p_dest_data = (esp_ble_mesh_sensor_client_cb_param_t *)p_dest; esp_ble_mesh_sensor_client_cb_param_t *p_src_data = (esp_ble_mesh_sensor_client_cb_param_t *)p_src; - u16_t length = 0U; + uint16_t length = 0U; if (!msg || !p_src_data || !p_dest_data) { BT_ERR("%s, Invalid parameter", __func__); @@ -462,10 +462,10 @@ static void btc_ble_mesh_sensor_client_callback(esp_ble_mesh_sensor_client_cb_pa btc_ble_mesh_sensor_client_copy_req_data); } -void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, +void bt_mesh_sensor_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len) + const uint8_t *val, size_t len) { esp_ble_mesh_sensor_client_cb_param_t cb_params = {0}; esp_ble_mesh_client_common_param_t params = {0}; @@ -516,7 +516,7 @@ void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, return; } -void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, +void btc_ble_mesh_sensor_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { @@ -634,7 +634,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des { esp_ble_mesh_sensor_server_cb_param_t *p_dest_data = (esp_ble_mesh_sensor_server_cb_param_t *)p_dest; esp_ble_mesh_sensor_server_cb_param_t *p_src_data = (esp_ble_mesh_sensor_server_cb_param_t *)p_src; - u16_t length = 0U; + uint16_t length = 0U; if (!msg || !p_src_data || !p_dest_data) { BT_ERR("%s, Invalid parameter", __func__); @@ -829,9 +829,9 @@ static void btc_ble_mesh_sensor_server_callback(esp_ble_mesh_sensor_server_cb_pa btc_ble_mesh_sensor_server_copy_req_data); } -void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model, +void bt_mesh_sensor_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len) + const uint8_t *val, size_t len) { esp_ble_mesh_sensor_server_cb_param_t cb_params = {0}; uint8_t act = 0U; diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c index 937f8fd0bb..66ad4eaaec 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c @@ -120,7 +120,7 @@ static void btc_ble_mesh_time_scene_client_copy_req_data(btc_msg_t *msg, void *p { esp_ble_mesh_time_scene_client_cb_param_t *p_dest_data = (esp_ble_mesh_time_scene_client_cb_param_t *)p_dest; esp_ble_mesh_time_scene_client_cb_param_t *p_src_data = (esp_ble_mesh_time_scene_client_cb_param_t *)p_src; - u16_t length = 0U; + uint16_t length = 0U; if (!msg || !p_src_data || !p_dest_data) { BT_ERR("%s, Invalid parameter", __func__); @@ -226,10 +226,10 @@ static void btc_ble_mesh_time_scene_client_callback(esp_ble_mesh_time_scene_clie btc_ble_mesh_time_scene_client_copy_req_data); } -void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, +void bt_mesh_time_scene_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len) + const uint8_t *val, size_t len) { esp_ble_mesh_time_scene_client_cb_param_t cb_params = {0}; esp_ble_mesh_client_common_param_t params = {0}; @@ -280,7 +280,7 @@ void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, return; } -void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, +void btc_ble_mesh_time_scene_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { @@ -412,9 +412,9 @@ static void btc_ble_mesh_time_scene_server_callback(esp_ble_mesh_time_scene_serv btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_time_scene_server_cb_param_t), NULL); } -void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model, +void bt_mesh_time_scene_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len) + const uint8_t *val, size_t len) { esp_ble_mesh_time_scene_server_cb_param_t cb_params = {0}; uint8_t act = 0U; diff --git a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_config_model.h b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_config_model.h index bee77fa745..989aaaa681 100644 --- a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_config_model.h +++ b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_config_model.h @@ -53,14 +53,14 @@ void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg); void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); -void btc_ble_mesh_config_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, +void btc_ble_mesh_config_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf); -void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, +void bt_mesh_config_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len); + const uint8_t *val, size_t len); void btc_ble_mesh_config_server_cb_handler(btc_msg_t *msg); @@ -69,9 +69,9 @@ typedef enum { BTC_BLE_MESH_EVT_CONFIG_SERVER_MAX, } btc_ble_mesh_config_server_evt_t; -void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model, +void bt_mesh_config_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len); + const uint8_t *val, size_t len); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_generic_model.h b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_generic_model.h index 9840961b45..ea4e0dbfb3 100644 --- a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_generic_model.h +++ b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_generic_model.h @@ -53,14 +53,14 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg); void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); -void btc_ble_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, +void btc_ble_mesh_generic_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf); -void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, +void bt_mesh_generic_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len); + const uint8_t *val, size_t len); typedef enum { BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, @@ -69,9 +69,9 @@ typedef enum { BTC_BLE_MESH_EVT_GENERIC_SERVER_MAX, } btc_ble_mesh_generic_server_evt_t; -void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model, +void bt_mesh_generic_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len); + const uint8_t *val, size_t len); void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg); diff --git a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_health_model.h b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_health_model.h index bf12d051e9..5bef5282ba 100644 --- a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_health_model.h +++ b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_health_model.h @@ -53,14 +53,14 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg); void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg); -void btc_ble_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model, +void btc_ble_mesh_health_publish_callback(uint32_t opcode, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf); -void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, +void bt_mesh_health_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, u16_t len); + const uint8_t *val, uint16_t len); typedef enum { BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE, @@ -79,12 +79,12 @@ void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg); void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); -void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t company_id); +void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, uint16_t company_id); void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model, - u8_t test_id, u16_t company_id); + uint8_t test_id, uint16_t company_id); -void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, u8_t time); +void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, uint8_t time); void btc_ble_mesh_health_server_attention_off(struct bt_mesh_model *model); diff --git a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_lighting_model.h b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_lighting_model.h index 0173c15e4e..331b105ccf 100644 --- a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_lighting_model.h +++ b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_lighting_model.h @@ -53,14 +53,14 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg); void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); -void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, +void btc_ble_mesh_lighting_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf); -void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, +void bt_mesh_lighting_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len); + const uint8_t *val, size_t len); typedef enum { BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, @@ -70,9 +70,9 @@ typedef enum { BTC_BLE_MESH_EVT_LIGHTING_SERVER_MAX, } btc_ble_mesh_lighting_server_evt_t; -void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model, +void bt_mesh_lighting_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len); + const uint8_t *val, size_t len); void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg); diff --git a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_prov.h b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_prov.h index 6790ccabf0..ac47a4ab82 100644 --- a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_prov.h +++ b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_prov.h @@ -365,7 +365,7 @@ esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_addr(uint16_t unicas esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_name(const char *name); -u16_t btc_ble_mesh_provisioner_get_prov_node_count(void); +uint16_t btc_ble_mesh_provisioner_get_prov_node_count(void); const esp_ble_mesh_node_t **btc_ble_mesh_provisioner_get_node_table_entry(void); @@ -379,7 +379,7 @@ uint16_t btc_ble_mesh_get_primary_addr(void); uint16_t *btc_ble_mesh_model_find_group(esp_ble_mesh_model_t *mod, uint16_t addr); -esp_ble_mesh_elem_t *btc_ble_mesh_elem_find(u16_t addr); +esp_ble_mesh_elem_t *btc_ble_mesh_elem_find(uint16_t addr); uint8_t btc_ble_mesh_elem_count(void); diff --git a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_sensor_model.h b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_sensor_model.h index 6e7e0659a2..10fcd34d3d 100644 --- a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_sensor_model.h +++ b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_sensor_model.h @@ -53,14 +53,14 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg); void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); -void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, +void btc_ble_mesh_sensor_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf); -void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, +void bt_mesh_sensor_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len); + const uint8_t *val, size_t len); typedef enum { BTC_BLE_MESH_EVT_SENSOR_SERVER_STATE_CHANGE, @@ -69,9 +69,9 @@ typedef enum { BTC_BLE_MESH_EVT_SENSOR_SERVER_MAX, } btc_ble_mesh_sensor_server_evt_t; -void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model, +void bt_mesh_sensor_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len); + const uint8_t *val, size_t len); void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg); diff --git a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_time_scene_model.h b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_time_scene_model.h index c021aa52db..ef26a5f49c 100644 --- a/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_time_scene_model.h +++ b/components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_time_scene_model.h @@ -53,14 +53,14 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg); void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); -void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model, +void btc_ble_mesh_time_scene_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf); -void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, +void bt_mesh_time_scene_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len); + const uint8_t *val, size_t len); typedef enum { BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE, @@ -70,9 +70,9 @@ typedef enum { BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_MAX, } btc_ble_mesh_time_scene_server_evt_t; -void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model, +void bt_mesh_time_scene_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - const u8_t *val, size_t len); + const uint8_t *val, size_t len); void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg); diff --git a/components/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h index 901aade955..aa7a9988be 100644 --- a/components/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h +++ b/components/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h @@ -12,6 +12,7 @@ #define _BLE_MESH_BUF_H_ #include "mesh_config.h" +#include "mesh_types.h" #include "mesh_slist.h" #include "mesh_compiler.h" @@ -51,7 +52,7 @@ __extension__ ({ \ * @param _size Maximum data storage for the buffer. */ #define NET_BUF_SIMPLE_DEFINE(_name, _size) \ - u8_t net_buf_data_##_name[_size]; \ + uint8_t net_buf_data_##_name[_size]; \ struct net_buf_simple _name = { \ .data = net_buf_data_##_name, \ .len = 0, \ @@ -70,7 +71,7 @@ __extension__ ({ \ * @param _size Maximum data storage for the buffer. */ #define NET_BUF_SIMPLE_DEFINE_STATIC(_name, _size) \ - static u8_t net_buf_data_##_name[_size]; \ + static uint8_t net_buf_data_##_name[_size]; \ static struct net_buf_simple _name = { \ .data = net_buf_data_##_name, \ .len = 0, \ @@ -93,18 +94,18 @@ __extension__ ({ \ */ struct net_buf_simple { /** Pointer to the start of data in the buffer. */ - u8_t *data; + uint8_t *data; /** Length of the data behind the data pointer. */ - u16_t len; + uint16_t len; /** Amount of data that this buffer can store. */ - u16_t size; + uint16_t size; /** Start of the data storage. Not to be accessed directly * (the data pointer should be used instead). */ - u8_t *__buf; + uint8_t *__buf; }; /** @@ -123,13 +124,13 @@ struct net_buf_simple { * * @return Pointer to stack-allocated net_buf_simple object. */ -#define NET_BUF_SIMPLE(_size) \ - ((struct net_buf_simple *)(&(struct { \ - struct net_buf_simple buf; \ - u8_t data[_size] __net_buf_align; \ - }) { \ - .buf.size = _size, \ - .buf.__buf = NULL, \ +#define NET_BUF_SIMPLE(_size) \ + ((struct net_buf_simple *)(&(struct { \ + struct net_buf_simple buf; \ + uint8_t data[_size] __net_buf_align; \ + }) { \ + .buf.size = _size, \ + .buf.__buf = NULL, \ })) /** @@ -145,7 +146,7 @@ static inline void net_buf_simple_init(struct net_buf_simple *buf, size_t reserve_head) { if (!buf->__buf) { - buf->__buf = (u8_t *)buf + sizeof(*buf); + buf->__buf = (uint8_t *)buf + sizeof(*buf); } buf->data = buf->__buf + reserve_head; @@ -229,7 +230,7 @@ void *net_buf_simple_add_mem(struct net_buf_simple *buf, const void *mem, * * @return Pointer to the value added */ -u8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, u8_t val); +uint8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, uint8_t val); /** * @brief Add 16-bit value at the end of the buffer @@ -241,7 +242,7 @@ u8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, u8_t val); * @param buf Buffer to update. * @param val 16-bit value to be added. */ -void net_buf_simple_add_le16(struct net_buf_simple *buf, u16_t val); +void net_buf_simple_add_le16(struct net_buf_simple *buf, uint16_t val); /** * @brief Add 16-bit value at the end of the buffer @@ -253,7 +254,7 @@ void net_buf_simple_add_le16(struct net_buf_simple *buf, u16_t val); * @param buf Buffer to update. * @param val 16-bit value to be added. */ -void net_buf_simple_add_be16(struct net_buf_simple *buf, u16_t val); +void net_buf_simple_add_be16(struct net_buf_simple *buf, uint16_t val); /** * @brief Add 24-bit value at the end of the buffer @@ -265,7 +266,7 @@ void net_buf_simple_add_be16(struct net_buf_simple *buf, u16_t val); * @param buf Buffer to update. * @param val 24-bit value to be added. */ -void net_buf_simple_add_le24(struct net_buf_simple *buf, u32_t val); +void net_buf_simple_add_le24(struct net_buf_simple *buf, uint32_t val); /** * @brief Add 24-bit value at the end of the buffer @@ -277,7 +278,7 @@ void net_buf_simple_add_le24(struct net_buf_simple *buf, u32_t val); * @param buf Buffer to update. * @param val 24-bit value to be added. */ -void net_buf_simple_add_be24(struct net_buf_simple *buf, u32_t val); +void net_buf_simple_add_be24(struct net_buf_simple *buf, uint32_t val); /** * @brief Add 32-bit value at the end of the buffer @@ -289,7 +290,7 @@ void net_buf_simple_add_be24(struct net_buf_simple *buf, u32_t val); * @param buf Buffer to update. * @param val 32-bit value to be added. */ -void net_buf_simple_add_le32(struct net_buf_simple *buf, u32_t val); +void net_buf_simple_add_le32(struct net_buf_simple *buf, uint32_t val); /** * @brief Add 32-bit value at the end of the buffer @@ -301,7 +302,7 @@ void net_buf_simple_add_le32(struct net_buf_simple *buf, u32_t val); * @param buf Buffer to update. * @param val 32-bit value to be added. */ -void net_buf_simple_add_be32(struct net_buf_simple *buf, u32_t val); +void net_buf_simple_add_be32(struct net_buf_simple *buf, uint32_t val); /** * @brief Add 48-bit value at the end of the buffer @@ -313,7 +314,7 @@ void net_buf_simple_add_be32(struct net_buf_simple *buf, u32_t val); * @param buf Buffer to update. * @param val 48-bit value to be added. */ -void net_buf_simple_add_le48(struct net_buf_simple *buf, u64_t val); +void net_buf_simple_add_le48(struct net_buf_simple *buf, uint64_t val); /** * @brief Add 48-bit value at the end of the buffer @@ -325,7 +326,7 @@ void net_buf_simple_add_le48(struct net_buf_simple *buf, u64_t val); * @param buf Buffer to update. * @param val 48-bit value to be added. */ -void net_buf_simple_add_be48(struct net_buf_simple *buf, u64_t val); +void net_buf_simple_add_be48(struct net_buf_simple *buf, uint64_t val); /** * @brief Add 64-bit value at the end of the buffer @@ -337,7 +338,7 @@ void net_buf_simple_add_be48(struct net_buf_simple *buf, u64_t val); * @param buf Buffer to update. * @param val 64-bit value to be added. */ -void net_buf_simple_add_le64(struct net_buf_simple *buf, u64_t val); +void net_buf_simple_add_le64(struct net_buf_simple *buf, uint64_t val); /** * @brief Add 64-bit value at the end of the buffer @@ -349,7 +350,7 @@ void net_buf_simple_add_le64(struct net_buf_simple *buf, u64_t val); * @param buf Buffer to update. * @param val 64-bit value to be added. */ -void net_buf_simple_add_be64(struct net_buf_simple *buf, u64_t val); +void net_buf_simple_add_be64(struct net_buf_simple *buf, uint64_t val); /** * @brief Push data to the beginning of the buffer. @@ -373,7 +374,7 @@ void *net_buf_simple_push(struct net_buf_simple *buf, size_t len); * @param buf Buffer to update. * @param val 16-bit value to be pushed to the buffer. */ -void net_buf_simple_push_le16(struct net_buf_simple *buf, u16_t val); +void net_buf_simple_push_le16(struct net_buf_simple *buf, uint16_t val); /** * @brief Push 16-bit value to the beginning of the buffer @@ -384,7 +385,7 @@ void net_buf_simple_push_le16(struct net_buf_simple *buf, u16_t val); * @param buf Buffer to update. * @param val 16-bit value to be pushed to the buffer. */ -void net_buf_simple_push_be16(struct net_buf_simple *buf, u16_t val); +void net_buf_simple_push_be16(struct net_buf_simple *buf, uint16_t val); /** * @brief Push 8-bit value to the beginning of the buffer @@ -394,7 +395,7 @@ void net_buf_simple_push_be16(struct net_buf_simple *buf, u16_t val); * @param buf Buffer to update. * @param val 8-bit value to be pushed to the buffer. */ -void net_buf_simple_push_u8(struct net_buf_simple *buf, u8_t val); +void net_buf_simple_push_u8(struct net_buf_simple *buf, uint8_t val); /** * @brief Push 24-bit value to the beginning of the buffer @@ -405,7 +406,7 @@ void net_buf_simple_push_u8(struct net_buf_simple *buf, u8_t val); * @param buf Buffer to update. * @param val 24-bit value to be pushed to the buffer. */ -void net_buf_simple_push_le24(struct net_buf_simple *buf, u32_t val); +void net_buf_simple_push_le24(struct net_buf_simple *buf, uint32_t val); /** * @brief Push 24-bit value to the beginning of the buffer @@ -416,7 +417,7 @@ void net_buf_simple_push_le24(struct net_buf_simple *buf, u32_t val); * @param buf Buffer to update. * @param val 24-bit value to be pushed to the buffer. */ -void net_buf_simple_push_be24(struct net_buf_simple *buf, u32_t val); +void net_buf_simple_push_be24(struct net_buf_simple *buf, uint32_t val); /** * @brief Push 32-bit value to the beginning of the buffer @@ -427,7 +428,7 @@ void net_buf_simple_push_be24(struct net_buf_simple *buf, u32_t val); * @param buf Buffer to update. * @param val 32-bit value to be pushed to the buffer. */ -void net_buf_simple_push_le32(struct net_buf_simple *buf, u32_t val); +void net_buf_simple_push_le32(struct net_buf_simple *buf, uint32_t val); /** * @brief Push 32-bit value to the beginning of the buffer @@ -438,7 +439,7 @@ void net_buf_simple_push_le32(struct net_buf_simple *buf, u32_t val); * @param buf Buffer to update. * @param val 32-bit value to be pushed to the buffer. */ -void net_buf_simple_push_be32(struct net_buf_simple *buf, u32_t val); +void net_buf_simple_push_be32(struct net_buf_simple *buf, uint32_t val); /** * @brief Push 48-bit value to the beginning of the buffer @@ -449,7 +450,7 @@ void net_buf_simple_push_be32(struct net_buf_simple *buf, u32_t val); * @param buf Buffer to update. * @param val 48-bit value to be pushed to the buffer. */ -void net_buf_simple_push_le48(struct net_buf_simple *buf, u64_t val); +void net_buf_simple_push_le48(struct net_buf_simple *buf, uint64_t val); /** * @brief Push 48-bit value to the beginning of the buffer @@ -460,7 +461,7 @@ void net_buf_simple_push_le48(struct net_buf_simple *buf, u64_t val); * @param buf Buffer to update. * @param val 48-bit value to be pushed to the buffer. */ -void net_buf_simple_push_be48(struct net_buf_simple *buf, u64_t val); +void net_buf_simple_push_be48(struct net_buf_simple *buf, uint64_t val); /** * @brief Push 64-bit value to the beginning of the buffer @@ -471,7 +472,7 @@ void net_buf_simple_push_be48(struct net_buf_simple *buf, u64_t val); * @param buf Buffer to update. * @param val 64-bit value to be pushed to the buffer. */ -void net_buf_simple_push_le64(struct net_buf_simple *buf, u64_t val); +void net_buf_simple_push_le64(struct net_buf_simple *buf, uint64_t val); /** * @brief Push 64-bit value to the beginning of the buffer @@ -482,7 +483,7 @@ void net_buf_simple_push_le64(struct net_buf_simple *buf, u64_t val); * @param buf Buffer to update. * @param val 64-bit value to be pushed to the buffer. */ -void net_buf_simple_push_be64(struct net_buf_simple *buf, u64_t val); +void net_buf_simple_push_be64(struct net_buf_simple *buf, uint64_t val); /** * @brief Remove data from the beginning of the buffer. @@ -520,7 +521,7 @@ void *net_buf_simple_pull_mem(struct net_buf_simple *buf, size_t len); * * @return The 8-bit removed value */ -u8_t net_buf_simple_pull_u8(struct net_buf_simple *buf); +uint8_t net_buf_simple_pull_u8(struct net_buf_simple *buf); /** * @brief Remove and convert 16 bits from the beginning of the buffer. @@ -532,7 +533,7 @@ u8_t net_buf_simple_pull_u8(struct net_buf_simple *buf); * * @return 16-bit value converted from little endian to host endian. */ -u16_t net_buf_simple_pull_le16(struct net_buf_simple *buf); +uint16_t net_buf_simple_pull_le16(struct net_buf_simple *buf); /** * @brief Remove and convert 16 bits from the beginning of the buffer. @@ -544,7 +545,7 @@ u16_t net_buf_simple_pull_le16(struct net_buf_simple *buf); * * @return 16-bit value converted from big endian to host endian. */ -u16_t net_buf_simple_pull_be16(struct net_buf_simple *buf); +uint16_t net_buf_simple_pull_be16(struct net_buf_simple *buf); /** * @brief Remove and convert 24 bits from the beginning of the buffer. @@ -556,7 +557,7 @@ u16_t net_buf_simple_pull_be16(struct net_buf_simple *buf); * * @return 24-bit value converted from little endian to host endian. */ -u32_t net_buf_simple_pull_le24(struct net_buf_simple *buf); +uint32_t net_buf_simple_pull_le24(struct net_buf_simple *buf); /** * @brief Remove and convert 24 bits from the beginning of the buffer. @@ -568,7 +569,7 @@ u32_t net_buf_simple_pull_le24(struct net_buf_simple *buf); * * @return 24-bit value converted from big endian to host endian. */ -u32_t net_buf_simple_pull_be24(struct net_buf_simple *buf); +uint32_t net_buf_simple_pull_be24(struct net_buf_simple *buf); /** * @brief Remove and convert 32 bits from the beginning of the buffer. @@ -580,7 +581,7 @@ u32_t net_buf_simple_pull_be24(struct net_buf_simple *buf); * * @return 32-bit value converted from little endian to host endian. */ -u32_t net_buf_simple_pull_le32(struct net_buf_simple *buf); +uint32_t net_buf_simple_pull_le32(struct net_buf_simple *buf); /** * @brief Remove and convert 32 bits from the beginning of the buffer. @@ -592,7 +593,7 @@ u32_t net_buf_simple_pull_le32(struct net_buf_simple *buf); * * @return 32-bit value converted from big endian to host endian. */ -u32_t net_buf_simple_pull_be32(struct net_buf_simple *buf); +uint32_t net_buf_simple_pull_be32(struct net_buf_simple *buf); /** * @brief Remove and convert 48 bits from the beginning of the buffer. @@ -604,7 +605,7 @@ u32_t net_buf_simple_pull_be32(struct net_buf_simple *buf); * * @return 48-bit value converted from little endian to host endian. */ -u64_t net_buf_simple_pull_le48(struct net_buf_simple *buf); +uint64_t net_buf_simple_pull_le48(struct net_buf_simple *buf); /** * @brief Remove and convert 48 bits from the beginning of the buffer. @@ -616,7 +617,7 @@ u64_t net_buf_simple_pull_le48(struct net_buf_simple *buf); * * @return 48-bit value converted from big endian to host endian. */ -u64_t net_buf_simple_pull_be48(struct net_buf_simple *buf); +uint64_t net_buf_simple_pull_be48(struct net_buf_simple *buf); /** * @brief Remove and convert 64 bits from the beginning of the buffer. @@ -628,7 +629,7 @@ u64_t net_buf_simple_pull_be48(struct net_buf_simple *buf); * * @return 64-bit value converted from little endian to host endian. */ -u64_t net_buf_simple_pull_le64(struct net_buf_simple *buf); +uint64_t net_buf_simple_pull_le64(struct net_buf_simple *buf); /** * @brief Remove and convert 64 bits from the beginning of the buffer. @@ -640,7 +641,7 @@ u64_t net_buf_simple_pull_le64(struct net_buf_simple *buf); * * @return 64-bit value converted from big endian to host endian. */ -u64_t net_buf_simple_pull_be64(struct net_buf_simple *buf); +uint64_t net_buf_simple_pull_be64(struct net_buf_simple *buf); /** * @brief Get the tail pointer for a buffer. @@ -651,7 +652,7 @@ u64_t net_buf_simple_pull_be64(struct net_buf_simple *buf); * * @return Tail pointer for the buffer. */ -static inline u8_t *net_buf_simple_tail(struct net_buf_simple *buf) +static inline uint8_t *net_buf_simple_tail(struct net_buf_simple *buf) { return buf->data + buf->len; } @@ -687,9 +688,9 @@ size_t net_buf_simple_tailroom(struct net_buf_simple *buf); */ 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; }; /** @@ -760,10 +761,10 @@ struct net_buf { }; /** Reference count. */ - u8_t ref; + uint8_t ref; /** Bit-field of buffer flags. */ - u8_t flags; + uint8_t flags; /** Where the buffer should go when freed up. */ struct net_buf_pool *pool; @@ -775,32 +776,32 @@ struct net_buf { /* The ABI of this struct must match net_buf_simple */ struct { /** Pointer to the start of data in the buffer. */ - u8_t *data; + uint8_t *data; /** Length of the data behind the data pointer. */ - u16_t len; + uint16_t len; /** Amount of data that this buffer can store. */ - u16_t size; + uint16_t size; /** Start of the data storage. Not to be accessed * directly (the data pointer should be used * instead). */ - u8_t *__buf; + uint8_t *__buf; }; struct net_buf_simple b; }; /** System metadata for this buffer. */ - u8_t user_data[BLE_MESH_NET_BUF_USER_DATA_SIZE] __net_buf_align; + uint8_t user_data[BLE_MESH_NET_BUF_USER_DATA_SIZE] __net_buf_align; }; struct net_buf_data_cb { - u8_t *(*alloc)(struct net_buf *buf, size_t *size, s32_t timeout); - u8_t *(*ref)(struct net_buf *buf, u8_t *data); - void (*unref)(struct net_buf *buf, u8_t *data); + uint8_t *(*alloc)(struct net_buf *buf, size_t *size, int32_t timeout); + uint8_t *(*ref)(struct net_buf *buf, uint8_t *data); + void (*unref)(struct net_buf *buf, uint8_t *data); }; struct net_buf_data_alloc { @@ -810,17 +811,17 @@ struct net_buf_data_alloc { struct net_buf_pool { /** Number of buffers in pool */ - const u16_t buf_count; + const uint16_t buf_count; /** Number of uninitialized buffers */ - u16_t uninit_count; + uint16_t uninit_count; #if defined(CONFIG_BLE_MESH_NET_BUF_POOL_USAGE) /** Amount of available buffers in the pool. */ - s16_t avail_count; + int16_t avail_count; /** Total size of the pool. */ - const u16_t pool_size; + const uint16_t pool_size; /** Name of the pool. Used when printing pool information. */ const char *name; @@ -860,7 +861,7 @@ struct net_buf_pool { struct net_buf_pool_fixed { size_t data_size; - u8_t *data_pool; + uint8_t *data_pool; }; /** @cond INTERNAL_HIDDEN */ @@ -895,10 +896,10 @@ extern const struct net_buf_data_cb net_buf_fixed_cb; */ #define NET_BUF_POOL_FIXED_DEFINE(_name, _count, _data_size, _destroy) \ static struct net_buf net_buf_##_name[_count]; \ - static u8_t net_buf_data_##_name[_count][_data_size]; \ + static uint8_t net_buf_data_##_name[_count][_data_size]; \ static const struct net_buf_pool_fixed net_buf_fixed_##_name = { \ .data_size = _data_size, \ - .data_pool = (u8_t *)net_buf_data_##_name, \ + .data_pool = (uint8_t *)net_buf_data_##_name, \ }; \ static const struct net_buf_data_alloc net_buf_fixed_alloc_##_name = { \ .cb = &net_buf_fixed_cb, \ @@ -962,12 +963,12 @@ int net_buf_id(struct net_buf *buf); * @return New buffer or NULL if out of buffers. */ #if defined(CONFIG_BLE_MESH_NET_BUF_LOG) -struct net_buf *net_buf_alloc_fixed_debug(struct net_buf_pool *pool, s32_t timeout, +struct net_buf *net_buf_alloc_fixed_debug(struct net_buf_pool *pool, int32_t timeout, const char *func, int line); #define net_buf_alloc_fixed(_pool, _timeout) \ net_buf_alloc_fixed_debug(_pool, _timeout, __func__, __LINE__) #else -struct net_buf *net_buf_alloc_fixed(struct net_buf_pool *pool, s32_t timeout); +struct net_buf *net_buf_alloc_fixed(struct net_buf_pool *pool, int32_t timeout); #endif /** @@ -1671,7 +1672,7 @@ size_t net_buf_linearize(void *dst, size_t dst_len, * @param user_data The user data given in net_buf_append_bytes call. * @return pointer to allocated net_buf or NULL on error. */ -typedef struct net_buf *(*net_buf_allocator_cb)(s32_t timeout, void *user_data); +typedef struct net_buf *(*net_buf_allocator_cb)(int32_t timeout, void *user_data); /** * @brief Append data to a list of net_buf @@ -1694,7 +1695,7 @@ typedef struct net_buf *(*net_buf_allocator_cb)(s32_t timeout, void *user_data); * were no free fragments in a pool to accommodate all data. */ size_t net_buf_append_bytes(struct net_buf *buf, size_t len, - const void *value, s32_t timeout, + const void *value, int32_t timeout, net_buf_allocator_cb allocate_cb, void *user_data); /** diff --git a/components/bt/esp_ble_mesh/mesh_common/include/mesh_byteorder.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_byteorder.h index f570bd6e00..965b14728d 100644 --- a/components/bt/esp_ble_mesh/mesh_common/include/mesh_byteorder.h +++ b/components/bt/esp_ble_mesh/mesh_common/include/mesh_byteorder.h @@ -16,40 +16,40 @@ extern "C" { /* Internal helpers only used by the sys_* APIs further below */ #ifndef __bswap_16 -#define __bswap_16(x) ((u16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))) +#define __bswap_16(x) ((uint16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))) #endif #ifndef __bswap_24 -#define __bswap_24(x) ((u32_t) ((((x) >> 16) & 0xff) | \ - (((x)) & 0xff00) | \ - (((x) & 0xff) << 16))) +#define __bswap_24(x) ((uint32_t) ((((x) >> 16) & 0xff) | \ + (((x)) & 0xff00) | \ + (((x) & 0xff) << 16))) #endif #ifndef __bswap_32 -#define __bswap_32(x) ((u32_t) ((((x) >> 24) & 0xff) | \ - (((x) >> 8) & 0xff00) | \ - (((x) & 0xff00) << 8) | \ - (((x) & 0xff) << 24))) +#define __bswap_32(x) ((uint32_t) ((((x) >> 24) & 0xff) | \ + (((x) >> 8) & 0xff00) | \ + (((x) & 0xff00) << 8) | \ + (((x) & 0xff) << 24))) #endif #ifndef __bswap_48 -#define __bswap_48(x) ((u64_t) ((((x) >> 40) & 0xff) | \ - (((x) >> 24) & 0xff00) | \ - (((x) >> 8) & 0xff0000) | \ - (((x) & 0xff0000) << 8) | \ - (((x) & 0xff00) << 24) | \ - (((x) & 0xff) << 40))) +#define __bswap_48(x) ((uint64_t) ((((x) >> 40) & 0xff) | \ + (((x) >> 24) & 0xff00) | \ + (((x) >> 8) & 0xff0000) | \ + (((x) & 0xff0000) << 8) | \ + (((x) & 0xff00) << 24) | \ + (((x) & 0xff) << 40))) #endif #ifndef __bswap_64 -#define __bswap_64(x) ((u64_t) ((((x) >> 56) & 0xff) | \ - (((x) >> 40) & 0xff00) | \ - (((x) >> 24) & 0xff0000) | \ - (((x) >> 8) & 0xff000000) | \ - (((x) & 0xff000000) << 8) | \ - (((x) & 0xff0000) << 24) | \ - (((x) & 0xff00) << 40) | \ - (((x) & 0xff) << 56))) +#define __bswap_64(x) ((uint64_t) ((((x) >> 56) & 0xff) | \ + (((x) >> 40) & 0xff00) | \ + (((x) >> 24) & 0xff0000) | \ + (((x) >> 8) & 0xff000000) | \ + (((x) & 0xff000000) << 8) | \ + (((x) & 0xff0000) << 24) | \ + (((x) & 0xff00) << 40) | \ + (((x) & 0xff) << 56))) #endif /** @def sys_le16_to_cpu @@ -250,7 +250,7 @@ extern "C" { * @param val 16-bit integer in host endianness. * @param dst Destination memory address to store the result. */ -static inline void sys_put_be16(u16_t val, u8_t dst[2]) +static inline void sys_put_be16(uint16_t val, uint8_t dst[2]) { dst[0] = val >> 8; dst[1] = val; @@ -265,7 +265,7 @@ static inline void sys_put_be16(u16_t val, u8_t dst[2]) * @param val 24-bit integer in host endianness. * @param dst Destination memory address to store the result. */ -static inline void sys_put_be24(u32_t val, u8_t dst[3]) +static inline void sys_put_be24(uint32_t val, uint8_t dst[3]) { dst[0] = val >> 16; sys_put_be16(val, &dst[1]); @@ -280,7 +280,7 @@ static inline void sys_put_be24(u32_t val, u8_t dst[3]) * @param val 32-bit integer in host endianness. * @param dst Destination memory address to store the result. */ -static inline void sys_put_be32(u32_t val, u8_t dst[4]) +static inline void sys_put_be32(uint32_t val, uint8_t dst[4]) { sys_put_be16(val >> 16, dst); sys_put_be16(val, &dst[2]); @@ -295,7 +295,7 @@ static inline void sys_put_be32(u32_t val, u8_t dst[4]) * @param val 48-bit integer in host endianness. * @param dst Destination memory address to store the result. */ -static inline void sys_put_be48(u64_t val, u8_t dst[6]) +static inline void sys_put_be48(uint64_t val, uint8_t dst[6]) { sys_put_be16(val >> 32, dst); sys_put_be32(val, &dst[2]); @@ -310,7 +310,7 @@ static inline void sys_put_be48(u64_t val, u8_t dst[6]) * @param val 64-bit integer in host endianness. * @param dst Destination memory address to store the result. */ -static inline void sys_put_be64(u64_t val, u8_t dst[8]) +static inline void sys_put_be64(uint64_t val, uint8_t dst[8]) { sys_put_be32(val >> 32, dst); sys_put_be32(val, &dst[4]); @@ -325,7 +325,7 @@ static inline void sys_put_be64(u64_t val, u8_t dst[8]) * @param val 16-bit integer in host endianness. * @param dst Destination memory address to store the result. */ -static inline void sys_put_le16(u16_t val, u8_t dst[2]) +static inline void sys_put_le16(uint16_t val, uint8_t dst[2]) { dst[0] = val; dst[1] = val >> 8; @@ -340,7 +340,7 @@ static inline void sys_put_le16(u16_t val, u8_t dst[2]) * @param val 24-bit integer in host endianness. * @param dst Destination memory address to store the result. */ -static inline void sys_put_le24(u32_t val, u8_t dst[3]) +static inline void sys_put_le24(uint32_t val, uint8_t dst[3]) { sys_put_le16(val, dst); dst[2] = val >> 16; @@ -355,7 +355,7 @@ static inline void sys_put_le24(u32_t val, u8_t dst[3]) * @param val 32-bit integer in host endianness. * @param dst Destination memory address to store the result. */ -static inline void sys_put_le32(u32_t val, u8_t dst[4]) +static inline void sys_put_le32(uint32_t val, uint8_t dst[4]) { sys_put_le16(val, dst); sys_put_le16(val >> 16, &dst[2]); @@ -370,7 +370,7 @@ static inline void sys_put_le32(u32_t val, u8_t dst[4]) * @param val 48-bit integer in host endianness. * @param dst Destination memory address to store the result. */ -static inline void sys_put_le48(u64_t val, u8_t dst[6]) +static inline void sys_put_le48(uint64_t val, uint8_t dst[6]) { sys_put_le32(val, dst); sys_put_le16(val >> 32, &dst[4]); @@ -385,7 +385,7 @@ static inline void sys_put_le48(u64_t val, u8_t dst[6]) * @param val 64-bit integer in host endianness. * @param dst Destination memory address to store the result. */ -static inline void sys_put_le64(u64_t val, u8_t dst[8]) +static inline void sys_put_le64(uint64_t val, uint8_t dst[8]) { sys_put_le32(val, dst); sys_put_le32(val >> 32, &dst[4]); @@ -401,9 +401,9 @@ static inline void sys_put_le64(u64_t val, u8_t dst[8]) * * @return 16-bit integer in host endianness. */ -static inline u16_t sys_get_be16(const u8_t src[2]) +static inline uint16_t sys_get_be16(const uint8_t src[2]) { - return ((u16_t)src[0] << 8) | src[1]; + return ((uint16_t)src[0] << 8) | src[1]; } /** @@ -416,9 +416,9 @@ static inline u16_t sys_get_be16(const u8_t src[2]) * * @return 24-bit integer in host endianness. */ -static inline u32_t sys_get_be24(const u8_t src[3]) +static inline uint32_t sys_get_be24(const uint8_t src[3]) { - return ((u32_t)src[0] << 16) | sys_get_be16(&src[1]); + return ((uint32_t)src[0] << 16) | sys_get_be16(&src[1]); } /** @@ -431,9 +431,9 @@ static inline u32_t sys_get_be24(const u8_t src[3]) * * @return 32-bit integer in host endianness. */ -static inline u32_t sys_get_be32(const u8_t src[4]) +static inline uint32_t sys_get_be32(const uint8_t src[4]) { - return ((u32_t)sys_get_be16(&src[0]) << 16) | sys_get_be16(&src[2]); + return ((uint32_t)sys_get_be16(&src[0]) << 16) | sys_get_be16(&src[2]); } /** @@ -446,9 +446,9 @@ static inline u32_t sys_get_be32(const u8_t src[4]) * * @return 48-bit integer in host endianness. */ -static inline u64_t sys_get_be48(const u8_t src[6]) +static inline uint64_t sys_get_be48(const uint8_t src[6]) { - return ((u64_t)sys_get_be32(&src[0]) << 32) | sys_get_be16(&src[4]); + return ((uint64_t)sys_get_be32(&src[0]) << 32) | sys_get_be16(&src[4]); } /** @@ -461,9 +461,9 @@ static inline u64_t sys_get_be48(const u8_t src[6]) * * @return 64-bit integer in host endianness. */ -static inline u64_t sys_get_be64(const u8_t src[8]) +static inline uint64_t sys_get_be64(const uint8_t src[8]) { - return ((u64_t)sys_get_be32(&src[0]) << 32) | sys_get_be32(&src[4]); + return ((uint64_t)sys_get_be32(&src[0]) << 32) | sys_get_be32(&src[4]); } /** @@ -476,9 +476,9 @@ static inline u64_t sys_get_be64(const u8_t src[8]) * * @return 16-bit integer in host endianness. */ -static inline u16_t sys_get_le16(const u8_t src[2]) +static inline uint16_t sys_get_le16(const uint8_t src[2]) { - return ((u16_t)src[1] << 8) | src[0]; + return ((uint16_t)src[1] << 8) | src[0]; } /** @@ -491,9 +491,9 @@ static inline u16_t sys_get_le16(const u8_t src[2]) * * @return 24-bit integer in host endianness. */ -static inline u32_t sys_get_le24(const u8_t src[3]) +static inline uint32_t sys_get_le24(const uint8_t src[3]) { - return ((u32_t)src[2] << 16) | sys_get_le16(&src[0]); + return ((uint32_t)src[2] << 16) | sys_get_le16(&src[0]); } /** @@ -506,9 +506,9 @@ static inline u32_t sys_get_le24(const u8_t src[3]) * * @return 32-bit integer in host endianness. */ -static inline u32_t sys_get_le32(const u8_t src[4]) +static inline uint32_t sys_get_le32(const uint8_t src[4]) { - return ((u32_t)sys_get_le16(&src[2]) << 16) | sys_get_le16(&src[0]); + return ((uint32_t)sys_get_le16(&src[2]) << 16) | sys_get_le16(&src[0]); } /** @@ -521,9 +521,9 @@ static inline u32_t sys_get_le32(const u8_t src[4]) * * @return 48-bit integer in host endianness. */ -static inline u64_t sys_get_le48(const u8_t src[6]) +static inline uint64_t sys_get_le48(const uint8_t src[6]) { - return ((u64_t)sys_get_le32(&src[2]) << 32) | sys_get_le16(&src[0]); + return ((uint64_t)sys_get_le32(&src[2]) << 32) | sys_get_le16(&src[0]); } /** @@ -536,9 +536,9 @@ static inline u64_t sys_get_le48(const u8_t src[6]) * * @return 64-bit integer in host endianness. */ -static inline u64_t sys_get_le64(const u8_t src[8]) +static inline uint64_t sys_get_le64(const uint8_t src[8]) { - return ((u64_t)sys_get_le32(&src[4]) << 32) | sys_get_le32(&src[0]); + return ((uint64_t)sys_get_le32(&src[4]) << 32) | sys_get_le32(&src[0]); } /** @@ -556,8 +556,8 @@ static inline u64_t sys_get_le64(const u8_t src[8]) */ static inline void sys_memcpy_swap(void *dst, const void *src, size_t length) { - u8_t *pdst = (u8_t *)dst; - const u8_t *psrc = (const u8_t *)src; + uint8_t *pdst = (uint8_t *)dst; + const uint8_t *psrc = (const uint8_t *)src; __ASSERT(((psrc < pdst && (psrc + length) <= pdst) || (psrc > pdst && (pdst + length) <= psrc)), @@ -585,10 +585,10 @@ static inline void sys_mem_swap(void *buf, size_t length) size_t i; for (i = 0; i < (length / 2); i++) { - u8_t tmp = ((u8_t *)buf)[i]; + uint8_t tmp = ((uint8_t *)buf)[i]; - ((u8_t *)buf)[i] = ((u8_t *)buf)[length - 1 - i]; - ((u8_t *)buf)[length - 1 - i] = tmp; + ((uint8_t *)buf)[i] = ((uint8_t *)buf)[length - 1 - i]; + ((uint8_t *)buf)[length - 1 - i] = tmp; } } diff --git a/components/bt/esp_ble_mesh/mesh_common/include/mesh_common.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_common.h index f78a557762..e39b73dff8 100644 --- a/components/bt/esp_ble_mesh/mesh_common/include/mesh_common.h +++ b/components/bt/esp_ble_mesh/mesh_common/include/mesh_common.h @@ -48,7 +48,7 @@ IRAM_ATTR void bt_mesh_free(void *ptr); * * @return NULL-fail, pointer of a net_buf_simple structure-success */ -struct net_buf_simple *bt_mesh_alloc_buf(u16_t size); +struct net_buf_simple *bt_mesh_alloc_buf(uint16_t size); /** * @brief This function releases the memory allocated for the outgoing message. @@ -71,7 +71,9 @@ void bt_mesh_free_buf(struct net_buf_simple *buf); * * @return 0 - Node, 1 - Provisioner */ -u8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send); +uint8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send); + +int bt_mesh_rand(void *buf, size_t len); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_common/include/mesh_ffs.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_ffs.h index 63c1b1b25a..4e96b8412c 100644 --- a/components/bt/esp_ble_mesh/mesh_common/include/mesh_ffs.h +++ b/components/bt/esp_ble_mesh/mesh_common/include/mesh_ffs.h @@ -27,7 +27,7 @@ extern "C" { * @return most significant bit set, 0 if @a op is 0 */ -static ALWAYS_INLINE unsigned int find_msb_set(u32_t op) +static ALWAYS_INLINE unsigned int find_msb_set(uint32_t op) { if (op == 0) { return 0; @@ -48,7 +48,7 @@ static ALWAYS_INLINE unsigned int find_msb_set(u32_t op) * @return least significant bit set, 0 if @a op is 0 */ -static ALWAYS_INLINE unsigned int find_lsb_set(u32_t op) +static ALWAYS_INLINE unsigned int find_lsb_set(uint32_t op) { return __builtin_ffs(op); } diff --git a/components/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h index 48c40d2595..83d67a7211 100644 --- a/components/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h +++ b/components/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h @@ -50,7 +50,7 @@ extern "C" { * * @return N/A */ -void k_sleep(s32_t duration); +void k_sleep(int32_t duration); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_common/include/mesh_timer.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_timer.h index 6f47d8184c..cd5e390201 100644 --- a/components/bt/esp_ble_mesh/mesh_common/include/mesh_timer.h +++ b/components/bt/esp_ble_mesh/mesh_common/include/mesh_timer.h @@ -142,7 +142,7 @@ struct k_work { * * @return Current uptime. */ -u32_t k_uptime_get_32(void); +uint32_t k_uptime_get_32(void); struct k_delayed_work { struct k_work work; @@ -180,9 +180,9 @@ struct k_delayed_work { * @retval -EINVAL Work item is being processed or has completed its work. * @retval -EADDRINUSE Work item is pending on a different workqueue. */ -int k_delayed_work_submit(struct k_delayed_work *work, s32_t delay); +int k_delayed_work_submit(struct k_delayed_work *work, int32_t delay); -int k_delayed_work_submit_periodic(struct k_delayed_work *work, s32_t period); +int k_delayed_work_submit_periodic(struct k_delayed_work *work, int32_t period); /** * @brief Get time remaining before a delayed work gets scheduled. @@ -195,7 +195,7 @@ int k_delayed_work_submit_periodic(struct k_delayed_work *work, s32_t period); * * @return Remaining time (in milliseconds). */ -s32_t k_delayed_work_remaining_get(struct k_delayed_work *work); +int32_t k_delayed_work_remaining_get(struct k_delayed_work *work); /** * @brief Submit a work item to the system workqueue. @@ -254,7 +254,7 @@ int k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler); * * @return Current uptime. */ -s64_t k_uptime_get(void); +int64_t k_uptime_get(void); void bt_mesh_timer_init(void); void bt_mesh_timer_deinit(void); diff --git a/components/bt/esp_ble_mesh/mesh_common/include/mesh_types.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_types.h index 61cddba0d0..3a69e55fc7 100644 --- a/components/bt/esp_ble_mesh/mesh_common/include/mesh_types.h +++ b/components/bt/esp_ble_mesh/mesh_common/include/mesh_types.h @@ -16,16 +16,6 @@ extern "C" { #endif -typedef signed char s8_t; -typedef signed short s16_t; -typedef signed int s32_t; -typedef signed long long s64_t; - -typedef unsigned char u8_t; -typedef unsigned short u16_t; -typedef unsigned int u32_t; -typedef unsigned long long u64_t; - typedef int bt_mesh_atomic_t; #ifndef PRIu64 diff --git a/components/bt/esp_ble_mesh/mesh_common/include/mesh_util.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_util.h index a1643e7d83..1de3030c74 100644 --- a/components/bt/esp_ble_mesh/mesh_common/include/mesh_util.h +++ b/components/bt/esp_ble_mesh/mesh_common/include/mesh_util.h @@ -25,13 +25,13 @@ extern "C" { * Those are available for 32 bits architectures: */ #ifndef POINTER_TO_UINT -#define POINTER_TO_UINT(x) ((u32_t) (x)) +#define POINTER_TO_UINT(x) ((uint32_t) (x)) #endif #ifndef UINT_TO_POINTER #define UINT_TO_POINTER(x) ((void *) (x)) #endif #ifndef POINTER_TO_INT -#define POINTER_TO_INT(x) ((s32_t) (x)) +#define POINTER_TO_INT(x) ((int32_t) (x)) #endif #ifndef INT_TO_POINTER #define INT_TO_POINTER(x) ((void *) (x)) @@ -56,9 +56,7 @@ extern "C" { * an array (e.g. pointer) */ #ifndef ARRAY_SIZE -#define ARRAY_SIZE(array) \ - ((unsigned long) (IS_ARRAY(array) + \ - (sizeof(array) / sizeof((array)[0])))) +#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) #endif /* Evaluates to 1 if ptr is part of array, 0 otherwise; compile error if @@ -183,7 +181,7 @@ extern "C" { const char *bt_hex(const void *buf, size_t len); -void mem_rcopy(u8_t *dst, u8_t const *src, u16_t len); +void mem_rcopy(uint8_t *dst, uint8_t const *src, uint16_t len); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_common/mesh_buf.c b/components/bt/esp_ble_mesh/mesh_common/mesh_buf.c index 1d7a711de8..8b5c260401 100644 --- a/components/bt/esp_ble_mesh/mesh_common/mesh_buf.c +++ b/components/bt/esp_ble_mesh/mesh_common/mesh_buf.c @@ -16,7 +16,7 @@ int net_buf_id(struct net_buf *buf) } static inline struct net_buf *pool_get_uninit(struct net_buf_pool *pool, - u16_t uninit_count) + uint16_t uninit_count) { struct net_buf *buf = NULL; @@ -35,7 +35,7 @@ void net_buf_simple_clone(const struct net_buf_simple *original, void *net_buf_simple_add(struct net_buf_simple *buf, size_t len) { - u8_t *tail = net_buf_simple_tail(buf); + uint8_t *tail = net_buf_simple_tail(buf); NET_BUF_SIMPLE_DBG("buf %p len %u", buf, len); @@ -53,9 +53,9 @@ void *net_buf_simple_add_mem(struct net_buf_simple *buf, const void *mem, return memcpy(net_buf_simple_add(buf, len), mem, len); } -u8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, u8_t val) +uint8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, uint8_t val) { - u8_t *u8 = NULL; + uint8_t *u8 = NULL; NET_BUF_SIMPLE_DBG("buf %p val 0x%02x", buf, val); @@ -65,70 +65,70 @@ u8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, u8_t val) return u8; } -void net_buf_simple_add_le16(struct net_buf_simple *buf, u16_t val) +void net_buf_simple_add_le16(struct net_buf_simple *buf, uint16_t val) { NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); sys_put_le16(val, net_buf_simple_add(buf, sizeof(val))); } -void net_buf_simple_add_be16(struct net_buf_simple *buf, u16_t val) +void net_buf_simple_add_be16(struct net_buf_simple *buf, uint16_t val) { NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); sys_put_be16(val, net_buf_simple_add(buf, sizeof(val))); } -void net_buf_simple_add_le24(struct net_buf_simple *buf, u32_t val) +void net_buf_simple_add_le24(struct net_buf_simple *buf, uint32_t val) { NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); sys_put_le24(val, net_buf_simple_add(buf, 3)); } -void net_buf_simple_add_be24(struct net_buf_simple *buf, u32_t val) +void net_buf_simple_add_be24(struct net_buf_simple *buf, uint32_t val) { NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); sys_put_be24(val, net_buf_simple_add(buf, 3)); } -void net_buf_simple_add_le32(struct net_buf_simple *buf, u32_t val) +void net_buf_simple_add_le32(struct net_buf_simple *buf, uint32_t val) { NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); sys_put_le32(val, net_buf_simple_add(buf, sizeof(val))); } -void net_buf_simple_add_be32(struct net_buf_simple *buf, u32_t val) +void net_buf_simple_add_be32(struct net_buf_simple *buf, uint32_t val) { NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); sys_put_be32(val, net_buf_simple_add(buf, sizeof(val))); } -void net_buf_simple_add_le48(struct net_buf_simple *buf, u64_t val) +void net_buf_simple_add_le48(struct net_buf_simple *buf, uint64_t val) { NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val); sys_put_le48(val, net_buf_simple_add(buf, 6)); } -void net_buf_simple_add_be48(struct net_buf_simple *buf, u64_t val) +void net_buf_simple_add_be48(struct net_buf_simple *buf, uint64_t val) { NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val); sys_put_be48(val, net_buf_simple_add(buf, 6)); } -void net_buf_simple_add_le64(struct net_buf_simple *buf, u64_t val) +void net_buf_simple_add_le64(struct net_buf_simple *buf, uint64_t val) { NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val); sys_put_le64(val, net_buf_simple_add(buf, sizeof(val))); } -void net_buf_simple_add_be64(struct net_buf_simple *buf, u64_t val) +void net_buf_simple_add_be64(struct net_buf_simple *buf, uint64_t val) { NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val); @@ -146,77 +146,77 @@ void *net_buf_simple_push(struct net_buf_simple *buf, size_t len) return buf->data; } -void net_buf_simple_push_le16(struct net_buf_simple *buf, u16_t val) +void net_buf_simple_push_le16(struct net_buf_simple *buf, uint16_t val) { NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); sys_put_le16(val, net_buf_simple_push(buf, sizeof(val))); } -void net_buf_simple_push_be16(struct net_buf_simple *buf, u16_t val) +void net_buf_simple_push_be16(struct net_buf_simple *buf, uint16_t val) { NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); sys_put_be16(val, net_buf_simple_push(buf, sizeof(val))); } -void net_buf_simple_push_u8(struct net_buf_simple *buf, u8_t val) +void net_buf_simple_push_u8(struct net_buf_simple *buf, uint8_t val) { - u8_t *data = net_buf_simple_push(buf, 1); + uint8_t *data = net_buf_simple_push(buf, 1); *data = val; } -void net_buf_simple_push_le24(struct net_buf_simple *buf, u32_t val) +void net_buf_simple_push_le24(struct net_buf_simple *buf, uint32_t val) { NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); sys_put_le24(val, net_buf_simple_push(buf, 3)); } -void net_buf_simple_push_be24(struct net_buf_simple *buf, u32_t val) +void net_buf_simple_push_be24(struct net_buf_simple *buf, uint32_t val) { NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); sys_put_be24(val, net_buf_simple_push(buf, 3)); } -void net_buf_simple_push_le32(struct net_buf_simple *buf, u32_t val) +void net_buf_simple_push_le32(struct net_buf_simple *buf, uint32_t val) { NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); sys_put_le32(val, net_buf_simple_push(buf, sizeof(val))); } -void net_buf_simple_push_be32(struct net_buf_simple *buf, u32_t val) +void net_buf_simple_push_be32(struct net_buf_simple *buf, uint32_t val) { NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val); sys_put_be32(val, net_buf_simple_push(buf, sizeof(val))); } -void net_buf_simple_push_le48(struct net_buf_simple *buf, u64_t val) +void net_buf_simple_push_le48(struct net_buf_simple *buf, uint64_t val) { NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val); sys_put_le48(val, net_buf_simple_push(buf, 6)); } -void net_buf_simple_push_be48(struct net_buf_simple *buf, u64_t val) +void net_buf_simple_push_be48(struct net_buf_simple *buf, uint64_t val) { NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val); sys_put_be48(val, net_buf_simple_push(buf, 6)); } -void net_buf_simple_push_le64(struct net_buf_simple *buf, u64_t val) +void net_buf_simple_push_le64(struct net_buf_simple *buf, uint64_t val) { NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val); sys_put_le64(val, net_buf_simple_push(buf, sizeof(val))); } -void net_buf_simple_push_be64(struct net_buf_simple *buf, u64_t val) +void net_buf_simple_push_be64(struct net_buf_simple *buf, uint64_t val) { NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val); @@ -247,9 +247,9 @@ void *net_buf_simple_pull_mem(struct net_buf_simple *buf, size_t len) return data; } -u8_t net_buf_simple_pull_u8(struct net_buf_simple *buf) +uint8_t net_buf_simple_pull_u8(struct net_buf_simple *buf) { - u8_t val = 0U; + uint8_t val = 0U; val = buf->data[0]; net_buf_simple_pull(buf, 1); @@ -257,30 +257,30 @@ u8_t net_buf_simple_pull_u8(struct net_buf_simple *buf) return val; } -u16_t net_buf_simple_pull_le16(struct net_buf_simple *buf) +uint16_t net_buf_simple_pull_le16(struct net_buf_simple *buf) { - u16_t val = 0U; + uint16_t val = 0U; - val = UNALIGNED_GET((u16_t *)buf->data); + val = UNALIGNED_GET((uint16_t *)buf->data); net_buf_simple_pull(buf, sizeof(val)); return sys_le16_to_cpu(val); } -u16_t net_buf_simple_pull_be16(struct net_buf_simple *buf) +uint16_t net_buf_simple_pull_be16(struct net_buf_simple *buf) { - u16_t val = 0U; + uint16_t val = 0U; - val = UNALIGNED_GET((u16_t *)buf->data); + val = UNALIGNED_GET((uint16_t *)buf->data); net_buf_simple_pull(buf, sizeof(val)); return sys_be16_to_cpu(val); } -u32_t net_buf_simple_pull_le24(struct net_buf_simple *buf) +uint32_t net_buf_simple_pull_le24(struct net_buf_simple *buf) { struct uint24 { - u32_t u24:24; + uint32_t u24:24; } __packed val; val = UNALIGNED_GET((struct uint24 *)buf->data); @@ -289,10 +289,10 @@ u32_t net_buf_simple_pull_le24(struct net_buf_simple *buf) return sys_le24_to_cpu(val.u24); } -u32_t net_buf_simple_pull_be24(struct net_buf_simple *buf) +uint32_t net_buf_simple_pull_be24(struct net_buf_simple *buf) { struct uint24 { - u32_t u24:24; + uint32_t u24:24; } __packed val; val = UNALIGNED_GET((struct uint24 *)buf->data); @@ -301,30 +301,30 @@ u32_t net_buf_simple_pull_be24(struct net_buf_simple *buf) return sys_be24_to_cpu(val.u24); } -u32_t net_buf_simple_pull_le32(struct net_buf_simple *buf) +uint32_t net_buf_simple_pull_le32(struct net_buf_simple *buf) { - u32_t val = 0U; + uint32_t val = 0U; - val = UNALIGNED_GET((u32_t *)buf->data); + val = UNALIGNED_GET((uint32_t *)buf->data); net_buf_simple_pull(buf, sizeof(val)); return sys_le32_to_cpu(val); } -u32_t net_buf_simple_pull_be32(struct net_buf_simple *buf) +uint32_t net_buf_simple_pull_be32(struct net_buf_simple *buf) { - u32_t val = 0U; + uint32_t val = 0U; - val = UNALIGNED_GET((u32_t *)buf->data); + val = UNALIGNED_GET((uint32_t *)buf->data); net_buf_simple_pull(buf, sizeof(val)); return sys_be32_to_cpu(val); } -u64_t net_buf_simple_pull_le48(struct net_buf_simple *buf) +uint64_t net_buf_simple_pull_le48(struct net_buf_simple *buf) { struct uint48 { - u64_t u48:48; + uint64_t u48:48; } __packed val; val = UNALIGNED_GET((struct uint48 *)buf->data); @@ -333,10 +333,10 @@ u64_t net_buf_simple_pull_le48(struct net_buf_simple *buf) return sys_le48_to_cpu(val.u48); } -u64_t net_buf_simple_pull_be48(struct net_buf_simple *buf) +uint64_t net_buf_simple_pull_be48(struct net_buf_simple *buf) { struct uint48 { - u64_t u48:48; + uint64_t u48:48; } __packed val; val = UNALIGNED_GET((struct uint48 *)buf->data); @@ -345,21 +345,21 @@ u64_t net_buf_simple_pull_be48(struct net_buf_simple *buf) return sys_be48_to_cpu(val.u48); } -u64_t net_buf_simple_pull_le64(struct net_buf_simple *buf) +uint64_t net_buf_simple_pull_le64(struct net_buf_simple *buf) { - u64_t val; + uint64_t val; - val = UNALIGNED_GET((u64_t *)buf->data); + val = UNALIGNED_GET((uint64_t *)buf->data); net_buf_simple_pull(buf, sizeof(val)); return sys_le64_to_cpu(val); } -u64_t net_buf_simple_pull_be64(struct net_buf_simple *buf) +uint64_t net_buf_simple_pull_be64(struct net_buf_simple *buf) { - u64_t val; + uint64_t val; - val = UNALIGNED_GET((u64_t *)buf->data); + val = UNALIGNED_GET((uint64_t *)buf->data); net_buf_simple_pull(buf, sizeof(val)); return sys_be64_to_cpu(val); @@ -506,7 +506,7 @@ void net_buf_unref(struct net_buf *buf) } } -static u8_t *fixed_data_alloc(struct net_buf *buf, size_t *size, s32_t timeout) +static uint8_t *fixed_data_alloc(struct net_buf *buf, size_t *size, int32_t timeout) { struct net_buf_pool *pool = buf->pool; const struct net_buf_pool_fixed *fixed = pool->alloc->alloc_data; @@ -516,7 +516,7 @@ static u8_t *fixed_data_alloc(struct net_buf *buf, size_t *size, s32_t timeout) return fixed->data_pool + fixed->data_size * net_buf_id(buf); } -static void fixed_data_unref(struct net_buf *buf, u8_t *data) +static void fixed_data_unref(struct net_buf *buf, uint8_t *data) { /* Nothing needed for fixed-size data pools */ } @@ -526,7 +526,7 @@ const struct net_buf_data_cb net_buf_fixed_cb = { .unref = fixed_data_unref, }; -static u8_t *data_alloc(struct net_buf *buf, size_t *size, s32_t timeout) +static uint8_t *data_alloc(struct net_buf *buf, size_t *size, int32_t timeout) { struct net_buf_pool *pool = buf->pool; @@ -535,10 +535,10 @@ static u8_t *data_alloc(struct net_buf *buf, size_t *size, s32_t timeout) #if defined(CONFIG_BLE_MESH_NET_BUF_LOG) struct net_buf *net_buf_alloc_len_debug(struct net_buf_pool *pool, size_t size, - s32_t timeout, const char *func, int line) + int32_t timeout, const char *func, int line) #else struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size, - s32_t timeout) + int32_t timeout) #endif { struct net_buf *buf = NULL; @@ -604,7 +604,7 @@ success: #if defined(CONFIG_BLE_MESH_NET_BUF_LOG) struct net_buf *net_buf_alloc_fixed_debug(struct net_buf_pool *pool, - s32_t timeout, const char *func, + int32_t timeout, const char *func, int line) { const struct net_buf_pool_fixed *fixed = pool->alloc->alloc_data; @@ -612,7 +612,7 @@ struct net_buf *net_buf_alloc_fixed_debug(struct net_buf_pool *pool, return net_buf_alloc_len_debug(pool, fixed->data_size, timeout, func, line); } #else -struct net_buf *net_buf_alloc_fixed(struct net_buf_pool *pool, s32_t timeout) +struct net_buf *net_buf_alloc_fixed(struct net_buf_pool *pool, int32_t timeout) { const struct net_buf_pool_fixed *fixed = pool->alloc->alloc_data; @@ -708,7 +708,7 @@ size_t net_buf_linearize(void *dst, size_t dst_len, struct net_buf *src, copied = 0; while (frag && len > 0) { to_copy = MIN(len, frag->len - offset); - memcpy((u8_t *)dst + copied, frag->data + offset, to_copy); + memcpy((uint8_t *)dst + copied, frag->data + offset, to_copy); copied += to_copy; @@ -728,15 +728,15 @@ size_t net_buf_linearize(void *dst, size_t dst_len, struct net_buf *src, * the buffer. It assumes that the buffer has at least one fragment. */ size_t net_buf_append_bytes(struct net_buf *buf, size_t len, - const void *value, s32_t timeout, + const void *value, int32_t timeout, net_buf_allocator_cb allocate_cb, void *user_data) { struct net_buf *frag = net_buf_frag_last(buf); size_t added_len = 0U; - const u8_t *value8 = value; + const uint8_t *value8 = value; do { - u16_t count = MIN(len, net_buf_tailroom(frag)); + uint16_t count = MIN(len, net_buf_tailroom(frag)); net_buf_add_mem(frag, value8, count); len -= count; diff --git a/components/bt/esp_ble_mesh/mesh_common/mesh_common.c b/components/bt/esp_ble_mesh/mesh_common/mesh_common.c index f6fd27f5da..3f0be4bb4a 100644 --- a/components/bt/esp_ble_mesh/mesh_common/mesh_common.c +++ b/components/bt/esp_ble_mesh/mesh_common/mesh_common.c @@ -15,6 +15,8 @@ #include #include +#include "esp_system.h" + #include "mesh_main.h" #include "client_common.h" #include "mesh_common.h" @@ -50,10 +52,10 @@ IRAM_ATTR void bt_mesh_free(void *ptr) heap_caps_free(ptr); } -struct net_buf_simple *bt_mesh_alloc_buf(u16_t size) +struct net_buf_simple *bt_mesh_alloc_buf(uint16_t size) { struct net_buf_simple *buf = NULL; - u8_t *data = NULL; + uint8_t *data = NULL; buf = (struct net_buf_simple *)bt_mesh_calloc(sizeof(struct net_buf_simple) + size); if (!buf) { @@ -61,7 +63,7 @@ struct net_buf_simple *bt_mesh_alloc_buf(u16_t size) return NULL; } - data = (u8_t *)buf + sizeof(struct net_buf_simple); + data = (uint8_t *)buf + sizeof(struct net_buf_simple); buf->data = data; buf->len = 0; @@ -78,7 +80,7 @@ void bt_mesh_free_buf(struct net_buf_simple *buf) } } -u8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send) +uint8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send) { bt_mesh_client_user_data_t *client = NULL; @@ -96,3 +98,17 @@ u8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send) return client->msg_role; } + +int bt_mesh_rand(void *buf, size_t len) +{ + if (buf == NULL || len == 0) { + BT_ERR("%s, Invalid parameter", __func__); + return -EINVAL; + } + + esp_fill_random(buf, len); + + BT_DBG("Random %s", bt_hex(buf, len)); + + return 0; +} diff --git a/components/bt/esp_ble_mesh/mesh_common/mesh_kernel.c b/components/bt/esp_ble_mesh/mesh_common/mesh_kernel.c index b288f6500b..d143b8757b 100644 --- a/components/bt/esp_ble_mesh/mesh_common/mesh_kernel.c +++ b/components/bt/esp_ble_mesh/mesh_common/mesh_kernel.c @@ -8,7 +8,7 @@ #include "mesh_kernel.h" -void k_sleep(s32_t duration) +void k_sleep(int32_t duration) { vTaskDelay(duration / portTICK_PERIOD_MS); } diff --git a/components/bt/esp_ble_mesh/mesh_common/mesh_timer.c b/components/bt/esp_ble_mesh/mesh_common/mesh_timer.c index e1a88d0612..da432de220 100644 --- a/components/bt/esp_ble_mesh/mesh_common/mesh_timer.c +++ b/components/bt/esp_ble_mesh/mesh_common/mesh_timer.c @@ -27,20 +27,20 @@ typedef struct alarm_t { int64_t deadline_us; } osi_alarm_t; -s64_t k_uptime_get(void) +int64_t k_uptime_get(void) { - /** k_uptime_get_32 is in in milliseconds, + /* k_uptime_get_32 is in in milliseconds, * but esp_timer_get_time is in microseconds */ return (esp_timer_get_time() / 1000); } -u32_t k_uptime_get_32(void) +uint32_t k_uptime_get_32(void) { - /** k_uptime_get_32 is in in milliseconds, + /* k_uptime_get_32 is in in milliseconds, * but esp_timer_get_time is in microseconds */ - return (u32_t)(esp_timer_get_time() / 1000); + return (uint32_t)(esp_timer_get_time() / 1000); } void bt_mesh_timer_init(void) @@ -100,7 +100,7 @@ int k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler) return 0; } -int k_delayed_work_submit(struct k_delayed_work *work, s32_t delay) +int k_delayed_work_submit(struct k_delayed_work *work, int32_t delay) { if (!work || !bm_alarm_hash_map) { BT_ERR("%s, Invalid parameter", __func__); @@ -122,7 +122,7 @@ int k_delayed_work_submit(struct k_delayed_work *work, s32_t delay) return 0; } -int k_delayed_work_submit_periodic(struct k_delayed_work *work, s32_t period) +int k_delayed_work_submit_periodic(struct k_delayed_work *work, int32_t period) { if (!work || !bm_alarm_hash_map) { BT_ERR("%s, Invalid parameter", __func__); @@ -186,9 +186,9 @@ int k_delayed_work_free(struct k_delayed_work *work) return 0; } -s32_t k_delayed_work_remaining_get(struct k_delayed_work *work) +int32_t k_delayed_work_remaining_get(struct k_delayed_work *work) { - s32_t time = 0; + int32_t time = 0; if (!work || !bm_alarm_hash_map) { BT_ERR("%s, Invalid parameter", __func__); diff --git a/components/bt/esp_ble_mesh/mesh_common/mesh_util.c b/components/bt/esp_ble_mesh/mesh_common/mesh_util.c index af7a32f7e2..05f682c438 100644 --- a/components/bt/esp_ble_mesh/mesh_common/mesh_util.c +++ b/components/bt/esp_ble_mesh/mesh_common/mesh_util.c @@ -15,8 +15,8 @@ const char *bt_hex(const void *buf, size_t len) { static const char hex[] = "0123456789abcdef"; static char hexbufs[2][129]; - static u8_t curbuf; - const u8_t *b = buf; + static uint8_t curbuf; + const uint8_t *b = buf; char *str = NULL; int i; @@ -35,7 +35,7 @@ const char *bt_hex(const void *buf, size_t len) return str; } -void mem_rcopy(u8_t *dst, u8_t const *src, u16_t len) +void mem_rcopy(uint8_t *dst, uint8_t const *src, uint16_t len) { src += len; while (len--) { diff --git a/components/bt/esp_ble_mesh/mesh_core/access.c b/components/bt/esp_ble_mesh/mesh_core/access.c index 7c67a81979..4c6d355486 100644 --- a/components/bt/esp_ble_mesh/mesh_core/access.c +++ b/components/bt/esp_ble_mesh/mesh_core/access.c @@ -10,8 +10,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_ACCESS) - #include "mesh.h" #include "adv.h" #include "transport.h" @@ -25,7 +23,7 @@ #define BLE_MESH_SDU_MAX_LEN 384 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, @@ -57,7 +55,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 = 0; @@ -95,10 +93,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 = 0U, period = 0U; + uint32_t elapsed = 0U, period = 0U; if (!pub) { BT_ERR("Model has no publication support"); @@ -126,7 +124,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 = 0; + int32_t delay = 0; BT_DBG("err %d", err); @@ -147,7 +145,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; @@ -236,7 +234,7 @@ static void mod_publish(struct k_work *work) struct bt_mesh_model_pub *pub = CONTAINER_OF(work, struct bt_mesh_model_pub, timer.work); - s32_t period_ms = 0; + int32_t period_ms = 0; int err = 0; BT_DBG("%s", __func__); @@ -287,7 +285,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 = NULL; @@ -437,7 +435,7 @@ int bt_mesh_comp_deregister(void) } #endif /* CONFIG_BLE_MESH_DEINIT */ -void bt_mesh_comp_provision(u16_t addr) +void bt_mesh_comp_provision(uint16_t addr) { int i; @@ -462,12 +460,12 @@ void bt_mesh_comp_unprovision(void) dev_primary_addr = BLE_MESH_ADDR_UNASSIGNED; } -u16_t bt_mesh_primary_addr(void) +uint16_t bt_mesh_primary_addr(void) { return dev_primary_addr; } -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) { int i; @@ -481,10 +479,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 = NULL; - u16_t *match = NULL; + uint16_t *match = NULL; int i; for (i = 0; i < elem->model_count; i++) { @@ -508,9 +506,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 = 0U; + uint16_t index = 0U; if (BLE_MESH_ADDR_IS_UNICAST(addr)) { index = (addr - dev_comp->elem[0].addr); @@ -532,12 +530,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; @@ -550,7 +548,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 *model, u16_t dst) +static bool model_has_dst(struct bt_mesh_model *model, uint16_t dst) { if (BLE_MESH_ADDR_IS_UNICAST(dst)) { return (dev_comp->elem[model->elem_idx].addr == dst); @@ -562,7 +560,7 @@ static bool model_has_dst(struct bt_mesh_model *model, 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) { int i; @@ -583,7 +581,7 @@ static const struct bt_mesh_model_op *find_op(struct bt_mesh_model *models, return NULL; } -static int get_opcode(struct net_buf_simple *buf, u32_t *opcode) +static int get_opcode(struct net_buf_simple *buf, uint32_t *opcode) { switch (buf->data[0] >> 6) { case 0x00: @@ -621,7 +619,7 @@ static int get_opcode(struct net_buf_simple *buf, u32_t *opcode) return -EINVAL; } -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) { @@ -642,8 +640,8 @@ void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) { struct bt_mesh_model *models = NULL, *model = NULL; const struct bt_mesh_model_op *op = NULL; - u32_t opcode = 0U; - u8_t count = 0U; + uint32_t opcode = 0U; + uint8_t count = 0U; int i; BT_INFO("recv, app_idx 0x%04x src 0x%04x dst 0x%04x", rx->ctx.app_idx, @@ -714,7 +712,7 @@ void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) } } -void bt_mesh_model_msg_init(struct net_buf_simple *msg, u32_t opcode) +void bt_mesh_model_msg_init(struct net_buf_simple *msg, uint32_t opcode) { net_buf_simple_init(msg, 0); @@ -739,7 +737,7 @@ void bt_mesh_model_msg_init(struct net_buf_simple *msg, u32_t opcode) } } -static bool ready_to_send(u8_t role, u16_t dst) +static bool ready_to_send(uint8_t role, uint16_t dst) { if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned() && role == NODE) { return true; @@ -761,7 +759,7 @@ static int model_send(struct bt_mesh_model *model, struct net_buf_simple *msg, const struct bt_mesh_send_cb *cb, void *cb_data) { - u8_t role = 0U; + uint8_t role = 0U; role = bt_mesh_get_device_role(model, tx->ctx->srv_send); if (role == ROLE_NVAL) { @@ -802,7 +800,7 @@ int bt_mesh_model_send(struct bt_mesh_model *model, const struct bt_mesh_send_cb *cb, void *cb_data) { struct bt_mesh_subnet *sub = NULL; - u8_t role = 0U; + uint8_t role = 0U; role = bt_mesh_get_device_role(model, ctx->srv_send); if (role == ROLE_NVAL) { @@ -911,7 +909,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model) } struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem, - u16_t company, u16_t id) + uint16_t company, uint16_t id) { int i; @@ -925,7 +923,7 @@ struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem, return NULL; } -struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem, u16_t id) +struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem, uint16_t id) { int i; @@ -944,7 +942,7 @@ const struct bt_mesh_comp *bt_mesh_comp_get(void) } /* APIs used by messages encryption in upper transport layer & network layer */ -struct bt_mesh_subnet *bt_mesh_tx_netkey_get(u8_t role, u16_t net_idx) +struct bt_mesh_subnet *bt_mesh_tx_netkey_get(uint8_t role, uint16_t net_idx) { struct bt_mesh_subnet *sub = NULL; @@ -959,9 +957,9 @@ struct bt_mesh_subnet *bt_mesh_tx_netkey_get(u8_t role, u16_t net_idx) return sub; } -const u8_t *bt_mesh_tx_devkey_get(u8_t role, u16_t dst) +const uint8_t *bt_mesh_tx_devkey_get(uint8_t role, uint16_t dst) { - const u8_t *key = NULL; + const uint8_t *key = NULL; if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned() && role == NODE) { key = bt_mesh.dev_key; @@ -974,7 +972,7 @@ const u8_t *bt_mesh_tx_devkey_get(u8_t role, u16_t dst) return key; } -struct bt_mesh_app_key *bt_mesh_tx_appkey_get(u8_t role, u16_t app_idx) +struct bt_mesh_app_key *bt_mesh_tx_appkey_get(uint8_t role, uint16_t app_idx) { struct bt_mesh_app_key *key = NULL; @@ -1069,9 +1067,9 @@ size_t bt_mesh_rx_devkey_size(void) return size; } -const u8_t *bt_mesh_rx_devkey_get(size_t index, u16_t src) +const uint8_t *bt_mesh_rx_devkey_get(size_t index, uint16_t src) { - const u8_t *key = NULL; + const uint8_t *key = NULL; #if CONFIG_BLE_MESH_NODE && !CONFIG_BLE_MESH_PROVISIONER if (bt_mesh_is_provisioned()) { diff --git a/components/bt/esp_ble_mesh/mesh_core/access.h b/components/bt/esp_ble_mesh/mesh_core/access.h index c5615af54d..0f26f9bd5a 100644 --- a/components/bt/esp_ble_mesh/mesh_core/access.h +++ b/components/bt/esp_ble_mesh/mesh_core/access.h @@ -22,16 +22,16 @@ enum { BLE_MESH_MOD_PUB_PENDING = BIT(2), }; -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); -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, @@ -39,27 +39,27 @@ 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 net_buf_simple *buf); int bt_mesh_comp_register(const struct bt_mesh_comp *comp); int bt_mesh_comp_deregister(void); -struct bt_mesh_subnet *bt_mesh_tx_netkey_get(u8_t role, u16_t net_idx); +struct bt_mesh_subnet *bt_mesh_tx_netkey_get(uint8_t role, uint16_t net_idx); -const u8_t *bt_mesh_tx_devkey_get(u8_t role, u16_t dst); +const uint8_t *bt_mesh_tx_devkey_get(uint8_t role, uint16_t dst); -struct bt_mesh_app_key *bt_mesh_tx_appkey_get(u8_t role, u16_t app_idx); +struct bt_mesh_app_key *bt_mesh_tx_appkey_get(uint8_t role, uint16_t app_idx); size_t bt_mesh_rx_netkey_size(void); @@ -67,7 +67,7 @@ struct bt_mesh_subnet *bt_mesh_rx_netkey_get(size_t index); size_t bt_mesh_rx_devkey_size(void); -const u8_t *bt_mesh_rx_devkey_get(size_t index, u16_t src); +const uint8_t *bt_mesh_rx_devkey_get(size_t index, uint16_t src); size_t bt_mesh_rx_appkey_size(void); diff --git a/components/bt/esp_ble_mesh/mesh_core/adv.c b/components/bt/esp_ble_mesh/mesh_core/adv.c index 86a2548467..04a441d592 100644 --- a/components/bt/esp_ble_mesh/mesh_core/adv.c +++ b/components/bt/esp_ble_mesh/mesh_core/adv.c @@ -11,8 +11,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_ADV) - #include "mesh_kernel.h" #include "mesh.h" #include "mesh_hci.h" @@ -43,7 +41,7 @@ static const bt_mesh_addr_t *dev_addr; -static const u8_t adv_type[] = { +static const uint8_t adv_type[] = { [BLE_MESH_ADV_PROV] = BLE_MESH_DATA_MESH_PROV, [BLE_MESH_ADV_DATA] = BLE_MESH_DATA_MESH_MESSAGE, [BLE_MESH_ADV_BEACON] = BLE_MESH_DATA_MESH_BEACON, @@ -59,7 +57,7 @@ struct bt_mesh_queue { QueueHandle_t handle; #if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC StaticQueue_t *buffer; - u8_t *storage; + uint8_t *storage; #endif }; @@ -86,7 +84,7 @@ static QueueSetHandle_t mesh_queue_set; #define BLE_MESH_RELAY_TIME_INTERVAL K_SECONDS(6) #define BLE_MESH_MAX_TIME_INTERVAL 0xFFFFFFFF -static bool ignore_relay_packet(u32_t timestamp); +static bool ignore_relay_packet(uint32_t timestamp); #endif /* defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */ #if CONFIG_BLE_MESH_SUPPORT_BLE_ADV @@ -132,7 +130,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) { @@ -151,12 +149,12 @@ static inline void adv_send_end(int err, const struct bt_mesh_send_cb *cb, static inline int adv_send(struct net_buf *buf) { - const s32_t adv_int_min = ((bt_mesh_dev.hci_version >= BLE_MESH_HCI_VERSION_5_0) ? - ADV_INT_FAST_MS : ADV_INT_DEFAULT_MS); + const int32_t adv_int_min = ((bt_mesh_dev.hci_version >= BLE_MESH_HCI_VERSION_5_0) ? + ADV_INT_FAST_MS : ADV_INT_DEFAULT_MS); const struct bt_mesh_send_cb *cb = BLE_MESH_ADV(buf)->cb; void *cb_data = BLE_MESH_ADV(buf)->cb_data; struct bt_mesh_adv_param param = {0}; - u16_t duration = 0U, adv_int = 0U; + uint16_t duration = 0U, adv_int = 0U; struct bt_mesh_adv_data ad = {0}; int err = 0; @@ -263,7 +261,7 @@ static void adv_thread(void *p) CONFIG_BLE_MESH_GATT_PROXY_SERVER xQueueReceive(adv_queue.handle, &msg, K_NO_WAIT); while (!(*buf)) { - s32_t timeout; + int32_t timeout = 0; BT_DBG("Mesh Proxy Advertising start"); timeout = bt_mesh_proxy_server_adv_start(); BT_DBG("Mesh Proxy Advertising up to %d ms", timeout); @@ -286,7 +284,7 @@ static void adv_thread(void *p) } } else { while (!(*buf)) { - s32_t timeout = 0; + int32_t timeout = 0; BT_DBG("Mesh Proxy Advertising start"); timeout = bt_mesh_proxy_server_adv_start(); BT_DBG("Mesh Proxy Advertising up to %d ms", timeout); @@ -351,7 +349,7 @@ static void adv_thread(void *p) struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_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 = NULL; struct net_buf *buf = NULL; @@ -374,8 +372,8 @@ struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool, (void)memset(adv, 0, sizeof(*adv)); - adv->type = type; - adv->xmit = xmit; + adv->type = type; + adv->xmit = xmit; return buf; } @@ -398,15 +396,15 @@ void bt_mesh_unref_buf_from_pool(struct net_buf_pool *pool) } } -struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, u8_t xmit, - s32_t timeout) +struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, uint8_t xmit, + int32_t timeout) { return bt_mesh_adv_create_from_pool(&adv_buf_pool, adv_alloc, type, xmit, timeout); } void bt_mesh_adv_buf_ref_debug(const char *func, struct net_buf *buf, - u8_t ref_cmp, bt_mesh_buf_ref_flag_t flag) + uint8_t ref_cmp, bt_mesh_buf_ref_flag_t flag) { if (buf == NULL || func == NULL || flag >= BLE_MESH_BUF_REF_MAX) { BT_ERR("%s, Invalid parameter", __func__); @@ -500,10 +498,10 @@ void bt_mesh_adv_update(void) } #if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) -static bool ignore_relay_packet(u32_t timestamp) +static bool ignore_relay_packet(uint32_t timestamp) { - u32_t now = k_uptime_get_32(); - u32_t interval = 0U; + uint32_t now = k_uptime_get_32(); + uint32_t interval = 0U; if (now >= timestamp) { interval = now - timestamp; @@ -519,8 +517,8 @@ static struct bt_mesh_adv *relay_adv_alloc(int id) return &relay_adv_pool[id]; } -struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, u8_t xmit, - s32_t timeout) +struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, uint8_t xmit, + int32_t timeout) { return bt_mesh_adv_create_from_pool(&relay_adv_buf_pool, relay_adv_alloc, type, xmit, timeout); @@ -570,7 +568,7 @@ static void ble_mesh_relay_task_post(bt_mesh_msg_t *msg, uint32_t timeout) } void bt_mesh_relay_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb, - void *cb_data, u16_t src, u16_t dst) + void *cb_data, uint16_t src, uint16_t dst) { bt_mesh_msg_t msg = { .relay = true, @@ -591,9 +589,9 @@ void bt_mesh_relay_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *c ble_mesh_relay_task_post(&msg, K_NO_WAIT); } -u16_t bt_mesh_get_stored_relay_count(void) +uint16_t bt_mesh_get_stored_relay_count(void) { - return (u16_t)uxQueueMessagesWaiting(relay_queue.handle); + return (uint16_t)uxQueueMessagesWaiting(relay_queue.handle); } #endif /* #if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */ @@ -606,7 +604,7 @@ const bt_mesh_addr_t *bt_mesh_get_unprov_dev_addr(void) CONFIG_BLE_MESH_GATT_PROXY_CLIENT static bool adv_flags_valid(struct net_buf_simple *buf) { - u8_t flags = 0U; + uint8_t flags = 0U; if (buf->len != 1U) { BT_DBG("Unexpected adv flags length %d", buf->len); @@ -623,7 +621,7 @@ static bool adv_flags_valid(struct net_buf_simple *buf) return true; } -static bool adv_service_uuid_valid(struct net_buf_simple *buf, u16_t *uuid) +static bool adv_service_uuid_valid(struct net_buf_simple *buf, uint16_t *uuid) { if (buf->len != 2U) { BT_DBG("Length not match mesh service uuid"); @@ -658,9 +656,9 @@ static bool adv_service_uuid_valid(struct net_buf_simple *buf, u16_t *uuid) static void handle_adv_service_data(struct net_buf_simple *buf, const bt_mesh_addr_t *addr, - u16_t uuid, s8_t rssi) + uint16_t uuid, int8_t rssi) { - u16_t type = 0U; + uint16_t type = 0U; if (!buf || !addr) { BT_ERR("%s, Invalid parameter", __func__); @@ -705,12 +703,12 @@ static void handle_adv_service_data(struct net_buf_simple *buf, } #endif -static void bt_mesh_scan_cb(const bt_mesh_addr_t *addr, s8_t rssi, - u8_t adv_type, struct net_buf_simple *buf) +static void bt_mesh_scan_cb(const bt_mesh_addr_t *addr, int8_t rssi, + uint8_t adv_type, struct net_buf_simple *buf) { #if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \ CONFIG_BLE_MESH_GATT_PROXY_CLIENT - u16_t uuid = 0U; + uint16_t uuid = 0U; #endif if (adv_type != BLE_MESH_ADV_NONCONN_IND && adv_type != BLE_MESH_ADV_IND) { @@ -723,7 +721,7 @@ static void bt_mesh_scan_cb(const bt_mesh_addr_t *addr, s8_t rssi, while (buf->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 */ @@ -997,7 +995,7 @@ static struct bt_mesh_adv *ble_adv_alloc(int id) return &ble_adv_pool[id]; } -static struct net_buf *bt_mesh_ble_adv_create(enum bt_mesh_adv_type type, u8_t xmit, s32_t timeout) +static struct net_buf *bt_mesh_ble_adv_create(enum bt_mesh_adv_type type, uint8_t xmit, int32_t timeout) { return bt_mesh_adv_create_from_pool(&ble_adv_buf_pool, ble_adv_alloc, type, xmit, timeout); @@ -1041,7 +1039,7 @@ static void ble_adv_tx_reset(struct ble_adv_tx *tx, bool unref) tx->buf = NULL; } -static void ble_adv_send_start(u16_t duration, int err, void *cb_data) +static void ble_adv_send_start(uint16_t duration, int err, void *cb_data) { struct ble_adv_tx *tx = cb_data; @@ -1107,7 +1105,7 @@ static void ble_adv_resend(struct k_work *work) } int bt_mesh_start_ble_advertising(const struct bt_mesh_ble_adv_param *param, - const struct bt_mesh_ble_adv_data *data, u8_t *index) + const struct bt_mesh_ble_adv_data *data, uint8_t *index) { struct ble_adv_tx *tx = NULL; struct net_buf *buf = NULL; @@ -1205,7 +1203,7 @@ int bt_mesh_start_ble_advertising(const struct bt_mesh_ble_adv_param *param, return 0; } -int bt_mesh_stop_ble_advertising(u8_t index) +int bt_mesh_stop_ble_advertising(uint8_t index) { struct ble_adv_tx *tx = NULL; bool unref = true; diff --git a/components/bt/esp_ble_mesh/mesh_core/adv.h b/components/bt/esp_ble_mesh/mesh_core/adv.h index 79f344e43b..c33e3e1e41 100644 --- a/components/bt/esp_ble_mesh/mesh_core/adv.h +++ b/components/bt/esp_ble_mesh/mesh_core/adv.h @@ -28,9 +28,9 @@ extern "C" { typedef struct bt_mesh_msg { bool relay; /* Flag indicates if the packet is a relayed one */ void *arg; /* Pointer to the struct net_buf */ - u16_t src; /* Source address for relay packets */ - u16_t dst; /* Destination address for relay packets */ - u32_t timestamp; /* Timestamp recorded when the relay packet is posted to queue */ + uint16_t src; /* Source address for relay packets */ + uint16_t dst; /* Destination address for relay packets */ + uint32_t timestamp; /* Timestamp recorded when the relay packet is posted to queue */ } bt_mesh_msg_t; enum bt_mesh_adv_type { @@ -41,23 +41,23 @@ enum bt_mesh_adv_type { BLE_MESH_ADV_BLE, }; -typedef void (*bt_mesh_adv_func_t)(struct net_buf *buf, u16_t duration, +typedef void (*bt_mesh_adv_func_t)(struct net_buf *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:3, - busy:1; - u8_t xmit; + uint8_t type:3, + busy:1; + uint8_t xmit; }; typedef struct bt_mesh_adv *(*bt_mesh_adv_alloc_t)(int id); /* xmit_count: Number of retransmissions, i.e. 0 == 1 transmission */ -struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, u8_t xmit, - s32_t timeout); +struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, uint8_t xmit, + int32_t timeout); typedef enum { BLE_MESH_BUF_REF_EQUAL, @@ -66,12 +66,12 @@ typedef enum { } bt_mesh_buf_ref_flag_t; void bt_mesh_adv_buf_ref_debug(const char *func, struct net_buf *buf, - u8_t ref_cmp, bt_mesh_buf_ref_flag_t flag); + uint8_t ref_cmp, bt_mesh_buf_ref_flag_t flag); struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_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_unref_buf_from_pool(struct net_buf_pool *pool); @@ -80,13 +80,13 @@ void bt_mesh_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb, const bt_mesh_addr_t *bt_mesh_get_unprov_dev_addr(void); -struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, u8_t xmit, - s32_t timeout); +struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, uint8_t xmit, + int32_t timeout); void bt_mesh_relay_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb, - void *cb_data, u16_t src, u16_t dst); + void *cb_data, uint16_t src, uint16_t dst); -u16_t bt_mesh_get_stored_relay_count(void); +uint16_t bt_mesh_get_stored_relay_count(void); void bt_mesh_adv_update(void); @@ -101,9 +101,9 @@ int bt_mesh_scan_with_wl_enable(void); #if CONFIG_BLE_MESH_SUPPORT_BLE_ADV int bt_mesh_start_ble_advertising(const struct bt_mesh_ble_adv_param *param, - const struct bt_mesh_ble_adv_data *data, u8_t *index); + const struct bt_mesh_ble_adv_data *data, uint8_t *index); -int bt_mesh_stop_ble_advertising(u8_t index); +int bt_mesh_stop_ble_advertising(uint8_t index); #endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */ #ifdef __cplusplus diff --git a/components/bt/esp_ble_mesh/mesh_core/beacon.c b/components/bt/esp_ble_mesh/mesh_core/beacon.c index 03776de7d0..2cc632b23d 100644 --- a/components/bt/esp_ble_mesh/mesh_core/beacon.c +++ b/components/bt/esp_ble_mesh/mesh_core/beacon.c @@ -10,8 +10,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_BEACON) - #include "adv.h" #include "mesh.h" #include "prov.h" @@ -40,12 +38,12 @@ /* 1 transmission, 20ms interval */ #define PROV_XMIT BLE_MESH_TRANSMIT(0, 20) -#define SNB_NET_IDX_SET(_val) ((void *)((u32_t)(_val))) -#define SNB_NET_IDX_GET(_ptr) ((u32_t)(_ptr)) +#define SNB_NET_IDX_SET(_val) ((void *)((uint32_t)(_val))) +#define SNB_NET_IDX_GET(_ptr) ((uint32_t)(_ptr)) 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]) { size_t subnet_size = 0U; int i = 0; @@ -67,7 +65,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); } @@ -75,11 +73,11 @@ static void cache_add(u8_t data[21], struct bt_mesh_subnet *sub) static void beacon_complete(int err, void *user_data) { struct bt_mesh_subnet *sub = NULL; - u16_t net_idx = BLE_MESH_KEY_UNUSED; + uint16_t net_idx = BLE_MESH_KEY_UNUSED; BT_DBG("err %d", err); - net_idx = (u16_t)SNB_NET_IDX_GET(user_data); + net_idx = (uint16_t)SNB_NET_IDX_GET(user_data); /* For node, directly updating the "beacon_sent" timestamp is fine, * since the subnet is pre-allocated. @@ -103,7 +101,7 @@ static void beacon_complete(int err, void *user_data) void bt_mesh_beacon_create(struct bt_mesh_subnet *sub, struct net_buf_simple *buf) { - u8_t flags = bt_mesh_net_flags(sub); + uint8_t flags = bt_mesh_net_flags(sub); struct bt_mesh_subnet_keys *keys = NULL; net_buf_simple_add_u8(buf, BEACON_TYPE_SECURE); @@ -131,15 +129,14 @@ void bt_mesh_beacon_create(struct bt_mesh_subnet *sub, } /* If the interval has passed or is within 5 seconds from now send a beacon */ -#define BEACON_THRESHOLD(sub) (K_SECONDS(10 * ((sub)->beacons_last + 1)) - \ - K_SECONDS(5)) +#define BEACON_THRESHOLD(sub) (K_SECONDS(10 * ((sub)->beacons_last + 1)) - K_SECONDS(5)) 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(); size_t subnet_size = 0U; int i = 0; @@ -150,7 +147,7 @@ static int secure_beacon_send(void) for (i = 0; i < subnet_size; i++) { struct bt_mesh_subnet *sub = bt_mesh_rx_netkey_get(i); struct net_buf *buf; - u32_t time_diff; + uint32_t time_diff; if (sub == NULL || sub->net_idx == BLE_MESH_KEY_UNUSED) { continue; @@ -205,9 +202,9 @@ static int unprovisioned_beacon_send(void) { #if defined(CONFIG_BLE_MESH_PB_ADV) const struct bt_mesh_prov *prov = NULL; - u8_t uri_hash[16] = { 0 }; + uint8_t uri_hash[16] = { 0 }; struct net_buf *buf = NULL; - u16_t oob_info = 0U; + uint16_t oob_info = 0U; BT_DBG("%s", __func__); @@ -334,11 +331,13 @@ static void beacon_send(struct k_work *work) static void secure_beacon_recv(struct net_buf_simple *buf) { - u8_t *data = NULL, *net_id = NULL, *auth = NULL; + uint8_t *data = NULL, *net_id = NULL, *auth = NULL; struct bt_mesh_subnet *sub = NULL; - u32_t iv_index = 0U; - bool new_key = false, kr_change = false, iv_change = false; - u8_t flags = 0U; + uint32_t iv_index = 0U; + bool kr_change = false; + bool iv_change = false; + bool new_key = false; + uint8_t flags = 0U; if (buf->len < 21) { BT_ERR("Too short secure beacon (len %u)", buf->len); @@ -413,9 +412,9 @@ update_stats: } } -void bt_mesh_beacon_recv(struct net_buf_simple *buf, s8_t rssi) +void bt_mesh_beacon_recv(struct net_buf_simple *buf, int8_t rssi) { - u8_t type = 0U; + uint8_t type = 0U; BT_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len)); diff --git a/components/bt/esp_ble_mesh/mesh_core/beacon.h b/components/bt/esp_ble_mesh/mesh_core/beacon.h index a7dbdd81fe..aac8c16e82 100644 --- a/components/bt/esp_ble_mesh/mesh_core/beacon.h +++ b/components/bt/esp_ble_mesh/mesh_core/beacon.h @@ -20,7 +20,7 @@ void bt_mesh_beacon_disable(void); void bt_mesh_beacon_ivu_initiator(bool enable); -void bt_mesh_beacon_recv(struct net_buf_simple *buf, s8_t rssi); +void bt_mesh_beacon_recv(struct net_buf_simple *buf, int8_t rssi); void bt_mesh_beacon_create(struct bt_mesh_subnet *sub, struct net_buf_simple *buf); diff --git a/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c b/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c index a3ce1cd564..dc1c19b139 100644 --- a/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c +++ b/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c @@ -38,8 +38,8 @@ struct bt_mesh_dev bt_mesh_dev; } \ } while(0); -#define BLE_MESH_GATT_GET_CONN_ID(conn_id) (((u16_t)(conn_id)) >> 8) -#define BLE_MESH_GATT_CREATE_CONN_ID(gatt_if, conn_id) ((u16_t)((((u8_t)(conn_id)) << 8) | ((u8_t)(gatt_if)))) +#define BLE_MESH_GATT_GET_CONN_ID(conn_id) (((uint16_t)(conn_id)) >> 8) +#define BLE_MESH_GATT_CREATE_CONN_ID(gatt_if, conn_id) ((uint16_t)((((uint8_t)(conn_id)) << 8) | ((uint8_t)(gatt_if)))) /* We don't need to manage the BLE_MESH_DEV_ADVERTISING flags in the version of Bluedroid, * it will manage it in the BTM layer. @@ -47,7 +47,7 @@ struct bt_mesh_dev bt_mesh_dev; #define BLE_MESH_DEV 0 /* P-256 Variables */ -static u8_t bt_mesh_public_key[64]; +static uint8_t bt_mesh_public_key[64]; static BT_OCTET32 bt_mesh_private_key; /* Scan related functions */ @@ -66,11 +66,11 @@ static struct bt_mesh_conn bt_mesh_gatts_conn[BLE_MESH_MAX_CONN]; static struct bt_mesh_conn_cb *bt_mesh_gatts_conn_cb; static tBTA_GATTS_IF bt_mesh_gatts_if; static BD_ADDR bt_mesh_gatts_addr; -static u16_t svc_handle, char_handle; +static uint16_t svc_handle, char_handle; static future_t *future_mesh; /* Static Functions */ -static struct bt_mesh_gatt_attr *bt_mesh_gatts_find_attr_by_handle(u16_t handle); +static struct bt_mesh_gatt_attr *bt_mesh_gatts_find_attr_by_handle(uint16_t handle); #endif #if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \ @@ -81,14 +81,14 @@ static struct gattc_prov_info { /* Service to be found depends on the type of adv pkt received */ struct bt_mesh_conn conn; bt_mesh_addr_t addr; - u16_t service_uuid; - u16_t mtu; - bool wr_desc_done; /* Indicate if write char descriptor event is received */ - u16_t start_handle; /* Service attribute start handle */ - u16_t end_handle; /* Service attribute end handle */ - u16_t data_in_handle; /* Data In Characteristic attribute handle */ - u16_t data_out_handle; /* Data Out Characteristic attribute handle */ - u16_t ccc_handle; /* Data Out Characteristic CCC attribute handle */ + uint16_t service_uuid; + uint16_t mtu; + bool wr_desc_done; /* Indicate if write char descriptor event is received */ + uint16_t start_handle; /* Service attribute start handle */ + uint16_t end_handle; /* Service attribute end handle */ + uint16_t data_in_handle; /* Data In Characteristic attribute handle */ + uint16_t data_out_handle; /* Data Out Characteristic attribute handle */ + uint16_t ccc_handle; /* Data Out Characteristic CCC attribute handle */ } bt_mesh_gattc_info[BLE_MESH_MAX_CONN]; static struct bt_mesh_prov_conn_cb *bt_mesh_gattc_conn_cb; static tBTA_GATTC_IF bt_mesh_gattc_if; @@ -128,7 +128,7 @@ void bt_mesh_hci_init(void) bt_mesh_dev.le.states = (states_sh << 32) | states_fh; } -static void bt_mesh_scan_results_change_2_bta(tBTM_INQ_RESULTS *p_inq, u8_t *p_eir, +static void bt_mesh_scan_results_change_2_bta(tBTM_INQ_RESULTS *p_inq, uint8_t *p_eir, tBTA_DM_SEARCH_CBACK *p_scan_cback) { tBTM_INQ_INFO *p_inq_info = NULL; @@ -166,7 +166,7 @@ static void bt_mesh_scan_results_change_2_bta(tBTM_INQ_RESULTS *p_inq, u8_t *p_e } } -static void bt_mesh_scan_results_cb(tBTM_INQ_RESULTS *p_inq, u8_t *p_eir) +static void bt_mesh_scan_results_cb(tBTM_INQ_RESULTS *p_inq, uint8_t *p_eir) { bt_mesh_scan_results_change_2_bta(p_inq, p_eir, bt_mesh_scan_result_callback); } @@ -190,7 +190,7 @@ static bool valid_adv_param(const struct bt_mesh_adv_param *param) return true; } -static int set_adv_data(u16_t hci_op, const struct bt_mesh_adv_data *ad, size_t ad_len) +static int set_adv_data(uint16_t hci_op, const struct bt_mesh_adv_data *ad, size_t ad_len) { struct bt_mesh_hci_cp_set_adv_data param = {0}; int i; @@ -222,7 +222,7 @@ static int set_adv_data(u16_t hci_op, const struct bt_mesh_adv_data *ad, size_t return 0; } -static void start_adv_completed_cb(u8_t status) +static void start_adv_completed_cb(uint8_t status) { #if BLE_MESH_DEV if (!status) { @@ -258,8 +258,8 @@ static bool valid_scan_param(const struct bt_mesh_scan_param *param) return true; } -static int start_le_scan(u8_t scan_type, u16_t interval, u16_t window, - u8_t filter_dup, u8_t scan_fil_policy) +static int start_le_scan(uint8_t scan_type, uint16_t interval, uint16_t window, + uint8_t filter_dup, uint8_t scan_fil_policy) { UINT8 addr_type_own = BLE_MESH_ADDR_PUBLIC; /* Currently only support Public Address */ tGATT_IF client_if = 0xFF; /* Default GATT interface id */ @@ -285,8 +285,8 @@ static int start_le_scan(u8_t scan_type, u16_t interval, u16_t window, static void bt_mesh_scan_result_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data) { bt_mesh_addr_t addr = {0}; - u8_t adv_type = 0U; - s8_t rssi = 0; + uint8_t adv_type = 0U; + int8_t rssi = 0; BT_DBG("%s, event %d", __func__, event); @@ -326,7 +326,7 @@ int bt_le_adv_start(const struct bt_mesh_adv_param *param, tBLE_ADDR_TYPE addr_type_own = 0U; tBLE_BD_ADDR p_dir_bda = {0}; tBTM_BLE_AFP adv_fil_pol = 0U; - u8_t adv_type = 0U; + uint8_t adv_type = 0U; int err = 0; #if BLE_MESH_DEV @@ -532,10 +532,10 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) break; case BTA_GATTS_READ_EVT: { struct bt_mesh_gatt_attr *attr = bt_mesh_gatts_find_attr_by_handle(p_data->req_data.p_data->read_req.handle); - u8_t index = BLE_MESH_GATT_GET_CONN_ID(p_data->req_data.conn_id); + uint8_t index = BLE_MESH_GATT_GET_CONN_ID(p_data->req_data.conn_id); tBTA_GATTS_RSP rsp = {0}; - u8_t buf[100] = {0}; - u16_t len = 0; + uint8_t buf[100] = {0}; + uint16_t len = 0; BT_DBG("gatts read, handle %d", p_data->req_data.p_data->read_req.handle); @@ -556,8 +556,8 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) } case BTA_GATTS_WRITE_EVT: { struct bt_mesh_gatt_attr *attr = bt_mesh_gatts_find_attr_by_handle(p_data->req_data.p_data->write_req.handle); - u8_t index = BLE_MESH_GATT_GET_CONN_ID(p_data->req_data.conn_id); - u16_t len = 0; + uint8_t index = BLE_MESH_GATT_GET_CONN_ID(p_data->req_data.conn_id); + uint16_t len = 0; BT_DBG("gatts write, handle %d, len %d, data %s", p_data->req_data.p_data->write_req.handle, p_data->req_data.p_data->write_req.len, @@ -620,7 +620,7 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) bt_mesh_atomic_test_and_clear_bit(bt_mesh_dev.flags, BLE_MESH_DEV_ADVERTISING); #endif if (bt_mesh_gatts_conn_cb != NULL && bt_mesh_gatts_conn_cb->connected != NULL) { - u8_t index = BLE_MESH_GATT_GET_CONN_ID(p_data->conn.conn_id); + uint8_t index = BLE_MESH_GATT_GET_CONN_ID(p_data->conn.conn_id); if (index < BLE_MESH_MAX_CONN) { bt_mesh_gatts_conn[index].handle = BLE_MESH_GATT_GET_CONN_ID(p_data->conn.conn_id); (bt_mesh_gatts_conn_cb->connected)(&bt_mesh_gatts_conn[index], 0); @@ -639,7 +639,7 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) bt_mesh_atomic_test_and_clear_bit(bt_mesh_dev.flags, BLE_MESH_DEV_ADVERTISING); #endif if (bt_mesh_gatts_conn_cb != NULL && bt_mesh_gatts_conn_cb->disconnected != NULL) { - u8_t index = BLE_MESH_GATT_GET_CONN_ID(p_data->conn.conn_id); + uint8_t index = BLE_MESH_GATT_GET_CONN_ID(p_data->conn.conn_id); if (index < BLE_MESH_MAX_CONN) { bt_mesh_gatts_conn[index].handle = BLE_MESH_GATT_GET_CONN_ID(p_data->conn.conn_id); (bt_mesh_gatts_conn_cb->disconnected)(&bt_mesh_gatts_conn[index], p_data->conn.reason); @@ -664,7 +664,7 @@ void bt_mesh_gatts_conn_cb_deregister(void) bt_mesh_gatts_conn_cb = NULL; } -static struct bt_mesh_gatt_attr *bt_mesh_gatts_find_attr_by_handle(u16_t handle) +static struct bt_mesh_gatt_attr *bt_mesh_gatts_find_attr_by_handle(uint16_t handle) { struct bt_mesh_gatt_service *svc = NULL; struct bt_mesh_gatt_attr *attr = NULL; @@ -684,7 +684,7 @@ static struct bt_mesh_gatt_attr *bt_mesh_gatts_find_attr_by_handle(u16_t handle) return NULL; } -static void bt_mesh_gatts_foreach_attr(u16_t start_handle, u16_t end_handle, +static void bt_mesh_gatts_foreach_attr(uint16_t start_handle, uint16_t end_handle, bt_mesh_gatt_attr_func_t func, void *user_data) { struct bt_mesh_gatt_service *svc = NULL; @@ -708,7 +708,7 @@ static void bt_mesh_gatts_foreach_attr(u16_t start_handle, u16_t end_handle, } } -static u8_t find_next(const struct bt_mesh_gatt_attr *attr, void *user_data) +static uint8_t find_next(const struct bt_mesh_gatt_attr *attr, void *user_data) { struct bt_mesh_gatt_attr **next = user_data; @@ -728,10 +728,10 @@ static struct bt_mesh_gatt_attr *bt_mesh_gatts_attr_next(const struct bt_mesh_ga ssize_t bt_mesh_gatts_attr_read(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - void *buf, u16_t buf_len, u16_t offset, - const void *value, u16_t value_len) + void *buf, uint16_t buf_len, uint16_t offset, + const void *value, uint16_t value_len) { - u16_t len = 0U; + uint16_t len = 0U; if (offset > value_len) { return BLE_MESH_GATT_ERR(BLE_MESH_ATT_ERR_INVALID_OFFSET); @@ -747,19 +747,19 @@ ssize_t bt_mesh_gatts_attr_read(struct bt_mesh_conn *conn, } struct gatts_incl { - u16_t start_handle; - u16_t end_handle; - u16_t uuid16; + uint16_t start_handle; + uint16_t end_handle; + uint16_t uuid16; } __packed; ssize_t bt_mesh_gatts_attr_read_included(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - void *buf, u16_t len, u16_t offset) + void *buf, uint16_t len, uint16_t offset) { struct bt_mesh_gatt_attr *incl = attr->user_data; struct bt_mesh_uuid *uuid = incl->user_data; struct gatts_incl pdu = {0}; - u8_t value_len = 0U; + uint8_t value_len = 0U; /* First attr points to the start handle */ pdu.start_handle = sys_cpu_to_le16(incl->handle); @@ -779,12 +779,12 @@ ssize_t bt_mesh_gatts_attr_read_included(struct bt_mesh_conn *conn, ssize_t bt_mesh_gatts_attr_read_service(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - void *buf, u16_t len, u16_t offset) + void *buf, uint16_t len, uint16_t offset) { struct bt_mesh_uuid *uuid = attr->user_data; if (uuid->type == BLE_MESH_UUID_TYPE_16) { - u16_t uuid16 = sys_cpu_to_le16(BLE_MESH_UUID_16(uuid)->val); + uint16_t uuid16 = sys_cpu_to_le16(BLE_MESH_UUID_16(uuid)->val); return bt_mesh_gatts_attr_read(conn, attr, buf, len, offset, &uuid16, 2); } @@ -794,22 +794,22 @@ ssize_t bt_mesh_gatts_attr_read_service(struct bt_mesh_conn *conn, } struct gatts_chrc { - u8_t properties; - u16_t value_handle; + uint8_t properties; + uint16_t value_handle; union { - u16_t uuid16; - u8_t uuid[16]; + uint16_t uuid16; + uint8_t uuid[16]; }; } __packed; ssize_t bt_mesh_gatts_attr_read_chrc(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - void *buf, u16_t len, u16_t offset) + void *buf, uint16_t len, uint16_t offset) { struct bt_mesh_gatt_char *chrc = attr->user_data; const struct bt_mesh_gatt_attr *next = NULL; struct gatts_chrc pdu = {0}; - u8_t value_len = 0U; + uint8_t value_len = 0U; pdu.properties = chrc->properties; /* BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part G] page 534: @@ -862,7 +862,7 @@ static void bta_uuid_to_bt_mesh_uuid(tBT_UUID *bta_uuid, const struct bt_mesh_uu static int gatts_register(struct bt_mesh_gatt_service *svc) { struct bt_mesh_gatt_service *last = NULL; - u16_t handle = 0U; + uint16_t handle = 0U; if (sys_slist_is_empty(&bt_mesh_gatts_db)) { handle = 0; @@ -890,7 +890,7 @@ static int gatts_deregister(struct bt_mesh_gatt_service *svc) return 0; } -static tBTA_GATT_PERM bt_mesh_perm_to_bta_perm(u8_t perm) +static tBTA_GATT_PERM bt_mesh_perm_to_bta_perm(uint8_t perm) { tBTA_GATT_PERM bta_perm = 0; @@ -1025,10 +1025,10 @@ int bt_mesh_gatts_service_deregister(struct bt_mesh_gatt_service *svc) return 0; } -int bt_mesh_gatts_disconnect(struct bt_mesh_conn *conn, u8_t reason) +int bt_mesh_gatts_disconnect(struct bt_mesh_conn *conn, uint8_t reason) { UNUSED(reason); - u16_t conn_id = BLE_MESH_GATT_CREATE_CONN_ID(bt_mesh_gatts_if, conn->handle); + uint16_t conn_id = BLE_MESH_GATT_CREATE_CONN_ID(bt_mesh_gatts_if, conn->handle); BTA_GATTS_Close(conn_id); return 0; } @@ -1043,14 +1043,14 @@ int bt_mesh_gatts_service_unregister(struct bt_mesh_gatt_service *svc) int bt_mesh_gatts_notify(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - const void *data, u16_t len) + const void *data, uint16_t len) { - u16_t conn_id = BLE_MESH_GATT_CREATE_CONN_ID(bt_mesh_gatts_if, conn->handle); - BTA_GATTS_HandleValueIndication(conn_id, attr->handle, len, (u8_t *)data, false); + uint16_t conn_id = BLE_MESH_GATT_CREATE_CONN_ID(bt_mesh_gatts_if, conn->handle); + BTA_GATTS_HandleValueIndication(conn_id, attr->handle, len, (uint8_t *)data, false); return 0; } -u16_t bt_mesh_gatt_get_mtu(struct bt_mesh_conn *conn) +uint16_t bt_mesh_gatt_get_mtu(struct bt_mesh_conn *conn) { return BTA_GATT_GetLocalMTU(); } @@ -1120,9 +1120,9 @@ void bt_mesh_gattc_conn_cb_deregister(void) bt_mesh_gattc_conn_cb = NULL; } -u8_t bt_mesh_gattc_get_free_conn_count(void) +uint8_t bt_mesh_gattc_get_free_conn_count(void) { - u8_t count = 0U; + uint8_t count = 0U; int i; for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) { @@ -1135,7 +1135,7 @@ u8_t bt_mesh_gattc_get_free_conn_count(void) return count; } -u16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn) +uint16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn) { int i; @@ -1159,9 +1159,9 @@ u16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn) * 6. Set the Notification bit of CCC */ -int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid) +int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, uint16_t service_uuid) { - u8_t zero[6] = {0}; + uint8_t zero[6] = {0}; int i; if (!addr || !memcmp(addr->val, zero, BLE_MESH_ADDR_LEN) || @@ -1222,20 +1222,20 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid) return 0; } -void bt_mesh_gattc_exchange_mtu(u8_t index) +void bt_mesh_gattc_exchange_mtu(uint8_t index) { /** Set local MTU and exchange with GATT server. * ATT_MTU >= 69 for Mesh GATT Prov Service * ATT_NTU >= 33 for Mesh GATT Proxy Service */ - u16_t conn_id = 0U; + uint16_t conn_id = 0U; conn_id = BLE_MESH_GATT_CREATE_CONN_ID(bt_mesh_gattc_if, bt_mesh_gattc_info[index].conn.handle); BTA_GATTC_ConfigureMTU(conn_id); } -u16_t bt_mesh_gattc_get_mtu_info(struct bt_mesh_conn *conn) +uint16_t bt_mesh_gattc_get_mtu_info(struct bt_mesh_conn *conn) { int i; @@ -1250,9 +1250,9 @@ u16_t bt_mesh_gattc_get_mtu_info(struct bt_mesh_conn *conn) int bt_mesh_gattc_write_no_rsp(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - const void *data, u16_t len) + const void *data, uint16_t len) { - u16_t conn_id = 0U; + uint16_t conn_id = 0U; int i; for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) { @@ -1260,7 +1260,7 @@ int bt_mesh_gattc_write_no_rsp(struct bt_mesh_conn *conn, conn_id = BLE_MESH_GATT_CREATE_CONN_ID(bt_mesh_gattc_if, bt_mesh_gattc_info[i].conn.handle); BTA_GATTC_WriteCharValue(conn_id, bt_mesh_gattc_info[i].data_in_handle, BTA_GATTC_TYPE_WRITE_NO_RSP, len, - (u8_t *)data, BTA_GATT_AUTH_REQ_NONE); + (uint8_t *)data, BTA_GATT_AUTH_REQ_NONE); return 0; } } @@ -1279,7 +1279,7 @@ void bt_mesh_gattc_disconnect(struct bt_mesh_conn *conn) * when proxy_disconnected callback comes, the proxy server * information and prov_link information should be cleared. */ - u16_t conn_id = 0U; + uint16_t conn_id = 0U; int i; for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) { @@ -1304,14 +1304,14 @@ void bt_mesh_gattc_disconnect(struct bt_mesh_conn *conn) static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data) { struct bt_mesh_conn *conn = NULL; - u16_t handle = 0U; + uint16_t handle = 0U; ssize_t len = 0; int i = 0; switch (event) { case BTA_GATTC_REG_EVT: if (p_data->reg_oper.status == BTA_GATT_OK) { - u8_t uuid[16] = { [0 ... 15] = BLE_MESH_GATTC_APP_UUID_BYTE }; + uint8_t uuid[16] = { [0 ... 15] = BLE_MESH_GATTC_APP_UUID_BYTE }; BT_DBG("BTA_GATTC_REG_EVT"); @@ -1386,13 +1386,13 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data) return; } - u16_t notify_en = BLE_MESH_GATT_CCC_NOTIFY; + uint16_t notify_en = BLE_MESH_GATT_CCC_NOTIFY; btgatt_db_element_t *result = NULL; tBT_UUID char_uuid = {0}; tBTA_GATT_STATUS status = 0U; tBTA_GATT_UNFMT write = {0}; - u16_t count = 0U; - u16_t num = 0; + uint16_t count = 0U; + uint16_t num = 0; /* Get the characteristic num within Mesh Provisioning/Proxy Service */ BTA_GATTC_GetDBSizeByType(p_data->search_cmpl.conn_id, BTGATT_DB_CHARACTERISTIC, @@ -1490,7 +1490,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data) * Characteristic Descriptor. */ write.len = sizeof(notify_en); - write.p_value = (u8_t *)¬ify_en; + write.p_value = (uint8_t *)¬ify_en; BTA_GATTC_WriteCharDescr(p_data->search_cmpl.conn_id, result[0].attribute_handle, BTA_GATTC_TYPE_WRITE, &write, BTA_GATT_AUTH_REQ_NONE); @@ -1797,30 +1797,12 @@ void bt_mesh_adapt_init(void) bt_mesh_rand(bt_mesh_private_key, sizeof(bt_mesh_private_key)); } -int bt_mesh_rand(void *buf, size_t len) -{ - int i; - - if (buf == NULL || len == 0) { - BT_ERR("%s, Invalid parameter", __func__); - return -EAGAIN; - } - - for (i = 0; i < (int)(len / sizeof(u32_t)); i++) { - u32_t rand = esp_random(); - memcpy(buf + i * sizeof(u32_t), &rand, sizeof(u32_t)); - } - - BT_DBG("Rand %s", bt_hex(buf, len)); - return 0; -} - -void bt_mesh_set_private_key(const u8_t pri_key[32]) +void bt_mesh_set_private_key(const uint8_t pri_key[32]) { memcpy(bt_mesh_private_key, pri_key, 32); } -const u8_t *bt_mesh_pub_key_get(void) +const uint8_t *bt_mesh_pub_key_get(void) { BT_OCTET32 private_key = {0}; Point public_key = {0}; @@ -1856,11 +1838,11 @@ const u8_t *bt_mesh_pub_key_get(void) return bt_mesh_public_key; } -bool bt_mesh_check_public_key(const u8_t key[64]) +bool bt_mesh_check_public_key(const uint8_t key[64]) { struct p256_pub_key { - u8_t x[32]; - u8_t y[32]; + uint8_t x[32]; + uint8_t y[32]; } check = {0}; sys_memcpy_swap(check.x, key, 32); @@ -1869,7 +1851,7 @@ bool bt_mesh_check_public_key(const u8_t key[64]) return ECC_CheckPointIsInElliCur_P256((Point *)&check); } -int bt_mesh_dh_key_gen(const u8_t remote_pk[64], bt_mesh_dh_key_cb_t cb, const u8_t idx) +int bt_mesh_dh_key_gen(const uint8_t remote_pk[64], bt_mesh_dh_key_cb_t cb, const uint8_t idx) { BT_OCTET32 private_key = {0}; Point peer_pub_key = {0}; @@ -1890,15 +1872,15 @@ int bt_mesh_dh_key_gen(const u8_t remote_pk[64], bt_mesh_dh_key_cb_t cb, const u BT_DBG("new public key y = %s", bt_hex(new_pub_key.y, 32)); if (cb != NULL) { - cb((const u8_t *)new_pub_key.x, idx); + cb((const uint8_t *)new_pub_key.x, idx); } return 0; } #if CONFIG_MBEDTLS_HARDWARE_AES -static void ecb_encrypt(u8_t const *const key_le, u8_t const *const clear_text_le, - u8_t *const cipher_text_le, u8_t *const cipher_text_be) +static void ecb_encrypt(uint8_t const *const key_le, uint8_t const *const clear_text_le, + uint8_t *const cipher_text_le, uint8_t *const cipher_text_be) { struct bt_mesh_ecb_param ecb = {0}; mbedtls_aes_context aes_ctx = {0}; @@ -1919,8 +1901,8 @@ static void ecb_encrypt(u8_t const *const key_le, u8_t const *const clear_text_l } } -static void ecb_encrypt_be(u8_t const *const key_be, u8_t const *const clear_text_be, - u8_t *const cipher_text_be) +static void ecb_encrypt_be(uint8_t const *const key_be, uint8_t const *const clear_text_be, + uint8_t *const cipher_text_be) { struct bt_mesh_ecb_param ecb = {0}; mbedtls_aes_context aes_ctx = {0}; @@ -1934,8 +1916,8 @@ static void ecb_encrypt_be(u8_t const *const key_be, u8_t const *const clear_tex } #endif /* CONFIG_MBEDTLS_HARDWARE_AES */ -int bt_mesh_encrypt_le(const u8_t key[16], const u8_t plaintext[16], - u8_t enc_data[16]) +int bt_mesh_encrypt_le(const uint8_t key[16], const uint8_t plaintext[16], + uint8_t enc_data[16]) { #if CONFIG_MBEDTLS_HARDWARE_AES BT_DBG("key %s plaintext %s", bt_hex(key, 16), bt_hex(plaintext, 16)); @@ -1946,7 +1928,7 @@ int bt_mesh_encrypt_le(const u8_t key[16], const u8_t plaintext[16], return 0; #else /* CONFIG_MBEDTLS_HARDWARE_AES */ struct tc_aes_key_sched_struct s = {0}; - u8_t tmp[16] = {0}; + uint8_t tmp[16] = {0}; BT_DBG("key %s plaintext %s", bt_hex(key, 16), bt_hex(plaintext, 16)); @@ -1970,8 +1952,8 @@ int bt_mesh_encrypt_le(const u8_t key[16], const u8_t plaintext[16], #endif /* CONFIG_MBEDTLS_HARDWARE_AES */ } -int bt_mesh_encrypt_be(const u8_t key[16], const u8_t plaintext[16], - u8_t enc_data[16]) +int bt_mesh_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16], + uint8_t enc_data[16]) { #if CONFIG_MBEDTLS_HARDWARE_AES BT_DBG("key %s plaintext %s", bt_hex(key, 16), bt_hex(plaintext, 16)); @@ -2001,7 +1983,7 @@ int bt_mesh_encrypt_be(const u8_t key[16], const u8_t plaintext[16], } #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) -int bt_mesh_update_exceptional_list(u8_t sub_code, u8_t type, void *info) +int bt_mesh_update_exceptional_list(uint8_t sub_code, uint8_t type, void *info) { BD_ADDR value = {0}; @@ -2016,7 +1998,7 @@ int bt_mesh_update_exceptional_list(u8_t sub_code, u8_t type, void *info) BT_ERR("Invalid Provisioning Link ID"); return -EINVAL; } - sys_memcpy_swap(value, info, sizeof(u32_t)); + sys_memcpy_swap(value, info, sizeof(uint32_t)); } BT_DBG("%s exceptional list, type 0x%02x", sub_code ? "Remove" : "Add", type); diff --git a/components/bt/esp_ble_mesh/mesh_core/cfg_cli.c b/components/bt/esp_ble_mesh/mesh_core/cfg_cli.c index 2c14767808..82482404b7 100644 --- a/components/bt/esp_ble_mesh/mesh_core/cfg_cli.c +++ b/components/bt/esp_ble_mesh/mesh_core/cfg_cli.c @@ -11,8 +11,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_MODEL) - #include "btc_ble_mesh_config_model.h" #include "mesh.h" @@ -104,7 +102,7 @@ static void timeout_handler(struct k_work *work) struct k_delayed_work *timer = NULL; bt_mesh_client_node_t *node = NULL; struct bt_mesh_msg_ctx ctx = {0}; - u32_t opcode = 0U; + uint32_t opcode = 0U; BT_WARN("Receive configuration status message timeout"); @@ -134,7 +132,7 @@ static void cfg_client_recv_status(struct bt_mesh_model *model, { bt_mesh_client_node_t *node = NULL; struct net_buf_simple buf = {0}; - u8_t evt_type = 0xFF; + uint8_t evt_type = 0xFF; if (!model || !ctx) { BT_ERR("%s, Invalid parameter", __func__); @@ -142,8 +140,8 @@ static void cfg_client_recv_status(struct bt_mesh_model *model, } /* If it is a publish message, sent to the user directly. */ - buf.data = (u8_t *)status; - buf.len = (u16_t)len; + buf.data = (uint8_t *)status; + buf.len = (uint16_t)len; bt_mesh_cfg_client_lock(); @@ -208,10 +206,10 @@ static void cfg_client_recv_status(struct bt_mesh_model *model, } if (!k_delayed_work_free(&node->timer)) { - u32_t opcode = node->opcode; + uint32_t opcode = node->opcode; bt_mesh_client_free_node(node); bt_mesh_config_client_cb_evt_to_btc( - opcode, evt_type, model, ctx, (const u8_t *)status, len); + opcode, evt_type, model, ctx, (const uint8_t *)status, len); } } @@ -276,7 +274,7 @@ static void state_status_u8(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - u8_t status = 0U; + uint8_t status = 0U; 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->len, @@ -284,7 +282,7 @@ static void state_status_u8(struct bt_mesh_model *model, status = net_buf_simple_pull_u8(buf); - cfg_client_recv_status(model, ctx, &status, sizeof(u8_t)); + cfg_client_recv_status(model, ctx, &status, sizeof(uint8_t)); } static void beacon_status(struct bt_mesh_model *model, @@ -678,7 +676,7 @@ const struct bt_mesh_model_op bt_mesh_cfg_cli_op[] = { BLE_MESH_MODEL_OP_END, }; -static int send_msg_with_none(bt_mesh_client_common_param_t *param, u32_t op) +static int send_msg_with_none(bt_mesh_client_common_param_t *param, uint32_t op) { BLE_MESH_MODEL_BUF_DEFINE(msg, op, 0); @@ -687,7 +685,7 @@ static int send_msg_with_none(bt_mesh_client_common_param_t *param, u32_t op) return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -static int send_msg_with_u8(bt_mesh_client_common_param_t *param, u32_t op, u8_t val) +static int send_msg_with_u8(bt_mesh_client_common_param_t *param, uint32_t op, uint8_t val) { BLE_MESH_MODEL_BUF_DEFINE(msg, op, 1); @@ -697,7 +695,7 @@ static int send_msg_with_u8(bt_mesh_client_common_param_t *param, u32_t op, u8_t return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -static int send_msg_with_le16(bt_mesh_client_common_param_t *param, u32_t op, u16_t val) +static int send_msg_with_le16(bt_mesh_client_common_param_t *param, uint32_t op, uint16_t val) { BLE_MESH_MODEL_BUF_DEFINE(msg, op, 2); @@ -707,7 +705,7 @@ static int send_msg_with_le16(bt_mesh_client_common_param_t *param, u32_t op, u1 return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -int bt_mesh_cfg_comp_data_get(bt_mesh_client_common_param_t *param, u8_t page) +int bt_mesh_cfg_comp_data_get(bt_mesh_client_common_param_t *param, uint8_t page) { return send_msg_with_u8(param, OP_DEV_COMP_DATA_GET, page); } @@ -717,7 +715,7 @@ int bt_mesh_cfg_beacon_get(bt_mesh_client_common_param_t *param) return send_msg_with_none(param, OP_BEACON_GET); } -int bt_mesh_cfg_beacon_set(bt_mesh_client_common_param_t *param, u8_t val) +int bt_mesh_cfg_beacon_set(bt_mesh_client_common_param_t *param, uint8_t val) { if (val > 0x01) { BT_ERR("Invalid beacon state 0x%02x", val); @@ -731,7 +729,7 @@ int bt_mesh_cfg_ttl_get(bt_mesh_client_common_param_t *param) return send_msg_with_none(param, OP_DEFAULT_TTL_GET); } -int bt_mesh_cfg_ttl_set(bt_mesh_client_common_param_t *param, u8_t val) +int bt_mesh_cfg_ttl_set(bt_mesh_client_common_param_t *param, uint8_t val) { return send_msg_with_u8(param, OP_DEFAULT_TTL_SET, val); } @@ -741,7 +739,7 @@ int bt_mesh_cfg_friend_get(bt_mesh_client_common_param_t *param) return send_msg_with_none(param, OP_FRIEND_GET); } -int bt_mesh_cfg_friend_set(bt_mesh_client_common_param_t *param, u8_t val) +int bt_mesh_cfg_friend_set(bt_mesh_client_common_param_t *param, uint8_t val) { return send_msg_with_u8(param, OP_FRIEND_SET, val); } @@ -751,7 +749,7 @@ int bt_mesh_cfg_gatt_proxy_get(bt_mesh_client_common_param_t *param) return send_msg_with_none(param, OP_GATT_PROXY_GET); } -int bt_mesh_cfg_gatt_proxy_set(bt_mesh_client_common_param_t *param, u8_t val) +int bt_mesh_cfg_gatt_proxy_set(bt_mesh_client_common_param_t *param, uint8_t val) { return send_msg_with_u8(param, OP_GATT_PROXY_SET, val); } @@ -762,7 +760,7 @@ int bt_mesh_cfg_relay_get(bt_mesh_client_common_param_t *param) } int bt_mesh_cfg_relay_set(bt_mesh_client_common_param_t *param, - u8_t relay, u8_t retransmit) + uint8_t relay, uint8_t retransmit) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_RELAY_SET, 2); @@ -774,7 +772,7 @@ int bt_mesh_cfg_relay_set(bt_mesh_client_common_param_t *param, } int bt_mesh_cfg_net_key_add(bt_mesh_client_common_param_t *param, - u16_t net_idx, const u8_t net_key[16]) + uint16_t net_idx, const uint8_t net_key[16]) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NET_KEY_ADD, 18); @@ -791,8 +789,8 @@ int bt_mesh_cfg_net_key_add(bt_mesh_client_common_param_t *param, } int bt_mesh_cfg_app_key_add(bt_mesh_client_common_param_t *param, - u16_t net_idx, u16_t app_idx, - const u8_t app_key[16]) + uint16_t net_idx, uint16_t app_idx, + const uint8_t app_key[16]) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_ADD, 19); @@ -809,8 +807,8 @@ int bt_mesh_cfg_app_key_add(bt_mesh_client_common_param_t *param, } int bt_mesh_cfg_mod_app_bind(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t app_idx, - u16_t mod_id, u16_t cid) + uint16_t elem_addr, uint16_t app_idx, + uint16_t mod_id, uint16_t cid) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_APP_BIND, 8); @@ -825,9 +823,9 @@ int bt_mesh_cfg_mod_app_bind(bt_mesh_client_common_param_t *param, return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -static int mod_sub(bt_mesh_client_common_param_t *param, u32_t op, - u16_t elem_addr, u16_t sub_addr, - u16_t mod_id, u16_t cid) +static int mod_sub(bt_mesh_client_common_param_t *param, uint32_t op, + uint16_t elem_addr, uint16_t sub_addr, + uint16_t mod_id, uint16_t cid) { BLE_MESH_MODEL_BUF_DEFINE(msg, op, 8); @@ -843,29 +841,29 @@ static int mod_sub(bt_mesh_client_common_param_t *param, u32_t op, } int bt_mesh_cfg_mod_sub_add(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t sub_addr, - u16_t mod_id, u16_t cid) + uint16_t elem_addr, uint16_t sub_addr, + uint16_t mod_id, uint16_t cid) { return mod_sub(param, OP_MOD_SUB_ADD, elem_addr, sub_addr, mod_id, cid); } int bt_mesh_cfg_mod_sub_del(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t sub_addr, - u16_t mod_id, u16_t cid) + uint16_t elem_addr, uint16_t sub_addr, + uint16_t mod_id, uint16_t cid) { return mod_sub(param, OP_MOD_SUB_DEL, elem_addr, sub_addr, mod_id, cid); } int bt_mesh_cfg_mod_sub_overwrite(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t sub_addr, - u16_t mod_id, u16_t cid) + uint16_t elem_addr, uint16_t sub_addr, + uint16_t mod_id, uint16_t cid) { return mod_sub(param, OP_MOD_SUB_OVERWRITE, elem_addr, sub_addr, mod_id, cid); } -static int mod_sub_va(bt_mesh_client_common_param_t *param, u32_t op, - u16_t elem_addr, const u8_t label[16], - u16_t mod_id, u16_t cid) +static int mod_sub_va(bt_mesh_client_common_param_t *param, uint32_t op, + uint16_t elem_addr, const uint8_t label[16], + uint16_t mod_id, uint16_t cid) { BLE_MESH_MODEL_BUF_DEFINE(msg, op, 22); @@ -889,28 +887,28 @@ static int mod_sub_va(bt_mesh_client_common_param_t *param, u32_t op, } int bt_mesh_cfg_mod_sub_va_add(bt_mesh_client_common_param_t *param, - u16_t elem_addr, const u8_t label[16], - u16_t mod_id, u16_t cid) + uint16_t elem_addr, const uint8_t label[16], + uint16_t mod_id, uint16_t cid) { return mod_sub_va(param, OP_MOD_SUB_VA_ADD, elem_addr, label, mod_id, cid); } int bt_mesh_cfg_mod_sub_va_del(bt_mesh_client_common_param_t *param, - u16_t elem_addr, const u8_t label[16], - u16_t mod_id, u16_t cid) + uint16_t elem_addr, const uint8_t label[16], + uint16_t mod_id, uint16_t cid) { return mod_sub_va(param, OP_MOD_SUB_VA_DEL, elem_addr, label, mod_id, cid); } int bt_mesh_cfg_mod_sub_va_overwrite(bt_mesh_client_common_param_t *param, - u16_t elem_addr, const u8_t label[16], - u16_t mod_id, u16_t cid) + uint16_t elem_addr, const uint8_t label[16], + uint16_t mod_id, uint16_t cid) { return mod_sub_va(param, OP_MOD_SUB_VA_OVERWRITE, elem_addr, label, mod_id, cid); } int bt_mesh_cfg_mod_pub_get(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t mod_id, u16_t cid) + uint16_t elem_addr, uint16_t mod_id, uint16_t cid) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_PUB_GET, 6); @@ -925,7 +923,7 @@ int bt_mesh_cfg_mod_pub_get(bt_mesh_client_common_param_t *param, } int bt_mesh_cfg_mod_pub_set(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t mod_id, u16_t cid, + uint16_t elem_addr, uint16_t mod_id, uint16_t cid, struct bt_mesh_cfg_mod_pub *pub) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_PUB_SET, 13); @@ -1005,8 +1003,8 @@ int bt_mesh_cfg_node_reset(bt_mesh_client_common_param_t *param) } int bt_mesh_cfg_mod_pub_va_set(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t mod_id, - u16_t cid, const u8_t label[16], + uint16_t elem_addr, uint16_t mod_id, + uint16_t cid, const uint8_t label[16], struct bt_mesh_cfg_mod_pub *pub) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_PUB_VA_SET, 27); @@ -1032,7 +1030,7 @@ int bt_mesh_cfg_mod_pub_va_set(bt_mesh_client_common_param_t *param, } int bt_mesh_cfg_mod_sub_del_all(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t mod_id, u16_t cid) + uint16_t elem_addr, uint16_t mod_id, uint16_t cid) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_SUB_DEL_ALL, 6); @@ -1046,8 +1044,8 @@ int bt_mesh_cfg_mod_sub_del_all(bt_mesh_client_common_param_t *param, return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -static int mod_sub_get(bt_mesh_client_common_param_t *param, u32_t op, - u16_t elem_addr, u16_t mod_id, u16_t cid) +static int mod_sub_get(bt_mesh_client_common_param_t *param, uint32_t op, + uint16_t elem_addr, uint16_t mod_id, uint16_t cid) { BLE_MESH_MODEL_BUF_DEFINE(msg, op, 6); @@ -1062,13 +1060,13 @@ static int mod_sub_get(bt_mesh_client_common_param_t *param, u32_t op, } int bt_mesh_cfg_mod_sub_get(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t mod_id) + uint16_t elem_addr, uint16_t mod_id) { return mod_sub_get(param, OP_MOD_SUB_GET, elem_addr, mod_id, BLE_MESH_CID_NVAL); } int bt_mesh_cfg_mod_sub_get_vnd(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t mod_id, u16_t cid) + uint16_t elem_addr, uint16_t mod_id, uint16_t cid) { if (cid == BLE_MESH_CID_NVAL) { BT_ERR("Invalid company id"); @@ -1078,7 +1076,7 @@ int bt_mesh_cfg_mod_sub_get_vnd(bt_mesh_client_common_param_t *param, } int bt_mesh_cfg_net_key_update(bt_mesh_client_common_param_t *param, - u16_t net_idx, const u8_t net_key[16]) + uint16_t net_idx, const uint8_t net_key[16]) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NET_KEY_UPDATE, 18); @@ -1094,7 +1092,7 @@ int bt_mesh_cfg_net_key_update(bt_mesh_client_common_param_t *param, return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -int bt_mesh_cfg_net_key_delete(bt_mesh_client_common_param_t *param, u16_t net_idx) +int bt_mesh_cfg_net_key_delete(bt_mesh_client_common_param_t *param, uint16_t net_idx) { return send_msg_with_le16(param, OP_NET_KEY_DEL, net_idx); } @@ -1105,8 +1103,8 @@ int bt_mesh_cfg_net_key_get(bt_mesh_client_common_param_t *param) } int bt_mesh_cfg_app_key_update(bt_mesh_client_common_param_t *param, - u16_t net_idx, u16_t app_idx, - const u8_t app_key[16]) + uint16_t net_idx, uint16_t app_idx, + const uint8_t app_key[16]) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_UPDATE, 19); @@ -1123,7 +1121,7 @@ int bt_mesh_cfg_app_key_update(bt_mesh_client_common_param_t *param, } int bt_mesh_cfg_app_key_delete(bt_mesh_client_common_param_t *param, - u16_t net_idx, u16_t app_idx) + uint16_t net_idx, uint16_t app_idx) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_DEL, 3); @@ -1133,18 +1131,18 @@ int bt_mesh_cfg_app_key_delete(bt_mesh_client_common_param_t *param, return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -int bt_mesh_cfg_app_key_get(bt_mesh_client_common_param_t *param, u16_t net_idx) +int bt_mesh_cfg_app_key_get(bt_mesh_client_common_param_t *param, uint16_t net_idx) { return send_msg_with_le16(param, OP_APP_KEY_GET, net_idx); } -int bt_mesh_cfg_node_identity_get(bt_mesh_client_common_param_t *param, u16_t net_idx) +int bt_mesh_cfg_node_identity_get(bt_mesh_client_common_param_t *param, uint16_t net_idx) { return send_msg_with_le16(param, OP_NODE_IDENTITY_GET, net_idx); } int bt_mesh_cfg_node_identity_set(bt_mesh_client_common_param_t *param, - u16_t net_idx, u8_t identity) + uint16_t net_idx, uint8_t identity) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NODE_IDENTITY_SET, 3); @@ -1161,8 +1159,8 @@ int bt_mesh_cfg_node_identity_set(bt_mesh_client_common_param_t *param, } int bt_mesh_cfg_mod_app_unbind(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t app_idx, - u16_t mod_id, u16_t cid) + uint16_t elem_addr, uint16_t app_idx, + uint16_t mod_id, uint16_t cid) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_APP_UNBIND, 8); @@ -1177,8 +1175,8 @@ int bt_mesh_cfg_mod_app_unbind(bt_mesh_client_common_param_t *param, return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -static int mod_app_get(bt_mesh_client_common_param_t *param, u32_t op, - u16_t elem_addr, u16_t mod_id, u16_t cid) +static int mod_app_get(bt_mesh_client_common_param_t *param, uint32_t op, + uint16_t elem_addr, uint16_t mod_id, uint16_t cid) { BLE_MESH_MODEL_BUF_DEFINE(msg, op, 6); @@ -1193,13 +1191,13 @@ static int mod_app_get(bt_mesh_client_common_param_t *param, u32_t op, } int bt_mesh_cfg_mod_app_get(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t mod_id) + uint16_t elem_addr, uint16_t mod_id) { return mod_app_get(param, OP_SIG_MOD_APP_GET, elem_addr, mod_id, BLE_MESH_CID_NVAL); } int bt_mesh_cfg_mod_app_get_vnd(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t mod_id, u16_t cid) + uint16_t elem_addr, uint16_t mod_id, uint16_t cid) { if (cid == BLE_MESH_CID_NVAL) { BT_ERR("Invalid company id"); @@ -1208,13 +1206,13 @@ int bt_mesh_cfg_mod_app_get_vnd(bt_mesh_client_common_param_t *param, return mod_app_get(param, OP_VND_MOD_APP_GET, elem_addr, mod_id, cid); } -int bt_mesh_cfg_kr_phase_get(bt_mesh_client_common_param_t *param, u16_t net_idx) +int bt_mesh_cfg_kr_phase_get(bt_mesh_client_common_param_t *param, uint16_t net_idx) { return send_msg_with_le16(param, OP_KRP_GET, net_idx); } int bt_mesh_cfg_kr_phase_set(bt_mesh_client_common_param_t *param, - u16_t net_idx, u8_t transition) + uint16_t net_idx, uint8_t transition) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_KRP_SET, 3); @@ -1230,7 +1228,7 @@ int bt_mesh_cfg_kr_phase_set(bt_mesh_client_common_param_t *param, return bt_mesh_client_send_msg(param, &msg, true, timeout_handler); } -int bt_mesh_cfg_lpn_timeout_get(bt_mesh_client_common_param_t *param, u16_t lpn_addr) +int bt_mesh_cfg_lpn_timeout_get(bt_mesh_client_common_param_t *param, uint16_t lpn_addr) { return send_msg_with_le16(param, OP_LPN_TIMEOUT_GET, lpn_addr); } @@ -1240,7 +1238,7 @@ int bt_mesh_cfg_net_transmit_get(bt_mesh_client_common_param_t *param) return send_msg_with_none(param, OP_NET_TRANSMIT_GET); } -int bt_mesh_cfg_net_transmit_set(bt_mesh_client_common_param_t *param, u8_t transmit) +int bt_mesh_cfg_net_transmit_set(bt_mesh_client_common_param_t *param, uint8_t transmit) { return send_msg_with_u8(param, OP_NET_TRANSMIT_SET, transmit); } diff --git a/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c b/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c index cb07f8c10e..e32510d0a0 100644 --- a/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c +++ b/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c @@ -11,8 +11,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_MODEL) - #include "btc_ble_mesh_config_model.h" #include "mesh.h" @@ -75,8 +73,8 @@ static int comp_add_elem(struct net_buf_simple *buf, struct bt_mesh_elem *elem, static int comp_get_page_0(struct net_buf_simple *buf) { - u16_t feat = 0U; const struct bt_mesh_comp *comp = NULL; + uint16_t feat = 0U; int i; comp = bt_mesh_comp_get(); @@ -120,7 +118,7 @@ static void dev_comp_data_get(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct net_buf_simple *sdu = NULL; - u8_t page = 0U; + uint8_t page = 0U; 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->len, @@ -159,7 +157,7 @@ static struct bt_mesh_model *get_model(struct bt_mesh_elem *elem, struct net_buf_simple *buf, bool *vnd) { if (buf->len < 4) { - u16_t id = 0U; + uint16_t id = 0U; id = net_buf_simple_pull_le16(buf); @@ -169,7 +167,7 @@ static struct bt_mesh_model *get_model(struct bt_mesh_elem *elem, return bt_mesh_model_find(elem, id); } else { - u16_t company = 0U, id = 0U; + uint16_t company = 0U, id = 0U; company = net_buf_simple_pull_le16(buf); id = net_buf_simple_pull_le16(buf); @@ -183,7 +181,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; @@ -199,9 +197,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; @@ -251,7 +249,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", period_ms); @@ -270,7 +268,7 @@ static u8_t _mod_pub_set(struct bt_mesh_model *model, u16_t pub_addr, return STATUS_SUCCESS; } -static u8_t mod_bind(struct bt_mesh_model *model, u16_t key_idx) +static uint8_t mod_bind(struct bt_mesh_model *model, uint16_t key_idx) { int i; @@ -302,7 +300,7 @@ static u8_t mod_bind(struct bt_mesh_model *model, u16_t key_idx) return STATUS_INSUFF_RESOURCES; } -static u8_t mod_unbind(struct bt_mesh_model *model, u16_t key_idx, bool store) +static uint8_t mod_unbind(struct bt_mesh_model *model, uint16_t key_idx, bool store) { int i; @@ -332,7 +330,7 @@ static 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; @@ -347,8 +345,8 @@ 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], - bool update) +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 = NULL; struct bt_mesh_app_key *key = NULL; @@ -441,8 +439,8 @@ static void app_key_add(struct bt_mesh_model *model, struct net_buf_simple *buf) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_STATUS, 4); - u16_t key_net_idx = 0U, key_app_idx = 0U; - u8_t status = 0U; + uint16_t key_net_idx = 0U, key_app_idx = 0U; + uint8_t status = 0U; key_idx_unpack(buf, &key_net_idx, &key_app_idx); @@ -467,7 +465,7 @@ static void app_key_add(struct bt_mesh_model *model, change.cfg_appkey_add.app_idx = key_app_idx; memcpy(change.cfg_appkey_add.app_key, buf->data, 16); bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const uint8_t *)&change, sizeof(change)); } } @@ -476,8 +474,8 @@ static void app_key_update(struct bt_mesh_model *model, struct net_buf_simple *buf) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_STATUS, 4); - u16_t key_net_idx = 0U, key_app_idx = 0U; - u8_t status = 0U; + uint16_t key_net_idx = 0U, key_app_idx = 0U; + uint8_t status = 0U; key_idx_unpack(buf, &key_net_idx, &key_app_idx); @@ -501,12 +499,12 @@ static void app_key_update(struct bt_mesh_model *model, change.cfg_appkey_update.app_idx = key_app_idx; memcpy(change.cfg_appkey_update.app_key, buf->data, 16); bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const uint8_t *)&change, sizeof(change)); } } struct unbind_data { - u16_t app_idx; + uint16_t app_idx; bool store; }; @@ -539,9 +537,9 @@ static void app_key_del(struct bt_mesh_model *model, struct net_buf_simple *buf) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_STATUS, 4); - u16_t key_net_idx = 0U, key_app_idx = 0U; + uint16_t key_net_idx = 0U, key_app_idx = 0U; struct bt_mesh_app_key *key = NULL; - u8_t status = 0U; + uint8_t status = 0U; key_idx_unpack(buf, &key_net_idx, &key_app_idx); @@ -585,7 +583,7 @@ send_status: change.cfg_appkey_delete.net_idx = key_net_idx; change.cfg_appkey_delete.app_idx = key_app_idx; bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const uint8_t *)&change, sizeof(change)); } } @@ -598,8 +596,8 @@ static void app_key_get(struct bt_mesh_model *model, { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_LIST, 3 + IDX_LEN(CONFIG_BLE_MESH_APP_KEY_COUNT)); - u16_t get_idx = 0U, i = 0U, prev = 0U; - u8_t status = 0U; + uint16_t get_idx = 0U, i = 0U, prev = 0U; + uint8_t status = 0U; get_idx = net_buf_simple_pull_le16(buf); if (get_idx > 0xfff) { @@ -953,9 +951,9 @@ static void relay_set(struct bt_mesh_model *model, 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) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_PUB_STATUS, 14); @@ -967,11 +965,11 @@ static void send_mod_pub_status(struct bt_mesh_model *cfg_mod, if (status != STATUS_SUCCESS) { (void)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); @@ -993,10 +991,10 @@ static void mod_pub_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - u16_t elem_addr = 0U, pub_addr = 0U; + uint16_t elem_addr = 0U, pub_addr = 0U; struct bt_mesh_model *mod = NULL; struct bt_mesh_elem *elem = NULL; - u8_t *mod_id = NULL, status = 0U; + uint8_t *mod_id = NULL, status = 0U; bool vnd = false; elem_addr = net_buf_simple_pull_le16(buf); @@ -1040,11 +1038,11 @@ static void mod_pub_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - u8_t retransmit = 0U, status = 0U, pub_ttl = 0U, pub_period = 0U, cred_flag = 0U; - u16_t elem_addr = 0U, pub_addr = 0U, pub_app_idx = 0U; + uint8_t retransmit = 0U, status = 0U, pub_ttl = 0U, pub_period = 0U, cred_flag = 0U; + uint16_t elem_addr = 0U, pub_addr = 0U, pub_app_idx = 0U; struct bt_mesh_model *mod = NULL; struct bt_mesh_elem *elem = NULL; - u8_t *mod_id = NULL; + uint8_t *mod_id = NULL; bool vnd = false; elem_addr = net_buf_simple_pull_le16(buf); @@ -1109,11 +1107,11 @@ send_status: change.cfg_mod_pub_set.cid = vnd ? mod->vnd.company : 0xFFFF; change.cfg_mod_pub_set.mod_id = vnd ? mod->vnd.id : mod->id; bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const uint8_t *)&change, sizeof(change)); } } -struct label *get_label(u16_t index) +struct label *get_label(uint16_t index) { if (index >= ARRAY_SIZE(labels)) { return NULL; @@ -1131,7 +1129,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; @@ -1157,7 +1155,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 = NULL, *free_slot = NULL; @@ -1184,7 +1182,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 = NULL; @@ -1209,7 +1207,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 = NULL; + uint8_t *label_uuid = NULL; size_t clear_count = 0U; int i; @@ -1243,12 +1241,12 @@ static void mod_pub_va_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - u8_t retransmit = 0U, status = 0U, pub_ttl = 0U, pub_period = 0U, cred_flag = 0U; - u16_t elem_addr = 0U, pub_addr = 0U, pub_app_idx = 0U; + uint8_t retransmit = 0U, status = 0U, pub_ttl = 0U, pub_period = 0U, cred_flag = 0U; + uint16_t elem_addr = 0U, pub_addr = 0U, pub_app_idx = 0U; struct bt_mesh_model *mod = NULL; struct bt_mesh_elem *elem = NULL; - u8_t *label_uuid = NULL; - u8_t *mod_id = NULL; + uint8_t *label_uuid = NULL; + uint8_t *mod_id = NULL; bool vnd = false; elem_addr = net_buf_simple_pull_le16(buf); @@ -1325,10 +1323,10 @@ static void mod_pub_va_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - u8_t *mod_id = NULL, status = 0U; + uint8_t *mod_id = NULL, status = 0U; struct bt_mesh_model *mod = NULL; struct bt_mesh_elem *elem = NULL; - u16_t elem_addr = 0U, pub_addr = 0U; + uint16_t elem_addr = 0U, pub_addr = 0U; bool vnd = false; elem_addr = net_buf_simple_pull_le16(buf); @@ -1371,8 +1369,8 @@ send_status: #endif /* CONFIG_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) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_SUB_STATUS, 9); @@ -1401,11 +1399,11 @@ static void mod_sub_add(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - u16_t elem_addr = 0U, sub_addr = 0U; + uint16_t elem_addr = 0U, sub_addr = 0U; struct bt_mesh_model *mod = NULL; struct bt_mesh_elem *elem = NULL; - u8_t *mod_id = NULL; - u8_t status = 0U; + uint8_t *mod_id = NULL; + uint8_t status = 0U; bool vnd = false; int i; @@ -1479,7 +1477,7 @@ send_status: change.cfg_mod_sub_add.cid = vnd ? mod->vnd.company : 0xFFFF; change.cfg_mod_sub_add.mod_id = vnd ? mod->vnd.id : mod->id; bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const uint8_t *)&change, sizeof(change)); } } @@ -1487,12 +1485,12 @@ static void mod_sub_del(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - u16_t elem_addr = 0U, sub_addr = 0U; + uint16_t elem_addr = 0U, sub_addr = 0U; struct bt_mesh_model *mod = NULL; struct bt_mesh_elem *elem = NULL; - u8_t *mod_id = NULL; - u16_t *match = NULL; - u8_t status = 0U; + uint8_t *mod_id = NULL; + uint16_t *match = NULL; + uint8_t status = 0U; bool vnd = false; elem_addr = net_buf_simple_pull_le16(buf); @@ -1555,7 +1553,7 @@ send_status: change.cfg_mod_sub_delete.cid = vnd ? mod->vnd.company : 0xFFFF; change.cfg_mod_sub_delete.mod_id = vnd ? mod->vnd.id : mod->id; bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const uint8_t *)&change, sizeof(change)); } } @@ -1563,11 +1561,11 @@ static void mod_sub_overwrite(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - u16_t elem_addr = 0U, sub_addr = 0U; + uint16_t elem_addr = 0U, sub_addr = 0U; struct bt_mesh_model *mod = NULL; struct bt_mesh_elem *elem = NULL; - u8_t *mod_id = NULL; - u8_t status = 0U; + uint8_t *mod_id = NULL; + uint8_t status = 0U; bool vnd = false; elem_addr = net_buf_simple_pull_le16(buf); @@ -1634,9 +1632,9 @@ static void mod_sub_del_all(struct bt_mesh_model *model, { struct bt_mesh_model *mod = NULL; struct bt_mesh_elem *elem = NULL; - u16_t elem_addr = 0U; - u8_t *mod_id = NULL; - u8_t status = 0U; + uint16_t elem_addr = 0U; + uint8_t *mod_id = NULL; + uint8_t status = 0U; bool vnd = false; elem_addr = net_buf_simple_pull_le16(buf); @@ -1688,7 +1686,7 @@ static void mod_sub_get(struct bt_mesh_model *model, 5 + CONFIG_BLE_MESH_MODEL_GROUP_COUNT * 2); struct bt_mesh_model *mod = NULL; struct bt_mesh_elem *elem = NULL; - u16_t addr = 0U, id = 0U; + uint16_t addr = 0U, id = 0U; int i; addr = net_buf_simple_pull_le16(buf); @@ -1744,7 +1742,7 @@ static void mod_sub_get_vnd(struct bt_mesh_model *model, 7 + CONFIG_BLE_MESH_MODEL_GROUP_COUNT * 2); struct bt_mesh_model *mod = NULL; struct bt_mesh_elem *elem = NULL; - u16_t company = 0U, addr = 0U, id = 0U; + uint16_t company = 0U, addr = 0U, id = 0U; int i; addr = net_buf_simple_pull_le16(buf); @@ -1801,12 +1799,12 @@ static void mod_sub_va_add(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - u16_t elem_addr = 0U, sub_addr = 0U; + uint16_t elem_addr = 0U, sub_addr = 0U; struct bt_mesh_model *mod = NULL; struct bt_mesh_elem *elem = NULL; - u8_t *label_uuid = NULL; - u8_t *mod_id = NULL; - u8_t status = 0U; + uint8_t *label_uuid = NULL; + uint8_t *mod_id = NULL; + uint8_t status = 0U; bool vnd = false; int i; @@ -1878,13 +1876,13 @@ static void mod_sub_va_del(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - u16_t elem_addr = 0U, sub_addr = 0U; + uint16_t elem_addr = 0U, sub_addr = 0U; struct bt_mesh_model *mod = NULL; struct bt_mesh_elem *elem = NULL; - u8_t *label_uuid = NULL; - u8_t *mod_id = NULL; - u16_t *match = NULL; - u8_t status = 0U; + uint8_t *label_uuid = NULL; + uint8_t *mod_id = NULL; + uint16_t *match = NULL; + uint8_t status = 0U; bool vnd = false; elem_addr = net_buf_simple_pull_le16(buf); @@ -1946,12 +1944,12 @@ static void mod_sub_va_overwrite(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - u16_t elem_addr = 0U, sub_addr = BLE_MESH_ADDR_UNASSIGNED; + uint16_t elem_addr = 0U, sub_addr = BLE_MESH_ADDR_UNASSIGNED; struct bt_mesh_model *mod = NULL; struct bt_mesh_elem *elem = NULL; - u8_t *label_uuid = NULL; - u8_t *mod_id = NULL; - u8_t status = 0U; + uint8_t *label_uuid = NULL; + uint8_t *mod_id = NULL; + uint8_t status = 0U; bool vnd = false; elem_addr = net_buf_simple_pull_le16(buf); @@ -2014,9 +2012,9 @@ static void mod_sub_va_add(struct bt_mesh_model *model, { struct bt_mesh_model *mod = NULL; struct bt_mesh_elem *elem = NULL; - u16_t elem_addr = 0U; - u8_t *mod_id = NULL; - u8_t status = 0U; + uint16_t elem_addr = 0U; + uint8_t *mod_id = NULL; + uint8_t status = 0U; bool vnd = false; elem_addr = net_buf_simple_pull_le16(buf); @@ -2055,9 +2053,9 @@ static void mod_sub_va_del(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_elem *elem = NULL; - u16_t elem_addr = 0U; - u8_t *mod_id = NULL; - u8_t status = 0U; + uint16_t elem_addr = 0U; + uint8_t *mod_id = NULL; + uint8_t status = 0U; bool vnd = false; elem_addr = net_buf_simple_pull_le16(buf); @@ -2094,9 +2092,9 @@ static void mod_sub_va_overwrite(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_elem *elem = NULL; - u16_t elem_addr = 0U; - u8_t *mod_id = NULL; - u8_t status = 0U; + uint16_t elem_addr = 0U; + uint8_t *mod_id = NULL; + uint8_t status = 0U; bool vnd = false; elem_addr = net_buf_simple_pull_le16(buf); @@ -2131,7 +2129,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) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NET_KEY_STATUS, 3); @@ -2150,7 +2148,7 @@ static void net_key_add(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_subnet *sub = NULL; - u16_t idx = 0U; + uint16_t idx = 0U; int err = 0; idx = net_buf_simple_pull_le16(buf); @@ -2181,7 +2179,7 @@ static void net_key_add(struct bt_mesh_model *model, /* Check for already existing subnet */ if (sub->net_idx == idx) { - u8_t status = 0U; + uint8_t status = 0U; if (memcmp(buf->data, sub->keys[0].net, 16)) { status = STATUS_IDX_ALREADY_STORED; @@ -2223,7 +2221,7 @@ static void net_key_add(struct bt_mesh_model *model, change.cfg_netkey_add.net_idx = sub->net_idx; memcpy(change.cfg_netkey_add.net_key, sub->keys[0].net, 16); bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const uint8_t *)&change, sizeof(change)); } static void net_key_update(struct bt_mesh_model *model, @@ -2231,7 +2229,7 @@ static void net_key_update(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_subnet *sub = NULL; - u16_t idx = 0U; + uint16_t idx = 0U; int err = 0; idx = net_buf_simple_pull_le16(buf); @@ -2298,7 +2296,7 @@ static void net_key_update(struct bt_mesh_model *model, change.cfg_netkey_update.net_idx = sub->net_idx; memcpy(change.cfg_netkey_update.net_key, sub->keys[1].net, 16); bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const uint8_t *)&change, sizeof(change)); } static void hb_pub_disable(struct bt_mesh_cfg_srv *cfg) @@ -2318,8 +2316,8 @@ static void net_key_del(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_subnet *sub = NULL; - u16_t del_idx = 0U; - u8_t status = 0U; + uint16_t del_idx = 0U; + uint8_t status = 0U; del_idx = net_buf_simple_pull_le16(buf); if (del_idx > 0xfff) { @@ -2356,7 +2354,7 @@ send_status: bt_mesh_cfg_server_state_change_t change = {0}; change.cfg_netkey_delete.net_idx = sub->net_idx; bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const uint8_t *)&change, sizeof(change)); } } @@ -2366,7 +2364,7 @@ static void net_key_get(struct bt_mesh_model *model, { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NET_KEY_LIST, IDX_LEN(CONFIG_BLE_MESH_SUBNET_COUNT)); - u16_t prev = 0U, i = 0U; + uint16_t prev = 0U, i = 0U; bt_mesh_model_msg_init(&msg, OP_NET_KEY_LIST); @@ -2402,8 +2400,8 @@ static void node_identity_get(struct bt_mesh_model *model, { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NODE_IDENTITY_STATUS, 4); struct bt_mesh_subnet *sub = NULL; - u8_t node_id = 0U; - u16_t idx = 0U; + uint8_t node_id = 0U; + uint16_t idx = 0U; 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->len, @@ -2440,8 +2438,8 @@ static void node_identity_set(struct bt_mesh_model *model, { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NODE_IDENTITY_STATUS, 4); struct bt_mesh_subnet *sub = NULL; - u8_t node_id = 0U; - u16_t idx = 0U; + uint8_t node_id = 0U; + uint16_t idx = 0U; 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->len, @@ -2488,8 +2486,8 @@ static void node_identity_set(struct bt_mesh_model *model, static void create_mod_app_status(struct net_buf_simple *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); @@ -2509,10 +2507,10 @@ static void mod_app_bind(struct bt_mesh_model *model, struct net_buf_simple *buf) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_APP_STATUS, 9); - u16_t elem_addr = 0U, key_app_idx = 0U; + uint16_t elem_addr = 0U, key_app_idx = 0U; struct bt_mesh_model *mod = NULL; struct bt_mesh_elem *elem = NULL; - u8_t *mod_id = NULL, status = 0U; + uint8_t *mod_id = NULL, status = 0U; bool vnd = false; elem_addr = net_buf_simple_pull_le16(buf); @@ -2563,7 +2561,7 @@ send_status: change.cfg_mod_app_bind.cid = vnd ? mod->vnd.company : 0xFFFF; change.cfg_mod_app_bind.mod_id = vnd ? mod->vnd.id : mod->id; bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const uint8_t *)&change, sizeof(change)); } } @@ -2572,10 +2570,10 @@ static void mod_app_unbind(struct bt_mesh_model *model, struct net_buf_simple *buf) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_APP_STATUS, 9); - u16_t elem_addr = 0U, key_app_idx = 0U; + uint16_t elem_addr = 0U, key_app_idx = 0U; struct bt_mesh_model *mod = NULL; struct bt_mesh_elem *elem = NULL; - u8_t *mod_id = NULL, status = 0U; + uint8_t *mod_id = NULL, status = 0U; bool vnd = false; elem_addr = net_buf_simple_pull_le16(buf); @@ -2619,7 +2617,7 @@ send_status: change.cfg_mod_app_unbind.cid = vnd ? mod->vnd.company : 0xFFFF; change.cfg_mod_app_unbind.mod_id = vnd ? mod->vnd.id : mod->id; bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const uint8_t *)&change, sizeof(change)); } } @@ -2636,8 +2634,8 @@ static void mod_app_get(struct bt_mesh_model *model, 9 + KEY_LIST_LEN))); struct bt_mesh_model *mod = NULL; struct bt_mesh_elem *elem = NULL; - u8_t *mod_id = NULL, status = 0U; - u16_t elem_addr = 0U; + uint8_t *mod_id = NULL, status = 0U; + uint16_t elem_addr = 0U; bool vnd = false; elem_addr = net_buf_simple_pull_le16(buf); @@ -2799,8 +2797,8 @@ static void lpn_timeout_get(struct bt_mesh_model *model, { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_LPN_TIMEOUT_STATUS, 5); struct bt_mesh_friend *frnd = NULL; - u16_t lpn_addr = 0U; - s32_t timeout = 0; + uint16_t lpn_addr = 0U; + int32_t timeout = 0; lpn_addr = net_buf_simple_pull_le16(buf); @@ -2838,7 +2836,7 @@ send_rsp: 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) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_KRP_STATUS, 4); @@ -2857,7 +2855,7 @@ static void krp_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { struct bt_mesh_subnet *sub = NULL; - u16_t idx = 0U; + uint16_t idx = 0U; idx = net_buf_simple_pull_le16(buf); if (idx > 0xfff) { @@ -2880,8 +2878,8 @@ static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { struct bt_mesh_subnet *sub = NULL; - u8_t phase = 0U; - u16_t idx = 0U; + uint8_t phase = 0U; + uint16_t idx = 0U; idx = net_buf_simple_pull_le16(buf); phase = net_buf_simple_pull_u8(buf); @@ -2940,10 +2938,10 @@ static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, change.cfg_kr_phase_set.net_idx = idx; change.cfg_kr_phase_set.kr_phase = phase; bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const uint8_t *)&change, sizeof(change)); } -static u8_t hb_log(u16_t val) +static uint8_t hb_log(uint16_t val) { if (!val) { return 0x00; @@ -2954,7 +2952,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; @@ -2967,7 +2965,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; @@ -2979,16 +2977,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) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEARTBEAT_PUB_STATUS, 10); @@ -3034,8 +3032,8 @@ static void heartbeat_pub_set(struct bt_mesh_model *model, { struct hb_pub_param *param = (void *)buf->data; struct bt_mesh_cfg_srv *cfg = model->user_data; - u16_t dst = 0U, feat = 0U, idx = 0U; - u8_t status = 0U; + uint16_t dst = 0U, feat = 0U, idx = 0U; + uint8_t status = 0U; BT_DBG("src 0x%04x", ctx->addr); @@ -3127,12 +3125,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) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEARTBEAT_SUB_STATUS, 9); struct bt_mesh_cfg_srv *cfg = model->user_data; - u16_t period = 0U; - s64_t uptime = 0; + uint16_t period = 0U; + int64_t uptime = 0; BT_DBG("src 0x%04x status 0x%02x", ctx->addr, status); @@ -3172,9 +3170,9 @@ static void heartbeat_sub_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_cfg_srv *cfg = model->user_data; - u16_t sub_src = 0U, sub_dst = 0U; - u8_t sub_period = 0U; - s32_t period_ms = 0; + uint16_t sub_src = 0U, sub_dst = 0U; + uint8_t sub_period = 0U; + int32_t period_ms = 0; BT_DBG("src 0x%04x", ctx->addr); @@ -3307,7 +3305,7 @@ static void hb_publish(struct k_work *work) struct bt_mesh_cfg_srv, hb_pub.timer.work); struct bt_mesh_subnet *sub = NULL; - u16_t period_ms = 0U; + uint16_t period_ms = 0U; BT_DBG("hb_pub.count: %u", cfg->hb_pub.count); @@ -3490,7 +3488,7 @@ void bt_mesh_cfg_reset(bool store) (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; @@ -3525,7 +3523,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; @@ -3534,7 +3532,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; @@ -3543,7 +3541,7 @@ u8_t bt_mesh_relay_get(void) return BLE_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); @@ -3553,7 +3551,7 @@ u8_t bt_mesh_friend_get(void) return BLE_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; @@ -3562,7 +3560,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; @@ -3571,7 +3569,7 @@ u8_t bt_mesh_beacon_get(void) return BLE_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; @@ -3580,7 +3578,7 @@ u8_t bt_mesh_gatt_proxy_get(void) return BLE_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; @@ -3589,7 +3587,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/components/bt/esp_ble_mesh/mesh_core/crypto.c b/components/bt/esp_ble_mesh/mesh_core/crypto.c index c266b279b2..085fa381d1 100644 --- a/components/bt/esp_ble_mesh/mesh_core/crypto.c +++ b/components/bt/esp_ble_mesh/mesh_core/crypto.c @@ -11,8 +11,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_CRYPTO) - #include #include #include @@ -24,8 +22,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 = {0}; struct tc_cmac_struct state = {0}; @@ -48,8 +46,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 = 0; @@ -61,14 +59,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] = {0}; - u8_t salt[16] = {0}; - u8_t out[16] = {0}; - u8_t t[16] = {0}; - u8_t pad = 0U; + uint8_t salt[16] = {0}; + uint8_t out[16] = {0}; + uint8_t t[16] = {0}; + uint8_t pad = 0U; int err = 0; BT_DBG("n %s", bt_hex(n, 16)); @@ -126,11 +124,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] = {0}; - u8_t t[16] = {0}; + uint8_t id64[] = { 'i', 'd', '6', '4', 0x01 }; + uint8_t tmp[16] = {0}; + uint8_t t[16] = {0}; int err = 0; err = bt_mesh_s1("smk3", tmp); @@ -153,11 +151,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] = {0}; - u8_t t[16] = {0}; + uint8_t id6[] = { 'i', 'd', '6', 0x01 }; + uint8_t tmp[16] = {0}; + uint8_t t[16] = {0}; int err = 0; err = bt_mesh_s1("smk4", tmp); @@ -180,10 +178,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] = {0}; + uint8_t salt[16] = {0}; int err = 0; err = bt_mesh_s1(s, salt); @@ -194,14 +192,14 @@ 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 int bt_mesh_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) +static int bt_mesh_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 msg[16] = {0}, pmsg[16] = {0}, cmic[16] = {0}, - cmsg[16] = {0}, Xn[16] = {0}, mic[16] = {0}; - u16_t last_blk = 0U, blk_cnt = 0U; + uint8_t msg[16] = {0}, pmsg[16] = {0}, cmic[16] = {0}, + cmsg[16] = {0}, Xn[16] = {0}, mic[16] = {0}; + uint16_t last_blk = 0U, blk_cnt = 0U; size_t i = 0U, j = 0U; int err = 0; @@ -220,7 +218,7 @@ static int bt_mesh_ccm_decrypt(const u8_t key[16], u8_t nonce[13], } /* X_0 = e(AppKey, 0x09 || nonce || length) */ - if (mic_size == sizeof(u64_t)) { + if (mic_size == sizeof(uint64_t)) { pmsg[0] = 0x19 | (aad_len ? 0x40 : 0x00); } else { pmsg[0] = 0x09 | (aad_len ? 0x40 : 0x00); @@ -238,12 +236,12 @@ static int bt_mesh_ccm_decrypt(const u8_t key[16], u8_t nonce[13], if (aad_len) { sys_put_be16(aad_len, pmsg); - for (i = 0; i < sizeof(u16_t); i++) { + for (i = 0; i < sizeof(uint16_t); i++) { pmsg[i] = Xn[i] ^ pmsg[i]; } j = 0; - aad_len += sizeof(u16_t); + aad_len += sizeof(uint16_t); while (aad_len > 16) { do { pmsg[i] = Xn[i] ^ aad[j]; @@ -353,14 +351,14 @@ static int bt_mesh_ccm_decrypt(const u8_t key[16], u8_t nonce[13], return 0; } -static int bt_mesh_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) +static int bt_mesh_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 pmsg[16] = {0}, cmic[16] = {0}, cmsg[16] = {0}, - mic[16] = {0}, Xn[16] = {0}; - u16_t blk_cnt = 0U, last_blk = 0U; + uint8_t pmsg[16] = {0}, cmic[16] = {0}, cmsg[16] = {0}, + mic[16] = {0}, Xn[16] = {0}; + uint16_t blk_cnt = 0U, last_blk = 0U; size_t i = 0U, j = 0U; int err = 0; @@ -385,7 +383,7 @@ static int bt_mesh_ccm_encrypt(const u8_t key[16], u8_t nonce[13], } /* X_0 = e(AppKey, 0x09 || nonce || length) */ - if (mic_size == sizeof(u64_t)) { + if (mic_size == sizeof(uint64_t)) { pmsg[0] = 0x19 | (aad_len ? 0x40 : 0x00); } else { pmsg[0] = 0x09 | (aad_len ? 0x40 : 0x00); @@ -403,12 +401,12 @@ static int bt_mesh_ccm_encrypt(const u8_t key[16], u8_t nonce[13], if (aad_len) { sys_put_be16(aad_len, pmsg); - for (i = 0; i < sizeof(u16_t); i++) { + for (i = 0; i < sizeof(uint16_t); i++) { pmsg[i] = Xn[i] ^ pmsg[i]; } j = 0; - aad_len += sizeof(u16_t); + aad_len += sizeof(uint16_t); while (aad_len > 16) { do { pmsg[i] = Xn[i] ^ aad[j]; @@ -515,8 +513,8 @@ static int bt_mesh_ccm_encrypt(const u8_t key[16], u8_t nonce[13], } #if defined(CONFIG_BLE_MESH_PROXY) -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; @@ -542,8 +540,8 @@ static void create_proxy_nonce(u8_t nonce[13], const u8_t *pdu, } #endif /* PROXY */ -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; @@ -568,11 +566,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] = {0}; + uint8_t priv_rand[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, }; + uint8_t tmp[16] = {0}; int err = 0, i; BT_DBG("IVIndex %u, PrivacyKey %s", iv_index, bt_hex(privacy_key, 16)); @@ -594,11 +592,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 net_buf_simple *buf, - u32_t iv_index, bool proxy) +int bt_mesh_net_encrypt(const uint8_t key[16], struct net_buf_simple *buf, + uint32_t iv_index, bool proxy) { - u8_t mic_len = NET_MIC_LEN(buf->data); - u8_t nonce[13] = {0}; + uint8_t mic_len = NET_MIC_LEN(buf->data); + uint8_t nonce[13] = {0}; int err = 0; BT_DBG("IVIndex %u EncKey %s mic_len %u", iv_index, bt_hex(key, 16), @@ -626,11 +624,11 @@ int bt_mesh_net_encrypt(const u8_t key[16], struct net_buf_simple *buf, return err; } -int bt_mesh_net_decrypt(const u8_t key[16], struct net_buf_simple *buf, - u32_t iv_index, bool proxy) +int bt_mesh_net_decrypt(const uint8_t key[16], struct net_buf_simple *buf, + uint32_t iv_index, bool proxy) { - u8_t mic_len = NET_MIC_LEN(buf->data); - u8_t nonce[13] = {0}; + uint8_t mic_len = NET_MIC_LEN(buf->data); + uint8_t nonce[13] = {0}; BT_DBG("PDU (%u bytes) %s", buf->len, bt_hex(buf->data, buf->len)); BT_DBG("iv_index %u, key %s mic_len %u", iv_index, bt_hex(key, 16), @@ -654,9 +652,9 @@ int bt_mesh_net_decrypt(const u8_t key[16], struct net_buf_simple *buf, NULL, 0, &buf->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; @@ -664,7 +662,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]); @@ -672,11 +670,11 @@ static void create_app_nonce(u8_t nonce[13], bool dev_key, u8_t aszmic, sys_put_be32(iv_index, &nonce[9]); } -int bt_mesh_app_encrypt(const u8_t key[16], bool dev_key, u8_t aszmic, - struct net_buf_simple *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 net_buf_simple *buf, const uint8_t *ad, + uint16_t src, uint16_t dst, uint32_t seq_num, uint32_t iv_index) { - u8_t nonce[13] = {0}; + uint8_t nonce[13] = {0}; int err = 0; BT_DBG("AppKey %s", bt_hex(key, 16)); @@ -698,12 +696,12 @@ int bt_mesh_app_encrypt(const u8_t key[16], bool dev_key, u8_t aszmic, return err; } -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 net_buf_simple *buf, struct net_buf_simple *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] = {0}; + uint8_t nonce[13] = {0}; int err = 0; BT_DBG("EncData (len %u) %s", buf->len, bt_hex(buf->data, buf->len)); @@ -723,7 +721,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, @@ -765,9 +763,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++]; @@ -778,11 +776,11 @@ u8_t bt_mesh_fcs_calc(const u8_t *data, u8_t data_len) return 0xff - fcs; } -bool bt_mesh_fcs_check(struct net_buf_simple *buf, u8_t received_fcs) +bool bt_mesh_fcs_check(struct net_buf_simple *buf, uint8_t received_fcs) { - const u8_t *data = buf->data; - u16_t data_len = buf->len; - u8_t fcs = 0xff; + const uint8_t *data = buf->data; + uint16_t data_len = buf->len; + uint8_t fcs = 0xff; while (data_len--) { fcs = crc_table[fcs ^ *data++]; @@ -791,10 +789,10 @@ bool bt_mesh_fcs_check(struct net_buf_simple *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] = {0}; - u8_t tmp[16] = {0}; + uint8_t salt[16] = {0}; + uint8_t tmp[16] = {0}; int err = 0; err = bt_mesh_s1("vtad", salt); @@ -812,21 +810,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 } }; @@ -837,25 +835,25 @@ 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_mesh_ccm_decrypt(key, nonce, data, 25, NULL, 0, out, 8); } #if CONFIG_BLE_MESH_PROVISIONER -int bt_mesh_prov_encrypt(const u8_t key[16], u8_t nonce[13], - const u8_t data[25], u8_t out[33]) +int bt_mesh_prov_encrypt(const uint8_t key[16], uint8_t nonce[13], + const uint8_t data[25], uint8_t out[33]) { return bt_mesh_ccm_encrypt(key, nonce, data, 25, NULL, 0, out, 8); } #endif -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] = {0}, tmp[16] = {0}; + uint8_t msg[13] = {0}, tmp[16] = {0}; int err = 0; BT_DBG("BeaconKey %s", bt_hex(beacon_key, 16)); diff --git a/components/bt/esp_ble_mesh/mesh_core/crypto.h b/components/bt/esp_ble_mesh/mesh_core/crypto.h index 147d85673b..4e9a6f3fa5 100644 --- a/components/bt/esp_ble_mesh/mesh_core/crypto.h +++ b/components/bt/esp_ble_mesh/mesh_core/crypto.h @@ -22,81 +22,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); @@ -107,19 +107,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 }, @@ -129,43 +129,43 @@ 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 net_buf_simple *buf, - u32_t iv_index, bool proxy); +int bt_mesh_net_encrypt(const uint8_t key[16], struct net_buf_simple *buf, + uint32_t iv_index, bool proxy); -int bt_mesh_net_decrypt(const u8_t key[16], struct net_buf_simple *buf, - u32_t iv_index, bool proxy); +int bt_mesh_net_decrypt(const uint8_t key[16], struct net_buf_simple *buf, + uint32_t iv_index, bool proxy); -int bt_mesh_app_encrypt(const u8_t key[16], bool dev_key, u8_t aszmic, - struct net_buf_simple *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 net_buf_simple *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 net_buf_simple *buf, struct net_buf_simple *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 net_buf_simple *buf, u8_t received_fcs); +bool bt_mesh_fcs_check(struct net_buf_simple *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[33]); +int bt_mesh_prov_encrypt(const uint8_t key[16], uint8_t nonce[13], + const uint8_t data[25], uint8_t out[33]); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_core/fast_prov.c b/components/bt/esp_ble_mesh/mesh_core/fast_prov.c index f7cb529ca1..992c6032f8 100644 --- a/components/bt/esp_ble_mesh/mesh_core/fast_prov.c +++ b/components/bt/esp_ble_mesh/mesh_core/fast_prov.c @@ -30,7 +30,7 @@ #define ACTION_SUSPEND 0x02 #define ACTION_EXIT 0x03 -const u8_t *bt_mesh_fast_prov_dev_key_get(u16_t dst) +const uint8_t *bt_mesh_fast_prov_dev_key_get(uint16_t dst) { if (!BLE_MESH_ADDR_IS_UNICAST(dst)) { BT_ERR("Invalid unicast address 0x%04x", dst); @@ -44,7 +44,7 @@ const u8_t *bt_mesh_fast_prov_dev_key_get(u16_t dst) return bt_mesh_provisioner_dev_key_get(dst); } -struct bt_mesh_subnet *bt_mesh_fast_prov_subnet_get(u16_t net_idx) +struct bt_mesh_subnet *bt_mesh_fast_prov_subnet_get(uint16_t net_idx) { struct bt_mesh_subnet *sub = NULL; int i; @@ -66,7 +66,7 @@ struct bt_mesh_subnet *bt_mesh_fast_prov_subnet_get(u16_t net_idx) return NULL; } -struct bt_mesh_app_key *bt_mesh_fast_prov_app_key_find(u16_t app_idx) +struct bt_mesh_app_key *bt_mesh_fast_prov_app_key_find(uint16_t app_idx) { struct bt_mesh_app_key *key = NULL; int i; @@ -90,7 +90,7 @@ struct bt_mesh_app_key *bt_mesh_fast_prov_app_key_find(u16_t app_idx) return NULL; } -u8_t bt_mesh_set_fast_prov_net_idx(u16_t net_idx) +uint8_t bt_mesh_set_fast_prov_net_idx(uint16_t net_idx) { /* Set net_idx for fast provisioning */ bt_mesh_provisioner_set_fast_prov_net_idx(net_idx); @@ -104,9 +104,9 @@ u8_t bt_mesh_set_fast_prov_net_idx(u16_t net_idx) return 0x0; /* status: Succeed */ } -u8_t bt_mesh_fast_prov_net_key_add(const u8_t net_key[16]) +uint8_t bt_mesh_fast_prov_net_key_add(const uint8_t net_key[16]) { - u16_t net_idx = 0U; + uint16_t net_idx = 0U; int err = 0; net_idx = bt_mesh_provisioner_get_fast_prov_net_idx(); @@ -122,7 +122,7 @@ u8_t bt_mesh_fast_prov_net_key_add(const u8_t net_key[16]) return 0x0; /* status: Succeed */ } -const u8_t *bt_mesh_fast_prov_net_key_get(u16_t net_idx) +const uint8_t *bt_mesh_fast_prov_net_key_get(uint16_t net_idx) { struct bt_mesh_subnet *sub = NULL; @@ -135,7 +135,7 @@ const u8_t *bt_mesh_fast_prov_net_key_get(u16_t net_idx) return (sub->kr_flag ? sub->keys[1].net : sub->keys[0].net); } -const u8_t *bt_mesh_get_fast_prov_app_key(u16_t net_idx, u16_t app_idx) +const uint8_t *bt_mesh_get_fast_prov_app_key(uint16_t net_idx, uint16_t app_idx) { struct bt_mesh_app_key *key = NULL; @@ -148,7 +148,7 @@ const u8_t *bt_mesh_get_fast_prov_app_key(u16_t net_idx, u16_t app_idx) return (key->updated ? key->keys[1].val : key->keys[0].val); } -u8_t bt_mesh_set_fast_prov_action(u8_t action) +uint8_t bt_mesh_set_fast_prov_action(uint8_t action) { if (!action || action > ACTION_EXIT) { return 0x01; diff --git a/components/bt/esp_ble_mesh/mesh_core/fast_prov.h b/components/bt/esp_ble_mesh/mesh_core/fast_prov.h index 9ab6fc4bef..f4002c73f7 100644 --- a/components/bt/esp_ble_mesh/mesh_core/fast_prov.h +++ b/components/bt/esp_ble_mesh/mesh_core/fast_prov.h @@ -21,21 +21,21 @@ extern "C" { #endif -const u8_t *bt_mesh_fast_prov_dev_key_get(u16_t dst); +const uint8_t *bt_mesh_fast_prov_dev_key_get(uint16_t dst); -struct bt_mesh_subnet *bt_mesh_fast_prov_subnet_get(u16_t net_idx); +struct bt_mesh_subnet *bt_mesh_fast_prov_subnet_get(uint16_t net_idx); -struct bt_mesh_app_key *bt_mesh_fast_prov_app_key_find(u16_t app_idx); +struct bt_mesh_app_key *bt_mesh_fast_prov_app_key_find(uint16_t app_idx); -u8_t bt_mesh_set_fast_prov_net_idx(u16_t net_idx); +uint8_t bt_mesh_set_fast_prov_net_idx(uint16_t net_idx); -u8_t bt_mesh_fast_prov_net_key_add(const u8_t net_key[16]); +uint8_t bt_mesh_fast_prov_net_key_add(const uint8_t net_key[16]); -const u8_t *bt_mesh_fast_prov_net_key_get(u16_t net_idx); +const uint8_t *bt_mesh_fast_prov_net_key_get(uint16_t net_idx); -const u8_t *bt_mesh_get_fast_prov_app_key(u16_t net_idx, u16_t app_idx); +const uint8_t *bt_mesh_get_fast_prov_app_key(uint16_t net_idx, uint16_t app_idx); -u8_t bt_mesh_set_fast_prov_action(u8_t action); +uint8_t bt_mesh_set_fast_prov_action(uint8_t action); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_core/foundation.h b/components/bt/esp_ble_mesh/mesh_core/foundation.h index f766fc9c36..53b6e96c9e 100644 --- a/components/bt/esp_ble_mesh/mesh_core/foundation.h +++ b/components/bt/esp_ble_mesh/mesh_core/foundation.h @@ -126,9 +126,9 @@ enum { }; struct label { - u16_t ref; - u16_t addr; - u8_t uuid[16]; + uint16_t ref; + uint16_t addr; + uint8_t uuid[16]; bt_mesh_atomic_t flags[1]; }; @@ -136,40 +136,40 @@ void bt_mesh_mod_sub_reset(bool store); void bt_mesh_cfg_reset(bool store); -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 net_buf_simple *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 net_buf_simple *buf, - u16_t *idx1, u16_t *idx2) + uint16_t *idx1, uint16_t *idx2) { *idx1 = sys_get_le16(&buf->data[0]) & 0xfff; *idx2 = sys_get_le16(&buf->data[1]) >> 4; diff --git a/components/bt/esp_ble_mesh/mesh_core/friend.c b/components/bt/esp_ble_mesh/mesh_core/friend.c index ba46c6bd5b..22a459e82c 100644 --- a/components/bt/esp_ble_mesh/mesh_core/friend.c +++ b/components/bt/esp_ble_mesh/mesh_core/friend.c @@ -10,8 +10,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_FRIEND) - #include "crypto.h" #include "adv.h" #include "mesh.h" @@ -38,15 +36,15 @@ #define FRIEND_XMIT BLE_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, - ctl: 1; + uint8_t ttl:7, + ctl:1; - u32_t iv_index; + uint32_t iv_index; }; NET_BUF_POOL_FIXED_DEFINE(friend_buf_pool, FRIEND_BUF_COUNT, @@ -54,7 +52,7 @@ NET_BUF_POOL_FIXED_DEFINE(friend_buf_pool, FRIEND_BUF_COUNT, static struct friend_adv { struct bt_mesh_adv adv; - u16_t app_idx; + uint16_t app_idx; } adv_pool[FRIEND_BUF_COUNT]; enum { @@ -65,11 +63,11 @@ enum { BLE_MESH_FRIENDSHIP_TERMINATE_DISABLE, }; -static void (*friend_cb)(bool establish, u16_t lpn_addr, u8_t reason); +static void (*friend_cb)(bool establish, uint16_t lpn_addr, uint8_t reason); static bool friend_init = false; -static struct bt_mesh_subnet *friend_subnet_get(u16_t net_idx) +static struct bt_mesh_subnet *friend_subnet_get(uint16_t net_idx) { struct bt_mesh_subnet *sub = NULL; @@ -88,7 +86,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 == BLE_MESH_ADDR_UNASSIGNED) { return false; @@ -97,8 +95,8 @@ 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, - bool valid, bool established) +struct bt_mesh_friend *bt_mesh_friend_find(uint16_t net_idx, uint16_t lpn_addr, + bool valid, bool established) { int i; @@ -146,16 +144,16 @@ static void purge_buffers(sys_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_BLE_MESH_FRIEND_RECV_WIN > 50 - return (s32_t)frnd->recv_delay + (CONFIG_BLE_MESH_FRIEND_RECV_WIN / 5); + return (int32_t)frnd->recv_delay + (CONFIG_BLE_MESH_FRIEND_RECV_WIN / 5); #else return frnd->recv_delay; #endif } -static void friend_clear(struct bt_mesh_friend *frnd, u8_t reason) +static void friend_clear(struct bt_mesh_friend *frnd, uint8_t reason) { int i; @@ -202,7 +200,7 @@ static void friend_clear(struct bt_mesh_friend *frnd, u8_t reason) (void)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; @@ -221,7 +219,7 @@ void bt_mesh_friend_clear_net_idx(u16_t net_idx) } } -void bt_mesh_friend_sec_update(u16_t net_idx) +void bt_mesh_friend_sec_update(uint16_t net_idx) { int i; @@ -244,7 +242,7 @@ int bt_mesh_friend_clear(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) { struct bt_mesh_ctl_friend_clear *msg = (void *)buf->data; struct bt_mesh_friend *frnd = NULL; - u16_t lpn_addr = 0U, lpn_counter = 0U; + uint16_t lpn_addr = 0U, lpn_counter = 0U; struct bt_mesh_net_tx tx = { .sub = rx->sub, .ctx = &rx->ctx, @@ -294,7 +292,7 @@ int bt_mesh_friend_clear(struct bt_mesh_net_rx *rx, struct net_buf_simple *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; @@ -308,7 +306,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; @@ -321,8 +319,8 @@ static void friend_sub_rem(struct bt_mesh_friend *frnd, u16_t addr) } static struct net_buf *create_friend_pdu(struct bt_mesh_friend *frnd, - struct friend_pdu_info *info, - struct net_buf_simple *sdu) + struct friend_pdu_info *info, + struct net_buf_simple *sdu) { struct net_buf *buf = NULL; @@ -353,19 +351,19 @@ static struct net_buf *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 net_buf *buf, struct unseg_app_sdu_meta *meta) { - u16_t app_idx = FRIEND_ADV(buf)->app_idx; - u8_t role = 0U; + uint16_t app_idx = FRIEND_ADV(buf)->app_idx; + uint8_t role = 0U; int err = 0; meta->subnet = friend_subnet_get(frnd->net_idx); @@ -471,10 +469,10 @@ static int encrypt_friend_pdu(struct bt_mesh_friend *frnd, struct net_buf *buf, bool master_cred) { struct bt_mesh_subnet *sub = friend_subnet_get(frnd->net_idx); - const u8_t *enc = NULL, *priv = NULL; - u32_t iv_index = 0U; - u16_t src = 0U; - u8_t nid = 0U; + const uint8_t *enc = NULL, *priv = NULL; + uint32_t iv_index = 0U; + uint16_t src = 0U; + uint8_t nid = 0U; int err = 0; if (!sub) { @@ -496,7 +494,7 @@ static int encrypt_friend_pdu(struct bt_mesh_friend *frnd, struct net_buf *buf, src = sys_get_be16(&buf->data[5]); if (bt_mesh_elem_find(src)) { - u32_t seq; + uint32_t seq; if (FRIEND_ADV(buf)->app_idx != BLE_MESH_KEY_UNUSED) { err = unseg_app_sdu_prepare(frnd, buf); @@ -511,7 +509,7 @@ static int encrypt_friend_pdu(struct bt_mesh_friend *frnd, struct net_buf *buf, iv_index = BLE_MESH_NET_IVI_TX; FRIEND_ADV(buf)->app_idx = BLE_MESH_KEY_UNUSED; } else { - u8_t ivi = (buf->data[0] >> 7); + uint8_t ivi = (buf->data[0] >> 7); iv_index = (bt_mesh.iv_index - ((bt_mesh.iv_index & 1) != ivi)); } @@ -531,8 +529,8 @@ static int encrypt_friend_pdu(struct bt_mesh_friend *frnd, struct net_buf *buf, } static struct net_buf *encode_friend_ctl(struct bt_mesh_friend *frnd, - u8_t ctl_op, - struct net_buf_simple *sdu) + uint8_t ctl_op, + struct net_buf_simple *sdu) { struct friend_pdu_info info = {0}; @@ -553,7 +551,7 @@ static struct net_buf *encode_friend_ctl(struct bt_mesh_friend *frnd, return create_friend_pdu(frnd, &info, sdu); } -static struct net_buf *encode_update(struct bt_mesh_friend *frnd, u8_t md) +static struct net_buf *encode_update(struct bt_mesh_friend *frnd, uint8_t md) { struct bt_mesh_ctl_friend_update *upd = NULL; NET_BUF_SIMPLE_DEFINE(sdu, 1 + sizeof(*upd)); @@ -576,7 +574,7 @@ static struct net_buf *encode_update(struct bt_mesh_friend *frnd, u8_t md) return encode_friend_ctl(frnd, TRANS_CTL_OP_FRIEND_UPDATE, &sdu); } -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 = NULL; NET_BUF_SIMPLE_DEFINE(sdu, 1 + sizeof(*cfm)); @@ -619,7 +617,7 @@ int bt_mesh_friend_sub_add(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) { struct bt_mesh_friend *frnd = NULL; - u8_t xact = 0U; + uint8_t xact = 0U; if (buf->len < BLE_MESH_FRIEND_SUB_MIN_LEN) { BT_WARN("Too short Friend Subscription Add (len %d)", buf->len); @@ -654,7 +652,7 @@ int bt_mesh_friend_sub_rem(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) { struct bt_mesh_friend *frnd = NULL; - u8_t xact = 0U; + uint8_t xact = 0U; if (buf->len < BLE_MESH_FRIEND_SUB_MIN_LEN) { BT_WARN("Too short Friend Subscription Remove (len %d)", buf->len); @@ -691,7 +689,7 @@ static void enqueue_buf(struct bt_mesh_friend *frnd, struct net_buf *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 net_buf *buf = NULL; @@ -763,7 +761,7 @@ int bt_mesh_friend_poll(struct bt_mesh_net_rx *rx, struct net_buf_simple *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; @@ -825,7 +823,7 @@ static void clear_timeout(struct k_work *work) { struct bt_mesh_friend *frnd = CONTAINER_OF(work, struct bt_mesh_friend, clear.timer.work); - u32_t duration = 0U; + uint32_t duration = 0U; BT_DBG("LPN 0x%04x (old) Friend 0x%04x", frnd->lpn, frnd->clear.frnd); @@ -854,7 +852,7 @@ int bt_mesh_friend_clear_cfm(struct bt_mesh_net_rx *rx, { struct bt_mesh_ctl_friend_clear_confirm *msg = (void *)buf->data; struct bt_mesh_friend *frnd = NULL; - u16_t lpn_addr = 0U, lpn_counter = 0U; + uint16_t lpn_addr = 0U, lpn_counter = 0U; BT_DBG("%s", __func__); @@ -889,7 +887,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 = NULL; NET_BUF_SIMPLE_DEFINE(sdu, 1 + sizeof(*off)); @@ -928,26 +926,26 @@ static void enqueue_offer(struct bt_mesh_friend *frnd, s8_t rssi) } #define RECV_WIN CONFIG_BLE_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 = 0; + static const uint8_t fact[] = { 10, 15, 20, 25 }; + int32_t delay = 0; BT_INFO("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", delay); @@ -963,7 +961,7 @@ int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) { struct bt_mesh_ctl_friend_req *msg = (void *)buf->data; struct bt_mesh_friend *frnd = NULL; - u32_t poll_to = 0U; + uint32_t poll_to = 0U; int i; if (buf->len < sizeof(*msg)) { @@ -1061,12 +1059,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 net_buf *buf = (void *)sys_slist_peek_head(&seg->queue); struct net_buf_simple_state state = {0}; - u16_t buf_seq_zero = 0U; - u16_t buf_src = 0U; + uint16_t buf_seq_zero = 0U; + uint16_t buf_src = 0U; if (!buf) { return false; @@ -1083,8 +1081,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; @@ -1110,7 +1108,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 net_buf *buf) { struct bt_mesh_friend_seg *seg = NULL; @@ -1126,7 +1124,7 @@ static void enqueue_friend_pdu(struct bt_mesh_friend *frnd, return; } - u16_t seq_zero = (((buf->data[10] << 8 | buf->data[11]) >> 2) & TRANS_SEQ_ZERO_MASK); + uint16_t seq_zero = (((buf->data[10] << 8 | buf->data[11]) >> 2) & TRANS_SEQ_ZERO_MASK); seg = get_seg(frnd, src, seq_zero, seg_count); if (!seg) { @@ -1152,7 +1150,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; @@ -1242,7 +1240,7 @@ send_last: bt_mesh_adv_send(frnd->last, &buf_sent_cb, frnd); } -void bt_mesh_friend_set_cb(void (*cb)(bool establish, u16_t lpn_addr, u8_t reason)) +void bt_mesh_friend_set_cb(void (*cb)(bool establish, uint16_t lpn_addr, uint8_t reason)) { friend_cb = cb; } @@ -1307,7 +1305,7 @@ int bt_mesh_friend_deinit(void) } #endif /* CONFIG_BLE_MESH_DEINIT */ -static bool is_segack(struct net_buf *buf, const u64_t *seqauth, u16_t src) +static bool is_segack(struct net_buf *buf, const uint64_t *seqauth, uint16_t src) { struct net_buf_simple_state state = {0}; bool found = false; @@ -1332,7 +1330,7 @@ static bool is_segack(struct net_buf *buf, const 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; } @@ -1344,7 +1342,7 @@ end: } static void friend_purge_old_ack(struct bt_mesh_friend *frnd, - const u64_t *seq_auth, u16_t src) + const uint64_t *seq_auth, uint16_t src) { sys_snode_t *cur = NULL, *prev = NULL; @@ -1371,7 +1369,7 @@ static void friend_purge_old_ack(struct bt_mesh_friend *frnd, static void friend_lpn_enqueue_rx(struct bt_mesh_friend *frnd, struct bt_mesh_net_rx *rx, enum bt_mesh_friend_pdu_type type, - const u64_t *seq_auth, u8_t seg_count, + const uint64_t *seq_auth, uint8_t seg_count, struct net_buf_simple *sbuf) { struct friend_pdu_info info = {0}; @@ -1421,7 +1419,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, - const u64_t *seq_auth, u8_t seg_count, + const uint64_t *seq_auth, uint8_t seg_count, struct net_buf_simple *sbuf) { struct friend_pdu_info info = {0}; @@ -1462,8 +1460,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; @@ -1488,7 +1486,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; @@ -1507,10 +1505,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, - const u64_t *seq_auth, u8_t seg_count) +static bool friend_queue_has_space(struct bt_mesh_friend *frnd, uint16_t addr, + const uint64_t *seq_auth, uint8_t seg_count) { - u32_t total = 0U; + uint32_t total = 0U; int i; if (seg_count > CONFIG_BLE_MESH_FRIEND_QUEUE_SIZE) { @@ -1538,8 +1536,8 @@ static bool friend_queue_has_space(struct bt_mesh_friend *frnd, u16_t addr, return (CONFIG_BLE_MESH_FRIEND_QUEUE_SIZE - total) > seg_count; } -bool bt_mesh_friend_queue_has_space(u16_t net_idx, u16_t src, u16_t dst, - const 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, + const uint64_t *seq_auth, uint8_t seg_count) { bool someone_has_space = false, friend_match = false; int i; @@ -1573,11 +1571,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, - const u64_t *seq_auth, u8_t seg_count) +static bool friend_queue_prepare_space(struct bt_mesh_friend *frnd, uint16_t addr, + const uint64_t *seq_auth, uint8_t seg_count) { bool pending_segments = false; - u8_t avail_space = 0U; + uint8_t avail_space = 0U; if (!friend_queue_has_space(frnd, addr, seq_auth, seg_count)) { return false; @@ -1611,7 +1609,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, - const u64_t *seq_auth, u8_t seg_count, + const uint64_t *seq_auth, uint8_t seg_count, struct net_buf_simple *sbuf) { int i; @@ -1646,7 +1644,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, - const u64_t *seq_auth, u8_t seg_count, + const uint64_t *seq_auth, uint8_t seg_count, struct net_buf_simple *sbuf) { bool matched = false; @@ -1681,8 +1679,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, const u64_t *seq_auth) +void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, uint16_t src, + uint16_t dst, const uint64_t *seq_auth) { int i; @@ -1712,7 +1710,7 @@ void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, u16_t src, } } -void bt_mesh_friend_remove_lpn(u16_t lpn_addr) +void bt_mesh_friend_remove_lpn(uint16_t lpn_addr) { struct bt_mesh_friend *frnd = NULL; diff --git a/components/bt/esp_ble_mesh/mesh_core/friend.h b/components/bt/esp_ble_mesh/mesh_core/friend.h index 1f47c1bd55..12d52a9b87 100644 --- a/components/bt/esp_ble_mesh/mesh_core/friend.h +++ b/components/bt/esp_ble_mesh/mesh_core/friend.h @@ -21,29 +21,29 @@ enum bt_mesh_friend_pdu_type { BLE_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, - bool valid, bool established); +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, - const 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, + const 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, - const u64_t *seq_auth, u8_t seg_count, + const uint64_t *seq_auth, uint8_t seg_count, struct net_buf_simple *sbuf); bool bt_mesh_friend_enqueue_tx(struct bt_mesh_net_tx *tx, enum bt_mesh_friend_pdu_type type, - const u64_t *seq_auth, u8_t seg_count, + const uint64_t *seq_auth, uint8_t seg_count, struct net_buf_simple *sbuf); -void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, u16_t src, - u16_t dst, const u64_t *seq_auth); +void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, uint16_t src, + uint16_t dst, const 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 net_buf_simple *buf); int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf); @@ -58,7 +58,7 @@ int bt_mesh_friend_sub_rem(struct bt_mesh_net_rx *rx, int bt_mesh_friend_init(void); int bt_mesh_friend_deinit(void); -void bt_mesh_friend_remove_lpn(u16_t lpn_addr); +void bt_mesh_friend_remove_lpn(uint16_t lpn_addr); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_core/health_cli.c b/components/bt/esp_ble_mesh/mesh_core/health_cli.c index e0d644da7b..20b7f16a08 100644 --- a/components/bt/esp_ble_mesh/mesh_core/health_cli.c +++ b/components/bt/esp_ble_mesh/mesh_core/health_cli.c @@ -10,8 +10,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_MODEL) - #include "btc_ble_mesh_health_model.h" #include "mesh_config.h" @@ -62,7 +60,7 @@ static void timeout_handler(struct k_work *work) struct k_delayed_work *timer = NULL; bt_mesh_client_node_t *node = NULL; struct bt_mesh_msg_ctx ctx = {0}; - u32_t opcode = 0U; + uint32_t opcode = 0U; BT_WARN("Receive health status message timeout"); @@ -92,7 +90,7 @@ static void health_client_recv_status(struct bt_mesh_model *model, { bt_mesh_client_node_t *node = NULL; struct net_buf_simple buf = {0}; - u8_t evt_type = 0xFF; + uint8_t evt_type = 0xFF; if (!model || !ctx || !status || !len) { BT_ERR("%s, Invalid parameter", __func__); @@ -100,8 +98,8 @@ static void health_client_recv_status(struct bt_mesh_model *model, } /* If it is a publish message, sent to the user directly. */ - buf.data = (u8_t *)status; - buf.len = (u16_t)len; + buf.data = (uint8_t *)status; + buf.len = (uint16_t)len; bt_mesh_health_client_lock(); @@ -126,10 +124,10 @@ static void health_client_recv_status(struct bt_mesh_model *model, } if (!k_delayed_work_free(&node->timer)) { - u32_t opcode = node->opcode; + uint32_t opcode = node->opcode; bt_mesh_client_free_node(node); bt_mesh_health_client_cb_evt_to_btc( - opcode, evt_type, model, ctx, (const u8_t *)status, len); + opcode, evt_type, model, ctx, (const uint8_t *)status, len); } } @@ -201,7 +199,7 @@ static void health_period_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - u8_t status = 0U; + uint8_t status = 0U; 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->len, @@ -209,14 +207,14 @@ static void health_period_status(struct bt_mesh_model *model, status = net_buf_simple_pull_u8(buf); - health_client_recv_status(model, ctx, &status, sizeof(u8_t)); + health_client_recv_status(model, ctx, &status, sizeof(uint8_t)); } static void health_attention_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - u8_t status = 0U; + uint8_t status = 0U; 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->len, @@ -224,7 +222,7 @@ static void health_attention_status(struct bt_mesh_model *model, status = net_buf_simple_pull_u8(buf); - health_client_recv_status(model, ctx, &status, sizeof(u8_t)); + health_client_recv_status(model, ctx, &status, sizeof(uint8_t)); } const struct bt_mesh_model_op bt_mesh_health_cli_op[] = { @@ -245,7 +243,7 @@ int bt_mesh_health_attention_get(bt_mesh_client_common_param_t *param) } int bt_mesh_health_attention_set(bt_mesh_client_common_param_t *param, - u8_t attention, bool need_ack) + uint8_t attention, bool need_ack) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_ATTENTION_SET, 1); @@ -265,7 +263,7 @@ int bt_mesh_health_period_get(bt_mesh_client_common_param_t *param) } int bt_mesh_health_period_set(bt_mesh_client_common_param_t *param, - u8_t divisor, bool need_ack) + uint8_t divisor, bool need_ack) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_PERIOD_SET, 1); @@ -276,7 +274,7 @@ int bt_mesh_health_period_set(bt_mesh_client_common_param_t *param, } int bt_mesh_health_fault_test(bt_mesh_client_common_param_t *param, - u16_t cid, u8_t test_id, bool need_ack) + uint16_t cid, uint8_t test_id, bool need_ack) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_FAULT_TEST, 3); @@ -288,7 +286,7 @@ int bt_mesh_health_fault_test(bt_mesh_client_common_param_t *param, } int bt_mesh_health_fault_clear(bt_mesh_client_common_param_t *param, - u16_t cid, bool need_ack) + uint16_t cid, bool need_ack) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_FAULT_CLEAR, 2); @@ -298,7 +296,7 @@ int bt_mesh_health_fault_clear(bt_mesh_client_common_param_t *param, return bt_mesh_client_send_msg(param, &msg, need_ack, timeout_handler); } -int bt_mesh_health_fault_get(bt_mesh_client_common_param_t *param, u16_t cid) +int bt_mesh_health_fault_get(bt_mesh_client_common_param_t *param, uint16_t cid) { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_FAULT_GET, 2); diff --git a/components/bt/esp_ble_mesh/mesh_core/health_srv.c b/components/bt/esp_ble_mesh/mesh_core/health_srv.c index 4d13b6a0b1..48a502733d 100644 --- a/components/bt/esp_ble_mesh/mesh_core/health_srv.c +++ b/components/bt/esp_ble_mesh/mesh_core/health_srv.c @@ -10,8 +10,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_MODEL) - #include "btc_ble_mesh_health_model.h" #include "access.h" @@ -38,10 +36,10 @@ struct bt_mesh_health_srv *health_srv; * the node for more than one Company ID. */ -static u8_t health_get_curr_fault_count(struct bt_mesh_model *model) +static uint8_t health_get_curr_fault_count(struct bt_mesh_model *model) { struct bt_mesh_health_srv *srv = model->user_data; - u8_t count = 0U; + uint8_t count = 0U; size_t i = 0U; for (i = 0U; i < ARRAY_SIZE(srv->test.curr_faults); i++) { @@ -68,14 +66,14 @@ static void health_get_fault_value(struct bt_mesh_model *model, return; } - u8_t fault = current ? srv->test.curr_faults[i] : srv->test.reg_faults[i]; + uint8_t fault = current ? srv->test.curr_faults[i] : srv->test.reg_faults[i]; if (fault != HEALTH_NO_FAULT) { net_buf_simple_add_u8(msg, fault); } } } -static bool health_is_test_id_exist(struct bt_mesh_model *model, u8_t test_id) +static bool health_is_test_id_exist(struct bt_mesh_model *model, uint8_t test_id) { struct bt_mesh_health_srv *srv = model->user_data; int i; @@ -127,7 +125,7 @@ static void health_fault_get(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_health_srv *srv = model->user_data; - u16_t company_id = 0U; + uint16_t company_id = 0U; if (!srv) { BT_ERR("No Health Server context provided"); @@ -150,7 +148,7 @@ static void health_fault_clear(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_health_srv *srv = model->user_data; - u16_t company_id = 0U; + uint16_t company_id = 0U; if (!srv) { BT_ERR("No Health Server context provided"); @@ -181,8 +179,8 @@ static void health_fault_test(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_health_srv *srv = model->user_data; - u16_t company_id = 0U; - u8_t test_id = 0U; + uint16_t company_id = 0U; + uint8_t test_id = 0U; BT_DBG("%s", __func__); @@ -221,7 +219,7 @@ static void send_attention_status(struct bt_mesh_model *model, { BLE_MESH_MODEL_BUF_DEFINE(msg, OP_ATTENTION_STATUS, 1); struct bt_mesh_health_srv *srv = model->user_data; - u8_t time = 0U; + uint8_t time = 0U; if (!srv) { BT_ERR("No Health Server context provided"); @@ -252,7 +250,7 @@ static void health_set_attention(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - u8_t time = 0U; + uint8_t time = 0U; time = net_buf_simple_pull_u8(buf); @@ -300,7 +298,7 @@ static void health_set_period(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - u8_t period = 0U; + uint8_t period = 0U; period = net_buf_simple_pull_u8(buf); if (period > 15) { @@ -511,7 +509,7 @@ const struct bt_mesh_model_cb bt_mesh_health_srv_cb = { #endif /* CONFIG_BLE_MESH_DEINIT */ }; -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 = NULL; @@ -550,7 +548,7 @@ void bt_mesh_attention(struct bt_mesh_model *model, u8_t time) } } #else /* CONFIG_BLE_MESH_HEALTH_SRV */ -void bt_mesh_attention(struct bt_mesh_model *model, u8_t time) +void bt_mesh_attention(struct bt_mesh_model *model, uint8_t time) { return; } diff --git a/components/bt/esp_ble_mesh/mesh_core/include/cfg_cli.h b/components/bt/esp_ble_mesh/mesh_core/include/cfg_cli.h index 2294a58f92..ebb6b064e8 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/cfg_cli.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/cfg_cli.h @@ -35,84 +35,84 @@ extern const struct bt_mesh_model_cb bt_mesh_cfg_cli_cb; BLE_MESH_MODEL_CB(BLE_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(bt_mesh_client_common_param_t *param, u8_t page); +int bt_mesh_cfg_comp_data_get(bt_mesh_client_common_param_t *param, uint8_t page); int bt_mesh_cfg_beacon_get(bt_mesh_client_common_param_t *param); -int bt_mesh_cfg_beacon_set(bt_mesh_client_common_param_t *param, u8_t val); +int bt_mesh_cfg_beacon_set(bt_mesh_client_common_param_t *param, uint8_t val); int bt_mesh_cfg_ttl_get(bt_mesh_client_common_param_t *param); -int bt_mesh_cfg_ttl_set(bt_mesh_client_common_param_t *param, u8_t val); +int bt_mesh_cfg_ttl_set(bt_mesh_client_common_param_t *param, uint8_t val); int bt_mesh_cfg_friend_get(bt_mesh_client_common_param_t *param); -int bt_mesh_cfg_friend_set(bt_mesh_client_common_param_t *param, u8_t val); +int bt_mesh_cfg_friend_set(bt_mesh_client_common_param_t *param, uint8_t val); int bt_mesh_cfg_gatt_proxy_get(bt_mesh_client_common_param_t *param); -int bt_mesh_cfg_gatt_proxy_set(bt_mesh_client_common_param_t *param, u8_t val); +int bt_mesh_cfg_gatt_proxy_set(bt_mesh_client_common_param_t *param, uint8_t val); int bt_mesh_cfg_relay_get(bt_mesh_client_common_param_t *param); int bt_mesh_cfg_relay_set(bt_mesh_client_common_param_t *param, - u8_t relay, u8_t retransmit); + uint8_t relay, uint8_t retransmit); int bt_mesh_cfg_net_key_add(bt_mesh_client_common_param_t *param, - u16_t net_idx, const u8_t net_key[16]); + uint16_t net_idx, const uint8_t net_key[16]); int bt_mesh_cfg_app_key_add(bt_mesh_client_common_param_t *param, - u16_t net_idx, u16_t app_idx, - const u8_t app_key[16]); + uint16_t net_idx, uint16_t app_idx, + const uint8_t app_key[16]); int bt_mesh_cfg_mod_app_bind(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t app_idx, - u16_t mod_id, u16_t cid); + uint16_t elem_addr, uint16_t app_idx, + uint16_t mod_id, uint16_t cid); struct bt_mesh_cfg_mod_pub { - u16_t addr; - u16_t app_idx; - bool cred_flag; - u8_t ttl; - u8_t period; - u8_t transmit; + uint16_t addr; + uint16_t app_idx; + bool cred_flag; + uint8_t ttl; + uint8_t period; + uint8_t transmit; }; int bt_mesh_cfg_mod_pub_get(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t mod_id, u16_t cid); + uint16_t elem_addr, uint16_t mod_id, uint16_t cid); int bt_mesh_cfg_mod_pub_set(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t mod_id, u16_t cid, + uint16_t elem_addr, uint16_t mod_id, uint16_t cid, struct bt_mesh_cfg_mod_pub *pub); int bt_mesh_cfg_mod_sub_add(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t sub_addr, - u16_t mod_id, u16_t cid); + uint16_t elem_addr, uint16_t sub_addr, + uint16_t mod_id, uint16_t cid); int bt_mesh_cfg_mod_sub_del(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t sub_addr, - u16_t mod_id, u16_t cid); + uint16_t elem_addr, uint16_t sub_addr, + uint16_t mod_id, uint16_t cid); int bt_mesh_cfg_mod_sub_overwrite(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t sub_addr, - u16_t mod_id, u16_t cid); + uint16_t elem_addr, uint16_t sub_addr, + uint16_t mod_id, uint16_t cid); int bt_mesh_cfg_mod_sub_va_add(bt_mesh_client_common_param_t *param, - u16_t elem_addr, const u8_t label[16], - u16_t mod_id, u16_t cid); + uint16_t elem_addr, const uint8_t label[16], + uint16_t mod_id, uint16_t cid); int bt_mesh_cfg_mod_sub_va_del(bt_mesh_client_common_param_t *param, - u16_t elem_addr, const u8_t label[16], - u16_t mod_id, u16_t cid); + uint16_t elem_addr, const uint8_t label[16], + uint16_t mod_id, uint16_t cid); int bt_mesh_cfg_mod_sub_va_overwrite(bt_mesh_client_common_param_t *param, - u16_t elem_addr, const u8_t label[16], - u16_t mod_id, u16_t cid); + uint16_t elem_addr, const uint8_t label[16], + uint16_t mod_id, uint16_t cid); struct bt_mesh_cfg_hb_sub { - u16_t src; - u16_t dst; - u8_t period; + uint16_t src; + uint16_t dst; + uint8_t period; }; int bt_mesh_cfg_hb_sub_set(bt_mesh_client_common_param_t *param, @@ -121,12 +121,12 @@ int bt_mesh_cfg_hb_sub_set(bt_mesh_client_common_param_t *param, int bt_mesh_cfg_hb_sub_get(bt_mesh_client_common_param_t *param); 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(bt_mesh_client_common_param_t *param, @@ -139,80 +139,80 @@ int bt_mesh_cfg_node_reset(bt_mesh_client_common_param_t *param); /* Configuration Client Status Message Context */ struct bt_mesh_cfg_comp_data_status { - u8_t page; + uint8_t page; struct net_buf_simple *comp_data; }; struct bt_mesh_cfg_relay_status { - u8_t relay; - u8_t retransmit; + uint8_t relay; + uint8_t retransmit; }; struct bt_mesh_cfg_netkey_status { - u8_t status; - u16_t net_idx; + uint8_t status; + uint16_t net_idx; }; struct bt_mesh_cfg_appkey_status { - u8_t status; - u16_t net_idx; - u16_t app_idx; + uint8_t status; + uint16_t net_idx; + uint16_t app_idx; }; struct bt_mesh_cfg_mod_app_status { - u8_t status; - u16_t elem_addr; - u16_t app_idx; - u16_t cid; - u16_t mod_id; + uint8_t status; + uint16_t elem_addr; + uint16_t app_idx; + uint16_t cid; + uint16_t mod_id; }; struct bt_mesh_cfg_mod_pub_status { - u8_t status; - u16_t elem_addr; - u16_t addr; - u16_t app_idx; - bool cred_flag; - u8_t ttl; - u8_t period; - u8_t transmit; - u16_t cid; - u16_t mod_id; + uint8_t status; + uint16_t elem_addr; + uint16_t addr; + uint16_t app_idx; + bool cred_flag; + uint8_t ttl; + uint8_t period; + uint8_t transmit; + uint16_t cid; + uint16_t mod_id; }; struct bt_mesh_cfg_mod_sub_status { - u8_t status; - u16_t elem_addr; - u16_t sub_addr; - u16_t cid; - u16_t mod_id; + uint8_t status; + uint16_t elem_addr; + uint16_t sub_addr; + uint16_t cid; + uint16_t mod_id; }; struct bt_mesh_cfg_hb_sub_status { - u8_t status; - u16_t src; - u16_t dst; - u8_t period; - u8_t count; - u8_t min; - u8_t max; + uint8_t status; + uint16_t src; + uint16_t dst; + uint8_t period; + uint8_t count; + uint8_t min; + uint8_t max; }; struct bt_mesh_cfg_hb_pub_status { - u8_t status; - u16_t dst; - u8_t count; - u8_t period; - u8_t ttl; - u16_t feat; - u16_t net_idx; + uint8_t status; + uint16_t dst; + uint8_t count; + uint8_t period; + uint8_t ttl; + uint16_t feat; + uint16_t net_idx; }; struct bt_mesh_cfg_mod_sub_list { - u8_t status; - u16_t elem_addr; - u16_t cid; - u16_t mod_id; + uint8_t status; + uint16_t elem_addr; + uint16_t cid; + uint16_t mod_id; struct net_buf_simple *addr; }; @@ -221,91 +221,91 @@ struct bt_mesh_cfg_net_key_list { }; struct bt_mesh_cfg_app_key_list { - u8_t status; - u16_t net_idx; + uint8_t status; + uint16_t net_idx; struct net_buf_simple *app_idx; }; struct bt_mesh_cfg_node_id_status { - u8_t status; - u16_t net_idx; - u8_t identity; + uint8_t status; + uint16_t net_idx; + uint8_t identity; }; struct bt_mesh_cfg_mod_app_list { - u8_t status; - u16_t elem_addr; - u16_t cid; - u16_t mod_id; + uint8_t status; + uint16_t elem_addr; + uint16_t cid; + uint16_t mod_id; struct net_buf_simple *app_idx; }; struct bt_mesh_cfg_key_refresh_status { - u8_t status; - u16_t net_idx; - u8_t phase; + uint8_t status; + uint16_t net_idx; + uint8_t phase; }; struct bt_mesh_cfg_lpn_pollto_status { - u16_t lpn_addr; - s32_t timeout; + uint16_t lpn_addr; + int32_t timeout; }; int bt_mesh_cfg_mod_pub_va_set(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t mod_id, - u16_t cid, const u8_t label[16], + uint16_t elem_addr, uint16_t mod_id, + uint16_t cid, const uint8_t label[16], struct bt_mesh_cfg_mod_pub *pub); int bt_mesh_cfg_mod_sub_del_all(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t mod_id, u16_t cid); + uint16_t elem_addr, uint16_t mod_id, uint16_t cid); int bt_mesh_cfg_mod_sub_get(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t mod_id); + uint16_t elem_addr, uint16_t mod_id); int bt_mesh_cfg_mod_sub_get_vnd(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t mod_id, u16_t cid); + uint16_t elem_addr, uint16_t mod_id, uint16_t cid); int bt_mesh_cfg_net_key_update(bt_mesh_client_common_param_t *param, - u16_t net_idx, const u8_t net_key[16]); + uint16_t net_idx, const uint8_t net_key[16]); -int bt_mesh_cfg_net_key_delete(bt_mesh_client_common_param_t *param, u16_t net_idx); +int bt_mesh_cfg_net_key_delete(bt_mesh_client_common_param_t *param, uint16_t net_idx); int bt_mesh_cfg_net_key_get(bt_mesh_client_common_param_t *param); int bt_mesh_cfg_app_key_update(bt_mesh_client_common_param_t *param, - u16_t net_idx, u16_t app_idx, - const u8_t app_key[16]); + uint16_t net_idx, uint16_t app_idx, + const uint8_t app_key[16]); int bt_mesh_cfg_app_key_delete(bt_mesh_client_common_param_t *param, - u16_t net_idx, u16_t app_idx); + uint16_t net_idx, uint16_t app_idx); -int bt_mesh_cfg_app_key_get(bt_mesh_client_common_param_t *param, u16_t net_idx); +int bt_mesh_cfg_app_key_get(bt_mesh_client_common_param_t *param, uint16_t net_idx); -int bt_mesh_cfg_node_identity_get(bt_mesh_client_common_param_t *param, u16_t net_idx); +int bt_mesh_cfg_node_identity_get(bt_mesh_client_common_param_t *param, uint16_t net_idx); int bt_mesh_cfg_node_identity_set(bt_mesh_client_common_param_t *param, - u16_t net_idx, u8_t identity); + uint16_t net_idx, uint8_t identity); int bt_mesh_cfg_mod_app_unbind(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t app_idx, - u16_t mod_id, u16_t cid); + uint16_t elem_addr, uint16_t app_idx, + uint16_t mod_id, uint16_t cid); int bt_mesh_cfg_mod_app_get(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t mod_id); + uint16_t elem_addr, uint16_t mod_id); int bt_mesh_cfg_mod_app_get_vnd(bt_mesh_client_common_param_t *param, - u16_t elem_addr, u16_t mod_id, u16_t cid); + uint16_t elem_addr, uint16_t mod_id, uint16_t cid); -int bt_mesh_cfg_kr_phase_get(bt_mesh_client_common_param_t *param, u16_t net_idx); +int bt_mesh_cfg_kr_phase_get(bt_mesh_client_common_param_t *param, uint16_t net_idx); int bt_mesh_cfg_kr_phase_set(bt_mesh_client_common_param_t *param, - u16_t net_idx, u8_t transition); + uint16_t net_idx, uint8_t transition); -int bt_mesh_cfg_lpn_timeout_get(bt_mesh_client_common_param_t *param, u16_t lpn_addr); +int bt_mesh_cfg_lpn_timeout_get(bt_mesh_client_common_param_t *param, uint16_t lpn_addr); int bt_mesh_cfg_net_transmit_get(bt_mesh_client_common_param_t *param); -int bt_mesh_cfg_net_transmit_set(bt_mesh_client_common_param_t *param, u8_t transmit); +int bt_mesh_cfg_net_transmit_set(bt_mesh_client_common_param_t *param, uint8_t transmit); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_core/include/cfg_srv.h b/components/bt/esp_ble_mesh/mesh_core/include/cfg_srv.h index 0af076e9e8..6bc6a7dc2e 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/cfg_srv.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/cfg_srv.h @@ -27,38 +27,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; }; @@ -71,144 +71,144 @@ extern const struct bt_mesh_model_cb bt_mesh_cfg_srv_cb; typedef union { struct { - u8_t beacon; + uint8_t beacon; } cfg_beacon_set; struct { - u8_t ttl; + uint8_t ttl; } cfg_default_ttl_set; struct { - u8_t gatt_proxy; + uint8_t gatt_proxy; } cfg_gatt_proxy_set; struct { - u8_t relay; - u8_t retransmit; + uint8_t relay; + uint8_t retransmit; } cfg_relay_set; struct { - u16_t elem_addr; - u16_t pub_addr; - u16_t app_idx; + uint16_t elem_addr; + uint16_t pub_addr; + uint16_t app_idx; bool cred_flag; - u8_t ttl; - u8_t period; - u8_t transmit; - u16_t cid; - u16_t mod_id; + uint8_t ttl; + uint8_t period; + uint8_t transmit; + uint16_t cid; + uint16_t mod_id; } cfg_mod_pub_set; struct { - u16_t elem_addr; - u8_t pub_addr[16]; - u16_t app_idx; + uint16_t elem_addr; + uint8_t pub_addr[16]; + uint16_t app_idx; bool cred_flag; - u8_t ttl; - u8_t period; - u8_t transmit; - u16_t cid; - u16_t mod_id; + uint8_t ttl; + uint8_t period; + uint8_t transmit; + uint16_t cid; + uint16_t mod_id; } cfg_mod_pub_va_set; struct { - u16_t elem_addr; - u16_t sub_addr; - u16_t cid; - u16_t mod_id; + uint16_t elem_addr; + uint16_t sub_addr; + uint16_t cid; + uint16_t mod_id; } cfg_mod_sub_add; struct { - u16_t elem_addr; - u8_t sub_addr[16]; - u16_t cid; - u16_t mod_id; + uint16_t elem_addr; + uint8_t sub_addr[16]; + uint16_t cid; + uint16_t mod_id; } cfg_mod_sub_va_add; struct { - u16_t elem_addr; - u16_t sub_addr; - u16_t cid; - u16_t mod_id; + uint16_t elem_addr; + uint16_t sub_addr; + uint16_t cid; + uint16_t mod_id; } cfg_mod_sub_delete; struct { - u16_t elem_addr; - u8_t sub_addr[16]; - u16_t cid; - u16_t mod_id; + uint16_t elem_addr; + uint8_t sub_addr[16]; + uint16_t cid; + uint16_t mod_id; } cfg_mod_sub_va_delete; struct { - u16_t elem_addr; - u16_t sub_addr; - u16_t cid; - u16_t mod_id; + uint16_t elem_addr; + uint16_t sub_addr; + uint16_t cid; + uint16_t mod_id; } cfg_mod_sub_overwrite; struct { - u16_t elem_addr; - u8_t sub_addr[16]; - u16_t cid; - u16_t mod_id; + uint16_t elem_addr; + uint8_t sub_addr[16]; + uint16_t cid; + uint16_t mod_id; } cfg_mod_sub_va_overwrite; struct { - u16_t elem_addr; - u16_t cid; - u16_t mod_id; + uint16_t elem_addr; + uint16_t cid; + uint16_t mod_id; } cfg_mod_sub_delete_all; struct { - u16_t net_idx; - u8_t net_key[16]; + uint16_t net_idx; + uint8_t net_key[16]; } cfg_netkey_add; struct { - u16_t net_idx; - u8_t net_key[16]; + uint16_t net_idx; + uint8_t net_key[16]; } cfg_netkey_update; struct { - u16_t net_idx; + uint16_t net_idx; } cfg_netkey_delete; struct { - u16_t net_idx; - u16_t app_idx; - u8_t app_key[16]; + uint16_t net_idx; + uint16_t app_idx; + uint8_t app_key[16]; } cfg_appkey_add; struct { - u16_t net_idx; - u16_t app_idx; - u8_t app_key[16]; + uint16_t net_idx; + uint16_t app_idx; + uint8_t app_key[16]; } cfg_appkey_update; struct { - u16_t net_idx; - u16_t app_idx; + uint16_t net_idx; + uint16_t app_idx; } cfg_appkey_delete; struct { - u16_t net_idx; - u8_t identity; + uint16_t net_idx; + uint8_t identity; } cfg_node_identity_set; struct { - u16_t elem_addr; - u16_t app_idx; - u16_t cid; - u16_t mod_id; + uint16_t elem_addr; + uint16_t app_idx; + uint16_t cid; + uint16_t mod_id; } cfg_mod_app_bind; struct { - u16_t elem_addr; - u16_t app_idx; - u16_t cid; - u16_t mod_id; + uint16_t elem_addr; + uint16_t app_idx; + uint16_t cid; + uint16_t mod_id; } cfg_mod_app_unbind; struct { - u8_t frnd; + uint8_t frnd; } cfg_friend_set; struct { - u16_t net_idx; - u8_t kr_phase; + uint16_t net_idx; + uint8_t kr_phase; } cfg_kr_phase_set; struct { - 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; } cfg_hb_pub_set; struct { - u16_t src; - u16_t dst; - u8_t period; + uint16_t src; + uint16_t dst; + uint8_t period; } cfg_hb_sub_set; struct { - u8_t transmit; + uint8_t transmit; } cfg_net_transmit_set; } bt_mesh_cfg_server_state_change_t; diff --git a/components/bt/esp_ble_mesh/mesh_core/include/health_cli.h b/components/bt/esp_ble_mesh/mesh_core/include/health_cli.h index 359b3878b9..b6578eb43e 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/health_cli.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/health_cli.h @@ -35,35 +35,35 @@ extern const struct bt_mesh_model_cb bt_mesh_health_cli_cb; BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_HEALTH_CLI, \ bt_mesh_health_cli_op, NULL, cli_data, &bt_mesh_health_cli_cb) -int bt_mesh_health_fault_get(bt_mesh_client_common_param_t *param, u16_t cid); +int bt_mesh_health_fault_get(bt_mesh_client_common_param_t *param, uint16_t cid); int bt_mesh_health_fault_clear(bt_mesh_client_common_param_t *param, - u16_t cid, bool need_ack); + uint16_t cid, bool need_ack); int bt_mesh_health_fault_test(bt_mesh_client_common_param_t *param, - u16_t cid, u8_t test_id, bool need_ack); + uint16_t cid, uint8_t test_id, bool need_ack); int bt_mesh_health_period_get(bt_mesh_client_common_param_t *param); int bt_mesh_health_period_set(bt_mesh_client_common_param_t *param, - u8_t divisor, bool need_ack); + uint8_t divisor, bool need_ack); int bt_mesh_health_attention_get(bt_mesh_client_common_param_t *param); int bt_mesh_health_attention_set(bt_mesh_client_common_param_t *param, - u8_t attention, bool need_ack); + uint8_t attention, bool need_ack); /* Health Client Status Message Context */ struct bt_mesh_health_current_status { - u8_t test_id; - u16_t cid; + uint8_t test_id; + uint16_t cid; struct net_buf_simple *fault_array; }; struct bt_mesh_health_fault_status { - u8_t test_id; - u16_t cid; + uint8_t test_id; + uint16_t cid; struct net_buf_simple *fault_array; }; diff --git a/components/bt/esp_ble_mesh/mesh_core/include/health_srv.h b/components/bt/esp_ble_mesh/mesh_core/include/health_srv.h index 8255993f8d..b88c1d7a02 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/health_srv.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/health_srv.h @@ -25,14 +25,14 @@ extern "C" { struct bt_mesh_health_srv_cb { /* Clear registered faults */ - void (*fault_clear)(struct bt_mesh_model *model, u16_t company_id); + void (*fault_clear)(struct bt_mesh_model *model, uint16_t company_id); /* Run a specific test */ - void (*fault_test)(struct bt_mesh_model *model, u8_t test_id, - u16_t company_id); + void (*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, u8_t time); + void (*attn_on)(struct bt_mesh_model *model, uint8_t time); /* Attention off */ void (*attn_off)(struct bt_mesh_model *model); @@ -49,12 +49,12 @@ struct bt_mesh_health_srv_cb { BLE_MESH_MODEL_PUB_DEFINE(_name, NULL, (1 + 3 + (_max_faults))) struct bt_mesh_health_test { - u8_t id_count; /* Number of Health self-test ID */ - const u8_t *test_ids; /* Array of Health self-test IDs */ - u16_t company_id; /* Company ID used to identify the Health Fault state */ - u8_t prev_test_id; /* Most currently performed test id */ - u8_t curr_faults[32]; /* Array of current faults */ - u8_t reg_faults[32]; /* Array of registered faults */ + uint8_t id_count; /* Number of Health self-test ID */ + const uint8_t *test_ids; /* Array of Health self-test IDs */ + uint16_t company_id; /* Company ID used to identify the Health Fault state */ + uint8_t prev_test_id; /* Most currently performed test id */ + uint8_t curr_faults[32]; /* Array of current faults */ + uint8_t reg_faults[32]; /* Array of registered faults */ } __attribute__((packed)); /** Mesh Health Server Model Context */ diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h b/components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h index d02f965787..1c4b743216 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h @@ -58,13 +58,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; @@ -133,32 +133,32 @@ 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: 7; + uint8_t recv_ttl: 7; /** Force sending reliably by using segment acknowledgement */ - u8_t send_rel: 1; + uint8_t send_rel: 1; /** TTL, or BLE_MESH_TTL_DEFAULT for default TTL. */ - u8_t send_ttl; + uint8_t send_ttl; /** Change by Espressif, opcode of a received message. * Not used for sending message. */ - u32_t recv_op; + uint32_t recv_op; /** Change by Espressif, model corresponds to the message */ struct bt_mesh_model *model; @@ -170,7 +170,7 @@ struct bt_mesh_msg_ctx { struct bt_mesh_model_op { /* OpCode encoded using the BLE_MESH_MODEL_OP_* macros */ - const u32_t opcode; + const uint32_t opcode; /* Minimum required message length */ const size_t min_len; @@ -311,7 +311,7 @@ struct bt_mesh_model_op { * * @return Transmission count (actual transmissions is N + 1). */ -#define BLE_MESH_TRANSMIT_COUNT(transmit) (((transmit) & (u8_t)BIT_MASK(3))) +#define BLE_MESH_TRANSMIT_COUNT(transmit) (((transmit) & (uint8_t)BIT_MASK(3))) /** @def BLE_MESH_TRANSMIT_INT * @@ -361,19 +361,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:12, /**< Publish AppKey Index. */ - cred:1, /**< Friendship Credentials Flag. */ - send_rel:1; /**< Force reliable sending (segment acks) */ + uint16_t addr; /**< Publish Address. */ + uint16_t key:12, /**< Publish AppKey Index. */ + cred:1, /**< Friendship Credentials Flag. */ + send_rel:1; /**< Force reliable sending (segment acks) */ - 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. */ - fast_period:1,/**< Use FastPeriodDivisor */ - count:3; /**< Retransmissions left. */ + 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. */ + 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. * @@ -405,7 +405,7 @@ struct bt_mesh_model_pub { struct k_delayed_work timer; /* Change by Espressif, role of the device going to publish messages */ - u8_t dev_role; + uint8_t dev_role; }; /** @def BLE_MESH_MODEL_PUB_DEFINE @@ -458,17 +458,17 @@ 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 model_idx; /* Is the Nth model in the element */ - u16_t flags; /* Information about what has changed */ + uint8_t elem_idx; /* Belongs to Nth element */ + uint8_t model_idx; /* Is the Nth model in the element */ + uint16_t flags; /* Information about what has changed */ /* The Element this Model belongs to */ struct bt_mesh_elem *elem; @@ -477,10 +477,10 @@ struct bt_mesh_model { struct bt_mesh_model_pub *const pub; /* AppKey List */ - u16_t keys[CONFIG_BLE_MESH_MODEL_KEY_COUNT]; + uint16_t keys[CONFIG_BLE_MESH_MODEL_KEY_COUNT]; /* Subscription List (group or virtual addresses) */ - u16_t groups[CONFIG_BLE_MESH_MODEL_GROUP_COUNT]; + uint16_t groups[CONFIG_BLE_MESH_MODEL_GROUP_COUNT]; /** Opcode handler list */ const struct bt_mesh_model_op *const op; @@ -493,11 +493,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 net_buf_simple *msg, u32_t opcode); +void bt_mesh_model_msg_init(struct net_buf_simple *msg, uint32_t opcode); /** Special TTL value to request using configured default TTL */ #define BLE_MESH_TTL_DEFAULT 0xff @@ -555,7 +555,7 @@ struct bt_mesh_elem *bt_mesh_model_elem(struct bt_mesh_model *mod); * @return A pointer to the Mesh model matching the given parameters, or NULL * if no SIG model with the given ID exists in the given element. */ -struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem, u16_t id); +struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem, uint16_t id); /** @brief Find a vendor model. * @@ -567,7 +567,7 @@ struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem, u16_t id); * if no vendor model with the given ID exists in the given element. */ struct bt_mesh_model *bt_mesh_model_find_vnd(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. * @@ -582,9 +582,9 @@ static inline bool bt_mesh_model_in_primary(const 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/components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h b/components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h index 1000290748..cc3d2b7bfc 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h @@ -313,7 +313,7 @@ struct bt_mesh_gatt_char { /** Characteristic UUID. */ const struct bt_mesh_uuid *uuid; /** Characteristic properties. */ - u8_t properties; + uint8_t properties; }; /** @brief GATT Service structure */ @@ -321,19 +321,19 @@ struct bt_mesh_gatt_service { /** Service Attributes */ struct bt_mesh_gatt_attr *attrs; /** Service Attribute count */ - u16_t attr_count; - sys_snode_t node; + uint16_t attr_count; + sys_snode_t node; }; struct bt_mesh_ecb_param { - u8_t key[16]; - u8_t clear_text[16]; - u8_t cipher_text[16]; + uint8_t key[16]; + uint8_t clear_text[16]; + uint8_t cipher_text[16]; } __packed; typedef struct { - u8_t type; - u8_t val[6]; + uint8_t type; + uint8_t val[6]; } bt_mesh_addr_t; /** Description of different data types that can be encoded into @@ -341,9 +341,9 @@ typedef struct { * bt_le_adv_start() function. */ struct bt_mesh_adv_data { - u8_t type; - u8_t data_len; - const u8_t *data; + uint8_t type; + uint8_t data_len; + const uint8_t *data; }; /** @brief Helper to declare elements of bt_data arrays @@ -360,7 +360,7 @@ struct bt_mesh_adv_data { { \ .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 @@ -372,19 +372,19 @@ struct bt_mesh_adv_data { * @param _bytes Variable number of single-byte parameters */ #define BLE_MESH_ADV_DATA_BYTES(_type, _bytes...) \ - BLE_MESH_ADV_DATA(_type, ((u8_t []) { _bytes }), \ - sizeof((u8_t []) { _bytes })) + BLE_MESH_ADV_DATA(_type, ((uint8_t []) { _bytes }), \ + sizeof((uint8_t []) { _bytes })) /* BLE Mesh Advertising Parameters */ struct bt_mesh_adv_param { /** Bit-field of advertising options */ - u8_t options; + uint8_t options; /** Minimum Advertising Interval (N * 0.625) */ - u16_t interval_min; + uint16_t interval_min; /** Maximum Advertising Interval (N * 0.625) */ - u16_t interval_max; + uint16_t interval_max; }; #if CONFIG_BLE_MESH_SUPPORT_BLE_ADV @@ -394,47 +394,47 @@ enum bt_mesh_ble_adv_priority { }; struct bt_mesh_ble_adv_param { - u16_t interval; /* Advertising interval */ - u8_t adv_type; /* Advertising type */ - u8_t own_addr_type; /* Own address type */ - u8_t peer_addr_type; /* Peer address type */ - u8_t peer_addr[6]; /* Peer address */ - u16_t duration; /* Duration is milliseconds */ - u16_t period; /* Period in milliseconds */ - u16_t count; /* Number of advertising duration */ - u8_t priority:2; /* Priority of BLE advertising packet */ + uint16_t interval; /* Advertising interval */ + uint8_t adv_type; /* Advertising type */ + uint8_t own_addr_type; /* Own address type */ + uint8_t peer_addr_type; /* Peer address type */ + uint8_t peer_addr[6]; /* Peer address */ + uint16_t duration; /* Duration is milliseconds */ + uint16_t period; /* Period in milliseconds */ + uint16_t count; /* Number of advertising duration */ + uint8_t priority:2; /* Priority of BLE advertising packet */ }; struct bt_mesh_ble_adv_data { - u8_t adv_data_len; /* Advertising data length */ - u8_t adv_data[31]; /* Advertising data */ - u8_t scan_rsp_data_len; /* Scan response data length */ - u8_t scan_rsp_data[31]; /* Scan response data */ + uint8_t adv_data_len; /* Advertising data length */ + uint8_t adv_data[31]; /* Advertising data */ + uint8_t scan_rsp_data_len; /* Scan response data length */ + uint8_t scan_rsp_data[31]; /* Scan response data */ }; #endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */ /* BLE Mesh scan parameters */ struct bt_mesh_scan_param { /** Scan type (BLE_MESH_SCAN_ACTIVE or BLE_MESH_SCAN_PASSIVE) */ - u8_t type; + uint8_t type; /** Duplicate filtering (BLE_MESH_SCAN_FILTER_DUP_ENABLE or * BLE_MESH_SCAN_FILTER_DUP_DISABLE) */ - u8_t filter_dup; + uint8_t filter_dup; /** Scan interval (N * 0.625 ms) */ - u16_t interval; + uint16_t interval; /** Scan window (N * 0.625 ms) */ - u16_t window; + uint16_t window; /** BLE scan filter policy */ - u8_t scan_fil_policy; + uint8_t scan_fil_policy; }; struct bt_mesh_conn { - u16_t handle; + uint16_t handle; bt_mesh_atomic_t ref; }; @@ -449,8 +449,8 @@ struct bt_mesh_conn { * @param adv_type Type of advertising response from advertiser. * @param data Buffer containing advertiser data. */ -typedef void bt_mesh_scan_cb_t(const bt_mesh_addr_t *addr, s8_t rssi, - u8_t adv_type, struct net_buf_simple *buf); +typedef void bt_mesh_scan_cb_t(const bt_mesh_addr_t *addr, int8_t rssi, + uint8_t adv_type, struct net_buf_simple *buf); /* @typedef bt_mesh_dh_key_cb_t * @brief Callback type for DH Key calculation. @@ -462,7 +462,7 @@ typedef void bt_mesh_scan_cb_t(const bt_mesh_addr_t *addr, s8_t rssi, * * @return The DH Key, or NULL in case of failure. */ -typedef void (*bt_mesh_dh_key_cb_t)(const u8_t key[32], const u8_t idx); +typedef void (*bt_mesh_dh_key_cb_t)(const uint8_t key[32], const uint8_t idx); /** @typedef bt_mesh_gatt_attr_func_t * @brief Attribute iterator callback. @@ -473,8 +473,8 @@ typedef void (*bt_mesh_dh_key_cb_t)(const u8_t key[32], const u8_t idx); * @return BLE_MESH_GATT_ITER_CONTINUE if should continue to the next attribute * or BLE_MESH_GATT_ITER_STOP to stop. */ -typedef u8_t (*bt_mesh_gatt_attr_func_t)(const struct bt_mesh_gatt_attr *attr, - void *user_data); +typedef uint8_t (*bt_mesh_gatt_attr_func_t)(const struct bt_mesh_gatt_attr *attr, + void *user_data); /** @brief Connection callback structure. * @@ -496,7 +496,7 @@ struct bt_mesh_conn_cb { * @param conn New connection object. * @param err HCI error. Zero for success, non-zero otherwise. */ - void (*connected)(struct bt_mesh_conn *conn, u8_t err); + void (*connected)(struct bt_mesh_conn *conn, uint8_t err); /** @brief A connection has been disconnected. * @@ -506,21 +506,21 @@ struct bt_mesh_conn_cb { * @param conn Connection object. * @param reason HCI reason for the disconnection. */ - void (*disconnected)(struct bt_mesh_conn *conn, u8_t reason); + void (*disconnected)(struct bt_mesh_conn *conn, uint8_t reason); }; struct bt_mesh_prov_conn_cb { void (*connected)(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn, int id); - void (*disconnected)(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn, u8_t reason); + void (*disconnected)(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn, uint8_t reason); ssize_t (*prov_write_descr)(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn); - ssize_t (*prov_notify)(struct bt_mesh_conn *conn, u8_t *data, u16_t len); + ssize_t (*prov_notify)(struct bt_mesh_conn *conn, uint8_t *data, uint16_t len); ssize_t (*proxy_write_descr)(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn); - ssize_t (*proxy_notify)(struct bt_mesh_conn *conn, u8_t *data, u16_t len); + ssize_t (*proxy_notify)(struct bt_mesh_conn *conn, uint8_t *data, uint16_t len); }; /** @brief GATT Attribute structure. */ @@ -541,8 +541,8 @@ struct bt_mesh_gatt_attr { */ ssize_t (*read)(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - void *buf, u16_t len, - u16_t offset); + void *buf, uint16_t len, + uint16_t offset); /** Attribute write callback * @@ -558,15 +558,15 @@ struct bt_mesh_gatt_attr { */ ssize_t (*write)(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - const void *buf, u16_t len, - u16_t offset, u8_t flags); + const void *buf, uint16_t len, + uint16_t offset, uint8_t flags); /** Attribute user data */ void *user_data; /** Attribute handle */ - u16_t handle; + uint16_t handle; /** Attribute permissions */ - u8_t perm; + uint8_t perm; }; /** @def BLE_MESH_GATT_PRIMARY_SERVICE @@ -688,12 +688,12 @@ typedef enum { struct bt_mesh_white_list { bool add_remove; - u8_t remote_bda[BLE_MESH_ADDR_LEN]; - u8_t addr_type; + uint8_t remote_bda[BLE_MESH_ADDR_LEN]; + uint8_t addr_type; /* For Bluedroid host, this callback is used to notify the * result of updating white list. */ - void (*update_wl_comp_cb)(u8_t status, bt_mesh_wl_operation wl_operation); + void (*update_wl_comp_cb)(uint8_t status, bt_mesh_wl_operation wl_operation); }; int bt_le_update_white_list(struct bt_mesh_white_list *wl); @@ -701,7 +701,7 @@ int bt_le_update_white_list(struct bt_mesh_white_list *wl); void bt_mesh_gatts_conn_cb_register(struct bt_mesh_conn_cb *cb); void bt_mesh_gatts_conn_cb_deregister(void); -int bt_mesh_gatts_disconnect(struct bt_mesh_conn *conn, u8_t reason); +int bt_mesh_gatts_disconnect(struct bt_mesh_conn *conn, uint8_t reason); int bt_mesh_gatts_service_register(struct bt_mesh_gatt_service *svc); int bt_mesh_gatts_service_deregister(struct bt_mesh_gatt_service *svc); @@ -710,26 +710,26 @@ int bt_mesh_gatts_service_unregister(struct bt_mesh_gatt_service *svc); ssize_t bt_mesh_gatts_attr_read_included(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - void *buf, u16_t len, u16_t offset); + void *buf, uint16_t len, uint16_t offset); ssize_t bt_mesh_gatts_attr_read(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - void *buf, u16_t buf_len, u16_t offset, - const void *value, u16_t value_len); + void *buf, uint16_t buf_len, uint16_t offset, + const void *value, uint16_t value_len); ssize_t bt_mesh_gatts_attr_read_service(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - void *buf, u16_t len, u16_t offset); + void *buf, uint16_t len, uint16_t offset); ssize_t bt_mesh_gatts_attr_read_chrc(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - void *buf, u16_t len, u16_t offset); + void *buf, uint16_t len, uint16_t offset); int bt_mesh_gatts_notify(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - const void *data, u16_t len); + const void *data, uint16_t len); -u16_t bt_mesh_gatt_get_mtu(struct bt_mesh_conn *conn); +uint16_t bt_mesh_gatt_get_mtu(struct bt_mesh_conn *conn); /** APIs added by Espressif */ int bt_mesh_gatts_service_stop(struct bt_mesh_gatt_service *svc); @@ -740,21 +740,21 @@ int bt_mesh_gatts_set_local_device_name(const char *name); void bt_mesh_gattc_conn_cb_register(struct bt_mesh_prov_conn_cb *cb); void bt_mesh_gattc_conn_cb_deregister(void); -u8_t bt_mesh_gattc_get_free_conn_count(void); +uint8_t bt_mesh_gattc_get_free_conn_count(void); -u16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn); +uint16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn); -int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid); +int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, uint16_t service_uuid); void bt_gattc_conn_close(struct bt_mesh_conn *conn); -void bt_mesh_gattc_exchange_mtu(u8_t index); +void bt_mesh_gattc_exchange_mtu(uint8_t index); -u16_t bt_mesh_gattc_get_mtu_info(struct bt_mesh_conn *conn); +uint16_t bt_mesh_gattc_get_mtu_info(struct bt_mesh_conn *conn); int bt_mesh_gattc_write_no_rsp(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - const void *data, u16_t len); + const void *data, uint16_t len); void bt_mesh_gattc_disconnect(struct bt_mesh_conn *conn); @@ -767,21 +767,19 @@ void bt_mesh_gatt_deinit(void); void bt_mesh_adapt_init(void); -int bt_mesh_rand(void *buf, size_t len); +void bt_mesh_set_private_key(const uint8_t pri_key[32]); -void bt_mesh_set_private_key(const u8_t pri_key[32]); - -const u8_t *bt_mesh_pub_key_get(void); +const uint8_t *bt_mesh_pub_key_get(void); bool bt_mesh_check_public_key(const uint8_t key[64]); -int bt_mesh_dh_key_gen(const u8_t remote_pk[64], bt_mesh_dh_key_cb_t cb, const u8_t idx); +int bt_mesh_dh_key_gen(const uint8_t remote_pk[64], bt_mesh_dh_key_cb_t cb, const uint8_t idx); -int bt_mesh_encrypt_le(const u8_t key[16], const u8_t plaintext[16], - u8_t enc_data[16]); +int bt_mesh_encrypt_le(const uint8_t key[16], const uint8_t plaintext[16], + uint8_t enc_data[16]); -int bt_mesh_encrypt_be(const u8_t key[16], const u8_t plaintext[16], - u8_t enc_data[16]); +int bt_mesh_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16], + uint8_t enc_data[16]); enum { BLE_MESH_EXCEP_LIST_ADD = 0, @@ -806,7 +804,7 @@ enum { BLE_MESH_EXCEP_CLEAN_ALL_LIST = 0xFFFF, }; -int bt_mesh_update_exceptional_list(u8_t sub_code, u8_t type, void *info); +int bt_mesh_update_exceptional_list(uint8_t sub_code, uint8_t type, void *info); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_hci.h b/components/bt/esp_ble_mesh/mesh_core/include/mesh_hci.h index 75ff8ccf3a..82a41a251b 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/mesh_hci.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/mesh_hci.h @@ -43,10 +43,10 @@ enum { struct bt_mesh_dev_le { /* LE features */ - u8_t features[8]; + uint8_t features[8]; /* LE states */ - u64_t states; + uint64_t states; }; /* State tracking for the local Bluetooth controller */ @@ -55,14 +55,14 @@ struct bt_mesh_dev { BLE_MESH_ATOMIC_DEFINE(flags, BLE_MESH_DEV_NUM_FLAGS); /* Controller version & manufacturer information */ - u8_t hci_version; - u8_t lmp_version; - u16_t hci_revision; - u16_t lmp_subversion; - u16_t manufacturer; + uint8_t hci_version; + uint8_t lmp_version; + uint16_t hci_revision; + uint16_t lmp_subversion; + uint16_t manufacturer; /* LMP features (pages 0, 1, 2) */ - u8_t features[BLE_MESH_LMP_FEAT_PAGES_COUNT][8]; + uint8_t features[BLE_MESH_LMP_FEAT_PAGES_COUNT][8]; /* LE controller specific features */ struct bt_mesh_dev_le le; @@ -100,25 +100,25 @@ struct bt_mesh_dev { #define BLE_MESH_HCI_OP_SET_ADV_PARAM BLE_MESH_OP(BLE_MESH_OGF_LE, 0x0006) struct bt_mesh_hci_cp_set_adv_param { - u16_t min_interval; - u16_t max_interval; - u8_t type; - u8_t own_addr_type; + uint16_t min_interval; + uint16_t max_interval; + uint8_t type; + uint8_t own_addr_type; bt_mesh_addr_t direct_addr; - u8_t channel_map; - u8_t filter_policy; + uint8_t channel_map; + uint8_t filter_policy; } __packed; #define BLE_MESH_HCI_OP_SET_ADV_DATA BLE_MESH_OP(BLE_MESH_OGF_LE, 0x0008) struct bt_mesh_hci_cp_set_adv_data { - u8_t len; - u8_t data[31]; + uint8_t len; + uint8_t data[31]; } __packed; #define BLE_MESH_HCI_OP_SET_SCAN_RSP_DATA BLE_MESH_OP(BLE_MESH_OGF_LE, 0x0009) struct bt_mesh_hci_cp_set_scan_rsp_data { - u8_t len; - u8_t data[31]; + uint8_t len; + uint8_t data[31]; } __packed; /* Added by Espressif */ diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_main.h b/components/bt/esp_ble_mesh/mesh_core/include/mesh_main.h index c18ce91553..e0c8a44e96 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/mesh_main.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/mesh_main.h @@ -70,7 +70,7 @@ typedef enum { struct bt_mesh_prov { #if CONFIG_BLE_MESH_NODE /** 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 @@ -93,19 +93,19 @@ struct bt_mesh_prov { void (*oob_pub_key_cb)(void); /** 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. * @@ -117,7 +117,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. * @@ -144,7 +144,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 Provisioning link has been opened. * @@ -176,7 +176,7 @@ struct bt_mesh_prov { * @param flags Key Refresh & IV Update flags * @param iv_index IV Index. */ - void (*complete)(u16_t net_idx, const u8_t net_key[16], u16_t addr, u8_t flags, u32_t iv_index); + void (*complete)(uint16_t net_idx, const uint8_t net_key[16], uint16_t addr, uint8_t flags, uint32_t iv_index); /** @brief Node has been reset. * @@ -191,28 +191,28 @@ struct bt_mesh_prov { #if CONFIG_BLE_MESH_PROVISIONER /* Provisioner device uuid */ - const u8_t *prov_uuid; + const uint8_t *prov_uuid; /* * Primary element address of the provisioner. * No need to initialize it for fast provisioning. */ - const u16_t prov_unicast_addr; + const uint16_t prov_unicast_addr; /* * Starting unicast address going to assigned. * No need to initialize it for fast provisioning. */ - u16_t prov_start_address; + uint16_t prov_start_address; /* Attention timer contained in Provisioning Invite */ - u8_t prov_attention; + uint8_t prov_attention; /* Provisioner provisioning Algorithm */ - u8_t prov_algorithm; + uint8_t prov_algorithm; /* Provisioner public key oob */ - u8_t prov_pub_key_oob; + uint8_t prov_pub_key_oob; /** @brief Input is requested. * @@ -223,13 +223,13 @@ struct bt_mesh_prov { * * @return Zero on success or negative error code otherwise */ - int (*prov_pub_key_oob_cb)(u8_t link_idx); + int (*prov_pub_key_oob_cb)(uint8_t link_idx); /* Provisioner static oob value */ - u8_t *prov_static_oob_val; + uint8_t *prov_static_oob_val; /* Provisioner static oob value length */ - u8_t prov_static_oob_len; + uint8_t prov_static_oob_len; /** @brief Provisioner input a number read from device output * @@ -243,7 +243,7 @@ struct bt_mesh_prov { * * @return Zero on success or negative error code otherwise */ - int (*prov_input_num)(u8_t method, bt_mesh_output_action_t act, u8_t size, u8_t link_idx); + int (*prov_input_num)(uint8_t method, bt_mesh_output_action_t act, uint8_t size, uint8_t link_idx); /** @brief Provisioner output a number to the device * @@ -258,18 +258,18 @@ struct bt_mesh_prov { * * @return Zero on success or negative error code otherwise */ - int (*prov_output_num)(u8_t method, bt_mesh_input_action_t act, void *data, u8_t size, u8_t link_idx); + int (*prov_output_num)(uint8_t method, bt_mesh_input_action_t act, void *data, uint8_t size, uint8_t link_idx); /* * Key refresh and IV update flag. * No need to initialize it for fast provisioning. */ - u8_t flags; + uint8_t flags; /* * IV index. No need to initialize it for fast provisioning. */ - u32_t iv_index; + uint32_t iv_index; /** @brief Provisioner has opened a provisioning link. * @@ -288,7 +288,7 @@ struct bt_mesh_prov { * @param bearer Provisioning bearer. * @param reason Provisioning link close reason(disconnect reason) */ - void (*prov_link_close)(bt_mesh_prov_bearer_t bearer, u8_t reason); + void (*prov_link_close)(bt_mesh_prov_bearer_t bearer, uint8_t reason); /** @brief Provision one device is complete. * @@ -302,9 +302,9 @@ struct bt_mesh_prov { * @param element_num Provisioned device element number. * @param netkey_idx Provisioned device assigned netkey index. */ - void (*prov_complete)(u16_t node_idx, const u8_t device_uuid[16], - u16_t unicast_addr, u8_t element_num, - u16_t netkey_idx); + void (*prov_complete)(uint16_t node_idx, const uint8_t device_uuid[16], + uint16_t unicast_addr, uint8_t element_num, + uint16_t netkey_idx); #endif /* CONFIG_BLE_MESH_PROVISIONER */ }; @@ -337,7 +337,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 * @@ -381,7 +381,7 @@ int bt_mesh_prov_input_string(const char *str); * * @return Zero on success or (negative) error code otherwise. */ -int bt_mesh_prov_input_number(u32_t num); +int bt_mesh_prov_input_number(uint32_t num); /** @brief Enable specific provisioning bearers * @@ -527,9 +527,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 Check if the device is an unprovisioned device * and will act as a node once provisioned. @@ -613,7 +613,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)); /** @brief Register a callback for Friendship changes of friend node. * @@ -622,7 +622,7 @@ void bt_mesh_lpn_set_cb(void (*cb)(u16_t friend_addr, bool established)); * * @param cb Function to call when the Friendship status of friend node changes. */ -void bt_mesh_friend_set_cb(void (*cb)(bool establish, u16_t lpn_addr, u8_t reason)); +void bt_mesh_friend_set_cb(void (*cb)(bool establish, uint16_t lpn_addr, uint8_t reason)); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_uuid.h b/components/bt/esp_ble_mesh/mesh_core/include/mesh_uuid.h index de03df5c32..82ef7b176a 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/mesh_uuid.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/mesh_uuid.h @@ -32,22 +32,22 @@ enum { /** @brief This is a 'tentative' type and should be used as a pointer only */ struct bt_mesh_uuid { - u8_t type; + uint8_t type; }; struct bt_mesh_uuid_16 { struct bt_mesh_uuid uuid; - u16_t val; + uint16_t val; }; struct bt_mesh_uuid_32 { struct bt_mesh_uuid uuid; - u32_t val; + uint32_t val; }; struct bt_mesh_uuid_128 { struct bt_mesh_uuid uuid; - u8_t val[16]; + uint8_t val[16]; }; #define BLE_MESH_UUID_INIT_16(value) \ diff --git a/components/bt/esp_ble_mesh/mesh_core/local_operation.c b/components/bt/esp_ble_mesh/mesh_core/local_operation.c index 6a78989af5..38583cc60a 100644 --- a/components/bt/esp_ble_mesh/mesh_core/local_operation.c +++ b/components/bt/esp_ble_mesh/mesh_core/local_operation.c @@ -18,7 +18,7 @@ #include "mesh_main.h" #include "settings.h" -static struct bt_mesh_model *find_model(u16_t elem_addr, u16_t cid, u16_t mod_id) +static struct bt_mesh_model *find_model(uint16_t elem_addr, uint16_t cid, uint16_t mod_id) { struct bt_mesh_elem *elem = NULL; @@ -40,8 +40,8 @@ static struct bt_mesh_model *find_model(u16_t elem_addr, u16_t cid, u16_t mod_id } } -int bt_mesh_model_subscribe_group_addr(u16_t elem_addr, u16_t cid, - u16_t mod_id, u16_t group_addr) +int bt_mesh_model_subscribe_group_addr(uint16_t elem_addr, uint16_t cid, + uint16_t mod_id, uint16_t group_addr) { struct bt_mesh_model *model = NULL; int i; @@ -83,11 +83,11 @@ int bt_mesh_model_subscribe_group_addr(u16_t elem_addr, u16_t cid, return -ENOMEM; } -int bt_mesh_model_unsubscribe_group_addr(u16_t elem_addr, u16_t cid, - u16_t mod_id, u16_t group_addr) +int bt_mesh_model_unsubscribe_group_addr(uint16_t elem_addr, uint16_t cid, + uint16_t mod_id, uint16_t group_addr) { struct bt_mesh_model *model = NULL; - u16_t *match = NULL; + uint16_t *match = NULL; model = find_model(elem_addr, cid, mod_id); if (model == NULL) { @@ -122,7 +122,7 @@ int bt_mesh_model_unsubscribe_group_addr(u16_t elem_addr, u16_t cid, #if CONFIG_BLE_MESH_NODE -const u8_t *bt_mesh_node_get_local_net_key(u16_t net_idx) +const uint8_t *bt_mesh_node_get_local_net_key(uint16_t net_idx) { struct bt_mesh_subnet *sub = NULL; @@ -140,7 +140,7 @@ const u8_t *bt_mesh_node_get_local_net_key(u16_t net_idx) return sub->kr_flag ? sub->keys[1].net : sub->keys[0].net; } -const u8_t *bt_mesh_node_get_local_app_key(u16_t app_idx) +const uint8_t *bt_mesh_node_get_local_app_key(uint16_t app_idx) { struct bt_mesh_app_key *key = NULL; @@ -158,7 +158,7 @@ const u8_t *bt_mesh_node_get_local_app_key(u16_t app_idx) return key->updated ? key->keys[1].val : key->keys[0].val; } -int bt_mesh_node_local_net_key_add(u16_t net_idx, const u8_t net_key[16]) +int bt_mesh_node_local_net_key_add(uint16_t net_idx, const uint8_t net_key[16]) { struct bt_mesh_subnet *sub = NULL; int err = 0; @@ -230,8 +230,8 @@ int bt_mesh_node_local_net_key_add(u16_t net_idx, const u8_t net_key[16]) return 0; } -int bt_mesh_node_local_app_key_add(u16_t net_idx, u16_t app_idx, - const u8_t app_key[16]) +int bt_mesh_node_local_app_key_add(uint16_t net_idx, uint16_t app_idx, + const uint8_t app_key[16]) { struct bt_mesh_app_key *key = NULL; @@ -295,8 +295,8 @@ int bt_mesh_node_local_app_key_add(u16_t net_idx, u16_t app_idx, return -ENOMEM; } -int bt_mesh_node_bind_app_key_to_model(u16_t elem_addr, u16_t mod_id, - u16_t cid, u16_t app_idx) +int bt_mesh_node_bind_app_key_to_model(uint16_t elem_addr, uint16_t mod_id, + uint16_t cid, uint16_t app_idx) { struct bt_mesh_model *model = NULL; int i; diff --git a/components/bt/esp_ble_mesh/mesh_core/local_operation.h b/components/bt/esp_ble_mesh/mesh_core/local_operation.h index bdfcda385e..f64796555f 100644 --- a/components/bt/esp_ble_mesh/mesh_core/local_operation.h +++ b/components/bt/esp_ble_mesh/mesh_core/local_operation.h @@ -16,23 +16,23 @@ extern "C" { #endif -int bt_mesh_model_subscribe_group_addr(u16_t elem_addr, u16_t mod_id, - u16_t cid, u16_t group_addr); +int bt_mesh_model_subscribe_group_addr(uint16_t elem_addr, uint16_t mod_id, + uint16_t cid, uint16_t group_addr); -int bt_mesh_model_unsubscribe_group_addr(u16_t elem_addr, u16_t cid, - u16_t mod_id, u16_t group_addr); +int bt_mesh_model_unsubscribe_group_addr(uint16_t elem_addr, uint16_t cid, + uint16_t mod_id, uint16_t group_addr); -const u8_t *bt_mesh_node_get_local_net_key(u16_t net_idx); +const uint8_t *bt_mesh_node_get_local_net_key(uint16_t net_idx); -const u8_t *bt_mesh_node_get_local_app_key(u16_t app_idx); +const uint8_t *bt_mesh_node_get_local_app_key(uint16_t app_idx); -int bt_mesh_node_local_net_key_add(u16_t net_idx, const u8_t net_key[16]); +int bt_mesh_node_local_net_key_add(uint16_t net_idx, const uint8_t net_key[16]); -int bt_mesh_node_local_app_key_add(u16_t net_idx, u16_t app_idx, - const u8_t app_key[16]); +int bt_mesh_node_local_app_key_add(uint16_t net_idx, uint16_t app_idx, + const uint8_t app_key[16]); -int bt_mesh_node_bind_app_key_to_model(u16_t elem_addr, u16_t mod_id, - u16_t cid, u16_t app_idx); +int bt_mesh_node_bind_app_key_to_model(uint16_t elem_addr, uint16_t mod_id, + uint16_t cid, uint16_t app_idx); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_core/lpn.c b/components/bt/esp_ble_mesh/mesh_core/lpn.c index 0562c059bb..eedc8922c1 100644 --- a/components/bt/esp_ble_mesh/mesh_core/lpn.c +++ b/components/bt/esp_ble_mesh/mesh_core/lpn.c @@ -9,8 +9,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_LOW_POWER) - #include "crypto.h" #include "adv.h" #include "mesh.h" @@ -31,8 +29,7 @@ #endif #define LPN_RECV_DELAY CONFIG_BLE_MESH_LPN_RECV_DELAY -#define SCAN_LATENCY MIN(CONFIG_BLE_MESH_LPN_SCAN_LATENCY, \ - LPN_RECV_DELAY) +#define SCAN_LATENCY MIN(CONFIG_BLE_MESH_LPN_SCAN_LATENCY, LPN_RECV_DELAY) #define FRIEND_REQ_RETRY_TIMEOUT K_SECONDS(CONFIG_BLE_MESH_LPN_RETRY_TIMEOUT) @@ -42,34 +39,34 @@ #define POLL_RETRY_TIMEOUT K_MSEC(100) -#define REQ_RETRY_DURATION(lpn) (4 * (LPN_RECV_DELAY + (lpn)->adv_duration + \ - (lpn)->recv_win + POLL_RETRY_TIMEOUT)) +#define REQ_RETRY_DURATION(lpn) (4 * (LPN_RECV_DELAY + (lpn)->adv_duration + \ + (lpn)->recv_win + POLL_RETRY_TIMEOUT)) -#define POLL_TIMEOUT_INIT (CONFIG_BLE_MESH_LPN_INIT_POLL_TIMEOUT * 100) -#define POLL_TIMEOUT_MAX(lpn) ((CONFIG_BLE_MESH_LPN_POLL_TIMEOUT * 100) - \ - REQ_RETRY_DURATION(lpn)) +#define POLL_TIMEOUT_INIT (CONFIG_BLE_MESH_LPN_INIT_POLL_TIMEOUT * 100) +#define POLL_TIMEOUT_MAX(lpn) ((CONFIG_BLE_MESH_LPN_POLL_TIMEOUT * 100) - \ + REQ_RETRY_DURATION(lpn)) /** * 1. Should use 20 attempts for BQB test case MESH/NODE/FRND/LPM/BI-02-C. * 2. We should use more specific value for each PollTimeout range. */ -#define REQ_ATTEMPTS(lpn) (POLL_TIMEOUT_MAX(lpn) < K_SECONDS(3) ? 2 : 6) +#define REQ_ATTEMPTS(lpn) (POLL_TIMEOUT_MAX(lpn) < K_SECONDS(3) ? 2 : 6) -#define CLEAR_ATTEMPTS 2 +#define CLEAR_ATTEMPTS 2 -#define LPN_CRITERIA ((CONFIG_BLE_MESH_LPN_MIN_QUEUE_SIZE) | \ - (CONFIG_BLE_MESH_LPN_RSSI_FACTOR << 3) | \ - (CONFIG_BLE_MESH_LPN_RECV_WIN_FACTOR << 5)) +#define LPN_CRITERIA ((CONFIG_BLE_MESH_LPN_MIN_QUEUE_SIZE) | \ + (CONFIG_BLE_MESH_LPN_RSSI_FACTOR << 3) | \ + (CONFIG_BLE_MESH_LPN_RECV_WIN_FACTOR << 5)) -#define POLL_TO(to) { (u8_t)((to) >> 16), (u8_t)((to) >> 8), (u8_t)(to) } -#define LPN_POLL_TO POLL_TO(CONFIG_BLE_MESH_LPN_POLL_TIMEOUT) +#define POLL_TO(to) { (uint8_t)((to) >> 16), (uint8_t)((to) >> 8), (uint8_t)(to) } +#define LPN_POLL_TO POLL_TO(CONFIG_BLE_MESH_LPN_POLL_TIMEOUT) /* 2 transmissions, 20ms interval */ -#define POLL_XMIT BLE_MESH_TRANSMIT(1, 20) +#define POLL_XMIT BLE_MESH_TRANSMIT(1, 20) -#define FIRST_POLL_ATTEMPTS 6 +#define FIRST_POLL_ATTEMPTS 6 -static void (*lpn_cb)(u16_t friend_addr, bool established); +static void (*lpn_cb)(uint16_t friend_addr, bool established); #if !CONFIG_BLE_MESH_NO_LOG static const char *state2str(int state) @@ -272,7 +269,7 @@ static void clear_friendship(bool force, bool disable) } } -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; @@ -331,7 +328,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; @@ -389,7 +386,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 = 0; BT_DBG("lpn->sent_req 0x%02x", lpn->sent_req); @@ -510,7 +507,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 = NULL; - u16_t frnd_counter = 0U; + uint16_t frnd_counter = 0U; int err = 0; if (buf->len < sizeof(*msg)) { @@ -572,7 +569,7 @@ int bt_mesh_lpn_friend_clear_cfm(struct bt_mesh_net_rx *rx, { struct bt_mesh_ctl_friend_clear_confirm *msg = (void *)buf->data; struct bt_mesh_lpn *lpn = &bt_mesh.lpn; - u16_t addr = 0U, counter = 0U; + uint16_t addr = 0U, counter = 0U; if (buf->len < sizeof(*msg)) { BT_WARN("Too short Friend Clear Confirm"); @@ -600,10 +597,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++) { @@ -626,7 +623,7 @@ static void lpn_group_add(u16_t group) lpn->groups_changed = 1U; } -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; @@ -657,7 +654,7 @@ static inline int group_popcount(bt_mesh_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); @@ -805,7 +802,7 @@ static void lpn_timeout(struct k_work *work) break; case BLE_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 = 0U; @@ -839,7 +836,7 @@ static void lpn_timeout(struct k_work *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); @@ -852,7 +849,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; @@ -870,7 +867,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()) { @@ -959,7 +956,7 @@ int bt_mesh_lpn_friend_update(struct bt_mesh_net_rx *rx, struct bt_mesh_ctl_friend_update *msg = (void *)buf->data; struct bt_mesh_lpn *lpn = &bt_mesh.lpn; struct bt_mesh_subnet *sub = rx->sub; - u32_t iv_index = 0U; + uint32_t iv_index = 0U; if (buf->len < sizeof(*msg)) { BT_WARN("Too short Friend Update"); @@ -1058,7 +1055,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/components/bt/esp_ble_mesh/mesh_core/lpn.h b/components/bt/esp_ble_mesh/mesh_core/lpn.h index 97ba929559..dd4955e4ab 100644 --- a/components/bt/esp_ble_mesh/mesh_core/lpn.h +++ b/components/bt/esp_ble_mesh/mesh_core/lpn.h @@ -33,7 +33,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 defined(CONFIG_BLE_MESH_LOW_POWER) if (bt_mesh_lpn_established()) { @@ -63,8 +63,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/components/bt/esp_ble_mesh/mesh_core/main.c b/components/bt/esp_ble_mesh/mesh_core/main.c index f2bbd63714..ab279119fa 100644 --- a/components/bt/esp_ble_mesh/mesh_core/main.c +++ b/components/bt/esp_ble_mesh/mesh_core/main.c @@ -10,8 +10,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG) - #include "adv.h" #include "prov.h" #include "beacon.h" @@ -36,9 +34,9 @@ bool bt_mesh_is_initialized(void) return mesh_init; } -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 = false; int err = 0; @@ -202,7 +200,7 @@ int bt_mesh_prov_enable(bt_mesh_prov_bearer_t bearers) * the device as a node, which will cause the information * in NVS been handled incorrectly. */ - u8_t role = bt_mesh_atomic_get(bt_mesh.flags) & BLE_MESH_SETTINGS_ROLE_BIT_MASK; + uint8_t role = bt_mesh_atomic_get(bt_mesh.flags) & BLE_MESH_SETTINGS_ROLE_BIT_MASK; if (role != BLE_MESH_SETTINGS_ROLE_NONE && role != BLE_MESH_SETTINGS_ROLE_NODE) { BT_ERR("%s, Mismatch role %u", __func__, role); @@ -310,7 +308,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); @@ -405,8 +403,8 @@ int bt_mesh_init(const struct bt_mesh_prov *prov, /* Changed by Espressif, add a random delay (0 ~ 3s) */ if (IS_ENABLED(CONFIG_BLE_MESH_FAST_PROV)) { - u32_t delay = 0; - bt_mesh_rand(&delay, sizeof(u32_t)); + uint32_t delay = 0; + bt_mesh_rand(&delay, sizeof(uint32_t)); vTaskDelay((delay % 3000) / portTICK_PERIOD_MS); } @@ -564,7 +562,7 @@ int bt_mesh_provisioner_enable(bt_mesh_prov_bearer_t bearers) * device as a Provisioner, which will cause the information * in NVS been handled incorrectly. */ - u8_t role = bt_mesh_atomic_get(bt_mesh.flags) & BLE_MESH_SETTINGS_ROLE_BIT_MASK; + uint8_t role = bt_mesh_atomic_get(bt_mesh.flags) & BLE_MESH_SETTINGS_ROLE_BIT_MASK; if (role != BLE_MESH_SETTINGS_ROLE_NONE && role != BLE_MESH_SETTINGS_ROLE_PROV) { BT_ERR("%s, Mismatch role %u", __func__, role); diff --git a/components/bt/esp_ble_mesh/mesh_core/net.c b/components/bt/esp_ble_mesh/mesh_core/net.c index 891ca5e2c1..74e260c41d 100644 --- a/components/bt/esp_ble_mesh/mesh_core/net.c +++ b/components/bt/esp_ble_mesh/mesh_core/net.c @@ -11,8 +11,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_NET) - #include "crypto.h" #include "adv.h" #include "mesh.h" @@ -61,10 +59,10 @@ static struct friend_cred friend_cred[FRIEND_CRED_COUNT]; #endif static struct { - u32_t src:15, /* MSB of source address is always 0 */ - seq:17; + uint32_t src:15, /* MSB of source address is always 0 */ + seq:17; } msg_cache[CONFIG_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 = { @@ -81,8 +79,8 @@ struct bt_mesh_net bt_mesh = { }, }; -static u32_t dup_cache[4]; -static int dup_cache_next; +static uint32_t dup_cache[4]; +static int dup_cache_next; #if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) #define BLE_MESH_MAX_STORED_RELAY_COUNT (CONFIG_BLE_MESH_RELAY_ADV_BUF_COUNT / 2) @@ -90,8 +88,8 @@ static int dup_cache_next; static bool check_dup(struct net_buf_simple *data) { - const u8_t *tail = net_buf_simple_tail(data); - u32_t val = 0U; + const uint8_t *tail = net_buf_simple_tail(data); + uint32_t val = 0U; int i; val = sys_get_be32(tail - 4) ^ sys_get_be32(tail - 8); @@ -132,7 +130,7 @@ static void msg_cache_add(struct bt_mesh_net_rx *rx) } #if CONFIG_BLE_MESH_PROVISIONER -void bt_mesh_msg_cache_clear(u16_t unicast_addr, u8_t elem_num) +void bt_mesh_msg_cache_clear(uint16_t unicast_addr, uint8_t elem_num) { int i; @@ -145,7 +143,7 @@ void bt_mesh_msg_cache_clear(u16_t unicast_addr, u8_t elem_num) } #endif /* CONFIG_BLE_MESH_PROVISIONER */ -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; @@ -163,10 +161,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 = 0U; + uint8_t p[] = { 0 }; + uint8_t nid = 0U; int err = 0; err = bt_mesh_k2(key, p, sizeof(p), &nid, keys->enc, keys->privacy); @@ -213,11 +211,11 @@ int bt_mesh_net_keys_create(struct bt_mesh_subnet_keys *keys, #if (defined(CONFIG_BLE_MESH_LOW_POWER) || \ defined(CONFIG_BLE_MESH_FRIEND)) -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 = 0U, frnd_addr = 0U; + uint16_t lpn_addr = 0U, frnd_addr = 0U; + uint8_t p[9] = {0}; int err = 0; - u8_t p[9] = {0}; #if defined(CONFIG_BLE_MESH_LOW_POWER) if (cred->addr == bt_mesh.lpn.frnd) { @@ -256,7 +254,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; @@ -294,8 +292,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 = NULL; int i, err = 0; @@ -347,7 +345,7 @@ void friend_cred_clear(struct friend_cred *cred) (void)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; @@ -363,8 +361,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; @@ -399,16 +397,16 @@ int friend_cred_get(struct bt_mesh_subnet *sub, u16_t addr, u8_t *nid, return -ENOENT; } #else -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) { return -ENOENT; } #endif /* FRIEND || LOW_POWER */ -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 |= BLE_MESH_NET_FLAG_KR; @@ -423,7 +421,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 = NULL; if (sub->kr_flag) { @@ -440,8 +438,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 = NULL; int err = 0; @@ -524,7 +522,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 == BLE_MESH_KR_NORMAL) { BT_WARN("KR change in normal operation. Are we blacklisted?"); @@ -641,7 +639,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; @@ -757,9 +755,9 @@ bool bt_mesh_primary_subnet_exist(void) return false; } -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_BLE_MESH_SETTINGS)) { bt_mesh_store_seq(); @@ -780,9 +778,9 @@ int bt_mesh_net_resend(struct bt_mesh_subnet *sub, struct net_buf *buf, bool new_key, const struct bt_mesh_send_cb *cb, void *cb_data) { - const u8_t *enc = NULL, *priv = NULL; - u32_t seq = 0U; - u16_t dst = 0U; + const uint8_t *enc = NULL, *priv = NULL; + uint32_t seq = 0U; + uint16_t dst = 0U; int err = 0; BT_DBG("net_idx 0x%04x new_key %u len %u", sub->net_idx, new_key, @@ -848,8 +846,8 @@ int bt_mesh_net_encode(struct bt_mesh_net_tx *tx, struct net_buf_simple *buf, bool proxy) { const bool ctl = (tx->ctx->app_idx == BLE_MESH_KEY_UNUSED); - const u8_t *enc = NULL, *priv = NULL; - u8_t nid = 0U; + const uint8_t *enc = NULL, *priv = NULL; + uint8_t nid = 0U; int err = 0; if (ctl && net_buf_simple_tailroom(buf) < BLE_MESH_MIC_LONG) { @@ -982,10 +980,10 @@ done: } 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] = {0}; + uint8_t net_auth[8] = {0}; if (memcmp(net_id, keys->net_id, 8)) { return false; @@ -1003,8 +1001,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) { size_t subnet_size = 0U; @@ -1037,8 +1035,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 net_buf_simple *buf) { @@ -1078,7 +1076,7 @@ static int net_decrypt(struct bt_mesh_subnet *sub, const u8_t *enc, #if (defined(CONFIG_BLE_MESH_LOW_POWER) || \ defined(CONFIG_BLE_MESH_FRIEND)) -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 net_buf_simple *buf) { @@ -1115,7 +1113,7 @@ static int friend_decrypt(struct bt_mesh_subnet *sub, const u8_t *data, } #endif -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 net_buf_simple *buf) { @@ -1194,9 +1192,9 @@ static bool relay_to_adv(enum bt_mesh_net_if net_if) static void bt_mesh_net_relay(struct net_buf_simple *sbuf, struct bt_mesh_net_rx *rx) { - const u8_t *enc = NULL, *priv = NULL; + const uint8_t *enc = NULL, *priv = NULL; struct net_buf *buf = NULL; - u8_t nid = 0U, transmit = 0U; + uint8_t nid = 0U, transmit = 0U; if (rx->net_if == BLE_MESH_NET_IF_LOCAL) { /* Locally originated PDUs with TTL=1 will only be delivered @@ -1405,7 +1403,7 @@ static bool ready_to_recv(void) return false; } -static bool ignore_net_msg(u16_t src, u16_t dst) +static bool ignore_net_msg(uint16_t src, uint16_t dst) { if (IS_ENABLED(CONFIG_BLE_MESH_FAST_PROV)) { /* When fast provisioning is enabled, the node addr @@ -1432,7 +1430,7 @@ static bool ignore_net_msg(u16_t src, u16_t dst) return false; } -void bt_mesh_net_recv(struct net_buf_simple *data, s8_t rssi, +void bt_mesh_net_recv(struct net_buf_simple *data, int8_t rssi, enum bt_mesh_net_if net_if) { NET_BUF_SIMPLE_DEFINE(buf, 29); @@ -1552,11 +1550,11 @@ void bt_mesh_net_start(void) } if (IS_ENABLED(CONFIG_BLE_MESH_PROV)) { - u16_t net_idx = bt_mesh.sub[0].net_idx; - u16_t addr = bt_mesh_primary_addr(); - u32_t iv_index = bt_mesh.iv_index; - u8_t flags = (u8_t)bt_mesh.sub[0].kr_flag; - const u8_t *net_key = bt_mesh.sub[0].keys[flags].net; + uint16_t net_idx = bt_mesh.sub[0].net_idx; + uint16_t addr = bt_mesh_primary_addr(); + uint32_t iv_index = bt_mesh.iv_index; + uint8_t flags = (uint8_t)bt_mesh.sub[0].kr_flag; + const uint8_t *net_key = bt_mesh.sub[0].keys[flags].net; if (bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_IVU_IN_PROGRESS)) { flags |= BLE_MESH_NET_FLAG_IVU; } diff --git a/components/bt/esp_ble_mesh/mesh_core/net.h b/components/bt/esp_ble_mesh/mesh_core/net.h index 4521401a5c..3c5c4f0fd1 100644 --- a/components/bt/esp_ble_mesh/mesh_core/net.h +++ b/components/bt/esp_ble_mesh/mesh_core/net.h @@ -29,89 +29,84 @@ extern "C" { /* How many hours in between updating IVU duration */ #define BLE_MESH_IVU_MIN_HOURS 96 -#define BLE_MESH_IVU_HOURS (BLE_MESH_IVU_MIN_HOURS / \ - CONFIG_BLE_MESH_IVU_DIVIDER) +#define BLE_MESH_IVU_HOURS (BLE_MESH_IVU_MIN_HOURS / CONFIG_BLE_MESH_IVU_DIVIDER) #define BLE_MESH_IVU_TIMEOUT K_HOURS(BLE_MESH_IVU_HOURS) struct bt_mesh_app_key { - u16_t net_idx; - u16_t app_idx; - bool updated; + 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_subnet { - u32_t beacon_sent; /* Timestamp of last sent beacon */ - u8_t beacons_last; /* Number of beacons during last - * observation window - */ - u8_t beacons_cur; /* Number of beacons observed during - * currently ongoing window. - */ + uint32_t beacon_sent; /* Timestamp of last sent beacon */ + uint8_t beacons_last; /* Number of beacons during last observation window. */ + uint8_t beacons_cur; /* Number of beacons 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 */ + bool kr_flag; /* Key Refresh Flag */ + 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 defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER) - 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]; }; struct bt_mesh_rpl { - u16_t src; - bool old_iv; + uint16_t src; + bool old_iv; #if defined(CONFIG_BLE_MESH_SETTINGS) - bool store; + bool store; #endif - u32_t seq; + uint32_t seq; }; #if defined(CONFIG_BLE_MESH_FRIEND) -#define FRIEND_SEG_RX CONFIG_BLE_MESH_FRIEND_SEG_RX -#define FRIEND_SUB_LIST_SIZE CONFIG_BLE_MESH_FRIEND_SUB_LIST_SIZE +#define FRIEND_SEG_RX CONFIG_BLE_MESH_FRIEND_SEG_RX +#define FRIEND_SUB_LIST_SIZE CONFIG_BLE_MESH_FRIEND_SUB_LIST_SIZE #else -#define FRIEND_SEG_RX 0 -#define FRIEND_SUB_LIST_SIZE 0 +#define FRIEND_SEG_RX 0 +#define FRIEND_SUB_LIST_SIZE 0 #endif struct bt_mesh_friend { - u16_t lpn; - u8_t recv_delay; - u8_t fsn: 1, - send_last: 1, - pending_req: 1, - sec_update: 1, - pending_buf: 1, - valid: 1, - established: 1; - s32_t poll_to; - u8_t num_elem; - u16_t lpn_counter; - u16_t counter; + uint16_t lpn; + uint8_t recv_delay; + uint8_t fsn:1, + send_last:1, + pending_req:1, + sec_update:1, + pending_buf:1, + valid:1, + established:1; + 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; @@ -122,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 net_buf *last; sys_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; }; @@ -161,46 +156,46 @@ 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 */ - pending_poll: 1, /* Poll to be sent after subscription */ - disable: 1, /* Disable LPN after clearing */ - fsn: 1, /* Friend Sequence Number */ - established: 1, /* Friendship established */ - clear_success: 1; /* Friend Clear Confirm received */ + 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 */ + established: 1, /* Friendship established */ + 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 */ BLE_MESH_ATOMIC_DEFINE(added, LPN_GROUPS); @@ -236,8 +231,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) */ BLE_MESH_ATOMIC_DEFINE(flags, BLE_MESH_FLAG_COUNT); @@ -255,12 +250,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[CONFIG_BLE_MESH_APP_KEY_COUNT]; @@ -272,12 +267,12 @@ struct bt_mesh_net { /* Application keys stored by provisioner */ struct bt_mesh_app_key *p_app_keys[CONFIG_BLE_MESH_PROVISIONER_APP_KEY_COUNT]; /* Next app_idx can be assigned */ - u16_t p_app_idx_next; + uint16_t p_app_idx_next; /* Network keys stored by provisioner */ struct bt_mesh_subnet *p_sub[CONFIG_BLE_MESH_PROVISIONER_SUBNET_COUNT]; /* Next net_idx can be assigned */ - u16_t p_net_idx_next; + uint16_t p_net_idx_next; #endif }; @@ -293,48 +288,48 @@ 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 */ - 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 */ + 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 */ + 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, - aszmic: 1, - aid: 6; + uint16_t src; + uint8_t xmit; + uint8_t friend_cred:1, + aszmic:1, + aid: 6; }; extern struct bt_mesh_net bt_mesh; #define BLE_MESH_NET_IVI_TX (bt_mesh.iv_index - \ - bt_mesh_atomic_test_bit(bt_mesh.flags, \ - BLE_MESH_IVU_IN_PROGRESS)) + bt_mesh_atomic_test_bit(bt_mesh.flags, \ + BLE_MESH_IVU_IN_PROGRESS)) #define BLE_MESH_NET_IVI_RX(rx) (bt_mesh.iv_index - (rx)->old_iv) #define BLE_MESH_NET_HDR_LEN 9 -void bt_mesh_msg_cache_clear(u16_t unicast_addr, u8_t elem_num); +void bt_mesh_msg_cache_clear(uint16_t unicast_addr, uint8_t elem_num); 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); @@ -342,14 +337,14 @@ int bt_mesh_net_beacon_update(struct bt_mesh_subnet *sub); void bt_mesh_rpl_reset(void); -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 net_buf_simple *buf, @@ -365,12 +360,12 @@ int bt_mesh_net_resend(struct bt_mesh_subnet *sub, struct net_buf *buf, int bt_mesh_net_decode(struct net_buf_simple *data, enum bt_mesh_net_if net_if, struct bt_mesh_net_rx *rx, struct net_buf_simple *buf); -void bt_mesh_net_recv(struct net_buf_simple *data, s8_t rssi, +void bt_mesh_net_recv(struct net_buf_simple *data, int8_t rssi, enum bt_mesh_net_if net_if); bool bt_mesh_primary_subnet_exist(void); -u32_t bt_mesh_next_seq(void); +uint32_t bt_mesh_next_seq(void); void bt_mesh_net_start(void); @@ -383,28 +378,28 @@ void bt_mesh_net_header_parse(struct net_buf_simple *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/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c b/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c index ddb0e84b4b..80389ce792 100644 --- a/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c +++ b/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c @@ -57,15 +57,15 @@ */ #define BT_UUID_MESH_PROXY_DATA_OUT_VAL 0x2ade -#define BLE_MESH_GATT_GET_CONN_ID(conn_id) ((u16_t)(conn_id)) -#define BLE_MESH_GATT_CREATE_CONN_ID(conn_id) ((u16_t)(conn_id)) +#define BLE_MESH_GATT_GET_CONN_ID(conn_id) ((uint16_t)(conn_id)) +#define BLE_MESH_GATT_CREATE_CONN_ID(conn_id) ((uint16_t)(conn_id)) static uint16_t proxy_svc_start_handle, prov_svc_start_handle; struct bt_mesh_dev bt_mesh_dev; /* P-256 Variables */ -static u8_t bt_mesh_public_key[64]; -static u8_t bt_mesh_private_key[32]; +static uint8_t bt_mesh_public_key[64]; +static uint8_t bt_mesh_private_key[32]; /* Scan related functions */ static bt_mesh_scan_cb_t *bt_mesh_scan_dev_found_cb; @@ -78,7 +78,7 @@ static sys_slist_t bt_mesh_gatts_db; static struct bt_mesh_conn bt_mesh_gatts_conn[BLE_MESH_MAX_CONN]; static struct bt_mesh_conn_cb *bt_mesh_gatts_conn_cb; -static u8_t bt_mesh_gatts_addr[6]; +static uint8_t bt_mesh_gatts_addr[6]; #endif /* defined(CONFIG_BLE_MESH_NODE) && CONFIG_BLE_MESH_NODE */ @@ -129,14 +129,14 @@ static struct gattc_prov_info { /* Service to be found depends on the type of adv pkt received */ struct bt_mesh_conn conn; bt_mesh_addr_t addr; - u16_t service_uuid; - u16_t mtu; - bool wr_desc_done; /* Indicate if write char descriptor event is received */ - u16_t start_handle; /* Service attribute start handle */ - u16_t end_handle; /* Service attribute end handle */ - u16_t data_in_handle; /* Data In Characteristic attribute handle */ - u16_t data_out_handle; /* Data Out Characteristic attribute handle */ - u16_t ccc_handle; /* Data Out Characteristic CCC attribute handle */ + uint16_t service_uuid; + uint16_t mtu; + bool wr_desc_done; /* Indicate if write char descriptor event is received */ + uint16_t start_handle; /* Service attribute start handle */ + uint16_t end_handle; /* Service attribute end handle */ + uint16_t data_in_handle; /* Data In Characteristic attribute handle */ + uint16_t data_out_handle; /* Data Out Characteristic attribute handle */ + uint16_t ccc_handle; /* Data Out Characteristic CCC attribute handle */ } bt_mesh_gattc_info[BLE_MESH_MAX_CONN]; static struct bt_mesh_prov_conn_cb *bt_mesh_gattc_conn_cb; @@ -562,7 +562,7 @@ static int disc_cb(struct ble_gap_event *event, void *arg) return 0; } -static int start_le_scan(u8_t scan_type, u16_t interval, u16_t window, u8_t filter_dup) +static int start_le_scan(uint8_t scan_type, uint16_t interval, uint16_t window, uint8_t filter_dup) { scan_param.filter_duplicates = filter_dup; @@ -587,7 +587,7 @@ static int start_le_scan(u8_t scan_type, u16_t interval, u16_t window, u8_t filt return 0; } -static int set_ad(const struct bt_mesh_adv_data *ad, size_t ad_len, u8_t *buf, u8_t *buf_len) +static int set_ad(const struct bt_mesh_adv_data *ad, size_t ad_len, uint8_t *buf, uint8_t *buf_len) { int i; @@ -604,7 +604,7 @@ static int set_ad(const struct bt_mesh_adv_data *ad, size_t ad_len, u8_t *buf, u } #if defined(CONFIG_BLE_MESH_NODE) && CONFIG_BLE_MESH_NODE -static struct bt_mesh_gatt_attr *bt_mesh_gatts_find_attr_by_handle(u16_t handle); +static struct bt_mesh_gatt_attr *bt_mesh_gatts_find_attr_by_handle(uint16_t handle); static int gap_event_cb(struct ble_gap_event *event, void *arg) { @@ -627,7 +627,7 @@ static int gap_event_cb(struct ble_gap_event *event, void *arg) bt_mesh_atomic_test_and_clear_bit(bt_mesh_dev.flags, BLE_MESH_DEV_ADVERTISING); #endif if (bt_mesh_gatts_conn_cb != NULL && bt_mesh_gatts_conn_cb->connected != NULL) { - u8_t index = BLE_MESH_GATT_GET_CONN_ID(event->connect.conn_handle); + uint8_t index = BLE_MESH_GATT_GET_CONN_ID(event->connect.conn_handle); if (index < BLE_MESH_MAX_CONN) { bt_mesh_gatts_conn[index].handle = BLE_MESH_GATT_GET_CONN_ID(event->connect.conn_handle); (bt_mesh_gatts_conn_cb->connected)(&bt_mesh_gatts_conn[index], 0); @@ -651,7 +651,7 @@ static int gap_event_cb(struct ble_gap_event *event, void *arg) bt_mesh_atomic_test_and_clear_bit(bt_mesh_dev.flags, BLE_MESH_DEV_ADVERTISING); #endif if (bt_mesh_gatts_conn_cb != NULL && bt_mesh_gatts_conn_cb->disconnected != NULL) { - u8_t index = BLE_MESH_GATT_GET_CONN_ID(event->disconnect.conn.conn_handle); + uint8_t index = BLE_MESH_GATT_GET_CONN_ID(event->disconnect.conn.conn_handle); if (index < BLE_MESH_MAX_CONN) { bt_mesh_gatts_conn[index].handle = BLE_MESH_GATT_GET_CONN_ID(event->disconnect.conn.conn_handle); (bt_mesh_gatts_conn_cb->disconnected)(&bt_mesh_gatts_conn[index], event->disconnect.reason); @@ -695,8 +695,8 @@ static int gap_event_cb(struct ble_gap_event *event, void *arg) event->subscribe.prev_indicate, event->subscribe.cur_indicate); struct bt_mesh_gatt_attr *attr = bt_mesh_gatts_find_attr_by_handle(event->subscribe.attr_handle + 1); - u8_t index = BLE_MESH_GATT_GET_CONN_ID(event->subscribe.conn_handle); - u16_t len = 0; + uint8_t index = BLE_MESH_GATT_GET_CONN_ID(event->subscribe.conn_handle); + uint16_t len = 0; uint16_t ccc_val = 0; if (event->subscribe.prev_notify != event->subscribe.cur_notify) { @@ -1001,7 +1001,7 @@ void bt_mesh_gatts_conn_cb_deregister(void) bt_mesh_gatts_conn_cb = NULL; } -static struct bt_mesh_gatt_attr *bt_mesh_gatts_find_attr_by_handle(u16_t handle) +static struct bt_mesh_gatt_attr *bt_mesh_gatts_find_attr_by_handle(uint16_t handle) { struct bt_mesh_gatt_service *svc = NULL; struct bt_mesh_gatt_attr *attr = NULL; @@ -1021,7 +1021,7 @@ static struct bt_mesh_gatt_attr *bt_mesh_gatts_find_attr_by_handle(u16_t handle) return NULL; } -static void bt_mesh_gatts_foreach_attr(u16_t start_handle, u16_t end_handle, +static void bt_mesh_gatts_foreach_attr(uint16_t start_handle, uint16_t end_handle, bt_mesh_gatt_attr_func_t func, void *user_data) { struct bt_mesh_gatt_service *svc = NULL; @@ -1045,7 +1045,7 @@ static void bt_mesh_gatts_foreach_attr(u16_t start_handle, u16_t end_handle, } } -static u8_t find_next(const struct bt_mesh_gatt_attr *attr, void *user_data) +static uint8_t find_next(const struct bt_mesh_gatt_attr *attr, void *user_data) { struct bt_mesh_gatt_attr **next = user_data; @@ -1065,10 +1065,10 @@ static struct bt_mesh_gatt_attr *bt_mesh_gatts_attr_next(const struct bt_mesh_ga ssize_t bt_mesh_gatts_attr_read(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - void *buf, u16_t buf_len, u16_t offset, - const void *value, u16_t value_len) + void *buf, uint16_t buf_len, uint16_t offset, + const void *value, uint16_t value_len) { - u16_t len; + uint16_t len; if (offset > value_len) { return BLE_MESH_GATT_ERR(BLE_MESH_ATT_ERR_INVALID_OFFSET); @@ -1084,19 +1084,19 @@ ssize_t bt_mesh_gatts_attr_read(struct bt_mesh_conn *conn, } struct gatts_incl { - u16_t start_handle; - u16_t end_handle; - u16_t uuid16; + uint16_t start_handle; + uint16_t end_handle; + uint16_t uuid16; } __packed; ssize_t bt_mesh_gatts_attr_read_included(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - void *buf, u16_t len, u16_t offset) + void *buf, uint16_t len, uint16_t offset) { struct bt_mesh_gatt_attr *incl = attr->user_data; struct bt_mesh_uuid *uuid = incl->user_data; struct gatts_incl pdu = {0}; - u8_t value_len; + uint8_t value_len; /* First attr points to the start handle */ pdu.start_handle = sys_cpu_to_le16(incl->handle); @@ -1116,12 +1116,12 @@ ssize_t bt_mesh_gatts_attr_read_included(struct bt_mesh_conn *conn, ssize_t bt_mesh_gatts_attr_read_service(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - void *buf, u16_t len, u16_t offset) + void *buf, uint16_t len, uint16_t offset) { struct bt_mesh_uuid *uuid = attr->user_data; if (uuid->type == BLE_MESH_UUID_TYPE_16) { - u16_t uuid16 = sys_cpu_to_le16(BLE_MESH_UUID_16(uuid)->val); + uint16_t uuid16 = sys_cpu_to_le16(BLE_MESH_UUID_16(uuid)->val); return bt_mesh_gatts_attr_read(conn, attr, buf, len, offset, &uuid16, 2); } @@ -1131,22 +1131,22 @@ ssize_t bt_mesh_gatts_attr_read_service(struct bt_mesh_conn *conn, } struct gatts_chrc { - u8_t properties; - u16_t value_handle; + uint8_t properties; + uint16_t value_handle; union { - u16_t uuid16; - u8_t uuid[16]; + uint16_t uuid16; + uint8_t uuid[16]; }; } __packed; ssize_t bt_mesh_gatts_attr_read_chrc(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - void *buf, u16_t len, u16_t offset) + void *buf, uint16_t len, uint16_t offset) { struct bt_mesh_gatt_char *chrc = attr->user_data; const struct bt_mesh_gatt_attr *next = NULL; struct gatts_chrc pdu = {0}; - u8_t value_len; + uint8_t value_len; pdu.properties = chrc->properties; /* BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part G] page 534: @@ -1179,7 +1179,7 @@ ssize_t bt_mesh_gatts_attr_read_chrc(struct bt_mesh_conn *conn, static int gatts_register(struct bt_mesh_gatt_service *svc) { struct bt_mesh_gatt_service *last; - u16_t handle; + uint16_t handle; if (sys_slist_is_empty(&bt_mesh_gatts_db)) { handle = 0; @@ -1231,9 +1231,9 @@ int bt_mesh_gatts_service_deregister(struct bt_mesh_gatt_service *svc) return 0; } -int bt_mesh_gatts_disconnect(struct bt_mesh_conn *conn, u8_t reason) +int bt_mesh_gatts_disconnect(struct bt_mesh_conn *conn, uint8_t reason) { - u16_t conn_id = BLE_MESH_GATT_CREATE_CONN_ID(conn->handle); + uint16_t conn_id = BLE_MESH_GATT_CREATE_CONN_ID(conn->handle); ble_gap_terminate(conn_id, reason); return 0; } @@ -1247,10 +1247,10 @@ int bt_mesh_gatts_service_unregister(struct bt_mesh_gatt_service *svc) int bt_mesh_gatts_notify(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - const void *data, u16_t len) + const void *data, uint16_t len) { struct os_mbuf *om; - u16_t conn_id = BLE_MESH_GATT_CREATE_CONN_ID(conn->handle); + uint16_t conn_id = BLE_MESH_GATT_CREATE_CONN_ID(conn->handle); om = ble_hs_mbuf_from_flat(data, len); assert(om); @@ -1259,7 +1259,7 @@ int bt_mesh_gatts_notify(struct bt_mesh_conn *conn, return 0; } -u16_t bt_mesh_gatt_get_mtu(struct bt_mesh_conn *conn) +uint16_t bt_mesh_gatt_get_mtu(struct bt_mesh_conn *conn) { return ble_att_preferred_mtu(); } @@ -1329,10 +1329,10 @@ void bt_mesh_gattc_conn_cb_deregister(void) bt_mesh_gattc_conn_cb = NULL; } -u8_t bt_mesh_gattc_get_free_conn_count(void) +uint8_t bt_mesh_gattc_get_free_conn_count(void) { - u8_t count = 0; - u8_t i; + uint8_t count = 0; + uint8_t i; for (i = 0U; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) { if (bt_mesh_gattc_info[i].conn.handle == 0xFFFF && @@ -1344,7 +1344,7 @@ u8_t bt_mesh_gattc_get_free_conn_count(void) return count; } -u16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn) +uint16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn) { int i; @@ -1371,9 +1371,9 @@ u16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn) * 6. Set the Notification bit of CCC */ -int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid) +int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, uint16_t service_uuid) { - u8_t zero[6] = {0}; + uint8_t zero[6] = {0}; int i, rc; if (!addr || !memcmp(addr->val, zero, BLE_MESH_ADDR_LEN) || @@ -1467,7 +1467,7 @@ static int mtu_cb(uint16_t conn_handle, -void bt_mesh_gattc_exchange_mtu(u8_t index) +void bt_mesh_gattc_exchange_mtu(uint8_t index) { /** Set local MTU and exchange with GATT server. * ATT_MTU >= 69 for Mesh GATT Prov Service @@ -1477,7 +1477,7 @@ void bt_mesh_gattc_exchange_mtu(u8_t index) ble_gattc_exchange_mtu(bt_mesh_gattc_info[index].conn.handle, mtu_cb, NULL); } -u16_t bt_mesh_gattc_get_mtu_info(struct bt_mesh_conn *conn) +uint16_t bt_mesh_gattc_get_mtu_info(struct bt_mesh_conn *conn) { int i; @@ -1492,9 +1492,9 @@ u16_t bt_mesh_gattc_get_mtu_info(struct bt_mesh_conn *conn) int bt_mesh_gattc_write_no_rsp(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - const void *data, u16_t len) + const void *data, uint16_t len) { - u16_t conn_id; + uint16_t conn_id; int i; for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) { @@ -1584,8 +1584,8 @@ static int proxy_char_access_cb(uint16_t conn_handle, uint16_t attr_handle, { if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR || ctxt->op == BLE_GATT_ACCESS_OP_WRITE_DSC) { struct bt_mesh_gatt_attr *attr = bt_mesh_gatts_find_attr_by_handle(attr_handle); - u8_t index = BLE_MESH_GATT_GET_CONN_ID(conn_handle); - u16_t len = 0; + uint8_t index = BLE_MESH_GATT_GET_CONN_ID(conn_handle); + uint16_t len = 0; BT_DBG("write, handle %d, len %d, data %s", attr_handle, ctxt->om->om_len, @@ -1758,32 +1758,14 @@ void bt_mesh_adapt_init(void) bt_mesh_rand(bt_mesh_private_key, sizeof(bt_mesh_private_key)); } -int bt_mesh_rand(void *buf, size_t len) -{ - int i; - - if (buf == NULL || len == 0) { - BT_ERR("%s, Invalid parameter", __func__); - return -EAGAIN; - } - - for (i = 0; i < (int)(len / sizeof(u32_t)); i++) { - u32_t rand = esp_random(); - memcpy(buf + i * sizeof(u32_t), &rand, sizeof(u32_t)); - } - - BT_DBG("Rand %s", bt_hex(buf, len)); - return 0; -} - -void bt_mesh_set_private_key(const u8_t pri_key[32]) +void bt_mesh_set_private_key(const uint8_t pri_key[32]) { memcpy(bt_mesh_private_key, pri_key, 32); } int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv); -const u8_t *bt_mesh_pub_key_get(void) +const uint8_t *bt_mesh_pub_key_get(void) { uint8_t pri_key[32] = {0}; @@ -1817,7 +1799,7 @@ const u8_t *bt_mesh_pub_key_get(void) return bt_mesh_public_key; } -bool bt_mesh_check_public_key(const u8_t key[64]) +bool bt_mesh_check_public_key(const uint8_t key[64]) { struct mbedtls_ecp_point pt = {0}; mbedtls_ecp_group grp = {0}; @@ -1857,7 +1839,7 @@ exit: int ble_sm_alg_gen_dhkey(uint8_t *peer_pub_key_x, uint8_t *peer_pub_key_y, uint8_t *our_priv_key, uint8_t *out_dhkey); -int bt_mesh_dh_key_gen(const u8_t remote_pk[64], bt_mesh_dh_key_cb_t cb, const u8_t idx) +int bt_mesh_dh_key_gen(const uint8_t remote_pk[64], bt_mesh_dh_key_cb_t cb, const uint8_t idx) { uint8_t dhkey[32]; @@ -1866,14 +1848,14 @@ int bt_mesh_dh_key_gen(const u8_t remote_pk[64], bt_mesh_dh_key_cb_t cb, const u ble_sm_alg_gen_dhkey((uint8_t *)&remote_pk[0], (uint8_t *)&remote_pk[32], bt_mesh_private_key, dhkey); if (cb != NULL) { - cb((const u8_t *)dhkey, idx); + cb((const uint8_t *)dhkey, idx); } return 0; } #if CONFIG_MBEDTLS_HARDWARE_AES -static void ecb_encrypt(u8_t const *const key_le, u8_t const *const clear_text_le, - u8_t *const cipher_text_le, u8_t *const cipher_text_be) +static void ecb_encrypt(uint8_t const *const key_le, uint8_t const *const clear_text_le, + uint8_t *const cipher_text_le, uint8_t *const cipher_text_be) { struct bt_mesh_ecb_param ecb; mbedtls_aes_context aes_ctx = {0}; @@ -1894,8 +1876,8 @@ static void ecb_encrypt(u8_t const *const key_le, u8_t const *const clear_text_l } } -static void ecb_encrypt_be(u8_t const *const key_be, u8_t const *const clear_text_be, - u8_t *const cipher_text_be) +static void ecb_encrypt_be(uint8_t const *const key_be, uint8_t const *const clear_text_be, + uint8_t *const cipher_text_be) { struct bt_mesh_ecb_param ecb; mbedtls_aes_context aes_ctx = {0}; @@ -1909,8 +1891,8 @@ static void ecb_encrypt_be(u8_t const *const key_be, u8_t const *const clear_tex } #endif /* CONFIG_MBEDTLS_HARDWARE_AES */ -int bt_mesh_encrypt_le(const u8_t key[16], const u8_t plaintext[16], - u8_t enc_data[16]) +int bt_mesh_encrypt_le(const uint8_t key[16], const uint8_t plaintext[16], + uint8_t enc_data[16]) { #if CONFIG_MBEDTLS_HARDWARE_AES BT_DBG("key %s plaintext %s", bt_hex(key, 16), bt_hex(plaintext, 16)); @@ -1921,7 +1903,7 @@ int bt_mesh_encrypt_le(const u8_t key[16], const u8_t plaintext[16], return 0; #else /* CONFIG_MBEDTLS_HARDWARE_AES */ struct tc_aes_key_sched_struct s; - u8_t tmp[16]; + uint8_t tmp[16]; BT_DBG("key %s plaintext %s", bt_hex(key, 16), bt_hex(plaintext, 16)); @@ -1945,8 +1927,8 @@ int bt_mesh_encrypt_le(const u8_t key[16], const u8_t plaintext[16], #endif /* CONFIG_MBEDTLS_HARDWARE_AES */ } -int bt_mesh_encrypt_be(const u8_t key[16], const u8_t plaintext[16], - u8_t enc_data[16]) +int bt_mesh_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16], + uint8_t enc_data[16]) { #if CONFIG_MBEDTLS_HARDWARE_AES BT_DBG("key %s plaintext %s", bt_hex(key, 16), bt_hex(plaintext, 16)); @@ -1976,7 +1958,7 @@ int bt_mesh_encrypt_be(const u8_t key[16], const u8_t plaintext[16], } #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) -int bt_mesh_update_exceptional_list(u8_t sub_code, u8_t type, void *info) +int bt_mesh_update_exceptional_list(uint8_t sub_code, uint8_t type, void *info) { BT_ERR("Unsupported for NimBLE host"); return 0; diff --git a/components/bt/esp_ble_mesh/mesh_core/prov.c b/components/bt/esp_ble_mesh/mesh_core/prov.c index 9ef3082f30..c2be7fb418 100644 --- a/components/bt/esp_ble_mesh/mesh_core/prov.c +++ b/components/bt/esp_ble_mesh/mesh_core/prov.c @@ -9,8 +9,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_PROV) - #include "crypto.h" #include "adv.h" #include "mesh.h" @@ -110,45 +108,45 @@ enum { struct prov_link { BLE_MESH_ATOMIC_DEFINE(flags, NUM_FLAGS); #if defined(CONFIG_BLE_MESH_PB_GATT) - struct bt_mesh_conn *conn; /* GATT connection */ + struct bt_mesh_conn *conn; /* GATT connection */ #endif - u8_t dhkey[32]; /* Calculated DHKey */ - u8_t expect; /* Next expected PDU */ + uint8_t dhkey[32]; /* Calculated DHKey */ + uint8_t expect; /* Next expected PDU */ - bool oob_pk_flag; /* Flag indicates whether using OOB public key */ + bool oob_pk_flag; /* Flag indicates whether using OOB public key */ - 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 */ #if defined(CONFIG_BLE_MESH_PB_ADV) - u32_t id; /* Link ID */ - u8_t tx_pdu_type; /* The previously transmitted Provisioning PDU type */ + uint32_t id; /* Link ID */ + uint8_t tx_pdu_type; /* The previously transmitted Provisioning PDU type */ 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 net_buf_simple *buf; } rx; struct { /* Start timestamp of the transaction */ - s64_t start; + int64_t start; /* Transaction id*/ - u8_t id; + uint8_t id; /* Pending outgoing buffer(s) */ struct net_buf *buf[3]; @@ -162,9 +160,9 @@ struct prov_link { }; 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; }; #define BUF_TIMEOUT K_MSEC(400) @@ -332,15 +330,15 @@ static struct net_buf *adv_buf_create(void) return buf; } -static u8_t pending_ack = XACT_NVAL; +static uint8_t pending_ack = XACT_NVAL; -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 %u complete", (u8_t)pending_ack); + BT_DBG("xact %u complete", (uint8_t)pending_ack); pending_ack = XACT_NVAL; } -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, @@ -396,7 +394,7 @@ static void send_reliable(void) } } -static int bearer_ctl_send(u8_t op, void *data, u8_t data_len) +static int bearer_ctl_send(uint8_t op, void *data, uint8_t data_len) { struct net_buf *buf = NULL; @@ -421,7 +419,7 @@ static int bearer_ctl_send(u8_t op, void *data, u8_t data_len) return 0; } -static u8_t last_seg(u8_t len) +static uint8_t last_seg(uint8_t len) { if (len <= START_PAYLOAD_MAX) { return 0; @@ -432,7 +430,7 @@ static u8_t last_seg(u8_t len) return 1 + (len / CONT_PAYLOAD_MAX); } -static inline u8_t next_transaction_id(void) +static inline uint8_t next_transaction_id(void) { if (link.tx.id != 0U && link.tx.id != 0xFF) { return ++link.tx.id; @@ -445,9 +443,9 @@ static inline u8_t next_transaction_id(void) static int prov_send_adv(struct net_buf_simple *msg) { struct net_buf *start = NULL, *buf = NULL; - u8_t seg_len = 0U, seg_id = 0U; - u8_t xact_id = 0U; - s32_t timeout = PROTOCOL_TIMEOUT; + uint8_t seg_len = 0U, seg_id = 0U; + uint8_t xact_id = 0U; + int32_t timeout = PROTOCOL_TIMEOUT; BT_DBG("len %u: %s", msg->len, bt_hex(msg->data, msg->len)); @@ -558,13 +556,13 @@ static inline int prov_send(struct net_buf_simple *buf) #endif } -static void prov_buf_init(struct net_buf_simple *buf, u8_t type) +static void prov_buf_init(struct net_buf_simple *buf, uint8_t type) { net_buf_simple_reserve(buf, PROV_BUF_HEADROOM); net_buf_simple_add_u8(buf, type); } -static void prov_send_fail_msg(u8_t err) +static void prov_send_fail_msg(uint8_t err) { PROV_BUF(buf, 2); @@ -578,7 +576,7 @@ static void prov_send_fail_msg(u8_t err) bt_mesh_atomic_set_bit(link.flags, LINK_INVALID); } -static void prov_invite(const u8_t *data) +static void prov_invite(const uint8_t *data) { PROV_BUF(buf, 12); @@ -626,9 +624,9 @@ static void prov_invite(const u8_t *data) link.expect = PROV_START; } -static void prov_capabilities(const u8_t *data) +static void prov_capabilities(const uint8_t *data) { - u16_t algorithms = 0U, output_action = 0U, input_action = 0U; + uint16_t algorithms = 0U, output_action = 0U, input_action = 0U; BT_DBG("Elements: %u", data[0]); @@ -652,7 +650,7 @@ static void prov_capabilities(const u8_t *data) ((void) input_action); } -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: @@ -670,7 +668,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: @@ -686,7 +684,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 = 0U; bt_mesh_input_action_t input = 0U; @@ -726,7 +724,7 @@ static int prov_auth(u8_t method, u8_t action, u8_t size) if (output == BLE_MESH_DISPLAY_STRING) { unsigned char str[9] = {'\0'}; - u8_t i = 0U; + uint8_t i = 0U; bt_mesh_rand(str, size); @@ -747,10 +745,10 @@ 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, - 1000000, 10000000, 100000000 - }; - u32_t num = 0U; + uint32_t div[8] = { 10, 100, 1000, 10000, 100000, + 1000000, 10000000, 100000000 + }; + uint32_t num = 0U; bt_mesh_rand(&num, sizeof(num)); num %= div[size - 1]; @@ -788,7 +786,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_INFO("Algorithm: 0x%02x", data[0]); BT_INFO("Public Key: 0x%02x", data[1]); @@ -888,7 +886,7 @@ static void send_input_complete(void) } } -int bt_mesh_input_number(u32_t num) +int bt_mesh_input_number(uint32_t num) { BT_INFO("%u", num); @@ -934,7 +932,7 @@ int bt_mesh_input_string(const char *str) return 0; } -static void prov_dh_key_cb(const u8_t key[32], const u8_t idx) +static void prov_dh_key_cb(const uint8_t key[32], const uint8_t idx) { BT_DBG("%p", key); @@ -963,7 +961,7 @@ static void prov_dh_key_cb(const u8_t key[32], const u8_t idx) static void send_pub_key(void) { PROV_BUF(buf, 65); - const u8_t *key = NULL; + const uint8_t *key = NULL; /* Copy remote key in little-endian for bt_mesh_dh_key_gen(). * X and Y halves are swapped independently. Use response @@ -1024,8 +1022,8 @@ static int bt_mesh_calc_dh_key(void) return 0; } -int bt_mesh_set_oob_pub_key(const u8_t pub_key_x[32], const u8_t pub_key_y[32], - const u8_t pri_key[32]) +int bt_mesh_set_oob_pub_key(const uint8_t pub_key_x[32], const uint8_t pub_key_y[32], + const uint8_t pri_key[32]) { if (!pub_key_x || !pub_key_y || !pri_key) { BT_ERR("%s, Invalid parameter", __func__); @@ -1050,7 +1048,7 @@ int bt_mesh_set_oob_pub_key(const u8_t pub_key_x[32], const u8_t pub_key_y[32], return bt_mesh_calc_dh_key(); } -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)); @@ -1085,12 +1083,12 @@ static void prov_pub_key(const u8_t *data) } } -static void prov_input_complete(const u8_t *data) +static void prov_input_complete(const uint8_t *data) { BT_DBG("%s", __func__); } -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)); @@ -1110,10 +1108,10 @@ static void prov_confirm(const u8_t *data) } } -static void prov_random(const u8_t *data) +static void prov_random(const uint8_t *data) { PROV_BUF(rnd, 17); - u8_t conf_verify[16] = {0}; + uint8_t conf_verify[16] = {0}; BT_DBG("Remote Random: %s", bt_hex(data, 16)); @@ -1160,17 +1158,17 @@ static inline bool is_pb_gatt(void) #endif } -static void prov_data(const u8_t *data) +static void prov_data(const uint8_t *data) { PROV_BUF(msg, 1); - u8_t session_key[16] = {0}; - u8_t nonce[13] = {0}; - u8_t dev_key[16] = {0}; - u8_t pdu[25] = {0}; - u8_t flags = 0U; - u32_t iv_index = 0U; - u16_t addr = 0U; - u16_t net_idx = 0U; + uint8_t session_key[16] = {0}; + uint8_t nonce[13] = {0}; + uint8_t dev_key[16] = {0}; + uint8_t pdu[25] = {0}; + uint8_t flags = 0U; + uint32_t iv_index = 0U; + uint16_t addr = 0U; + uint16_t net_idx = 0U; int err = 0; bool identity_enable = false; @@ -1248,19 +1246,19 @@ static void prov_data(const u8_t *data) } } -static void prov_complete(const u8_t *data) +static void prov_complete(const uint8_t *data) { BT_DBG("%s", __func__); } -static void prov_failed(const u8_t *data) +static void prov_failed(const uint8_t *data) { BT_WARN("Error: 0x%02x", data[0]); } 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 }, @@ -1277,7 +1275,7 @@ static const struct { #if defined(CONFIG_BLE_MESH_PB_ADV) static void prov_retransmit(struct k_work *work) { - s64_t timeout = TRANSACTION_TIMEOUT; + int64_t timeout = TRANSACTION_TIMEOUT; int i; BT_DBG("%s", __func__); @@ -1412,7 +1410,7 @@ static void gen_prov_ctl(struct prov_rx *rx, struct net_buf_simple *buf) static void prov_msg_recv(void) { - u8_t type = link.rx.buf->data[0]; + uint8_t type = link.rx.buf->data[0]; BT_DBG("type 0x%02x len %u", type, link.rx.buf->len); @@ -1460,7 +1458,7 @@ static void prov_msg_recv(void) static void gen_prov_cont(struct prov_rx *rx, struct net_buf_simple *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->len, seg); @@ -1481,7 +1479,7 @@ static void gen_prov_cont(struct prov_rx *rx, struct net_buf_simple *buf) prov_send_fail_msg(PROV_ERR_NVAL_FMT); return; } else if (seg == link.rx.last_seg) { - u8_t expect_len = 0U; + uint8_t expect_len = 0U; expect_len = (link.rx.buf->len - 20U - ((link.rx.last_seg - 1) * 23U)); @@ -1571,7 +1569,7 @@ static void gen_prov_start(struct prov_rx *rx, struct net_buf_simple *buf) static const struct { void (*func)(struct prov_rx *rx, struct net_buf_simple *buf); bool require_link; - u8_t min_len; + uint8_t min_len; } gen_prov[] = { { gen_prov_start, true, 3 }, { gen_prov_ack, true, 0 }, @@ -1627,7 +1625,7 @@ void bt_mesh_pb_adv_recv(struct net_buf_simple *buf) #if defined(CONFIG_BLE_MESH_PB_GATT) int bt_mesh_pb_gatt_recv(struct bt_mesh_conn *conn, struct net_buf_simple *buf) { - u8_t type = 0U; + uint8_t type = 0U; BT_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len)); @@ -1727,7 +1725,7 @@ static void protocol_timeout(struct k_work *work) #endif #if defined(CONFIG_BLE_MESH_PB_ADV) - u8_t reason = CLOSE_REASON_TIMEOUT; + uint8_t reason = CLOSE_REASON_TIMEOUT; link.rx.seg = 0U; bearer_ctl_send(LINK_CLOSE, &reason, sizeof(reason)); @@ -1738,7 +1736,7 @@ static void protocol_timeout(struct k_work *work) int bt_mesh_prov_init(const struct bt_mesh_prov *prov_info) { - const u8_t *key = NULL; + const uint8_t *key = NULL; if (!prov_info) { BT_ERR("No provisioning context provided"); @@ -1810,8 +1808,8 @@ int bt_mesh_prov_deinit(void) } #endif /* CONFIG_BLE_MESH_DEINIT */ -void bt_mesh_prov_complete(u16_t net_idx, const u8_t net_key[16], - u16_t addr, u8_t flags, u32_t iv_index) +void bt_mesh_prov_complete(uint16_t net_idx, const uint8_t net_key[16], + uint16_t addr, uint8_t flags, uint32_t iv_index) { if (prov->complete) { prov->complete(net_idx, net_key, addr, flags, iv_index); diff --git a/components/bt/esp_ble_mesh/mesh_core/prov.h b/components/bt/esp_ble_mesh/mesh_core/prov.h index 04466b6ba1..a6c1d9dfe5 100644 --- a/components/bt/esp_ble_mesh/mesh_core/prov.h +++ b/components/bt/esp_ble_mesh/mesh_core/prov.h @@ -24,16 +24,16 @@ int bt_mesh_pb_gatt_open(struct bt_mesh_conn *conn); int bt_mesh_pb_gatt_close(struct bt_mesh_conn *conn); int bt_mesh_pb_gatt_recv(struct bt_mesh_conn *conn, struct net_buf_simple *buf); -int bt_mesh_set_oob_pub_key(const u8_t pub_key_x[32], const u8_t pub_key_y[32], - const u8_t pri_key[32]); +int bt_mesh_set_oob_pub_key(const uint8_t pub_key_x[32], const uint8_t pub_key_y[32], + const uint8_t pri_key[32]); const struct bt_mesh_prov *bt_mesh_prov_get(void); int bt_mesh_prov_init(const struct bt_mesh_prov *prov); int bt_mesh_prov_deinit(void); -void bt_mesh_prov_complete(u16_t net_idx, const u8_t net_key[16], - u16_t addr, u8_t flags, u32_t iv_index); +void bt_mesh_prov_complete(uint16_t net_idx, const uint8_t net_key[16], + uint16_t addr, uint8_t flags, uint32_t iv_index); void bt_mesh_prov_reset(void); #ifdef __cplusplus diff --git a/components/bt/esp_ble_mesh/mesh_core/provisioner_main.c b/components/bt/esp_ble_mesh/mesh_core/provisioner_main.c index d3be4ee791..4b35f45377 100644 --- a/components/bt/esp_ble_mesh/mesh_core/provisioner_main.c +++ b/components/bt/esp_ble_mesh/mesh_core/provisioner_main.c @@ -32,9 +32,9 @@ static struct bt_mesh_node *mesh_nodes[CONFIG_BLE_MESH_MAX_PROV_NODES]; static bt_mesh_mutex_t provisioner_lock; -static u16_t node_count; +static uint16_t node_count; -static int provisioner_remove_node(u16_t index, bool erase); +static int provisioner_remove_node(uint16_t index, bool erase); static inline void bt_mesh_provisioner_mutex_new(void) { @@ -76,7 +76,7 @@ int bt_mesh_provisioner_net_create(void) { const struct bt_mesh_prov *prov = NULL; struct bt_mesh_subnet *sub = NULL; - u8_t p_key[16] = {0}; + uint8_t p_key[16] = {0}; BT_DBG("%s", __func__); @@ -202,12 +202,12 @@ int bt_mesh_provisioner_deinit(bool erase) } #endif /* CONFIG_BLE_MESH_DEINIT */ -bool bt_mesh_provisioner_check_is_addr_dup(u16_t addr, u8_t elem_num, bool comp_with_own) +bool bt_mesh_provisioner_check_is_addr_dup(uint16_t addr, uint8_t elem_num, bool comp_with_own) { const struct bt_mesh_comp *comp = NULL; struct bt_mesh_node *node = NULL; - u16_t primary_addr = BLE_MESH_ADDR_UNASSIGNED; - u16_t comp_addr = BLE_MESH_ADDR_UNASSIGNED; + uint16_t primary_addr = BLE_MESH_ADDR_UNASSIGNED; + uint16_t comp_addr = BLE_MESH_ADDR_UNASSIGNED; int i; if (comp_with_own) { @@ -256,12 +256,12 @@ static void provisioner_node_count_dec(void) } } -u16_t bt_mesh_provisioner_get_node_count(void) +uint16_t bt_mesh_provisioner_get_node_count(void) { return node_count; } -static int provisioner_store_node(struct bt_mesh_node *node, bool store, u16_t *index) +static int provisioner_store_node(struct bt_mesh_node *node, bool store, uint16_t *index) { int i; @@ -315,11 +315,11 @@ int bt_mesh_provisioner_restore_node_info(struct bt_mesh_node *node) return provisioner_store_node(node, false, NULL); } -int bt_mesh_provisioner_provision(const bt_mesh_addr_t *addr, const u8_t uuid[16], - u16_t oob_info, u16_t unicast_addr, - u8_t element_num, u16_t net_idx, - u8_t flags, u32_t iv_index, - const u8_t dev_key[16], u16_t *index) +int bt_mesh_provisioner_provision(const bt_mesh_addr_t *addr, const uint8_t uuid[16], + uint16_t oob_info, uint16_t unicast_addr, + uint8_t element_num, uint16_t net_idx, + uint8_t flags, uint32_t iv_index, + const uint8_t dev_key[16], uint16_t *index) { struct bt_mesh_node node = {0}; @@ -349,7 +349,7 @@ int bt_mesh_provisioner_provision(const bt_mesh_addr_t *addr, const u8_t uuid[16 return provisioner_store_node(&node, true, index); } -static int provisioner_remove_node(u16_t index, bool erase) +static int provisioner_remove_node(uint16_t index, bool erase) { struct bt_mesh_node *node = NULL; int i; @@ -396,7 +396,7 @@ static int provisioner_remove_node(u16_t index, bool erase) return 0; } -static struct bt_mesh_node *provisioner_find_node_with_uuid(const u8_t uuid[16], u16_t *index) +static struct bt_mesh_node *provisioner_find_node_with_uuid(const uint8_t uuid[16], uint16_t *index) { int i; @@ -423,10 +423,10 @@ static struct bt_mesh_node *provisioner_find_node_with_uuid(const u8_t uuid[16], return NULL; } -int bt_mesh_provisioner_remove_node(const u8_t uuid[16]) +int bt_mesh_provisioner_remove_node(const uint8_t uuid[16]) { struct bt_mesh_node *node = NULL; - u16_t index = 0U; + uint16_t index = 0U; int i; if (uuid == NULL) { @@ -448,7 +448,7 @@ int bt_mesh_provisioner_remove_node(const u8_t uuid[16]) return 0; } -static struct bt_mesh_node *provisioner_find_node_with_addr(u16_t addr, u16_t *index) +static struct bt_mesh_node *provisioner_find_node_with_addr(uint16_t addr, uint16_t *index) { struct bt_mesh_node *node = NULL; int i; @@ -478,7 +478,7 @@ static struct bt_mesh_node *provisioner_find_node_with_addr(u16_t addr, u16_t *i return NULL; } -int bt_mesh_provisioner_restore_node_name(u16_t addr, const char *name) +int bt_mesh_provisioner_restore_node_name(uint16_t addr, const char *name) { struct bt_mesh_node *node = NULL; @@ -494,20 +494,20 @@ int bt_mesh_provisioner_restore_node_name(u16_t addr, const char *name) return 0; } -struct bt_mesh_node *bt_mesh_provisioner_get_node_with_uuid(const u8_t uuid[16]) +struct bt_mesh_node *bt_mesh_provisioner_get_node_with_uuid(const uint8_t uuid[16]) { return provisioner_find_node_with_uuid(uuid, NULL); } -struct bt_mesh_node *bt_mesh_provisioner_get_node_with_addr(u16_t unicast_addr) +struct bt_mesh_node *bt_mesh_provisioner_get_node_with_addr(uint16_t unicast_addr) { return provisioner_find_node_with_addr(unicast_addr, NULL); } -int bt_mesh_provisioner_delete_node_with_uuid(const u8_t uuid[16]) +int bt_mesh_provisioner_delete_node_with_uuid(const uint8_t uuid[16]) { struct bt_mesh_node *node = NULL; - u16_t index = 0U; + uint16_t index = 0U; node = provisioner_find_node_with_uuid(uuid, &index); if (!node) { @@ -519,10 +519,10 @@ int bt_mesh_provisioner_delete_node_with_uuid(const u8_t uuid[16]) return 0; } -int bt_mesh_provisioner_delete_node_with_node_addr(u16_t unicast_addr) +int bt_mesh_provisioner_delete_node_with_node_addr(uint16_t unicast_addr) { struct bt_mesh_node *node = NULL; - u16_t index = 0U; + uint16_t index = 0U; node = provisioner_find_node_with_addr(unicast_addr, &index); if (!node) { @@ -576,7 +576,7 @@ static struct bt_mesh_node **provisioner_find_node_with_name(const char *name) return NULL; } -int bt_mesh_provisioner_set_node_name(u16_t index, const char *name) +int bt_mesh_provisioner_set_node_name(uint16_t index, const char *name) { if (index >= ARRAY_SIZE(mesh_nodes)) { BT_ERR("Invalid node index %d", index); @@ -608,7 +608,7 @@ int bt_mesh_provisioner_set_node_name(u16_t index, const char *name) return 0; } -const char *bt_mesh_provisioner_get_node_name(u16_t index) +const char *bt_mesh_provisioner_get_node_name(uint16_t index) { if (index >= ARRAY_SIZE(mesh_nodes)) { BT_ERR("Invalid node index %d", index); @@ -623,7 +623,7 @@ const char *bt_mesh_provisioner_get_node_name(u16_t index) return mesh_nodes[index]->name; } -u16_t bt_mesh_provisioner_get_node_index(const char *name) +uint16_t bt_mesh_provisioner_get_node_index(const char *name) { struct bt_mesh_node **node = NULL; @@ -666,7 +666,7 @@ const struct bt_mesh_node **bt_mesh_provisioner_get_node_table_entry(void) #define COMP_DATA_PAGE_0_MIN_LEN 16 -static int store_node_comp_data(u16_t addr, const u8_t *data, u16_t length, bool store) +static int store_node_comp_data(uint16_t addr, const uint8_t *data, uint16_t length, bool store) { struct bt_mesh_node *node = NULL; @@ -702,19 +702,19 @@ static int store_node_comp_data(u16_t addr, const u8_t *data, u16_t length, bool return 0; } -int bt_mesh_provisioner_store_node_comp_data(u16_t addr, const u8_t *data, u16_t length) +int bt_mesh_provisioner_store_node_comp_data(uint16_t addr, const uint8_t *data, uint16_t length) { return store_node_comp_data(addr, data, length, true); } -int bt_mesh_provisioner_restore_node_comp_data(u16_t addr, const u8_t *data, u16_t length) +int bt_mesh_provisioner_restore_node_comp_data(uint16_t addr, const uint8_t *data, uint16_t length) { return store_node_comp_data(addr, data, length, false); } /* Provisioner DevKey, NetKey and AppKey related functions */ -const u8_t *bt_mesh_provisioner_net_key_get(u16_t net_idx) +const uint8_t *bt_mesh_provisioner_net_key_get(uint16_t net_idx) { struct bt_mesh_subnet *sub = NULL; int i; @@ -735,7 +735,7 @@ const u8_t *bt_mesh_provisioner_net_key_get(u16_t net_idx) return NULL; } -struct bt_mesh_subnet *bt_mesh_provisioner_subnet_get(u16_t net_idx) +struct bt_mesh_subnet *bt_mesh_provisioner_subnet_get(uint16_t net_idx) { struct bt_mesh_subnet *sub = NULL; int i; @@ -756,7 +756,7 @@ struct bt_mesh_subnet *bt_mesh_provisioner_subnet_get(u16_t net_idx) return NULL; } -bool bt_mesh_provisioner_check_msg_dst(u16_t dst) +bool bt_mesh_provisioner_check_msg_dst(uint16_t dst) { struct bt_mesh_node *node = NULL; int i; @@ -778,7 +778,7 @@ bool bt_mesh_provisioner_check_msg_dst(u16_t dst) return false; } -const u8_t *bt_mesh_provisioner_dev_key_get(u16_t dst) +const uint8_t *bt_mesh_provisioner_dev_key_get(uint16_t dst) { /* Device key is only used to encrypt configuration messages. * Configuration model shall only be supported by the primary @@ -804,7 +804,7 @@ const u8_t *bt_mesh_provisioner_dev_key_get(u16_t dst) return NULL; } -struct bt_mesh_app_key *bt_mesh_provisioner_app_key_find(u16_t app_idx) +struct bt_mesh_app_key *bt_mesh_provisioner_app_key_find(uint16_t app_idx) { struct bt_mesh_app_key *key = NULL; int i; @@ -822,7 +822,7 @@ struct bt_mesh_app_key *bt_mesh_provisioner_app_key_find(u16_t app_idx) return NULL; } -static int provisioner_check_app_key(const u8_t app_key[16], u16_t *app_idx) +static int provisioner_check_app_key(const uint8_t app_key[16], uint16_t *app_idx) { struct bt_mesh_app_key *key = NULL; int i; @@ -844,7 +844,7 @@ static int provisioner_check_app_key(const u8_t app_key[16], u16_t *app_idx) return 0; } -static int provisioner_check_app_idx(u16_t app_idx, bool exist) +static int provisioner_check_app_idx(uint16_t app_idx, bool exist) { struct bt_mesh_app_key *key = NULL; int i; @@ -884,7 +884,7 @@ static int provisioner_check_app_key_full(void) return -ENOMEM; } -static int provisioner_check_net_key(const u8_t net_key[16], u16_t *net_idx) +static int provisioner_check_net_key(const uint8_t net_key[16], uint16_t *net_idx) { struct bt_mesh_subnet *sub = NULL; int i; @@ -906,7 +906,7 @@ static int provisioner_check_net_key(const u8_t net_key[16], u16_t *net_idx) return 0; } -static int provisioner_check_net_idx(u16_t net_idx, bool exist) +static int provisioner_check_net_idx(uint16_t net_idx, bool exist) { struct bt_mesh_subnet *sub = NULL; int i; @@ -946,12 +946,12 @@ static int provisioner_check_net_key_full(void) return -ENOMEM; } -int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], - u16_t net_idx, u16_t *app_idx) +int bt_mesh_provisioner_local_app_key_add(const uint8_t app_key[16], + uint16_t net_idx, uint16_t *app_idx) { struct bt_mesh_app_keys *keys = NULL; struct bt_mesh_app_key *key = NULL; - u8_t p_key[16] = {0}; + uint8_t p_key[16] = {0}; int add = -1; if (bt_mesh.p_app_idx_next >= 0x1000) { @@ -1043,8 +1043,8 @@ int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], return 0; } -int bt_mesh_provisioner_local_app_key_update(const u8_t app_key[16], - u16_t net_idx, u16_t app_idx) +int bt_mesh_provisioner_local_app_key_update(const uint8_t app_key[16], + uint16_t net_idx, uint16_t app_idx) { struct bt_mesh_app_keys *keys = NULL; struct bt_mesh_app_key *key = NULL; @@ -1087,7 +1087,7 @@ int bt_mesh_provisioner_local_app_key_update(const u8_t app_key[16], return 0; } -const u8_t *bt_mesh_provisioner_local_app_key_get(u16_t net_idx, u16_t app_idx) +const uint8_t *bt_mesh_provisioner_local_app_key_get(uint16_t net_idx, uint16_t app_idx) { struct bt_mesh_app_key *key = NULL; int i; @@ -1147,7 +1147,7 @@ static void model_pub_clear(struct bt_mesh_model *model, bool store) return; } -static void model_unbind(struct bt_mesh_model *model, u16_t app_idx, bool store) +static void model_unbind(struct bt_mesh_model *model, uint16_t app_idx, bool store) { int i; @@ -1169,7 +1169,7 @@ static void model_unbind(struct bt_mesh_model *model, u16_t app_idx, bool store) } struct unbind_data { - u16_t app_idx; + uint16_t app_idx; bool store; }; @@ -1181,7 +1181,7 @@ static void _model_unbind(struct bt_mesh_model *mod, struct bt_mesh_elem *elem, model_unbind(mod, data->app_idx, data->store); } -int bt_mesh_provisioner_local_app_key_del(u16_t net_idx, u16_t app_idx, bool store) +int bt_mesh_provisioner_local_app_key_del(uint16_t net_idx, uint16_t app_idx, bool store) { struct unbind_data data = { .app_idx = app_idx, .store = store }; struct bt_mesh_app_key *key = NULL; @@ -1220,10 +1220,10 @@ int bt_mesh_provisioner_local_app_key_del(u16_t net_idx, u16_t app_idx, bool sto return -ENODEV; } -int bt_mesh_provisioner_local_net_key_add(const u8_t net_key[16], u16_t *net_idx) +int bt_mesh_provisioner_local_net_key_add(const uint8_t net_key[16], uint16_t *net_idx) { struct bt_mesh_subnet *sub = NULL; - u8_t p_key[16] = {0}; + uint8_t p_key[16] = {0}; int add = -1; if (bt_mesh.p_net_idx_next >= 0x1000) { @@ -1308,7 +1308,7 @@ int bt_mesh_provisioner_local_net_key_add(const u8_t net_key[16], u16_t *net_idx return 0; } -int bt_mesh_provisioner_local_net_key_update(const u8_t net_key[16], u16_t net_idx) +int bt_mesh_provisioner_local_net_key_update(const uint8_t net_key[16], uint16_t net_idx) { struct bt_mesh_subnet *sub = NULL; int err = 0; @@ -1352,7 +1352,7 @@ int bt_mesh_provisioner_local_net_key_update(const u8_t net_key[16], u16_t net_i return 0; } -const u8_t *bt_mesh_provisioner_local_net_key_get(u16_t net_idx) +const uint8_t *bt_mesh_provisioner_local_net_key_get(uint16_t net_idx) { struct bt_mesh_subnet *sub = NULL; int i; @@ -1377,7 +1377,7 @@ const u8_t *bt_mesh_provisioner_local_net_key_get(u16_t net_idx) return NULL; } -int bt_mesh_provisioner_local_net_key_del(u16_t net_idx, bool store) +int bt_mesh_provisioner_local_net_key_del(uint16_t net_idx, bool store) { struct bt_mesh_subnet *sub = NULL; int i, j; @@ -1415,8 +1415,8 @@ int bt_mesh_provisioner_local_net_key_del(u16_t net_idx, bool store) return -ENODEV; } -int bt_mesh_provisioner_bind_local_model_app_idx(u16_t elem_addr, u16_t mod_id, - u16_t cid, u16_t app_idx) +int bt_mesh_provisioner_bind_local_model_app_idx(uint16_t elem_addr, uint16_t mod_id, + uint16_t cid, uint16_t app_idx) { struct bt_mesh_model *model = NULL; struct bt_mesh_elem *elem = NULL; @@ -1561,11 +1561,11 @@ int bt_mesh_provisioner_store_node_info(struct bt_mesh_node *node) static struct heartbeat_recv { struct heartbeat_filter { - u8_t type; /* Indicate if using src or dst or both to filter heartbeat messages */ - u16_t src; /* Heartbeat source address (unicast address) */ - u16_t dst; /* Heartbeat destination address (unicast address or group address) */ + uint8_t type; /* Indicate if using src or dst or both to filter heartbeat messages */ + uint16_t src; /* Heartbeat source address (unicast address) */ + uint16_t dst; /* Heartbeat destination address (unicast address or group address) */ } filter[CONFIG_BLE_MESH_PROVISIONER_RECV_HB_FILTER_SIZE]; - u8_t type; /* Heartbeat filter type */ + uint8_t type; /* Heartbeat filter type */ bt_mesh_heartbeat_recv_cb_t cb; /* Heartbeat receive callback */ } hb_rx; @@ -1580,7 +1580,7 @@ int bt_mesh_provisioner_recv_heartbeat(bt_mesh_heartbeat_recv_cb_t cb) return 0; } -int bt_mesh_provisioner_set_heartbeat_filter_type(u8_t type) +int bt_mesh_provisioner_set_heartbeat_filter_type(uint8_t type) { if (type > HEARTBEAT_FILTER_REJECTLIST) { BT_ERR("Invalid heartbeat filter type 0x%02x", type); @@ -1598,7 +1598,7 @@ int bt_mesh_provisioner_set_heartbeat_filter_type(u8_t type) return 0; } -static inline u8_t get_filter_addr_type(u16_t src, u16_t dst) +static inline uint8_t get_filter_addr_type(uint16_t src, uint16_t dst) { if (BLE_MESH_ADDR_IS_UNICAST(src)) { if (BLE_MESH_ADDR_IS_UNICAST(dst) || BLE_MESH_ADDR_IS_GROUP(dst)) { @@ -1611,7 +1611,7 @@ static inline u8_t get_filter_addr_type(u16_t src, u16_t dst) } } -static int hb_filter_alloc(u16_t src, u16_t dst) +static int hb_filter_alloc(uint16_t src, uint16_t dst) { int i; @@ -1631,7 +1631,7 @@ static int hb_filter_alloc(u16_t src, u16_t dst) return -ENOMEM; } -static int hb_filter_add(u16_t src, u16_t dst) +static int hb_filter_add(uint16_t src, uint16_t dst) { int i; @@ -1655,7 +1655,7 @@ static int hb_filter_add(u16_t src, u16_t dst) return hb_filter_alloc(src, dst); } -static int hb_filter_remove(u16_t src, u16_t dst) +static int hb_filter_remove(uint16_t src, uint16_t dst) { int i; @@ -1678,7 +1678,7 @@ static int hb_filter_remove(u16_t src, u16_t dst) return 0; } -int bt_mesh_provisioner_set_heartbeat_filter_info(u8_t op, u16_t src, u16_t dst) +int bt_mesh_provisioner_set_heartbeat_filter_info(uint8_t op, uint16_t src, uint16_t dst) { switch (op) { case HEARTBEAT_FILTER_ADD: @@ -1692,7 +1692,7 @@ int bt_mesh_provisioner_set_heartbeat_filter_info(u8_t op, u16_t src, u16_t dst) } static bool filter_with_rejectlist(struct heartbeat_filter *filter, - u16_t hb_src, u16_t hb_dst) + uint16_t hb_src, uint16_t hb_dst) { switch (filter->type) { case HEARTBEAT_FILTER_WITH_SRC: @@ -1719,7 +1719,7 @@ static bool filter_with_rejectlist(struct heartbeat_filter *filter, } static bool filter_with_acceptlist(struct heartbeat_filter *filter, - u16_t hb_src, u16_t hb_dst) + uint16_t hb_src, uint16_t hb_dst) { switch (filter->type) { case HEARTBEAT_FILTER_WITH_SRC: @@ -1745,9 +1745,9 @@ static bool filter_with_acceptlist(struct heartbeat_filter *filter, return true; } -void bt_mesh_provisioner_heartbeat(u16_t hb_src, u16_t hb_dst, - u8_t init_ttl, u8_t rx_ttl, - u8_t hops, u16_t feat, s8_t rssi) +void bt_mesh_provisioner_heartbeat(uint16_t hb_src, uint16_t hb_dst, + uint8_t init_ttl, uint8_t rx_ttl, + uint8_t hops, uint16_t feat, int8_t rssi) { int i; diff --git a/components/bt/esp_ble_mesh/mesh_core/provisioner_main.h b/components/bt/esp_ble_mesh/mesh_core/provisioner_main.h index 9523ff0c68..e631e8384a 100644 --- a/components/bt/esp_ble_mesh/mesh_core/provisioner_main.h +++ b/components/bt/esp_ble_mesh/mesh_core/provisioner_main.h @@ -28,23 +28,23 @@ extern "C" { /* Each node information stored by provisioner */ struct bt_mesh_node { /* Device information */ - u8_t addr[6]; /* Node device address */ - u8_t addr_type; /* Node device address type */ - u8_t dev_uuid[16]; /* Node Device UUID */ - u16_t oob_info; /* Node OOB information */ + uint8_t addr[6]; /* Node device address */ + uint8_t addr_type; /* Node device address type */ + uint8_t dev_uuid[16]; /* Node Device UUID */ + uint16_t oob_info; /* Node OOB information */ /* Provisioning information */ - u16_t unicast_addr; /* Node unicast address */ - u8_t element_num; /* Node element number */ - u16_t net_idx; /* Node NetKey Index */ - u8_t flags; /* Node key refresh flag and iv update flag */ - u32_t iv_index; /* Node IV Index */ - u8_t dev_key[16]; /* Node device key */ + uint16_t unicast_addr; /* Node unicast address */ + uint8_t element_num; /* Node element number */ + uint16_t net_idx; /* Node NetKey Index */ + uint8_t flags; /* Node key refresh flag and iv update flag */ + uint32_t iv_index; /* Node IV Index */ + uint8_t dev_key[16]; /* Node device key */ /* Additional information */ char name[BLE_MESH_NODE_NAME_SIZE + 1]; /* Node name */ - u16_t comp_length; /* Length of Composition Data */ - u8_t *comp_data; /* Value of Composition Data */ + uint16_t comp_length; /* Length of Composition Data */ + uint8_t *comp_data; /* Value of Composition Data */ } __packed; int bt_mesh_provisioner_init(void); @@ -55,91 +55,91 @@ void bt_mesh_provisioner_main_reset(bool erase); int bt_mesh_provisioner_deinit(bool erase); -bool bt_mesh_provisioner_check_is_addr_dup(u16_t addr, u8_t elem_num, bool comp_with_own); +bool bt_mesh_provisioner_check_is_addr_dup(uint16_t addr, uint8_t elem_num, bool comp_with_own); -u16_t bt_mesh_provisioner_get_node_count(void); +uint16_t bt_mesh_provisioner_get_node_count(void); int bt_mesh_provisioner_restore_node_info(struct bt_mesh_node *node); -int bt_mesh_provisioner_provision(const bt_mesh_addr_t *addr, const u8_t uuid[16], - u16_t oob_info, u16_t unicast_addr, - u8_t element_num, u16_t net_idx, - u8_t flags, u32_t iv_index, - const u8_t dev_key[16], u16_t *index); +int bt_mesh_provisioner_provision(const bt_mesh_addr_t *addr, const uint8_t uuid[16], + uint16_t oob_info, uint16_t unicast_addr, + uint8_t element_num, uint16_t net_idx, + uint8_t flags, uint32_t iv_index, + const uint8_t dev_key[16], uint16_t *index); -int bt_mesh_provisioner_remove_node(const u8_t uuid[16]); +int bt_mesh_provisioner_remove_node(const uint8_t uuid[16]); -int bt_mesh_provisioner_restore_node_name(u16_t addr, const char *name); +int bt_mesh_provisioner_restore_node_name(uint16_t addr, const char *name); -int bt_mesh_provisioner_restore_node_comp_data(u16_t addr, const u8_t *data, u16_t length); +int bt_mesh_provisioner_restore_node_comp_data(uint16_t addr, const uint8_t *data, uint16_t length); -struct bt_mesh_node *bt_mesh_provisioner_get_node_with_uuid(const u8_t uuid[16]); +struct bt_mesh_node *bt_mesh_provisioner_get_node_with_uuid(const uint8_t uuid[16]); -struct bt_mesh_node *bt_mesh_provisioner_get_node_with_addr(u16_t unicast_addr); +struct bt_mesh_node *bt_mesh_provisioner_get_node_with_addr(uint16_t unicast_addr); -int bt_mesh_provisioner_delete_node_with_uuid(const u8_t uuid[16]); +int bt_mesh_provisioner_delete_node_with_uuid(const uint8_t uuid[16]); -int bt_mesh_provisioner_delete_node_with_node_addr(u16_t unicast_addr); +int bt_mesh_provisioner_delete_node_with_node_addr(uint16_t unicast_addr); int bt_mesh_provisioner_delete_node_with_dev_addr(const bt_mesh_addr_t *addr); -int bt_mesh_provisioner_set_node_name(u16_t index, const char *name); +int bt_mesh_provisioner_set_node_name(uint16_t index, const char *name); -const char *bt_mesh_provisioner_get_node_name(u16_t index); +const char *bt_mesh_provisioner_get_node_name(uint16_t index); -u16_t bt_mesh_provisioner_get_node_index(const char *name); +uint16_t bt_mesh_provisioner_get_node_index(const char *name); struct bt_mesh_node *bt_mesh_provisioner_get_node_with_name(const char *name); const struct bt_mesh_node **bt_mesh_provisioner_get_node_table_entry(void); -int bt_mesh_provisioner_store_node_comp_data(u16_t addr, const u8_t *data, u16_t length); +int bt_mesh_provisioner_store_node_comp_data(uint16_t addr, const uint8_t *data, uint16_t length); -const u8_t *bt_mesh_provisioner_net_key_get(u16_t net_idx); +const uint8_t *bt_mesh_provisioner_net_key_get(uint16_t net_idx); -struct bt_mesh_subnet *bt_mesh_provisioner_subnet_get(u16_t net_idx); +struct bt_mesh_subnet *bt_mesh_provisioner_subnet_get(uint16_t net_idx); -bool bt_mesh_provisioner_check_msg_dst(u16_t dst); +bool bt_mesh_provisioner_check_msg_dst(uint16_t dst); -const u8_t *bt_mesh_provisioner_dev_key_get(u16_t dst); +const uint8_t *bt_mesh_provisioner_dev_key_get(uint16_t dst); -struct bt_mesh_app_key *bt_mesh_provisioner_app_key_find(u16_t app_idx); +struct bt_mesh_app_key *bt_mesh_provisioner_app_key_find(uint16_t app_idx); -int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], - u16_t net_idx, u16_t *app_idx); +int bt_mesh_provisioner_local_app_key_add(const uint8_t app_key[16], + uint16_t net_idx, uint16_t *app_idx); -int bt_mesh_provisioner_local_app_key_update(const u8_t app_key[16], - u16_t net_idx, u16_t app_idx); +int bt_mesh_provisioner_local_app_key_update(const uint8_t app_key[16], + uint16_t net_idx, uint16_t app_idx); -const u8_t *bt_mesh_provisioner_local_app_key_get(u16_t net_idx, u16_t app_idx); +const uint8_t *bt_mesh_provisioner_local_app_key_get(uint16_t net_idx, uint16_t app_idx); -int bt_mesh_provisioner_local_app_key_del(u16_t net_idx, u16_t app_idx, bool store); +int bt_mesh_provisioner_local_app_key_del(uint16_t net_idx, uint16_t app_idx, bool store); -int bt_mesh_provisioner_local_net_key_add(const u8_t net_key[16], u16_t *net_idx); +int bt_mesh_provisioner_local_net_key_add(const uint8_t net_key[16], uint16_t *net_idx); -int bt_mesh_provisioner_local_net_key_update(const u8_t net_key[16], u16_t net_idx); +int bt_mesh_provisioner_local_net_key_update(const uint8_t net_key[16], uint16_t net_idx); -const u8_t *bt_mesh_provisioner_local_net_key_get(u16_t net_idx); +const uint8_t *bt_mesh_provisioner_local_net_key_get(uint16_t net_idx); -int bt_mesh_provisioner_local_net_key_del(u16_t net_idx, bool store); +int bt_mesh_provisioner_local_net_key_del(uint16_t net_idx, bool store); /* Provisioner bind local client model with proper appkey index */ -int bt_mesh_provisioner_bind_local_model_app_idx(u16_t elem_addr, u16_t mod_id, - u16_t cid, u16_t app_idx); +int bt_mesh_provisioner_bind_local_model_app_idx(uint16_t elem_addr, uint16_t mod_id, + uint16_t cid, uint16_t app_idx); -typedef void (* bt_mesh_heartbeat_recv_cb_t)(u16_t hb_src, u16_t hb_dst, - u8_t init_ttl, u8_t rx_ttl, - u8_t hops, u16_t feat, s8_t rssi); +typedef void (* bt_mesh_heartbeat_recv_cb_t)(uint16_t hb_src, uint16_t hb_dst, + uint8_t init_ttl, uint8_t rx_ttl, + uint8_t hops, uint16_t feat, int8_t rssi); int bt_mesh_provisioner_recv_heartbeat(bt_mesh_heartbeat_recv_cb_t cb); -int bt_mesh_provisioner_set_heartbeat_filter_type(u8_t filter_type); +int bt_mesh_provisioner_set_heartbeat_filter_type(uint8_t filter_type); -int bt_mesh_provisioner_set_heartbeat_filter_info(u8_t op, u16_t src, u16_t dst); +int bt_mesh_provisioner_set_heartbeat_filter_info(uint8_t op, uint16_t src, uint16_t dst); -void bt_mesh_provisioner_heartbeat(u16_t hb_src, u16_t hb_dst, - u8_t init_ttl, u8_t rx_ttl, - u8_t hops, u16_t feat, s8_t rssi); +void bt_mesh_provisioner_heartbeat(uint16_t hb_src, uint16_t hb_dst, + uint8_t init_ttl, uint8_t rx_ttl, + uint8_t hops, uint16_t feat, int8_t rssi); /* Provisioner print own element information */ int bt_mesh_print_local_composition_data(void); diff --git a/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c b/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c index fc4fcf8095..479ebfeef5 100644 --- a/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c +++ b/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c @@ -128,59 +128,59 @@ enum { */ struct prov_link { BLE_MESH_ATOMIC_DEFINE(flags, NUM_FLAGS); - u8_t uuid[16]; /* check if device is being provisioned*/ - u16_t oob_info; /* oob info of this device */ - u8_t element_num; /* element num of device */ - u8_t ki_flags; /* Key refresh flag and iv update flag */ - u32_t iv_index; /* IV Index */ - u8_t auth_method; /* Choosen authentication method */ - u8_t auth_action; /* Choosen authentication action */ - u8_t auth_size; /* Choosen authentication size */ - u16_t assign_addr; /* Application assigned address for the device */ - u16_t unicast_addr; /* unicast address allocated for device */ - bt_mesh_addr_t addr; /* Device address */ + uint8_t uuid[16]; /* check if device is being provisioned*/ + uint16_t oob_info; /* oob info of this device */ + uint8_t element_num; /* element num of device */ + uint8_t ki_flags; /* Key refresh flag and iv update flag */ + uint32_t iv_index; /* IV Index */ + uint8_t auth_method; /* Choosen authentication method */ + uint8_t auth_action; /* Choosen authentication action */ + uint8_t auth_size; /* Choosen authentication size */ + uint16_t assign_addr; /* Application assigned address for the device */ + uint16_t unicast_addr; /* unicast address allocated for device */ + bt_mesh_addr_t addr; /* Device address */ #if defined(CONFIG_BLE_MESH_PB_GATT) - bool connecting; /* start connecting with device */ - struct bt_mesh_conn *conn; /* GATT connection */ + bool connecting; /* start connecting with device */ + struct bt_mesh_conn *conn; /* GATT connection */ #endif - u8_t expect; /* Next expected PDU */ + uint8_t expect; /* Next expected PDU */ - u8_t *dhkey; /* Calculated DHKey */ - u8_t *auth; /* Authentication Value */ + uint8_t *dhkey; /* Calculated DHKey */ + uint8_t *auth; /* Authentication Value */ - u8_t *conf_salt; /* ConfirmationSalt */ - u8_t *conf_key; /* ConfirmationKey */ - u8_t *conf_inputs; /* ConfirmationInputs */ + uint8_t *conf_salt; /* ConfirmationSalt */ + uint8_t *conf_key; /* ConfirmationKey */ + uint8_t *conf_inputs; /* ConfirmationInputs */ - u8_t *rand; /* Local Random */ - u8_t *conf; /* Remote Confirmation */ + uint8_t *rand; /* Local Random */ + uint8_t *conf; /* Remote Confirmation */ - u8_t *prov_salt; /* Provisioning Salt */ + uint8_t *prov_salt; /* Provisioning Salt */ #if defined(CONFIG_BLE_MESH_PB_ADV) - bool linking; /* Linking is being establishing */ - u16_t send_link_close; /* Link close is being sent flag */ - u32_t link_id; /* Link ID */ - u8_t pending_ack; /* Decide which transaction id ack is pending */ - u8_t expect_ack_for; /* Transaction ACK expected for provisioning pdu */ - u8_t tx_pdu_type; /* The current transmitted Provisioning PDU type */ + bool linking; /* Linking is being establishing */ + uint16_t send_link_close; /* Link close is being sent flag */ + uint32_t link_id; /* Link ID */ + uint8_t pending_ack; /* Decide which transaction id ack is pending */ + uint8_t expect_ack_for; /* Transaction ACK expected for provisioning pdu */ + uint8_t tx_pdu_type; /* The current transmitted Provisioning PDU type */ struct { - u8_t trans_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 */ - u8_t adv_buf_id; /* index of buf allocated in adv_buf_data */ + uint8_t trans_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 */ + uint8_t adv_buf_id; /* index of buf allocated in adv_buf_data */ struct net_buf_simple *buf; } rx; struct { /* Start timestamp of the transaction */ - s64_t start; + int64_t start; /* Transaction id*/ - u8_t trans_id; + uint8_t trans_id; /* Pending outgoing buffer(s) */ struct net_buf *buf[3]; @@ -206,56 +206,56 @@ struct prov_link { static struct prov_link link[BLE_MESH_PROV_SAME_TIME]; 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; }; struct bt_mesh_prov_ctx { /* Primary element address of Provisioner */ - u16_t primary_addr; + uint16_t primary_addr; /* Provisioning bearers used by Provisioner */ bt_mesh_prov_bearer_t bearers; /* If provisioning random have been generated, set BIT0 to 1 */ - u8_t rand_gen_done; + uint8_t rand_gen_done; /* Provisioner random */ - u8_t random[16]; + uint8_t random[16]; /* Current number of PB-ADV provisioned devices simultaneously */ - u8_t pba_count; + uint8_t pba_count; /* Current number of PB-GATT provisioned devices simultaneously */ - u8_t pbg_count; + uint8_t pbg_count; /* Current unicast address going to allocated */ - u16_t curr_alloc_addr; + uint16_t curr_alloc_addr; /* Current net_idx going to be used in provisioning data */ - u16_t curr_net_idx; + uint16_t curr_net_idx; /* Current flags going to be used in provisioning data */ - u8_t curr_flags; + uint8_t curr_flags; /* Current iv_index going to be used in provisioning data */ - u16_t curr_iv_index; + uint16_t curr_iv_index; /* Length of Static OOB value */ - u8_t static_oob_len; + uint8_t static_oob_len; /* Static OOB value */ - u8_t static_oob_val[16]; + uint8_t static_oob_val[16]; /* Offset of the device uuid to be matched, based on zero */ - u8_t match_offset; + uint8_t match_offset; /* Length of the device uuid to be matched (start from the match_offset) */ - u8_t match_length; + uint8_t match_length; /* Value of the device uuid to be matched */ - u8_t match_value[16]; + uint8_t match_value[16]; /* Indicate when received uuid_match adv_pkts, can provision it at once */ bool prov_after_match; @@ -275,12 +275,12 @@ struct bt_mesh_prov_ctx { /* Fast provisioning related information */ struct { - bool enable; - u16_t net_idx; - u8_t flags; - u32_t iv_index; - u16_t unicast_addr_min; - u16_t unicast_addr_max; + bool enable; + uint16_t net_idx; + uint8_t flags; + uint32_t iv_index; + uint16_t unicast_addr_min; + uint16_t unicast_addr_max; } fast_prov; }; @@ -290,10 +290,10 @@ static struct bt_mesh_prov_ctx prov_ctx; struct unprov_dev_queue { bt_mesh_addr_t addr; - u8_t uuid[16]; - u16_t oob_info; - u8_t bearer; - u8_t flags; + uint8_t uuid[16]; + uint16_t oob_info; + uint8_t bearer; + uint8_t flags; } __packed unprov_dev[CONFIG_BLE_MESH_WAIT_FOR_PROV_MAX_DEV_NUM] = { [0 ... (CONFIG_BLE_MESH_WAIT_FOR_PROV_MAX_DEV_NUM - 1)] = { .addr.type = 0xff, @@ -328,14 +328,14 @@ static unprov_adv_pkt_cb_t notify_unprov_adv_pkt_cb; static const struct bt_mesh_prov *prov; #if defined(CONFIG_BLE_MESH_PB_ADV) -static void send_link_open(const u8_t idx); +static void send_link_open(const uint8_t idx); #endif -static void prov_gen_dh_key(const u8_t idx); +static void prov_gen_dh_key(const uint8_t idx); -static void send_pub_key(const u8_t idx, u8_t oob); +static void send_pub_key(const uint8_t idx, uint8_t oob); -static void close_link(const u8_t idx, u8_t reason); +static void close_link(const uint8_t idx, uint8_t reason); #if defined(CONFIG_BLE_MESH_PB_ADV) #define ADV_BUF_SIZE 65 @@ -344,7 +344,7 @@ static struct prov_adv_buf { struct net_buf_simple buf; } adv_buf[CONFIG_BLE_MESH_PBA_SAME_TIME]; -static u8_t adv_buf_data[ADV_BUF_SIZE * CONFIG_BLE_MESH_PBA_SAME_TIME]; +static uint8_t adv_buf_data[ADV_BUF_SIZE * CONFIG_BLE_MESH_PBA_SAME_TIME]; #endif /* CONFIG_BLE_MESH_PB_ADV */ #define PROV_FREE_MEM(_idx, member) \ @@ -442,7 +442,7 @@ static inline void provisioner_pbg_count_inc(void) prov_ctx.pbg_count++; } -void bt_mesh_provisioner_clear_link_info(const u8_t addr[6]) +void bt_mesh_provisioner_clear_link_info(const uint8_t addr[6]) { int i; @@ -478,13 +478,13 @@ const struct bt_mesh_prov *bt_mesh_provisioner_get_prov_info(void) return prov; } -void bt_mesh_provisioner_restore_prov_info(u16_t primary_addr, u16_t alloc_addr) +void bt_mesh_provisioner_restore_prov_info(uint16_t primary_addr, uint16_t alloc_addr) { prov_ctx.primary_addr = primary_addr; prov_ctx.curr_alloc_addr = alloc_addr; } -static bool is_unprov_dev_being_provision(const u8_t uuid[16]) +static bool is_unprov_dev_being_provision(const uint8_t uuid[16]) { int i; @@ -521,7 +521,7 @@ static bool is_unprov_dev_being_provision(const u8_t uuid[16]) return false; } -static bool is_unprov_dev_uuid_match(const u8_t uuid[16]) +static bool is_unprov_dev_uuid_match(const uint8_t uuid[16]) { if (prov_ctx.match_length) { if (memcmp(uuid + prov_ctx.match_offset, @@ -533,7 +533,7 @@ static bool is_unprov_dev_uuid_match(const u8_t uuid[16]) return true; } -static int provisioner_check_unprov_dev_info(const u8_t uuid[16], bt_mesh_prov_bearer_t bearer) +static int provisioner_check_unprov_dev_info(const uint8_t uuid[16], bt_mesh_prov_bearer_t bearer) { if (!uuid) { BT_ERR("%s, Invalid parameter", __func__); @@ -583,8 +583,8 @@ static int provisioner_check_unprov_dev_info(const u8_t uuid[16], bt_mesh_prov_b } #if defined(CONFIG_BLE_MESH_PB_ADV) -static int provisioner_start_prov_pb_adv(const u8_t uuid[16], const bt_mesh_addr_t *addr, - u16_t oob_info, u16_t assign_addr) +static int provisioner_start_prov_pb_adv(const uint8_t uuid[16], const bt_mesh_addr_t *addr, + uint16_t oob_info, uint16_t assign_addr) { int i; @@ -644,8 +644,8 @@ static int provisioner_start_prov_pb_adv(const u8_t uuid[16], const bt_mesh_addr #endif /* CONFIG_BLE_MESH_PB_ADV */ #if defined(CONFIG_BLE_MESH_PB_GATT) -static int provisioner_start_prov_pb_gatt(const u8_t uuid[16], const bt_mesh_addr_t *addr, - u16_t oob_info, u16_t assign_addr) +static int provisioner_start_prov_pb_gatt(const uint8_t uuid[16], const bt_mesh_addr_t *addr, + uint16_t oob_info, uint16_t assign_addr) { int i; @@ -708,11 +708,11 @@ static int provisioner_start_prov_pb_gatt(const u8_t uuid[16], const bt_mesh_add } #endif /* CONFIG_BLE_MESH_PB_GATT */ -int bt_mesh_provisioner_add_unprov_dev(struct bt_mesh_unprov_dev_add *add_dev, u8_t flags) +int bt_mesh_provisioner_add_unprov_dev(struct bt_mesh_unprov_dev_add *add_dev, uint8_t flags) { bt_mesh_addr_t add_addr = {0}; bool addr_valid = false; - u8_t zero[16] = {0}; + uint8_t zero[16] = {0}; int err = 0; int i; @@ -858,9 +858,9 @@ start: return 0; } -int bt_mesh_provisioner_prov_device_with_addr(const u8_t uuid[16], const u8_t addr[6], - u8_t addr_type, bt_mesh_prov_bearer_t bearer, - u16_t oob_info, u16_t unicast_addr) +int bt_mesh_provisioner_prov_device_with_addr(const uint8_t uuid[16], const uint8_t addr[6], + uint8_t addr_type, bt_mesh_prov_bearer_t bearer, + uint16_t oob_info, uint16_t unicast_addr) { bt_mesh_addr_t dev_addr = {0}; int err = 0; @@ -951,7 +951,7 @@ int bt_mesh_provisioner_prov_device_with_addr(const u8_t uuid[16], const u8_t ad int bt_mesh_provisioner_delete_device(struct bt_mesh_device_delete *del_dev) { - u8_t zero[16] = {0}; + uint8_t zero[16] = {0}; int i; if (del_dev == NULL) { @@ -983,8 +983,8 @@ int bt_mesh_provisioner_delete_device(struct bt_mesh_device_delete *del_dev) return 0; } -int bt_mesh_provisioner_set_dev_uuid_match(u8_t offset, u8_t length, - const u8_t *match, bool prov_flag) +int bt_mesh_provisioner_set_dev_uuid_match(uint8_t offset, uint8_t length, + const uint8_t *match, bool prov_flag) { if (length && (!match || (offset + length > 16))) { BT_ERR("%s, Invalid parameter", __func__); @@ -1016,7 +1016,7 @@ int bt_mesh_provisioner_adv_pkt_cb_register(unprov_adv_pkt_cb_t cb) int bt_mesh_provisioner_set_prov_data_info(struct bt_mesh_prov_data_info *info) { - const u8_t *key = NULL; + const uint8_t *key = NULL; if (!info || info->flag == 0) { return -EINVAL; @@ -1100,7 +1100,7 @@ bt_mesh_prov_bearer_t bt_mesh_provisioner_get_prov_bearer(void) return prov_ctx.bearers; } -int bt_mesh_provisioner_set_static_oob_value(const u8_t *value, u8_t length) +int bt_mesh_provisioner_set_static_oob_value(const uint8_t *value, uint8_t length) { int i; @@ -1125,12 +1125,12 @@ int bt_mesh_provisioner_set_static_oob_value(const u8_t *value, u8_t length) return 0; } -u16_t bt_mesh_provisioner_get_primary_elem_addr(void) +uint16_t bt_mesh_provisioner_get_primary_elem_addr(void) { return prov_ctx.primary_addr; } -int bt_mesh_provisioner_set_primary_elem_addr(u16_t addr) +int bt_mesh_provisioner_set_primary_elem_addr(uint16_t addr) { const struct bt_mesh_comp *comp = NULL; @@ -1172,9 +1172,9 @@ int bt_mesh_provisioner_set_primary_elem_addr(u16_t addr) } #if CONFIG_BLE_MESH_TEST_AUTO_ENTER_NETWORK -int bt_mesh_test_provisioner_update_alloc_addr(u16_t unicast_addr, u16_t element_num) +int bt_mesh_test_provisioner_update_alloc_addr(uint16_t unicast_addr, uint16_t element_num) { - u16_t max_addr = FAST_PROV_ENABLE() ? prov_ctx.fast_prov.unicast_addr_max : PROV_MAX_ADDR_TO_ASSIGN; + uint16_t max_addr = FAST_PROV_ENABLE() ? prov_ctx.fast_prov.unicast_addr_max : PROV_MAX_ADDR_TO_ASSIGN; if (unicast_addr + element_num > max_addr) { BT_WARN("Not enough unicast address to allocate"); @@ -1198,17 +1198,17 @@ void bt_mesh_provisioner_fast_prov_enable(bool enable) prov_ctx.fast_prov.enable = enable; } -void bt_mesh_provisioner_set_fast_prov_net_idx(u16_t net_idx) +void bt_mesh_provisioner_set_fast_prov_net_idx(uint16_t net_idx) { prov_ctx.fast_prov.net_idx = net_idx; } -u16_t bt_mesh_provisioner_get_fast_prov_net_idx(void) +uint16_t bt_mesh_provisioner_get_fast_prov_net_idx(void) { return prov_ctx.fast_prov.net_idx; } -u8_t bt_mesh_set_fast_prov_unicast_addr_range(u16_t min, u16_t max) +uint8_t bt_mesh_set_fast_prov_unicast_addr_range(uint16_t min, uint16_t max) { if (!BLE_MESH_ADDR_IS_UNICAST(min) || !BLE_MESH_ADDR_IS_UNICAST(max)) { BT_ERR("Invalid unicast address, min 0x%04x, max 0x%04x", min, max); @@ -1233,7 +1233,7 @@ u8_t bt_mesh_set_fast_prov_unicast_addr_range(u16_t min, u16_t max) return 0x0; /* status: success */ } -void bt_mesh_set_fast_prov_flags_iv_index(u8_t flags, u32_t iv_index) +void bt_mesh_set_fast_prov_flags_iv_index(uint8_t flags, uint32_t iv_index) { /* BIT0: Key Refresh flag, BIT1: IV Update flag */ prov_ctx.fast_prov.flags = flags & BIT_MASK(2); @@ -1241,7 +1241,7 @@ void bt_mesh_set_fast_prov_flags_iv_index(u8_t flags, u32_t iv_index) } #if defined(CONFIG_BLE_MESH_PB_ADV) -static struct net_buf_simple *bt_mesh_pba_get_buf(const u8_t idx) +static struct net_buf_simple *bt_mesh_pba_get_buf(const uint8_t idx) { struct net_buf_simple *buf = &(adv_buf[idx].buf); @@ -1251,7 +1251,7 @@ static struct net_buf_simple *bt_mesh_pba_get_buf(const u8_t idx) } #endif /* CONFIG_BLE_MESH_PB_ADV */ -static void prov_memory_free(const u8_t idx) +static void prov_memory_free(const uint8_t idx) { PROV_FREE_MEM(idx, dhkey); PROV_FREE_MEM(idx, auth); @@ -1265,7 +1265,7 @@ static void prov_memory_free(const u8_t idx) #if defined(CONFIG_BLE_MESH_PB_ADV) static void buf_sent(int err, void *user_data) { - u8_t idx = (int)user_data; + uint8_t idx = (int)user_data; if (!link[idx].tx.buf[0]) { return; @@ -1278,7 +1278,7 @@ static struct bt_mesh_send_cb buf_sent_cb = { .end = buf_sent, }; -static void free_segments(const u8_t idx) +static void free_segments(const uint8_t idx) { int i; @@ -1301,7 +1301,7 @@ static void free_segments(const u8_t idx) bt_mesh_pb_buf_unlock(); } -static void prov_clear_tx(const u8_t idx) +static void prov_clear_tx(const uint8_t idx) { BT_DBG("%s", __func__); @@ -1310,7 +1310,7 @@ static void prov_clear_tx(const u8_t idx) free_segments(idx); } -static void reset_link(const u8_t idx, u8_t reason) +static void reset_link(const uint8_t idx, uint8_t reason) { prov_clear_tx(idx); @@ -1360,16 +1360,16 @@ static struct net_buf *adv_buf_create(void) 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) { - u8_t idx = (int)user_data; + uint8_t idx = (int)user_data; BT_DBG("xact %u complete", link[idx].pending_ack); link[idx].pending_ack = XACT_NVAL; } -static void gen_prov_ack_send(const u8_t idx, u8_t xact_id) +static void gen_prov_ack_send(const uint8_t idx, uint8_t xact_id) { static const struct bt_mesh_send_cb cb = { .start = ack_complete, @@ -1404,7 +1404,7 @@ static void gen_prov_ack_send(const u8_t idx, u8_t xact_id) net_buf_unref(buf); } -static void send_reliable(const u8_t idx) +static void send_reliable(const uint8_t idx) { int i; @@ -1425,7 +1425,7 @@ static void send_reliable(const u8_t idx) } } -static int bearer_ctl_send(const u8_t idx, u8_t op, void *data, u8_t data_len) +static int bearer_ctl_send(const uint8_t idx, uint8_t op, void *data, uint8_t data_len) { struct net_buf *buf = NULL; @@ -1454,7 +1454,7 @@ static int bearer_ctl_send(const u8_t idx, u8_t op, void *data, u8_t data_len) * link close pdu, so we add link[i].tx.id = 0 */ if (op == LINK_CLOSE) { - u8_t reason = *(u8_t *)data; + uint8_t reason = *(uint8_t *)data; link[idx].send_link_close = ((reason & BIT_MASK(2)) << 1) | BIT(0); link[idx].tx.trans_id = 0; } @@ -1462,19 +1462,19 @@ static int bearer_ctl_send(const u8_t idx, u8_t op, void *data, u8_t data_len) return 0; } -static void send_link_open(const u8_t idx) +static void send_link_open(const uint8_t idx) { int j; /** Generate link ID, and may need to check if this id is * currently being used, which may will not happen ever. */ - bt_mesh_rand(&link[idx].link_id, sizeof(u32_t)); + bt_mesh_rand(&link[idx].link_id, sizeof(uint32_t)); while (1) { for (j = 0; j < CONFIG_BLE_MESH_PBA_SAME_TIME; j++) { if (bt_mesh_atomic_test_bit(link[j].flags, LINK_ACTIVE) || link[j].linking) { if (link[idx].link_id == link[j].link_id) { - bt_mesh_rand(&link[idx].link_id, sizeof(u32_t)); + bt_mesh_rand(&link[idx].link_id, sizeof(uint32_t)); break; } } @@ -1510,7 +1510,7 @@ static void send_link_open(const u8_t idx) } } -static u8_t last_seg(u8_t len) +static uint8_t last_seg(uint8_t len) { if (len <= START_PAYLOAD_MAX) { return 0; @@ -1521,7 +1521,7 @@ static u8_t last_seg(u8_t len) return 1 + (len / CONT_PAYLOAD_MAX); } -static inline u8_t next_transaction_id(const u8_t idx) +static inline uint8_t next_transaction_id(const uint8_t idx) { if (link[idx].tx.trans_id > 0x7F) { link[idx].tx.trans_id = 0x0; @@ -1529,12 +1529,12 @@ static inline u8_t next_transaction_id(const u8_t idx) return link[idx].tx.trans_id++; } -static int prov_send_adv(const u8_t idx, struct net_buf_simple *msg) +static int prov_send_adv(const uint8_t idx, struct net_buf_simple *msg) { struct net_buf *start = NULL, *buf = NULL; - u8_t seg_len = 0U, seg_id = 0U; - u8_t xact_id = 0U; - s32_t timeout = PROVISION_TIMEOUT; + uint8_t seg_len = 0U, seg_id = 0U; + uint8_t xact_id = 0U; + int32_t timeout = PROVISION_TIMEOUT; BT_DBG("len %u: %s", msg->len, bt_hex(msg->data, msg->len)); @@ -1606,7 +1606,7 @@ static int prov_send_adv(const u8_t idx, struct net_buf_simple *msg) #endif /* CONFIG_BLE_MESH_PB_ADV */ #if defined(CONFIG_BLE_MESH_PB_GATT) -static int prov_send_gatt(const u8_t idx, struct net_buf_simple *msg) +static int prov_send_gatt(const uint8_t idx, struct net_buf_simple *msg) { int err = 0; @@ -1628,7 +1628,7 @@ static int prov_send_gatt(const u8_t idx, struct net_buf_simple *msg) } #endif /* CONFIG_BLE_MESH_PB_GATT */ -static inline int prov_send(const u8_t idx, struct net_buf_simple *buf) +static inline int prov_send(const uint8_t idx, struct net_buf_simple *buf) { #if defined(CONFIG_BLE_MESH_PB_ADV) if (idx < CONFIG_BLE_MESH_PBA_SAME_TIME) { @@ -1650,28 +1650,28 @@ static inline int prov_send(const u8_t idx, struct net_buf_simple *buf) return -EINVAL; } -static void prov_buf_init(struct net_buf_simple *buf, u8_t type) +static void prov_buf_init(struct net_buf_simple *buf, uint8_t type) { net_buf_simple_reserve(buf, PROV_BUF_HEADROOM); net_buf_simple_add_u8(buf, type); } -static void prov_invite(const u8_t idx, const u8_t *data) +static void prov_invite(const uint8_t idx, const uint8_t *data) { BT_DBG("%s", __func__); } -static void prov_start(const u8_t idx, const u8_t *data) +static void prov_start(const uint8_t idx, const uint8_t *data) { BT_DBG("%s", __func__); } -static void prov_data(const u8_t idx, const u8_t *data) +static void prov_data(const uint8_t idx, const uint8_t *data) { BT_DBG("%s", __func__); } -static void send_invite(const u8_t idx) +static void send_invite(const uint8_t idx) { PROV_BUF(buf, 2); @@ -1690,13 +1690,13 @@ static void send_invite(const u8_t idx) link[idx].expect = PROV_CAPABILITIES; } -static void prov_capabilities(const u8_t idx, const u8_t *data) +static void prov_capabilities(const uint8_t idx, const uint8_t *data) { PROV_BUF(buf, 6); - u16_t algorithms = 0U, output_action = 0U, input_action = 0U; - u8_t element_num = 0U, pub_key_oob = 0U, static_oob = 0U, - output_size = 0U, input_size = 0U; - u8_t auth_method = 0U, auth_action = 0U, auth_size = 0U; + uint16_t algorithms = 0U, output_action = 0U, input_action = 0U; + uint8_t element_num = 0U, pub_key_oob = 0U, static_oob = 0U, + output_size = 0U, input_size = 0U; + uint8_t auth_method = 0U, auth_action = 0U, auth_size = 0U; element_num = data[0]; BT_INFO("Elements: 0x%02x", element_num); @@ -1791,11 +1791,11 @@ static void prov_capabilities(const u8_t idx, const u8_t *data) auth_size = 0x00; } else if (!output_size && input_size) { auth_method = AUTH_METHOD_INPUT; - auth_action = (u8_t)input_action; + auth_action = (uint8_t)input_action; auth_size = input_size; } else { auth_method = AUTH_METHOD_OUTPUT; - auth_action = (u8_t)output_action; + auth_action = (uint8_t)output_action; auth_size = output_size; } } @@ -1850,7 +1850,7 @@ fail: return; } -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: @@ -1868,7 +1868,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: @@ -1884,12 +1884,12 @@ static bt_mesh_input_action_t input_action(u8_t action) } } -static int prov_auth(const u8_t idx, u8_t method, u8_t action, u8_t size) +static int prov_auth(const uint8_t idx, uint8_t method, uint8_t action, uint8_t size) { bt_mesh_output_action_t output = 0U; bt_mesh_input_action_t input = 0U; - link[idx].auth = (u8_t *)bt_mesh_calloc(PROV_AUTH_VAL_SIZE); + link[idx].auth = (uint8_t *)bt_mesh_calloc(PROV_AUTH_VAL_SIZE); if (!link[idx].auth) { BT_ERR("%s, Out of memory", __func__); close_link(idx, CLOSE_REASON_FAILED); @@ -1933,7 +1933,7 @@ static int prov_auth(const u8_t idx, u8_t method, u8_t action, u8_t size) if (input == BLE_MESH_ENTER_STRING) { unsigned char str[9] = {'\0'}; - u8_t j = 0U; + uint8_t j = 0U; bt_mesh_rand(str, size); @@ -1953,8 +1953,8 @@ static int prov_auth(const u8_t idx, u8_t method, u8_t action, u8_t size) return prov->prov_output_num(AUTH_METHOD_INPUT, input, str, size, idx); } else { - u32_t div[8] = { 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000 }; - u32_t num = 0U; + uint32_t div[8] = { 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000 }; + uint32_t num = 0U; bt_mesh_rand(&num, sizeof(num)); num %= div[size - 1]; @@ -1970,7 +1970,7 @@ static int prov_auth(const u8_t idx, u8_t method, u8_t action, u8_t size) } } -static void send_confirm(const u8_t idx) +static void send_confirm(const uint8_t idx) { PROV_BUF(buf, 17); @@ -1978,13 +1978,13 @@ static void send_confirm(const u8_t idx) BT_DBG("ConfInputs[64] %s", bt_hex(link[idx].conf_inputs + 64, 64)); BT_DBG("ConfInputs[128] %s", bt_hex(link[idx].conf_inputs + 128, 17)); - link[idx].conf_salt = (u8_t *)bt_mesh_calloc(PROV_CONF_SALT_SIZE); + link[idx].conf_salt = (uint8_t *)bt_mesh_calloc(PROV_CONF_SALT_SIZE); if (!link[idx].conf_salt) { BT_ERR("%s, Out of memory", __func__); goto fail; } - link[idx].conf_key = (u8_t *)bt_mesh_calloc(PROV_CONF_KEY_SIZE); + link[idx].conf_key = (uint8_t *)bt_mesh_calloc(PROV_CONF_KEY_SIZE); if (!link[idx].conf_key) { BT_ERR("%s, Out of memory", __func__); goto fail; @@ -2043,7 +2043,7 @@ fail: return; } -int bt_mesh_provisioner_set_oob_input_data(const u8_t idx, const u8_t *val, bool num_flag) +int bt_mesh_provisioner_set_oob_input_data(const uint8_t idx, const uint8_t *val, bool num_flag) { /** This function should be called in the prov_input_num * callback, after the data output by device has been @@ -2065,7 +2065,7 @@ int bt_mesh_provisioner_set_oob_input_data(const u8_t idx, const u8_t *val, bool memset(link[idx].auth, 0, 16); if (num_flag) { /* Provisioner inputs number */ - memcpy(link[idx].auth + 12, val, sizeof(u32_t)); + memcpy(link[idx].auth + 12, val, sizeof(uint32_t)); } else { /* Provisioner inputs string */ memcpy(link[idx].auth, val, link[idx].auth_size); @@ -2075,8 +2075,8 @@ int bt_mesh_provisioner_set_oob_input_data(const u8_t idx, const u8_t *val, bool return 0; } -int bt_mesh_provisioner_set_oob_output_data(const u8_t idx, const u8_t *num, - u8_t size, bool num_flag) +int bt_mesh_provisioner_set_oob_output_data(const uint8_t idx, const uint8_t *num, + uint8_t size, bool num_flag) { /** This function should be called in the prov_output_num * callback, after the data has been output by provisioner. @@ -2114,8 +2114,8 @@ int bt_mesh_provisioner_set_oob_output_data(const u8_t idx, const u8_t *num, return 0; } -int bt_mesh_provisioner_read_oob_pub_key(const u8_t idx, const u8_t pub_key_x[32], - const u8_t pub_key_y[32]) +int bt_mesh_provisioner_read_oob_pub_key(const uint8_t idx, const uint8_t pub_key_x[32], + const uint8_t pub_key_y[32]) { if (!link[idx].conf_inputs) { BT_ERR("Invalid link conf_inputs"); @@ -2135,7 +2135,7 @@ int bt_mesh_provisioner_read_oob_pub_key(const u8_t idx, const u8_t pub_key_x[32 return 0; } -static void prov_dh_key_cb(const u8_t key[32], const u8_t idx) +static void prov_dh_key_cb(const uint8_t key[32], const uint8_t idx) { BT_DBG("%p", key); @@ -2144,7 +2144,7 @@ static void prov_dh_key_cb(const u8_t key[32], const u8_t idx) goto fail; } - link[idx].dhkey = (u8_t *)bt_mesh_calloc(PROV_DH_KEY_SIZE); + link[idx].dhkey = (uint8_t *)bt_mesh_calloc(PROV_DH_KEY_SIZE); if (!link[idx].dhkey) { BT_ERR("%s, Out of memory", __func__); goto fail; @@ -2182,9 +2182,9 @@ fail: return; } -static void prov_gen_dh_key(const u8_t idx) +static void prov_gen_dh_key(const uint8_t idx) { - u8_t pub_key[64] = {0}; + uint8_t pub_key[64] = {0}; /* Copy device public key in little-endian for bt_mesh_dh_key_gen(). * X and Y halves are swapped independently. @@ -2199,10 +2199,10 @@ static void prov_gen_dh_key(const u8_t idx) } } -static void send_pub_key(const u8_t idx, u8_t oob) +static void send_pub_key(const uint8_t idx, uint8_t oob) { PROV_BUF(buf, 65); - const u8_t *key = NULL; + const uint8_t *key = NULL; key = bt_mesh_pub_key_get(); if (!key) { @@ -2256,7 +2256,7 @@ static void send_pub_key(const u8_t idx, u8_t oob) } } -static void prov_pub_key(const u8_t idx, const u8_t *data) +static void prov_pub_key(const uint8_t idx, const uint8_t *data) { BT_DBG("Remote Public Key: %s", bt_hex(data, 64)); @@ -2280,7 +2280,7 @@ static void prov_pub_key(const u8_t idx, const u8_t *data) prov_gen_dh_key(idx); } -static void prov_input_complete(const u8_t idx, const u8_t *data) +static void prov_input_complete(const uint8_t idx, const uint8_t *data) { /* Make sure received pdu is ok and cancel the timeout timer */ if (bt_mesh_atomic_test_and_clear_bit(link[idx].flags, TIMEOUT_START)) { @@ -2291,13 +2291,8 @@ static void prov_input_complete(const u8_t idx, const u8_t *data) send_confirm(idx); } -static void prov_confirm(const u8_t idx, const u8_t *data) +static void prov_confirm(const uint8_t idx, const uint8_t *data) { - /** - * Zephyr uses PROV_BUF(16). Currently test with PROV_BUF(16) - * and PROV_BUF(17) on branch feature/btdm_ble_mesh_debug both - * work fine. - */ PROV_BUF(buf, 17); BT_DBG("Remote Confirm: %s", bt_hex(data, 16)); @@ -2307,7 +2302,7 @@ static void prov_confirm(const u8_t idx, const u8_t *data) k_delayed_work_cancel(&link[idx].timeout); } - link[idx].conf = (u8_t *)bt_mesh_calloc(PROV_CONFIRM_SIZE); + link[idx].conf = (uint8_t *)bt_mesh_calloc(PROV_CONFIRM_SIZE); if (!link[idx].conf) { BT_ERR("%s, Out of memory", __func__); close_link(idx, CLOSE_REASON_FAILED); @@ -2336,16 +2331,16 @@ static void prov_confirm(const u8_t idx, const u8_t *data) link[idx].expect = PROV_RANDOM; } -static void send_prov_data(const u8_t idx) +static void send_prov_data(const uint8_t idx) { PROV_BUF(buf, 34); - u16_t prev_addr = BLE_MESH_ADDR_UNASSIGNED; - u16_t max_addr = BLE_MESH_ADDR_UNASSIGNED; + uint16_t prev_addr = BLE_MESH_ADDR_UNASSIGNED; + uint16_t max_addr = BLE_MESH_ADDR_UNASSIGNED; struct bt_mesh_node *node = NULL; - const u8_t *netkey = NULL; - u8_t session_key[16] = {0}; - u8_t nonce[13] = {0}; - u8_t pdu[25] = {0}; + const uint8_t *netkey = NULL; + uint8_t session_key[16] = {0}; + uint8_t nonce[13] = {0}; + uint8_t pdu[25] = {0}; int err = 0; err = bt_mesh_session_key(link[idx].dhkey, link[idx].prov_salt, session_key); @@ -2415,7 +2410,7 @@ static void send_prov_data(const u8_t idx) sys_put_be16(prev_addr, &pdu[23]); link[idx].unicast_addr = prev_addr; } else { - u16_t alloc_addr = BLE_MESH_ADDR_UNASSIGNED; + uint16_t alloc_addr = BLE_MESH_ADDR_UNASSIGNED; if (BLE_MESH_ADDR_IS_UNICAST(link[idx].assign_addr)) { alloc_addr = link[idx].assign_addr; @@ -2506,9 +2501,9 @@ fail: return; } -static void prov_random(const u8_t idx, const u8_t *data) +static void prov_random(const uint8_t idx, const uint8_t *data) { - u8_t conf_verify[16] = {0}; + uint8_t conf_verify[16] = {0}; BT_DBG("Remote Random: %s", bt_hex(data, 16)); @@ -2536,7 +2531,7 @@ static void prov_random(const u8_t idx, const u8_t *data) * 2. calculate prov_salt * 3. prepare provisioning data and send */ - link[idx].prov_salt = (u8_t *)bt_mesh_calloc(PROV_PROV_SALT_SIZE); + link[idx].prov_salt = (uint8_t *)bt_mesh_calloc(PROV_PROV_SALT_SIZE); if (!link[idx].prov_salt) { BT_ERR("%s, Out of memory", __func__); goto fail; @@ -2558,11 +2553,11 @@ fail: return; } -static void prov_complete(const u8_t idx, const u8_t *data) +static void prov_complete(const uint8_t idx, const uint8_t *data) { - u8_t device_key[16] = {0}; - u16_t net_idx = 0U; - u16_t index = 0U; + uint8_t device_key[16] = {0}; + uint16_t net_idx = 0U; + uint16_t index = 0U; int err = 0; int i; @@ -2609,7 +2604,7 @@ static void prov_complete(const u8_t idx, const u8_t *data) close_link(idx, CLOSE_REASON_SUCCESS); } -static void prov_failed(const u8_t idx, const u8_t *data) +static void prov_failed(const uint8_t idx, const uint8_t *data) { BT_WARN("Error 0x%02x", data[0]); @@ -2617,8 +2612,8 @@ static void prov_failed(const u8_t idx, const u8_t *data) } static const struct { - void (*func)(const u8_t idx, const u8_t *data); - u16_t len; + void (*func)(const uint8_t idx, const uint8_t *data); + uint16_t len; } prov_handlers[] = { { prov_invite, 1 }, { prov_capabilities, 11 }, @@ -2632,7 +2627,7 @@ static const struct { { prov_failed, 1 }, }; -static void close_link(const u8_t idx, u8_t reason) +static void close_link(const uint8_t idx, uint8_t reason) { #if defined(CONFIG_BLE_MESH_PB_ADV) if (idx < CONFIG_BLE_MESH_PBA_SAME_TIME) { @@ -2660,7 +2655,7 @@ static void close_link(const u8_t idx, u8_t reason) static void prov_timeout(struct k_work *work) { - u8_t idx = (u8_t)work->index; + uint8_t idx = (uint8_t)work->index; BT_WARN("%s", __func__); @@ -2670,8 +2665,8 @@ static void prov_timeout(struct k_work *work) #if defined(CONFIG_BLE_MESH_PB_ADV) static void prov_retransmit(struct k_work *work) { - s64_t timeout = TRANSACTION_TIMEOUT; - u8_t idx = (u8_t)work->index; + int64_t timeout = TRANSACTION_TIMEOUT; + uint8_t idx = (uint8_t)work->index; int i; BT_DBG("%s", __func__); @@ -2693,8 +2688,8 @@ static void prov_retransmit(struct k_work *work) } if (link[idx].send_link_close & BIT(0)) { - u8_t reason = (link[idx].send_link_close >> 1) & BIT_MASK(2); - u16_t count = (link[idx].send_link_close >> 3); + uint8_t reason = (link[idx].send_link_close >> 1) & BIT_MASK(2); + uint16_t count = (link[idx].send_link_close >> 3); if (count >= 2) { reset_link(idx, reason); return; @@ -2727,7 +2722,7 @@ static void prov_retransmit(struct k_work *work) bt_mesh_pb_buf_unlock(); } -static void link_ack(const u8_t idx, struct prov_rx *rx, struct net_buf_simple *buf) +static void link_ack(const uint8_t idx, struct prov_rx *rx, struct net_buf_simple *buf) { BT_DBG("len %u", buf->len); @@ -2742,7 +2737,7 @@ static void link_ack(const u8_t idx, struct prov_rx *rx, struct net_buf_simple * return; } - link[idx].conf_inputs = (u8_t *)bt_mesh_calloc(PROV_CONF_INPUTS_SIZE); + link[idx].conf_inputs = (uint8_t *)bt_mesh_calloc(PROV_CONF_INPUTS_SIZE); if (!link[idx].conf_inputs) { BT_ERR("%s, Out of memory", __func__); close_link(idx, CLOSE_REASON_FAILED); @@ -2752,9 +2747,9 @@ static void link_ack(const u8_t idx, struct prov_rx *rx, struct net_buf_simple * send_invite(idx); } -static void link_close(const u8_t idx, struct prov_rx *rx, struct net_buf_simple *buf) +static void link_close(const uint8_t idx, struct prov_rx *rx, struct net_buf_simple *buf) { - u8_t reason = 0U; + uint8_t reason = 0U; BT_DBG("len %u", buf->len); @@ -2763,7 +2758,7 @@ static void link_close(const u8_t idx, struct prov_rx *rx, struct net_buf_simple reset_link(idx, reason); } -static void gen_prov_ctl(const u8_t idx, struct prov_rx *rx, struct net_buf_simple *buf) +static void gen_prov_ctl(const uint8_t idx, struct prov_rx *rx, struct net_buf_simple *buf) { BT_DBG("op 0x%02x len %u", BEARER_CTL(rx->gpc), buf->len); @@ -2791,9 +2786,9 @@ static void gen_prov_ctl(const u8_t idx, struct prov_rx *rx, struct net_buf_simp } } -static void prov_msg_recv(const u8_t idx) +static void prov_msg_recv(const uint8_t idx) { - u8_t type = link[idx].rx.buf->data[0]; + uint8_t type = link[idx].rx.buf->data[0]; BT_DBG("type 0x%02x len %u", type, link[idx].rx.buf->len); @@ -2833,9 +2828,9 @@ fail: return; } -static void gen_prov_cont(const u8_t idx, struct prov_rx *rx, struct net_buf_simple *buf) +static void gen_prov_cont(const uint8_t idx, struct prov_rx *rx, struct net_buf_simple *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->len, seg); @@ -2855,7 +2850,7 @@ static void gen_prov_cont(const u8_t idx, struct prov_rx *rx, struct net_buf_sim BT_ERR("Invalid segment index %u", seg); goto fail; } else if (seg == link[idx].rx.last_seg) { - u8_t expect_len = 0U; + uint8_t expect_len = 0U; expect_len = (link[idx].rx.buf->len - 20 - (23 * (link[idx].rx.last_seg - 1))); @@ -2884,9 +2879,9 @@ fail: return; } -static void gen_prov_ack(const u8_t idx, struct prov_rx *rx, struct net_buf_simple *buf) +static void gen_prov_ack(const uint8_t idx, struct prov_rx *rx, struct net_buf_simple *buf) { - u8_t ack_type = 0U, pub_key_oob = 0U; + uint8_t ack_type = 0U, pub_key_oob = 0U; BT_DBG("len %u", buf->len); @@ -2917,7 +2912,7 @@ static void gen_prov_ack(const u8_t idx, struct prov_rx *rx, struct net_buf_simp } } -static void gen_prov_start(const u8_t idx, struct prov_rx *rx, struct net_buf_simple *buf) +static void gen_prov_start(const uint8_t idx, struct prov_rx *rx, struct net_buf_simple *buf) { if (link[idx].rx.seg) { BT_INFO("Get Start while there are unreceived segments"); @@ -2968,9 +2963,9 @@ static void gen_prov_start(const u8_t idx, struct prov_rx *rx, struct net_buf_si } static const struct { - void (*const func)(const u8_t idx, struct prov_rx *rx, struct net_buf_simple *buf); - const u8_t require_link; - const u8_t min_len; + void (*const func)(const uint8_t idx, struct prov_rx *rx, struct net_buf_simple *buf); + const uint8_t require_link; + const uint8_t min_len; } gen_prov[] = { { gen_prov_start, true, 3 }, { gen_prov_ack, true, 0 }, @@ -2978,7 +2973,7 @@ static const struct { { gen_prov_ctl, true, 0 }, }; -static void gen_prov_recv(const u8_t idx, struct prov_rx *rx, struct net_buf_simple *buf) +static void gen_prov_recv(const uint8_t idx, struct prov_rx *rx, struct net_buf_simple *buf) { if (buf->len < gen_prov[GPCF(rx->gpc)].min_len) { BT_ERR("Too short GPC message type %u", GPCF(rx->gpc)); @@ -3000,7 +2995,7 @@ static void gen_prov_recv(const u8_t idx, struct prov_rx *rx, struct net_buf_sim gen_prov[GPCF(rx->gpc)].func(idx, rx, buf); } -static int find_link(u32_t link_id, u8_t *idx) +static int find_link(uint32_t link_id, uint8_t *idx) { int i; @@ -3022,7 +3017,7 @@ static int find_link(u32_t link_id, u8_t *idx) void bt_mesh_provisioner_pb_adv_recv(struct net_buf_simple *buf) { struct prov_rx rx = {0}; - u8_t idx = 0U; + uint8_t idx = 0U; rx.link_id = net_buf_simple_pull_be32(buf); if (find_link(rx.link_id, &idx) < 0) { @@ -3046,7 +3041,7 @@ void bt_mesh_provisioner_pb_adv_recv(struct net_buf_simple *buf) #endif /* CONFIG_BLE_MESH_PB_ADV */ #if defined(CONFIG_BLE_MESH_PB_GATT) -static struct bt_mesh_conn *find_conn(struct bt_mesh_conn *conn, u8_t *idx) +static struct bt_mesh_conn *find_conn(struct bt_mesh_conn *conn, uint8_t *idx) { int i; @@ -3067,8 +3062,8 @@ static struct bt_mesh_conn *find_conn(struct bt_mesh_conn *conn, u8_t *idx) int bt_mesh_provisioner_pb_gatt_recv(struct bt_mesh_conn *conn, struct net_buf_simple *buf) { - u8_t type = 0U; - u8_t idx = 0U; + uint8_t type = 0U; + uint8_t idx = 0U; BT_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len)); @@ -3108,7 +3103,7 @@ fail: return -EINVAL; } -int bt_mesh_provisioner_set_prov_conn(const u8_t addr[6], struct bt_mesh_conn *conn) +int bt_mesh_provisioner_set_prov_conn(const uint8_t addr[6], struct bt_mesh_conn *conn) { int i; @@ -3128,9 +3123,9 @@ int bt_mesh_provisioner_set_prov_conn(const u8_t addr[6], struct bt_mesh_conn *c return -ENOMEM; } -int bt_mesh_provisioner_pb_gatt_open(struct bt_mesh_conn *conn, u8_t *addr) +int bt_mesh_provisioner_pb_gatt_open(struct bt_mesh_conn *conn, uint8_t *addr) { - u8_t idx = 0U; + uint8_t idx = 0U; int i; BT_DBG("conn %p", conn); @@ -3173,7 +3168,7 @@ int bt_mesh_provisioner_pb_gatt_open(struct bt_mesh_conn *conn, u8_t *addr) prov->prov_link_open(BLE_MESH_PROV_GATT); } - link[idx].conf_inputs = (u8_t *)bt_mesh_calloc(PROV_CONF_INPUTS_SIZE); + link[idx].conf_inputs = (uint8_t *)bt_mesh_calloc(PROV_CONF_INPUTS_SIZE); if (!link[idx].conf_inputs) { /* Disconnect this connection, clear corresponding informations */ BT_ERR("%s, Out of memory", __func__); @@ -3185,9 +3180,9 @@ int bt_mesh_provisioner_pb_gatt_open(struct bt_mesh_conn *conn, u8_t *addr) return 0; } -int bt_mesh_provisioner_pb_gatt_close(struct bt_mesh_conn *conn, u8_t reason) +int bt_mesh_provisioner_pb_gatt_close(struct bt_mesh_conn *conn, uint8_t reason) { - u8_t idx = 0U; + uint8_t idx = 0U; BT_DBG("conn %p", conn); @@ -3218,7 +3213,7 @@ int bt_mesh_provisioner_pb_gatt_close(struct bt_mesh_conn *conn, u8_t reason) int bt_mesh_provisioner_prov_init(const struct bt_mesh_prov *prov_info) { - const u8_t *key = NULL; + const uint8_t *key = NULL; int i; if (!prov_info) { @@ -3370,14 +3365,14 @@ int bt_mesh_provisioner_prov_deinit(bool erase) } #endif /* CONFIG_BLE_MESH_DEINIT */ -static bool is_unprov_dev_info_callback_to_app(bt_mesh_prov_bearer_t bearer, const u8_t uuid[16], - const bt_mesh_addr_t *addr, u16_t oob_info, s8_t rssi) +static bool is_unprov_dev_info_callback_to_app(bt_mesh_prov_bearer_t bearer, const uint8_t uuid[16], + const bt_mesh_addr_t *addr, uint16_t oob_info, int8_t rssi) { int i; if (prov_ctx.prov_after_match == false) { - u8_t adv_type = (bearer == BLE_MESH_PROV_ADV) ? - BLE_MESH_ADV_NONCONN_IND : BLE_MESH_ADV_IND; + uint8_t adv_type = (bearer == BLE_MESH_PROV_ADV) ? + BLE_MESH_ADV_NONCONN_IND : BLE_MESH_ADV_IND; for (i = 0; i < ARRAY_SIZE(unprov_dev); i++) { if (!memcmp(unprov_dev[i].uuid, uuid, 16)) { @@ -3406,12 +3401,12 @@ static bool is_unprov_dev_info_callback_to_app(bt_mesh_prov_bearer_t bearer, con return false; } -void bt_mesh_provisioner_unprov_beacon_recv(struct net_buf_simple *buf, s8_t rssi) +void bt_mesh_provisioner_unprov_beacon_recv(struct net_buf_simple *buf, int8_t rssi) { #if defined(CONFIG_BLE_MESH_PB_ADV) const bt_mesh_addr_t *addr = NULL; - const u8_t *uuid = NULL; - u16_t oob_info = 0U; + const uint8_t *uuid = NULL; + uint16_t oob_info = 0U; if (!(prov_ctx.bearers & BLE_MESH_PROV_ADV)) { BT_WARN("Not support PB-ADV bearer"); @@ -3443,11 +3438,11 @@ void bt_mesh_provisioner_unprov_beacon_recv(struct net_buf_simple *buf, s8_t rss } void bt_mesh_provisioner_prov_adv_recv(struct net_buf_simple *buf, - const bt_mesh_addr_t *addr, s8_t rssi) + const bt_mesh_addr_t *addr, int8_t rssi) { #if defined(CONFIG_BLE_MESH_PB_GATT) - const u8_t *uuid = NULL; - u16_t oob_info = 0U; + const uint8_t *uuid = NULL; + uint16_t oob_info = 0U; if (!(prov_ctx.bearers & BLE_MESH_PROV_GATT)) { BT_WARN("Not support PB-GATT bearer"); diff --git a/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.h b/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.h index 7d94837706..2f8db19677 100644 --- a/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.h +++ b/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.h @@ -35,17 +35,17 @@ extern "C" { #define FLUSHABLE_DEV BIT(2) struct bt_mesh_unprov_dev_add { - u8_t addr[6]; - u8_t addr_type; - u8_t uuid[16]; - u16_t oob_info; - u8_t bearer; + uint8_t addr[6]; + uint8_t addr_type; + uint8_t uuid[16]; + uint16_t oob_info; + uint8_t bearer; }; struct bt_mesh_device_delete { - u8_t addr[6]; - u8_t addr_type; - u8_t uuid[16]; + uint8_t addr[6]; + uint8_t addr_type; + uint8_t uuid[16]; }; #define NET_IDX_FLAG BIT(0) @@ -54,11 +54,11 @@ struct bt_mesh_device_delete { struct bt_mesh_prov_data_info { union { - u16_t net_idx; - u8_t flags; - u32_t iv_index; + uint16_t net_idx; + uint8_t flags; + uint32_t iv_index; }; - u8_t flag; + uint8_t flag; }; /* The following APIs are for primary provisioner internal use */ @@ -77,7 +77,7 @@ void bt_mesh_provisioner_pbg_count_dec(void); * * @return None */ -void bt_mesh_provisioner_clear_link_info(const u8_t addr[6]); +void bt_mesh_provisioner_clear_link_info(const uint8_t addr[6]); /** * @brief This function handles the received PB-ADV PDUs. @@ -97,7 +97,7 @@ void bt_mesh_provisioner_pb_adv_recv(struct net_buf_simple *buf); * * @return Zero - success, otherwise - fail */ -int bt_mesh_provisioner_set_prov_conn(const u8_t addr[6], struct bt_mesh_conn *conn); +int bt_mesh_provisioner_set_prov_conn(const uint8_t addr[6], struct bt_mesh_conn *conn); /** * @brief This function sends provisioning invite to start @@ -108,7 +108,7 @@ int bt_mesh_provisioner_set_prov_conn(const u8_t addr[6], struct bt_mesh_conn *c * * @return Zero - success, otherwise - fail */ -int bt_mesh_provisioner_pb_gatt_open(struct bt_mesh_conn *conn, u8_t *addr); +int bt_mesh_provisioner_pb_gatt_open(struct bt_mesh_conn *conn, uint8_t *addr); /** * @brief This function resets the used information when @@ -119,7 +119,7 @@ int bt_mesh_provisioner_pb_gatt_open(struct bt_mesh_conn *conn, u8_t *addr); * * @return Zero - success, otherwise - fail */ -int bt_mesh_provisioner_pb_gatt_close(struct bt_mesh_conn *conn, u8_t reason); +int bt_mesh_provisioner_pb_gatt_close(struct bt_mesh_conn *conn, uint8_t reason); /** * @brief This function handles the received PB-GATT provision @@ -164,10 +164,10 @@ int bt_mesh_provisioner_prov_deinit(bool erase); * * @return None */ -void bt_mesh_provisioner_unprov_beacon_recv(struct net_buf_simple *buf, s8_t rssi); +void bt_mesh_provisioner_unprov_beacon_recv(struct net_buf_simple *buf, int8_t rssi); void bt_mesh_provisioner_prov_adv_recv(struct net_buf_simple *buf, - const bt_mesh_addr_t *addr, s8_t rssi); + const bt_mesh_addr_t *addr, int8_t rssi); /** * @brief This function gets the bt_mesh_prov pointer. @@ -176,7 +176,7 @@ void bt_mesh_provisioner_prov_adv_recv(struct net_buf_simple *buf, */ const struct bt_mesh_prov *bt_mesh_provisioner_get_prov_info(void); -void bt_mesh_provisioner_restore_prov_info(u16_t primary_addr, u16_t alloc_addr); +void bt_mesh_provisioner_restore_prov_info(uint16_t primary_addr, uint16_t alloc_addr); /* The following APIs are for primary provisioner application use */ @@ -196,7 +196,7 @@ void bt_mesh_provisioner_restore_prov_info(u16_t primary_addr, u16_t alloc_addr) * will also be successful and it will update the provision bearer supported by * the device. */ -int bt_mesh_provisioner_add_unprov_dev(struct bt_mesh_unprov_dev_add *add_dev, u8_t flags); +int bt_mesh_provisioner_add_unprov_dev(struct bt_mesh_unprov_dev_add *add_dev, uint8_t flags); /** @brief Provision an unprovisioned device with fixed unicast address. * @@ -212,9 +212,9 @@ int bt_mesh_provisioner_add_unprov_dev(struct bt_mesh_unprov_dev_add *add_dev, u * @note 1. Currently address type only supports public address and static random address. * 2. Bearer must be equal to BLE_MESH_PROV_ADV or BLE_MESH_PROV_GATT */ -int bt_mesh_provisioner_prov_device_with_addr(const u8_t uuid[16], const u8_t addr[6], - u8_t addr_type, bt_mesh_prov_bearer_t bearer, - u16_t oob_info, u16_t unicast_addr); +int bt_mesh_provisioner_prov_device_with_addr(const uint8_t uuid[16], const uint8_t addr[6], + uint8_t addr_type, bt_mesh_prov_bearer_t bearer, + uint16_t oob_info, uint16_t unicast_addr); /** @brief Delete device from queue, reset current provisioning link and reset the node * @@ -236,8 +236,8 @@ int bt_mesh_provisioner_delete_device(struct bt_mesh_device_delete *del_dev); * * @return Zero - success, otherwise - fail */ -int bt_mesh_provisioner_set_dev_uuid_match(u8_t offset, u8_t length, - const u8_t *match, bool prov_flag); +int bt_mesh_provisioner_set_dev_uuid_match(uint8_t offset, uint8_t length, + const uint8_t *match, bool prov_flag); /** @brief Callback for provisioner receiving advertising packet from unprovisioned devices which are * not in the unprovisioned device queue. @@ -254,9 +254,9 @@ int bt_mesh_provisioner_set_dev_uuid_match(u8_t offset, u8_t length, * @param rssi RSSI of the received advertising packet * */ -typedef void (*unprov_adv_pkt_cb_t)(const u8_t addr[6], const u8_t addr_type, - const u8_t adv_type, const u8_t dev_uuid[16], - u16_t oob_info, bt_mesh_prov_bearer_t bearer, s8_t rssi); +typedef void (*unprov_adv_pkt_cb_t)(const uint8_t addr[6], const uint8_t addr_type, + const uint8_t adv_type, const uint8_t dev_uuid[16], + uint16_t oob_info, bt_mesh_prov_bearer_t bearer, int8_t rssi); /** * @brief This function registers the callback which notifies the application @@ -311,14 +311,14 @@ bt_mesh_prov_bearer_t bt_mesh_provisioner_get_prov_bearer(void); * * @return Zero - success, otherwise - fail */ -int bt_mesh_provisioner_set_static_oob_value(const u8_t *value, u8_t length); +int bt_mesh_provisioner_set_static_oob_value(const uint8_t *value, uint8_t length); /** * @brief This function gets the unicast address of primary element of Provisioner. * * @return Unicast address of primary element of Provisioner. */ -u16_t bt_mesh_provisioner_get_primary_elem_addr(void); +uint16_t bt_mesh_provisioner_get_primary_elem_addr(void); /** * @brief This function sets the unicast address of primary element of Provisioner. @@ -327,7 +327,7 @@ u16_t bt_mesh_provisioner_get_primary_elem_addr(void); * * @return Zero - success, otherwise - fail */ -int bt_mesh_provisioner_set_primary_elem_addr(u16_t addr); +int bt_mesh_provisioner_set_primary_elem_addr(uint16_t addr); /** * @brief This function is used to update next allocated address by Provisioner. @@ -339,7 +339,7 @@ int bt_mesh_provisioner_set_primary_elem_addr(u16_t addr); * * @return Zero - success, otherwise - fail */ -int bt_mesh_test_provisioner_update_alloc_addr(u16_t unicast_addr, u16_t element_num); +int bt_mesh_test_provisioner_update_alloc_addr(uint16_t unicast_addr, uint16_t element_num); /** * @brief This function is called to input number/string out-put by unprovisioned device. @@ -350,7 +350,7 @@ int bt_mesh_test_provisioner_update_alloc_addr(u16_t unicast_addr, u16_t element * * @return Zero - success, otherwise - fail */ -int bt_mesh_provisioner_set_oob_input_data(const u8_t idx, const u8_t *val, bool num_flag); +int bt_mesh_provisioner_set_oob_input_data(const uint8_t idx, const uint8_t *val, bool num_flag); /** * @brief This function is called to output number/string which will be input by unprovisioned device. @@ -362,8 +362,8 @@ int bt_mesh_provisioner_set_oob_input_data(const u8_t idx, const u8_t *val, bool * * @return Zero - success, otherwise - fail */ -int bt_mesh_provisioner_set_oob_output_data(const u8_t idx, const u8_t *num, - u8_t size, bool num_flag); +int bt_mesh_provisioner_set_oob_output_data(const uint8_t idx, const uint8_t *num, + uint8_t size, bool num_flag); /** * @brief This function is called to read unprovisioned device's oob public key. @@ -374,8 +374,8 @@ int bt_mesh_provisioner_set_oob_output_data(const u8_t idx, const u8_t *num, * * @return Zero - success, otherwise - fail */ -int bt_mesh_provisioner_read_oob_pub_key(const u8_t idx, const u8_t pub_key_x[32], - const u8_t pub_key_y[32]); +int bt_mesh_provisioner_read_oob_pub_key(const uint8_t idx, const uint8_t pub_key_x[32], + const uint8_t pub_key_y[32]); /* The following APIs are for fast provisioning */ @@ -395,14 +395,14 @@ void bt_mesh_provisioner_fast_prov_enable(bool enable); * * @return None */ -void bt_mesh_provisioner_set_fast_prov_net_idx(u16_t net_idx); +void bt_mesh_provisioner_set_fast_prov_net_idx(uint16_t net_idx); /** * @brief This function is called to get netkey index used for fast provisioning. * * @return net_idx of fast provisioning */ -u16_t bt_mesh_provisioner_get_fast_prov_net_idx(void); +uint16_t bt_mesh_provisioner_get_fast_prov_net_idx(void); /** * @brief This function is called to set unicast address range used for fast provisioning. @@ -412,7 +412,7 @@ u16_t bt_mesh_provisioner_get_fast_prov_net_idx(void); * * @return status for set unicast address range message */ -u8_t bt_mesh_set_fast_prov_unicast_addr_range(u16_t min, u16_t max); +uint8_t bt_mesh_set_fast_prov_unicast_addr_range(uint16_t min, uint16_t max); /** * @brief This function is called to set flags & iv_index used for fast provisioning. @@ -422,7 +422,7 @@ u8_t bt_mesh_set_fast_prov_unicast_addr_range(u16_t min, u16_t max); * * @return None */ -void bt_mesh_set_fast_prov_flags_iv_index(u8_t flags, u32_t iv_index); +void bt_mesh_set_fast_prov_flags_iv_index(uint8_t flags, uint32_t iv_index); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_core/proxy_client.c b/components/bt/esp_ble_mesh/mesh_core/proxy_client.c index 334e078aaf..d66f9ebb09 100644 --- a/components/bt/esp_ble_mesh/mesh_core/proxy_client.c +++ b/components/bt/esp_ble_mesh/mesh_core/proxy_client.c @@ -51,14 +51,14 @@ static struct bt_mesh_proxy_server { PROXY, } conn_type; #if CONFIG_BLE_MESH_GATT_PROXY_CLIENT - u16_t net_idx; + uint16_t net_idx; #endif - u8_t msg_type; + uint8_t msg_type; struct k_delayed_work sar_timer; struct net_buf_simple buf; } servers[BLE_MESH_MAX_CONN]; -static u8_t server_buf_data[SERVER_BUF_SIZE * BLE_MESH_MAX_CONN]; +static uint8_t server_buf_data[SERVER_BUF_SIZE * BLE_MESH_MAX_CONN]; static struct bt_mesh_proxy_server *find_server(struct bt_mesh_conn *conn) { @@ -123,8 +123,8 @@ static void filter_status(struct bt_mesh_proxy_server *server, struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) { - u8_t filter_type = 0U; - u16_t list_size = 0U; + uint8_t filter_type = 0U; + uint16_t list_size = 0U; if (buf->len != 3) { BT_ERR("Invalid Proxy Filter Status length %d", buf->len); @@ -152,7 +152,7 @@ static void proxy_cfg(struct bt_mesh_proxy_server *server) { NET_BUF_SIMPLE_DEFINE(buf, 29); struct bt_mesh_net_rx rx = {0}; - u8_t opcode = 0U; + uint8_t opcode = 0U; int err = 0; if (server->buf.len > 29) { @@ -238,11 +238,11 @@ static void proxy_complete_pdu(struct bt_mesh_proxy_server *server) static ssize_t proxy_recv(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, const void *buf, - u16_t len, u16_t offset, u8_t flags) + uint16_t len, uint16_t offset, uint8_t flags) { struct bt_mesh_proxy_server *server = find_server(conn); - const u8_t *data = buf; - u16_t srvc_uuid = 0U; + const uint8_t *data = buf; + uint16_t srvc_uuid = 0U; if (!server) { BT_ERR("No Proxy Server object found"); @@ -329,17 +329,17 @@ static ssize_t proxy_recv(struct bt_mesh_conn *conn, } -static int proxy_send(struct bt_mesh_conn *conn, const void *data, u16_t len) +static int proxy_send(struct bt_mesh_conn *conn, const void *data, uint16_t len) { BT_DBG("%u bytes: %s", len, bt_hex(data, len)); return bt_mesh_gattc_write_no_rsp(conn, NULL, data, len); } -static int proxy_segment_and_send(struct bt_mesh_conn *conn, u8_t type, +static int proxy_segment_and_send(struct bt_mesh_conn *conn, uint8_t type, struct net_buf_simple *msg) { - u16_t mtu = 0U; + uint16_t mtu = 0U; int err = 0; if (conn == NULL) { @@ -382,7 +382,7 @@ static int proxy_segment_and_send(struct bt_mesh_conn *conn, u8_t type, return err; } -int bt_mesh_proxy_client_send(struct bt_mesh_conn *conn, u8_t type, +int bt_mesh_proxy_client_send(struct bt_mesh_conn *conn, uint8_t type, struct net_buf_simple *msg) { struct bt_mesh_proxy_server *server = find_server(conn); @@ -425,7 +425,7 @@ static void proxy_connected(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn, int return; } -static void proxy_disconnected(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn, u8_t reason) +static void proxy_disconnected(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn, uint8_t reason) { struct bt_mesh_proxy_server *server = find_server(conn); @@ -483,7 +483,7 @@ static ssize_t prov_write_ccc(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn) return -ENOMEM; } -static ssize_t prov_recv_ntf(struct bt_mesh_conn *conn, u8_t *data, u16_t len) +static ssize_t prov_recv_ntf(struct bt_mesh_conn *conn, uint8_t *data, uint16_t len) { struct bt_mesh_proxy_server *server = find_server(conn); @@ -555,7 +555,7 @@ static ssize_t proxy_write_ccc(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn) return -EINVAL; } -static ssize_t proxy_recv_ntf(struct bt_mesh_conn *conn, u8_t *data, u16_t len) +static ssize_t proxy_recv_ntf(struct bt_mesh_conn *conn, uint8_t *data, uint16_t len) { struct bt_mesh_proxy_server *server = find_server(conn); @@ -641,7 +641,7 @@ static struct bt_mesh_prov_conn_cb conn_callbacks = { }; #if defined(CONFIG_BLE_MESH_GATT_PROXY_CLIENT) -static struct bt_mesh_subnet *bt_mesh_is_net_id_exist(const u8_t net_id[8]) +static struct bt_mesh_subnet *bt_mesh_is_net_id_exist(const uint8_t net_id[8]) { struct bt_mesh_subnet *sub = NULL; size_t size = 0U, i = 0U; @@ -659,10 +659,10 @@ static struct bt_mesh_subnet *bt_mesh_is_net_id_exist(const u8_t net_id[8]) } void bt_mesh_proxy_client_gatt_adv_recv(struct net_buf_simple *buf, - const bt_mesh_addr_t *addr, s8_t rssi) + const bt_mesh_addr_t *addr, int8_t rssi) { bt_mesh_proxy_adv_ctx_t ctx = {0}; - u8_t type = 0U; + uint8_t type = 0U; /* Check if connection reaches the maximum limitation */ if (bt_mesh_gattc_get_free_conn_count() == 0) { @@ -706,7 +706,7 @@ void bt_mesh_proxy_client_gatt_adv_recv(struct net_buf_simple *buf, } } -int bt_mesh_proxy_client_connect(const u8_t addr[6], u8_t addr_type, u16_t net_idx) +int bt_mesh_proxy_client_connect(const uint8_t addr[6], uint8_t addr_type, uint16_t net_idx) { bt_mesh_addr_t remote_addr = {0}; int result = 0; @@ -729,7 +729,7 @@ int bt_mesh_proxy_client_connect(const u8_t addr[6], u8_t addr_type, u16_t net_i return 0; } -int bt_mesh_proxy_client_disconnect(u8_t conn_handle) +int bt_mesh_proxy_client_disconnect(uint8_t conn_handle) { struct bt_mesh_conn *conn = NULL; @@ -750,7 +750,7 @@ int bt_mesh_proxy_client_disconnect(u8_t conn_handle) return 0; } -bool bt_mesh_proxy_client_relay(struct net_buf_simple *buf, u16_t dst) +bool bt_mesh_proxy_client_relay(struct net_buf_simple *buf, uint16_t dst) { bool send = false; int err = 0; @@ -837,7 +837,7 @@ bool bt_mesh_proxy_client_beacon_send(struct bt_mesh_subnet *sub) return send; } -static int send_proxy_cfg(struct bt_mesh_conn *conn, u16_t net_idx, struct bt_mesh_proxy_cfg_pdu *cfg) +static int send_proxy_cfg(struct bt_mesh_conn *conn, uint16_t net_idx, struct bt_mesh_proxy_cfg_pdu *cfg) { struct bt_mesh_msg_ctx ctx = { .net_idx = net_idx, @@ -850,7 +850,7 @@ static int send_proxy_cfg(struct bt_mesh_conn *conn, u16_t net_idx, struct bt_me .src = bt_mesh_primary_addr(), }; struct net_buf_simple *buf = NULL; - u16_t alloc_len = 0U; + uint16_t alloc_len = 0U; int err = 0; if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned()) { @@ -911,12 +911,12 @@ static int send_proxy_cfg(struct bt_mesh_conn *conn, u16_t net_idx, struct bt_me net_buf_simple_add_u8(buf, cfg->set.filter_type); break; case BLE_MESH_PROXY_CFG_FILTER_ADD: - for (u16_t i = 0U; i < cfg->add.addr_num; i++) { + for (uint16_t i = 0U; i < cfg->add.addr_num; i++) { net_buf_simple_add_le16(buf, cfg->add.addr[i]); } break; case BLE_MESH_PROXY_CFG_FILTER_REMOVE: - for (u16_t i = 0U; i < cfg->remove.addr_num; i++) { + for (uint16_t i = 0U; i < cfg->remove.addr_num; i++) { net_buf_simple_add_le16(buf, cfg->remove.addr[i]); } break; @@ -940,7 +940,7 @@ static int send_proxy_cfg(struct bt_mesh_conn *conn, u16_t net_idx, struct bt_me return err; } -int bt_mesh_proxy_client_cfg_send(u8_t conn_handle, u16_t net_idx, +int bt_mesh_proxy_client_cfg_send(uint8_t conn_handle, uint16_t net_idx, struct bt_mesh_proxy_cfg_pdu *pdu) { struct bt_mesh_conn *conn = NULL; diff --git a/components/bt/esp_ble_mesh/mesh_core/proxy_client.h b/components/bt/esp_ble_mesh/mesh_core/proxy_client.h index bbead7a912..28798d119d 100644 --- a/components/bt/esp_ble_mesh/mesh_core/proxy_client.h +++ b/components/bt/esp_ble_mesh/mesh_core/proxy_client.h @@ -37,11 +37,11 @@ extern "C" { typedef union { struct { - u8_t net_id[8]; - u16_t net_idx; + uint8_t net_id[8]; + uint16_t net_idx; } net_id; struct { - u16_t src; + uint16_t src; } node_id; } bt_mesh_proxy_adv_ctx_t; @@ -50,31 +50,31 @@ struct bt_mesh_proxy_net_pdu { }; struct bt_mesh_proxy_cfg_pdu { - u8_t opcode; + uint8_t opcode; union { struct cfg_filter_set { - u8_t filter_type; + uint8_t filter_type; } set; struct cfg_addr_add { - u16_t *addr; - u16_t addr_num; + uint16_t *addr; + uint16_t addr_num; } add; struct cfg_addr_remove { - u16_t *addr; - u16_t addr_num; + uint16_t *addr; + uint16_t addr_num; } remove; }; }; typedef struct { - u8_t type; + uint8_t type; union { struct bt_mesh_proxy_net_pdu net; struct bt_mesh_proxy_cfg_pdu cfg; }; } bt_mesh_proxy_client_pdu_t; -int bt_mesh_proxy_client_send(struct bt_mesh_conn *conn, u8_t type, +int bt_mesh_proxy_client_send(struct bt_mesh_conn *conn, uint8_t type, struct net_buf_simple *msg); int bt_mesh_proxy_client_prov_enable(void); @@ -83,14 +83,14 @@ int bt_mesh_proxy_client_prov_disable(void); int bt_mesh_proxy_client_gatt_enable(void); int bt_mesh_proxy_client_gatt_disable(void); -typedef void (*proxy_client_recv_adv_cb_t)(const bt_mesh_addr_t *addr, u8_t type, - bt_mesh_proxy_adv_ctx_t *ctx, s8_t rssi); +typedef void (*proxy_client_recv_adv_cb_t)(const bt_mesh_addr_t *addr, uint8_t type, + bt_mesh_proxy_adv_ctx_t *ctx, int8_t rssi); typedef void (*proxy_client_connect_cb_t)(const bt_mesh_addr_t *addr, - u8_t conn_handle, u16_t net_idx); -typedef void (*proxy_client_disconnect_cb_t)(const bt_mesh_addr_t *addr, u8_t conn_handle, - u16_t net_idx, u8_t reason); -typedef void (*proxy_client_recv_filter_status_cb_t)(u8_t conn_handle, u16_t src, u16_t net_idx, - u8_t filter_type, u16_t list_size); + uint8_t conn_handle, uint16_t net_idx); +typedef void (*proxy_client_disconnect_cb_t)(const bt_mesh_addr_t *addr, uint8_t conn_handle, + uint16_t net_idx, uint8_t reason); +typedef void (*proxy_client_recv_filter_status_cb_t)(uint8_t conn_handle, uint16_t src, uint16_t net_idx, + uint8_t filter_type, uint16_t list_size); void bt_mesh_proxy_client_set_adv_recv_cb(proxy_client_recv_adv_cb_t cb); void bt_mesh_proxy_client_set_conn_cb(proxy_client_connect_cb_t cb); @@ -98,16 +98,16 @@ void bt_mesh_proxy_client_set_disconn_cb(proxy_client_disconnect_cb_t cb); void bt_mesh_proxy_client_set_filter_status_cb(proxy_client_recv_filter_status_cb_t cb); void bt_mesh_proxy_client_gatt_adv_recv(struct net_buf_simple *buf, - const bt_mesh_addr_t *addr, s8_t rssi); + const bt_mesh_addr_t *addr, int8_t rssi); -int bt_mesh_proxy_client_connect(const u8_t addr[6], u8_t addr_type, u16_t net_idx); -int bt_mesh_proxy_client_disconnect(u8_t conn_handle); +int bt_mesh_proxy_client_connect(const uint8_t addr[6], uint8_t addr_type, uint16_t net_idx); +int bt_mesh_proxy_client_disconnect(uint8_t conn_handle); bool bt_mesh_proxy_client_beacon_send(struct bt_mesh_subnet *sub); -bool bt_mesh_proxy_client_relay(struct net_buf_simple *buf, u16_t dst); +bool bt_mesh_proxy_client_relay(struct net_buf_simple *buf, uint16_t dst); -int bt_mesh_proxy_client_cfg_send(u8_t conn_handle, u16_t net_idx, +int bt_mesh_proxy_client_cfg_send(uint8_t conn_handle, uint16_t net_idx, struct bt_mesh_proxy_cfg_pdu *pdu); int bt_mesh_proxy_client_init(void); diff --git a/components/bt/esp_ble_mesh/mesh_core/proxy_server.c b/components/bt/esp_ble_mesh/mesh_core/proxy_server.c index 1480e44a04..4d84c9a5b8 100644 --- a/components/bt/esp_ble_mesh/mesh_core/proxy_server.c +++ b/components/bt/esp_ble_mesh/mesh_core/proxy_server.c @@ -9,8 +9,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_PROXY) - #include "mesh.h" #include "adv.h" #include "prov.h" @@ -18,6 +16,7 @@ #include "access.h" #include "transport.h" #include "foundation.h" +#include "mesh_common.h" #include "proxy_server.h" #if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || \ @@ -68,18 +67,18 @@ static bool proxy_adv_enabled; #if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER) static void proxy_send_beacons(struct k_work *work); -static u16_t proxy_ccc_val; +static uint16_t proxy_ccc_val; #endif #if defined(CONFIG_BLE_MESH_PB_GATT) -static u16_t prov_ccc_val; +static uint16_t prov_ccc_val; static bool prov_fast_adv; #endif static struct bt_mesh_proxy_client { struct bt_mesh_conn *conn; #if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER) - u16_t filter[CONFIG_BLE_MESH_PROXY_FILTER_SIZE]; + uint16_t filter[CONFIG_BLE_MESH_PROXY_FILTER_SIZE]; #endif enum __packed { NONE, @@ -87,12 +86,12 @@ static struct bt_mesh_proxy_client { BLACKLIST, PROV, } filter_type; - u8_t msg_type; + uint8_t msg_type; #if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER) struct k_work send_beacons; #endif - struct k_delayed_work sar_timer; - struct net_buf_simple buf; + struct k_delayed_work sar_timer; + struct net_buf_simple buf; } clients[BLE_MESH_MAX_CONN] = { [0 ... (BLE_MESH_MAX_CONN - 1)] = { #if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER) @@ -101,7 +100,7 @@ static struct bt_mesh_proxy_client { }, }; -static u8_t client_buf_data[CLIENT_BUF_SIZE * BLE_MESH_MAX_CONN]; +static uint8_t client_buf_data[CLIENT_BUF_SIZE * BLE_MESH_MAX_CONN]; /* Track which service is enabled */ static enum { @@ -163,13 +162,13 @@ static void proxy_sar_timeout(struct k_work *work) /* Next subnet in queue to be advertised */ static int next_idx; -static int proxy_segment_and_send(struct bt_mesh_conn *conn, u8_t type, +static int proxy_segment_and_send(struct bt_mesh_conn *conn, uint8_t type, struct net_buf_simple *msg); static int filter_set(struct bt_mesh_proxy_client *client, struct net_buf_simple *buf) { - u8_t type = 0U; + uint8_t type = 0U; if (buf->len < 1) { BT_WARN("Too short Filter Set message"); @@ -196,7 +195,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; @@ -223,7 +222,7 @@ static void filter_add(struct bt_mesh_proxy_client *client, u16_t addr) BT_WARN("Proxy filter is full!"); } -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; @@ -251,7 +250,7 @@ static void send_filter_status(struct bt_mesh_proxy_client *client, .ctx = &rx->ctx, .src = bt_mesh_primary_addr(), }; - u16_t filter_size = 0U; + uint16_t filter_size = 0U; int i, err = 0; /* Configuration messages always have dst unassigned */ @@ -294,7 +293,7 @@ static void proxy_cfg(struct bt_mesh_proxy_client *client) { NET_BUF_SIMPLE_DEFINE(buf, 29); struct bt_mesh_net_rx rx = {0}; - u8_t opcode = 0U; + uint8_t opcode = 0U; int err = 0; if (client->buf.len > 29) { @@ -335,7 +334,7 @@ static void proxy_cfg(struct bt_mesh_proxy_client *client) break; case CFG_FILTER_ADD: while (buf.len >= 2) { - u16_t addr = 0U; + uint16_t addr = 0U; addr = net_buf_simple_pull_be16(&buf); filter_add(client, addr); @@ -344,7 +343,7 @@ static void proxy_cfg(struct bt_mesh_proxy_client *client) break; case CFG_FILTER_REMOVE: while (buf.len >= 2) { - u16_t addr = 0U; + uint16_t addr = 0U; addr = net_buf_simple_pull_be16(&buf); filter_remove(client, addr); @@ -489,10 +488,10 @@ static void proxy_complete_pdu(struct bt_mesh_proxy_client *client) static ssize_t proxy_recv(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, const void *buf, - u16_t len, u16_t offset, u8_t flags) + uint16_t len, uint16_t offset, uint8_t flags) { struct bt_mesh_proxy_client *client = find_client(conn); - const u8_t *data = buf; + const uint8_t *data = buf; if (!client) { return -ENOTCONN; @@ -573,7 +572,7 @@ static ssize_t proxy_recv(struct bt_mesh_conn *conn, static int conn_count; -static void proxy_connected(struct bt_mesh_conn *conn, u8_t err) +static void proxy_connected(struct bt_mesh_conn *conn, uint8_t err) { struct bt_mesh_proxy_client *client = NULL; int i; @@ -610,7 +609,7 @@ static void proxy_connected(struct bt_mesh_conn *conn, u8_t err) net_buf_simple_reset(&client->buf); } -static void proxy_disconnected(struct bt_mesh_conn *conn, u8_t reason) +static void proxy_disconnected(struct bt_mesh_conn *conn, uint8_t reason) { int i; @@ -649,11 +648,11 @@ struct net_buf_simple *bt_mesh_proxy_server_get_buf(void) #if defined(CONFIG_BLE_MESH_PB_GATT) static ssize_t prov_ccc_write(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - const void *buf, u16_t len, - u16_t offset, u8_t flags) + const void *buf, uint16_t len, + uint16_t offset, uint8_t flags) { struct bt_mesh_proxy_client *client = NULL; - u16_t *value = attr->user_data; + uint16_t *value = attr->user_data; BT_DBG("len %u: %s", len, bt_hex(buf, len)); @@ -684,9 +683,9 @@ static ssize_t prov_ccc_write(struct bt_mesh_conn *conn, static ssize_t prov_ccc_read(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - void *buf, u16_t len, u16_t offset) + void *buf, uint16_t len, uint16_t offset) { - u16_t *value = attr->user_data; + uint16_t *value = attr->user_data; return bt_mesh_gatts_attr_read(conn, attr, buf, len, offset, value, sizeof(*value)); @@ -787,11 +786,11 @@ int bt_mesh_proxy_server_prov_disable(bool disconnect) #if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER) static ssize_t proxy_ccc_write(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - const void *buf, u16_t len, - u16_t offset, u8_t flags) + const void *buf, uint16_t len, + uint16_t offset, uint8_t flags) { struct bt_mesh_proxy_client *client = NULL; - u16_t value = 0U; + uint16_t value = 0U; BT_DBG("len %u: %s", len, bt_hex(buf, len)); @@ -822,9 +821,9 @@ static ssize_t proxy_ccc_write(struct bt_mesh_conn *conn, static ssize_t proxy_ccc_read(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, - void *buf, u16_t len, u16_t offset) + void *buf, uint16_t len, uint16_t offset) { - u16_t *value = attr->user_data; + uint16_t *value = attr->user_data; return bt_mesh_gatts_attr_read(conn, attr, buf, len, offset, value, sizeof(*value)); @@ -918,7 +917,7 @@ int bt_mesh_proxy_server_gatt_disable(void) return 0; } -void bt_mesh_proxy_server_addr_add(struct net_buf_simple *buf, u16_t addr) +void bt_mesh_proxy_server_addr_add(struct net_buf_simple *buf, uint16_t addr) { struct bt_mesh_proxy_client *client = CONTAINER_OF(buf, struct bt_mesh_proxy_client, buf); @@ -933,7 +932,7 @@ void bt_mesh_proxy_server_addr_add(struct net_buf_simple *buf, u16_t addr) } static bool client_filter_match(struct bt_mesh_proxy_client *client, - u16_t addr) + uint16_t addr) { int i; @@ -964,7 +963,7 @@ static bool client_filter_match(struct bt_mesh_proxy_client *client, return false; } -bool bt_mesh_proxy_server_relay(struct net_buf_simple *buf, u16_t dst) +bool bt_mesh_proxy_server_relay(struct net_buf_simple *buf, uint16_t dst) { bool relayed = false; int i; @@ -998,7 +997,7 @@ bool bt_mesh_proxy_server_relay(struct net_buf_simple *buf, u16_t dst) #endif /* CONFIG_BLE_MESH_GATT_PROXY_SERVER */ -static int proxy_send(struct bt_mesh_conn *conn, const void *data, u16_t len) +static int proxy_send(struct bt_mesh_conn *conn, const void *data, uint16_t len) { BT_DBG("%u bytes: %s", len, bt_hex(data, len)); @@ -1017,10 +1016,10 @@ static int proxy_send(struct bt_mesh_conn *conn, const void *data, u16_t len) return 0; } -static int proxy_segment_and_send(struct bt_mesh_conn *conn, u8_t type, +static int proxy_segment_and_send(struct bt_mesh_conn *conn, uint8_t type, struct net_buf_simple *msg) { - u16_t mtu = 0U; + uint16_t mtu = 0U; BT_DBG("conn %p type 0x%02x len %u: %s", conn, type, msg->len, bt_hex(msg->data, msg->len)); @@ -1051,7 +1050,7 @@ static int proxy_segment_and_send(struct bt_mesh_conn *conn, u8_t type, return 0; } -int bt_mesh_proxy_server_send(struct bt_mesh_conn *conn, u8_t type, +int bt_mesh_proxy_server_send(struct bt_mesh_conn *conn, uint8_t type, struct net_buf_simple *msg) { struct bt_mesh_proxy_client *client = find_client(conn); @@ -1070,7 +1069,7 @@ int bt_mesh_proxy_server_send(struct bt_mesh_conn *conn, u8_t type, } #if defined(CONFIG_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_mesh_adv_data prov_ad[] = { BLE_MESH_ADV_DATA_BYTES(BLE_MESH_DATA_FLAGS, (BLE_MESH_AD_GENERAL | BLE_MESH_AD_NO_BREDR)), @@ -1089,7 +1088,7 @@ static const struct bt_mesh_adv_data prov_ad[] = { #define NODE_ID_TIMEOUT K_SECONDS(CONFIG_BLE_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_mesh_adv_data node_id_ad[] = { BLE_MESH_ADV_DATA_BYTES(BLE_MESH_DATA_FLAGS, (BLE_MESH_AD_GENERAL | BLE_MESH_AD_NO_BREDR)), @@ -1118,7 +1117,7 @@ static size_t gatt_proxy_adv_create(struct bt_mesh_adv_data *proxy_sd) proxy_sd->data_len = name_len; } - proxy_sd->data = (const u8_t *)name; + proxy_sd->data = (const uint8_t *)name; return 1; } @@ -1127,7 +1126,7 @@ static int node_id_adv(struct bt_mesh_subnet *sub) { struct bt_mesh_adv_data proxy_sd = {0}; size_t proxy_sd_len = 0U; - u8_t tmp[16] = {0}; + uint8_t tmp[16] = {0}; int err = 0; BT_DBG("%s", __func__); @@ -1244,9 +1243,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 = 0; BT_DBG("%s", __func__); @@ -1262,7 +1261,7 @@ static s32_t gatt_proxy_advertise(struct bt_mesh_subnet *sub) } if (sub->node_id == BLE_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; @@ -1282,7 +1281,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 = 0; + int32_t max_timeout = 0; /* We use NODE_ID_TIMEOUT as a starting point since it may * be less than 60 seconds. Divide this period into at least @@ -1324,7 +1323,7 @@ static size_t gatt_prov_adv_create(struct bt_mesh_adv_data prov_sd[2]) } else { prov_sd[0].type = BLE_MESH_DATA_URI; prov_sd[0].data_len = uri_len; - prov_sd[0].data = (const u8_t *)prov->uri; + prov_sd[0].data = (const uint8_t *)prov->uri; sd_space -= 2 + uri_len; prov_sd_len++; } @@ -1341,7 +1340,7 @@ static size_t gatt_prov_adv_create(struct bt_mesh_adv_data prov_sd[2]) prov_sd[prov_sd_len].data_len = name_len; } - prov_sd[prov_sd_len].data = (const u8_t *)name; + prov_sd[prov_sd_len].data = (const uint8_t *)name; prov_sd_len++; } @@ -1349,7 +1348,7 @@ static size_t gatt_prov_adv_create(struct bt_mesh_adv_data prov_sd[2]) } #endif /* CONFIG_BLE_MESH_PB_GATT */ -s32_t bt_mesh_proxy_server_adv_start(void) +int32_t bt_mesh_proxy_server_adv_start(void) { BT_DBG("%s", __func__); diff --git a/components/bt/esp_ble_mesh/mesh_core/proxy_server.h b/components/bt/esp_ble_mesh/mesh_core/proxy_server.h index c8c277027b..e473306027 100644 --- a/components/bt/esp_ble_mesh/mesh_core/proxy_server.h +++ b/components/bt/esp_ble_mesh/mesh_core/proxy_server.h @@ -40,7 +40,7 @@ extern "C" { int bt_mesh_set_device_name(const char *name); -int bt_mesh_proxy_server_send(struct bt_mesh_conn *conn, u8_t type, +int bt_mesh_proxy_server_send(struct bt_mesh_conn *conn, uint8_t type, struct net_buf_simple *msg); int bt_mesh_proxy_server_prov_enable(void); @@ -55,14 +55,14 @@ void bt_mesh_proxy_server_beacon_send(struct bt_mesh_subnet *sub); struct net_buf_simple *bt_mesh_proxy_server_get_buf(void); -s32_t bt_mesh_proxy_server_adv_start(void); +int32_t bt_mesh_proxy_server_adv_start(void); void bt_mesh_proxy_server_adv_stop(void); void bt_mesh_proxy_server_identity_start(struct bt_mesh_subnet *sub); void bt_mesh_proxy_server_identity_stop(struct bt_mesh_subnet *sub); -bool bt_mesh_proxy_server_relay(struct net_buf_simple *buf, u16_t dst); -void bt_mesh_proxy_server_addr_add(struct net_buf_simple *buf, u16_t addr); +bool bt_mesh_proxy_server_relay(struct net_buf_simple *buf, uint16_t dst); +void bt_mesh_proxy_server_addr_add(struct net_buf_simple *buf, uint16_t addr); int bt_mesh_proxy_server_init(void); int bt_mesh_proxy_server_deinit(void); diff --git a/components/bt/esp_ble_mesh/mesh_core/settings.c b/components/bt/esp_ble_mesh/mesh_core/settings.c index 8c64604c37..a029512961 100644 --- a/components/bt/esp_ble_mesh/mesh_core/settings.c +++ b/components/bt/esp_ble_mesh/mesh_core/settings.c @@ -8,8 +8,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_SETTINGS) - #include "mesh.h" #include "crypto.h" #include "transport.h" @@ -59,10 +57,10 @@ * gets deleted its struct becomes invalid and may be reused for other keys. */ static struct key_update { - u16_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 */ + 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 */ } key_updates[CONFIG_BLE_MESH_APP_KEY_COUNT + CONFIG_BLE_MESH_SUBNET_COUNT]; static struct k_delayed_work pending_store; @@ -70,78 +68,78 @@ static void store_pending(struct k_work *work); /* 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, - indefinite: 1; + uint16_t dst; + uint8_t period; + uint8_t ttl; + uint16_t feat; + uint16_t net_idx:12, + indefinite:1; }; /* Miscellaneous 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, - iv_duration: 7; + uint32_t iv_index; + uint8_t iv_update:1, + iv_duration:7; } __packed; /* Replay Protection List storage */ struct rpl_val { - u32_t seq: 24, - old_iv: 1; + uint32_t seq:24, + old_iv:1; }; /* NetKey storage information */ struct net_key_val { - u8_t kr_flag: 1, - kr_phase: 7; - u8_t val[2][16]; + uint8_t kr_flag:1, + kr_phase:7; + uint8_t val[2][16]; } __packed; /* AppKey storage information */ struct app_key_val { - u16_t net_idx; - bool updated; - u8_t val[2][16]; + uint16_t net_idx; + bool updated; + 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, - cred: 1; + 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; /* We need this so we don't overwrite app-hardcoded values in case FCB @@ -153,21 +151,21 @@ static struct { } stored_cfg; struct prov_info { - u16_t primary_addr; - u16_t alloc_addr; + uint16_t primary_addr; + uint16_t alloc_addr; }; struct node_info { - u8_t addr[6]; - u8_t addr_type; - u8_t dev_uuid[16]; - u16_t oob_info; - u16_t unicast_addr; - u8_t element_num; - u16_t net_idx; - u8_t flags; - u32_t iv_index; - u8_t dev_key[16]; + uint8_t addr[6]; + uint8_t addr_type; + uint8_t dev_uuid[16]; + uint16_t oob_info; + uint16_t unicast_addr; + uint8_t element_num; + uint16_t net_idx; + uint8_t flags; + uint32_t iv_index; + uint8_t dev_key[16]; } __packed; static bt_mesh_mutex_t settings_lock; @@ -203,7 +201,7 @@ static int role_set(const char *name) BT_DBG("%s", __func__); - err = bt_mesh_load_core_settings(name, (u8_t *)bt_mesh.flags, sizeof(bt_mesh.flags), &exist); + err = bt_mesh_load_core_settings(name, (uint8_t *)bt_mesh.flags, sizeof(bt_mesh.flags), &exist); if (err) { BT_ERR("Failed to load mesh device role"); return err; @@ -231,7 +229,7 @@ static int net_set(const char *name) BT_DBG("%s", __func__); - err = bt_mesh_load_core_settings(name, (u8_t *)&net, sizeof(net), &exist); + err = bt_mesh_load_core_settings(name, (uint8_t *)&net, sizeof(net), &exist); if (err) { BT_ERR("Failed to load node net info"); memset(bt_mesh.dev_key, 0, sizeof(bt_mesh.dev_key)); @@ -260,7 +258,7 @@ static int iv_set(const char *name) BT_DBG("%s", __func__); - err = bt_mesh_load_core_settings(name, (u8_t *)&iv, sizeof(iv), &exist); + err = bt_mesh_load_core_settings(name, (uint8_t *)&iv, sizeof(iv), &exist); if (err) { BT_ERR("Failed to load iv_index"); bt_mesh.iv_index = 0U; @@ -290,7 +288,7 @@ static int seq_set(const char *name) BT_DBG("%s", __func__); - err = bt_mesh_load_core_settings(name, (u8_t *)&seq, sizeof(seq), &exist); + err = bt_mesh_load_core_settings(name, (uint8_t *)&seq, sizeof(seq), &exist); if (err) { BT_ERR("Failed to load sequence number"); bt_mesh.seq = 0U; @@ -318,7 +316,7 @@ static int seq_set(const char *name) return 0; } -static struct bt_mesh_rpl *rpl_find(u16_t src) +static struct bt_mesh_rpl *rpl_find(uint16_t src) { int i; @@ -331,7 +329,7 @@ static struct bt_mesh_rpl *rpl_find(u16_t src) return NULL; } -static struct bt_mesh_rpl *rpl_alloc(u16_t src) +static struct bt_mesh_rpl *rpl_alloc(uint16_t src) { int i; @@ -366,7 +364,7 @@ static int rpl_set(const char *name) length = buf->len; for (i = 0; i < length / SETTINGS_ITEM_SIZE; i++) { - u16_t src = net_buf_simple_pull_le16(buf); + uint16_t src = net_buf_simple_pull_le16(buf); if (!BLE_MESH_ADDR_IS_UNICAST(src)) { BT_ERR("Invalid source address 0x%04x", src); @@ -375,7 +373,7 @@ static int rpl_set(const char *name) sprintf(get, "mesh/rpl/%04x", src); - err = bt_mesh_load_core_settings(get, (u8_t *)&rpl, sizeof(rpl), &exist); + err = bt_mesh_load_core_settings(get, (uint8_t *)&rpl, sizeof(rpl), &exist); if (err) { BT_ERR("Failed to load RPL entry 0x%04x", src); continue; @@ -407,7 +405,7 @@ free: return err; } -static struct bt_mesh_subnet *subnet_alloc(u16_t net_idx) +static struct bt_mesh_subnet *subnet_alloc(uint16_t net_idx) { int i; @@ -442,10 +440,10 @@ static int net_key_set(const char *name) length = buf->len; for (i = 0; i < length / SETTINGS_ITEM_SIZE; i++) { - u16_t net_idx = net_buf_simple_pull_le16(buf); + uint16_t net_idx = net_buf_simple_pull_le16(buf); sprintf(get, "mesh/nk/%04x", net_idx); - err = bt_mesh_load_core_settings(get, (u8_t *)&key, sizeof(key), &exist); + err = bt_mesh_load_core_settings(get, (uint8_t *)&key, sizeof(key), &exist); if (err) { BT_ERR("Failed to load NetKey 0x%03x", net_idx); continue; @@ -502,10 +500,10 @@ static int app_key_set(const char *name) length = buf->len; for (i = 0; i < length / SETTINGS_ITEM_SIZE; i++) { - u16_t app_idx = net_buf_simple_pull_le16(buf); + uint16_t app_idx = net_buf_simple_pull_le16(buf); sprintf(get, "mesh/ak/%04x", app_idx); - err = bt_mesh_load_core_settings(get, (u8_t *)&key, sizeof(key), &exist); + err = bt_mesh_load_core_settings(get, (uint8_t *)&key, sizeof(key), &exist); if (err) { BT_ERR("Failed to load AppKey 0x%03x", app_idx); continue; @@ -563,7 +561,7 @@ static int hb_pub_set(const char *name) return -EINVAL; } - err = bt_mesh_load_core_settings(name, (u8_t *)&hb_val, sizeof(hb_val), &exist); + err = bt_mesh_load_core_settings(name, (uint8_t *)&hb_val, sizeof(hb_val), &exist); if (err) { BT_ERR("Failed to load heartbeat publication"); hb_pub->dst = BLE_MESH_ADDR_UNASSIGNED; @@ -610,7 +608,7 @@ static int cfg_set(const char *name) return -EINVAL; } - err = bt_mesh_load_core_settings(name, (u8_t *)&val, sizeof(val), &exist); + err = bt_mesh_load_core_settings(name, (uint8_t *)&val, sizeof(val), &exist); if (err) { BT_ERR("Failed to load configuration state"); stored_cfg.valid = false; @@ -630,7 +628,7 @@ static int cfg_set(const char *name) return 0; } -static int model_set_bind(bool vnd, struct bt_mesh_model *model, u16_t model_key) +static int model_set_bind(bool vnd, struct bt_mesh_model *model, uint16_t model_key) { char name[16] = {'\0'}; bool exist = false; @@ -643,7 +641,7 @@ static int model_set_bind(bool vnd, struct bt_mesh_model *model, u16_t model_key } sprintf(name, "mesh/%s/%04x/b", vnd ? "v" : "s", model_key); - err = bt_mesh_load_core_settings(name, (u8_t *)model->keys, sizeof(model->keys), &exist); + err = bt_mesh_load_core_settings(name, (uint8_t *)model->keys, sizeof(model->keys), &exist); if (err) { BT_ERR("Failed to load model bound keys"); return -EIO; @@ -656,7 +654,7 @@ static int model_set_bind(bool vnd, struct bt_mesh_model *model, u16_t model_key return 0; } -static int model_set_sub(bool vnd, struct bt_mesh_model *model, u16_t model_key) +static int model_set_sub(bool vnd, struct bt_mesh_model *model, uint16_t model_key) { char name[16] = {'\0'}; bool exist = false; @@ -669,7 +667,7 @@ static int model_set_sub(bool vnd, struct bt_mesh_model *model, u16_t model_key) } sprintf(name, "mesh/%s/%04x/s", vnd ? "v" : "s", model_key); - err = bt_mesh_load_core_settings(name, (u8_t *)model->groups, sizeof(model->groups), &exist); + err = bt_mesh_load_core_settings(name, (uint8_t *)model->groups, sizeof(model->groups), &exist); if (err) { BT_ERR("Failed to load model subscriptions"); return -EIO; @@ -682,7 +680,7 @@ static int model_set_sub(bool vnd, struct bt_mesh_model *model, u16_t model_key) return 0; } -static int model_set_pub(bool vnd, struct bt_mesh_model *model, u16_t model_key) +static int model_set_pub(bool vnd, struct bt_mesh_model *model, uint16_t model_key) { struct mod_pub_val pub = {0}; char name[16] = {'\0'}; @@ -696,7 +694,7 @@ static int model_set_pub(bool vnd, struct bt_mesh_model *model, u16_t model_key) } sprintf(name, "mesh/%s/%04x/p", vnd ? "v" : "s", model_key); - err = bt_mesh_load_core_settings(name, (u8_t *)&pub, sizeof(pub), &exist); + err = bt_mesh_load_core_settings(name, (uint8_t *)&pub, sizeof(pub), &exist); if (err) { BT_ERR("Failed to load model publication"); model->pub->addr = BLE_MESH_ADDR_UNASSIGNED; @@ -730,7 +728,7 @@ static int model_set(bool vnd, const char *name) { struct bt_mesh_model *model = NULL; struct net_buf_simple *buf = NULL; - u8_t elem_idx = 0U, model_idx = 0U; + uint8_t elem_idx = 0U, model_idx = 0U; size_t length = 0U; int i; @@ -744,7 +742,7 @@ static int model_set(bool vnd, const char *name) length = buf->len; for (i = 0; i < length / SETTINGS_ITEM_SIZE; i++) { - u16_t model_key = net_buf_simple_pull_le16(buf); + uint16_t model_key = net_buf_simple_pull_le16(buf); elem_idx = BLE_MESH_GET_ELEM_IDX(model_key); model_idx = BLE_MESH_GET_MODEL_IDX(model_key); @@ -797,10 +795,10 @@ static int va_set(const char *name) length = buf->len; for (i = 0; i < length / SETTINGS_ITEM_SIZE; i++) { - u16_t index = net_buf_simple_pull_le16(buf); + uint16_t index = net_buf_simple_pull_le16(buf); sprintf(get, "mesh/va/%04x", index); - err = bt_mesh_load_core_settings(get, (u8_t *)&va, sizeof(va), &exist); + err = bt_mesh_load_core_settings(get, (uint8_t *)&va, sizeof(va), &exist); if (err) { BT_ERR("Failed to load virtual address 0x%04x", index); continue; @@ -844,7 +842,7 @@ static int p_prov_set(const char *name) BT_DBG("%s", __func__); - err = bt_mesh_load_core_settings(name, (u8_t *)&val, sizeof(val), &exist); + err = bt_mesh_load_core_settings(name, (uint8_t *)&val, sizeof(val), &exist); if (err) { BT_ERR("Failed to load next address allocation"); return 0; @@ -864,13 +862,13 @@ static int p_prov_set(const char *name) static int p_net_idx_set(const char *name) { - u16_t net_idx = 0U; + uint16_t net_idx = 0U; bool exist = false; int err = 0; BT_DBG("%s", __func__); - err = bt_mesh_load_core_settings(name, (u8_t *)&net_idx, sizeof(net_idx), &exist); + err = bt_mesh_load_core_settings(name, (uint8_t *)&net_idx, sizeof(net_idx), &exist); if (err) { BT_ERR("Failed to load next NetKeyIndex alloc"); return 0; @@ -889,13 +887,13 @@ static int p_net_idx_set(const char *name) static int p_app_idx_set(const char *name) { - u16_t app_idx = 0U; + uint16_t app_idx = 0U; bool exist = false; int err = 0; BT_DBG("%s", __func__); - err = bt_mesh_load_core_settings(name, (u8_t *)&app_idx, sizeof(app_idx), &exist); + err = bt_mesh_load_core_settings(name, (uint8_t *)&app_idx, sizeof(app_idx), &exist); if (err) { BT_ERR("Failed to load next AppKeyIndex alloc"); return 0; @@ -971,10 +969,10 @@ static int p_net_key_set(const char *name) length = buf->len; for (i = 0; i < length / SETTINGS_ITEM_SIZE; i++) { - u16_t net_idx = net_buf_simple_pull_le16(buf); + uint16_t net_idx = net_buf_simple_pull_le16(buf); sprintf(get, "mesh/pnk/%04x", net_idx); - err = bt_mesh_load_core_settings(get, (u8_t *)&key, sizeof(key), &exist); + err = bt_mesh_load_core_settings(get, (uint8_t *)&key, sizeof(key), &exist); if (err) { BT_ERR("Failed to load NetKey 0x%03x", net_idx); continue; @@ -1031,10 +1029,10 @@ static int p_app_key_set(const char *name) length = buf->len; for (i = 0; i < length / SETTINGS_ITEM_SIZE; i++) { - u16_t app_idx = net_buf_simple_pull_le16(buf); + uint16_t app_idx = net_buf_simple_pull_le16(buf); sprintf(get, "mesh/pak/%04x", app_idx); - err = bt_mesh_load_core_settings(get, (u8_t *)&key, sizeof(key), &exist); + err = bt_mesh_load_core_settings(get, (uint8_t *)&key, sizeof(key), &exist); if (err) { BT_ERR("Failed to load AppKey 0x%03x", app_idx); continue; @@ -1078,7 +1076,7 @@ free: return err; } -static int node_info_set(u16_t addr, bool *exist) +static int node_info_set(uint16_t addr, bool *exist) { struct bt_mesh_node node = {0}; struct node_info info = {0}; @@ -1086,7 +1084,7 @@ static int node_info_set(u16_t addr, bool *exist) int err = 0; sprintf(get, "mesh/pn/%04x/i", addr); - err = bt_mesh_load_core_settings(get, (u8_t *)&info, sizeof(info), exist); + err = bt_mesh_load_core_settings(get, (uint8_t *)&info, sizeof(info), exist); if (err) { BT_ERR("Failed to load node 0x%04x info", addr); return -EIO; @@ -1118,7 +1116,7 @@ static int node_info_set(u16_t addr, bool *exist) return 0; } -static int node_name_set(u16_t addr) +static int node_name_set(uint16_t addr) { char name[BLE_MESH_NODE_NAME_SIZE + 1] = {0}; char get[16] = {'\0'}; @@ -1126,7 +1124,7 @@ static int node_name_set(u16_t addr) int err = 0; sprintf(get, "mesh/pn/%04x/n", addr); - err = bt_mesh_load_core_settings(get, (u8_t *)name, BLE_MESH_NODE_NAME_SIZE, &exist); + err = bt_mesh_load_core_settings(get, (uint8_t *)name, BLE_MESH_NODE_NAME_SIZE, &exist); if (err) { BT_ERR("Failed to load node 0x%04x name", addr); return -EIO; @@ -1147,7 +1145,7 @@ static int node_name_set(u16_t addr) return 0; } -static int node_comp_data_set(u16_t addr) +static int node_comp_data_set(uint16_t addr) { struct net_buf_simple *buf = NULL; char get[16] = {'\0'}; @@ -1185,7 +1183,7 @@ static int p_node_set(const char *name) length = buf->len; for (i = 0; i < length / SETTINGS_ITEM_SIZE; i++) { - u16_t addr = net_buf_simple_pull_le16(buf); + uint16_t addr = net_buf_simple_pull_le16(buf); if (!BLE_MESH_ADDR_IS_UNICAST(addr)) { BT_ERR("Invalid unicast address 0x%04x", addr); continue; @@ -1288,7 +1286,7 @@ int settings_core_load(void) settings[i].func(settings[i].name); if (!strcmp(settings[i].name, "mesh/role")) { - u8_t role = bt_mesh_atomic_get(bt_mesh.flags) & BLE_MESH_SETTINGS_ROLE_BIT_MASK; + uint8_t role = bt_mesh_atomic_get(bt_mesh.flags) & BLE_MESH_SETTINGS_ROLE_BIT_MASK; switch (role) { case BLE_MESH_SETTINGS_ROLE_NONE: BT_INFO("Mesh device just starts up, no restore"); @@ -1345,7 +1343,7 @@ static void commit_model(struct bt_mesh_model *model, struct bt_mesh_elem *elem, { if (model->pub && model->pub->update && model->pub->addr != BLE_MESH_ADDR_UNASSIGNED) { - s32_t ms = bt_mesh_model_pub_period_get(model); + int32_t ms = bt_mesh_model_pub_period_get(model); if (ms) { BT_DBG("Starting publish timer (period %u ms)", ms); k_delayed_work_submit(&model->pub->timer, ms); @@ -1463,7 +1461,7 @@ int settings_core_commit(void) static void schedule_store(int flag) { - s32_t timeout = 0, remaining = 0; + int32_t timeout = 0, remaining = 0; bt_mesh_atomic_set_bit(bt_mesh.flags, flag); @@ -1516,14 +1514,14 @@ static void store_pending_net(void) net.primary_addr = bt_mesh_primary_addr(); memcpy(net.dev_key, bt_mesh.dev_key, 16); - bt_mesh_save_core_settings("mesh/net", (const u8_t *)&net, sizeof(net)); + bt_mesh_save_core_settings("mesh/net", (const uint8_t *)&net, sizeof(net)); } void bt_mesh_store_role(void) { BT_DBG("Store, device role %lu", bt_mesh_atomic_get(bt_mesh.flags) & BLE_MESH_SETTINGS_ROLE_BIT_MASK); - bt_mesh_save_core_settings("mesh/role", (const u8_t *)bt_mesh.flags, sizeof(bt_mesh.flags)); + bt_mesh_save_core_settings("mesh/role", (const uint8_t *)bt_mesh.flags, sizeof(bt_mesh.flags)); } void bt_mesh_store_net(void) @@ -1539,7 +1537,7 @@ static void store_pending_iv(void) iv.iv_update = bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_IVU_IN_PROGRESS); iv.iv_duration = bt_mesh.ivu_duration; - bt_mesh_save_core_settings("mesh/iv", (const u8_t *)&iv, sizeof(iv)); + bt_mesh_save_core_settings("mesh/iv", (const uint8_t *)&iv, sizeof(iv)); } void bt_mesh_store_iv(bool only_duration) @@ -1564,7 +1562,7 @@ static void store_pending_seq(void) sys_put_le24(bt_mesh.seq, seq.val); - bt_mesh_save_core_settings("mesh/seq", (const u8_t *)&seq, sizeof(seq)); + bt_mesh_save_core_settings("mesh/seq", (const uint8_t *)&seq, sizeof(seq)); } void bt_mesh_store_seq(void) @@ -1595,7 +1593,7 @@ static void store_rpl(struct bt_mesh_rpl *entry) rpl.old_iv = entry->old_iv; sprintf(name, "mesh/rpl/%04x", entry->src); - err = bt_mesh_save_core_settings(name, (const u8_t *)&rpl, sizeof(rpl)); + err = bt_mesh_save_core_settings(name, (const uint8_t *)&rpl, sizeof(rpl)); if (err) { BT_ERR("Failed to store RPL entry 0x%04x", entry->src); return; @@ -1614,7 +1612,7 @@ static void clear_rpl(void) struct net_buf_simple *buf = NULL; char name[16] = {'\0'}; size_t length = 0U; - u16_t src = 0U; + uint16_t src = 0U; int i; BT_DBG("%s", __func__); @@ -1678,7 +1676,7 @@ static void store_pending_hb_pub(void) val.feat = hb_pub->feat; val.net_idx = hb_pub->net_idx; - bt_mesh_save_core_settings("mesh/hb_pub", (const u8_t *)&val, sizeof(val)); + bt_mesh_save_core_settings("mesh/hb_pub", (const uint8_t *)&val, sizeof(val)); } static void clear_hb_pub(void) @@ -1705,7 +1703,7 @@ static void store_pending_cfg(void) val.frnd = cfg->frnd; val.default_ttl = cfg->default_ttl; - bt_mesh_save_core_settings("mesh/cfg", (const u8_t *)&val, sizeof(val)); + bt_mesh_save_core_settings("mesh/cfg", (const uint8_t *)&val, sizeof(val)); } static void clear_cfg(void) @@ -1714,7 +1712,7 @@ static void clear_cfg(void) bt_mesh_erase_core_settings("mesh/cfg"); } -static void clear_app_key(u16_t app_idx) +static void clear_app_key(uint16_t app_idx) { char name[16] = {'\0'}; int err = 0; @@ -1732,7 +1730,7 @@ static void clear_app_key(u16_t app_idx) return; } -static void clear_net_key(u16_t net_idx) +static void clear_net_key(uint16_t net_idx) { char name[16] = {'\0'}; int err = 0; @@ -1765,7 +1763,7 @@ static void store_net_key(struct bt_mesh_subnet *sub) key.kr_phase = sub->kr_phase; sprintf(name, "mesh/nk/%04x", sub->net_idx); - err = bt_mesh_save_core_settings(name, (const u8_t *)&key, sizeof(key)); + err = bt_mesh_save_core_settings(name, (const uint8_t *)&key, sizeof(key)); if (err) { BT_ERR("Failed to store NetKey 0x%03x", sub->net_idx); return; @@ -1791,7 +1789,7 @@ static void store_app_key(struct bt_mesh_app_key *app) memcpy(key.val[1], app->keys[1].val, 16); sprintf(name, "mesh/ak/%04x", app->app_idx); - err = bt_mesh_save_core_settings(name, (const u8_t *)&key, sizeof(key)); + err = bt_mesh_save_core_settings(name, (const uint8_t *)&key, sizeof(key)); if (err) { BT_ERR("Failed to store AppKey 0x%03x", app->app_idx); return; @@ -1849,13 +1847,13 @@ static void store_pending_keys(void) static void store_pending_mod_bind(struct bt_mesh_model *model, bool vnd) { char name[16] = {'\0'}; - u16_t model_key = 0U; + uint16_t model_key = 0U; int err = 0; model_key = BLE_MESH_GET_MODEL_KEY(model->elem_idx, model->model_idx); sprintf(name, "mesh/%s/%04x/b", vnd ? "v" : "s", model_key); - err = bt_mesh_save_core_settings(name, (const u8_t *)model->keys, sizeof(model->keys)); + err = bt_mesh_save_core_settings(name, (const uint8_t *)model->keys, sizeof(model->keys)); if (err) { BT_ERR("Failed to store %s", name); return; @@ -1873,13 +1871,13 @@ static void store_pending_mod_bind(struct bt_mesh_model *model, bool vnd) static void store_pending_mod_sub(struct bt_mesh_model *model, bool vnd) { char name[16] = {'\0'}; - u16_t model_key = 0U; + uint16_t model_key = 0U; int err = 0; model_key = BLE_MESH_GET_MODEL_KEY(model->elem_idx, model->model_idx); sprintf(name, "mesh/%s/%04x/s", vnd ? "v" : "s", model_key); - err = bt_mesh_save_core_settings(name, (const u8_t *)model->groups, sizeof(model->groups)); + err = bt_mesh_save_core_settings(name, (const uint8_t *)model->groups, sizeof(model->groups)); if (err) { BT_ERR("Failed to store %s", name); return; @@ -1898,7 +1896,7 @@ static void store_pending_mod_pub(struct bt_mesh_model *model, bool vnd) { struct mod_pub_val pub = {0}; char name[16] = {'\0'}; - u16_t model_key = 0U; + uint16_t model_key = 0U; int err = 0; if (!model->pub) { @@ -1917,7 +1915,7 @@ static void store_pending_mod_pub(struct bt_mesh_model *model, bool vnd) pub.period_div = model->pub->period_div; pub.cred = model->pub->cred; - err = bt_mesh_save_core_settings(name, (const u8_t *)&pub, sizeof(pub)); + err = bt_mesh_save_core_settings(name, (const uint8_t *)&pub, sizeof(pub)); if (err) { BT_ERR("Failed to store %s", name); return; @@ -1959,7 +1957,7 @@ static void store_pending_mod(struct bt_mesh_model *model, static void clear_mod_bind(struct bt_mesh_model *model, bool vnd) { char name[16] = {'\0'}; - u16_t model_key = 0U; + uint16_t model_key = 0U; model_key = BLE_MESH_GET_MODEL_KEY(model->elem_idx, model->model_idx); sprintf(name, "mesh/%s/%04x/b", vnd ? "v" : "s", model_key); @@ -1971,7 +1969,7 @@ static void clear_mod_bind(struct bt_mesh_model *model, bool vnd) static void clear_mod_sub(struct bt_mesh_model *model, bool vnd) { char name[16] = {'\0'}; - u16_t model_key = 0U; + uint16_t model_key = 0U; model_key = BLE_MESH_GET_MODEL_KEY(model->elem_idx, model->model_idx); sprintf(name, "mesh/%s/%04x/s", vnd ? "v" : "s", model_key); @@ -1983,7 +1981,7 @@ static void clear_mod_sub(struct bt_mesh_model *model, bool vnd) static void clear_mod_pub(struct bt_mesh_model *model, bool vnd) { char name[16] = {'\0'}; - u16_t model_key = 0U; + uint16_t model_key = 0U; model_key = BLE_MESH_GET_MODEL_KEY(model->elem_idx, model->model_idx); sprintf(name, "mesh/%s/%04x/p", vnd ? "v" : "s", model_key); @@ -2022,7 +2020,7 @@ static void store_pending_va(void) struct va_val va = {0}; char name[16] = {'\0'}; struct label *lab = NULL; - u16_t i = 0U; + uint16_t i = 0U; int err = 0; for (i = 0U; (lab = get_label(i)) != NULL; i++) { @@ -2039,7 +2037,7 @@ static void store_pending_va(void) va.ref = lab->ref; va.addr = lab->addr; memcpy(va.uuid, lab->uuid, 16); - err = bt_mesh_save_core_settings(name, (const u8_t *)&va, sizeof(va)); + err = bt_mesh_save_core_settings(name, (const uint8_t *)&va, sizeof(va)); } if (err) { BT_ERR("Failed to %s virtual address %s", @@ -2144,8 +2142,8 @@ void bt_mesh_store_rpl(struct bt_mesh_rpl *entry) schedule_store(BLE_MESH_RPL_PENDING); } -static struct key_update *key_update_find(bool app_key, u16_t key_idx, - struct key_update **free_slot) +static struct key_update *key_update_find(bool app_key, uint16_t key_idx, + struct key_update **free_slot) { struct key_update *match = NULL; int i; @@ -2345,7 +2343,7 @@ void bt_mesh_store_label(void) * key: "mesh/pn/xxxx/n" -> write/read to set/get the "xxxx" provisioned node name * key: "mesh/pn/xxxx/c" -> write/read to set/get the "xxxx" provisioned node composition data */ -void bt_mesh_store_prov_info(u16_t primary_addr, u16_t alloc_addr) +void bt_mesh_store_prov_info(uint16_t primary_addr, uint16_t alloc_addr) { struct prov_info val = {0}; @@ -2354,7 +2352,7 @@ void bt_mesh_store_prov_info(u16_t primary_addr, u16_t alloc_addr) val.primary_addr = primary_addr; val.alloc_addr = alloc_addr; - bt_mesh_save_core_settings("mesh/p_prov", (const u8_t *)&val, sizeof(val)); + bt_mesh_save_core_settings("mesh/p_prov", (const uint8_t *)&val, sizeof(val)); } void bt_mesh_clear_prov_info(void) @@ -2375,7 +2373,7 @@ static void store_p_net_key(struct bt_mesh_subnet *sub) key.kr_phase = sub->kr_phase; sprintf(name, "mesh/pnk/%04x", sub->net_idx); - err = bt_mesh_save_core_settings(name, (const u8_t *)&key, sizeof(key)); + err = bt_mesh_save_core_settings(name, (const uint8_t *)&key, sizeof(key)); if (err) { BT_ERR("Failed to store NetKey 0x%03x", sub->net_idx); return; @@ -2399,7 +2397,7 @@ static void store_p_app_key(struct bt_mesh_app_key *app) memcpy(key.val[1], app->keys[1].val, 16); sprintf(name, "mesh/pak/%04x", app->app_idx); - err = bt_mesh_save_core_settings(name, (const u8_t *)&key, sizeof(key)); + err = bt_mesh_save_core_settings(name, (const uint8_t *)&key, sizeof(key)); if (err) { BT_ERR("Failed to store AppKey 0x%03x", app->app_idx); return; @@ -2416,7 +2414,7 @@ void bt_mesh_store_p_net_idx(void) BT_DBG("Store, p_net_idx_next 0x%03x", bt_mesh.p_net_idx_next); bt_mesh_save_core_settings("mesh/p_netidx", - (const u8_t *)&bt_mesh.p_net_idx_next, sizeof(bt_mesh.p_net_idx_next)); + (const uint8_t *)&bt_mesh.p_net_idx_next, sizeof(bt_mesh.p_net_idx_next)); } void bt_mesh_clear_p_net_idx(void) @@ -2430,7 +2428,7 @@ void bt_mesh_store_p_app_idx(void) BT_DBG("Store, p_app_idx_next 0x%03x", bt_mesh.p_app_idx_next); bt_mesh_save_core_settings("mesh/p_appidx", - (const u8_t *)&bt_mesh.p_app_idx_next, sizeof(bt_mesh.p_app_idx_next)); + (const uint8_t *)&bt_mesh.p_app_idx_next, sizeof(bt_mesh.p_app_idx_next)); } void bt_mesh_clear_p_app_idx(void) @@ -2465,7 +2463,7 @@ void bt_mesh_store_p_app_key(struct bt_mesh_app_key *key) store_p_app_key(key); } -void bt_mesh_clear_p_subnet(u16_t net_idx) +void bt_mesh_clear_p_subnet(uint16_t net_idx) { char name[16] = {'\0'}; int err = 0; @@ -2481,7 +2479,7 @@ void bt_mesh_clear_p_subnet(u16_t net_idx) } } -void bt_mesh_clear_p_app_key(u16_t app_idx) +void bt_mesh_clear_p_app_key(uint16_t app_idx) { char name[16] = {'\0'}; int err = 0; @@ -2497,7 +2495,7 @@ void bt_mesh_clear_p_app_key(u16_t app_idx) } } -void bt_mesh_clear_rpl_single(u16_t src) +void bt_mesh_clear_rpl_single(uint16_t src) { char name[16] = {'\0'}; int err = 0; @@ -2539,7 +2537,7 @@ void bt_mesh_store_node_info(struct bt_mesh_node *node) memcpy(val.dev_key, node->dev_key, 16); sprintf(name, "mesh/pn/%04x/i", node->unicast_addr); - err = bt_mesh_save_core_settings(name, (const u8_t *)&val, sizeof(val)); + err = bt_mesh_save_core_settings(name, (const uint8_t *)&val, sizeof(val)); if (err) { BT_ERR("Failed to store node 0x%04x info", node->unicast_addr); return; @@ -2551,7 +2549,7 @@ void bt_mesh_store_node_info(struct bt_mesh_node *node) } } -static void clear_node(u16_t addr) +static void clear_node(uint16_t addr) { char name[16] = {'\0'}; int err = 0; @@ -2574,7 +2572,7 @@ static void clear_node(u16_t addr) } } -void bt_mesh_clear_node_info(u16_t unicast_addr) +void bt_mesh_clear_node_info(uint16_t unicast_addr) { if (!BLE_MESH_ADDR_IS_UNICAST(unicast_addr)) { BT_ERR("Invalid unicast address 0x%04x", unicast_addr); @@ -2600,7 +2598,7 @@ void bt_mesh_store_node_name(struct bt_mesh_node *node) strncpy(node_name, node->name, BLE_MESH_NODE_NAME_SIZE + 1); sprintf(name, "mesh/pn/%04x/n", node->unicast_addr); - err = bt_mesh_save_core_settings(name, (const u8_t *)node_name, BLE_MESH_NODE_NAME_SIZE); + err = bt_mesh_save_core_settings(name, (const uint8_t *)node_name, BLE_MESH_NODE_NAME_SIZE); if (err) { BT_ERR("Failed to store node 0x%04x name", node->unicast_addr); } @@ -2617,7 +2615,7 @@ void bt_mesh_store_node_comp_data(struct bt_mesh_node *node) } sprintf(name, "mesh/pn/%04x/c", node->unicast_addr); - err = bt_mesh_save_core_settings(name, (const u8_t *)node->comp_data, node->comp_length); + err = bt_mesh_save_core_settings(name, (const uint8_t *)node->comp_data, node->comp_length); if (err) { BT_ERR("Failed to store node 0x%04x comp data", node->unicast_addr); } diff --git a/components/bt/esp_ble_mesh/mesh_core/settings.h b/components/bt/esp_ble_mesh/mesh_core/settings.h index 19745c7f8b..55eefef0c4 100644 --- a/components/bt/esp_ble_mesh/mesh_core/settings.h +++ b/components/bt/esp_ble_mesh/mesh_core/settings.h @@ -42,7 +42,7 @@ void bt_mesh_clear_app_key(struct bt_mesh_app_key *key); void bt_mesh_clear_rpl(void); #if CONFIG_BLE_MESH_PROVISIONER -void bt_mesh_store_prov_info(u16_t primary_addr, u16_t alloc_addr); +void bt_mesh_store_prov_info(uint16_t primary_addr, uint16_t alloc_addr); void bt_mesh_clear_prov_info(void); void bt_mesh_store_p_net_idx(void); void bt_mesh_clear_p_net_idx(void); @@ -50,11 +50,11 @@ void bt_mesh_store_p_app_idx(void); void bt_mesh_clear_p_app_idx(void); void bt_mesh_store_p_subnet(struct bt_mesh_subnet *sub); void bt_mesh_store_p_app_key(struct bt_mesh_app_key *key); -void bt_mesh_clear_p_subnet(u16_t net_idx); -void bt_mesh_clear_p_app_key(u16_t app_idx); -void bt_mesh_clear_rpl_single(u16_t src); +void bt_mesh_clear_p_subnet(uint16_t net_idx); +void bt_mesh_clear_p_app_key(uint16_t app_idx); +void bt_mesh_clear_rpl_single(uint16_t src); void bt_mesh_store_node_info(struct bt_mesh_node *node); -void bt_mesh_clear_node_info(u16_t unicast_addr); +void bt_mesh_clear_node_info(uint16_t unicast_addr); void bt_mesh_store_node_name(struct bt_mesh_node *node); void bt_mesh_store_node_comp_data(struct bt_mesh_node *node); #endif diff --git a/components/bt/esp_ble_mesh/mesh_core/settings_uid.c b/components/bt/esp_ble_mesh/mesh_core/settings_uid.c index db42445ce9..ae60d9693c 100644 --- a/components/bt/esp_ble_mesh/mesh_core/settings_uid.c +++ b/components/bt/esp_ble_mesh/mesh_core/settings_uid.c @@ -41,7 +41,7 @@ static struct settings_uid { bt_mesh_nvs_handle_t handle; /* Core Settings nvs handle */ } user_ids[CONFIG_BLE_MESH_MAX_NVS_NAMESPACE]; -static int settings_direct_erase(u8_t index); +static int settings_direct_erase(uint8_t index); static inline bool settings_uid_empty(struct settings_uid *uid) { @@ -95,11 +95,11 @@ int settings_uid_load(void) length = buf->len; for (i = 0; i < length / SETTINGS_ITEM_SIZE; i++) { - u16_t index = net_buf_simple_pull_le16(buf); + uint16_t index = net_buf_simple_pull_le16(buf); sprintf(name, "mesh/id/%04x", index); - err = bt_mesh_load_uid_settings(name, (u8_t *)user_ids[index].id, + err = bt_mesh_load_uid_settings(name, (uint8_t *)user_ids[index].id, SETTINGS_UID_SIZE, &exist); if (err) { continue; @@ -159,7 +159,7 @@ int settings_uid_erase(void) } #endif /* CONFIG_BLE_MESH_DEINIT */ -static int settings_direct_erase(u8_t index) +static int settings_direct_erase(uint8_t index) { bt_mesh_nvs_handle_t handle = 0; char name[16] = {'\0'}; @@ -193,9 +193,9 @@ static int settings_direct_erase(u8_t index) return 0; } -static u8_t settings_index_get(const char *id, u8_t *index) +static uint8_t settings_index_get(const char *id, uint8_t *index) { - u8_t idx = 0; + uint8_t idx = 0; int i; for (i = 0; i < ARRAY_SIZE(user_ids); i++) { @@ -219,7 +219,7 @@ static u8_t settings_index_get(const char *id, u8_t *index) return idx; } -static int settings_open(u8_t index) +static int settings_open(uint8_t index) { struct settings_uid *uid = &user_ids[index]; char name[16] = {'\0'}; @@ -261,7 +261,7 @@ static int settings_open(u8_t index) BT_INFO("Open settings, index %d, uid %s", index, uid->id); sprintf(name, "mesh/id/%04x", index); - err = bt_mesh_save_uid_settings(name, (const u8_t *)uid->id, SETTINGS_UID_SIZE); + err = bt_mesh_save_uid_settings(name, (const uint8_t *)uid->id, SETTINGS_UID_SIZE); if (err) { BT_ERR("Save uid failed, name %s", name); return err; @@ -293,7 +293,7 @@ static int settings_open(u8_t index) return 0; } -int bt_mesh_provisioner_open_settings_with_index(u8_t index) +int bt_mesh_provisioner_open_settings_with_index(uint8_t index) { if (index >= ARRAY_SIZE(user_ids)) { BT_ERR("Invalid settings index %d", index); @@ -303,9 +303,9 @@ int bt_mesh_provisioner_open_settings_with_index(u8_t index) return settings_open(index); } -int bt_mesh_provisioner_open_settings_with_uid(const char *id, u8_t *index) +int bt_mesh_provisioner_open_settings_with_uid(const char *id, uint8_t *index) { - u8_t idx = 0; + uint8_t idx = 0; int i; if (!id || strlen(id) > SETTINGS_UID_SIZE) { @@ -338,7 +338,7 @@ int bt_mesh_provisioner_open_settings_with_uid(const char *id, u8_t *index) return settings_open(idx); } -static int settings_close(u8_t index, bool erase) +static int settings_close(uint8_t index, bool erase) { struct settings_uid *uid = &user_ids[index]; char name[16] = {'\0'}; @@ -382,7 +382,7 @@ static int settings_close(u8_t index, bool erase) return 0; } -int bt_mesh_provisioner_close_settings_with_index(u8_t index, bool erase) +int bt_mesh_provisioner_close_settings_with_index(uint8_t index, bool erase) { if (index >= ARRAY_SIZE(user_ids)) { BT_ERR("Invalid settings index %d", index); @@ -392,9 +392,9 @@ int bt_mesh_provisioner_close_settings_with_index(u8_t index, bool erase) return settings_close(index, erase); } -int bt_mesh_provisioner_close_settings_with_uid(const char *id, bool erase, u8_t *index) +int bt_mesh_provisioner_close_settings_with_uid(const char *id, bool erase, uint8_t *index) { - u8_t idx = 0; + uint8_t idx = 0; if (!id || strlen(id) > SETTINGS_UID_SIZE) { BT_ERR("Invalid settings uid"); @@ -410,7 +410,7 @@ int bt_mesh_provisioner_close_settings_with_uid(const char *id, bool erase, u8_t return settings_close(idx, erase); } -static int settings_delete(u8_t index) +static int settings_delete(uint8_t index) { /* The function is used to erase mesh information from * the nvs namespace when it is not open and restored, @@ -433,7 +433,7 @@ static int settings_delete(u8_t index) return 0; } -int bt_mesh_provisioner_delete_settings_with_index(u8_t index) +int bt_mesh_provisioner_delete_settings_with_index(uint8_t index) { if (index >= ARRAY_SIZE(user_ids)) { BT_ERR("Invalid settings index %d", index); @@ -443,9 +443,9 @@ int bt_mesh_provisioner_delete_settings_with_index(u8_t index) return settings_delete(index); } -int bt_mesh_provisioner_delete_settings_with_uid(const char *id, u8_t *index) +int bt_mesh_provisioner_delete_settings_with_uid(const char *id, uint8_t *index) { - u8_t idx = 0; + uint8_t idx = 0; if (!id || strlen(id) > SETTINGS_UID_SIZE) { BT_ERR("Invalid settings uid"); @@ -461,7 +461,7 @@ int bt_mesh_provisioner_delete_settings_with_uid(const char *id, u8_t *index) return settings_delete(idx); } -const char *bt_mesh_provisioner_get_settings_uid(u8_t index) +const char *bt_mesh_provisioner_get_settings_uid(uint8_t index) { if (index >= ARRAY_SIZE(user_ids)) { BT_ERR("Invalid settings index %d", index); @@ -471,9 +471,9 @@ const char *bt_mesh_provisioner_get_settings_uid(u8_t index) return user_ids[index].id; } -u8_t bt_mesh_provisioner_get_settings_index(const char *id) +uint8_t bt_mesh_provisioner_get_settings_index(const char *id) { - u8_t idx = 0; + uint8_t idx = 0; if (!id || strlen(id) > SETTINGS_UID_SIZE) { BT_ERR("Invalid settings uid"); @@ -488,9 +488,9 @@ u8_t bt_mesh_provisioner_get_settings_index(const char *id) return idx; } -u8_t bt_mesh_provisioner_get_free_settings_count(void) +uint8_t bt_mesh_provisioner_get_free_settings_count(void) { - u8_t count = 0; + uint8_t count = 0; int i; for (i = 0; i < ARRAY_SIZE(user_ids); i++) { diff --git a/components/bt/esp_ble_mesh/mesh_core/settings_uid.h b/components/bt/esp_ble_mesh/mesh_core/settings_uid.h index c0348cdf3f..57b937e6c2 100644 --- a/components/bt/esp_ble_mesh/mesh_core/settings_uid.h +++ b/components/bt/esp_ble_mesh/mesh_core/settings_uid.h @@ -27,16 +27,16 @@ int settings_uid_load(void); int settings_uid_deinit(void); int settings_uid_erase(void); -int bt_mesh_provisioner_open_settings_with_index(u8_t index); -int bt_mesh_provisioner_open_settings_with_uid(const char *id, u8_t *index); -int bt_mesh_provisioner_close_settings_with_index(u8_t index, bool erase); -int bt_mesh_provisioner_close_settings_with_uid(const char *id, bool erase, u8_t *index); -int bt_mesh_provisioner_delete_settings_with_index(u8_t index); -int bt_mesh_provisioner_delete_settings_with_uid(const char *id, u8_t *index); +int bt_mesh_provisioner_open_settings_with_index(uint8_t index); +int bt_mesh_provisioner_open_settings_with_uid(const char *id, uint8_t *index); +int bt_mesh_provisioner_close_settings_with_index(uint8_t index, bool erase); +int bt_mesh_provisioner_close_settings_with_uid(const char *id, bool erase, uint8_t *index); +int bt_mesh_provisioner_delete_settings_with_index(uint8_t index); +int bt_mesh_provisioner_delete_settings_with_uid(const char *id, uint8_t *index); -const char *bt_mesh_provisioner_get_settings_uid(u8_t index); -u8_t bt_mesh_provisioner_get_settings_index(const char *id); -u8_t bt_mesh_provisioner_get_free_settings_count(void); +const char *bt_mesh_provisioner_get_settings_uid(uint8_t index); +uint8_t bt_mesh_provisioner_get_settings_index(const char *id); +uint8_t bt_mesh_provisioner_get_free_settings_count(void); int bt_mesh_provisioner_direct_erase_settings(void); diff --git a/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.c b/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.c index eb1a68c990..061b9ab6e9 100644 --- a/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.c +++ b/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.c @@ -222,7 +222,7 @@ static inline bt_mesh_nvs_handle_t settings_get_nvs_handle(enum settings_type ty /* API used to store/erase BLE Mesh related settings */ -static int settings_save(bt_mesh_nvs_handle_t handle, const char *key, const u8_t *val, size_t len) +static int settings_save(bt_mesh_nvs_handle_t handle, const char *key, const uint8_t *val, size_t len) { int err = 0; @@ -258,7 +258,7 @@ static int settings_save(bt_mesh_nvs_handle_t handle, const char *key, const u8_ } int bt_mesh_save_settings(bt_mesh_nvs_handle_t handle, const char *key, - const u8_t *val, size_t len) + const uint8_t *val, size_t len) { int err = 0; bt_mesh_settings_lock(); @@ -267,14 +267,14 @@ int bt_mesh_save_settings(bt_mesh_nvs_handle_t handle, const char *key, return err; } -int bt_mesh_save_core_settings(const char *key, const u8_t *val, size_t len) +int bt_mesh_save_core_settings(const char *key, const uint8_t *val, size_t len) { bt_mesh_nvs_handle_t handle = settings_get_nvs_handle(SETTINGS_CORE); return bt_mesh_save_settings(handle, key, val, len); } #if CONFIG_BLE_MESH_USE_MULTIPLE_NAMESPACE -int bt_mesh_save_uid_settings(const char *key, const u8_t *val, size_t len) +int bt_mesh_save_uid_settings(const char *key, const uint8_t *val, size_t len) { bt_mesh_nvs_handle_t handle = settings_get_nvs_handle(SETTINGS_UID); return bt_mesh_save_settings(handle, key, val, len); @@ -301,7 +301,7 @@ int bt_mesh_erase_uid_settings(const char *name) /* API used to load BLE Mesh related settings */ static int settings_load(bt_mesh_nvs_handle_t handle, const char *key, - u8_t *buf, size_t buf_len, bool *exist) + uint8_t *buf, size_t buf_len, bool *exist) { int err = 0; @@ -327,7 +327,7 @@ static int settings_load(bt_mesh_nvs_handle_t handle, const char *key, } int bt_mesh_load_settings(bt_mesh_nvs_handle_t handle, const char *key, - u8_t *buf, size_t buf_len, bool *exist) + uint8_t *buf, size_t buf_len, bool *exist) { int err = 0; bt_mesh_settings_lock(); @@ -336,14 +336,14 @@ int bt_mesh_load_settings(bt_mesh_nvs_handle_t handle, const char *key, return err; } -int bt_mesh_load_core_settings(const char *key, u8_t *buf, size_t buf_len, bool *exist) +int bt_mesh_load_core_settings(const char *key, uint8_t *buf, size_t buf_len, bool *exist) { bt_mesh_nvs_handle_t handle = settings_get_nvs_handle(SETTINGS_CORE); return bt_mesh_load_settings(handle, key, buf, buf_len, exist); } #if CONFIG_BLE_MESH_USE_MULTIPLE_NAMESPACE -int bt_mesh_load_uid_settings(const char *key, u8_t *buf, size_t buf_len, bool *exist) +int bt_mesh_load_uid_settings(const char *key, uint8_t *buf, size_t buf_len, bool *exist) { bt_mesh_nvs_handle_t handle = settings_get_nvs_handle(SETTINGS_UID); return bt_mesh_load_settings(handle, key, buf, buf_len, exist); @@ -440,7 +440,7 @@ struct net_buf_simple *bt_mesh_get_uid_settings_item(const char *key) /* API used to check if the settings item exists */ -static bool is_settings_item_exist(struct net_buf_simple *buf, const u16_t val) +static bool is_settings_item_exist(struct net_buf_simple *buf, const uint16_t val) { struct net_buf_simple_state state = {0}; size_t length = 0U; @@ -454,7 +454,7 @@ static bool is_settings_item_exist(struct net_buf_simple *buf, const u16_t val) length = buf->len; for (i = 0; i < length / SETTINGS_ITEM_SIZE; i++) { - u16_t item = net_buf_simple_pull_le16(buf); + uint16_t item = net_buf_simple_pull_le16(buf); if (item == val) { net_buf_simple_restore(buf, &state); return true; @@ -467,7 +467,7 @@ static bool is_settings_item_exist(struct net_buf_simple *buf, const u16_t val) /* API used to add the settings item */ -static int settings_add_item(bt_mesh_nvs_handle_t handle, const char *key, const u16_t val) +static int settings_add_item(bt_mesh_nvs_handle_t handle, const char *key, const uint16_t val) { struct net_buf_simple *store = NULL; struct net_buf_simple *buf = NULL; @@ -504,7 +504,7 @@ static int settings_add_item(bt_mesh_nvs_handle_t handle, const char *key, const return err; } -int bt_mesh_add_settings_item(bt_mesh_nvs_handle_t handle, const char *key, const u16_t val) +int bt_mesh_add_settings_item(bt_mesh_nvs_handle_t handle, const char *key, const uint16_t val) { int err = 0; bt_mesh_settings_lock(); @@ -513,14 +513,14 @@ int bt_mesh_add_settings_item(bt_mesh_nvs_handle_t handle, const char *key, cons return err; } -int bt_mesh_add_core_settings_item(const char *key, const u16_t val) +int bt_mesh_add_core_settings_item(const char *key, const uint16_t val) { bt_mesh_nvs_handle_t handle = settings_get_nvs_handle(SETTINGS_CORE); return bt_mesh_add_settings_item(handle, key, val); } #if CONFIG_BLE_MESH_USE_MULTIPLE_NAMESPACE -int bt_mesh_add_uid_settings_item(const char *key, const u16_t val) +int bt_mesh_add_uid_settings_item(const char *key, const uint16_t val) { bt_mesh_nvs_handle_t handle = settings_get_nvs_handle(SETTINGS_UID); return bt_mesh_add_settings_item(handle, key, val); @@ -529,7 +529,7 @@ int bt_mesh_add_uid_settings_item(const char *key, const u16_t val) /* API used to remove the settings item */ -static int settings_remove_item(bt_mesh_nvs_handle_t handle, const char *key, const u16_t val) +static int settings_remove_item(bt_mesh_nvs_handle_t handle, const char *key, const uint16_t val) { struct net_buf_simple *store = NULL; struct net_buf_simple *buf = NULL; @@ -563,7 +563,7 @@ static int settings_remove_item(bt_mesh_nvs_handle_t handle, const char *key, co buf_len = buf->len; for (i = 0; i < buf_len / SETTINGS_ITEM_SIZE; i++) { - u16_t item = net_buf_simple_pull_le16(buf); + uint16_t item = net_buf_simple_pull_le16(buf); if (item != val) { net_buf_simple_add_le16(store, item); } @@ -576,7 +576,7 @@ static int settings_remove_item(bt_mesh_nvs_handle_t handle, const char *key, co return err; } -int bt_mesh_remove_settings_item(bt_mesh_nvs_handle_t handle, const char *key, const u16_t val) +int bt_mesh_remove_settings_item(bt_mesh_nvs_handle_t handle, const char *key, const uint16_t val) { int err = 0; bt_mesh_settings_lock(); @@ -585,14 +585,14 @@ int bt_mesh_remove_settings_item(bt_mesh_nvs_handle_t handle, const char *key, c return err; } -int bt_mesh_remove_core_settings_item(const char *key, const u16_t val) +int bt_mesh_remove_core_settings_item(const char *key, const uint16_t val) { bt_mesh_nvs_handle_t handle = settings_get_nvs_handle(SETTINGS_CORE); return bt_mesh_remove_settings_item(handle, key, val); } #if CONFIG_BLE_MESH_USE_MULTIPLE_NAMESPACE -int bt_mesh_remove_uid_settings_item(const char *key, const u16_t val) +int bt_mesh_remove_uid_settings_item(const char *key, const uint16_t val) { bt_mesh_nvs_handle_t handle = settings_get_nvs_handle(SETTINGS_UID); return bt_mesh_remove_settings_item(handle, key, val); diff --git a/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.h b/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.h index 9987a3ab6b..a4cb3ad101 100644 --- a/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.h +++ b/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.h @@ -24,11 +24,11 @@ extern "C" { typedef nvs_handle_t bt_mesh_nvs_handle_t; -#define SETTINGS_ITEM_SIZE sizeof(u16_t) +#define SETTINGS_ITEM_SIZE sizeof(uint16_t) -#define BLE_MESH_GET_ELEM_IDX(x) ((u8_t)((x) >> 8)) -#define BLE_MESH_GET_MODEL_IDX(x) ((u8_t)(x)) -#define BLE_MESH_GET_MODEL_KEY(a, b) ((u16_t)(((u16_t)((a) << 8)) | (b))) +#define BLE_MESH_GET_ELEM_IDX(x) ((uint8_t)((x) >> 8)) +#define BLE_MESH_GET_MODEL_IDX(x) ((uint8_t)(x)) +#define BLE_MESH_GET_MODEL_KEY(a, b) ((uint16_t)(((uint16_t)((a) << 8)) | (b))) int bt_mesh_settings_nvs_open(const char* name, bt_mesh_nvs_handle_t *handle); void bt_mesh_settings_nvs_close(bt_mesh_nvs_handle_t handle); @@ -40,30 +40,30 @@ int bt_mesh_settings_direct_open(bt_mesh_nvs_handle_t *handle); void bt_mesh_settings_direct_close(void); int bt_mesh_save_settings(bt_mesh_nvs_handle_t handle, const char *key, - const u8_t *val, size_t len); -int bt_mesh_save_core_settings(const char *key, const u8_t *val, size_t len); -int bt_mesh_save_uid_settings(const char *key, const u8_t *val, size_t len); + const uint8_t *val, size_t len); +int bt_mesh_save_core_settings(const char *key, const uint8_t *val, size_t len); +int bt_mesh_save_uid_settings(const char *key, const uint8_t *val, size_t len); int bt_mesh_erase_settings(bt_mesh_nvs_handle_t handle, const char *key); int bt_mesh_erase_core_settings(const char *key); int bt_mesh_erase_uid_settings(const char *name); int bt_mesh_load_settings(bt_mesh_nvs_handle_t handle, const char *key, - u8_t *buf, size_t buf_len, bool *exist); -int bt_mesh_load_core_settings(const char *key, u8_t *buf, size_t buf_len, bool *exist); -int bt_mesh_load_uid_settings(const char *key, u8_t *buf, size_t buf_len, bool *exist); + uint8_t *buf, size_t buf_len, bool *exist); +int bt_mesh_load_core_settings(const char *key, uint8_t *buf, size_t buf_len, bool *exist); +int bt_mesh_load_uid_settings(const char *key, uint8_t *buf, size_t buf_len, bool *exist); struct net_buf_simple *bt_mesh_get_settings_item(bt_mesh_nvs_handle_t handle, const char *key); struct net_buf_simple *bt_mesh_get_core_settings_item(const char *key); struct net_buf_simple *bt_mesh_get_uid_settings_item(const char *key); -int bt_mesh_add_settings_item(bt_mesh_nvs_handle_t handle, const char *key, const u16_t val); -int bt_mesh_add_core_settings_item(const char *key, const u16_t val); -int bt_mesh_add_uid_settings_item(const char *key, const u16_t val); +int bt_mesh_add_settings_item(bt_mesh_nvs_handle_t handle, const char *key, const uint16_t val); +int bt_mesh_add_core_settings_item(const char *key, const uint16_t val); +int bt_mesh_add_uid_settings_item(const char *key, const uint16_t val); -int bt_mesh_remove_settings_item(bt_mesh_nvs_handle_t handle, const char *key, const u16_t val); -int bt_mesh_remove_core_settings_item(const char *key, const u16_t val); -int bt_mesh_remove_uid_settings_item(const char *key, const u16_t val); +int bt_mesh_remove_settings_item(bt_mesh_nvs_handle_t handle, const char *key, const uint16_t val); +int bt_mesh_remove_core_settings_item(const char *key, const uint16_t val); +int bt_mesh_remove_uid_settings_item(const char *key, const uint16_t val); int bt_mesh_settings_erase_key(bt_mesh_nvs_handle_t handle, const char *key); int bt_mesh_settings_erase_all(bt_mesh_nvs_handle_t handle); diff --git a/components/bt/esp_ble_mesh/mesh_core/test.h b/components/bt/esp_ble_mesh/mesh_core/test.h index ffb054f3c8..a81e38b020 100644 --- a/components/bt/esp_ble_mesh/mesh_core/test.h +++ b/components/bt/esp_ble_mesh/mesh_core/test.h @@ -19,15 +19,15 @@ extern "C" { int bt_mesh_test(void); struct bt_mesh_device_network_info { - u8_t net_key[16]; - u16_t net_idx; - u8_t flags; - u32_t iv_index; - u16_t unicast_addr; - u8_t dev_key[16]; - u8_t app_key[16]; - u16_t app_idx; - u16_t group_addr; + uint8_t net_key[16]; + uint16_t net_idx; + uint8_t flags; + uint32_t iv_index; + uint16_t unicast_addr; + uint8_t dev_key[16]; + uint8_t app_key[16]; + uint16_t app_idx; + uint16_t group_addr; }; int bt_mesh_device_auto_enter_network(struct bt_mesh_device_network_info *info); diff --git a/components/bt/esp_ble_mesh/mesh_core/transport.c b/components/bt/esp_ble_mesh/mesh_core/transport.c index 4fbdd9fbf4..faac12dc3b 100644 --- a/components/bt/esp_ble_mesh/mesh_core/transport.c +++ b/components/bt/esp_ble_mesh/mesh_core/transport.c @@ -10,8 +10,6 @@ #include #include -#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_TRANS) - #include "crypto.h" #include "adv.h" #include "mesh.h" @@ -33,7 +31,7 @@ _Static_assert(CONFIG_BLE_MESH_ADV_BUF_COUNT >= (CONFIG_BLE_MESH_TX_SEG_MAX + 3), "Too small BLE Mesh adv buffer count"); -#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) @@ -45,9 +43,9 @@ _Static_assert(CONFIG_BLE_MESH_ADV_BUF_COUNT >= (CONFIG_BLE_MESH_TX_SEG_MAX + 3) #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 4 @@ -72,46 +70,46 @@ _Static_assert(CONFIG_BLE_MESH_ADV_BUF_COUNT >= (CONFIG_BLE_MESH_TX_SEG_MAX + 3) #define BUF_TIMEOUT K_NO_WAIT static struct seg_tx { - struct bt_mesh_subnet *sub; - struct net_buf *seg[CONFIG_BLE_MESH_TX_SEG_MAX]; - u64_t seq_auth; - u16_t dst; - u8_t seg_n:5, /* Last segment index */ - new_key:1; /* New/old key */ - u8_t nack_count; /* Number of unacked segs */ - u8_t ttl; - u8_t seg_pending; /* Number of segments pending */ - u8_t attempts; /* Transmit attempts */ + struct bt_mesh_subnet *sub; + struct net_buf *seg[CONFIG_BLE_MESH_TX_SEG_MAX]; + uint64_t seq_auth; + uint16_t dst; + uint8_t seg_n:5, /* Last segment index */ + new_key:1; /* New/old key */ + uint8_t nack_count; /* Number of unacked segs */ + uint8_t ttl; + uint8_t seg_pending; /* Number of segments pending */ + uint8_t attempts; /* Transmit attempts */ const struct bt_mesh_send_cb *cb; - void *cb_data; - struct k_delayed_work retransmit; /* Retransmit timer */ + void *cb_data; + struct k_delayed_work retransmit; /* Retransmit timer */ } seg_tx[CONFIG_BLE_MESH_TX_SEG_MSG_COUNT]; static struct seg_rx { - struct bt_mesh_subnet *sub; - u64_t seq_auth; - u8_t seg_n: 5, - ctl: 1, - in_use: 1, - obo: 1; - u8_t hdr; - u8_t ttl; - u16_t src; - u16_t dst; - u32_t block; - u32_t last; - struct k_delayed_work ack; - struct net_buf_simple buf; + struct bt_mesh_subnet *sub; + uint64_t seq_auth; + uint8_t seg_n:5, + ctl:1, + in_use:1, + obo:1; + uint8_t hdr; + uint8_t ttl; + uint16_t src; + uint16_t dst; + uint32_t block; + uint32_t last; + struct k_delayed_work ack; + struct net_buf_simple buf; } seg_rx[CONFIG_BLE_MESH_RX_SEG_MSG_COUNT] = { [0 ... (CONFIG_BLE_MESH_RX_SEG_MSG_COUNT - 1)] = { .buf.size = CONFIG_BLE_MESH_RX_SDU_MAX, }, }; -static u8_t seg_rx_buf_data[(CONFIG_BLE_MESH_RX_SEG_MSG_COUNT * - CONFIG_BLE_MESH_RX_SDU_MAX)]; +static uint8_t seg_rx_buf_data[(CONFIG_BLE_MESH_RX_SEG_MSG_COUNT * + CONFIG_BLE_MESH_RX_SDU_MAX)]; -static u16_t hb_sub_dst = BLE_MESH_ADDR_UNASSIGNED; +static uint16_t hb_sub_dst = BLE_MESH_ADDR_UNASSIGNED; static bt_mesh_mutex_t tx_seg_lock; static bt_mesh_mutex_t rx_seg_lock; @@ -164,12 +162,12 @@ static inline void bt_mesh_rx_seg_unlock(void) bt_mesh_mutex_unlock(&rx_seg_lock); } -u8_t bt_mesh_get_seg_retrans_num(void) +uint8_t bt_mesh_get_seg_retrans_num(void) { return SEG_RETRANSMIT_ATTEMPTS; } -s32_t bt_mesh_get_seg_retrans_timeout(u8_t ttl) +int32_t bt_mesh_get_seg_retrans_timeout(uint8_t ttl) { /* This function will be used when a client model sending an * acknowledged message. And if the dst of a message is not @@ -183,7 +181,7 @@ s32_t bt_mesh_get_seg_retrans_timeout(u8_t ttl) return SEG_RETRANSMIT_TIMEOUT_UNICAST(&tx); } -void bt_mesh_set_hb_sub_dst(u16_t addr) +void bt_mesh_set_hb_sub_dst(uint16_t addr) { hb_sub_dst = addr; } @@ -255,7 +253,7 @@ 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) { bt_mesh_adv_buf_ref_debug(__func__, tx->seg[seg_idx], 3U, BLE_MESH_BUF_REF_SMALL); @@ -329,7 +327,7 @@ static void schedule_retransmit(struct seg_tx *tx) k_delayed_work_submit(&tx->retransmit, SEG_RETRANSMIT_TIMEOUT(tx)); } -static void seg_first_send_start(u16_t duration, int err, void *user_data) +static void seg_first_send_start(uint16_t duration, int err, void *user_data) { struct seg_tx *tx = user_data; @@ -338,7 +336,7 @@ static void seg_first_send_start(u16_t duration, int err, void *user_data) } } -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; @@ -422,8 +420,8 @@ static void seg_retransmit(struct k_work *work) static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu, const struct bt_mesh_send_cb *cb, void *cb_data) { - u8_t seg_hdr = 0U, seg_o = 0U; - u16_t seq_zero = 0U; + uint8_t seg_hdr = 0U, seg_o = 0U; + uint16_t seq_zero = 0U; struct seg_tx *tx = NULL; int i; @@ -494,7 +492,7 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu, for (seg_o = 0U; sdu->len; seg_o++) { struct net_buf *seg = NULL; - u16_t len = 0U; + uint16_t len = 0U; int err = 0; seg = bt_mesh_adv_create(BLE_MESH_ADV_DATA, net_tx->xmit, @@ -572,7 +570,7 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *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; @@ -591,9 +589,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 net_buf_simple *msg, const struct bt_mesh_send_cb *cb, void *cb_data) { - const u8_t *key = NULL; - u8_t *ad = NULL, role = 0U; - u8_t aid = 0U; + const uint8_t *key = NULL; + uint8_t *ad = NULL, role = 0U; + uint8_t aid = 0U; int err = 0; if (net_buf_simple_tailroom(msg) < BLE_MESH_MIC_SHORT) { @@ -722,13 +720,13 @@ bool bt_mesh_rpl_check(struct bt_mesh_net_rx *rx, struct bt_mesh_rpl **match) return true; } -static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr, - u8_t aszmic, struct net_buf_simple *buf) +static int sdu_recv(struct bt_mesh_net_rx *rx, uint32_t seq, uint8_t hdr, + uint8_t aszmic, struct net_buf_simple *buf) { struct net_buf_simple *sdu = NULL; size_t array_size = 0U; + uint8_t *ad = NULL; size_t i = 0U; - u8_t *ad = NULL; int err = 0; BT_DBG("ASZMIC %u AKF %u AID 0x%02x", aszmic, AKF(&hdr), AID(&hdr)); @@ -767,7 +765,7 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr, array_size = bt_mesh_rx_devkey_size(); for (i = 0U; i < array_size; i++) { - const u8_t *dev_key = NULL; + const uint8_t *dev_key = NULL; dev_key = bt_mesh_rx_devkey_get(i, rx->ctx.addr); if (!dev_key) { @@ -849,7 +847,7 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr, 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 = NULL; int i; @@ -879,14 +877,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 net_buf_simple *buf, u64_t *seq_auth) +static int trans_ack(struct bt_mesh_net_rx *rx, uint8_t hdr, + struct net_buf_simple *buf, uint64_t *seq_auth) { struct seg_tx *tx = NULL; unsigned int bit = 0; - u32_t ack = 0U; - u16_t seq_zero = 0U; - u8_t obo = 0U; + uint32_t ack = 0U; + uint16_t seq_zero = 0U; + uint8_t obo = 0U; if (buf->len < 6) { BT_ERR("Too short ack message (len %u)", buf->len); @@ -958,8 +956,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 net_buf_simple *buf) { - u8_t init_ttl = 0U, hops = 0U; - u16_t feat = 0U; + uint8_t init_ttl = 0U, hops = 0U; + uint16_t feat = 0U; if (buf->len < 3) { BT_ERR("Too short heartbeat message (len %u)", buf->len); @@ -992,10 +990,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 net_buf_simple *buf, u64_t *seq_auth) +static int ctl_recv(struct bt_mesh_net_rx *rx, uint8_t hdr, + struct net_buf_simple *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->len); @@ -1058,9 +1056,9 @@ static int ctl_recv(struct bt_mesh_net_rx *rx, u8_t hdr, } static int trans_unseg(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx, - u64_t *seq_auth) + uint64_t *seq_auth) { - u8_t hdr = 0U; + uint8_t hdr = 0U; BT_DBG("AFK %u AID 0x%02x", AKF(buf->data), AID(buf->data)); @@ -1089,10 +1087,10 @@ static int trans_unseg(struct net_buf_simple *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 = 0; - u8_t ttl = 0U; + int32_t to = 0; + uint8_t ttl = 0U; if (rx->ttl == BLE_MESH_TTL_DEFAULT) { ttl = bt_mesh_default_ttl_get(); @@ -1114,7 +1112,7 @@ static inline s32_t ack_timeout(struct seg_rx *rx) return MAX(to, K_MSEC(400)); } -static int ctl_send_unseg(struct bt_mesh_net_tx *tx, u8_t ctl_op, void *data, +static int ctl_send_unseg(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) { @@ -1147,14 +1145,14 @@ static int ctl_send_unseg(struct bt_mesh_net_tx *tx, u8_t ctl_op, void *data, return bt_mesh_net_send(tx, buf, cb, cb_data); } -static int ctl_send_seg(struct bt_mesh_net_tx *tx, u8_t ctl_op, void *data, +static int ctl_send_seg(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 seg_tx *tx_seg = NULL; - u16_t unsent = data_len; - u16_t seq_zero = 0; - u8_t seg_o = 0; + uint16_t unsent = data_len; + uint16_t seq_zero = 0; + uint8_t seg_o = 0; int i; for (tx_seg = NULL, i = 0; i < ARRAY_SIZE(seg_tx); i++) { @@ -1192,7 +1190,7 @@ static int ctl_send_seg(struct bt_mesh_net_tx *tx, u8_t ctl_op, void *data, for (seg_o = 0; seg_o <= tx_seg->seg_n; seg_o++) { struct net_buf *seg = NULL; - u16_t len = 0; + uint16_t len = 0; int err = 0; seg = bt_mesh_adv_create(BLE_MESH_ADV_DATA, tx->xmit, @@ -1211,7 +1209,7 @@ static int ctl_send_seg(struct bt_mesh_net_tx *tx, u8_t ctl_op, void *data, net_buf_add_u8(seg, ((seg_o & 0x07) << 5) | tx_seg->seg_n); len = MIN(unsent, BLE_MESH_CTL_SEG_SDU_MAX); - net_buf_add_mem(seg, (u8_t *)data + (data_len - unsent), len); + net_buf_add_mem(seg, (uint8_t *)data + (data_len - unsent), len); unsent -= len; tx_seg->seg[seg_o] = net_buf_ref(seg); @@ -1232,7 +1230,7 @@ static int ctl_send_seg(struct bt_mesh_net_tx *tx, u8_t ctl_op, void *data, return 0; } -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) { @@ -1249,8 +1247,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, @@ -1264,8 +1262,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] = {0}; + uint16_t seq_zero = *seq_auth & TRANS_SEQ_ZERO_MASK; + uint8_t buf[6] = {0}; BT_DBG("SeqZero 0x%04x Block 0x%08x OBO %u", seq_zero, block, obo); @@ -1320,10 +1318,10 @@ static void seg_rx_reset(struct seg_rx *rx, bool full_reset) bt_mesh_rx_seg_unlock(); } -static u32_t incomplete_timeout(struct seg_rx *rx) +static uint32_t incomplete_timeout(struct seg_rx *rx) { - u32_t timeout = 0U; - u8_t ttl = 0U; + uint32_t timeout = 0U; + uint8_t ttl = 0U; if (rx->ttl == BLE_MESH_TTL_DEFAULT) { ttl = bt_mesh_default_ttl_get(); @@ -1371,7 +1369,7 @@ static void seg_ack(struct k_work *work) bt_mesh_rx_seg_unlock(); } -static inline u8_t seg_len(bool ctl) +static inline uint8_t seg_len(bool ctl) { if (ctl) { return BLE_MESH_CTL_SEG_SDU_MAX; @@ -1380,13 +1378,13 @@ static inline u8_t seg_len(bool ctl) } } -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 * seg_len(ctl) + 1) <= CONFIG_BLE_MESH_RX_SDU_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; @@ -1426,7 +1424,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"); @@ -1447,8 +1445,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; @@ -1481,15 +1479,15 @@ static struct seg_rx *seg_rx_alloc(struct bt_mesh_net_rx *net_rx, } static int trans_seg(struct net_buf_simple *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 = NULL; - u8_t *hdr = buf->data; - u16_t seq_zero = 0U; - u8_t seg_n = 0U; - u8_t seg_o = 0U; + uint8_t *hdr = buf->data; + uint16_t seq_zero = 0U; + uint8_t seg_n = 0U; + uint8_t seg_o = 0U; int err = 0; if (buf->len < 5) { @@ -1696,10 +1694,10 @@ found_rx: int bt_mesh_trans_recv(struct net_buf_simple *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 = BLE_MESH_FRIEND_PDU_SINGLE; struct net_buf_simple_state state = {0}; - u8_t seg_count = 0U; + uint8_t seg_count = 0U; int err = 0; if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) { @@ -1808,7 +1806,7 @@ void bt_mesh_tx_reset(void) } #if CONFIG_BLE_MESH_PROVISIONER -void bt_mesh_rx_reset_single(u16_t src) +void bt_mesh_rx_reset_single(uint16_t src) { int i; @@ -1834,7 +1832,7 @@ void bt_mesh_rx_reset_single(u16_t src) } } -void bt_mesh_tx_reset_single(u16_t dst) +void bt_mesh_tx_reset_single(uint16_t dst) { int i; @@ -1894,10 +1892,10 @@ void bt_mesh_trans_deinit(bool erase) void bt_mesh_heartbeat_send(void) { 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, @@ -1943,8 +1941,8 @@ void bt_mesh_heartbeat_send(void) NULL, NULL); } -int bt_mesh_app_key_get(const struct bt_mesh_subnet *subnet, u16_t app_idx, - const u8_t **key, u8_t *aid, u8_t role, u16_t dst) +int bt_mesh_app_key_get(const struct bt_mesh_subnet *subnet, uint16_t app_idx, + const uint8_t **key, uint8_t *aid, uint8_t role, uint16_t dst) { struct bt_mesh_app_key *app_key = NULL; diff --git a/components/bt/esp_ble_mesh/mesh_core/transport.h b/components/bt/esp_ble_mesh/mesh_core/transport.h index 31c5f0e1a5..366d19a6a7 100644 --- a/components/bt/esp_ble_mesh/mesh_core/transport.h +++ b/components/bt/esp_ble_mesh/mesh_core/transport.h @@ -23,8 +23,8 @@ extern "C" { #define BLE_MESH_APP_SEG_SDU_MAX 12 #define BLE_MESH_TX_SDU_MAX (CONFIG_BLE_MESH_TX_SEG_MAX * 12) -#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)) @@ -41,68 +41,68 @@ extern "C" { #define TRANS_CTL_OP_HEARTBEAT 0x0a struct bt_mesh_ctl_friend_poll { - u8_t fsn; + uint8_t fsn; } __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; } __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; } __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; } __packed; struct bt_mesh_ctl_friend_clear { - u16_t lpn_addr; - u16_t lpn_counter; + uint16_t lpn_addr; + uint16_t lpn_counter; } __packed; struct bt_mesh_ctl_friend_clear_confirm { - u16_t lpn_addr; - u16_t lpn_counter; + uint16_t lpn_addr; + uint16_t lpn_counter; } __packed; #define BLE_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]; } __packed; struct bt_mesh_ctl_friend_sub_confirm { - u8_t xact; + uint8_t xact; } __packed; -u8_t bt_mesh_get_seg_retrans_num(void); +uint8_t bt_mesh_get_seg_retrans_num(void); -s32_t bt_mesh_get_seg_retrans_timeout(u8_t ttl); +int32_t bt_mesh_get_seg_retrans_timeout(uint8_t ttl); -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(bool erase); void bt_mesh_tx_reset(void); -void bt_mesh_rx_reset_single(u16_t src); -void bt_mesh_tx_reset_single(u16_t dst); +void bt_mesh_rx_reset_single(uint16_t src); +void bt_mesh_tx_reset_single(uint16_t dst); -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); @@ -118,8 +118,8 @@ bool bt_mesh_rpl_check(struct bt_mesh_net_rx *rx, struct bt_mesh_rpl **match); void bt_mesh_heartbeat_send(void); -int bt_mesh_app_key_get(const struct bt_mesh_subnet *subnet, u16_t app_idx, - const u8_t **key, u8_t *aid, u8_t role, u16_t dst); +int bt_mesh_app_key_get(const struct bt_mesh_subnet *subnet, uint16_t app_idx, + const uint8_t **key, uint8_t *aid, uint8_t role, uint16_t dst); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_models/client/client_common.c b/components/bt/esp_ble_mesh/mesh_models/client/client_common.c index a12c66bcab..5c0bcb0ab3 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/client_common.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/client_common.c @@ -24,7 +24,7 @@ #define HCI_TIME_FOR_START_ADV K_MSEC(5) /* Three adv related hci commands may take 4 ~ 5ms */ -static bt_mesh_client_node_t *bt_mesh_client_pick_node(sys_slist_t *list, u16_t tx_dst) +static bt_mesh_client_node_t *bt_mesh_client_pick_node(sys_slist_t *list, uint16_t tx_dst) { bt_mesh_client_node_t *node = NULL; sys_snode_t *cur = NULL; @@ -117,7 +117,7 @@ bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(struct bt_mesh_model * return node; } -static bool bt_mesh_client_check_node_in_list(sys_slist_t *list, u16_t tx_dst) +static bool bt_mesh_client_check_node_in_list(sys_slist_t *list, uint16_t tx_dst) { bt_mesh_client_node_t *node = NULL; sys_snode_t *cur = NULL; @@ -141,8 +141,8 @@ static bool bt_mesh_client_check_node_in_list(sys_slist_t *list, u16_t tx_dst) return false; } -static u32_t bt_mesh_client_get_status_op(const bt_mesh_client_op_pair_t *op_pair, - int size, u32_t opcode) +static uint32_t bt_mesh_client_get_status_op(const bt_mesh_client_op_pair_t *op_pair, + int size, uint32_t opcode) { if (!op_pair || size == 0) { return 0; @@ -159,26 +159,26 @@ static u32_t bt_mesh_client_get_status_op(const bt_mesh_client_op_pair_t *op_pai return 0; } -static s32_t bt_mesh_get_adv_duration(void) +static int32_t bt_mesh_get_adv_duration(void) { - u16_t duration, adv_int; - u8_t xmit; + uint16_t duration, adv_int; + uint8_t xmit; xmit = bt_mesh_net_transmit_get(); /* Network transmit */ adv_int = BLE_MESH_TRANSMIT_INT(xmit); duration = (BLE_MESH_TRANSMIT_COUNT(xmit) + 1) * (adv_int + 10); - return (s32_t)duration; + return (int32_t)duration; } -static s32_t bt_mesh_client_calc_timeout(struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *msg, - u32_t opcode, s32_t timeout) +static int32_t bt_mesh_client_calc_timeout(struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *msg, + uint32_t opcode, int32_t timeout) { - s32_t seg_retrans_to = 0, duration = 0, time = 0; - u8_t seg_count = 0, seg_retrans_num = 0; + int32_t seg_retrans_to = 0, duration = 0, time = 0; + uint8_t seg_count = 0, seg_retrans_num = 0; bool need_seg = false; - u8_t mic_size = 0; + uint8_t mic_size = 0; if (msg->len > BLE_MESH_SDU_UNSEG_MAX || ctx->send_rel) { need_seg = true; /* Needs segmentation */ @@ -207,7 +207,7 @@ static s32_t bt_mesh_client_calc_timeout(struct bt_mesh_msg_ctx *ctx, * calculation here. And the retransmit timer will be started event if * the attempts reaches ZERO when the dst is a unicast address. */ - s32_t seg_duration = seg_count * (duration + HCI_TIME_FOR_START_ADV); + int32_t seg_duration = seg_count * (duration + HCI_TIME_FOR_START_ADV); time = (seg_duration + seg_retrans_to) * seg_retrans_num; BT_INFO("Original timeout %dms, calculated timeout %dms", timeout, time); @@ -230,7 +230,7 @@ static s32_t bt_mesh_client_calc_timeout(struct bt_mesh_msg_ctx *ctx, return time; } -static void msg_send_start(u16_t duration, int err, void *cb_data) +static void msg_send_start(uint16_t duration, int err, void *cb_data) { bt_mesh_client_node_t *node = cb_data; @@ -503,7 +503,7 @@ int bt_mesh_client_clear_list(void *data) return 0; } -int bt_mesh_set_client_model_role(struct bt_mesh_model *model, u8_t role) +int bt_mesh_set_client_model_role(struct bt_mesh_model *model, uint8_t role) { bt_mesh_client_user_data_t *client = NULL; diff --git a/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c b/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c index 64abe802f6..b6bcc5196b 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c @@ -143,7 +143,7 @@ static void timeout_handler(struct k_work *work) struct k_delayed_work *timer = NULL; bt_mesh_client_node_t *node = NULL; struct bt_mesh_msg_ctx ctx = {0}; - u32_t opcode = 0U; + uint32_t opcode = 0U; BT_WARN("Receive generic status message timeout"); @@ -172,8 +172,8 @@ static void generic_status(struct bt_mesh_model *model, struct net_buf_simple *buf) { bt_mesh_client_node_t *node = NULL; - u8_t *val = NULL; - u8_t evt = 0xFF; + uint8_t *val = NULL; + uint8_t evt = 0xFF; size_t len = 0U; BT_DBG("len %d, bytes %s", buf->len, bt_hex(buf->data, buf->len)); @@ -196,7 +196,7 @@ static void generic_status(struct bt_mesh_model *model, status->target_onoff = net_buf_simple_pull_u8(buf); status->remain_time = net_buf_simple_pull_u8(buf); } - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_gen_onoff_status); break; } @@ -217,7 +217,7 @@ static void generic_status(struct bt_mesh_model *model, status->target_level = net_buf_simple_pull_le16(buf); status->remain_time = net_buf_simple_pull_u8(buf); } - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_gen_level_status); break; } @@ -233,7 +233,7 @@ static void generic_status(struct bt_mesh_model *model, return; } status->trans_time = net_buf_simple_pull_u8(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_gen_def_trans_time_status); break; } @@ -249,7 +249,7 @@ static void generic_status(struct bt_mesh_model *model, return; } status->onpowerup = net_buf_simple_pull_u8(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_gen_onpowerup_status); break; } @@ -270,7 +270,7 @@ static void generic_status(struct bt_mesh_model *model, status->target_power = net_buf_simple_pull_le16(buf); status->remain_time = net_buf_simple_pull_u8(buf); } - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_gen_power_level_status); break; } @@ -286,7 +286,7 @@ static void generic_status(struct bt_mesh_model *model, return; } status->power = net_buf_simple_pull_le16(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_gen_power_last_status); break; } @@ -302,7 +302,7 @@ static void generic_status(struct bt_mesh_model *model, return; } status->power = net_buf_simple_pull_le16(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_gen_power_default_status); break; } @@ -320,7 +320,7 @@ static void generic_status(struct bt_mesh_model *model, status->status_code = net_buf_simple_pull_u8(buf); status->range_min = net_buf_simple_pull_le16(buf); status->range_max = net_buf_simple_pull_le16(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_gen_power_range_status); break; } @@ -335,14 +335,14 @@ static void generic_status(struct bt_mesh_model *model, BT_ERR("%s, Out of memory", __func__); return; } - u32_t value = 0; + uint32_t value = 0; value = net_buf_simple_pull_le32(buf); - status->battery_level = (u8_t)value; + status->battery_level = (uint8_t)value; status->time_to_discharge = (value >> 8); value = net_buf_simple_pull_le32(buf); status->time_to_charge = (value & 0xffffff); - status->flags = (u8_t)(value >> 24); - val = (u8_t *)status; + status->flags = (uint8_t)(value >> 24); + val = (uint8_t *)status; len = sizeof(struct bt_mesh_gen_battery_status); break; } @@ -360,7 +360,7 @@ static void generic_status(struct bt_mesh_model *model, status->global_latitude = net_buf_simple_pull_le32(buf); status->global_longitude = net_buf_simple_pull_le32(buf); status->global_altitude = net_buf_simple_pull_le16(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_gen_loc_global_status); break; } @@ -380,7 +380,7 @@ static void generic_status(struct bt_mesh_model *model, status->local_altitude = net_buf_simple_pull_le16(buf); status->floor_number = net_buf_simple_pull_u8(buf); status->uncertainty = net_buf_simple_pull_le16(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_gen_loc_local_status); break; } @@ -398,7 +398,7 @@ static void generic_status(struct bt_mesh_model *model, return; } net_buf_simple_add_mem(status->user_property_ids, buf->data, buf->len); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_gen_user_properties_status); break; } @@ -421,7 +421,7 @@ static void generic_status(struct bt_mesh_model *model, } net_buf_simple_add_mem(status->user_property_value, buf->data, buf->len); } - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_gen_user_property_status); break; } @@ -439,7 +439,7 @@ static void generic_status(struct bt_mesh_model *model, return; } net_buf_simple_add_mem(status->admin_property_ids, buf->data, buf->len); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_gen_admin_properties_status); break; } @@ -462,7 +462,7 @@ static void generic_status(struct bt_mesh_model *model, } net_buf_simple_add_mem(status->admin_property_value, buf->data, buf->len); } - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_gen_admin_property_status); break; } @@ -480,7 +480,7 @@ static void generic_status(struct bt_mesh_model *model, return; } net_buf_simple_add_mem(status->manu_property_ids, buf->data, buf->len); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_gen_manu_properties_status); break; } @@ -503,7 +503,7 @@ static void generic_status(struct bt_mesh_model *model, } net_buf_simple_add_mem(status->manu_property_value, buf->data, buf->len); } - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_gen_manu_property_status); break; } @@ -521,7 +521,7 @@ static void generic_status(struct bt_mesh_model *model, return; } net_buf_simple_add_mem(status->client_property_ids, buf->data, buf->len); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_gen_client_properties_status); break; } @@ -581,7 +581,7 @@ static void generic_status(struct bt_mesh_model *model, } if (!k_delayed_work_free(&node->timer)) { - u32_t opcode = node->opcode; + uint32_t opcode = node->opcode; bt_mesh_client_free_node(node); bt_mesh_generic_client_cb_evt_to_btc(opcode, evt, model, ctx, val, len); } @@ -733,7 +733,7 @@ static int gen_get_state(bt_mesh_client_common_param_t *common, void *value) } static int gen_set_state(bt_mesh_client_common_param_t *common, - void *value, u16_t value_len, bool need_ack) + void *value, uint16_t value_len, bool need_ack) { struct net_buf_simple *msg = NULL; int err = 0; @@ -974,7 +974,7 @@ int bt_mesh_generic_client_get_state(bt_mesh_client_common_param_t *common, void int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void *set) { bt_mesh_generic_client_t *client = NULL; - u16_t length = 0U; + uint16_t length = 0U; bool need_ack = false; if (!common || !common->model || !set) { @@ -1048,7 +1048,7 @@ int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void case BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET: need_ack = true; case BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET_UNACK: { - u8_t value = *(u8_t *)set; + uint8_t value = *(uint8_t *)set; if ((value & 0x3F) > 0x3E) { BT_ERR("Invalid Generic Default Trans Time Set transition time"); return -EINVAL; diff --git a/components/bt/esp_ble_mesh/mesh_models/client/include/client_common.h b/components/bt/esp_ble_mesh/mesh_models/client/include/client_common.h index 9883efe208..1686e3cf22 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/include/client_common.h +++ b/components/bt/esp_ble_mesh/mesh_models/client/include/client_common.h @@ -23,8 +23,8 @@ extern "C" { /** Client model opcode pair table */ typedef struct { - u32_t cli_op; /* Client message opcode */ - u32_t status_op; /* Corresponding status message opcode */ + uint32_t cli_op; /* Client message opcode */ + uint32_t status_op; /* Corresponding status message opcode */ } bt_mesh_client_op_pair_t; /** Client model user data context */ @@ -49,13 +49,13 @@ typedef struct { * * @return None */ - void (*publish_status)(u32_t opcode, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf); + void (*publish_status)(uint32_t opcode, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf); /** Pointer to the internal data of client model */ void *internal_data; /** Role of the device to which the client model belongs */ - u8_t msg_role; + uint8_t msg_role; } bt_mesh_client_user_data_t; /** Client model internal data context */ @@ -67,19 +67,19 @@ typedef struct { typedef struct { sys_snode_t client_node; struct bt_mesh_msg_ctx ctx; /* Message context */ - u32_t opcode; /* Message opcode */ - u32_t op_pending; /* Expected status message opcode */ - s32_t timeout; /* Calculated message timeout value */ + uint32_t opcode; /* Message opcode */ + uint32_t op_pending; /* Expected status message opcode */ + int32_t timeout; /* Calculated message timeout value */ struct k_delayed_work timer; /* Time used to get response. Only for internal use. */ } bt_mesh_client_node_t; /** Client model sending message parameters */ typedef struct { - u32_t opcode; /* Message opcode */ + uint32_t opcode; /* Message opcode */ struct bt_mesh_model *model; /* Pointer to the client model */ struct bt_mesh_msg_ctx ctx; /* Message context */ - s32_t msg_timeout; /* Time to get corresponding response */ - u8_t msg_role; /* Role (Node/Provisioner) of the device */ + int32_t msg_timeout; /* Time to get corresponding response */ + uint8_t msg_role; /* Role (Node/Provisioner) of the device */ const struct bt_mesh_send_cb *cb; /* User defined callback function */ void *cb_data; /* User defined callback value */ } bt_mesh_client_common_param_t; @@ -121,7 +121,7 @@ int bt_mesh_client_clear_list(void *data); * * @return Zero - success, otherwise - fail */ -int bt_mesh_set_client_model_role(struct bt_mesh_model *model, u8_t role); +int bt_mesh_set_client_model_role(struct bt_mesh_model *model, uint8_t role); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_models/client/include/generic_client.h b/components/bt/esp_ble_mesh/mesh_models/client/include/generic_client.h index b9619ac1cf..244fbdba02 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/include/generic_client.h +++ b/components/bt/esp_ble_mesh/mesh_models/client/include/generic_client.h @@ -52,18 +52,18 @@ extern const struct bt_mesh_model_op bt_mesh_gen_onoff_cli_op[]; typedef bt_mesh_client_user_data_t bt_mesh_gen_onoff_client_t; struct bt_mesh_gen_onoff_status { - bool op_en; /* Indicate whether optional parameters included */ - u8_t present_onoff; /* Present value of Generic OnOff state */ - u8_t target_onoff; /* Target value of Generic OnOff state (optional) */ - u8_t remain_time; /* Time to complete state transition (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint8_t present_onoff; /* Present value of Generic OnOff state */ + uint8_t target_onoff; /* Target value of Generic OnOff state (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ }; struct bt_mesh_gen_onoff_set { - bool op_en; /* Indicate whether optional parameters included */ - u8_t onoff; /* Target value of Generic OnOff state */ - u8_t tid; /* Transaction Identifier */ - u8_t trans_time; /* Time to complete state transition (optional) */ - u8_t delay; /* Indicate message execution delay (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint8_t onoff; /* Target value of Generic OnOff state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ }; /* Generic Level Client Model Context */ @@ -86,34 +86,34 @@ extern const struct bt_mesh_model_op bt_mesh_gen_level_cli_op[]; typedef bt_mesh_client_user_data_t bt_mesh_gen_level_client_t; struct bt_mesh_gen_level_status { - bool op_en; /* Indicate whether optional parameters included */ - s16_t present_level; /* Present value of Generic Level state */ - s16_t target_level; /* Target value of the Generic Level state (optional) */ - u8_t remain_time; /* Time to complete state transition (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + int16_t present_level; /* Present value of Generic Level state */ + int16_t target_level; /* Target value of the Generic Level state (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ }; struct bt_mesh_gen_level_set { - bool op_en; /* Indicate whether optional parameters included */ - s16_t level; /* Target value of Generic Level state */ - u8_t tid; /* Transaction Identifier */ - u8_t trans_time; /* Time to complete state transition (optional) */ - u8_t delay; /* Indicate message execution delay (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + int16_t level; /* Target value of Generic Level state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ }; struct bt_mesh_gen_delta_set { - bool op_en; /* Indicate whether optional parameters included */ - s32_t delta_level; /* Delta change of Generic Level state */ - u8_t tid; /* Transaction Identifier */ - u8_t trans_time; /* Time to complete state transition (optional) */ - u8_t delay; /* Indicate message execution delay (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + int32_t delta_level; /* Delta change of Generic Level state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ }; struct bt_mesh_gen_move_set { - bool op_en; /* Indicate whether optional parameters included */ - s16_t delta_level; /* Delta Level step to calculate Move speed for Generic Level state */ - u8_t tid; /* Transaction Identifier */ - u8_t trans_time; /* Time to complete state transition (optional) */ - u8_t delay; /* Indicate message execution delay (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + int16_t delta_level; /* Delta Level step to calculate Move speed for Generic Level state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ }; /* Generic Default Transition Time Client Model Context */ @@ -137,11 +137,11 @@ extern const struct bt_mesh_model_op bt_mesh_gen_def_trans_time_cli_op[]; typedef bt_mesh_client_user_data_t bt_mesh_gen_def_trans_time_client_t; struct bt_mesh_gen_def_trans_time_set { - u8_t trans_time; /* The value of the Generic Default Transition Time state */ + uint8_t trans_time; /* The value of the Generic Default Transition Time state */ }; struct bt_mesh_gen_def_trans_time_status { - u8_t trans_time; /* The value of the Generic Default Transition Time state */ + uint8_t trans_time; /* The value of the Generic Default Transition Time state */ }; /* Generic Power OnOff Client Model Context */ @@ -164,11 +164,11 @@ extern const struct bt_mesh_model_op bt_mesh_gen_power_onoff_cli_op[]; typedef bt_mesh_client_user_data_t bt_mesh_gen_power_onoff_client_t; struct bt_mesh_gen_onpowerup_set { - u8_t onpowerup; /* The value of the Generic OnPowerUp state */ + uint8_t onpowerup; /* The value of the Generic OnPowerUp state */ }; struct bt_mesh_gen_onpowerup_status { - u8_t onpowerup; /* The value of the Generic OnPowerUp state */ + uint8_t onpowerup; /* The value of the Generic OnPowerUp state */ }; /* Generic Power Level Client Model Context */ @@ -191,41 +191,41 @@ extern const struct bt_mesh_model_op bt_mesh_gen_power_level_cli_op[]; typedef bt_mesh_client_user_data_t bt_mesh_gen_power_level_client_t; struct bt_mesh_gen_power_level_status { - bool op_en; /* Indicate whether optional parameters included */ - u16_t present_power; /* Present value of Generic Power Actual state */ - u16_t target_power; /* Target value of Generic Power Actual state (optional) */ - u8_t remain_time; /* Time to complete state transition (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t present_power; /* Present value of Generic Power Actual state */ + uint16_t target_power; /* Target value of Generic Power Actual state (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ }; struct bt_mesh_gen_power_last_status { - u16_t power; /* The value of the Generic Power Last state */ + uint16_t power; /* The value of the Generic Power Last state */ }; struct bt_mesh_gen_power_default_status { - u16_t power; /* The value of the Generic Default Last state */ + uint16_t power; /* The value of the Generic Default Last state */ }; struct bt_mesh_gen_power_range_status { - u8_t status_code; /* Status Code for the requesting message */ - u16_t range_min; /* Value of Range Min field of Generic Power Range state */ - u16_t range_max; /* Value of Range Max field of Generic Power Range state */ + uint8_t status_code; /* Status Code for the requesting message */ + uint16_t range_min; /* Value of Range Min field of Generic Power Range state */ + uint16_t range_max; /* Value of Range Max field of Generic Power Range state */ }; struct bt_mesh_gen_power_level_set { - bool op_en; /* Indicate whether optional parameters included */ - u16_t power; /* Target value of Generic Power Actual state */ - u8_t tid; /* Transaction Identifier */ - u8_t trans_time; /* Time to complete state transition (optional) */ - u8_t delay; /* Indicate message execution delay (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t power; /* Target value of Generic Power Actual state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ }; struct bt_mesh_gen_power_default_set { - u16_t power; /* The value of the Generic Power Default state */ + uint16_t power; /* The value of the Generic Power Default state */ }; struct bt_mesh_gen_power_range_set { - u16_t range_min; /* Value of Range Min field of Generic Power Range state */ - u16_t range_max; /* Value of Range Max field of Generic Power Range state */ + uint16_t range_min; /* Value of Range Min field of Generic Power Range state */ + uint16_t range_max; /* Value of Range Max field of Generic Power Range state */ }; /* Generic Battery Client Model Context */ @@ -248,10 +248,10 @@ extern const struct bt_mesh_model_op bt_mesh_gen_battery_cli_op[]; typedef bt_mesh_client_user_data_t bt_mesh_gen_battery_client_t; struct bt_mesh_gen_battery_status { - u32_t battery_level : 8; /* Value of Generic Battery Level state */ - u32_t time_to_discharge : 24; /* Value of Generic Battery Time to Discharge state */ - u32_t time_to_charge : 24; /* Value of Generic Battery Time to Charge state */ - u32_t flags : 8; /* Value of Generic Battery Flags state */ + uint32_t battery_level : 8; /* Value of Generic Battery Level state */ + uint32_t time_to_discharge : 24; /* Value of Generic Battery Time to Discharge state */ + uint32_t time_to_charge : 24; /* Value of Generic Battery Time to Charge state */ + uint32_t flags : 8; /* Value of Generic Battery Flags state */ }; /* Generic Location Client Model Context */ @@ -274,31 +274,31 @@ extern const struct bt_mesh_model_op bt_mesh_gen_location_cli_op[]; typedef bt_mesh_client_user_data_t bt_mesh_gen_location_client_t; struct bt_mesh_gen_loc_global_status { - s32_t global_latitude; /* Global Coordinates (Latitude) */ - s32_t global_longitude; /* Global Coordinates (Longitude) */ - s16_t global_altitude; /* Global Altitude */ + int32_t global_latitude; /* Global Coordinates (Latitude) */ + int32_t global_longitude; /* Global Coordinates (Longitude) */ + int16_t global_altitude; /* Global Altitude */ }; struct bt_mesh_gen_loc_local_status { - s16_t local_north; /* Local Coordinates (North) */ - s16_t local_east; /* Local Coordinates (East) */ - s16_t local_altitude; /* Local Altitude */ - u8_t floor_number; /* Floor Number */ - u16_t uncertainty; /* Uncertainty */ + int16_t local_north; /* Local Coordinates (North) */ + int16_t local_east; /* Local Coordinates (East) */ + int16_t local_altitude; /* Local Altitude */ + uint8_t floor_number; /* Floor Number */ + uint16_t uncertainty; /* Uncertainty */ }; struct bt_mesh_gen_loc_global_set { - s32_t global_latitude; /* Global Coordinates (Latitude) */ - s32_t global_longitude; /* Global Coordinates (Longitude) */ - s16_t global_altitude; /* Global Altitude */ + int32_t global_latitude; /* Global Coordinates (Latitude) */ + int32_t global_longitude; /* Global Coordinates (Longitude) */ + int16_t global_altitude; /* Global Altitude */ }; struct bt_mesh_gen_loc_local_set { - s16_t local_north; /* Local Coordinates (North) */ - s16_t local_east; /* Local Coordinates (East) */ - s16_t local_altitude; /* Local Altitude */ - u8_t floor_number; /* Floor Number */ - u16_t uncertainty; /* Uncertainty */ + int16_t local_north; /* Local Coordinates (North) */ + int16_t local_east; /* Local Coordinates (East) */ + int16_t local_altitude; /* Local Altitude */ + uint8_t floor_number; /* Floor Number */ + uint16_t uncertainty; /* Uncertainty */ }; /* Generic Property Client Model Context */ @@ -325,9 +325,9 @@ struct bt_mesh_gen_user_properties_status { }; struct bt_mesh_gen_user_property_status { - bool op_en; /* Indicate whether optional parameters included */ - u16_t user_property_id; /* Property ID identifying a Generic User Property */ - u8_t user_access; /* Enumeration indicating user access (optional) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t user_property_id; /* Property ID identifying a Generic User Property */ + uint8_t user_access; /* Enumeration indicating user access (optional) */ struct net_buf_simple *user_property_value; /* Raw value for the User Property (C.1) */ }; @@ -336,9 +336,9 @@ struct bt_mesh_gen_admin_properties_status { }; struct bt_mesh_gen_admin_property_status { - bool op_en; /* Indicate whether optional parameters included */ - u16_t admin_property_id; /* Property ID identifying a Generic Admin Property */ - u8_t admin_user_access; /* Enumeration indicating user access (optional) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t admin_property_id; /* Property ID identifying a Generic Admin Property */ + uint8_t admin_user_access; /* Enumeration indicating user access (optional) */ struct net_buf_simple *admin_property_value; /* Raw value for the Admin Property (C.1) */ }; @@ -347,9 +347,9 @@ struct bt_mesh_gen_manu_properties_status { }; struct bt_mesh_gen_manu_property_status { - bool op_en; /* Indicate whether optional parameters included */ - u16_t manu_property_id; /* Property ID identifying a Generic Manufacturer Property */ - u8_t manu_user_access; /* Enumeration indicating user access (optional) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t manu_property_id; /* Property ID identifying a Generic Manufacturer Property */ + uint8_t manu_user_access; /* Enumeration indicating user access (optional) */ struct net_buf_simple *manu_property_value; /* Raw value for the Manufacturer Property (C.1) */ }; @@ -358,35 +358,35 @@ struct bt_mesh_gen_client_properties_status { }; struct bt_mesh_gen_user_property_get { - u16_t user_property_id; /* Property ID identifying a Generic User Property */ + uint16_t user_property_id; /* Property ID identifying a Generic User Property */ }; struct bt_mesh_gen_user_property_set { - u16_t user_property_id; /* Property ID identifying a Generic User Property */ + uint16_t user_property_id; /* Property ID identifying a Generic User Property */ struct net_buf_simple *user_property_value; /* Raw value for the User Property */ }; struct bt_mesh_gen_admin_property_get { - u16_t admin_property_id; /* Property ID identifying a Generic Admin Property */ + uint16_t admin_property_id; /* Property ID identifying a Generic Admin Property */ }; struct bt_mesh_gen_admin_property_set { - u16_t admin_property_id; /* Property ID identifying a Generic Admin Property */ - u8_t admin_user_access; /* Enumeration indicating user access */ + uint16_t admin_property_id; /* Property ID identifying a Generic Admin Property */ + uint8_t admin_user_access; /* Enumeration indicating user access */ struct net_buf_simple *admin_property_value; /* Raw value for the Admin Property */ }; struct bt_mesh_gen_manu_property_get { - u16_t manu_property_id; /* Property ID identifying a Generic Manufacturer Property */ + uint16_t manu_property_id; /* Property ID identifying a Generic Manufacturer Property */ }; struct bt_mesh_gen_manu_property_set { - u16_t manu_property_id; /* Property ID identifying a Generic Manufacturer Property */ - u8_t manu_user_access; /* Enumeration indicating user access */ + uint16_t manu_property_id; /* Property ID identifying a Generic Manufacturer Property */ + uint8_t manu_user_access; /* Enumeration indicating user access */ }; struct bt_mesh_gen_client_properties_get { - u16_t client_property_id; /* A starting Client Property ID present within an element */ + uint16_t client_property_id; /* A starting Client Property ID present within an element */ }; /** diff --git a/components/bt/esp_ble_mesh/mesh_models/client/include/lighting_client.h b/components/bt/esp_ble_mesh/mesh_models/client/include/lighting_client.h index 5f1f8a86c8..fe2c9203c3 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/include/lighting_client.h +++ b/components/bt/esp_ble_mesh/mesh_models/client/include/lighting_client.h @@ -52,56 +52,56 @@ extern const struct bt_mesh_model_op bt_mesh_light_lightness_cli_op[]; typedef bt_mesh_client_user_data_t bt_mesh_light_lightness_client_t; struct bt_mesh_light_lightness_status { - bool op_en; /* Indicate whether optional parameters included */ - u16_t present_lightness; /* Present value of light lightness actual state */ - u16_t target_lightness; /* Target value of light lightness actual state (optional) */ - u8_t remain_time; /* Time to complete state transition (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t present_lightness; /* Present value of light lightness actual state */ + uint16_t target_lightness; /* Target value of light lightness actual state (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ }; struct bt_mesh_light_lightness_linear_status { - bool op_en; /* Indicate whether optional parameters included */ - u16_t present_lightness; /* Present value of light lightness linear state */ - u16_t target_lightness; /* Target value of light lightness linear state (optional) */ - u8_t remain_time; /* Time to complete state transition (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t present_lightness; /* Present value of light lightness linear state */ + uint16_t target_lightness; /* Target value of light lightness linear state (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ }; struct bt_mesh_light_lightness_last_status { - u16_t lightness; /* The value of the Light Lightness Last state */ + uint16_t lightness; /* The value of the Light Lightness Last state */ }; struct bt_mesh_light_lightness_default_status { - u16_t lightness; /* The value of the Light Lightness default state */ + uint16_t lightness; /* The value of the Light Lightness default state */ }; struct bt_mesh_light_lightness_range_status { - u8_t status_code; /* Status Code for the requesting message */ - u16_t range_min; /* Value of range min field of light lightness range state */ - u16_t range_max; /* Value of range max field of light lightness range state */ + uint8_t status_code; /* Status Code for the requesting message */ + uint16_t range_min; /* Value of range min field of light lightness range state */ + uint16_t range_max; /* Value of range max field of light lightness range state */ }; struct bt_mesh_light_lightness_set { - bool op_en; /* Indicate whether optional parameters included */ - u16_t lightness; /* Target value of light lightness actual state */ - u8_t tid; /* Transaction Identifier */ - u8_t trans_time; /* Time to complete state transition (optional) */ - u8_t delay; /* Indicate message execution delay (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t lightness; /* Target value of light lightness actual state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ }; struct bt_mesh_light_lightness_linear_set { - bool op_en; /* Indicate whether optional parameters included */ - u16_t lightness; /* Target value of light lightness linear state */ - u8_t tid; /* Transaction Identifier */ - u8_t trans_time; /* Time to complete state transition (optional) */ - u8_t delay; /* Indicate message execution delay (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t lightness; /* Target value of light lightness linear state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ }; struct bt_mesh_light_lightness_default_set { - u16_t lightness; /* The value of the Light Lightness Default state */ + uint16_t lightness; /* The value of the Light Lightness Default state */ }; struct bt_mesh_light_lightness_range_set { - u16_t range_min; /* Value of range min field of light lightness range state */ - u16_t range_max; /* Value of range max field of light lightness range state */ + uint16_t range_min; /* Value of range min field of light lightness range state */ + uint16_t range_max; /* Value of range max field of light lightness range state */ }; /* Light CTL Client Model Context */ @@ -124,63 +124,63 @@ extern const struct bt_mesh_model_op bt_mesh_light_ctl_cli_op[]; typedef bt_mesh_client_user_data_t bt_mesh_light_ctl_client_t; struct bt_mesh_light_ctl_status { - bool op_en; /* Indicate whether optional parameters included */ - u16_t present_ctl_lightness; /* Present value of light ctl lightness state */ - u16_t present_ctl_temperature; /* Present value of light ctl temperature state */ - u16_t target_ctl_lightness; /* Target value of light ctl lightness state (optional) */ - u16_t target_ctl_temperature; /* Target value of light ctl temperature state (C.1) */ - u8_t remain_time; /* Time to complete state transition (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t present_ctl_lightness; /* Present value of light ctl lightness state */ + uint16_t present_ctl_temperature; /* Present value of light ctl temperature state */ + uint16_t target_ctl_lightness; /* Target value of light ctl lightness state (optional) */ + uint16_t target_ctl_temperature; /* Target value of light ctl temperature state (C.1) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ }; struct bt_mesh_light_ctl_temperature_status { - bool op_en; /* Indicate whether optional parameters included */ - u16_t present_ctl_temperature; /* Present value of light ctl temperature state */ - u16_t present_ctl_delta_uv; /* Present value of light ctl delta UV state */ - u16_t target_ctl_temperature; /* Target value of light ctl temperature state (optional) */ - u16_t target_ctl_delta_uv; /* Target value of light ctl delta UV state (C.1) */ - u8_t remain_time; /* Time to complete state transition (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t present_ctl_temperature; /* Present value of light ctl temperature state */ + uint16_t present_ctl_delta_uv; /* Present value of light ctl delta UV state */ + uint16_t target_ctl_temperature; /* Target value of light ctl temperature state (optional) */ + uint16_t target_ctl_delta_uv; /* Target value of light ctl delta UV state (C.1) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ }; struct bt_mesh_light_ctl_temperature_range_status { - u8_t status_code; /* Status code for the requesting message */ - u16_t range_min; /* Value of temperature range min field of light ctl temperature range state */ - u16_t range_max; /* Value of temperature range max field of light ctl temperature range state */ + uint8_t status_code; /* Status code for the requesting message */ + uint16_t range_min; /* Value of temperature range min field of light ctl temperature range state */ + uint16_t range_max; /* Value of temperature range max field of light ctl temperature range state */ }; struct bt_mesh_light_ctl_default_status { - u16_t lightness; /* Value of light lightness default state */ - u16_t temperature; /* Value of light temperature default state */ - s16_t delta_uv; /* Value of light delta UV default state */ + uint16_t lightness; /* Value of light lightness default state */ + uint16_t temperature; /* Value of light temperature default state */ + int16_t delta_uv; /* Value of light delta UV default state */ }; struct bt_mesh_light_ctl_set { - bool op_en; /* Indicate whether optional parameters included */ - u16_t ctl_lightness; /* Target value of light ctl lightness state */ - u16_t ctl_temperature; /* Target value of light ctl temperature state */ - s16_t ctl_delta_uv; /* Target value of light ctl delta UV state */ - u8_t tid; /* Transaction Identifier */ - u8_t trans_time; /* Time to complete state transition (optional) */ - u8_t delay; /* Indicate message execution delay (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t ctl_lightness; /* Target value of light ctl lightness state */ + uint16_t ctl_temperature; /* Target value of light ctl temperature state */ + int16_t ctl_delta_uv; /* Target value of light ctl delta UV state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ }; struct bt_mesh_light_ctl_temperature_set { - bool op_en; /* Indicate whether optional parameters included */ - u16_t ctl_temperature; /* Target value of light ctl temperature state */ - s16_t ctl_delta_uv; /* Target value of light ctl delta UV state */ - u8_t tid; /* Transaction Identifier */ - u8_t trans_time; /* Time to complete state transition (optional) */ - u8_t delay; /* Indicate message execution delay (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t ctl_temperature; /* Target value of light ctl temperature state */ + int16_t ctl_delta_uv; /* Target value of light ctl delta UV state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ }; struct bt_mesh_light_ctl_temperature_range_set { - u16_t range_min; /* Value of temperature range min field of light ctl temperature range state */ - u16_t range_max; /* Value of temperature range max field of light ctl temperature range state */ + uint16_t range_min; /* Value of temperature range min field of light ctl temperature range state */ + uint16_t range_max; /* Value of temperature range max field of light ctl temperature range state */ }; struct bt_mesh_light_ctl_default_set { - u16_t lightness; /* Value of light lightness default state */ - u16_t temperature; /* Value of light temperature default state */ - s16_t delta_uv; /* Value of light delta UV default state */ + uint16_t lightness; /* Value of light lightness default state */ + uint16_t temperature; /* Value of light temperature default state */ + int16_t delta_uv; /* Value of light delta UV default state */ }; /* Light HSL Client Model Context */ @@ -203,86 +203,86 @@ extern const struct bt_mesh_model_op bt_mesh_light_hsl_cli_op[]; typedef bt_mesh_client_user_data_t bt_mesh_light_hsl_client_t; struct bt_mesh_light_hsl_status { - bool op_en; /* Indicate whether optional parameters included */ - u16_t hsl_lightness; /* Present value of light hsl lightness state */ - u16_t hsl_hue; /* Present value of light hsl hue state */ - u16_t hsl_saturation; /* Present value of light hsl saturation state */ - u8_t remain_time; /* Time to complete state transition (optional) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t hsl_lightness; /* Present value of light hsl lightness state */ + uint16_t hsl_hue; /* Present value of light hsl hue state */ + uint16_t hsl_saturation; /* Present value of light hsl saturation state */ + uint8_t remain_time; /* Time to complete state transition (optional) */ }; struct bt_mesh_light_hsl_target_status { - bool op_en; /* Indicate whether optional parameters included */ - u16_t hsl_lightness_target; /* Target value of light hsl lightness state */ - u16_t hsl_hue_target; /* Target value of light hsl hue state */ - u16_t hsl_saturation_target; /* Target value of light hsl saturation state */ - u8_t remain_time; /* Time to complete state transition (optional) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t hsl_lightness_target; /* Target value of light hsl lightness state */ + uint16_t hsl_hue_target; /* Target value of light hsl hue state */ + uint16_t hsl_saturation_target; /* Target value of light hsl saturation state */ + uint8_t remain_time; /* Time to complete state transition (optional) */ }; struct bt_mesh_light_hsl_hue_status { - bool op_en; /* Indicate whether optional parameters included */ - u16_t present_hue; /* Present value of light hsl hue state */ - u16_t target_hue; /* Target value of light hsl hue state (optional) */ - u8_t remain_time; /* Time to complete state transition (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t present_hue; /* Present value of light hsl hue state */ + uint16_t target_hue; /* Target value of light hsl hue state (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ }; struct bt_mesh_light_hsl_saturation_status { - bool op_en; /* Indicate whether optional parameters included */ - u16_t present_saturation; /* Present value of light hsl saturation state */ - u16_t target_saturation; /* Target value of light hsl saturation state (optional) */ - u8_t remain_time; /* Time to complete state transition (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t present_saturation; /* Present value of light hsl saturation state */ + uint16_t target_saturation; /* Target value of light hsl saturation state (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ }; struct bt_mesh_light_hsl_default_status { - u16_t lightness; /* Value of light lightness default state */ - u16_t hue; /* Value of light hue default state */ - u16_t saturation; /* Value of light saturation default state */ + uint16_t lightness; /* Value of light lightness default state */ + uint16_t hue; /* Value of light hue default state */ + uint16_t saturation; /* Value of light saturation default state */ }; struct bt_mesh_light_hsl_range_status { - u8_t status_code; /* Status code for the requesting message */ - u16_t hue_range_min; /* Value of hue range min field of light hsl hue range state */ - u16_t hue_range_max; /* Value of hue range max field of light hsl hue range state */ - u16_t saturation_range_min; /* Value of saturation range min field of light hsl saturation range state */ - u16_t saturation_range_max; /* Value of saturation range max field of light hsl saturation range state */ + uint8_t status_code; /* Status code for the requesting message */ + uint16_t hue_range_min; /* Value of hue range min field of light hsl hue range state */ + uint16_t hue_range_max; /* Value of hue range max field of light hsl hue range state */ + uint16_t saturation_range_min; /* Value of saturation range min field of light hsl saturation range state */ + uint16_t saturation_range_max; /* Value of saturation range max field of light hsl saturation range state */ }; struct bt_mesh_light_hsl_set { - bool op_en; /* Indicate whether optional parameters included */ - u16_t hsl_lightness; /* Target value of light hsl lightness state */ - u16_t hsl_hue; /* Target value of light hsl hue state */ - u16_t hsl_saturation; /* Target value of light hsl saturation state */ - u8_t tid; /* Transaction Identifier */ - u8_t trans_time; /* Time to complete state transition (optional) */ - u8_t delay; /* Indicate message execution delay (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t hsl_lightness; /* Target value of light hsl lightness state */ + uint16_t hsl_hue; /* Target value of light hsl hue state */ + uint16_t hsl_saturation; /* Target value of light hsl saturation state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ }; struct bt_mesh_light_hsl_hue_set { - bool op_en; /* Indicate whether optional parameters included */ - u16_t hue; /* Target value of light hsl hue state */ - u8_t tid; /* Transaction Identifier */ - u8_t trans_time; /* Time to complete state transition (optional) */ - u8_t delay; /* Indicate message execution delay (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t hue; /* Target value of light hsl hue state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ }; struct bt_mesh_light_hsl_saturation_set { - bool op_en; /* Indicate whether optional parameters included */ - u16_t saturation; /* Target value of light hsl hue state */ - u8_t tid; /* Transaction Identifier */ - u8_t trans_time; /* Time to complete state transition (optional) */ - u8_t delay; /* Indicate message execution delay (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t saturation; /* Target value of light hsl hue state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ }; struct bt_mesh_light_hsl_default_set { - u16_t lightness; /* Value of light lightness default state */ - u16_t hue; /* Value of light hue default state */ - u16_t saturation; /* Value of light saturation default state */ + uint16_t lightness; /* Value of light lightness default state */ + uint16_t hue; /* Value of light hue default state */ + uint16_t saturation; /* Value of light saturation default state */ }; struct bt_mesh_light_hsl_range_set { - u16_t hue_range_min; /* Value of hue range min field of light hsl hue range state */ - u16_t hue_range_max; /* Value of hue range max field of light hsl hue range state */ - u16_t saturation_range_min; /* Value of saturation range min field of light hsl saturation range state */ - u16_t saturation_range_max; /* Value of saturation range max field of light hsl saturation range state */ + uint16_t hue_range_min; /* Value of hue range min field of light hsl hue range state */ + uint16_t hue_range_max; /* Value of hue range max field of light hsl hue range state */ + uint16_t saturation_range_min; /* Value of saturation range min field of light hsl saturation range state */ + uint16_t saturation_range_max; /* Value of saturation range max field of light hsl saturation range state */ }; /* Light xyL Client Model Context */ @@ -305,56 +305,56 @@ extern const struct bt_mesh_model_op bt_mesh_light_xyl_cli_op[]; typedef bt_mesh_client_user_data_t bt_mesh_light_xyl_client_t; struct bt_mesh_light_xyl_status { - bool op_en; /* Indicate whether optional parameters included */ - u16_t xyl_lightness; /* The present value of the Light xyL Lightness state */ - u16_t xyl_x; /* The present value of the Light xyL x state */ - u16_t xyl_y; /* The present value of the Light xyL y state */ - u8_t remain_time; /* Time to complete state transition (optional) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t xyl_lightness; /* The present value of the Light xyL Lightness state */ + uint16_t xyl_x; /* The present value of the Light xyL x state */ + uint16_t xyl_y; /* The present value of the Light xyL y state */ + uint8_t remain_time; /* Time to complete state transition (optional) */ }; struct bt_mesh_light_xyl_target_status { - bool op_en; /* Indicate whether optional parameters included */ - u16_t target_xyl_lightness; /* The target value of the Light xyL Lightness state */ - u16_t target_xyl_x; /* The target value of the Light xyL x state */ - u16_t target_xyl_y; /* The target value of the Light xyL y state */ - u8_t remain_time; /* Time to complete state transition (optional) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t target_xyl_lightness; /* The target value of the Light xyL Lightness state */ + uint16_t target_xyl_x; /* The target value of the Light xyL x state */ + uint16_t target_xyl_y; /* The target value of the Light xyL y state */ + uint8_t remain_time; /* Time to complete state transition (optional) */ }; struct bt_mesh_light_xyl_default_status { - u16_t lightness; /* The value of the Light Lightness Default state */ - u16_t xyl_x; /* The value of the Light xyL x Default state */ - u16_t xyl_y; /* The value of the Light xyL y Default state */ + uint16_t lightness; /* The value of the Light Lightness Default state */ + uint16_t xyl_x; /* The value of the Light xyL x Default state */ + uint16_t xyl_y; /* The value of the Light xyL y Default state */ }; struct bt_mesh_light_xyl_range_status { - u8_t status_code; /* Status Code for the requesting message */ - u16_t xyl_x_range_min; /* The value of the xyL x Range Min field of the Light xyL x Range state */ - u16_t xyl_x_range_max; /* The value of the xyL x Range Max field of the Light xyL x Range state */ - u16_t xyl_y_range_min; /* The value of the xyL y Range Min field of the Light xyL y Range state */ - u16_t xyl_y_range_max; /* The value of the xyL y Range Max field of the Light xyL y Range state */ + uint8_t status_code; /* Status Code for the requesting message */ + uint16_t xyl_x_range_min; /* The value of the xyL x Range Min field of the Light xyL x Range state */ + uint16_t xyl_x_range_max; /* The value of the xyL x Range Max field of the Light xyL x Range state */ + uint16_t xyl_y_range_min; /* The value of the xyL y Range Min field of the Light xyL y Range state */ + uint16_t xyl_y_range_max; /* The value of the xyL y Range Max field of the Light xyL y Range state */ }; struct bt_mesh_light_xyl_set { - bool op_en; /* Indicate whether optional parameters included */ - u16_t xyl_lightness; /* The target value of the Light xyL Lightness state */ - u16_t xyl_x; /* The target value of the Light xyL x state */ - u16_t xyl_y; /* The target value of the Light xyL y state */ - u8_t tid; /* Transaction Identifier */ - u8_t trans_time; /* Time to complete state transition (optional) */ - u8_t delay; /* Indicate message execution delay (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t xyl_lightness; /* The target value of the Light xyL Lightness state */ + uint16_t xyl_x; /* The target value of the Light xyL x state */ + uint16_t xyl_y; /* The target value of the Light xyL y state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ }; struct bt_mesh_light_xyl_default_set { - u16_t lightness; /* The value of the Light Lightness Default state */ - u16_t xyl_x; /* The value of the Light xyL x Default state */ - u16_t xyl_y; /* The value of the Light xyL y Default state */ + uint16_t lightness; /* The value of the Light Lightness Default state */ + uint16_t xyl_x; /* The value of the Light xyL x Default state */ + uint16_t xyl_y; /* The value of the Light xyL y Default state */ }; struct bt_mesh_light_xyl_range_set { - u16_t xyl_x_range_min; /* The value of the xyL x Range Min field of the Light xyL x Range state */ - u16_t xyl_x_range_max; /* The value of the xyL x Range Max field of the Light xyL x Range state */ - u16_t xyl_y_range_min; /* The value of the xyL y Range Min field of the Light xyL y Range state */ - u16_t xyl_y_range_max; /* The value of the xyL y Range Max field of the Light xyL y Range state */ + uint16_t xyl_x_range_min; /* The value of the xyL x Range Min field of the Light xyL x Range state */ + uint16_t xyl_x_range_max; /* The value of the xyL x Range Max field of the Light xyL x Range state */ + uint16_t xyl_y_range_min; /* The value of the xyL y Range Min field of the Light xyL y Range state */ + uint16_t xyl_y_range_max; /* The value of the xyL y Range Max field of the Light xyL y Range state */ }; /* Light LC Client Model Context */ @@ -377,47 +377,47 @@ extern const struct bt_mesh_model_op bt_mesh_light_lc_cli_op[]; typedef bt_mesh_client_user_data_t bt_mesh_light_lc_client_t; struct bt_mesh_light_lc_mode_status { - u8_t mode; /* The present value of the Light LC Mode state */ + uint8_t mode; /* The present value of the Light LC Mode state */ }; struct bt_mesh_light_lc_om_status { - u8_t mode; /* The present value of the Light LC Occupancy Mode state */ + uint8_t mode; /* The present value of the Light LC Occupancy Mode state */ }; struct bt_mesh_light_lc_light_onoff_status { - bool op_en; /* Indicate whether optional parameters included */ - u8_t present_light_onoff; /* The present value of the Light LC Light OnOff state */ - u8_t target_light_onoff; /* The target value of the Light LC Light OnOff state (Optional) */ - u8_t remain_time; /* Time to complete state transition (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint8_t present_light_onoff; /* The present value of the Light LC Light OnOff state */ + uint8_t target_light_onoff; /* The target value of the Light LC Light OnOff state (Optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ }; struct bt_mesh_light_lc_property_status { - u16_t light_lc_property_id; /* Property ID identifying a Light LC Property */ + uint16_t light_lc_property_id; /* Property ID identifying a Light LC Property */ struct net_buf_simple *light_lc_property_value; /* Raw value for the Light LC Property */ }; struct bt_mesh_light_lc_mode_set { - u8_t mode; /* The target value of the Light LC Mode state */ + uint8_t mode; /* The target value of the Light LC Mode state */ }; struct bt_mesh_light_lc_om_set { - u8_t mode; /* The target value of the Light LC Occupancy Mode state */ + uint8_t mode; /* The target value of the Light LC Occupancy Mode state */ }; struct bt_mesh_light_lc_light_onoff_set { - bool op_en; /* Indicate whether optional parameters included */ - u8_t light_onoff; /* The target value of the Light LC Light OnOff state */ - u8_t tid; /* Transaction Identifier */ - u8_t trans_time; /* Time to complete state transition (optional) */ - u8_t delay; /* Indicate message execution delay (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint8_t light_onoff; /* The target value of the Light LC Light OnOff state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ }; struct bt_mesh_light_lc_property_get { - u16_t light_lc_property_id; /* Property ID identifying a Light LC Property */ + uint16_t light_lc_property_id; /* Property ID identifying a Light LC Property */ }; struct bt_mesh_light_lc_property_set { - u16_t light_lc_property_id; /* Property ID identifying a Light LC Property */ + uint16_t light_lc_property_id; /* Property ID identifying a Light LC Property */ struct net_buf_simple *light_lc_property_value; /* Raw value for the Light LC Property */ }; diff --git a/components/bt/esp_ble_mesh/mesh_models/client/include/sensor_client.h b/components/bt/esp_ble_mesh/mesh_models/client/include/sensor_client.h index 70fb3989d5..03cd0743b8 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/include/sensor_client.h +++ b/components/bt/esp_ble_mesh/mesh_models/client/include/sensor_client.h @@ -53,20 +53,20 @@ struct bt_mesh_sensor_descriptor_status { }; struct bt_mesh_sensor_cadence_status { - u16_t property_id; /* Property for the sensor */ + uint16_t property_id; /* Property for the sensor */ struct net_buf_simple *sensor_cadence_value; /* Value of sensor cadence state */ }; struct bt_mesh_sensor_settings_status { - u16_t sensor_property_id; /* Property ID identifying a sensor */ + uint16_t sensor_property_id; /* Property ID identifying a sensor */ struct net_buf_simple *sensor_setting_property_ids; /* A sequence of N sensor setting property IDs (optional) */ }; struct bt_mesh_sensor_setting_status { - bool op_en; /* Indicate whether optional parameters included */ - u16_t sensor_property_id; /* Property ID identifying a sensor */ - u16_t sensor_setting_property_id; /* Setting ID identifying a setting within a sensor */ - u8_t sensor_setting_access; /* Read/Write access rights for the setting (optional) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t sensor_property_id; /* Property ID identifying a sensor */ + uint16_t sensor_setting_property_id; /* Setting ID identifying a setting within a sensor */ + uint8_t sensor_setting_access; /* Read/Write access rights for the setting (optional) */ struct net_buf_simple *sensor_setting_raw; /* Raw value for the setting */ }; @@ -75,63 +75,63 @@ struct bt_mesh_sensor_status { }; struct bt_mesh_sensor_column_status { - u16_t property_id; /* Property identifying a sensor and the Y axis */ + uint16_t property_id; /* Property identifying a sensor and the Y axis */ struct net_buf_simple *sensor_column_value; /* Left values of sensor column status */ }; struct bt_mesh_sensor_series_status { - u16_t property_id; /* Property identifying a sensor and the Y axis */ + uint16_t property_id; /* Property identifying a sensor and the Y axis */ struct net_buf_simple *sensor_series_value; /* Left values of sensor series status */ }; struct bt_mesh_sensor_descriptor_get { - bool op_en; /* Indicate whether optional parameters included */ - u16_t property_id; /* Property ID for the sensor (optional) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t property_id; /* Property ID for the sensor (optional) */ }; struct bt_mesh_sensor_cadence_get { - u16_t property_id; /* Property ID for the sensor */ + uint16_t property_id; /* Property ID for the sensor */ }; struct bt_mesh_sensor_cadence_set { - u16_t property_id; /* Property ID for the sensor */ - u8_t fast_cadence_period_divisor : 7, /* Divisor for the publish period */ - status_trigger_type : 1; /* The unit and format of the Status Trigger Delta fields */ + uint16_t property_id; /* Property ID for the sensor */ + uint8_t fast_cadence_period_divisor : 7, /* Divisor for the publish period */ + status_trigger_type : 1; /* The unit and format of the Status Trigger Delta fields */ struct net_buf_simple *status_trigger_delta_down; /* Delta down value that triggers a status message */ struct net_buf_simple *status_trigger_delta_up; /* Delta up value that triggers a status message */ - u8_t status_min_interval; /* Minimum interval between two consecutive Status messages */ - struct net_buf_simple *fast_cadence_low; /* Low value for the fast cadence range */ + uint8_t status_min_interval; /* Minimum interval between two consecutive Status messages */ + struct net_buf_simple *fast_cadence_low; /* Low value for the fast cadence range */ struct net_buf_simple *fast_cadence_high; /* Fast value for the fast cadence range */ }; struct bt_mesh_sensor_settings_get { - u16_t sensor_property_id; /* Property ID for the sensor */ + uint16_t sensor_property_id; /* Property ID for the sensor */ }; struct bt_mesh_sensor_setting_get { - u16_t sensor_property_id; /* Property ID identifying a sensor */ - u16_t sensor_setting_property_id; /* Setting ID identifying a setting within a sensor */ + uint16_t sensor_property_id; /* Property ID identifying a sensor */ + uint16_t sensor_setting_property_id; /* Setting ID identifying a setting within a sensor */ }; struct bt_mesh_sensor_setting_set { - u16_t sensor_property_id; /* Property ID identifying a sensor */ - u16_t sensor_setting_property_id; /* Setting ID identifying a setting within a sensor */ + uint16_t sensor_property_id; /* Property ID identifying a sensor */ + uint16_t sensor_setting_property_id; /* Setting ID identifying a setting within a sensor */ struct net_buf_simple *sensor_setting_raw; /* Raw value for the setting */ }; struct bt_mesh_sensor_get { - bool op_en; /* Indicate whether optional parameters included */ - u16_t property_id; /* Property ID for the sensor (optional) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t property_id; /* Property ID for the sensor (optional) */ }; struct bt_mesh_sensor_column_get { - u16_t property_id; /* Property identifying a sensor */ + uint16_t property_id; /* Property identifying a sensor */ struct net_buf_simple *raw_value_x; /* Raw value identifying a column */ }; struct bt_mesh_sensor_series_get { - bool op_en; /* Indicate whether optional parameters included */ - u16_t property_id; /* Property identifying a sensor */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t property_id; /* Property identifying a sensor */ struct net_buf_simple *raw_value_x1; /* Raw value identifying a starting column (optional) */ struct net_buf_simple *raw_value_x2; /* Raw value identifying a ending column (C.1) */ }; diff --git a/components/bt/esp_ble_mesh/mesh_models/client/include/time_scene_client.h b/components/bt/esp_ble_mesh/mesh_models/client/include/time_scene_client.h index 78cce2cbb3..216d2559c9 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/include/time_scene_client.h +++ b/components/bt/esp_ble_mesh/mesh_models/client/include/time_scene_client.h @@ -52,54 +52,54 @@ extern const struct bt_mesh_model_op bt_mesh_time_cli_op[]; typedef bt_mesh_client_user_data_t bt_mesh_time_client_t; struct bt_mesh_time_status { - u8_t tai_seconds[5]; /* The current TAI time in seconds */ - u8_t sub_second; /* The sub-second time in units of 1/256 second */ - u8_t uncertainty; /* The estimated uncertainty in 10-millisecond steps */ - u16_t time_authority : 1; /* 0 = No Time Authority, 1 = Time Authority */ - u16_t tai_utc_delta : 15; /* Current difference between TAI and UTC in seconds */ - u8_t time_zone_offset; /* The local time zone offset in 15-minute increments */ + uint8_t tai_seconds[5]; /* The current TAI time in seconds */ + uint8_t sub_second; /* The sub-second time in units of 1/256 second */ + uint8_t uncertainty; /* The estimated uncertainty in 10-millisecond steps */ + uint16_t time_authority : 1; /* 0 = No Time Authority, 1 = Time Authority */ + uint16_t tai_utc_delta : 15; /* Current difference between TAI and UTC in seconds */ + uint8_t time_zone_offset; /* The local time zone offset in 15-minute increments */ }; struct bt_mesh_time_zone_status { - u8_t time_zone_offset_curr; /* Current local time zone offset */ - u8_t time_zone_offset_new; /* Upcoming local time zone offset */ - u8_t tai_zone_change[5]; /* TAI Seconds time of the upcoming Time Zone Offset change */ + uint8_t time_zone_offset_curr; /* Current local time zone offset */ + uint8_t time_zone_offset_new; /* Upcoming local time zone offset */ + uint8_t tai_zone_change[5]; /* TAI Seconds time of the upcoming Time Zone Offset change */ }; struct bt_mesh_tai_utc_delta_status { - u16_t tai_utc_delta_curr : 15; /* Current difference between TAI and UTC in seconds */ - u16_t padding_1 : 1; /* Always 0b0. Other values are Prohibited. */ - u16_t tai_utc_delta_new : 15; /* Upcoming difference between TAI and UTC in seconds */ - u16_t padding_2 : 1; /* Always 0b0. Other values are Prohibited. */ - u8_t tai_delta_change[5]; /* TAI Seconds time of the upcoming TAI-UTC Delta change */ + uint16_t tai_utc_delta_curr : 15; /* Current difference between TAI and UTC in seconds */ + uint16_t padding_1 : 1; /* Always 0b0. Other values are Prohibited. */ + uint16_t tai_utc_delta_new : 15; /* Upcoming difference between TAI and UTC in seconds */ + uint16_t padding_2 : 1; /* Always 0b0. Other values are Prohibited. */ + uint8_t tai_delta_change[5]; /* TAI Seconds time of the upcoming TAI-UTC Delta change */ }; struct bt_mesh_time_role_status { - u8_t time_role; /* The Time Role for the element */ + uint8_t time_role; /* The Time Role for the element */ }; struct bt_mesh_time_set { - u8_t tai_seconds[5]; /* The current TAI time in seconds */ - u8_t sub_second; /* The sub-second time in units of 1/256 second */ - u8_t uncertainty; /* The estimated uncertainty in 10-millisecond steps */ - u16_t time_authority : 1; /* 0 = No Time Authority, 1 = Time Authority */ - u16_t tai_utc_delta : 15; /* Current difference between TAI and UTC in seconds */ - u8_t time_zone_offset; /* The local time zone offset in 15-minute increments */ + uint8_t tai_seconds[5]; /* The current TAI time in seconds */ + uint8_t sub_second; /* The sub-second time in units of 1/256 second */ + uint8_t uncertainty; /* The estimated uncertainty in 10-millisecond steps */ + uint16_t time_authority : 1; /* 0 = No Time Authority, 1 = Time Authority */ + uint16_t tai_utc_delta : 15; /* Current difference between TAI and UTC in seconds */ + uint8_t time_zone_offset; /* The local time zone offset in 15-minute increments */ }; struct bt_mesh_time_zone_set { - u8_t time_zone_offset_new; /* Upcoming local time zone offset */ - u8_t tai_zone_change[5]; /* TAI Seconds time of the upcoming Time Zone Offset change */ + uint8_t time_zone_offset_new; /* Upcoming local time zone offset */ + uint8_t tai_zone_change[5]; /* TAI Seconds time of the upcoming Time Zone Offset change */ }; struct bt_mesh_tai_utc_delta_set { - u16_t tai_utc_delta_new : 15; /* Upcoming difference between TAI and UTC in seconds */ - u16_t padding : 1; /* Always 0b0. Other values are Prohibited. */ - u8_t tai_delta_change[5]; /* TAI Seconds time of the upcoming TAI-UTC Delta change */ + uint16_t tai_utc_delta_new : 15; /* Upcoming difference between TAI and UTC in seconds */ + uint16_t padding : 1; /* Always 0b0. Other values are Prohibited. */ + uint8_t tai_delta_change[5]; /* TAI Seconds time of the upcoming TAI-UTC Delta change */ }; struct bt_mesh_time_role_set { - u8_t time_role; /* The Time Role for the element */ + uint8_t time_role; /* The Time Role for the element */ }; /* Scene Client Model Context */ @@ -122,33 +122,33 @@ extern const struct bt_mesh_model_op bt_mesh_scene_cli_op[]; typedef bt_mesh_client_user_data_t bt_mesh_scene_client_t; struct bt_mesh_scene_status { - bool op_en; /* Indicate whether optional parameters included */ - u8_t status_code; /* Status code for the last operation */ - u16_t current_scene; /* Scene Number of a current scene */ - u16_t target_scene; /* Scene Number of a target scene (optional) */ - u8_t remain_time; /* Time to complete state transition (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint8_t status_code; /* Status code for the last operation */ + uint16_t current_scene; /* Scene Number of a current scene */ + uint16_t target_scene; /* Scene Number of a target scene (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ }; struct bt_mesh_scene_register_status { - u8_t status_code; /* Status code for the previous operation */ - u16_t current_scene; /* Scene Number of a current scene */ + uint8_t status_code; /* Status code for the previous operation */ + uint16_t current_scene; /* Scene Number of a current scene */ struct net_buf_simple *scenes; /* A list of scenes stored within an element */ }; struct bt_mesh_scene_store { - u16_t scene_number; /* The number of the scene to be stored */ + uint16_t scene_number; /* The number of the scene to be stored */ }; struct bt_mesh_scene_recall { - bool op_en; /* Indicate whether optional parameters included */ - u16_t scene_number; /* The number of the scene to be recalled */ - u8_t tid; /* Transaction Identifier */ - u8_t trans_time; /* Time to complete state transition (optional) */ - u8_t delay; /* Indicate message execution delay (C.1) */ + bool op_en; /* Indicate whether optional parameters included */ + uint16_t scene_number; /* The number of the scene to be recalled */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ }; struct bt_mesh_scene_delete { - u16_t scene_number; /* The number of the scene to be deleted */ + uint16_t scene_number; /* The number of the scene to be deleted */ }; /* Scheduler Client Model Context */ @@ -171,39 +171,39 @@ extern const struct bt_mesh_model_op bt_mesh_scheduler_cli_op[]; typedef bt_mesh_client_user_data_t bt_mesh_scheduler_client_t; struct bt_mesh_scheduler_status { - u16_t schedules; /* Bit field indicating defined Actions in the Schedule Register */ + uint16_t schedules; /* Bit field indicating defined Actions in the Schedule Register */ }; struct bt_mesh_scheduler_act_status { - u64_t index : 4; /* Enumerates (selects) a Schedule Register entry */ - u64_t year : 7; /* Scheduled year for the action */ - u64_t month : 12; /* Scheduled month for the action */ - u64_t day : 5; /* Scheduled day of the month for the action */ - u64_t hour : 5; /* Scheduled hour for the action */ - u64_t minute : 6; /* Scheduled minute for the action */ - u64_t second : 6; /* Scheduled second for the action */ - u64_t day_of_week : 7; /* Schedule days of the week for the action */ - u64_t action : 4; /* Action to be performed at the scheduled time */ - u64_t trans_time : 8; /* Transition time for this action */ - u16_t scene_number; /* Transition time for this action */ + uint64_t index : 4; /* Enumerates (selects) a Schedule Register entry */ + uint64_t year : 7; /* Scheduled year for the action */ + uint64_t month : 12; /* Scheduled month for the action */ + uint64_t day : 5; /* Scheduled day of the month for the action */ + uint64_t hour : 5; /* Scheduled hour for the action */ + uint64_t minute : 6; /* Scheduled minute for the action */ + uint64_t second : 6; /* Scheduled second for the action */ + uint64_t day_of_week : 7; /* Schedule days of the week for the action */ + uint64_t action : 4; /* Action to be performed at the scheduled time */ + uint64_t trans_time : 8; /* Transition time for this action */ + uint16_t scene_number; /* Transition time for this action */ }; struct bt_mesh_scheduler_act_get { - u8_t index; /* Index of the Schedule Register entry to get */ + uint8_t index; /* Index of the Schedule Register entry to get */ }; struct bt_mesh_scheduler_act_set { - u64_t index : 4; /* Index of the Schedule Register entry to set */ - u64_t year : 7; /* Scheduled year for the action */ - u64_t month : 12; /* Scheduled month for the action */ - u64_t day : 5; /* Scheduled day of the month for the action */ - u64_t hour : 5; /* Scheduled hour for the action */ - u64_t minute : 6; /* Scheduled minute for the action */ - u64_t second : 6; /* Scheduled second for the action */ - u64_t day_of_week : 7; /* Schedule days of the week for the action */ - u64_t action : 4; /* Action to be performed at the scheduled time */ - u64_t trans_time : 8; /* Transition time for this action */ - u16_t scene_number; /* Transition time for this action */ + uint64_t index : 4; /* Index of the Schedule Register entry to set */ + uint64_t year : 7; /* Scheduled year for the action */ + uint64_t month : 12; /* Scheduled month for the action */ + uint64_t day : 5; /* Scheduled day of the month for the action */ + uint64_t hour : 5; /* Scheduled hour for the action */ + uint64_t minute : 6; /* Scheduled minute for the action */ + uint64_t second : 6; /* Scheduled second for the action */ + uint64_t day_of_week : 7; /* Schedule days of the week for the action */ + uint64_t action : 4; /* Action to be performed at the scheduled time */ + uint64_t trans_time : 8; /* Transition time for this action */ + uint16_t scene_number; /* Transition time for this action */ }; /** diff --git a/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c b/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c index 147ba73f58..3c2a535686 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c @@ -152,7 +152,7 @@ static void timeout_handler(struct k_work *work) struct k_delayed_work *timer = NULL; bt_mesh_client_node_t *node = NULL; struct bt_mesh_msg_ctx ctx = {0}; - u32_t opcode = 0U; + uint32_t opcode = 0U; BT_WARN("Receive light status message timeout"); @@ -181,8 +181,8 @@ static void light_status(struct bt_mesh_model *model, struct net_buf_simple *buf) { bt_mesh_client_node_t *node = NULL; - u8_t *val = NULL; - u8_t evt = 0xFF; + uint8_t *val = NULL; + uint8_t evt = 0xFF; size_t len = 0U; BT_DBG("len %d, bytes %s", buf->len, bt_hex(buf->data, buf->len)); @@ -205,7 +205,7 @@ static void light_status(struct bt_mesh_model *model, status->target_lightness = net_buf_simple_pull_le16(buf); status->remain_time = net_buf_simple_pull_u8(buf); } - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_lightness_status); break; } @@ -226,7 +226,7 @@ static void light_status(struct bt_mesh_model *model, status->target_lightness = net_buf_simple_pull_le16(buf); status->remain_time = net_buf_simple_pull_u8(buf); } - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_lightness_linear_status); break; } @@ -242,7 +242,7 @@ static void light_status(struct bt_mesh_model *model, return; } status->lightness = net_buf_simple_pull_le16(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_lightness_last_status); break; } @@ -258,7 +258,7 @@ static void light_status(struct bt_mesh_model *model, return; } status->lightness = net_buf_simple_pull_le16(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_lightness_default_status); break; } @@ -276,7 +276,7 @@ static void light_status(struct bt_mesh_model *model, status->status_code = net_buf_simple_pull_u8(buf); status->range_min = net_buf_simple_pull_le16(buf); status->range_max = net_buf_simple_pull_le16(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_lightness_range_status); break; } @@ -299,7 +299,7 @@ static void light_status(struct bt_mesh_model *model, status->target_ctl_temperature = net_buf_simple_pull_le16(buf); status->remain_time = net_buf_simple_pull_u8(buf); } - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_ctl_status); break; } @@ -322,7 +322,7 @@ static void light_status(struct bt_mesh_model *model, status->target_ctl_delta_uv = net_buf_simple_pull_le16(buf); status->remain_time = net_buf_simple_pull_u8(buf); } - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_ctl_temperature_status); break; } @@ -340,7 +340,7 @@ static void light_status(struct bt_mesh_model *model, status->status_code = net_buf_simple_pull_u8(buf); status->range_min = net_buf_simple_pull_le16(buf); status->range_max = net_buf_simple_pull_le16(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_ctl_temperature_range_status); break; } @@ -358,7 +358,7 @@ static void light_status(struct bt_mesh_model *model, status->lightness = net_buf_simple_pull_le16(buf); status->temperature = net_buf_simple_pull_le16(buf); status->delta_uv = net_buf_simple_pull_le16(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_ctl_default_status); break; } @@ -380,7 +380,7 @@ static void light_status(struct bt_mesh_model *model, status->op_en = true; status->remain_time = net_buf_simple_pull_u8(buf); } - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_hsl_status); break; } @@ -402,7 +402,7 @@ static void light_status(struct bt_mesh_model *model, status->op_en = true; status->remain_time = net_buf_simple_pull_u8(buf); } - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_hsl_target_status); break; } @@ -423,7 +423,7 @@ static void light_status(struct bt_mesh_model *model, status->target_hue = net_buf_simple_pull_le16(buf); status->remain_time = net_buf_simple_pull_u8(buf); } - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_hsl_hue_status); break; } @@ -444,7 +444,7 @@ static void light_status(struct bt_mesh_model *model, status->target_saturation = net_buf_simple_pull_le16(buf); status->remain_time = net_buf_simple_pull_u8(buf); } - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_hsl_saturation_status); break; } @@ -462,7 +462,7 @@ static void light_status(struct bt_mesh_model *model, status->lightness = net_buf_simple_pull_le16(buf); status->hue = net_buf_simple_pull_le16(buf); status->saturation = net_buf_simple_pull_le16(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_hsl_default_status); break; } @@ -482,7 +482,7 @@ static void light_status(struct bt_mesh_model *model, status->hue_range_max = net_buf_simple_pull_le16(buf); status->saturation_range_min = net_buf_simple_pull_le16(buf); status->saturation_range_max = net_buf_simple_pull_le16(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_hsl_range_status); break; } @@ -504,7 +504,7 @@ static void light_status(struct bt_mesh_model *model, status->op_en = true; status->remain_time = net_buf_simple_pull_u8(buf); } - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_xyl_status); break; } @@ -526,7 +526,7 @@ static void light_status(struct bt_mesh_model *model, status->op_en = true; status->remain_time = net_buf_simple_pull_u8(buf); } - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_xyl_target_status); break; } @@ -544,7 +544,7 @@ static void light_status(struct bt_mesh_model *model, status->lightness = net_buf_simple_pull_le16(buf); status->xyl_x = net_buf_simple_pull_le16(buf); status->xyl_y = net_buf_simple_pull_le16(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_xyl_default_status); break; } @@ -564,7 +564,7 @@ static void light_status(struct bt_mesh_model *model, status->xyl_x_range_max = net_buf_simple_pull_le16(buf); status->xyl_y_range_min = net_buf_simple_pull_le16(buf); status->xyl_y_range_max = net_buf_simple_pull_le16(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_xyl_range_status); break; } @@ -580,7 +580,7 @@ static void light_status(struct bt_mesh_model *model, return; } status->mode = net_buf_simple_pull_u8(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_lc_mode_status); break; } @@ -596,7 +596,7 @@ static void light_status(struct bt_mesh_model *model, return; } status->mode = net_buf_simple_pull_u8(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_lc_om_status); break; } @@ -617,7 +617,7 @@ static void light_status(struct bt_mesh_model *model, status->target_light_onoff = net_buf_simple_pull_u8(buf); status->remain_time = net_buf_simple_pull_u8(buf); } - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_lc_light_onoff_status); break; } @@ -636,7 +636,7 @@ static void light_status(struct bt_mesh_model *model, return; } net_buf_simple_add_mem(status->light_lc_property_value, buf->data, buf->len); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_light_lc_property_status); break; } @@ -707,7 +707,7 @@ static void light_status(struct bt_mesh_model *model, } if (!k_delayed_work_free(&node->timer)) { - u32_t opcode = node->opcode; + uint32_t opcode = node->opcode; bt_mesh_client_free_node(node); bt_mesh_lighting_client_cb_evt_to_btc(opcode, evt, model, ctx, val, len); } @@ -798,7 +798,7 @@ static int light_get_state(bt_mesh_client_common_param_t *common, void *value) } static int light_set_state(bt_mesh_client_common_param_t *common, - void *value, u16_t value_len, bool need_ack) + void *value, uint16_t value_len, bool need_ack) { struct net_buf_simple *msg = NULL; int err = 0; @@ -1088,7 +1088,7 @@ int bt_mesh_light_client_get_state(bt_mesh_client_common_param_t *common, void * int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *set) { bt_mesh_light_client_t *client = NULL; - u16_t length = 0U; + uint16_t length = 0U; bool need_ack = false; if (!common || !common->model || !set) { diff --git a/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c b/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c index f97c5f606d..2a1f7fc9ab 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c @@ -81,7 +81,7 @@ static void timeout_handler(struct k_work *work) struct k_delayed_work *timer = NULL; bt_mesh_client_node_t *node = NULL; struct bt_mesh_msg_ctx ctx = {0}; - u32_t opcode = 0U; + uint32_t opcode = 0U; BT_WARN("Receive sensor status message timeout"); @@ -110,8 +110,8 @@ static void sensor_status(struct bt_mesh_model *model, struct net_buf_simple *buf) { bt_mesh_client_node_t *node = NULL; - u8_t *val = NULL; - u8_t evt = 0xFF; + uint8_t *val = NULL; + uint8_t evt = 0xFF; size_t len = 0U; BT_DBG("len %d, bytes %s", buf->len, bt_hex(buf->data, buf->len)); @@ -131,7 +131,7 @@ static void sensor_status(struct bt_mesh_model *model, return; } net_buf_simple_add_mem(status->descriptor, buf->data, buf->len); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_sensor_descriptor_status); break; } @@ -150,7 +150,7 @@ static void sensor_status(struct bt_mesh_model *model, return; } net_buf_simple_add_mem(status->sensor_cadence_value, buf->data, buf->len); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_sensor_cadence_status); break; } @@ -169,7 +169,7 @@ static void sensor_status(struct bt_mesh_model *model, return; } net_buf_simple_add_mem(status->sensor_setting_property_ids, buf->data, buf->len); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_sensor_settings_status); break; } @@ -193,7 +193,7 @@ static void sensor_status(struct bt_mesh_model *model, } net_buf_simple_add_mem(status->sensor_setting_raw, buf->data, buf->len); } - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_sensor_setting_status); break; } @@ -211,7 +211,7 @@ static void sensor_status(struct bt_mesh_model *model, return; } net_buf_simple_add_mem(status->marshalled_sensor_data, buf->data, buf->len); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_sensor_status); break; } @@ -230,7 +230,7 @@ static void sensor_status(struct bt_mesh_model *model, return; } net_buf_simple_add_mem(status->sensor_column_value, buf->data, buf->len); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_sensor_column_status); break; } @@ -249,7 +249,7 @@ static void sensor_status(struct bt_mesh_model *model, return; } net_buf_simple_add_mem(status->sensor_series_value, buf->data, buf->len); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_sensor_series_status); break; } @@ -286,7 +286,7 @@ static void sensor_status(struct bt_mesh_model *model, } if (!k_delayed_work_free(&node->timer)) { - u32_t opcode = node->opcode; + uint32_t opcode = node->opcode; bt_mesh_client_free_node(node); bt_mesh_sensor_client_cb_evt_to_btc(opcode, evt, model, ctx, val, len); } @@ -358,7 +358,7 @@ const struct bt_mesh_model_op bt_mesh_sensor_cli_op[] = { }; static int sensor_act_state(bt_mesh_client_common_param_t *common, - void *value, u16_t value_len, bool need_ack) + void *value, uint16_t value_len, bool need_ack) { struct net_buf_simple *msg = NULL; int err = 0; @@ -462,7 +462,7 @@ end: int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void *get) { bt_mesh_sensor_client_t *client = NULL; - u16_t length = 0U; + uint16_t length = 0U; if (!common || !common->model || !get) { BT_ERR("%s, Invalid parameter", __func__); @@ -527,7 +527,7 @@ int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void int bt_mesh_sensor_client_set_state(bt_mesh_client_common_param_t *common, void *set) { bt_mesh_sensor_client_t *client = NULL; - u16_t length = 0U; + uint16_t length = 0U; bool need_ack = false; if (!common || !common->model || !set) { diff --git a/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c b/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c index c1a13665c2..1a0be4fd20 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c @@ -97,7 +97,7 @@ static void timeout_handler(struct k_work *work) struct k_delayed_work *timer = NULL; bt_mesh_client_node_t *node = NULL; struct bt_mesh_msg_ctx ctx = {0}; - u32_t opcode = 0U; + uint32_t opcode = 0U; BT_WARN("Receive time scene status message timeout"); @@ -126,8 +126,8 @@ static void time_scene_status(struct bt_mesh_model *model, struct net_buf_simple *buf) { bt_mesh_client_node_t *node = NULL; - u8_t *val = NULL; - u8_t evt = 0xFF; + uint8_t *val = NULL; + uint8_t evt = 0xFF; size_t len = 0U; BT_DBG("len %d, bytes %s", buf->len, bt_hex(buf->data, buf->len)); @@ -148,11 +148,11 @@ static void time_scene_status(struct bt_mesh_model *model, net_buf_simple_pull(buf, 5); status->sub_second = net_buf_simple_pull_u8(buf); status->uncertainty = net_buf_simple_pull_u8(buf); - u16_t temp = net_buf_simple_pull_le16(buf); + uint16_t temp = net_buf_simple_pull_le16(buf); status->time_authority = temp & BIT(0); status->tai_utc_delta = temp >> 15; status->time_zone_offset = net_buf_simple_pull_u8(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_time_status); break; } @@ -171,7 +171,7 @@ static void time_scene_status(struct bt_mesh_model *model, status->time_zone_offset_new = net_buf_simple_pull_u8(buf); memcpy(status->tai_zone_change, buf->data, 5); net_buf_simple_pull(buf, 5); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_time_zone_status); break; } @@ -186,7 +186,7 @@ static void time_scene_status(struct bt_mesh_model *model, BT_ERR("%s, Out of memory", __func__); return; } - u16_t temp = net_buf_simple_pull_le16(buf); + uint16_t temp = net_buf_simple_pull_le16(buf); status->tai_utc_delta_curr = temp & BIT_MASK(15); status->padding_1 = (temp >> 15) & BIT(0); temp = net_buf_simple_pull_le16(buf); @@ -194,7 +194,7 @@ static void time_scene_status(struct bt_mesh_model *model, status->padding_2 = (temp >> 15) & BIT(0); memcpy(status->tai_delta_change, buf->data, 5); net_buf_simple_pull(buf, 5); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_tai_utc_delta_status); break; } @@ -210,7 +210,7 @@ static void time_scene_status(struct bt_mesh_model *model, return; } status->time_role = net_buf_simple_pull_u8(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_time_role_status); break; } @@ -232,7 +232,7 @@ static void time_scene_status(struct bt_mesh_model *model, status->target_scene = net_buf_simple_pull_le16(buf); status->remain_time = net_buf_simple_pull_u8(buf); } - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_scene_status); break; } @@ -252,7 +252,7 @@ static void time_scene_status(struct bt_mesh_model *model, return; } net_buf_simple_add_mem(status->scenes, buf->data, buf->len); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_scene_register_status); break; } @@ -268,7 +268,7 @@ static void time_scene_status(struct bt_mesh_model *model, return; } status->schedules = net_buf_simple_pull_le16(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_scheduler_status); break; } @@ -286,7 +286,7 @@ static void time_scene_status(struct bt_mesh_model *model, memcpy(status, buf->data, offsetof(struct bt_mesh_scheduler_act_status, scene_number)); net_buf_simple_pull(buf, offsetof(struct bt_mesh_scheduler_act_status, scene_number)); status->scene_number = net_buf_simple_pull_le16(buf); - val = (u8_t *)status; + val = (uint8_t *)status; len = sizeof(struct bt_mesh_scheduler_act_status); break; } @@ -330,7 +330,7 @@ static void time_scene_status(struct bt_mesh_model *model, } if (!k_delayed_work_free(&node->timer)) { - u32_t opcode = node->opcode; + uint32_t opcode = node->opcode; bt_mesh_client_free_node(node); bt_mesh_time_scene_client_cb_evt_to_btc(opcode, evt, model, ctx, val, len); } @@ -398,7 +398,7 @@ static int time_scene_get_state(bt_mesh_client_common_param_t *common, void *val } static int time_scene_set_state(bt_mesh_client_common_param_t *common, - void *value, u16_t value_len, bool need_ack) + void *value, uint16_t value_len, bool need_ack) { struct net_buf_simple *msg = NULL; int err = 0; @@ -530,7 +530,7 @@ int bt_mesh_time_scene_client_get_state(bt_mesh_client_common_param_t *common, v int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, void *set) { bt_mesh_time_scene_client_t *client = NULL; - u16_t length = 0U; + uint16_t length = 0U; bool need_ack = false; if (!common || !common->model || !set) { diff --git a/components/bt/esp_ble_mesh/mesh_models/common/device_property.c b/components/bt/esp_ble_mesh/mesh_models/common/device_property.c index 9031c00df9..d487bd6d0d 100644 --- a/components/bt/esp_ble_mesh/mesh_models/common/device_property.c +++ b/components/bt/esp_ble_mesh/mesh_models/common/device_property.c @@ -17,8 +17,8 @@ #include "device_property.h" static struct bt_mesh_dev_prop { - u16_t prop_id; - u8_t len; + uint16_t prop_id; + uint8_t len; } device_properties[] = { { BLE_MESH_INVALID_DEVICE_PROPERTY_ID, 0xFF }, /* Prohibited */ { BLE_MESH_AVERAGE_AMBIENT_TEMPERATURE_IN_A_PERIOD_OF_DAY, 0x03 }, @@ -206,7 +206,7 @@ static struct bt_mesh_dev_prop { { BLE_MESH_OUTPUT_CURRENT_PERCENT, 0x01 }, }; -u8_t bt_mesh_get_dev_prop_len(u16_t prop_id) +uint8_t bt_mesh_get_dev_prop_len(uint16_t prop_id) { if (prop_id > BLE_MESH_OUTPUT_CURRENT_PERCENT) { BT_ERR("Unknown Device Property ID 0x%04x", prop_id); diff --git a/components/bt/esp_ble_mesh/mesh_models/common/include/device_property.h b/components/bt/esp_ble_mesh/mesh_models/common/include/device_property.h index 9236032f5e..16dc6428a7 100644 --- a/components/bt/esp_ble_mesh/mesh_models/common/include/device_property.h +++ b/components/bt/esp_ble_mesh/mesh_models/common/include/device_property.h @@ -824,9 +824,9 @@ extern "C" { */ /* Unit is in degrees Celsius with a resolution of 0.01 degrees Celsius. */ -typedef s16_t bt_mesh_temperature_t; +typedef int16_t bt_mesh_temperature_t; -typedef u16_t bt_mesh_gap_appearance_t; +typedef uint16_t bt_mesh_gap_appearance_t; /* Mesh Characteristics Type Definitions */ @@ -835,7 +835,7 @@ typedef u16_t bt_mesh_gap_appearance_t; * Minimum value: 0, maximum value: 655.34; * A value of 0xFFFF represents 'value is not known'. */ -typedef u16_t bt_mesh_electric_current_t; +typedef uint16_t bt_mesh_electric_current_t; /* The Time Exponential 8 characteristic is used to represent a measure of period of * time in seconds. @@ -845,7 +845,7 @@ typedef u16_t bt_mesh_electric_current_t; * A raw value of 0x00 represents 0 seconds, and a raw value of 0xFF represents * the total life of the device. */ -typedef u8_t bt_mesh_time_exponential_8_t; +typedef uint8_t bt_mesh_time_exponential_8_t; /* The Voltage characteristic is used to represent a measure of positive electric * potential difference in units of volts. @@ -855,7 +855,7 @@ typedef u8_t bt_mesh_time_exponential_8_t; * value represents the minimum value or lower, the maximum representable value * represents the maximum value or higher. */ -typedef u16_t bt_mesh_voltage_t; +typedef uint16_t bt_mesh_voltage_t; /* This characteristic aggregates the Electric Current characteristic and instance of * the Time Exponential 8 characteristic. @@ -879,7 +879,7 @@ typedef struct __packed average_voltage { * 1 | True * 2 to 255 | Prohibited */ -typedef u8_t bt_mesh_boolean_t; +typedef uint8_t bt_mesh_boolean_t; /* The Chromatic Distance From Planckian characteristic represents a distance of a * chromaticity coordinate from the Planckian locus in the (u',2/3 v') diagram as @@ -892,14 +892,14 @@ typedef u8_t bt_mesh_boolean_t; * A value of 0xFFFF represents 'value is not known'; * A value of 0xFFFE represents 'value is not valid'. */ -typedef s16_t bt_mesh_chromatic_distance_from_planckian_t; +typedef int16_t bt_mesh_chromatic_distance_from_planckian_t; /* This characteristic represents a chromaticity coordinate in a color diagram such as * the CIE1931 diagram. It can represent an x or y coordinate. * Note: Unit is unitless with a resolution of 1/65535; * Minimum value: 0, maximum value: 1.0. */ -typedef u16_t bt_mesh_chromaticity_coordinate_t; +typedef uint16_t bt_mesh_chromaticity_coordinate_t; /* This characteristic represents a chromaticity coordinate as a tuple with an x and * y coordinate. @@ -915,7 +915,7 @@ typedef struct __packed chromaticity_coordinates { * Minimum value: 800, maximum value: 65534; * A value of 0xFFFF represents 'value is not known'. */ -typedef u16_t bt_mesh_correlated_color_temperature_t; +typedef uint16_t bt_mesh_correlated_color_temperature_t; /* The Chromaticity In CCT And Duv Values characteristic is a composite characteristic * consisting of the Correlated Color Temperature characteristic and the Chromatic @@ -932,14 +932,14 @@ typedef struct __packed chromaticity_in_cct_and_duv_values { * Note: Unit is unitless with a resolution of 0.0001; * Minimum value: 0, maximum value: 0.0255. */ -typedef u8_t bt_mesh_chromaticity_tolerance_t; +typedef uint8_t bt_mesh_chromaticity_tolerance_t; /* The CIE 13.3-1995 Color Rendering Index characteristic is a color rendition index value * for a color patch as calculated in accordance with the CIE 13.3-1995 standard. * Note: Unit is unitless with a resolution of 1; * Minimum value: -128, maximum value: 100. */ -typedef s8_t bt_mesh_cie_13_3_1995_color_rendering_index_t; +typedef int8_t bt_mesh_cie_13_3_1995_color_rendering_index_t; /* The Coefficient characteristic is used to represent a general coefficient value. */ typedef float bt_mesh_coefficient_t; @@ -949,14 +949,14 @@ typedef float bt_mesh_coefficient_t; * Minimum value: 0, maximum value 65534; * A value of 0xFFFF represents 'value is not known'. */ -typedef u16_t bt_mesh_count_16_t; +typedef uint16_t bt_mesh_count_16_t; /* The Count 24 characteristic is used to represent a general count value. * Note: Unit is unitless with a resolution of 1; * Minimum value: 0, maximum value 16777214; * A value of 0xFFFFFF represents 'value is not known'. */ -typedef u8_t bt_mesh_count_24_t[3]; +typedef uint8_t bt_mesh_count_24_t[3]; /* This characteristic represents a country or dependent areas in accordance with * the ISO 3166-1 Numeric standard. @@ -964,7 +964,7 @@ typedef u8_t bt_mesh_count_24_t[3]; * Minimum value: 0, maximum value: 4095; * A value of 0xFFFF represents 'value is not known'. */ -typedef u16_t bt_mesh_country_code_t; +typedef uint16_t bt_mesh_country_code_t; /* Date as days elapsed since the Epoch (Jan 1, 1970) in the Coordinated Universal * Time (UTC) time zone. @@ -972,7 +972,7 @@ typedef u16_t bt_mesh_country_code_t; * Minimum value: 1, maximum value: 16777214; * A value of 0x000000 represents 'value is not known'. */ -typedef u8_t bt_mesh_date_utc_t[3]; +typedef uint8_t bt_mesh_date_utc_t[3]; /* This characteristic aggregates two instances of the Electric Current characteristic * to represent a range of Electric Current values. @@ -1008,7 +1008,7 @@ typedef struct __packed electric_current_statistics { * Minimum value: 0, maximum value: 16777214; * A value of 0xFFFFFF represents ‘value is not known’. */ -typedef u8_t bt_mesh_energy_t[3]; +typedef uint8_t bt_mesh_energy_t[3]; /* The Time Decihour 8 characteristic is used to represent a period of time in * tenths of an hour. @@ -1016,7 +1016,7 @@ typedef u8_t bt_mesh_energy_t[3]; * Minimum value: 0.0, maximum value: 24.0; * A value of 0xFF represents 'value is not known'. All other values are Prohibited. */ -typedef u8_t bt_mesh_time_decihour_8_t; +typedef uint8_t bt_mesh_time_decihour_8_t; /* This characteristic aggregates the Energy characteristic, and two instances of * the Time Decihour 8 characteristic, to represent energy use in a period of day. @@ -1033,7 +1033,7 @@ typedef struct __packed energy_in_a_period_of_day { * Minimum value: 0, maximum value: 65534; * A value of 0xFFFF represents 'value is not known'. */ -typedef u16_t bt_mesh_time_second_16_t; +typedef uint16_t bt_mesh_time_second_16_t; /* This characteristic aggregates the Count 16 characteristic, two instances of the * Time Decihour 8 characteristic and an instance of the Sensing Duration characteristic, @@ -1063,13 +1063,13 @@ typedef char bt_mesh_fixed_string_8_t[8]; * Note: Unit is unitless with a resolution of 1; * Minimum value: 0, maximum value: 65535. */ -typedef u16_t bt_mesh_generic_level_t; +typedef uint16_t bt_mesh_generic_level_t; /* The Global Trade Item Number characteristic represents an identifier as * issued by GS1 General Specifications, which may consist up to 14 digits, * and is here represented as a 48-bit unsigned integer. */ -typedef u8_t bt_mesh_global_trade_item_number_t[6]; +typedef uint8_t bt_mesh_global_trade_item_number_t[6]; /* The Illuminance characteristic is used to represent a measure of illuminance * in units of lux. @@ -1077,7 +1077,7 @@ typedef u8_t bt_mesh_global_trade_item_number_t[6]; * Minimum value: 0, maximum value: 167772.14; * A value of 0xFFFFFF represents 'value is not known'. */ -typedef u8_t bt_mesh_illuminance_t[3]; +typedef uint8_t bt_mesh_illuminance_t[3]; /* The Luminous Efficacy characteristic is used to represent a measure of luminous * efficacy in units of lumen per watt. @@ -1085,7 +1085,7 @@ typedef u8_t bt_mesh_illuminance_t[3]; * Minimum value: 0, maximum value: 1800; * A value of 0xFFFF represents 'value is not known'. All other values are Prohibited. */ -typedef u16_t bt_mesh_luminous_efficacy_t; +typedef uint16_t bt_mesh_luminous_efficacy_t; /* The Luminous Energy characteristic is used to represent a measure of luminous * energy in units of lumen hour. @@ -1093,7 +1093,7 @@ typedef u16_t bt_mesh_luminous_efficacy_t; * Minimum value: 0, maximum value: 16777214000; * A value of 0xFFFFFF represents 'value is not known'. */ -typedef u8_t bt_mesh_luminous_energy_t[3]; +typedef uint8_t bt_mesh_luminous_energy_t[3]; /* The Luminous Exposure characteristic is used to represent a measure of luminous * exposure in units of lux-hour. @@ -1101,7 +1101,7 @@ typedef u8_t bt_mesh_luminous_energy_t[3]; * Minimum value: 0, maximum value: 16777214000; * A value of 0xFFFFFF represents 'value is not known'. */ -typedef u8_t bt_mesh_luminous_exposure_t[3]; +typedef uint8_t bt_mesh_luminous_exposure_t[3]; /* The Luminous Flux characteristic is used to represent a measure of luminous flux * in units of lumen. @@ -1109,7 +1109,7 @@ typedef u8_t bt_mesh_luminous_exposure_t[3]; * Minimum value: 0, maximum value: 65534; * A value of 0xFFFF represents 'value is not known'. */ -typedef u16_t bt_mesh_luminous_flux_t; +typedef uint16_t bt_mesh_luminous_flux_t; /* This characteristic aggregates two instances of the Luminous Flux characteristic * to represent a luminous flux range. @@ -1125,14 +1125,14 @@ typedef struct __packed luminous_flux_range { * Minimum value: 0, maximum value: 65534; * A value of 0xFFFF represents 'value is not known'. */ -typedef u16_t bt_mesh_luminous_intensity_t; +typedef uint16_t bt_mesh_luminous_intensity_t; /* The Mass Flow characteristic is used to represent a flow of mass. * Note: Unit is gram/second with a resolution of 1; * Minimum value: 0, maximum value: 65534; * A value of 0xFFFF represents 'value is not known'. */ -typedef u16_t bt_mesh_mass_flow_t; +typedef uint16_t bt_mesh_mass_flow_t; /* The Mesh Provisioning Data In characteristic can be written to send a Proxy PDU * message containing Provisioning PDU to the Provisioning Server. @@ -1167,21 +1167,21 @@ struct mesh_proxy_data_out { * Note: Unit is unitless with a resolution of 1; * Minimum value: 0, maximum value: 65535. */ -typedef u16_t bt_mesh_perceived_lightness_t; +typedef uint16_t bt_mesh_perceived_lightness_t; /* The Percentage 8 characteristic is used to represent a measure of percentage. * Note: Unit is a percentage with a resolution of 0.5; * Minimum value: 0, maximum value: 100; * A value of 0xFF represents 'value is not known'. All other values are Prohibited. */ -typedef u8_t bt_mesh_percentage_8_t; +typedef uint8_t bt_mesh_percentage_8_t; /* The Power characteristic is used to represent a measure of power in units of watts. * Note: Unit is watt with a resolution of 0.1; * Minimum value: 0, maximum value: 1677721.4; * A value of 0xFFFFFF represents 'value is not known'. */ -typedef u8_t bt_mesh_power_t[3]; +typedef uint8_t bt_mesh_power_t[3]; /* This characteristic aggregates three instances of the Power characteristic to * represent a specification of Power values. @@ -1253,7 +1253,7 @@ typedef struct __packed relative_value_in_an_illuminance_range { * Minimum value: -64.0, maximum value: 63.5; * A value of 0xFF represents 'value is not known'. */ -typedef s8_t bt_mesh_temperature_8_t; +typedef int8_t bt_mesh_temperature_8_t; /* This characteristic aggregates the Temperature 8 characteristic, and two instances * of the Time Decihour 8 characteristic, to represent a temperature value in a period @@ -1300,7 +1300,7 @@ typedef struct __packed temperature_statistics { * Minimum value: 0, maximum value: 16777214; * A value of 0xFFFFFF represents 'value is not known'. */ -typedef u8_t bt_mesh_time_hour_24_t[3]; +typedef uint8_t bt_mesh_time_hour_24_t[3]; /* The Time Millisecond 24 characteristic is used to represent a period of time with * a resolution of 1 millisecond. @@ -1308,7 +1308,7 @@ typedef u8_t bt_mesh_time_hour_24_t[3]; * Minimum value: 0, maximum value: 16777.214; * A value of 0xFFFFFF represents 'value is not known'. */ -typedef u8_t bt_mesh_time_millisecond_24_t[3]; +typedef uint8_t bt_mesh_time_millisecond_24_t[3]; /* The Time Second 8 characteristic is used to represent a period of time with a unit * of 1 second. @@ -1316,7 +1316,7 @@ typedef u8_t bt_mesh_time_millisecond_24_t[3]; * Minimum value: 0, maximum value: 254; * A value of 0xFF represents 'value is not known'. */ -typedef u8_t bt_mesh_time_second_8_t; +typedef uint8_t bt_mesh_time_second_8_t; /* This characteristic aggregates three instances of the Voltage characteristic to * represent a specification of voltage values. @@ -1345,11 +1345,11 @@ typedef struct __packed voltage_statistics { * Minimum value: 0, maximum value: 65534; * A value of 0xFFFF represents 'value is not known'. */ -typedef u16_t bt_mesh_volume_flow_t; +typedef uint16_t bt_mesh_volume_flow_t; /* Mesh Device Property related function */ -u8_t bt_mesh_get_dev_prop_len(u16_t prop_id); +uint8_t bt_mesh_get_dev_prop_len(uint16_t prop_id); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_models/server/generic_server.c b/components/bt/esp_ble_mesh/mesh_models/server/generic_server.c index 69472dbba7..0c949d8810 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/generic_server.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/generic_server.c @@ -54,7 +54,7 @@ static void send_gen_onoff_status(struct bt_mesh_model *model, { struct bt_mesh_gen_onoff_srv *srv = model->user_data; struct net_buf_simple *msg = NULL; - u8_t length = 2 + 3; + uint8_t length = 2 + 3; if (ctx == NULL && publish == false) { BT_ERR("%s, Invalid parameter", __func__); @@ -129,9 +129,9 @@ static void gen_onoff_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_gen_onoff_srv *srv = model->user_data; - u8_t tid = 0U, onoff = 0U, trans_time = 0U, delay = 0U; + uint8_t tid = 0U, onoff = 0U, trans_time = 0U, delay = 0U; bool optional = false; - s64_t now = 0; + int64_t now = 0; if (srv == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -159,7 +159,7 @@ static void gen_onoff_set(struct bt_mesh_model *model, .onoff_set.delay = delay, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -186,7 +186,7 @@ static void gen_onoff_set(struct bt_mesh_model *model, .gen_onoff_set.onoff = srv->state.onoff, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_GEN_ONOFF_SET) { send_gen_onoff_status(model, ctx, false); @@ -226,7 +226,7 @@ static void send_gen_level_status(struct bt_mesh_model *model, { struct bt_mesh_gen_level_srv *srv = model->user_data; struct net_buf_simple *msg = NULL; - u8_t length = 2 + 5; + uint8_t length = 2 + 5; if (ctx == NULL && publish == false) { BT_ERR("%s, Invalid parameter", __func__); @@ -310,17 +310,17 @@ static void gen_level_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_gen_level_srv *srv = model->user_data; - u8_t tid = 0U, trans_time = 0U, delay = 0U; + uint8_t tid = 0U, trans_time = 0U, delay = 0U; bool optional = false; - s16_t level = 0; - s64_t now = 0; + int16_t level = 0; + int64_t now = 0; if (srv == NULL) { BT_ERR("%s, Invalid model user data", __func__); return; } - 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); if (bt_mesh_server_get_optional(model, ctx, buf, &trans_time, &delay, &optional)) { @@ -337,7 +337,7 @@ static void gen_level_set(struct bt_mesh_model *model, .level_set.delay = delay, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -368,7 +368,7 @@ static void gen_level_set(struct bt_mesh_model *model, .gen_level_set.level = srv->state.level, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_GEN_LEVEL_SET) { send_gen_level_status(model, ctx, false); @@ -406,17 +406,17 @@ static void gen_delta_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_gen_level_srv *srv = model->user_data; - u8_t tid = 0U, trans_time = 0U, delay = 0U; - s32_t tmp32 = 0, delta = 0; + uint8_t tid = 0U, trans_time = 0U, delay = 0U; + int32_t tmp32 = 0, delta = 0; bool optional = false; - s64_t now = 0; + int64_t now = 0; if (srv == NULL) { BT_ERR("%s, Invalid model user data", __func__); return; } - 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); if (bt_mesh_server_get_optional(model, ctx, buf, &trans_time, &delay, &optional)) { @@ -433,7 +433,7 @@ static void gen_delta_set(struct bt_mesh_model *model, .delta_set.delay = delay, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -489,7 +489,7 @@ static void gen_delta_set(struct bt_mesh_model *model, .gen_delta_set.level = srv->state.level, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_GEN_DELTA_SET) { send_gen_level_status(model, ctx, false); @@ -527,18 +527,18 @@ static void gen_move_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_gen_level_srv *srv = model->user_data; - u8_t tid = 0U, trans_time = 0U, delay = 0U; + uint8_t tid = 0U, trans_time = 0U, delay = 0U; bool optional = false; - s16_t delta = 0; - s32_t tmp32 = 0; - s64_t now = 0; + int16_t delta = 0; + int32_t tmp32 = 0; + int64_t now = 0; if (srv == NULL) { BT_ERR("%s, Invalid model user data", __func__); return; } - 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); if (bt_mesh_server_get_optional(model, ctx, buf, &trans_time, &delay, &optional)) { @@ -555,7 +555,7 @@ static void gen_move_set(struct bt_mesh_model *model, .move_set.delay = delay, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -594,7 +594,7 @@ static void gen_move_set(struct bt_mesh_model *model, .gen_move_set.level = srv->state.level, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_GEN_MOVE_SET) { send_gen_level_status(model, ctx, false); @@ -640,7 +640,7 @@ static void gen_move_set(struct bt_mesh_model *model, .gen_move_set.level = srv->state.level, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); return; } @@ -655,7 +655,7 @@ static void send_gen_def_trans_time_status(struct bt_mesh_model *model, { struct bt_mesh_gen_def_trans_time_srv *srv = model->user_data; struct net_buf_simple *msg = NULL; - u8_t length = 2 + 1; + uint8_t length = 2 + 1; if (ctx == NULL && publish == false) { BT_ERR("%s, Invalid parameter", __func__); @@ -714,7 +714,7 @@ static void gen_def_trans_time_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_gen_def_trans_time_srv *srv = model->user_data; - u8_t trans_time = 0U; + uint8_t trans_time = 0U; if (srv == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -733,7 +733,7 @@ static void gen_def_trans_time_set(struct bt_mesh_model *model, .def_trans_time_set.trans_time = trans_time, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -745,7 +745,7 @@ static void gen_def_trans_time_set(struct bt_mesh_model *model, .gen_def_trans_time_set.trans_time = trans_time, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET) { send_gen_def_trans_time_status(model, ctx, false); @@ -761,7 +761,7 @@ static void send_gen_onpowerup_status(struct bt_mesh_model *model, bool publish) { struct net_buf_simple *msg = NULL; - u8_t length = 2 + 1; + uint8_t length = 2 + 1; if (ctx == NULL && publish == false) { BT_ERR("%s, Invalid parameter", __func__); @@ -871,7 +871,7 @@ static void gen_onpowerup_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_gen_power_onoff_setup_srv *srv = model->user_data; - u8_t onpowerup = 0U; + uint8_t onpowerup = 0U; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -890,7 +890,7 @@ static void gen_onpowerup_set(struct bt_mesh_model *model, .onpowerup_set.onpowerup = onpowerup, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -902,7 +902,7 @@ static void gen_onpowerup_set(struct bt_mesh_model *model, .gen_onpowerup_set.onpowerup = onpowerup, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET) { send_gen_onpowerup_status(model, ctx, false); @@ -915,10 +915,10 @@ static void gen_onpowerup_set(struct bt_mesh_model *model, /* Generic Power Level Server message handlers */ static void send_gen_power_level_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - bool publish, u16_t opcode) + bool publish, uint16_t opcode) { struct net_buf_simple *msg = NULL; - u8_t length = 2 + 5; + uint8_t length = 2 + 5; if (ctx == NULL && publish == false) { BT_ERR("%s, Invalid parameter", __func__); @@ -999,7 +999,7 @@ static void gen_power_level_get(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_gen_power_level_srv *srv = model->user_data; - u16_t opcode = 0U; + uint16_t opcode = 0U; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -1035,7 +1035,7 @@ static void gen_power_level_get(struct bt_mesh_model *model, return; } -void gen_power_level_publish(struct bt_mesh_model *model, u16_t opcode) +void gen_power_level_publish(struct bt_mesh_model *model, uint16_t opcode) { if (model->user_data == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -1073,10 +1073,10 @@ static void gen_power_level_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_gen_power_level_srv *srv = model->user_data; - u8_t tid = 0U, trans_time = 0U, delay = 0U; + uint8_t tid = 0U, trans_time = 0U, delay = 0U; bool optional = false; - u16_t power = 0U; - s64_t now = 0; + uint16_t power = 0U; + int64_t now = 0; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -1100,7 +1100,7 @@ static void gen_power_level_set(struct bt_mesh_model *model, .power_level_set.delay = delay, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -1137,7 +1137,7 @@ static void gen_power_level_set(struct bt_mesh_model *model, .gen_power_level_set.power = srv->state->power_actual, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET) { send_gen_power_level_status(model, ctx, false, BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_STATUS); @@ -1184,7 +1184,7 @@ static void gen_power_default_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_gen_power_level_setup_srv *srv = model->user_data; - u16_t power = 0U; + uint16_t power = 0U; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -1199,7 +1199,7 @@ static void gen_power_default_set(struct bt_mesh_model *model, .power_default_set.power = power, /* Just callback the actual received value */ }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -1219,7 +1219,7 @@ static void gen_power_default_set(struct bt_mesh_model *model, .gen_power_default_set.power = power, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET) { send_gen_power_level_status(model, ctx, false, BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_STATUS); @@ -1234,7 +1234,7 @@ static void gen_power_range_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_gen_power_level_setup_srv *srv = model->user_data; - u16_t range_min = 0U, range_max = 0U; + uint16_t range_min = 0U, range_max = 0U; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -1257,7 +1257,7 @@ static void gen_power_range_set(struct bt_mesh_model *model, .power_range_set.range_max = range_max, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -1282,7 +1282,7 @@ static void gen_power_range_set(struct bt_mesh_model *model, .gen_power_range_set.range_max = srv->state->power_range_max, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET) { send_gen_power_level_status(model, ctx, false, BLE_MESH_MODEL_OP_GEN_POWER_RANGE_STATUS); @@ -1323,10 +1323,10 @@ static void gen_battery_get(struct bt_mesh_model *model, /* Generic Location Server message handlers */ static void send_gen_location_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - bool publish, u16_t opcode) + bool publish, uint16_t opcode) { struct net_buf_simple *msg = NULL; - u8_t length = 1 + 10; + uint8_t length = 1 + 10; if (ctx == NULL && publish == false) { BT_ERR("%s, Invalid parameter", __func__); @@ -1400,7 +1400,7 @@ static void gen_location_get(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_gen_location_srv *srv = model->user_data; - u16_t opcode = 0U; + uint16_t opcode = 0U; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -1436,7 +1436,7 @@ static void gen_location_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_gen_location_setup_srv *srv = model->user_data; - u16_t opcode = 0U; + uint16_t opcode = 0U; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -1447,9 +1447,9 @@ static void gen_location_set(struct bt_mesh_model *model, case BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET: case BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET_UNACK: { opcode = BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_STATUS; - s32_t latitude = net_buf_simple_pull_le32(buf); - s32_t longitude = net_buf_simple_pull_le32(buf); - s16_t altitude = net_buf_simple_pull_le16(buf); + int32_t latitude = net_buf_simple_pull_le32(buf); + int32_t longitude = net_buf_simple_pull_le32(buf); + int16_t altitude = net_buf_simple_pull_le16(buf); /* Callback the received message to the application layer */ if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_RSP_BY_APP) { @@ -1459,7 +1459,7 @@ static void gen_location_set(struct bt_mesh_model *model, .loc_global_set.altitude = altitude, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -1479,17 +1479,17 @@ static void gen_location_set(struct bt_mesh_model *model, .gen_loc_global_set.altitude = srv->state->global_altitude, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); break; } case BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET: case BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET_UNACK: { opcode = BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_STATUS; - u16_t north = net_buf_simple_pull_le16(buf); - u16_t east = net_buf_simple_pull_le16(buf); - u16_t altitude = net_buf_simple_pull_le16(buf); - u8_t floor = net_buf_simple_pull_u8(buf); - u16_t uncertainty = net_buf_simple_pull_le16(buf); + uint16_t north = net_buf_simple_pull_le16(buf); + uint16_t east = net_buf_simple_pull_le16(buf); + uint16_t altitude = net_buf_simple_pull_le16(buf); + uint8_t floor = net_buf_simple_pull_u8(buf); + uint16_t uncertainty = net_buf_simple_pull_le16(buf); /* Callback the received message to the application layer */ if (srv->rsp_ctrl.set_auto_rsp == BLE_MESH_SERVER_RSP_BY_APP) { @@ -1501,7 +1501,7 @@ static void gen_location_set(struct bt_mesh_model *model, .loc_local_set.uncertainty = uncertainty, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -1527,7 +1527,7 @@ static void gen_location_set(struct bt_mesh_model *model, .gen_loc_local_set.uncertainty = srv->state->uncertainty, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); break; } default: @@ -1546,7 +1546,7 @@ static void gen_location_set(struct bt_mesh_model *model, /* Generic User Property Server message handlers */ static struct bt_mesh_generic_property *gen_get_user_property(struct bt_mesh_model *model, - u16_t property_id) + uint16_t property_id) { struct bt_mesh_gen_user_prop_srv *srv = model->user_data; int i; @@ -1562,11 +1562,11 @@ static struct bt_mesh_generic_property *gen_get_user_property(struct bt_mesh_mod static void send_gen_user_prop_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - u16_t property_id, bool publish) + uint16_t property_id, bool publish) { struct bt_mesh_generic_property *property = NULL; struct net_buf_simple *msg = NULL; - u16_t length = 0U; + uint16_t length = 0U; if (property_id == BLE_MESH_INVALID_DEVICE_PROPERTY_ID) { BT_ERR("Invalid User Property ID 0x%04x", property_id); @@ -1638,11 +1638,11 @@ static void gen_user_prop_get(struct bt_mesh_model *model, * and directly callback with buf->data & buf->len. */ bt_mesh_gen_server_recv_get_msg_t get = {0}; - const u8_t *param = NULL; + const uint8_t *param = NULL; size_t len = 0; if (ctx->recv_op == BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET) { get.user_property_get.id = net_buf_simple_pull_le16(buf); - param = (const u8_t *)&get; + param = (const uint8_t *)&get; len = sizeof(get); } bt_mesh_generic_server_cb_evt_to_btc( @@ -1653,7 +1653,7 @@ static void gen_user_prop_get(struct bt_mesh_model *model, switch (ctx->recv_op) { case BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET: { struct net_buf_simple *msg = NULL; - u8_t i; + uint8_t i; msg = bt_mesh_alloc_buf(1 + srv->property_count * 2 + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { BT_ERR("%s, Out of memory", __func__); @@ -1671,7 +1671,7 @@ static void gen_user_prop_get(struct bt_mesh_model *model, return; } case BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET: { - u16_t property_id = net_buf_simple_pull_le16(buf); + uint16_t property_id = net_buf_simple_pull_le16(buf); send_gen_user_prop_status(model, ctx, property_id, false); return; } @@ -1687,8 +1687,8 @@ static void gen_user_prop_set(struct bt_mesh_model *model, { struct bt_mesh_gen_user_prop_srv *srv = model->user_data; struct bt_mesh_generic_property *property = NULL; - u16_t property_id = 0U; - u8_t expect_len = 0U; + uint16_t property_id = 0U; + uint8_t expect_len = 0U; if (srv == NULL || srv->property_count == 0U || srv->properties == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -1704,7 +1704,7 @@ static void gen_user_prop_set(struct bt_mesh_model *model, .user_property_set.value = buf, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -1738,7 +1738,7 @@ static void gen_user_prop_set(struct bt_mesh_model *model, .gen_user_prop_set.value = property->val, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET) { send_gen_user_prop_status(model, ctx, property_id, false); @@ -1750,7 +1750,7 @@ static void gen_user_prop_set(struct bt_mesh_model *model, /* Generic Admin Property Server message handlers */ static struct bt_mesh_generic_property *gen_get_admin_property(struct bt_mesh_model *model, - u16_t property_id) + uint16_t property_id) { struct bt_mesh_gen_admin_prop_srv *srv = model->user_data; int i; @@ -1766,11 +1766,11 @@ static struct bt_mesh_generic_property *gen_get_admin_property(struct bt_mesh_mo static void send_gen_admin_prop_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - u16_t property_id, bool publish) + uint16_t property_id, bool publish) { struct bt_mesh_generic_property *property = NULL; struct net_buf_simple *msg = NULL; - u16_t length = 0U; + uint16_t length = 0U; if (property_id == BLE_MESH_INVALID_DEVICE_PROPERTY_ID) { BT_ERR("Invalid Admin Property ID 0x%04x", property_id); @@ -1833,11 +1833,11 @@ static void gen_admin_prop_get(struct bt_mesh_model *model, /* Callback the received message to the application layer */ if (srv->rsp_ctrl.get_auto_rsp == BLE_MESH_SERVER_RSP_BY_APP) { bt_mesh_gen_server_recv_get_msg_t get = {0}; - const u8_t *param = NULL; + const uint8_t *param = NULL; size_t len = 0U; if (ctx->recv_op == BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET) { get.admin_property_get.id = net_buf_simple_pull_le16(buf); - param = (const u8_t *)&get; + param = (const uint8_t *)&get; len = sizeof(get); } bt_mesh_generic_server_cb_evt_to_btc( @@ -1848,7 +1848,7 @@ static void gen_admin_prop_get(struct bt_mesh_model *model, switch (ctx->recv_op) { case BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_GET: { struct net_buf_simple *msg = NULL; - u8_t i = 0U; + uint8_t i = 0U; msg = bt_mesh_alloc_buf(1 + srv->property_count * 2 + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { BT_ERR("%s, Out of memory", __func__); @@ -1863,7 +1863,7 @@ static void gen_admin_prop_get(struct bt_mesh_model *model, return; } case BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET: { - u16_t property_id = net_buf_simple_pull_le16(buf); + uint16_t property_id = net_buf_simple_pull_le16(buf); send_gen_admin_prop_status(model, ctx, property_id, false); return; } @@ -1879,8 +1879,8 @@ static void gen_admin_prop_set(struct bt_mesh_model *model, { struct bt_mesh_gen_admin_prop_srv *srv = model->user_data; struct bt_mesh_generic_property *property = NULL; - u16_t property_id = 0U; - u8_t access = 0U; + uint16_t property_id = 0U; + uint8_t access = 0U; if (srv == NULL || srv->property_count == 0U || srv->properties == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -1902,7 +1902,7 @@ static void gen_admin_prop_set(struct bt_mesh_model *model, .admin_property_set.value = buf, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -1926,7 +1926,7 @@ static void gen_admin_prop_set(struct bt_mesh_model *model, .gen_admin_prop_set.value = property->val, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET) { send_gen_admin_prop_status(model, ctx, property_id, false); @@ -1938,7 +1938,7 @@ static void gen_admin_prop_set(struct bt_mesh_model *model, /* Generic Manufacturer Property Server message handlers */ static struct bt_mesh_generic_property *gen_get_manu_property(struct bt_mesh_model *model, - u16_t property_id) + uint16_t property_id) { struct bt_mesh_gen_manu_prop_srv *srv = model->user_data; int i; @@ -1954,11 +1954,11 @@ static struct bt_mesh_generic_property *gen_get_manu_property(struct bt_mesh_mod static void send_gen_manu_prop_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - u16_t property_id, bool publish) + uint16_t property_id, bool publish) { struct bt_mesh_generic_property *property = NULL; struct net_buf_simple *msg = NULL; - u16_t length = 0U; + uint16_t length = 0U; if (property_id == BLE_MESH_INVALID_DEVICE_PROPERTY_ID) { BT_ERR("Invalid Manu Property ID 0x%04x", property_id); @@ -2018,11 +2018,11 @@ static void gen_manu_prop_get(struct bt_mesh_model *model, /* Callback the received message to the application layer */ if (srv->rsp_ctrl.get_auto_rsp == BLE_MESH_SERVER_RSP_BY_APP) { bt_mesh_gen_server_recv_get_msg_t get = {0}; - const u8_t *param = NULL; + const uint8_t *param = NULL; size_t len = 0U; if (ctx->recv_op == BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_GET) { get.manu_property_get.id = net_buf_simple_pull_le16(buf); - param = (const u8_t *)&get; + param = (const uint8_t *)&get; len = sizeof(get); } bt_mesh_generic_server_cb_evt_to_btc( @@ -2033,7 +2033,7 @@ static void gen_manu_prop_get(struct bt_mesh_model *model, switch (ctx->recv_op) { case BLE_MESH_MODEL_OP_GEN_MANU_PROPERTIES_GET: { struct net_buf_simple *msg = NULL; - u8_t i = 0U; + uint8_t i = 0U; msg = bt_mesh_alloc_buf(1 + srv->property_count * 2 + BLE_MESH_SERVER_TRANS_MIC_SIZE); if (msg == NULL) { BT_ERR("%s, Out of memory", __func__); @@ -2048,7 +2048,7 @@ static void gen_manu_prop_get(struct bt_mesh_model *model, return; } case BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_GET: { - u16_t property_id = net_buf_simple_pull_le16(buf); + uint16_t property_id = net_buf_simple_pull_le16(buf); send_gen_manu_prop_status(model, ctx, property_id, false); return; } @@ -2064,8 +2064,8 @@ static void gen_manu_prop_set(struct bt_mesh_model *model, { struct bt_mesh_gen_manu_prop_srv *srv = model->user_data; struct bt_mesh_generic_property *property = NULL; - u16_t property_id = 0U; - u8_t access = 0U; + uint16_t property_id = 0U; + uint8_t access = 0U; if (srv == NULL || srv->property_count == 0U || srv->properties == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -2086,7 +2086,7 @@ static void gen_manu_prop_set(struct bt_mesh_model *model, .manu_property_set.access = access, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -2106,7 +2106,7 @@ static void gen_manu_prop_set(struct bt_mesh_model *model, .gen_manu_prop_set.access = property->manu_access, }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_SET) { send_gen_manu_prop_status(model, ctx, property_id, false); @@ -2117,11 +2117,11 @@ static void gen_manu_prop_set(struct bt_mesh_model *model, } /* Generic Client Property Server message handlers */ -static int search_prop_id_index(const u16_t *array, u8_t array_idx, u16_t id) +static int search_prop_id_index(const uint16_t *array, uint8_t array_idx, uint16_t id) { - static const u16_t *start = NULL; - u8_t index = 0U; - u16_t temp = 0U; + static const uint16_t *start = NULL; + uint8_t index = 0U; + uint16_t temp = 0U; if (start == NULL) { start = array; @@ -2153,8 +2153,8 @@ static void gen_client_prop_get(struct bt_mesh_model *model, { struct bt_mesh_gen_client_prop_srv *srv = model->user_data; struct net_buf_simple *sdu = NULL; - u16_t total_len = 5U; - u16_t property_id = 0U; + uint16_t total_len = 5U; + uint16_t property_id = 0U; int i, index = 0; if (srv == NULL || srv->id_count == 0U || srv->property_ids == NULL) { @@ -2168,7 +2168,7 @@ static void gen_client_prop_get(struct bt_mesh_model *model, .client_properties_get.id = net_buf_simple_pull_le16(buf), }; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_GET_MSG, model, ctx, (const u8_t *)&get, sizeof(get)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_GET_MSG, model, ctx, (const uint8_t *)&get, sizeof(get)); return; } @@ -2195,7 +2195,7 @@ static void gen_client_prop_get(struct bt_mesh_model *model, bt_mesh_model_msg_init(sdu, BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_STATUS); for (i = index; i < srv->id_count; i++) { - total_len += sizeof(u16_t); + total_len += sizeof(uint16_t); if (total_len > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN)) { /* Add this in case the message is too long */ BT_WARN("Too large generic client properties status"); @@ -2329,10 +2329,10 @@ const struct bt_mesh_model_op bt_mesh_gen_client_prop_srv_op[] = { static inline int property_id_compare(const void *p1, const void *p2) { - if (*(u16_t *)p1 < * (u16_t *)p2) { + if (*(uint16_t *)p1 < * (uint16_t *)p2) { return -1; } - if (*(u16_t *)p1 > *(u16_t *)p2) { + if (*(uint16_t *)p1 > *(uint16_t *)p2) { return 1; } return 0; @@ -2466,7 +2466,7 @@ static int generic_server_init(struct bt_mesh_model *model) return -EINVAL; } /* Quick sort the Client Property IDs in ascending order */ - qsort(srv->property_ids, srv->id_count, sizeof(u16_t), property_id_compare); + qsort(srv->property_ids, srv->id_count, sizeof(uint16_t), property_id_compare); srv->model = model; break; } diff --git a/components/bt/esp_ble_mesh/mesh_models/server/include/generic_server.h b/components/bt/esp_ble_mesh/mesh_models/server/include/generic_server.h index 6ca0805bea..ce56b7f76d 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/include/generic_server.h +++ b/components/bt/esp_ble_mesh/mesh_models/server/include/generic_server.h @@ -16,8 +16,8 @@ extern "C" { #endif struct bt_mesh_gen_onoff_state { - u8_t onoff; - u8_t target_onoff; + uint8_t onoff; + uint8_t target_onoff; }; struct bt_mesh_gen_onoff_srv { @@ -29,11 +29,11 @@ struct bt_mesh_gen_onoff_srv { }; struct bt_mesh_gen_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; bool move_start; bool positive; @@ -45,11 +45,11 @@ struct bt_mesh_gen_level_srv { struct bt_mesh_gen_level_state state; struct bt_mesh_last_msg_info last; struct bt_mesh_state_transition transition; - s32_t tt_delta_level; + int32_t tt_delta_level; }; struct bt_mesh_gen_def_trans_time_state { - u8_t trans_time; + uint8_t trans_time; }; struct bt_mesh_gen_def_trans_time_srv { @@ -59,7 +59,7 @@ struct bt_mesh_gen_def_trans_time_srv { }; struct bt_mesh_gen_onpowerup_state { - u8_t onpowerup; + uint8_t onpowerup; }; struct bt_mesh_gen_power_onoff_srv { @@ -75,15 +75,15 @@ struct bt_mesh_gen_power_onoff_setup_srv { }; struct bt_mesh_gen_power_level_state { - u16_t power_actual; - u16_t target_power_actual; + uint16_t power_actual; + uint16_t target_power_actual; - u16_t power_last; - u16_t power_default; + uint16_t power_last; + uint16_t power_default; - u8_t status_code; - u16_t power_range_min; - u16_t power_range_max; + uint8_t status_code; + uint16_t power_range_min; + uint16_t power_range_max; }; struct bt_mesh_gen_power_level_srv { @@ -92,7 +92,7 @@ struct bt_mesh_gen_power_level_srv { struct bt_mesh_gen_power_level_state *state; struct bt_mesh_last_msg_info last; struct bt_mesh_state_transition transition; - s32_t tt_delta_level; + int32_t tt_delta_level; }; struct bt_mesh_gen_power_level_setup_srv { @@ -102,10 +102,10 @@ struct bt_mesh_gen_power_level_setup_srv { }; struct bt_mesh_gen_battery_state { - u32_t battery_level : 8, - time_to_discharge : 24; - u32_t time_to_charge : 24, - battery_flags : 8; + uint32_t battery_level : 8, + time_to_discharge : 24; + uint32_t time_to_charge : 24, + battery_flags : 8; }; struct bt_mesh_gen_battery_srv { @@ -115,14 +115,14 @@ struct bt_mesh_gen_battery_srv { }; struct bt_mesh_gen_location_state { - s32_t global_latitude; - s32_t global_longitude; - s16_t global_altitude; - s16_t local_north; - s16_t local_east; - s16_t local_altitude; - u8_t floor_number; - u16_t uncertainty; + int32_t global_latitude; + int32_t global_longitude; + int16_t global_altitude; + int16_t local_north; + int16_t local_east; + int16_t local_altitude; + uint8_t floor_number; + uint16_t uncertainty; }; struct bt_mesh_gen_location_srv { @@ -170,185 +170,185 @@ enum bt_mesh_gen_manu_prop_access { }; struct bt_mesh_generic_property { - u16_t id; - u8_t user_access; - u8_t admin_access; - u8_t manu_access; + uint16_t id; + uint8_t user_access; + uint8_t admin_access; + uint8_t manu_access; struct net_buf_simple *val; }; struct bt_mesh_gen_user_prop_srv { struct bt_mesh_model *model; struct bt_mesh_server_rsp_ctrl rsp_ctrl; - u8_t property_count; + uint8_t property_count; struct bt_mesh_generic_property *properties; }; struct bt_mesh_gen_admin_prop_srv { struct bt_mesh_model *model; struct bt_mesh_server_rsp_ctrl rsp_ctrl; - u8_t property_count; + uint8_t property_count; struct bt_mesh_generic_property *properties; }; struct bt_mesh_gen_manu_prop_srv { struct bt_mesh_model *model; struct bt_mesh_server_rsp_ctrl rsp_ctrl; - u8_t property_count; + uint8_t property_count; struct bt_mesh_generic_property *properties; }; struct bt_mesh_gen_client_prop_srv { struct bt_mesh_model *model; struct bt_mesh_server_rsp_ctrl rsp_ctrl; - u8_t id_count; - u16_t *property_ids; + uint8_t id_count; + uint16_t *property_ids; }; typedef union { struct { - u8_t onoff; + uint8_t onoff; } gen_onoff_set; struct { - s16_t level; + int16_t level; } gen_level_set; struct { - s16_t level; + int16_t level; } gen_delta_set; struct { - s16_t level; + int16_t level; } gen_move_set; struct { - u8_t trans_time; + uint8_t trans_time; } gen_def_trans_time_set; struct { - u8_t onpowerup; + uint8_t onpowerup; } gen_onpowerup_set; struct { - u16_t power; + uint16_t power; } gen_power_level_set; struct { - u16_t power; + uint16_t power; } gen_power_default_set; struct { - u16_t range_min; - u16_t range_max; + uint16_t range_min; + uint16_t range_max; } gen_power_range_set; struct { - s32_t latitude; - s32_t longitude; - s16_t altitude; + int32_t latitude; + int32_t longitude; + int16_t altitude; } gen_loc_global_set; struct { - s16_t north; - s16_t east; - s16_t altitude; - u8_t floor_number; - u16_t uncertainty; + int16_t north; + int16_t east; + int16_t altitude; + uint8_t floor_number; + uint16_t uncertainty; } gen_loc_local_set; struct { - u16_t id; + uint16_t id; struct net_buf_simple *value; } gen_user_prop_set; struct { - u16_t id; - u8_t access; + uint16_t id; + uint8_t access; struct net_buf_simple *value; } gen_admin_prop_set; struct { - u16_t id; - u8_t access; + uint16_t id; + uint8_t access; } gen_manu_prop_set; } bt_mesh_gen_server_state_change_t; typedef union { struct { - u16_t id; + uint16_t id; } user_property_get; struct { - u16_t id; + uint16_t id; } admin_property_get; struct { - u16_t id; + uint16_t id; } manu_property_get; struct { - u16_t id; + uint16_t id; } client_properties_get; } bt_mesh_gen_server_recv_get_msg_t; typedef union { struct { - bool op_en; - u8_t onoff; - u8_t tid; - u8_t trans_time; - u8_t delay; + bool op_en; + uint8_t onoff; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; } onoff_set; struct { - bool op_en; - s16_t level; - u8_t tid; - u8_t trans_time; - u8_t delay; + bool op_en; + int16_t level; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; } level_set; struct { - bool op_en; - s32_t delta_level; - u8_t tid; - u8_t trans_time; - u8_t delay; + bool op_en; + int32_t delta_level; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; } delta_set; struct { - bool op_en; - s16_t delta_level; - u8_t tid; - u8_t trans_time; - u8_t delay; + bool op_en; + int16_t delta_level; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; } move_set; struct { - u8_t trans_time; + uint8_t trans_time; } def_trans_time_set; struct { - u8_t onpowerup; + uint8_t onpowerup; } onpowerup_set; struct { - bool op_en; - u16_t power; - u8_t tid; - u8_t trans_time; - u8_t delay; + bool op_en; + uint16_t power; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; } power_level_set; struct { - u16_t power; + uint16_t power; } power_default_set; struct { - u16_t range_min; - u16_t range_max; + uint16_t range_min; + uint16_t range_max; } power_range_set; struct { - s32_t latitude; - s32_t longitude; - s16_t altitude; + int32_t latitude; + int32_t longitude; + int16_t altitude; } loc_global_set; struct { - s16_t north; - s16_t east; - s16_t altitude; - u8_t floor_number; - u16_t uncertainty; + int16_t north; + int16_t east; + int16_t altitude; + uint8_t floor_number; + uint16_t uncertainty; } loc_local_set; struct { - u16_t id; + uint16_t id; struct net_buf_simple *value; } user_property_set; struct { - u16_t id; - u8_t access; + uint16_t id; + uint8_t access; struct net_buf_simple *value; } admin_property_set; struct { - u16_t id; - u8_t access; + uint16_t id; + uint8_t access; } manu_property_set; } bt_mesh_gen_server_recv_set_msg_t; @@ -358,7 +358,7 @@ void bt_mesh_generic_server_unlock(void); void gen_onoff_publish(struct bt_mesh_model *model); void gen_level_publish(struct bt_mesh_model *model); void gen_onpowerup_publish(struct bt_mesh_model *model); -void gen_power_level_publish(struct bt_mesh_model *model, u16_t opcode); +void gen_power_level_publish(struct bt_mesh_model *model, uint16_t opcode); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_models/server/include/lighting_server.h b/components/bt/esp_ble_mesh/mesh_models/server/include/lighting_server.h index 7f5bc348c3..dbd9612066 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/include/lighting_server.h +++ b/components/bt/esp_ble_mesh/mesh_models/server/include/lighting_server.h @@ -16,18 +16,18 @@ extern "C" { #endif struct bt_mesh_light_lightness_state { - u16_t lightness_linear; - u16_t target_lightness_linear; + uint16_t lightness_linear; + uint16_t target_lightness_linear; - u16_t lightness_actual; - u16_t target_lightness_actual; + uint16_t lightness_actual; + uint16_t target_lightness_actual; - u16_t lightness_last; - u16_t lightness_default; + uint16_t lightness_last; + uint16_t lightness_default; - u8_t status_code; - u16_t lightness_range_min; - u16_t lightness_range_max; + uint8_t status_code; + uint16_t lightness_range_min; + uint16_t lightness_range_max; }; struct bt_mesh_light_lightness_srv { @@ -37,8 +37,8 @@ struct bt_mesh_light_lightness_srv { struct bt_mesh_last_msg_info last; struct bt_mesh_state_transition actual_transition; struct bt_mesh_state_transition linear_transition; - s32_t tt_delta_lightness_actual; - s32_t tt_delta_lightness_linear; + int32_t tt_delta_lightness_actual; + int32_t tt_delta_lightness_linear; }; struct bt_mesh_light_lightness_setup_srv { @@ -48,22 +48,22 @@ struct bt_mesh_light_lightness_setup_srv { }; struct bt_mesh_light_ctl_state { - u16_t lightness; - u16_t target_lightness; + uint16_t lightness; + uint16_t target_lightness; - u16_t temperature; - u16_t target_temperature; + uint16_t temperature; + uint16_t target_temperature; - s16_t delta_uv; - s16_t target_delta_uv; + int16_t delta_uv; + int16_t target_delta_uv; - u8_t status_code; - u16_t temperature_range_min; - u16_t temperature_range_max; + uint8_t status_code; + uint16_t temperature_range_min; + uint16_t temperature_range_max; - u16_t lightness_default; - u16_t temperature_default; - s16_t delta_uv_default; + uint16_t lightness_default; + uint16_t temperature_default; + int16_t delta_uv_default; }; struct bt_mesh_light_ctl_srv { @@ -72,9 +72,9 @@ struct bt_mesh_light_ctl_srv { struct bt_mesh_light_ctl_state *state; struct bt_mesh_last_msg_info last; struct bt_mesh_state_transition transition; - s32_t tt_delta_lightness; - s32_t tt_delta_temperature; - s32_t tt_delta_delta_uv; + int32_t tt_delta_lightness; + int32_t tt_delta_temperature; + int32_t tt_delta_delta_uv; }; struct bt_mesh_light_ctl_setup_srv { @@ -89,29 +89,29 @@ struct bt_mesh_light_ctl_temp_srv { struct bt_mesh_light_ctl_state *state; struct bt_mesh_last_msg_info last; struct bt_mesh_state_transition transition; - s32_t tt_delta_temperature; - s32_t tt_delta_delta_uv; + int32_t tt_delta_temperature; + int32_t tt_delta_delta_uv; }; struct bt_mesh_light_hsl_state { - u16_t lightness; - u16_t target_lightness; + uint16_t lightness; + uint16_t target_lightness; - u16_t hue; - u16_t target_hue; + uint16_t hue; + uint16_t target_hue; - u16_t saturation; - u16_t target_saturation; + uint16_t saturation; + uint16_t target_saturation; - u16_t lightness_default; - u16_t hue_default; - u16_t saturation_default; + uint16_t lightness_default; + uint16_t hue_default; + uint16_t saturation_default; - u8_t status_code; - u16_t hue_range_min; - u16_t hue_range_max; - u16_t saturation_range_min; - u16_t saturation_range_max; + uint8_t status_code; + uint16_t hue_range_min; + uint16_t hue_range_max; + uint16_t saturation_range_min; + uint16_t saturation_range_max; }; struct bt_mesh_light_hsl_srv { @@ -120,9 +120,9 @@ struct bt_mesh_light_hsl_srv { struct bt_mesh_light_hsl_state *state; struct bt_mesh_last_msg_info last; struct bt_mesh_state_transition transition; - s32_t tt_delta_lightness; - s32_t tt_delta_hue; - s32_t tt_delta_saturation; + int32_t tt_delta_lightness; + int32_t tt_delta_hue; + int32_t tt_delta_saturation; }; struct bt_mesh_light_hsl_setup_srv { @@ -137,7 +137,7 @@ struct bt_mesh_light_hsl_hue_srv { struct bt_mesh_light_hsl_state *state; struct bt_mesh_last_msg_info last; struct bt_mesh_state_transition transition; - s32_t tt_delta_hue; + int32_t tt_delta_hue; }; struct bt_mesh_light_hsl_sat_srv { @@ -146,28 +146,28 @@ struct bt_mesh_light_hsl_sat_srv { struct bt_mesh_light_hsl_state *state; struct bt_mesh_last_msg_info last; struct bt_mesh_state_transition transition; - s32_t tt_delta_saturation; + int32_t tt_delta_saturation; }; struct bt_mesh_light_xyl_state { - u16_t lightness; - u16_t target_lightness; + uint16_t lightness; + uint16_t target_lightness; - u16_t x; - u16_t target_x; + uint16_t x; + uint16_t target_x; - u16_t y; - u16_t target_y; + uint16_t y; + uint16_t target_y; - u16_t lightness_default; - u16_t x_default; - u16_t y_default; + uint16_t lightness_default; + uint16_t x_default; + uint16_t y_default; - u8_t status_code; - u16_t x_range_min; - u16_t x_range_max; - u16_t y_range_min; - u16_t y_range_max; + uint8_t status_code; + uint16_t x_range_min; + uint16_t x_range_max; + uint16_t y_range_min; + uint16_t y_range_max; }; struct bt_mesh_light_xyl_srv { @@ -176,9 +176,9 @@ struct bt_mesh_light_xyl_srv { struct bt_mesh_light_xyl_state *state; struct bt_mesh_last_msg_info last; struct bt_mesh_state_transition transition; - s32_t tt_delta_lightness; - s32_t tt_delta_x; - s32_t tt_delta_y; + int32_t tt_delta_lightness; + int32_t tt_delta_x; + int32_t tt_delta_y; }; struct bt_mesh_light_xyl_setup_srv { @@ -188,40 +188,40 @@ struct bt_mesh_light_xyl_setup_srv { }; struct bt_mesh_light_lc_state { - u32_t mode : 1, /* default 0 */ - occupancy_mode : 1, /* default 1 */ - light_onoff : 1, - target_light_onoff : 1, - occupancy : 1, - ambient_luxlevel : 24; /* 0x000000 ~ 0xFFFFFF */ + uint32_t mode : 1, /* default 0 */ + occupancy_mode : 1, /* default 1 */ + light_onoff : 1, + target_light_onoff : 1, + occupancy : 1, + ambient_luxlevel : 24; /* 0x000000 ~ 0xFFFFFF */ - u16_t linear_output; /* 0x0000 ~ 0xFFFF */ + uint16_t linear_output; /* 0x0000 ~ 0xFFFF */ }; struct bt_mesh_light_lc_property_state { - u32_t time_occupancy_delay; /* 0x003A */ - u32_t time_fade_on; /* 0x0037 */ - u32_t time_run_on; /* 0x003C */ - u32_t time_fade; /* 0x0036 */ - u32_t time_prolong; /* 0x003B */ - u32_t time_fade_standby_auto; /* 0x0038 */ - u32_t time_fade_standby_manual; /* 0x0039 */ + uint32_t time_occupancy_delay; /* 0x003A */ + uint32_t time_fade_on; /* 0x0037 */ + uint32_t time_run_on; /* 0x003C */ + uint32_t time_fade; /* 0x0036 */ + uint32_t time_prolong; /* 0x003B */ + uint32_t time_fade_standby_auto; /* 0x0038 */ + uint32_t time_fade_standby_manual; /* 0x0039 */ - u16_t lightness_on; /* 0x002E */ - u16_t lightness_prolong; /* 0x002F */ - u16_t lightness_standby; /* 0x0030 */ + uint16_t lightness_on; /* 0x002E */ + uint16_t lightness_prolong; /* 0x002F */ + uint16_t lightness_standby; /* 0x0030 */ - u16_t ambient_luxlevel_on; /* 0x002B, 0x0000 ~ 0xFFFF */ - u16_t ambient_luxlevel_prolong; /* 0x002C, 0x0000 ~ 0xFFFF */ - u16_t ambient_luxlevel_standby; /* 0x002D, 0x0000 ~ 0xFFFF */ + uint16_t ambient_luxlevel_on; /* 0x002B, 0x0000 ~ 0xFFFF */ + uint16_t ambient_luxlevel_prolong; /* 0x002C, 0x0000 ~ 0xFFFF */ + uint16_t ambient_luxlevel_standby; /* 0x002D, 0x0000 ~ 0xFFFF */ - float regulator_kiu; /* 0x0033, 0.0 ~ 1000.0, default 250.0 */ - float regulator_kid; /* 0x0032, 0.0 ~ 1000.0, default 25.0 */ - float regulator_kpu; /* 0x0035, 0.0 ~ 1000.0, default 80.0 */ - float regulator_kpd; /* 0x0034, 0.0 ~ 1000.0, default 80.0 */ - s8_t regulator_accuracy; /* 0x0031, 0.0 ~ 100.0, default 2.0 */ + float regulator_kiu; /* 0x0033, 0.0 ~ 1000.0, default 250.0 */ + float regulator_kid; /* 0x0032, 0.0 ~ 1000.0, default 25.0 */ + float regulator_kpu; /* 0x0035, 0.0 ~ 1000.0, default 80.0 */ + float regulator_kpd; /* 0x0034, 0.0 ~ 1000.0, default 80.0 */ + int8_t regulator_accuracy; /* 0x0031, 0.0 ~ 100.0, default 2.0 */ - u32_t set_occupancy_to_1_delay; + uint32_t set_occupancy_to_1_delay; }; typedef enum { @@ -237,10 +237,10 @@ typedef enum { struct bt_mesh_light_lc_state_machine { struct { - u8_t fade_on; - u8_t fade; - u8_t fade_standby_auto; - u8_t fade_standby_manual; + uint8_t fade_on; + uint8_t fade; + uint8_t fade_standby_auto; + uint8_t fade_standby_manual; } trans_time; bt_mesh_lc_state state; struct k_delayed_work timer; @@ -268,220 +268,220 @@ struct bt_mesh_light_lc_setup_srv { typedef union { struct { - u16_t lightness; + uint16_t lightness; } lightness_set; struct { - u16_t lightness; + uint16_t lightness; } lightness_linear_set; struct { - u16_t lightness; + uint16_t lightness; } lightness_default_set; struct { - u16_t range_min; - u16_t range_max; + uint16_t range_min; + uint16_t range_max; } lightness_range_set; struct { - u16_t lightness; - u16_t temperature; - s16_t delta_uv; + uint16_t lightness; + uint16_t temperature; + int16_t delta_uv; } ctl_set; struct { - u16_t temperature; - s16_t delta_uv; + uint16_t temperature; + int16_t delta_uv; } ctl_temp_set; struct { - u16_t range_min; - u16_t range_max; + uint16_t range_min; + uint16_t range_max; } ctl_temp_range_set; struct { - u16_t lightness; - u16_t temperature; - s16_t delta_uv; + uint16_t lightness; + uint16_t temperature; + int16_t delta_uv; } ctl_default_set; struct { - u16_t lightness; - u16_t hue; - u16_t saturation; + uint16_t lightness; + uint16_t hue; + uint16_t saturation; } hsl_set; struct { - u16_t hue; + uint16_t hue; } hsl_hue_set; struct { - u16_t saturation; + uint16_t saturation; } hsl_saturation_set; struct { - u16_t lightness; - u16_t hue; - u16_t saturation; + uint16_t lightness; + uint16_t hue; + uint16_t saturation; } hsl_default_set; struct { - u16_t hue_range_min; - u16_t hue_range_max; - u16_t sat_range_min; - u16_t sat_range_max; + uint16_t hue_range_min; + uint16_t hue_range_max; + uint16_t sat_range_min; + uint16_t sat_range_max; } hsl_range_set; struct { - u16_t lightness; - u16_t x; - u16_t y; + uint16_t lightness; + uint16_t x; + uint16_t y; } xyl_set; struct { - u16_t lightness; - u16_t x; - u16_t y; + uint16_t lightness; + uint16_t x; + uint16_t y; } xyl_default_set; struct { - u16_t x_range_min; - u16_t x_range_max; - u16_t y_range_min; - u16_t y_range_max; + uint16_t x_range_min; + uint16_t x_range_max; + uint16_t y_range_min; + uint16_t y_range_max; } xyl_range_set; struct { - u8_t mode; + uint8_t mode; } lc_mode_set; struct { - u8_t mode; + uint8_t mode; } lc_om_set; struct { - u8_t onoff; + uint8_t onoff; } lc_light_onoff_set; struct { - u16_t id; + uint16_t id; struct net_buf_simple *value; } lc_property_set; struct { - u16_t property_id; + uint16_t property_id; union { - u8_t occupancy; - u32_t set_occupancy_to_1_delay; - u32_t ambient_luxlevel; + uint8_t occupancy; + uint32_t set_occupancy_to_1_delay; + uint32_t ambient_luxlevel; } state; } sensor_status; } bt_mesh_light_server_state_change_t; typedef union { struct { - u16_t id; + uint16_t id; } lc_property_get; } bt_mesh_light_server_recv_get_msg_t; typedef union { struct { - bool op_en; - u16_t lightness; - u8_t tid; - u8_t trans_time; - u8_t delay; + bool op_en; + uint16_t lightness; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; } lightness_set; struct { - bool op_en; - u16_t lightness; - u8_t tid; - u8_t trans_time; - u8_t delay; + bool op_en; + uint16_t lightness; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; } lightness_linear_set; struct { - u16_t lightness; + uint16_t lightness; } lightness_default_set; struct { - u16_t range_min; - u16_t range_max; + uint16_t range_min; + uint16_t range_max; } lightness_range_set; struct { - bool op_en; - u16_t lightness; - u16_t temperature; - s16_t delta_uv; - u8_t tid; - u8_t trans_time; - u8_t delay; + bool op_en; + uint16_t lightness; + uint16_t temperature; + int16_t delta_uv; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; } ctl_set; struct { - bool op_en; - u16_t temperature; - s16_t delta_uv; - u8_t tid; - u8_t trans_time; - u8_t delay; + bool op_en; + uint16_t temperature; + int16_t delta_uv; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; } ctl_temp_set; struct { - u16_t range_min; - u16_t range_max; + uint16_t range_min; + uint16_t range_max; } ctl_temp_range_set; struct { - u16_t lightness; - u16_t temperature; - s16_t delta_uv; + uint16_t lightness; + uint16_t temperature; + int16_t delta_uv; } ctl_default_set; struct { - bool op_en; - u16_t lightness; - u16_t hue; - u16_t saturation; - u8_t tid; - u8_t trans_time; - u8_t delay; + bool op_en; + uint16_t lightness; + uint16_t hue; + uint16_t saturation; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; } hsl_set; struct { - bool op_en; - u16_t hue; - u8_t tid; - u8_t trans_time; - u8_t delay; + bool op_en; + uint16_t hue; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; } hsl_hue_set; struct { - bool op_en; - u16_t saturation; - u8_t tid; - u8_t trans_time; - u8_t delay; + bool op_en; + uint16_t saturation; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; } hsl_saturation_set; struct { - u16_t lightness; - u16_t hue; - u16_t saturation; + uint16_t lightness; + uint16_t hue; + uint16_t saturation; } hsl_default_set; struct { - u16_t hue_range_min; - u16_t hue_range_max; - u16_t sat_range_min; - u16_t sat_range_max; + uint16_t hue_range_min; + uint16_t hue_range_max; + uint16_t sat_range_min; + uint16_t sat_range_max; } hsl_range_set; struct { - bool op_en; - u16_t lightness; - u16_t x; - u16_t y; - u8_t tid; - u8_t trans_time; - u8_t delay; + bool op_en; + uint16_t lightness; + uint16_t x; + uint16_t y; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; } xyl_set; struct { - u16_t lightness; - u16_t x; - u16_t y; + uint16_t lightness; + uint16_t x; + uint16_t y; } xyl_default_set; struct { - u16_t x_range_min; - u16_t x_range_max; - u16_t y_range_min; - u16_t y_range_max; + uint16_t x_range_min; + uint16_t x_range_max; + uint16_t y_range_min; + uint16_t y_range_max; } xyl_range_set; struct { - u8_t mode; + uint8_t mode; } lc_mode_set; struct { - u8_t mode; + uint8_t mode; } lc_om_set; struct { - bool op_en; - u8_t light_onoff; - u8_t tid; - u8_t trans_time; - u8_t delay; + bool op_en; + uint8_t light_onoff; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; } lc_light_onoff_set; struct { - u16_t id; + uint16_t id; struct net_buf_simple *value; } lc_property_set; } bt_mesh_light_server_recv_set_msg_t; @@ -495,13 +495,13 @@ typedef union { void bt_mesh_light_server_lock(void); void bt_mesh_light_server_unlock(void); -u8_t *bt_mesh_get_lc_prop_value(struct bt_mesh_model *model, u16_t prop_id); +uint8_t *bt_mesh_get_lc_prop_value(struct bt_mesh_model *model, uint16_t prop_id); -void light_lightness_publish(struct bt_mesh_model *model, u16_t opcode); -void light_ctl_publish(struct bt_mesh_model *model, u16_t opcode); -void light_hsl_publish(struct bt_mesh_model *model, u16_t opcode); -void light_xyl_publish(struct bt_mesh_model *model, u16_t opcode); -void light_lc_publish(struct bt_mesh_model *model, u16_t opcode); +void light_lightness_publish(struct bt_mesh_model *model, uint16_t opcode); +void light_ctl_publish(struct bt_mesh_model *model, uint16_t opcode); +void light_hsl_publish(struct bt_mesh_model *model, uint16_t opcode); +void light_xyl_publish(struct bt_mesh_model *model, uint16_t opcode); +void light_lc_publish(struct bt_mesh_model *model, uint16_t opcode); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_models/server/include/sensor_server.h b/components/bt/esp_ble_mesh/mesh_models/server/include/sensor_server.h index ca75d7d806..2b33058be2 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/include/sensor_server.h +++ b/components/bt/esp_ble_mesh/mesh_models/server/include/sensor_server.h @@ -79,26 +79,26 @@ enum bt_mesh_sensor_sample_func { }; struct sensor_descriptor { - u32_t positive_tolerance : 12, - negative_tolerance : 12, - sample_function : 8; - u8_t measure_period; - u8_t update_interval; + uint32_t positive_tolerance : 12, + negative_tolerance : 12, + sample_function : 8; + uint8_t measure_period; + uint8_t update_interval; }; struct sensor_setting { - u16_t property_id; - u8_t access; + uint16_t property_id; + uint8_t access; /* Or use union to include all possible types */ struct net_buf_simple *raw; }; struct sensor_cadence { - u8_t period_divisor : 7, - trigger_type : 1; + uint8_t period_divisor : 7, + trigger_type : 1; struct net_buf_simple *trigger_delta_down; struct net_buf_simple *trigger_delta_up; - u8_t min_interval; + uint8_t min_interval; struct net_buf_simple *fast_cadence_low; struct net_buf_simple *fast_cadence_high; }; @@ -111,8 +111,8 @@ struct sensor_data { * representing range of 1 – 127). The value 0x7F represents a * length of zero. */ - u8_t format : 1, - length : 7; + uint8_t format : 1, + length : 7; struct net_buf_simple *raw_value; }; @@ -123,7 +123,7 @@ struct sensor_series_column { }; struct bt_mesh_sensor_state { - u16_t sensor_property_id; + uint16_t sensor_property_id; /* Constant throughout the lifetime of an element */ struct sensor_descriptor descriptor; @@ -132,7 +132,7 @@ struct bt_mesh_sensor_state { * The Sensor Setting Property ID values shall be unique for each * Sensor Property ID that identifies a sensor within an element. */ - const u8_t setting_count; + const uint8_t setting_count; struct sensor_setting *settings; /* The Sensor Cadence state may be not supported by sensors based @@ -176,73 +176,73 @@ struct bt_mesh_sensor_state { struct bt_mesh_sensor_srv { struct bt_mesh_model *model; struct bt_mesh_server_rsp_ctrl rsp_ctrl; - const u8_t state_count; + const uint8_t state_count; struct bt_mesh_sensor_state *states; }; struct bt_mesh_sensor_setup_srv { struct bt_mesh_model *model; struct bt_mesh_server_rsp_ctrl rsp_ctrl; - const u8_t state_count; + const uint8_t state_count; struct bt_mesh_sensor_state *states; }; typedef union { struct { - u16_t id; - u8_t period_divisor : 7, - trigger_type : 1; + uint16_t id; + uint8_t period_divisor : 7, + trigger_type : 1; struct net_buf_simple *trigger_delta_down; struct net_buf_simple *trigger_delta_up; - u8_t min_interval; + uint8_t min_interval; struct net_buf_simple *fast_cadence_low; struct net_buf_simple *fast_cadence_high; } sensor_cadence_set; struct { - u16_t id; - u16_t setting_id; + uint16_t id; + uint16_t setting_id; struct net_buf_simple *value; } sensor_setting_set; } bt_mesh_sensor_server_state_change_t; typedef union { struct { - bool op_en; - u16_t id; + bool op_en; + uint16_t id; } sensor_descriptor_get; struct { - u16_t id; + uint16_t id; } sensor_cadence_get; struct { - u16_t id; + uint16_t id; } sensor_settings_get; struct { - u16_t id; - u16_t setting_id; + uint16_t id; + uint16_t setting_id; } sensor_setting_get; struct { - bool op_en; - u16_t id; + bool op_en; + uint16_t id; } sensor_get; struct { - u16_t id; + uint16_t id; struct net_buf_simple *raw_x; } sensor_column_get; struct { - bool op_en; - u16_t id; + bool op_en; + uint16_t id; struct net_buf_simple *raw; } sensor_series_get; } bt_mesh_sensor_server_recv_get_msg_t; typedef union { struct { - u16_t id; + uint16_t id; struct net_buf_simple *cadence; } sensor_cadence_set; struct { - u16_t id; - u16_t setting_id; + uint16_t id; + uint16_t setting_id; struct net_buf_simple *raw; } sensor_setting_set; } bt_mesh_sensor_server_recv_set_msg_t; diff --git a/components/bt/esp_ble_mesh/mesh_models/server/include/server_common.h b/components/bt/esp_ble_mesh/mesh_models/server/include/server_common.h index 835940307e..dece2ef78c 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/include/server_common.h +++ b/components/bt/esp_ble_mesh/mesh_models/server/include/server_common.h @@ -61,23 +61,23 @@ enum { struct bt_mesh_state_transition { bool just_started; - u8_t trans_time; - u8_t remain_time; - u8_t delay; - u32_t quo_tt; - u32_t counter; - u32_t total_duration; - s64_t start_timestamp; + uint8_t trans_time; + uint8_t remain_time; + uint8_t delay; + uint32_t quo_tt; + uint32_t counter; + uint32_t total_duration; + int64_t start_timestamp; BLE_MESH_ATOMIC_DEFINE(flag, BLE_MESH_TRANS_FLAG_MAX); struct k_delayed_work timer; }; struct bt_mesh_last_msg_info { - u8_t tid; - u16_t src; - u16_t dst; - s64_t timestamp; + uint8_t tid; + uint16_t src; + uint16_t dst; + int64_t timestamp; }; #define BLE_MESH_SERVER_RSP_BY_APP 0 @@ -99,31 +99,31 @@ struct bt_mesh_server_rsp_ctrl { * 6. If status_auto_rsp is set to BLE_MESH_SERVER_AUTO_RSP, then the response * of Server status messages will be replied by the server models; */ - u8_t get_auto_rsp : 1, /* Response for Client Get messages */ - set_auto_rsp : 1, /* Response for Client Set messages */ - status_auto_rsp : 1; /* Response for Server Status messages */ + uint8_t get_auto_rsp : 1, /* Response for Client Get messages */ + set_auto_rsp : 1, /* Response for Client Set messages */ + status_auto_rsp : 1; /* Response for Server Status messages */ }; -u8_t bt_mesh_get_default_trans_time(struct bt_mesh_model *model); +uint8_t bt_mesh_get_default_trans_time(struct bt_mesh_model *model); -int bt_mesh_get_light_lc_trans_time(struct bt_mesh_model *model, u8_t *trans_time); +int bt_mesh_get_light_lc_trans_time(struct bt_mesh_model *model, uint8_t *trans_time); int bt_mesh_server_get_optional(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, - u8_t *trans_time, u8_t *delay, + uint8_t *trans_time, uint8_t *delay, bool *optional); void bt_mesh_server_alloc_ctx(struct k_work *work); void bt_mesh_server_free_ctx(struct k_work *work); bool bt_mesh_is_server_recv_last_msg(struct bt_mesh_last_msg_info *last, - u8_t tid, u16_t src, u16_t dst, s64_t *now); + uint8_t tid, uint16_t src, uint16_t dst, int64_t *now); void bt_mesh_server_update_last_msg(struct bt_mesh_last_msg_info *last, - u8_t tid, u16_t src, u16_t dst, s64_t *now); + uint8_t tid, uint16_t src, uint16_t dst, int64_t *now); -struct net_buf_simple *bt_mesh_server_get_pub_msg(struct bt_mesh_model *model, u16_t msg_len); +struct net_buf_simple *bt_mesh_server_get_pub_msg(struct bt_mesh_model *model, uint16_t msg_len); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_models/server/include/state_binding.h b/components/bt/esp_ble_mesh/mesh_models/server/include/state_binding.h index c418192c2c..d65609b005 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/include/state_binding.h +++ b/components/bt/esp_ble_mesh/mesh_models/server/include/state_binding.h @@ -34,62 +34,62 @@ typedef enum { typedef union { struct { - u8_t onoff; + uint8_t onoff; } gen_onoff; struct { - s16_t level; + int16_t level; } gen_level; struct { - u8_t onpowerup; + uint8_t onpowerup; } gen_onpowerup; struct { - u16_t power; + uint16_t power; } gen_power_actual; struct { - u16_t lightness; + uint16_t lightness; } light_lightness_actual; struct { - u16_t lightness; + uint16_t lightness; } light_lightness_linear; struct { - u16_t lightness; + uint16_t lightness; } light_ctl_lightness; struct { - u16_t temperature; - s16_t delta_uv; + uint16_t temperature; + int16_t delta_uv; } light_ctl_temp_delta_uv; struct { - u16_t lightness; + uint16_t lightness; } light_hsl_lightness; struct { - u16_t hue; + uint16_t hue; } light_hsl_hue; struct { - u16_t saturation; + uint16_t saturation; } light_hsl_saturation; struct { - u16_t lightness; + uint16_t lightness; } light_xyl_lightness; struct { - u8_t onoff; + uint8_t onoff; } light_lc_light_onoff; } bt_mesh_server_state_value_t; -u16_t bt_mesh_convert_lightness_actual_to_linear(u16_t actual); +uint16_t bt_mesh_convert_lightness_actual_to_linear(uint16_t actual); -u16_t bt_mesh_convert_lightness_linear_to_actual(u16_t linear); +uint16_t bt_mesh_convert_lightness_linear_to_actual(uint16_t linear); -s16_t bt_mesh_convert_temperature_to_gen_level(u16_t temp, u16_t min, u16_t max); +int16_t bt_mesh_convert_temperature_to_gen_level(uint16_t temp, uint16_t min, uint16_t max); -u16_t bt_mesh_covert_gen_level_to_temperature(s16_t level, u16_t min, u16_t max); +uint16_t bt_mesh_covert_gen_level_to_temperature(int16_t level, uint16_t min, uint16_t max); -s16_t bt_mesh_convert_hue_to_level(u16_t hue); +int16_t bt_mesh_convert_hue_to_level(uint16_t hue); -u16_t bt_mesh_convert_level_to_hue(s16_t level); +uint16_t bt_mesh_convert_level_to_hue(int16_t level); -s16_t bt_mesh_convert_saturation_to_level(u16_t saturation); +int16_t bt_mesh_convert_saturation_to_level(uint16_t saturation); -u16_t bt_mesh_convert_level_to_saturation(s16_t level); +uint16_t bt_mesh_convert_level_to_saturation(int16_t level); int bt_mesh_update_binding_state(struct bt_mesh_model *model, bt_mesh_server_state_type_t type, diff --git a/components/bt/esp_ble_mesh/mesh_models/server/include/state_transition.h b/components/bt/esp_ble_mesh/mesh_models/server/include/state_transition.h index 5cb6da9b38..e7d1a4fb5e 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/include/state_transition.h +++ b/components/bt/esp_ble_mesh/mesh_models/server/include/state_transition.h @@ -24,42 +24,42 @@ void bt_mesh_server_calc_remain_time(struct bt_mesh_state_transition *transition /* APIs used to get server model transition time values */ void generic_onoff_tt_values(struct bt_mesh_gen_onoff_srv *srv, - u8_t trans_time, u8_t delay); + uint8_t trans_time, uint8_t delay); void generic_level_tt_values(struct bt_mesh_gen_level_srv *srv, - u8_t trans_time, u8_t delay); + uint8_t trans_time, uint8_t delay); void generic_power_level_tt_values(struct bt_mesh_gen_power_level_srv *srv, - u8_t trans_time, u8_t delay); + uint8_t trans_time, uint8_t delay); void light_lightness_actual_tt_values(struct bt_mesh_light_lightness_srv *srv, - u8_t trans_time, u8_t delay); + uint8_t trans_time, uint8_t delay); void light_lightness_linear_tt_values(struct bt_mesh_light_lightness_srv *srv, - u8_t trans_time, u8_t delay); + uint8_t trans_time, uint8_t delay); void light_ctl_tt_values(struct bt_mesh_light_ctl_srv *srv, - u8_t trans_time, u8_t delay); + uint8_t trans_time, uint8_t delay); void light_ctl_temp_tt_values(struct bt_mesh_light_ctl_temp_srv *srv, - u8_t trans_time, u8_t delay); + uint8_t trans_time, uint8_t delay); void light_hsl_tt_values(struct bt_mesh_light_hsl_srv *srv, - u8_t trans_time, u8_t delay); + uint8_t trans_time, uint8_t delay); void light_hsl_hue_tt_values(struct bt_mesh_light_hsl_hue_srv *srv, - u8_t trans_time, u8_t delay); + uint8_t trans_time, uint8_t delay); void light_hsl_sat_tt_values(struct bt_mesh_light_hsl_sat_srv *srv, - u8_t trans_time, u8_t delay); + uint8_t trans_time, uint8_t delay); void light_xyl_tt_values(struct bt_mesh_light_xyl_srv *srv, - u8_t trans_time, u8_t delay); + uint8_t trans_time, uint8_t delay); void light_lc_tt_values(struct bt_mesh_light_lc_srv *srv, - u8_t trans_time, u8_t delay); + uint8_t trans_time, uint8_t delay); -void scene_tt_values(struct bt_mesh_scene_srv *srv, u8_t trans_time, u8_t delay); +void scene_tt_values(struct bt_mesh_scene_srv *srv, uint8_t trans_time, uint8_t delay); /* Server model transition timer handlers */ diff --git a/components/bt/esp_ble_mesh/mesh_models/server/include/time_scene_server.h b/components/bt/esp_ble_mesh/mesh_models/server/include/time_scene_server.h index 6280bd76c5..845ea8f7d8 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/include/time_scene_server.h +++ b/components/bt/esp_ble_mesh/mesh_models/server/include/time_scene_server.h @@ -85,18 +85,18 @@ extern "C" { */ struct bt_mesh_time_state { struct { - u8_t tai_seconds[5]; - u8_t subsecond; - u8_t uncertainty; - u8_t time_zone_offset_curr; - u8_t time_zone_offset_new; - u8_t tai_zone_change[5]; - u16_t time_authority : 1, - tai_utc_delta_curr : 15; - u16_t tai_utc_delta_new : 15; - u8_t tai_delta_change[5]; + uint8_t tai_seconds[5]; + uint8_t subsecond; + uint8_t uncertainty; + uint8_t time_zone_offset_curr; + uint8_t time_zone_offset_new; + uint8_t tai_zone_change[5]; + uint16_t time_authority : 1, + tai_utc_delta_curr : 15; + uint16_t tai_utc_delta_new : 15; + uint8_t tai_delta_change[5]; } time; - u8_t time_role; + uint8_t time_role; }; struct bt_mesh_time_srv { @@ -112,8 +112,8 @@ struct bt_mesh_time_setup_srv { }; struct scene_register { - u16_t scene_number; - u8_t scene_type; /* Indicate the type of scene value */ + uint16_t scene_number; + uint8_t scene_type; /* Indicate the type of scene value */ /** * Scene value may use a union to represent later, the union contains * structures of all the model states which can be stored in a scene. @@ -140,7 +140,7 @@ struct scene_register { * is in progress. */ struct bt_mesh_scenes_state { - const u16_t scene_count; + const uint16_t scene_count; struct scene_register *scenes; /** @@ -163,7 +163,7 @@ struct bt_mesh_scenes_state { * When a scene transition is in progress, the value of the Current Scene * state shall be set to 0x0000. */ - u16_t current_scene; + uint16_t current_scene; /** * The Target Scene state is a 16-bit value that contains the target Scene @@ -180,10 +180,10 @@ struct bt_mesh_scenes_state { * When the scene transition is not in progress, the value of the Target Scene * state shall be set to 0x0000. */ - u16_t target_scene; + uint16_t target_scene; /* Indicate the status code for the last operation */ - u8_t status_code; + uint8_t status_code; /* Indicate if scene transition is in progress */ bool in_progress; @@ -204,21 +204,21 @@ struct bt_mesh_scene_setup_srv { }; struct schedule_register { - bool in_use; - u64_t year : 7, - month : 12, - day : 5, - hour : 5, - minute : 6, - second : 6, - day_of_week : 7, - action : 4, - trans_time : 8; - u16_t scene_number; + bool in_use; + uint64_t year : 7, + month : 12, + day : 5, + hour : 5, + minute : 6, + second : 6, + day_of_week : 7, + action : 4, + trans_time : 8; + uint16_t scene_number; }; struct bt_mesh_scheduler_state { - const u8_t schedule_count; + const uint8_t schedule_count; struct schedule_register *schedules; /* Up to 16 scheduled entries */ /** @@ -242,7 +242,7 @@ struct bt_mesh_scheduler_state { * For each event_queue item, it can use the following struct: * struct schedule_event { * sys_snode_t node; - * u8_t event_index; + * uint8_t event_index; * }; * * Also we need a "struct k_delayed_work track_timer" which can be used to @@ -264,126 +264,126 @@ struct bt_mesh_scheduler_setup_srv { typedef union { struct { - u8_t tai_seconds[5]; - u8_t subsecond; - u8_t uncertainty; - u16_t time_authority : 1; - u16_t tai_utc_delta_curr : 15; - u8_t time_zone_offset_curr; + uint8_t tai_seconds[5]; + uint8_t subsecond; + uint8_t uncertainty; + uint16_t time_authority : 1; + uint16_t tai_utc_delta_curr : 15; + uint8_t time_zone_offset_curr; } time_set; struct { - u8_t tai_seconds[5]; - u8_t subsecond; - u8_t uncertainty; - u16_t time_authority : 1; - u16_t tai_utc_delta_curr : 15; - u8_t time_zone_offset_curr; + uint8_t tai_seconds[5]; + uint8_t subsecond; + uint8_t uncertainty; + uint16_t time_authority : 1; + uint16_t tai_utc_delta_curr : 15; + uint8_t time_zone_offset_curr; } time_status; struct { - u8_t time_zone_offset_new; - u8_t tai_zone_change[5]; + uint8_t time_zone_offset_new; + uint8_t tai_zone_change[5]; } time_zone_set; struct { - u16_t tai_utc_delta_new : 15; - u8_t tai_delta_change[5]; + uint16_t tai_utc_delta_new : 15; + uint8_t tai_delta_change[5]; } tai_utc_delta_set; struct { - u8_t role; + uint8_t role; } time_role_set; struct { - u16_t scene_number; + uint16_t scene_number; } scene_store; struct { - u16_t scene_number; + uint16_t scene_number; } scene_recall; struct { - u16_t scene_number; + uint16_t scene_number; } scene_delete; struct { - u64_t index : 4, - year : 7, - month : 12, - day : 5, - hour : 5, - minute : 6, - second : 6, - day_of_week : 7, - action : 4, - trans_time : 8; - u16_t scene_number; + uint64_t index : 4, + year : 7, + month : 12, + day : 5, + hour : 5, + minute : 6, + second : 6, + day_of_week : 7, + action : 4, + trans_time : 8; + uint16_t scene_number; } scheduler_act_set; } bt_mesh_time_scene_server_state_change_t; typedef union { struct { - u8_t index; + uint8_t index; } scheduler_act_get; } bt_mesh_time_scene_server_recv_get_msg_t; typedef union { struct { - u8_t tai_seconds[5]; - u8_t subsecond; - u8_t uncertainty; - u16_t time_authority : 1; - u16_t tai_utc_delta : 15; - u8_t time_zone_offset; + uint8_t tai_seconds[5]; + uint8_t subsecond; + uint8_t uncertainty; + uint16_t time_authority : 1; + uint16_t tai_utc_delta : 15; + uint8_t time_zone_offset; } time_set; struct { - u8_t time_zone_offset_new; - u8_t tai_zone_change[5]; + uint8_t time_zone_offset_new; + uint8_t tai_zone_change[5]; } time_zone_set; struct { - u16_t tai_utc_delta_new : 15; - u16_t padding : 1; - u8_t tai_delta_change[5]; + uint16_t tai_utc_delta_new : 15; + uint16_t padding : 1; + uint8_t tai_delta_change[5]; } tai_utc_delta_set; struct { - u8_t time_role; + uint8_t time_role; } time_role_set; struct { - u16_t scene_number; + uint16_t scene_number; } scene_store; struct { - bool op_en; - u16_t scene_number; - u8_t tid; - u8_t trans_time; - u8_t delay; + bool op_en; + uint16_t scene_number; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; } scene_recall; struct { - u16_t scene_number; + uint16_t scene_number; } scene_delete; struct { - u64_t index : 4, - year : 7, - month : 12, - day : 5, - hour : 5, - minute : 6, - second : 6, - day_of_week : 7, - action : 4, - trans_time : 8; - u16_t scene_number; + uint64_t index : 4, + year : 7, + month : 12, + day : 5, + hour : 5, + minute : 6, + second : 6, + day_of_week : 7, + action : 4, + trans_time : 8; + uint16_t scene_number; } scheduler_act_set; } bt_mesh_time_scene_server_recv_set_msg_t; typedef union { struct { - u8_t tai_seconds[5]; - u8_t subsecond; - u8_t uncertainty; - u16_t time_authority : 1; - u16_t tai_utc_delta : 15; - u8_t time_zone_offset; + uint8_t tai_seconds[5]; + uint8_t subsecond; + uint8_t uncertainty; + uint16_t time_authority : 1; + uint16_t tai_utc_delta : 15; + uint8_t time_zone_offset; } time_status; } bt_mesh_time_scene_server_recv_status_msg_t; void bt_mesh_time_scene_server_lock(void); void bt_mesh_time_scene_server_unlock(void); -void scene_publish(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, u16_t opcode); +void scene_publish(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, uint16_t opcode); #ifdef __cplusplus } diff --git a/components/bt/esp_ble_mesh/mesh_models/server/lighting_server.c b/components/bt/esp_ble_mesh/mesh_models/server/lighting_server.c index c994b969b2..c579fa6a1c 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/lighting_server.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/lighting_server.c @@ -51,10 +51,10 @@ void bt_mesh_light_server_unlock(void) static void send_light_lightness_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - bool publish, u16_t opcode) + bool publish, uint16_t opcode) { struct net_buf_simple *msg = NULL; - u8_t length = 2 + 5; + uint8_t length = 2 + 5; if (ctx == NULL && publish == false) { BT_ERR("%s, Invalid parameter", __func__); @@ -145,7 +145,7 @@ static void light_lightness_get(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_lightness_srv *srv = model->user_data; - u16_t opcode = 0U; + uint16_t opcode = 0U; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -184,7 +184,7 @@ static void light_lightness_get(struct bt_mesh_model *model, return; } -void light_lightness_publish(struct bt_mesh_model *model, u16_t opcode) +void light_lightness_publish(struct bt_mesh_model *model, uint16_t opcode) { if (model->user_data == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -222,10 +222,10 @@ static void light_lightness_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_lightness_srv *srv = model->user_data; - u8_t tid = 0U, trans_time = 0U, delay = 0U; + uint8_t tid = 0U, trans_time = 0U, delay = 0U; bool optional = false; - u16_t actual = 0U; - s64_t now = 0; + uint16_t actual = 0U; + int64_t now = 0; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -249,7 +249,7 @@ static void light_lightness_set(struct bt_mesh_model *model, .lightness_set.delay = delay, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -287,7 +287,7 @@ static void light_lightness_set(struct bt_mesh_model *model, .lightness_set.lightness = srv->state->lightness_actual, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET) { send_light_lightness_status(model, ctx, false, BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_STATUS); @@ -334,10 +334,10 @@ static void light_lightness_linear_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_lightness_srv *srv = model->user_data; - u8_t tid = 0U, trans_time = 0U, delay = 0U; + uint8_t tid = 0U, trans_time = 0U, delay = 0U; bool optional = false; - u16_t linear = 0U; - s64_t now = 0; + uint16_t linear = 0U; + int64_t now = 0; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -361,7 +361,7 @@ static void light_lightness_linear_set(struct bt_mesh_model *model, .lightness_linear_set.delay = delay, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -392,7 +392,7 @@ static void light_lightness_linear_set(struct bt_mesh_model *model, .lightness_linear_set.lightness = srv->state->lightness_actual, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET) { send_light_lightness_status(model, ctx, false, BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_STATUS); @@ -430,7 +430,7 @@ static void light_lightness_default_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_lightness_setup_srv *srv = model->user_data; - u16_t lightness = 0U; + uint16_t lightness = 0U; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -445,7 +445,7 @@ static void light_lightness_default_set(struct bt_mesh_model *model, .lightness_default_set.lightness = lightness, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -456,7 +456,7 @@ static void light_lightness_default_set(struct bt_mesh_model *model, .lightness_default_set.lightness = lightness, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); } if (ctx->recv_op == BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET) { @@ -472,7 +472,7 @@ static void light_lightness_range_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_lightness_setup_srv *srv = model->user_data; - u16_t range_min = 0U, range_max = 0U; + uint16_t range_min = 0U, range_max = 0U; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -495,7 +495,7 @@ static void light_lightness_range_set(struct bt_mesh_model *model, .lightness_range_set.range_max = range_max, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -534,7 +534,7 @@ static void light_lightness_range_set(struct bt_mesh_model *model, .lightness_range_set.range_max = srv->state->lightness_range_max, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET) { send_light_lightness_status(model, ctx, false, BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_STATUS); @@ -548,10 +548,10 @@ static void light_lightness_range_set(struct bt_mesh_model *model, static void send_light_ctl_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - bool publish, u16_t opcode) + bool publish, uint16_t opcode) { struct net_buf_simple *msg = NULL; - u8_t length = 2 + 9; + uint8_t length = 2 + 9; if (ctx == NULL && publish == false) { BT_ERR("%s, Invalid parameter", __func__); @@ -646,7 +646,7 @@ static void light_ctl_get(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_server_rsp_ctrl *rsp_ctrl = NULL; - u16_t opcode = 0U; + uint16_t opcode = 0U; if (model->user_data == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -706,7 +706,7 @@ static void light_ctl_get(struct bt_mesh_model *model, return; } -void light_ctl_publish(struct bt_mesh_model *model, u16_t opcode) +void light_ctl_publish(struct bt_mesh_model *model, uint16_t opcode) { if (model->user_data == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -752,11 +752,11 @@ static void light_ctl_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_ctl_srv *srv = model->user_data; - u16_t lightness = 0U, temperature = 0U; - u8_t tid = 0U, trans_time = 0U, delay = 0U; - s16_t delta_uv = 0; + uint16_t lightness = 0U, temperature = 0U; + uint8_t tid = 0U, trans_time = 0U, delay = 0U; + int16_t delta_uv = 0; bool optional = false; - s64_t now = 0; + int64_t now = 0; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -765,7 +765,7 @@ static void light_ctl_set(struct bt_mesh_model *model, lightness = net_buf_simple_pull_le16(buf); temperature = 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 (temperature < BLE_MESH_TEMPERATURE_MIN || temperature > BLE_MESH_TEMPERATURE_MAX) { @@ -789,7 +789,7 @@ static void light_ctl_set(struct bt_mesh_model *model, .ctl_set.delay = delay, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -831,7 +831,7 @@ static void light_ctl_set(struct bt_mesh_model *model, .ctl_set.delta_uv = srv->state->delta_uv, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_LIGHT_CTL_SET) { send_light_ctl_status(model, ctx, false, BLE_MESH_MODEL_OP_LIGHT_CTL_STATUS); @@ -871,8 +871,8 @@ static void light_ctl_default_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_ctl_setup_srv *srv = model->user_data; - u16_t lightness = 0U, temperature = 0U; - s16_t delta_uv = 0; + uint16_t lightness = 0U, temperature = 0U; + int16_t delta_uv = 0; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -881,7 +881,7 @@ static void light_ctl_default_set(struct bt_mesh_model *model, lightness = net_buf_simple_pull_le16(buf); temperature = 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); if (temperature < BLE_MESH_TEMPERATURE_MIN || temperature > BLE_MESH_TEMPERATURE_MAX) { BT_ERR("Invalid temperature 0x%04x", temperature); @@ -896,7 +896,7 @@ static void light_ctl_default_set(struct bt_mesh_model *model, .ctl_default_set.delta_uv = delta_uv, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -920,7 +920,7 @@ static void light_ctl_default_set(struct bt_mesh_model *model, .ctl_default_set.delta_uv = srv->state->delta_uv_default, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET) { send_light_ctl_status(model, ctx, false, BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_STATUS); @@ -935,7 +935,7 @@ static void light_ctl_temp_range_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_ctl_setup_srv *srv = model->user_data; - u16_t min = 0U, max = 0U; + uint16_t min = 0U, max = 0U; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -961,7 +961,7 @@ static void light_ctl_temp_range_set(struct bt_mesh_model *model, .ctl_temp_range_set.range_max = max, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -986,7 +986,7 @@ static void light_ctl_temp_range_set(struct bt_mesh_model *model, .ctl_temp_range_set.range_max = srv->state->temperature_range_max, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET) { send_light_ctl_status(model, ctx, false, BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_STATUS); @@ -1001,11 +1001,11 @@ static void light_ctl_temp_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_ctl_temp_srv *srv = model->user_data; - u8_t tid = 0U, trans_time = 0U, delay = 0U; - u16_t temperature = 0U; - s16_t delta_uv = 0; + uint8_t tid = 0U, trans_time = 0U, delay = 0U; + uint16_t temperature = 0U; + int16_t delta_uv = 0; bool optional = false; - s64_t now = 0; + int64_t now = 0; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -1013,7 +1013,7 @@ static void light_ctl_temp_set(struct bt_mesh_model *model, } temperature = 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 (temperature < BLE_MESH_TEMPERATURE_MIN || temperature > BLE_MESH_TEMPERATURE_MAX) { @@ -1036,7 +1036,7 @@ static void light_ctl_temp_set(struct bt_mesh_model *model, .ctl_temp_set.delay = delay, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -1075,7 +1075,7 @@ static void light_ctl_temp_set(struct bt_mesh_model *model, .ctl_temp_set.delta_uv = srv->state->delta_uv, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET) { send_light_ctl_status(model, ctx, false, BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_STATUS); @@ -1113,10 +1113,10 @@ static void light_ctl_temp_set(struct bt_mesh_model *model, static void send_light_hsl_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - bool publish, u16_t opcode) + bool publish, uint16_t opcode) { struct net_buf_simple *msg = NULL; - u8_t length = 2 + 9; + uint8_t length = 2 + 9; if (ctx == NULL && publish == false) { BT_ERR("%s, Invalid parameter", __func__); @@ -1232,7 +1232,7 @@ static void light_hsl_get(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_server_rsp_ctrl *rsp_ctrl = NULL; - u16_t opcode = 0U; + uint16_t opcode = 0U; if (model->user_data == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -1307,7 +1307,7 @@ static void light_hsl_get(struct bt_mesh_model *model, return; } -void light_hsl_publish(struct bt_mesh_model *model, u16_t opcode) +void light_hsl_publish(struct bt_mesh_model *model, uint16_t opcode) { if (model->user_data == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -1361,10 +1361,10 @@ static void light_hsl_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_hsl_srv *srv = model->user_data; - u16_t lightness = 0U, hue = 0U, saturation = 0U; - u8_t tid = 0U, trans_time = 0U, delay = 0U; + uint16_t lightness = 0U, hue = 0U, saturation = 0U; + uint8_t tid = 0U, trans_time = 0U, delay = 0U; bool optional = false; - s64_t now = 0; + int64_t now = 0; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -1392,7 +1392,7 @@ static void light_hsl_set(struct bt_mesh_model *model, .hsl_set.delay = delay, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -1439,7 +1439,7 @@ static void light_hsl_set(struct bt_mesh_model *model, .hsl_set.saturation = srv->state->saturation, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_LIGHT_HSL_SET) { send_light_hsl_status(model, ctx, false, BLE_MESH_MODEL_OP_LIGHT_HSL_STATUS); @@ -1479,7 +1479,7 @@ static void light_hsl_default_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_hsl_setup_srv *srv = model->user_data; - u16_t lightness = 0U, hue = 0U, saturation = 0U; + uint16_t lightness = 0U, hue = 0U, saturation = 0U; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -1498,7 +1498,7 @@ static void light_hsl_default_set(struct bt_mesh_model *model, .hsl_default_set.saturation = saturation, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -1524,7 +1524,7 @@ static void light_hsl_default_set(struct bt_mesh_model *model, .hsl_default_set.saturation = srv->state->saturation_default, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET) { send_light_hsl_status(model, ctx, false, BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_STATUS); @@ -1539,7 +1539,7 @@ static void light_hsl_range_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_hsl_setup_srv *srv = model->user_data; - u16_t hue_min = 0U, hue_max = 0U, saturation_min = 0U, saturation_max = 0U; + uint16_t hue_min = 0U, hue_max = 0U, saturation_min = 0U, saturation_max = 0U; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -1572,7 +1572,7 @@ static void light_hsl_range_set(struct bt_mesh_model *model, .hsl_range_set.sat_range_max = saturation_max, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -1589,7 +1589,7 @@ static void light_hsl_range_set(struct bt_mesh_model *model, .hsl_range_set.sat_range_max = srv->state->saturation_range_max, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET) { send_light_hsl_status(model, ctx, false, BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_STATUS); @@ -1604,10 +1604,10 @@ static void light_hsl_hue_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_hsl_hue_srv *srv = model->user_data; - u8_t tid = 0U, trans_time = 0U, delay = 0U; + uint8_t tid = 0U, trans_time = 0U, delay = 0U; bool optional = false; - u16_t hue = 0U; - s64_t now = 0; + uint16_t hue = 0U; + int64_t now = 0; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -1631,7 +1631,7 @@ static void light_hsl_hue_set(struct bt_mesh_model *model, .hsl_hue_set.delay = delay, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -1667,7 +1667,7 @@ static void light_hsl_hue_set(struct bt_mesh_model *model, .hsl_hue_set.hue = srv->state->hue, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET) { send_light_hsl_status(model, ctx, false, BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_STATUS); @@ -1705,10 +1705,10 @@ static void light_hsl_sat_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_hsl_sat_srv *srv = model->user_data; - u8_t tid = 0U, trans_time = 0U, delay = 0U; - u16_t saturation = 0U; + uint8_t tid = 0U, trans_time = 0U, delay = 0U; + uint16_t saturation = 0U; bool optional = false; - s64_t now = 0; + int64_t now = 0; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -1732,7 +1732,7 @@ static void light_hsl_sat_set(struct bt_mesh_model *model, .hsl_saturation_set.delay = delay, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -1768,7 +1768,7 @@ static void light_hsl_sat_set(struct bt_mesh_model *model, .hsl_saturation_set.saturation = srv->state->saturation, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET) { send_light_hsl_status(model, ctx, false, BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_STATUS); @@ -1805,10 +1805,10 @@ static void light_hsl_sat_set(struct bt_mesh_model *model, static void send_light_xyl_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - bool publish, u16_t opcode) + bool publish, uint16_t opcode) { struct net_buf_simple *msg = NULL; - u8_t length = 2 + 9; + uint8_t length = 2 + 9; if (ctx == NULL && publish == false) { BT_ERR("%s, Invalid parameter", __func__); @@ -1904,7 +1904,7 @@ static void light_xyl_get(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_xyl_srv *srv = model->user_data; - u16_t opcode = 0U; + uint16_t opcode = 0U; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -1940,7 +1940,7 @@ static void light_xyl_get(struct bt_mesh_model *model, return; } -void light_xyl_publish(struct bt_mesh_model *model, u16_t opcode) +void light_xyl_publish(struct bt_mesh_model *model, uint16_t opcode) { if (model->user_data == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -1978,10 +1978,10 @@ static void light_xyl_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_xyl_srv *srv = model->user_data; - u8_t tid = 0U, trans_time = 0U, delay = 0U; - u16_t lightness = 0U, x = 0U, y = 0U; + uint8_t tid = 0U, trans_time = 0U, delay = 0U; + uint16_t lightness = 0U, x = 0U, y = 0U; bool optional = false; - s64_t now = 0; + int64_t now = 0; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -2009,7 +2009,7 @@ static void light_xyl_set(struct bt_mesh_model *model, .xyl_set.delay = delay, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -2056,7 +2056,7 @@ static void light_xyl_set(struct bt_mesh_model *model, .xyl_set.y = srv->state->y, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_LIGHT_XYL_SET) { send_light_xyl_status(model, ctx, false, BLE_MESH_MODEL_OP_LIGHT_XYL_STATUS); @@ -2096,7 +2096,7 @@ static void light_xyl_default_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_xyl_setup_srv *srv = model->user_data; - u16_t lightness = 0U, x = 0U, y = 0U; + uint16_t lightness = 0U, x = 0U, y = 0U; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -2115,7 +2115,7 @@ static void light_xyl_default_set(struct bt_mesh_model *model, .xyl_default_set.y = y, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -2141,7 +2141,7 @@ static void light_xyl_default_set(struct bt_mesh_model *model, .xyl_default_set.y = srv->state->y_default, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET) { send_light_xyl_status(model, ctx, false, BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_STATUS); @@ -2156,7 +2156,7 @@ static void light_xyl_range_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_xyl_setup_srv *srv = model->user_data; - u16_t x_min = 0U, x_max = 0U, y_min = 0U, y_max = 0U; + uint16_t x_min = 0U, x_max = 0U, y_min = 0U, y_max = 0U; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -2189,7 +2189,7 @@ static void light_xyl_range_set(struct bt_mesh_model *model, .xyl_range_set.y_range_max = y_max, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -2206,7 +2206,7 @@ static void light_xyl_range_set(struct bt_mesh_model *model, .xyl_range_set.y_range_max = srv->state->y_range_max, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET) { send_light_xyl_status(model, ctx, false, BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_STATUS); @@ -2219,11 +2219,11 @@ static void light_xyl_range_set(struct bt_mesh_model *model, /* Light LC Server/Setup Server message handlers */ static void send_light_lc_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - bool publish, u16_t opcode) + bool publish, uint16_t opcode) { struct bt_mesh_light_lc_srv *srv = model->user_data; struct net_buf_simple *msg = NULL; - u8_t length = 2 + 3; + uint8_t length = 2 + 3; if (ctx == NULL && publish == false) { BT_ERR("%s, Invalid parameter", __func__); @@ -2281,7 +2281,7 @@ static void light_lc_get(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_lc_srv *srv = model->user_data; - u16_t opcode = 0U; + uint16_t opcode = 0U; if (srv == NULL || srv->lc == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -2314,7 +2314,7 @@ static void light_lc_get(struct bt_mesh_model *model, return; } -void light_lc_publish(struct bt_mesh_model *model, u16_t opcode) +void light_lc_publish(struct bt_mesh_model *model, uint16_t opcode) { struct bt_mesh_light_lc_srv *srv = model->user_data; @@ -2332,7 +2332,7 @@ static void light_lc_mode_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_lc_srv *srv = model->user_data; - u8_t mode = 0U; + uint8_t mode = 0U; if (srv == NULL || srv->lc == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -2351,7 +2351,7 @@ static void light_lc_mode_set(struct bt_mesh_model *model, .lc_mode_set.mode = mode, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -2361,7 +2361,7 @@ static void light_lc_mode_set(struct bt_mesh_model *model, .lc_mode_set.mode = srv->lc->state.mode, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET) { send_light_lc_status(model, ctx, false, BLE_MESH_MODEL_OP_LIGHT_LC_MODE_STATUS); @@ -2376,7 +2376,7 @@ static void light_lc_om_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_lc_srv *srv = model->user_data; - u8_t om = 0U; + uint8_t om = 0U; if (srv == NULL || srv->lc == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -2395,7 +2395,7 @@ static void light_lc_om_set(struct bt_mesh_model *model, .lc_om_set.mode = om, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -2405,7 +2405,7 @@ static void light_lc_om_set(struct bt_mesh_model *model, .lc_om_set.mode = srv->lc->state.occupancy_mode, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET) { send_light_lc_status(model, ctx, false, BLE_MESH_MODEL_OP_LIGHT_LC_OM_STATUS); @@ -2420,10 +2420,10 @@ static void light_lc_light_onoff_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_lc_srv *srv = model->user_data; - u8_t tid = 0U, trans_time = 0U, delay = 0U; + uint8_t tid = 0U, trans_time = 0U, delay = 0U; bool optional = false; - u8_t onoff = 0U; - s64_t now = 0; + uint8_t onoff = 0U; + int64_t now = 0; if (srv == NULL || srv->lc == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -2447,7 +2447,7 @@ static void light_lc_light_onoff_set(struct bt_mesh_model *model, .lc_light_onoff_set.delay = delay, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -2474,7 +2474,7 @@ static void light_lc_light_onoff_set(struct bt_mesh_model *model, .lc_light_onoff_set.onoff = srv->lc->state.light_onoff, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET) { send_light_lc_status(model, ctx, false, BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_STATUS); @@ -2538,8 +2538,8 @@ static void light_lc_sensor_status(struct bt_mesh_model *model, */ struct bt_mesh_light_lc_srv *srv = model->user_data; bt_mesh_light_server_state_change_t change = {0}; - u16_t mpid = 0U, prop_id = 0U; - u8_t length = 0U; + uint16_t mpid = 0U, prop_id = 0U; + uint8_t length = 0U; if (srv == NULL || srv->lc == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -2551,18 +2551,18 @@ static void light_lc_sensor_status(struct bt_mesh_model *model, .sensor_status.data = buf, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_STATUS_MSG, model, ctx, (const u8_t *)&status, sizeof(status)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_STATUS_MSG, model, ctx, (const uint8_t *)&status, sizeof(status)); return; } mpid = net_buf_simple_pull_le16(buf); if (mpid & BIT(0)) { - length = (u8_t)((mpid & 0xff) >> 1); - u8_t msb = net_buf_simple_pull_u8(buf); - prop_id = (u16_t)(msb << 8) | (u16_t)(mpid >> 8); + length = (uint8_t)((mpid & 0xff) >> 1); + uint8_t msb = net_buf_simple_pull_u8(buf); + prop_id = (uint16_t)(msb << 8) | (uint16_t)(mpid >> 8); } else { - length = (u8_t)((mpid & 0x1f) >> 1); - prop_id = (u16_t)(mpid >> 5); + length = (uint8_t)((mpid & 0x1f) >> 1); + prop_id = (uint16_t)(mpid >> 5); } change.sensor_status.property_id = prop_id; @@ -2573,13 +2573,13 @@ static void light_lc_sensor_status(struct bt_mesh_model *model, BT_WARN("Invalid Motion Sensed Property length %d", length); return; } - u8_t val = net_buf_simple_pull_u8(buf); + uint8_t val = net_buf_simple_pull_u8(buf); if (val > 0) { srv->lc->state.occupancy = BLE_MESH_STATE_ON; change.sensor_status.state.occupancy = srv->lc->state.occupancy; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); } break; } @@ -2588,13 +2588,13 @@ static void light_lc_sensor_status(struct bt_mesh_model *model, BT_WARN("Invalid Motion Sensed Property length %d", length); return; } - u16_t val = net_buf_simple_pull_le16(buf); + uint16_t val = net_buf_simple_pull_le16(buf); if (val > 0) { srv->lc->state.occupancy = BLE_MESH_STATE_ON; change.sensor_status.state.occupancy = srv->lc->state.occupancy; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); } break; } @@ -2603,13 +2603,13 @@ static void light_lc_sensor_status(struct bt_mesh_model *model, BT_WARN("Invalid Motion Sensed Property length %d", length); return; } - u8_t val = net_buf_simple_pull_u8(buf); + uint8_t val = net_buf_simple_pull_u8(buf); if (val > 0) { srv->lc->state.occupancy = BLE_MESH_STATE_ON; change.sensor_status.state.occupancy = srv->lc->state.occupancy; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); } break; } @@ -2618,14 +2618,14 @@ static void light_lc_sensor_status(struct bt_mesh_model *model, BT_WARN("Invalid Motion Sensed Property length %d", length); return; } - u16_t val = net_buf_simple_pull_le16(buf); + uint16_t val = net_buf_simple_pull_le16(buf); if (val <= srv->lc->prop_state.time_occupancy_delay) { srv->lc->prop_state.set_occupancy_to_1_delay = srv->lc->prop_state.time_occupancy_delay - val; change.sensor_status.state.set_occupancy_to_1_delay = srv->lc->prop_state.set_occupancy_to_1_delay; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); } break; } @@ -2640,13 +2640,13 @@ static void light_lc_sensor_status(struct bt_mesh_model *model, BT_WARN("Invalid Motion Sensed Property length %d", buf->len); return; } - u16_t lsb = net_buf_simple_pull_le16(buf); - u8_t msb = net_buf_simple_pull_u8(buf); + uint16_t lsb = net_buf_simple_pull_le16(buf); + uint8_t msb = net_buf_simple_pull_u8(buf); srv->lc->state.ambient_luxlevel = (msb << 16) | lsb; change.sensor_status.state.ambient_luxlevel = srv->lc->state.ambient_luxlevel; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); break; } default: @@ -2654,72 +2654,72 @@ static void light_lc_sensor_status(struct bt_mesh_model *model, } } -static u8_t *get_light_lc_prop_val(struct bt_mesh_model *model, u16_t prop_id) +static uint8_t *get_light_lc_prop_val(struct bt_mesh_model *model, uint16_t prop_id) { struct bt_mesh_light_lc_setup_srv *srv = model->user_data; - u8_t *val = NULL; + uint8_t *val = NULL; switch (prop_id) { case BLE_MESH_LIGHT_CONTROL_TIME_OCCUPANCY_DELAY: - val = (u8_t *)&srv->lc->prop_state.time_occupancy_delay; + val = (uint8_t *)&srv->lc->prop_state.time_occupancy_delay; break; case BLE_MESH_LIGHT_CONTROL_TIME_FADE_ON: - val = (u8_t *)&srv->lc->prop_state.time_fade_on; + val = (uint8_t *)&srv->lc->prop_state.time_fade_on; break; case BLE_MESH_LIGHT_CONTROL_TIME_RUN_ON: - val = (u8_t *)&srv->lc->prop_state.time_run_on; + val = (uint8_t *)&srv->lc->prop_state.time_run_on; break; case BLE_MESH_LIGHT_CONTROL_TIME_FADE: - val = (u8_t *)&srv->lc->prop_state.time_fade; + val = (uint8_t *)&srv->lc->prop_state.time_fade; break; case BLE_MESH_LIGHT_CONTROL_TIME_PROLONG: - val = (u8_t *)&srv->lc->prop_state.time_prolong; + val = (uint8_t *)&srv->lc->prop_state.time_prolong; break; case BLE_MESH_LIGHT_CONTROL_TIME_FADE_STANDBY_AUTO: - val = (u8_t *)&srv->lc->prop_state.time_fade_standby_auto; + val = (uint8_t *)&srv->lc->prop_state.time_fade_standby_auto; break; case BLE_MESH_LIGHT_CONTROL_TIME_FADE_STANDBY_MANUAL: - val = (u8_t *)&srv->lc->prop_state.time_fade_standby_manual; + val = (uint8_t *)&srv->lc->prop_state.time_fade_standby_manual; break; case BLE_MESH_LIGHT_CONTROL_LIGHTNESS_ON: - val = (u8_t *)&srv->lc->prop_state.lightness_on; + val = (uint8_t *)&srv->lc->prop_state.lightness_on; break; case BLE_MESH_LIGHT_CONTROL_LIGHTNESS_PROLONG: - val = (u8_t *)&srv->lc->prop_state.lightness_prolong; + val = (uint8_t *)&srv->lc->prop_state.lightness_prolong; break; case BLE_MESH_LIGHT_CONTROL_LIGHTNESS_STANDBY: - val = (u8_t *)&srv->lc->prop_state.lightness_standby; + val = (uint8_t *)&srv->lc->prop_state.lightness_standby; break; case BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_ON: - val = (u8_t *)&srv->lc->prop_state.ambient_luxlevel_on; + val = (uint8_t *)&srv->lc->prop_state.ambient_luxlevel_on; break; case BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_PROLONG: - val = (u8_t *)&srv->lc->prop_state.ambient_luxlevel_prolong; + val = (uint8_t *)&srv->lc->prop_state.ambient_luxlevel_prolong; break; case BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_STANDBY: - val = (u8_t *)&srv->lc->prop_state.ambient_luxlevel_standby; + val = (uint8_t *)&srv->lc->prop_state.ambient_luxlevel_standby; break; case BLE_MESH_LIGHT_CONTROL_REGULATOR_KIU: - val = (u8_t *)&srv->lc->prop_state.regulator_kiu; + val = (uint8_t *)&srv->lc->prop_state.regulator_kiu; break; case BLE_MESH_LIGHT_CONTROL_REGULATOR_KID: - val = (u8_t *)&srv->lc->prop_state.regulator_kid; + val = (uint8_t *)&srv->lc->prop_state.regulator_kid; break; case BLE_MESH_LIGHT_CONTROL_REGULATOR_KPU: - val = (u8_t *)&srv->lc->prop_state.regulator_kpu; + val = (uint8_t *)&srv->lc->prop_state.regulator_kpu; break; case BLE_MESH_LIGHT_CONTROL_REGULATOR_KPD: - val = (u8_t *)&srv->lc->prop_state.regulator_kpd; + val = (uint8_t *)&srv->lc->prop_state.regulator_kpd; break; case BLE_MESH_LIGHT_CONTROL_REGULATOR_ACCURACY: - val = (u8_t *)&srv->lc->prop_state.regulator_accuracy; + val = (uint8_t *)&srv->lc->prop_state.regulator_accuracy; break; } return val; } -u8_t *bt_mesh_get_lc_prop_value(struct bt_mesh_model *model, u16_t prop_id) +uint8_t *bt_mesh_get_lc_prop_value(struct bt_mesh_model *model, uint16_t prop_id) { if (model == NULL) { BT_ERR("%s, Invalid parameter", __func__); @@ -2731,11 +2731,11 @@ u8_t *bt_mesh_get_lc_prop_value(struct bt_mesh_model *model, u16_t prop_id) static void send_light_lc_prop_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - u16_t prop_id, bool publish) + uint16_t prop_id, bool publish) { struct net_buf_simple *msg = NULL; - u8_t length = 1 + 2 + 4; - u8_t *prop_val = NULL; + uint8_t length = 1 + 2 + 4; + uint8_t *prop_val = NULL; prop_val = get_light_lc_prop_val(model, prop_id); if (prop_val == NULL) { @@ -2774,7 +2774,7 @@ static void light_lc_prop_get(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_lc_setup_srv *srv = model->user_data; - u16_t prop_id = 0U; + uint16_t prop_id = 0U; if (srv == NULL || srv->lc == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -2793,7 +2793,7 @@ static void light_lc_prop_get(struct bt_mesh_model *model, .lc_property_get.id = net_buf_simple_pull_le16(buf), }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_GET_MSG, model, ctx, (const u8_t *)&get, sizeof(get)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_GET_MSG, model, ctx, (const uint8_t *)&get, sizeof(get)); return; } @@ -2806,8 +2806,8 @@ static void light_lc_prop_set(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_light_lc_setup_srv *srv = model->user_data; - u8_t *prop_val = NULL, expect_len = 0U; - u16_t prop_id = 0U; + uint8_t *prop_val = NULL, expect_len = 0U; + uint16_t prop_id = 0U; if (srv == NULL || srv->lc == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -2826,7 +2826,7 @@ static void light_lc_prop_set(struct bt_mesh_model *model, .lc_property_set.value = buf, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -2850,7 +2850,7 @@ static void light_lc_prop_set(struct bt_mesh_model *model, .lc_property_set.value = buf, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET) { send_light_lc_prop_status(model, ctx, prop_id, false); diff --git a/components/bt/esp_ble_mesh/mesh_models/server/sensor_server.c b/components/bt/esp_ble_mesh/mesh_models/server/sensor_server.c index aa07242781..d8d00c6b15 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/sensor_server.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/sensor_server.c @@ -25,19 +25,19 @@ #if CONFIG_BLE_MESH_SENSOR_SERVER -static void update_sensor_periodic_pub(struct bt_mesh_model *model, u16_t prop_id); +static void update_sensor_periodic_pub(struct bt_mesh_model *model, uint16_t prop_id); /* message handlers (Start) */ /* Sensor Server & Sensor Setup Server message handlers */ static void send_sensor_descriptor_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - u16_t prop_id, bool get_all) + struct bt_mesh_msg_ctx *ctx, + uint16_t prop_id, bool get_all) { struct bt_mesh_sensor_srv *srv = model->user_data; struct bt_mesh_sensor_state *state = NULL; struct net_buf_simple *msg = NULL; - u16_t total_len = 5U; + uint16_t total_len = 5U; int i; msg = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN)); @@ -99,12 +99,12 @@ static void send_sensor_descriptor_status(struct bt_mesh_model *model, static void send_sensor_data_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - u16_t prop_id, bool get_all) + uint16_t prop_id, bool get_all) { struct bt_mesh_sensor_srv *srv = model->user_data; struct bt_mesh_sensor_state *state = NULL; struct net_buf_simple *msg = NULL; - u16_t total_len = 5U; + uint16_t total_len = 5U; int i; msg = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN)); @@ -119,8 +119,8 @@ static void send_sensor_data_status(struct bt_mesh_model *model, for (i = 0; i < srv->state_count; i++) { state = &srv->states[i]; if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID) { - u8_t mpid_len = (state->sensor_data.format == SENSOR_DATA_FORMAT_A) ? - SENSOR_DATA_FORMAT_A_MPID_LEN : SENSOR_DATA_FORMAT_B_MPID_LEN; + uint8_t mpid_len = (state->sensor_data.format == SENSOR_DATA_FORMAT_A) ? + SENSOR_DATA_FORMAT_A_MPID_LEN : SENSOR_DATA_FORMAT_B_MPID_LEN; total_len += (mpid_len + (state->sensor_data.raw_value ? state->sensor_data.raw_value->len : 0)); if (total_len > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN)) { @@ -129,11 +129,12 @@ static void send_sensor_data_status(struct bt_mesh_model *model, break; } if (state->sensor_data.format == SENSOR_DATA_FORMAT_A) { - u16_t mpid = ((state->sensor_property_id & BIT_MASK(11)) << 5) | - ((state->sensor_data.length & BIT_MASK(4)) << 1) | state->sensor_data.format; + uint16_t mpid = ((state->sensor_property_id & BIT_MASK(11)) << 5) | + ((state->sensor_data.length & BIT_MASK(4)) << 1) | + state->sensor_data.format; net_buf_simple_add_le16(msg, mpid); } else if (state->sensor_data.format == SENSOR_DATA_FORMAT_B) { - u8_t mpid = (state->sensor_data.length << 1) | state->sensor_data.format; + uint8_t mpid = (state->sensor_data.length << 1) | state->sensor_data.format; net_buf_simple_add_u8(msg, mpid); net_buf_simple_add_le16(msg, state->sensor_property_id); } @@ -147,8 +148,8 @@ static void send_sensor_data_status(struct bt_mesh_model *model, state = &srv->states[i]; if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID && state->sensor_property_id == prop_id) { - u8_t mpid_len = (state->sensor_data.format == SENSOR_DATA_FORMAT_A) ? - SENSOR_DATA_FORMAT_A_MPID_LEN : SENSOR_DATA_FORMAT_B_MPID_LEN; + uint8_t mpid_len = (state->sensor_data.format == SENSOR_DATA_FORMAT_A) ? + SENSOR_DATA_FORMAT_A_MPID_LEN : SENSOR_DATA_FORMAT_B_MPID_LEN; total_len += (mpid_len + (state->sensor_data.raw_value ? state->sensor_data.raw_value->len : 0)); if (total_len > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN)) { @@ -157,12 +158,12 @@ static void send_sensor_data_status(struct bt_mesh_model *model, break; } if (state->sensor_data.format == SENSOR_DATA_FORMAT_A) { - u16_t mpid = ((state->sensor_property_id & BIT_MASK(11)) << 5) | - ((state->sensor_data.length & BIT_MASK(4)) << 1) | - state->sensor_data.format; + uint16_t mpid = ((state->sensor_property_id & BIT_MASK(11)) << 5) | + ((state->sensor_data.length & BIT_MASK(4)) << 1) | + state->sensor_data.format; net_buf_simple_add_le16(msg, mpid); } else if (state->sensor_data.format == SENSOR_DATA_FORMAT_B) { - u8_t mpid = (state->sensor_data.length << 1) | state->sensor_data.format; + uint8_t mpid = (state->sensor_data.length << 1) | state->sensor_data.format; net_buf_simple_add_u8(msg, mpid); net_buf_simple_add_le16(msg, state->sensor_property_id); } @@ -175,7 +176,7 @@ static void send_sensor_data_status(struct bt_mesh_model *model, } if (i == srv->state_count) { BT_WARN("Sensor Property ID 0x%04x not exists", prop_id); - u8_t mpid = (SENSOR_DATA_ZERO_LEN << 1) | SENSOR_DATA_FORMAT_B; + uint8_t mpid = (SENSOR_DATA_ZERO_LEN << 1) | SENSOR_DATA_FORMAT_B; net_buf_simple_add_u8(msg, mpid); net_buf_simple_add_le16(msg, prop_id); } @@ -188,12 +189,12 @@ static void send_sensor_data_status(struct bt_mesh_model *model, static void send_sensor_cadence_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - u16_t prop_id, bool publish) + uint16_t prop_id, bool publish) { struct bt_mesh_sensor_setup_srv *srv = model->user_data; struct bt_mesh_sensor_state *state = NULL; struct net_buf_simple *msg = NULL; - u16_t length = 0U; + uint16_t length = 0U; int i; for (i = 0; i < srv->state_count; i++) { @@ -289,13 +290,13 @@ static void send_sensor_cadence_status(struct bt_mesh_model *model, static void send_sensor_settings_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - u16_t prop_id) + uint16_t prop_id) { struct bt_mesh_sensor_setup_srv *srv = model->user_data; struct bt_mesh_sensor_state *state = NULL; struct sensor_setting *item = NULL; struct net_buf_simple *msg = NULL; - u16_t total_len = 7U; + uint16_t total_len = 7U; int i, j; msg = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN)); @@ -337,7 +338,7 @@ static void send_sensor_settings_status(struct bt_mesh_model *model, } static struct sensor_setting *find_sensor_setting(struct bt_mesh_model *model, - u16_t prop_id, u16_t set_prop_id) + uint16_t prop_id, uint16_t set_prop_id) { struct bt_mesh_sensor_setup_srv *srv = model->user_data; struct bt_mesh_sensor_state *state = NULL; @@ -363,12 +364,12 @@ static struct sensor_setting *find_sensor_setting(struct bt_mesh_model *model, } static void send_sensor_setting_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, u16_t prop_id, - u16_t set_prop_id, bool publish) + struct bt_mesh_msg_ctx *ctx, uint16_t prop_id, + uint16_t set_prop_id, bool publish) { struct sensor_setting *item = NULL; struct net_buf_simple *msg = NULL; - u16_t length = 0U; + uint16_t length = 0U; item = find_sensor_setting(model, prop_id, set_prop_id); if (item) { @@ -432,13 +433,13 @@ static void send_sensor_setting_status(struct bt_mesh_model *model, static void send_sensor_column_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, u16_t prop_id) + struct net_buf_simple *buf, uint16_t prop_id) { struct bt_mesh_sensor_srv *srv = model->user_data; struct bt_mesh_sensor_state *state = NULL; struct net_buf_simple *msg = NULL; bool optional = false; - u16_t length = 0U; + uint16_t length = 0U; int i; for (i = 0; i < srv->state_count; i++) { @@ -507,13 +508,13 @@ static void send_sensor_column_status(struct bt_mesh_model *model, static void send_sensor_series_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, u16_t prop_id) + struct net_buf_simple *buf, uint16_t prop_id) { struct bt_mesh_sensor_srv *srv = model->user_data; struct bt_mesh_sensor_state *state = NULL; struct net_buf_simple *msg = NULL; bool optional = false; - u16_t length = 0U; + uint16_t length = 0U; int i; for (i = 0; i < srv->state_count; i++) { @@ -584,8 +585,8 @@ static void sensor_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - u16_t set_prop_id = INVALID_SENSOR_PROPERTY_ID; - u16_t prop_id = INVALID_SENSOR_PROPERTY_ID; + uint16_t set_prop_id = INVALID_SENSOR_PROPERTY_ID; + uint16_t prop_id = INVALID_SENSOR_PROPERTY_ID; if (model->user_data == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -619,7 +620,7 @@ static void sensor_get(struct bt_mesh_model *model, .sensor_descriptor_get.id = prop_id, }; bt_mesh_sensor_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG, model, ctx, (const u8_t *)&get, sizeof(get)); + BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG, model, ctx, (const uint8_t *)&get, sizeof(get)); } else { send_sensor_descriptor_status(model, ctx, prop_id, get_all); } @@ -630,7 +631,7 @@ static void sensor_get(struct bt_mesh_model *model, .sensor_get.id = prop_id, }; bt_mesh_sensor_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG, model, ctx, (const u8_t *)&get, sizeof(get)); + BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG, model, ctx, (const uint8_t *)&get, sizeof(get)); } else { send_sensor_data_status(model, ctx, prop_id, get_all); } @@ -648,7 +649,7 @@ static void sensor_get(struct bt_mesh_model *model, .sensor_column_get.raw_x = buf, }; bt_mesh_sensor_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG, model, ctx, (const u8_t *)&get, sizeof(get)); + BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG, model, ctx, (const uint8_t *)&get, sizeof(get)); } else { send_sensor_column_status(model, ctx, buf, prop_id); } @@ -659,7 +660,7 @@ static void sensor_get(struct bt_mesh_model *model, .sensor_series_get.raw = buf, }; bt_mesh_sensor_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG, model, ctx, (const u8_t *)&get, sizeof(get)); + BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG, model, ctx, (const uint8_t *)&get, sizeof(get)); } else { send_sensor_series_status(model, ctx, buf, prop_id); } @@ -688,7 +689,7 @@ static void sensor_get(struct bt_mesh_model *model, .sensor_cadence_get.id = prop_id, }; bt_mesh_sensor_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG, model, ctx, (const u8_t *)&get, sizeof(get)); + BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG, model, ctx, (const uint8_t *)&get, sizeof(get)); } else { send_sensor_cadence_status(model, ctx, prop_id, false); } @@ -698,7 +699,7 @@ static void sensor_get(struct bt_mesh_model *model, .sensor_settings_get.id = prop_id, }; bt_mesh_sensor_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG, model, ctx, (const u8_t *)&get, sizeof(get)); + BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG, model, ctx, (const uint8_t *)&get, sizeof(get)); } else { send_sensor_settings_status(model, ctx, prop_id); } @@ -721,7 +722,7 @@ static void sensor_get(struct bt_mesh_model *model, .sensor_setting_get.setting_id = set_prop_id, }; bt_mesh_sensor_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG, model, ctx, (const u8_t *)&get, sizeof(get)); + BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG, model, ctx, (const uint8_t *)&get, sizeof(get)); } else { send_sensor_setting_status(model, ctx, prop_id, set_prop_id, false); } @@ -743,8 +744,8 @@ static void sensor_cadence_set(struct bt_mesh_model *model, struct bt_mesh_sensor_state *state = NULL; struct bt_mesh_model *sensor_model = NULL; struct bt_mesh_elem *element = NULL; - u16_t prop_id = 0U, trigger_len = 0U; - u8_t val = 0U, divisor = 0U; + uint16_t prop_id = 0U, trigger_len = 0U; + uint8_t val = 0U, divisor = 0U; int i; if (srv == NULL || srv->state_count == 0U || srv->states == NULL) { @@ -764,7 +765,7 @@ static void sensor_cadence_set(struct bt_mesh_model *model, .sensor_cadence_set.cadence = buf, }; bt_mesh_sensor_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -836,7 +837,7 @@ static void sensor_cadence_set(struct bt_mesh_model *model, return; } if (buf->len) { - u8_t range_len = buf->len / 2; + uint8_t range_len = buf->len / 2; if (state->cadence->fast_cadence_low) { net_buf_simple_reset(state->cadence->fast_cadence_low); net_buf_simple_add_mem(state->cadence->fast_cadence_low, buf->data, range_len); @@ -858,7 +859,7 @@ static void sensor_cadence_set(struct bt_mesh_model *model, change.sensor_cadence_set.fast_cadence_low = state->cadence->fast_cadence_low; change.sensor_cadence_set.fast_cadence_high = state->cadence->fast_cadence_high; bt_mesh_sensor_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_SENSOR_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_SENSOR_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET) { send_sensor_cadence_status(model, ctx, prop_id, false); @@ -881,7 +882,7 @@ static void sensor_cadence_set(struct bt_mesh_model *model, return; } -static void update_sensor_periodic_pub(struct bt_mesh_model *model, u16_t prop_id) +static void update_sensor_periodic_pub(struct bt_mesh_model *model, uint16_t prop_id) { struct bt_mesh_sensor_state *state = NULL; struct bt_mesh_sensor_srv *srv = NULL; @@ -930,7 +931,7 @@ static void sensor_setting_set(struct bt_mesh_model *model, struct bt_mesh_sensor_setup_srv *srv = model->user_data; bt_mesh_sensor_server_state_change_t change = {0}; struct sensor_setting *item = NULL; - u16_t prop_id = 0U, set_prop_id = 0U; + uint16_t prop_id = 0U, set_prop_id = 0U; if (srv == NULL || srv->state_count == 0U || srv->states == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -956,7 +957,7 @@ static void sensor_setting_set(struct bt_mesh_model *model, .sensor_setting_set.raw = buf, }; bt_mesh_sensor_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -971,7 +972,7 @@ static void sensor_setting_set(struct bt_mesh_model *model, change.sensor_setting_set.setting_id = set_prop_id; change.sensor_setting_set.value = item->raw; bt_mesh_sensor_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_SENSOR_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_SENSOR_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); } } @@ -1009,7 +1010,7 @@ const struct bt_mesh_model_op bt_mesh_sensor_setup_srv_op[] = { }; static int check_sensor_server_init(struct bt_mesh_sensor_state *state_start, - const u8_t state_count) + const uint8_t state_count) { struct bt_mesh_sensor_state *state = NULL; struct sensor_setting *setting = NULL; diff --git a/components/bt/esp_ble_mesh/mesh_models/server/server_common.c b/components/bt/esp_ble_mesh/mesh_models/server/server_common.c index f33b0f7513..202bd07b4c 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/server_common.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/server_common.c @@ -31,7 +31,7 @@ */ #define INSTANTANEOUS_TRANS_TIME 0 -u8_t bt_mesh_get_default_trans_time(struct bt_mesh_model *model) +uint8_t bt_mesh_get_default_trans_time(struct bt_mesh_model *model) { /** * 1. If a Generic Default Transition Time Server model is present on the @@ -46,10 +46,10 @@ u8_t bt_mesh_get_default_trans_time(struct bt_mesh_model *model) */ struct bt_mesh_elem *element = bt_mesh_model_elem(model); struct bt_mesh_gen_def_trans_time_srv *state = NULL; - u16_t primary_addr = bt_mesh_primary_addr(); + uint16_t primary_addr = bt_mesh_primary_addr(); struct bt_mesh_model *srv = NULL; - for (u16_t addr = element->addr; addr >= primary_addr; addr--) { + for (uint16_t addr = element->addr; addr >= primary_addr; addr--) { element = bt_mesh_elem_find(addr); if (element) { srv = bt_mesh_model_find(element, BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV); @@ -65,10 +65,10 @@ u8_t bt_mesh_get_default_trans_time(struct bt_mesh_model *model) return INSTANTANEOUS_TRANS_TIME; } -int bt_mesh_get_light_lc_trans_time(struct bt_mesh_model *model, u8_t *trans_time) +int bt_mesh_get_light_lc_trans_time(struct bt_mesh_model *model, uint8_t *trans_time) { struct bt_mesh_light_lc_srv *srv = NULL; - u32_t value = 0U; + uint32_t value = 0U; if (model == NULL || trans_time == NULL) { BT_ERR("%s, Invalid parameter", __func__); @@ -123,7 +123,7 @@ int bt_mesh_get_light_lc_trans_time(struct bt_mesh_model *model, u8_t *trans_tim int bt_mesh_server_get_optional(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf, - u8_t *trans_time, u8_t *delay, + uint8_t *trans_time, uint8_t *delay, bool *optional) { if (model == NULL || buf == NULL || trans_time == NULL || @@ -205,7 +205,7 @@ void bt_mesh_server_free_ctx(struct k_work *work) #endif /* CONFIG_BLE_MESH_DEINIT */ bool bt_mesh_is_server_recv_last_msg(struct bt_mesh_last_msg_info *last, - u8_t tid, u16_t src, u16_t dst, s64_t *now) + uint8_t tid, uint16_t src, uint16_t dst, int64_t *now) { *now = k_uptime_get(); @@ -223,7 +223,7 @@ bool bt_mesh_is_server_recv_last_msg(struct bt_mesh_last_msg_info *last, } void bt_mesh_server_update_last_msg(struct bt_mesh_last_msg_info *last, - u8_t tid, u16_t src, u16_t dst, s64_t *now) + uint8_t tid, uint16_t src, uint16_t dst, int64_t *now) { /* Currently we only update msg info which dst is set to a unicast address */ if (!BLE_MESH_ADDR_IS_UNICAST(dst)) { @@ -237,7 +237,7 @@ void bt_mesh_server_update_last_msg(struct bt_mesh_last_msg_info *last, return; } -struct net_buf_simple *bt_mesh_server_get_pub_msg(struct bt_mesh_model *model, u16_t msg_len) +struct net_buf_simple *bt_mesh_server_get_pub_msg(struct bt_mesh_model *model, uint16_t msg_len) { struct net_buf_simple *buf = NULL; diff --git a/components/bt/esp_ble_mesh/mesh_models/server/state_binding.c b/components/bt/esp_ble_mesh/mesh_models/server/state_binding.c index 0e00d892ec..cfe27d0824 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/state_binding.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/state_binding.c @@ -38,9 +38,9 @@ static float bt_mesh_sqrt(float square) return root; } -static s32_t bt_mesh_ceiling(float num) +static int32_t bt_mesh_ceiling(float num) { - s32_t inum = (s32_t)num; + int32_t inum = (int32_t)num; if (num == (float)inum) { return inum; @@ -49,49 +49,49 @@ static s32_t bt_mesh_ceiling(float num) return inum + 1; } -u16_t bt_mesh_convert_lightness_actual_to_linear(u16_t actual) +uint16_t bt_mesh_convert_lightness_actual_to_linear(uint16_t actual) { float tmp = ((float) actual / UINT16_MAX); return bt_mesh_ceiling(UINT16_MAX * tmp * tmp); } -u16_t bt_mesh_convert_lightness_linear_to_actual(u16_t linear) +uint16_t bt_mesh_convert_lightness_linear_to_actual(uint16_t linear) { - return (u16_t) (UINT16_MAX * bt_mesh_sqrt(((float) linear / UINT16_MAX))); + return (uint16_t) (UINT16_MAX * bt_mesh_sqrt(((float) linear / UINT16_MAX))); } -s16_t bt_mesh_convert_temperature_to_gen_level(u16_t temp, u16_t min, u16_t max) +int16_t bt_mesh_convert_temperature_to_gen_level(uint16_t temp, uint16_t min, uint16_t max) { float tmp = (temp - min) * UINT16_MAX / (max - min); - return (s16_t) (tmp + INT16_MIN); + return (int16_t) (tmp + INT16_MIN); } -u16_t bt_mesh_covert_gen_level_to_temperature(s16_t level, u16_t min, u16_t max) +uint16_t bt_mesh_covert_gen_level_to_temperature(int16_t level, uint16_t min, uint16_t max) { float diff = (float) (max - min) / UINT16_MAX; - u16_t tmp = (u16_t) ((level - INT16_MIN) * diff); - return (u16_t) (min + tmp); + uint16_t tmp = (uint16_t) ((level - INT16_MIN) * diff); + return (uint16_t) (min + tmp); } -s16_t bt_mesh_convert_hue_to_level(u16_t hue) +int16_t bt_mesh_convert_hue_to_level(uint16_t hue) { - return (s16_t) (hue + INT16_MIN); + return (int16_t) (hue + INT16_MIN); } -u16_t bt_mesh_convert_level_to_hue(s16_t level) +uint16_t bt_mesh_convert_level_to_hue(int16_t level) { - return (u16_t) (level - INT16_MIN); + return (uint16_t) (level - INT16_MIN); } -s16_t bt_mesh_convert_saturation_to_level(u16_t saturation) +int16_t bt_mesh_convert_saturation_to_level(uint16_t saturation) { - return (s16_t) (saturation + INT16_MIN); + return (int16_t) (saturation + INT16_MIN); } -u16_t bt_mesh_convert_level_to_saturation(s16_t level) +uint16_t bt_mesh_convert_level_to_saturation(int16_t level) { - return (u16_t) (level - INT16_MIN); + return (uint16_t) (level - INT16_MIN); } int bt_mesh_update_binding_state(struct bt_mesh_model *model, diff --git a/components/bt/esp_ble_mesh/mesh_models/server/state_transition.c b/components/bt/esp_ble_mesh/mesh_models/server/state_transition.c index 775ccf831a..c930a80dac 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/state_transition.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/state_transition.c @@ -23,9 +23,9 @@ void bt_mesh_server_calc_remain_time(struct bt_mesh_state_transition *transition) { - u8_t steps = 0U, resolution = 0U; - s32_t duration_remainder = 0; - s64_t now = 0; + uint8_t steps = 0U, resolution = 0U; + int32_t duration_remainder = 0; + int64_t now = 0; if (transition->just_started) { transition->remain_time = transition->trans_time; @@ -62,7 +62,7 @@ void bt_mesh_server_calc_remain_time(struct bt_mesh_state_transition *transition static void tt_values_calculator(struct bt_mesh_state_transition *transition) { - u8_t steps_multiplier = 0U, resolution = 0U; + uint8_t steps_multiplier = 0U, resolution = 0U; resolution = (transition->trans_time >> 6); steps_multiplier = (transition->trans_time & 0x3F); @@ -90,7 +90,7 @@ static void tt_values_calculator(struct bt_mesh_state_transition *transition) } static void transition_time_values(struct bt_mesh_state_transition *transition, - u8_t trans_time, u8_t delay) + uint8_t trans_time, uint8_t delay) { transition->trans_time = trans_time; transition->delay = delay; @@ -118,13 +118,13 @@ static void transition_timer_stop(struct bt_mesh_state_transition *transition) #if CONFIG_BLE_MESH_GENERIC_SERVER void generic_onoff_tt_values(struct bt_mesh_gen_onoff_srv *srv, - u8_t trans_time, u8_t delay) + uint8_t trans_time, uint8_t delay) { return transition_time_values(&srv->transition, trans_time, delay); } void generic_level_tt_values(struct bt_mesh_gen_level_srv *srv, - u8_t trans_time, u8_t delay) + uint8_t trans_time, uint8_t delay) { transition_time_values(&srv->transition, trans_time, delay); srv->tt_delta_level = @@ -132,7 +132,7 @@ void generic_level_tt_values(struct bt_mesh_gen_level_srv *srv, } void generic_power_level_tt_values(struct bt_mesh_gen_power_level_srv *srv, - u8_t trans_time, u8_t delay) + uint8_t trans_time, uint8_t delay) { transition_time_values(&srv->transition, trans_time, delay); srv->tt_delta_level = @@ -142,7 +142,7 @@ void generic_power_level_tt_values(struct bt_mesh_gen_power_level_srv *srv, #if CONFIG_BLE_MESH_LIGHTING_SERVER void light_lightness_actual_tt_values(struct bt_mesh_light_lightness_srv *srv, - u8_t trans_time, u8_t delay) + uint8_t trans_time, uint8_t delay) { transition_time_values(&srv->actual_transition, trans_time, delay); srv->tt_delta_lightness_actual = @@ -150,7 +150,7 @@ void light_lightness_actual_tt_values(struct bt_mesh_light_lightness_srv *srv, } void light_lightness_linear_tt_values(struct bt_mesh_light_lightness_srv *srv, - u8_t trans_time, u8_t delay) + uint8_t trans_time, uint8_t delay) { transition_time_values(&srv->linear_transition, trans_time, delay); srv->tt_delta_lightness_linear = @@ -158,7 +158,7 @@ void light_lightness_linear_tt_values(struct bt_mesh_light_lightness_srv *srv, } void light_ctl_tt_values(struct bt_mesh_light_ctl_srv *srv, - u8_t trans_time, u8_t delay) + uint8_t trans_time, uint8_t delay) { transition_time_values(&srv->transition, trans_time, delay); srv->tt_delta_lightness = @@ -170,7 +170,7 @@ void light_ctl_tt_values(struct bt_mesh_light_ctl_srv *srv, } void light_ctl_temp_tt_values(struct bt_mesh_light_ctl_temp_srv *srv, - u8_t trans_time, u8_t delay) + uint8_t trans_time, uint8_t delay) { transition_time_values(&srv->transition, trans_time, delay); srv->tt_delta_temperature = @@ -180,7 +180,7 @@ void light_ctl_temp_tt_values(struct bt_mesh_light_ctl_temp_srv *srv, } void light_hsl_tt_values(struct bt_mesh_light_hsl_srv *srv, - u8_t trans_time, u8_t delay) + uint8_t trans_time, uint8_t delay) { transition_time_values(&srv->transition, trans_time, delay); srv->tt_delta_lightness = @@ -192,7 +192,7 @@ void light_hsl_tt_values(struct bt_mesh_light_hsl_srv *srv, } void light_hsl_hue_tt_values(struct bt_mesh_light_hsl_hue_srv *srv, - u8_t trans_time, u8_t delay) + uint8_t trans_time, uint8_t delay) { transition_time_values(&srv->transition, trans_time, delay); srv->tt_delta_hue = @@ -200,7 +200,7 @@ void light_hsl_hue_tt_values(struct bt_mesh_light_hsl_hue_srv *srv, } void light_hsl_sat_tt_values(struct bt_mesh_light_hsl_sat_srv *srv, - u8_t trans_time, u8_t delay) + uint8_t trans_time, uint8_t delay) { transition_time_values(&srv->transition, trans_time, delay); srv->tt_delta_saturation = @@ -208,7 +208,7 @@ void light_hsl_sat_tt_values(struct bt_mesh_light_hsl_sat_srv *srv, } void light_xyl_tt_values(struct bt_mesh_light_xyl_srv *srv, - u8_t trans_time, u8_t delay) + uint8_t trans_time, uint8_t delay) { transition_time_values(&srv->transition, trans_time, delay); srv->tt_delta_lightness = @@ -220,14 +220,14 @@ void light_xyl_tt_values(struct bt_mesh_light_xyl_srv *srv, } void light_lc_tt_values(struct bt_mesh_light_lc_srv *srv, - u8_t trans_time, u8_t delay) + uint8_t trans_time, uint8_t delay) { transition_time_values(&srv->transition, trans_time, delay); } #endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */ #if CONFIG_BLE_MESH_TIME_SCENE_SERVER -void scene_tt_values(struct bt_mesh_scene_srv *srv, u8_t trans_time, u8_t delay) +void scene_tt_values(struct bt_mesh_scene_srv *srv, uint8_t trans_time, uint8_t delay) { transition_time_values(&srv->transition, trans_time, delay); } @@ -257,7 +257,7 @@ void generic_onoff_work_handler(struct k_work *work) if (srv->transition.counter == 0U) { change.gen_onoff_set.onoff = srv->state.onoff; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); bt_mesh_atomic_clear_bit(srv->transition.flag, BLE_MESH_TRANS_TIMER_START); } else { /** @@ -270,7 +270,7 @@ void generic_onoff_work_handler(struct k_work *work) srv->state.onoff = BLE_MESH_STATE_ON; change.gen_onoff_set.onoff = srv->state.onoff; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); } transition_timer_start(&srv->transition); } @@ -289,7 +289,7 @@ void generic_onoff_work_handler(struct k_work *work) if (srv->state.target_onoff != BLE_MESH_STATE_ON) { change.gen_onoff_set.onoff = srv->state.onoff; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); } } @@ -333,7 +333,7 @@ void generic_level_work_handler(struct k_work *work) break; } bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); bt_mesh_atomic_clear_bit(srv->transition.flag, BLE_MESH_TRANS_TIMER_START); } else { transition_timer_start(&srv->transition); @@ -368,7 +368,7 @@ void generic_level_work_handler(struct k_work *work) break; } bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); gen_level_publish(srv->model); @@ -398,7 +398,7 @@ void generic_power_level_work_handler(struct k_work *work) if (srv->transition.counter == 0U) { change.gen_power_level_set.power = srv->state->power_actual; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); bt_mesh_atomic_clear_bit(srv->transition.flag, BLE_MESH_TRANS_TIMER_START); } else { transition_timer_start(&srv->transition); @@ -430,7 +430,7 @@ void generic_power_level_work_handler(struct k_work *work) change.gen_power_level_set.power = srv->state->power_actual; bt_mesh_generic_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); gen_power_level_publish(srv->model, BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_STATUS); @@ -462,7 +462,7 @@ void light_lightness_actual_work_handler(struct k_work *work) if (srv->actual_transition.counter == 0U) { change.lightness_set.lightness = srv->state->lightness_actual; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); bt_mesh_atomic_clear_bit(srv->actual_transition.flag, BLE_MESH_TRANS_TIMER_START); } else { transition_timer_start(&srv->actual_transition); @@ -494,7 +494,7 @@ void light_lightness_actual_work_handler(struct k_work *work) change.lightness_set.lightness = srv->state->lightness_actual; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); light_lightness_publish(srv->model, BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_STATUS); @@ -524,7 +524,7 @@ void light_lightness_linear_work_handler(struct k_work *work) if (srv->linear_transition.counter == 0U) { change.lightness_linear_set.lightness = srv->state->lightness_linear; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); bt_mesh_atomic_clear_bit(srv->linear_transition.flag, BLE_MESH_TRANS_TIMER_START); } else { transition_timer_start(&srv->linear_transition); @@ -546,7 +546,7 @@ void light_lightness_linear_work_handler(struct k_work *work) change.lightness_linear_set.lightness = srv->state->lightness_linear; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); light_lightness_publish(srv->model, BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_STATUS); @@ -578,7 +578,7 @@ void light_ctl_work_handler(struct k_work *work) change.ctl_set.temperature = srv->state->temperature; change.ctl_set.delta_uv = srv->state->delta_uv; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); bt_mesh_atomic_clear_bit(srv->transition.flag, BLE_MESH_TRANS_TIMER_START); } else { transition_timer_start(&srv->transition); @@ -606,7 +606,7 @@ void light_ctl_work_handler(struct k_work *work) change.ctl_set.temperature = srv->state->temperature; change.ctl_set.delta_uv = srv->state->delta_uv; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); light_ctl_publish(srv->model, BLE_MESH_MODEL_OP_LIGHT_CTL_STATUS); @@ -637,7 +637,7 @@ void light_ctl_temp_work_handler(struct k_work *work) change.ctl_temp_set.temperature = srv->state->temperature; change.ctl_temp_set.delta_uv = srv->state->delta_uv; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); bt_mesh_atomic_clear_bit(srv->transition.flag, BLE_MESH_TRANS_TIMER_START); } else { transition_timer_start(&srv->transition); @@ -662,7 +662,7 @@ void light_ctl_temp_work_handler(struct k_work *work) change.ctl_temp_set.temperature = srv->state->temperature; change.ctl_temp_set.delta_uv = srv->state->delta_uv; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); light_ctl_publish(srv->model, BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_STATUS); @@ -694,7 +694,7 @@ void light_hsl_work_handler(struct k_work *work) change.hsl_set.hue = srv->state->hue; change.hsl_set.saturation = srv->state->saturation; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); bt_mesh_atomic_clear_bit(srv->transition.flag, BLE_MESH_TRANS_TIMER_START); } else { transition_timer_start(&srv->transition); @@ -722,7 +722,7 @@ void light_hsl_work_handler(struct k_work *work) change.hsl_set.hue = srv->state->hue; change.hsl_set.saturation = srv->state->saturation; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); light_hsl_publish(srv->model, BLE_MESH_MODEL_OP_LIGHT_HSL_STATUS); @@ -752,7 +752,7 @@ void light_hsl_hue_work_handler(struct k_work *work) if (srv->transition.counter == 0U) { change.hsl_hue_set.hue = srv->state->hue; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); bt_mesh_atomic_clear_bit(srv->transition.flag, BLE_MESH_TRANS_TIMER_START); } else { transition_timer_start(&srv->transition); @@ -774,7 +774,7 @@ void light_hsl_hue_work_handler(struct k_work *work) change.hsl_hue_set.hue = srv->state->hue; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); light_hsl_publish(srv->model, BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_STATUS); @@ -804,7 +804,7 @@ void light_hsl_sat_work_handler(struct k_work *work) if (srv->transition.counter == 0U) { change.hsl_saturation_set.saturation = srv->state->saturation; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); bt_mesh_atomic_clear_bit(srv->transition.flag, BLE_MESH_TRANS_TIMER_START); } else { transition_timer_start(&srv->transition); @@ -826,7 +826,7 @@ void light_hsl_sat_work_handler(struct k_work *work) change.hsl_saturation_set.saturation = srv->state->saturation; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); light_hsl_publish(srv->model, BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_STATUS); @@ -858,7 +858,7 @@ void light_xyl_work_handler(struct k_work *work) change.xyl_set.x = srv->state->x; change.xyl_set.y = srv->state->y; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); bt_mesh_atomic_clear_bit(srv->transition.flag, BLE_MESH_TRANS_TIMER_START); } else { transition_timer_start(&srv->transition); @@ -886,7 +886,7 @@ void light_xyl_work_handler(struct k_work *work) change.xyl_set.x = srv->state->x; change.xyl_set.y = srv->state->y; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); light_xyl_publish(srv->model, BLE_MESH_MODEL_OP_LIGHT_XYL_STATUS); @@ -915,7 +915,7 @@ void light_lc_work_handler(struct k_work *work) if (srv->transition.counter == 0U) { change.lc_light_onoff_set.onoff = srv->lc->state.light_onoff; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); bt_mesh_atomic_clear_bit(srv->transition.flag, BLE_MESH_TRANS_TIMER_START); } else { /** @@ -930,7 +930,7 @@ void light_lc_work_handler(struct k_work *work) .lc_light_onoff_set.onoff = srv->lc->state.light_onoff, }; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); } transition_timer_start(&srv->transition); } @@ -949,7 +949,7 @@ void light_lc_work_handler(struct k_work *work) if (srv->lc->state.light_onoff != BLE_MESH_STATE_ON) { change.lc_light_onoff_set.onoff = srv->lc->state.light_onoff; bt_mesh_lighting_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); } } @@ -983,7 +983,7 @@ void scene_recall_work_handler(struct k_work *work) if (srv->transition.counter == 0U) { change.scene_recall.scene_number = srv->state->current_scene; bt_mesh_time_scene_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); bt_mesh_atomic_clear_bit(srv->transition.flag, BLE_MESH_TRANS_TIMER_START); } else { transition_timer_start(&srv->transition); @@ -1006,7 +1006,7 @@ void scene_recall_work_handler(struct k_work *work) change.scene_recall.scene_number = srv->state->current_scene; bt_mesh_time_scene_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE, srv->model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE, srv->model, ctx, (const uint8_t *)&change, sizeof(change)); scene_publish(srv->model, ctx, BLE_MESH_MODEL_OP_SCENE_STATUS); diff --git a/components/bt/esp_ble_mesh/mesh_models/server/time_scene_server.c b/components/bt/esp_ble_mesh/mesh_models/server/time_scene_server.c index 5b2d878e2a..d7a3a93aad 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/time_scene_server.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/time_scene_server.c @@ -55,11 +55,11 @@ void bt_mesh_time_scene_server_unlock(void) /* Time Server & Time Setup Server message handlers */ static void send_time_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - bool publish, u16_t opcode) + bool publish, uint16_t opcode) { struct net_buf_simple *msg = NULL; - u8_t zero[5] = {0}; - u8_t length = 1 + 10; + uint8_t zero[5] = {0}; + uint8_t length = 1 + 10; if (ctx == NULL && publish == false) { BT_ERR("%s, Invalid parameter", __func__); @@ -164,9 +164,9 @@ static void time_get(struct bt_mesh_model *model, struct net_buf_simple *buf) { struct bt_mesh_server_rsp_ctrl *rsp_ctrl = NULL; - u8_t zero[5] = {0}; - u16_t opcode = 0U, val = 0U; - u8_t prev_ttl = 0U; + uint8_t zero[5] = {0}; + uint16_t opcode = 0U, val = 0U; + uint8_t prev_ttl = 0U; if (model->user_data == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -240,7 +240,7 @@ static void time_get(struct bt_mesh_model *model, status.time_status.time_zone_offset = net_buf_simple_pull_u8(buf); } bt_mesh_time_scene_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_STATUS_MSG, model, ctx, (const u8_t *)&status, sizeof(status)); + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_STATUS_MSG, model, ctx, (const uint8_t *)&status, sizeof(status)); return; } memcpy(srv->state->time.tai_seconds, buf->data, TAI_SECONDS_LEN); @@ -269,7 +269,7 @@ static void time_get(struct bt_mesh_model *model, change.time_status.time_authority = srv->state->time.time_authority; change.time_status.tai_utc_delta_curr = srv->state->time.subsecond; bt_mesh_time_scene_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (model->pub == NULL || model->pub->msg == NULL || model->pub->addr == BLE_MESH_ADDR_UNASSIGNED) { @@ -313,8 +313,8 @@ static void time_set(struct bt_mesh_model *model, { struct bt_mesh_time_setup_srv *srv = model->user_data; bt_mesh_time_scene_server_state_change_t change = {0}; - u16_t opcode = 0U, val = 0U; - u8_t role = 0U; + uint16_t opcode = 0U, val = 0U; + uint8_t role = 0U; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -334,7 +334,7 @@ static void time_set(struct bt_mesh_model *model, set.time_set.tai_utc_delta = (val >> 1) & BIT_MASK(15); set.time_set.time_zone_offset = net_buf_simple_pull_u8(buf); bt_mesh_time_scene_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } memcpy(srv->state->time.tai_seconds, buf->data, TAI_SECONDS_LEN); @@ -354,7 +354,7 @@ static void time_set(struct bt_mesh_model *model, memcpy(set.time_zone_set.tai_zone_change, buf->data, TAI_OF_ZONE_CHANGE_LEN); net_buf_simple_pull(buf, TAI_OF_ZONE_CHANGE_LEN); bt_mesh_time_scene_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } srv->state->time.time_zone_offset_new = net_buf_simple_pull_u8(buf); @@ -374,7 +374,7 @@ static void time_set(struct bt_mesh_model *model, memcpy(set.tai_utc_delta_set.tai_delta_change, buf->data, TAI_OF_DELTA_CHANGE_LEN); net_buf_simple_pull(buf, TAI_OF_DELTA_CHANGE_LEN); bt_mesh_time_scene_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } srv->state->time.tai_utc_delta_new = val & BIT_MASK(15); @@ -393,7 +393,7 @@ static void time_set(struct bt_mesh_model *model, .time_role_set.time_role = role, }; bt_mesh_time_scene_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } srv->state->time_role = role; @@ -428,7 +428,7 @@ static void time_set(struct bt_mesh_model *model, } bt_mesh_time_scene_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); /* Send corresponding time status message */ send_time_status(model, ctx, false, opcode); @@ -442,7 +442,7 @@ static void send_scene_status(struct bt_mesh_model *model, { struct bt_mesh_scene_srv *srv = model->user_data; struct net_buf_simple *msg = NULL; - u8_t length = 1 + 6; + uint8_t length = 1 + 6; if (publish == false) { msg = bt_mesh_alloc_buf(length + BLE_MESH_SERVER_TRANS_MIC_SIZE); @@ -493,12 +493,12 @@ static void send_scene_status(struct bt_mesh_model *model, static void send_scene_register_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - u8_t status_code, bool publish) + uint8_t status_code, bool publish) { struct bt_mesh_scene_setup_srv *srv = model->user_data; struct scene_register *scene = NULL; struct net_buf_simple *msg = NULL; - u16_t total_len = 9U; + uint16_t total_len = 9U; int i; if (ctx == NULL && publish == false) { @@ -581,7 +581,7 @@ static void scene_get(struct bt_mesh_model *model, } } -void scene_publish(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, u16_t opcode) +void scene_publish(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, uint16_t opcode) { struct bt_mesh_scene_srv *srv = model->user_data; @@ -600,10 +600,10 @@ static void scene_recall(struct bt_mesh_model *model, { struct bt_mesh_scene_srv *srv = model->user_data; struct scene_register *scene = NULL; - u8_t tid = 0U, trans_time = 0U, delay = 0U; - u16_t scene_number = 0U; + uint8_t tid = 0U, trans_time = 0U, delay = 0U; + uint16_t scene_number = 0U; bool optional = false; - s64_t now = 0; + int64_t now = 0; int i; if (srv == NULL || srv->state == NULL) { @@ -631,7 +631,7 @@ static void scene_recall(struct bt_mesh_model *model, .scene_recall.delay = delay, }; bt_mesh_time_scene_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -690,7 +690,7 @@ static void scene_recall(struct bt_mesh_model *model, .scene_recall.scene_number = scene_number, }; bt_mesh_time_scene_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); bt_mesh_time_scene_server_unlock(); return; @@ -732,7 +732,7 @@ static void scene_action(struct bt_mesh_model *model, { struct bt_mesh_scene_setup_srv *srv = model->user_data; struct scene_register *scene = NULL; - u16_t scene_number = 0U; + uint16_t scene_number = 0U; int i; if (srv == NULL || srv->state == NULL) { @@ -754,7 +754,7 @@ static void scene_action(struct bt_mesh_model *model, .scene_store.scene_number = scene_number, }; bt_mesh_time_scene_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } /* Try to find a matching Scene Number */ @@ -809,7 +809,7 @@ static void scene_action(struct bt_mesh_model *model, .scene_store.scene_number = scene_number, }; bt_mesh_time_scene_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); } break; } @@ -820,7 +820,7 @@ static void scene_action(struct bt_mesh_model *model, .scene_delete.scene_number = scene_number, }; bt_mesh_time_scene_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } for (i = 0; i < srv->state->scene_count; i++) { @@ -913,7 +913,7 @@ static void scene_action(struct bt_mesh_model *model, .scene_delete.scene_number = scene_number, }; bt_mesh_time_scene_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); break; } default: @@ -930,9 +930,9 @@ static void scene_action(struct bt_mesh_model *model, return; } -static u16_t get_schedule_reg_bit(struct bt_mesh_scheduler_state *state) +static uint16_t get_schedule_reg_bit(struct bt_mesh_scheduler_state *state) { - u16_t val = 0U; + uint16_t val = 0U; int i; for (i = 0; i < state->schedule_count; i++) { @@ -944,42 +944,42 @@ static u16_t get_schedule_reg_bit(struct bt_mesh_scheduler_state *state) return val; } -static u64_t get_schedule_reg_state(struct bt_mesh_scheduler_state *state, u8_t index) +static uint64_t get_schedule_reg_state(struct bt_mesh_scheduler_state *state, uint8_t index) { struct schedule_register *reg = &state->schedules[index]; - u64_t val = 0U; + uint64_t val = 0U; - val = ((u64_t)(reg->year) << 4) | index; - val |= ((u64_t)(reg->day) << 23) | ((u64_t)(reg->month) << 11); - val |= ((u64_t)(reg->minute) << 33) | ((u64_t)(reg->hour) << 28); - val |= ((u64_t)(reg->day_of_week) << 45) | ((u64_t)(reg->second) << 39); - val |= ((u64_t)(reg->trans_time) << 56) | ((u64_t)(reg->action) << 52); + val = ((uint64_t)(reg->year) << 4) | index; + val |= ((uint64_t)(reg->day) << 23) | ((uint64_t)(reg->month) << 11); + val |= ((uint64_t)(reg->minute) << 33) | ((uint64_t)(reg->hour) << 28); + val |= ((uint64_t)(reg->day_of_week) << 45) | ((uint64_t)(reg->second) << 39); + val |= ((uint64_t)(reg->trans_time) << 56) | ((uint64_t)(reg->action) << 52); return val; } static void send_scheduler_act_status(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, - u8_t index) + uint8_t index) { NET_BUF_SIMPLE_DEFINE(msg, 1 + 10 + BLE_MESH_SERVER_TRANS_MIC_SIZE); - u64_t value = 0U; + uint64_t value = 0U; bt_mesh_model_msg_init(&msg, BLE_MESH_MODEL_OP_SCHEDULER_ACT_STATUS); switch (model->id) { case BLE_MESH_MODEL_ID_SCHEDULER_SRV: { struct bt_mesh_scheduler_srv *srv = model->user_data; value = get_schedule_reg_state(srv->state, index); - net_buf_simple_add_le32(&msg, (u32_t)value); - net_buf_simple_add_le32(&msg, (u32_t)(value >> 32)); + net_buf_simple_add_le32(&msg, (uint32_t)value); + net_buf_simple_add_le32(&msg, (uint32_t)(value >> 32)); net_buf_simple_add_le16(&msg, srv->state->schedules[index].scene_number); break; } case BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV: { struct bt_mesh_scheduler_setup_srv *srv = model->user_data; value = get_schedule_reg_state(srv->state, index); - net_buf_simple_add_le32(&msg, (u32_t)value); - net_buf_simple_add_le32(&msg, (u32_t)(value >> 32)); + net_buf_simple_add_le32(&msg, (uint32_t)value); + net_buf_simple_add_le32(&msg, (uint32_t)(value >> 32)); net_buf_simple_add_le16(&msg, srv->state->schedules[index].scene_number); break; } @@ -1018,7 +1018,7 @@ static void scheduler_get(struct bt_mesh_model *model, return; } case BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET: { - u8_t index = net_buf_simple_pull_u8(buf); + uint8_t index = net_buf_simple_pull_u8(buf); if (index > SCHEDULE_ENTRY_MAX_INDEX) { BT_ERR("Invalid Scheduler Register Entry index 0x%02x", index); return; @@ -1029,7 +1029,7 @@ static void scheduler_get(struct bt_mesh_model *model, .scheduler_act_get.index = index, }; bt_mesh_time_scene_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_GET_MSG, model, ctx, (const u8_t *)&get, sizeof(get)); + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_GET_MSG, model, ctx, (const uint8_t *)&get, sizeof(get)); return; } @@ -1057,10 +1057,10 @@ static void scheduler_act_set(struct bt_mesh_model *model, * queue. */ struct bt_mesh_scheduler_setup_srv *srv = model->user_data; - u8_t index = 0U, year = 0U, day = 0U, hour = 0U, minute = 0U, + uint8_t index = 0U, year = 0U, day = 0U, hour = 0U, minute = 0U, second = 0U, day_of_week = 0U, action = 0U, trans_time = 0U; - u16_t month = 0U, scene_number = 0U; - u64_t value = 0U; + uint16_t month = 0U, scene_number = 0U; + uint64_t value = 0U; if (srv == NULL || srv->state == NULL) { BT_ERR("%s, Invalid model user data", __func__); @@ -1068,7 +1068,7 @@ static void scheduler_act_set(struct bt_mesh_model *model, } value = net_buf_simple_pull_le32(buf); - value |= ((u64_t)net_buf_simple_pull_le32(buf) << 32); + value |= ((uint64_t)net_buf_simple_pull_le32(buf) << 32); index = value & BIT_MASK(4); year = (value >> 4) & BIT_MASK(7); @@ -1118,7 +1118,7 @@ static void scheduler_act_set(struct bt_mesh_model *model, .scheduler_act_set.scene_number = scene_number, }; bt_mesh_time_scene_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG, model, ctx, (const u8_t *)&set, sizeof(set)); + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG, model, ctx, (const uint8_t *)&set, sizeof(set)); return; } @@ -1148,7 +1148,7 @@ static void scheduler_act_set(struct bt_mesh_model *model, .scheduler_act_set.scene_number = scene_number, }; bt_mesh_time_scene_server_cb_evt_to_btc( - BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE, model, ctx, (const uint8_t *)&change, sizeof(change)); if (ctx->recv_op == BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET) { send_scheduler_act_status(model, ctx, index);