فهرست منبع

ble_mesh: Define a macro for invalid company id

lly 5 سال پیش
والد
کامیت
11cfb44e58

+ 3 - 0
components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h

@@ -58,6 +58,9 @@ typedef uint8_t esp_ble_mesh_octet16_t[ESP_BLE_MESH_OCTET16_LEN];
 #define ESP_BLE_MESH_OCTET8_LEN     8
 typedef uint8_t esp_ble_mesh_octet8_t[ESP_BLE_MESH_OCTET8_LEN];
 
+/*!< Invalid Company ID */
+#define ESP_BLE_MESH_CID_NVAL                     0xFFFF
+
 #define ESP_BLE_MESH_ADDR_UNASSIGNED              0x0000
 #define ESP_BLE_MESH_ADDR_ALL_NODES               0xFFFF
 #define ESP_BLE_MESH_ADDR_PROXIES                 0xFFFC

+ 0 - 2
components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c

@@ -20,8 +20,6 @@
 #include "cfg_cli.h"
 #include "esp_ble_mesh_config_model_api.h"
 
-#define CID_NVAL 0xffff
-
 extern s32_t config_msg_timeout;
 
 /* Configuration Client Model related functions */

+ 19 - 21
components/bt/esp_ble_mesh/mesh_core/cfg_cli.c

@@ -20,8 +20,6 @@
 #include "mesh_common.h"
 #include "cfg_cli.h"
 
-#define CID_NVAL 0xffff
-
 /* 2 byte dummy opcode for getting compile time buffer sizes. */
 #define DUMMY_2_BYTE_OP     BLE_MESH_MODEL_OP_2(0xff, 0xff)
 
@@ -384,7 +382,7 @@ static void mod_app_status(struct bt_mesh_model *model,
     if (buf->len >= 4) {
         status.cid = net_buf_simple_pull_le16(buf);
     } else {
-        status.cid = CID_NVAL;
+        status.cid = BLE_MESH_CID_NVAL;
     }
     status.mod_id = net_buf_simple_pull_le16(buf);
 
@@ -413,7 +411,7 @@ static void mod_pub_status(struct bt_mesh_model *model,
     if (buf->len >= 4) {
         status.cid = net_buf_simple_pull_le16(buf);
     } else {
-        status.cid = CID_NVAL;
+        status.cid = BLE_MESH_CID_NVAL;
     }
     status.mod_id = net_buf_simple_pull_le16(buf);
 
@@ -436,7 +434,7 @@ static void mod_sub_status(struct bt_mesh_model *model,
     if (buf->len >= 4) {
         status.cid = net_buf_simple_pull_le16(buf);
     } else {
-        status.cid = CID_NVAL;
+        status.cid = BLE_MESH_CID_NVAL;
     }
     status.mod_id = net_buf_simple_pull_le16(buf);
 
@@ -511,7 +509,7 @@ static void mod_sub_list(struct bt_mesh_model *model,
     if (ctx->recv_op == OP_MOD_SUB_LIST_VND) {
         list.cid = net_buf_simple_pull_le16(buf);
     } else {
-        list.cid = CID_NVAL;
+        list.cid = BLE_MESH_CID_NVAL;
     }
     list.mod_id = net_buf_simple_pull_le16(buf);
 
@@ -599,7 +597,7 @@ static void mod_app_list(struct bt_mesh_model *model,
     if (ctx->recv_op == OP_VND_MOD_APP_LIST) {
         list.cid = net_buf_simple_pull_le16(buf);
     } else {
-        list.cid = CID_NVAL;
+        list.cid = BLE_MESH_CID_NVAL;
     }
     list.mod_id = net_buf_simple_pull_le16(buf);
 
@@ -908,7 +906,7 @@ int bt_mesh_cfg_mod_app_bind(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
     bt_mesh_model_msg_init(&msg, OP_MOD_APP_BIND);
     net_buf_simple_add_le16(&msg, elem_addr);
     net_buf_simple_add_le16(&msg, mod_app_idx);
-    if (cid != CID_NVAL) {
+    if (cid != BLE_MESH_CID_NVAL) {
         net_buf_simple_add_le16(&msg, cid);
     }
     net_buf_simple_add_le16(&msg, mod_id);
@@ -932,7 +930,7 @@ static int mod_sub(u32_t op, struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
     bt_mesh_model_msg_init(&msg, op);
     net_buf_simple_add_le16(&msg, elem_addr);
     net_buf_simple_add_le16(&msg, sub_addr);
-    if (cid != CID_NVAL) {
+    if (cid != BLE_MESH_CID_NVAL) {
         net_buf_simple_add_le16(&msg, cid);
     }
     net_buf_simple_add_le16(&msg, mod_id);
@@ -986,7 +984,7 @@ static int mod_sub_va(u32_t op, struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
     bt_mesh_model_msg_init(&msg, op);
     net_buf_simple_add_le16(&msg, elem_addr);
     net_buf_simple_add_mem(&msg, label, 16);
-    if (cid != CID_NVAL) {
+    if (cid != BLE_MESH_CID_NVAL) {
         net_buf_simple_add_le16(&msg, cid);
     }
     net_buf_simple_add_le16(&msg, mod_id);
@@ -1039,7 +1037,7 @@ int bt_mesh_cfg_mod_pub_get(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
 
     bt_mesh_model_msg_init(&msg, OP_MOD_PUB_GET);
     net_buf_simple_add_le16(&msg, elem_addr);
-    if (cid != CID_NVAL) {
+    if (cid != BLE_MESH_CID_NVAL) {
         net_buf_simple_add_le16(&msg, cid);
     }
     net_buf_simple_add_le16(&msg, mod_id);
@@ -1072,7 +1070,7 @@ int bt_mesh_cfg_mod_pub_set(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
     net_buf_simple_add_u8(&msg, pub->ttl);
     net_buf_simple_add_u8(&msg, pub->period);
     net_buf_simple_add_u8(&msg, pub->transmit);
-    if (cid != CID_NVAL) {
+    if (cid != BLE_MESH_CID_NVAL) {
         net_buf_simple_add_le16(&msg, cid);
     }
     net_buf_simple_add_le16(&msg, mod_id);
@@ -1221,7 +1219,7 @@ int bt_mesh_cfg_mod_pub_va_set(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
     net_buf_simple_add_u8(&msg, pub->ttl);
     net_buf_simple_add_u8(&msg, pub->period);
     net_buf_simple_add_u8(&msg, pub->transmit);
-    if (cid != CID_NVAL) {
+    if (cid != BLE_MESH_CID_NVAL) {
         net_buf_simple_add_le16(&msg, cid);
     }
     net_buf_simple_add_le16(&msg, mod_id);
@@ -1248,7 +1246,7 @@ int bt_mesh_cfg_mod_sub_del_all(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
 
     bt_mesh_model_msg_init(&msg, OP_MOD_SUB_DEL_ALL);
     net_buf_simple_add_le16(&msg, elem_addr);
-    if (cid != CID_NVAL) {
+    if (cid != BLE_MESH_CID_NVAL) {
         net_buf_simple_add_le16(&msg, cid);
     }
     net_buf_simple_add_le16(&msg, mod_id);
@@ -1271,7 +1269,7 @@ static int mod_sub_get(u32_t op, struct bt_mesh_msg_ctx *ctx,
 
     bt_mesh_model_msg_init(&msg, op);
     net_buf_simple_add_le16(&msg, elem_addr);
-    if (cid != CID_NVAL) {
+    if (cid != BLE_MESH_CID_NVAL) {
         net_buf_simple_add_le16(&msg, cid);
     }
     net_buf_simple_add_le16(&msg, mod_id);
@@ -1290,13 +1288,13 @@ int bt_mesh_cfg_mod_sub_get(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr, u16_t
     if (!ctx || !ctx->addr) {
         return -EINVAL;
     }
-    return mod_sub_get(OP_MOD_SUB_GET, ctx, elem_addr, mod_id, CID_NVAL);
+    return mod_sub_get(OP_MOD_SUB_GET, ctx, elem_addr, mod_id, BLE_MESH_CID_NVAL);
 }
 
 int bt_mesh_cfg_mod_sub_get_vnd(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
                                 u16_t mod_id, u16_t cid)
 {
-    if (!ctx || !ctx->addr || cid == CID_NVAL) {
+    if (!ctx || !ctx->addr || cid == BLE_MESH_CID_NVAL) {
         return -EINVAL;
     }
     return mod_sub_get(OP_MOD_SUB_GET_VND, ctx, elem_addr, mod_id, cid);
@@ -1487,7 +1485,7 @@ int bt_mesh_cfg_mod_app_unbind(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
     bt_mesh_model_msg_init(&msg, OP_MOD_APP_UNBIND);
     net_buf_simple_add_le16(&msg, elem_addr);
     net_buf_simple_add_le16(&msg, app_idx);
-    if (cid != CID_NVAL) {
+    if (cid != BLE_MESH_CID_NVAL) {
         net_buf_simple_add_le16(&msg, cid);
     }
     net_buf_simple_add_le16(&msg, mod_id);
@@ -1510,7 +1508,7 @@ static int mod_app_get(u32_t op, struct bt_mesh_msg_ctx *ctx,
 
     bt_mesh_model_msg_init(&msg, op);
     net_buf_simple_add_le16(&msg, elem_addr);
-    if (cid != CID_NVAL) {
+    if (cid != BLE_MESH_CID_NVAL) {
         net_buf_simple_add_le16(&msg, cid);
     }
     net_buf_simple_add_le16(&msg, mod_id);
@@ -1529,13 +1527,13 @@ int bt_mesh_cfg_mod_app_get(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr, u16_t
     if (!ctx || !ctx->addr) {
         return -EINVAL;
     }
-    return mod_app_get(OP_SIG_MOD_APP_GET, ctx, elem_addr, mod_id, CID_NVAL);
+    return mod_app_get(OP_SIG_MOD_APP_GET, ctx, elem_addr, mod_id, BLE_MESH_CID_NVAL);
 }
 
 int bt_mesh_cfg_mod_app_get_vnd(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
                                 u16_t mod_id, u16_t cid)
 {
-    if (!ctx || !ctx->addr || cid == CID_NVAL) {
+    if (!ctx || !ctx->addr || cid == BLE_MESH_CID_NVAL) {
         return -EINVAL;
     }
     return mod_app_get(OP_VND_MOD_APP_GET, ctx, elem_addr, mod_id, cid);

+ 2 - 0
components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h

@@ -26,6 +26,8 @@
 extern "C" {
 #endif
 
+#define BLE_MESH_CID_NVAL          0xFFFF
+
 #define BLE_MESH_ADDR_UNASSIGNED   0x0000
 #define BLE_MESH_ADDR_ALL_NODES    0xffff
 #define BLE_MESH_ADDR_PROXIES      0xfffc

+ 1 - 1
examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/main/main.c

@@ -288,7 +288,7 @@ static void example_provisioning_callback(esp_ble_mesh_prov_cb_event_t event,
             esp_err_t err;
             prov_info.app_idx = param->provisioner_add_app_key_comp.app_idx;
             err = esp_ble_mesh_provisioner_bind_app_key_to_local_model(PROV_OWN_ADDR, prov_info.app_idx,
-                    ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, CID_NVAL);
+                    ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, ESP_BLE_MESH_CID_NVAL);
             if (err != ESP_OK) {
                 ESP_LOGE(TAG, "%s: Failed to bind AppKey with OnOff Client Model", __func__);
                 return;

+ 1 - 1
examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/tutorial/BLE_Mesh_Fast_Prov_Client_Example_Walkthrough.md

@@ -101,7 +101,7 @@ To control the server model, the client model uses messages to control the serve
 ```c
 prov_info.app_idx = param->provisioner_add_app_key_comp.app_idx;
 err = esp_ble_mesh_provisioner_bind_app_key_to_local_model(PROV_OWN_ADDR, prov_info.app_idx,
-                                              ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, CID_NVAL);
+                                              ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, ESP_BLE_MESH_CID_NVAL);
 if (err != ESP_OK) {
     ESP_LOGE(TAG, "%s: Failed to bind AppKey with OnOff Client Model", __func__);
     return;

+ 3 - 4
examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/main/main.c

@@ -25,7 +25,6 @@
 #define LED_ON              0x1
 
 #define CID_ESP             0x02E5
-#define CID_NVAL            0xFFFF
 
 #define PROV_OWN_ADDR       0x0001
 
@@ -323,7 +322,7 @@ static void example_ble_mesh_provisioning_cb(esp_ble_mesh_prov_cb_event_t event,
             esp_err_t err = 0;
             prov_key.app_idx = param->provisioner_add_app_key_comp.app_idx;
             err = esp_ble_mesh_provisioner_bind_app_key_to_local_model(PROV_OWN_ADDR, prov_key.app_idx,
-                    ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, CID_NVAL);
+                    ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, ESP_BLE_MESH_CID_NVAL);
             if (err != ESP_OK) {
                 ESP_LOGE(TAG, "Provisioner bind local model appkey failed");
                 return;
@@ -397,7 +396,7 @@ static void example_ble_mesh_config_client_cb(esp_ble_mesh_cfg_client_cb_event_t
             set_state.model_app_bind.element_addr = node->unicast;
             set_state.model_app_bind.model_app_idx = prov_key.app_idx;
             set_state.model_app_bind.model_id = ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV;
-            set_state.model_app_bind.company_id = CID_NVAL;
+            set_state.model_app_bind.company_id = ESP_BLE_MESH_CID_NVAL;
             err = esp_ble_mesh_config_client_set_state(&common, &set_state);
             if (err) {
                 ESP_LOGE(TAG, "%s: Config Model App Bind failed", __func__);
@@ -463,7 +462,7 @@ static void example_ble_mesh_config_client_cb(esp_ble_mesh_cfg_client_cb_event_t
             set_state.model_app_bind.element_addr = node->unicast;
             set_state.model_app_bind.model_app_idx = prov_key.app_idx;
             set_state.model_app_bind.model_id = ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV;
-            set_state.model_app_bind.company_id = CID_NVAL;
+            set_state.model_app_bind.company_id = ESP_BLE_MESH_CID_NVAL;
             err = esp_ble_mesh_config_client_set_state(&common, &set_state);
             if (err) {
                 ESP_LOGE(TAG, "%s: Config Model App Bind failed", __func__);

+ 7 - 8
examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/main/main.c

@@ -23,7 +23,6 @@
 #include "board.h"
 
 #define CID_ESP             0x02E5
-#define CID_NVAL            0xFFFF
 
 #define PROV_OWN_ADDR       0x0001
 
@@ -225,7 +224,7 @@ static void example_ble_mesh_provisioning_cb(esp_ble_mesh_prov_cb_event_t event,
         if (param->provisioner_add_app_key_comp.err_code == 0) {
             prov_key.app_idx = param->provisioner_add_app_key_comp.app_idx;
             esp_err_t err = esp_ble_mesh_provisioner_bind_app_key_to_local_model(PROV_OWN_ADDR, prov_key.app_idx,
-                                ESP_BLE_MESH_MODEL_ID_SENSOR_CLI, CID_NVAL);
+                                ESP_BLE_MESH_MODEL_ID_SENSOR_CLI, ESP_BLE_MESH_CID_NVAL);
             if (err != ESP_OK) {
                 ESP_LOGE(TAG, "Failed to bind AppKey to sensor client");
             }
@@ -334,31 +333,31 @@ static void example_ble_mesh_config_client_cb(esp_ble_mesh_cfg_client_cb_event_t
             set.model_app_bind.element_addr = node->unicast_addr;
             set.model_app_bind.model_app_idx = prov_key.app_idx;
             set.model_app_bind.model_id = ESP_BLE_MESH_MODEL_ID_SENSOR_SRV;
-            set.model_app_bind.company_id = CID_NVAL;
+            set.model_app_bind.company_id = ESP_BLE_MESH_CID_NVAL;
             err = esp_ble_mesh_config_client_set_state(&common, &set);
             if (err != ESP_OK) {
                 ESP_LOGE(TAG, "Failed to send Config Model App Bind");
                 return;
             }
             wait_model_id = ESP_BLE_MESH_MODEL_ID_SENSOR_SRV;
-            wait_cid = CID_NVAL;
+            wait_cid = ESP_BLE_MESH_CID_NVAL;
         } else if (param->params->opcode == ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND) {
             if (param->status_cb.model_app_status.model_id == ESP_BLE_MESH_MODEL_ID_SENSOR_SRV &&
-                param->status_cb.model_app_status.company_id == CID_NVAL) {
+                param->status_cb.model_app_status.company_id == ESP_BLE_MESH_CID_NVAL) {
                 example_ble_mesh_set_msg_common(&common, node, config_client.model, ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND);
                 set.model_app_bind.element_addr = node->unicast_addr;
                 set.model_app_bind.model_app_idx = prov_key.app_idx;
                 set.model_app_bind.model_id = ESP_BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV;
-                set.model_app_bind.company_id = CID_NVAL;
+                set.model_app_bind.company_id = ESP_BLE_MESH_CID_NVAL;
                 err = esp_ble_mesh_config_client_set_state(&common, &set);
                 if (err) {
                     ESP_LOGE(TAG, "Failed to send Config Model App Bind");
                     return;
                 }
                 wait_model_id = ESP_BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV;
-                wait_cid = CID_NVAL;
+                wait_cid = ESP_BLE_MESH_CID_NVAL;
             } else if (param->status_cb.model_app_status.model_id == ESP_BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV &&
-                param->status_cb.model_app_status.company_id == CID_NVAL) {
+                param->status_cb.model_app_status.company_id == ESP_BLE_MESH_CID_NVAL) {
                 ESP_LOGW(TAG, "Provision and config successfully");
             }
         }

+ 0 - 1
examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/main/main.c

@@ -24,7 +24,6 @@
 #include "board.h"
 
 #define CID_ESP     0x02E5
-#define CID_NVAL    0xFFFF
 
 /* Sensor Property ID */
 #define SENSOR_PROPERTY_ID_0        0x0056  /* Present Indoor Ambient Temperature */

+ 0 - 1
examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/main/main.c

@@ -23,7 +23,6 @@
 #include "board.h"
 
 #define CID_ESP             0x02E5
-#define CID_NVAL            0xFFFF
 
 #define PROV_OWN_ADDR       0x0001
 

+ 0 - 1
examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/main/main.c

@@ -25,7 +25,6 @@
 #include "ble_mesh_example_init.h"
 
 #define CID_ESP     0x02E5
-#define CID_NVAL    0xFFFF
 
 #define ESP_BLE_MESH_VND_MODEL_ID_CLIENT    0x0000
 #define ESP_BLE_MESH_VND_MODEL_ID_SERVER    0x0001

+ 1 - 1
examples/bluetooth/esp_ble_mesh/common_components/fast_provisioning/ble_mesh_fast_prov_client_model.c

@@ -379,7 +379,7 @@ esp_err_t example_fast_prov_client_recv_status(esp_ble_mesh_model_t *model,
             return ESP_FAIL;
         }
         cli_model = example_find_model(esp_ble_mesh_get_primary_element_address(),
-                                       ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, CID_NVAL);
+                                       ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, ESP_BLE_MESH_CID_NVAL);
         if (!cli_model) {
             ESP_LOGE(TAG, "%s: Failed to get Generic OnOff Client Model info", __func__);
             return ESP_FAIL;

+ 0 - 1
examples/bluetooth/esp_ble_mesh/common_components/fast_provisioning/ble_mesh_fast_prov_common.h

@@ -22,7 +22,6 @@
 #define LED_ON      0x01
 
 #define CID_ESP     0x02E5
-#define CID_NVAL    0xFFFF
 
 /* Fast Prov Model ID */
 #define ESP_BLE_MESH_VND_MODEL_ID_FAST_PROV_CLI                 0x0000

+ 1 - 1
examples/bluetooth/esp_ble_mesh/common_components/fast_provisioning/ble_mesh_fast_prov_operation.c

@@ -150,7 +150,7 @@ esp_ble_mesh_model_t *example_find_model(uint16_t element_addr, uint16_t model_i
         return NULL;
     }
 
-    if (company_id == CID_NVAL) {
+    if (company_id == ESP_BLE_MESH_CID_NVAL) {
         return esp_ble_mesh_find_sig_model(element, model_id);
     } else {
         return esp_ble_mesh_find_vendor_model(element, company_id, model_id);

+ 1 - 1
examples/bluetooth/esp_ble_mesh/common_components/fast_provisioning/ble_mesh_fast_prov_server_model.c

@@ -62,7 +62,7 @@ esp_ble_mesh_cfg_srv_t *get_cfg_srv_user_data(void)
     esp_ble_mesh_model_t *model = NULL;
 
     model = example_find_model(esp_ble_mesh_get_primary_element_address(),
-                               ESP_BLE_MESH_MODEL_ID_CONFIG_SRV, CID_NVAL);
+                               ESP_BLE_MESH_MODEL_ID_CONFIG_SRV, ESP_BLE_MESH_CID_NVAL);
     if (!model) {
         ESP_LOGE(TAG, "%s: Failed to get config server model", __func__);
         return NULL;