Skip to content

Commit

Permalink
Merge branch 'revert/ble_mesh_example_changes' into 'master'
Browse files Browse the repository at this point in the history
fix(ble_mesh): Check if role needed based on idf version

See merge request espressif/esp-idf!26095
  • Loading branch information
Isl2017 committed Sep 25, 2023
2 parents 923fcc2 + ec9e9ff commit 272b409
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ void example_send_self_prov_node_addr(struct k_work *work)
.app_idx = fast_prov_srv->app_idx,
.dst = fast_prov_srv->prim_prov_addr,
.timeout = 0,
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
.role = ROLE_FAST_PROV,
#endif
};
err = example_send_fast_prov_self_prov_node_addr(model, &info, node_addr_send.addr);
if (err != ESP_OK) {
Expand Down Expand Up @@ -178,6 +181,9 @@ static void example_get_all_node_addr(struct k_work *work)
.app_idx = node->app_idx,
.dst = node->unicast_addr,
.timeout = 10000,
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
.role = ROLE_PROVISIONER,
#endif
};
err = example_send_fast_prov_all_node_addr_get(model, &info);
if (err != ESP_OK) {
Expand Down Expand Up @@ -232,10 +238,16 @@ esp_err_t example_fast_prov_client_recv_timeout(uint32_t opcode, esp_ble_mesh_mo
set.ctx_flags = BIT(6);
set.group_addr = fast_prov_srv->group_addr;
}
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
info.role = ROLE_FAST_PROV;
#endif
#else
set.ctx_flags = 0x037F;
memcpy(&set.node_addr_cnt, &node->node_addr_cnt,
sizeof(example_node_info_t) - offsetof(example_node_info_t, node_addr_cnt));
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
info.role = ROLE_PROVISIONER;
#endif
#endif
err = example_send_fast_prov_info_set(model, &info, &set);
if (err != ESP_OK) {
Expand All @@ -254,6 +266,9 @@ esp_err_t example_fast_prov_client_recv_timeout(uint32_t opcode, esp_ble_mesh_mo
.app_idx = fast_prov_srv->app_idx,
.dst = fast_prov_srv->prim_prov_addr,
.timeout = 0,
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
.role = ROLE_FAST_PROV,
#endif
};
err = example_send_fast_prov_self_prov_node_addr(model, &info, node_addr_send.addr);
if (err != ESP_OK) {
Expand Down Expand Up @@ -281,6 +296,9 @@ esp_err_t example_fast_prov_client_recv_timeout(uint32_t opcode, esp_ble_mesh_mo
.app_idx = node->app_idx,
.dst = node->unicast_addr,
.timeout = 10000,
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
.role = ROLE_PROVISIONER,
#endif
};
err = example_send_fast_prov_all_node_addr_get(model, &info);
if (err != ESP_OK) {
Expand Down Expand Up @@ -378,6 +396,9 @@ esp_err_t example_fast_prov_client_recv_status(esp_ble_mesh_model_t *model,
.app_idx = node->app_idx,
.dst = node->group_addr,
.timeout = 0,
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
.role = ROLE_PROVISIONER,
#endif
};
err = example_send_generic_onoff_set(cli_model, &info, LED_ON, 0x00, false);
if (err != ESP_OK) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ esp_err_t example_send_config_appkey_add(esp_ble_mesh_model_t *model,
common.ctx.addr = info->dst;
common.ctx.send_ttl = 0;
common.msg_timeout = info->timeout;
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
common.msg_role = info->role;
#endif

return esp_ble_mesh_config_client_set_state(&common, &set);
}
Expand All @@ -372,6 +375,9 @@ esp_err_t example_send_generic_onoff_get(esp_ble_mesh_model_t *model,
common.ctx.addr = info->dst;
common.ctx.send_ttl = 0;
common.msg_timeout = info->timeout;
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
common.msg_role = info->role;
#endif

return esp_ble_mesh_generic_client_get_state(&common, &get);
}
Expand Down Expand Up @@ -403,6 +409,9 @@ esp_err_t example_send_generic_onoff_set(esp_ble_mesh_model_t *model,
common.ctx.addr = info->dst;
common.ctx.send_ttl = 0;
common.msg_timeout = info->timeout;
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
common.msg_role = info->role;
#endif

return esp_ble_mesh_generic_client_set_state(&common, &set);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ static void provisioner_prov_complete(int node_index, const uint8_t uuid[16], ui
.app_idx = node->app_idx,
.dst = node->unicast_addr,
.timeout = 0,
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
.role = ROLE_PROVISIONER,
#endif
};
esp_ble_mesh_cfg_app_key_add_t add_key = {
.net_idx = prov_info.net_idx,
Expand Down Expand Up @@ -424,6 +427,9 @@ static void example_config_client_callback(esp_ble_mesh_cfg_client_cb_event_t ev
.app_idx = node->app_idx,
.dst = node->unicast_addr,
.timeout = 0,
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
.role = ROLE_PROVISIONER,
#endif
};
err = example_send_fast_prov_info_set(fast_prov_client.model, &info, &set);
if (err != ESP_OK) {
Expand All @@ -446,6 +452,9 @@ static void example_config_client_callback(esp_ble_mesh_cfg_client_cb_event_t ev
.app_idx = node->app_idx,
.dst = node->unicast_addr,
.timeout = 0,
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
.role = ROLE_PROVISIONER,
#endif
};
esp_ble_mesh_cfg_app_key_add_t add_key = {
.net_idx = prov_info.net_idx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ static void provisioner_prov_complete(int node_idx, const uint8_t uuid[16], uint
.app_idx = node->app_idx,
.dst = node->unicast_addr,
.timeout = 0,
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
.role = ROLE_FAST_PROV,
#endif
};
err = example_send_config_appkey_add(config_client.model, &info, NULL);
if (err != ESP_OK) {
Expand Down Expand Up @@ -605,6 +608,9 @@ static void example_ble_mesh_config_client_cb(esp_ble_mesh_cfg_client_cb_event_t
.app_idx = node->app_idx,
.dst = node->unicast_addr,
.timeout = 0,
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
.role = ROLE_FAST_PROV,
#endif
};
err = example_send_fast_prov_info_set(fast_prov_client.model, &info, &set);
if (err != ESP_OK) {
Expand All @@ -627,6 +633,9 @@ static void example_ble_mesh_config_client_cb(esp_ble_mesh_cfg_client_cb_event_t
.app_idx = node->app_idx,
.dst = node->unicast_addr,
.timeout = 0,
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
.role = ROLE_FAST_PROV,
#endif
};
err = example_send_config_appkey_add(config_client.model, &info, NULL);
if (err != ESP_OK) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ void example_ble_mesh_send_gen_onoff_set(void)
common.ctx.addr = 0xFFFF; /* to all nodes */
common.ctx.send_ttl = 3;
common.msg_timeout = 0; /* 0 indicates that timeout value from menuconfig will be used */
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
common.msg_role = ROLE_NODE;
#endif

set.onoff_set.op_en = false;
set.onoff_set.onoff = store.onoff;
Expand Down
3 changes: 3 additions & 0 deletions examples/bluetooth/esp_ble_mesh/provisioner/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ static esp_err_t example_ble_mesh_set_msg_common(esp_ble_mesh_client_common_para
common->ctx.addr = node->unicast;
common->ctx.send_ttl = MSG_SEND_TTL;
common->msg_timeout = MSG_TIMEOUT;
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
common->msg_role = MSG_ROLE;
#endif

return ESP_OK;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ static void example_ble_mesh_set_msg_common(esp_ble_mesh_client_common_param_t *
common->ctx.addr = node->unicast_addr;
common->ctx.send_ttl = MSG_SEND_TTL;
common->msg_timeout = MSG_TIMEOUT;
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
common->msg_role = MSG_ROLE;
#endif
}

static esp_err_t prov_complete(uint16_t node_index, const esp_ble_mesh_octet16_t uuid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ static void example_ble_mesh_set_msg_common(esp_ble_mesh_client_common_param_t *
common->ctx.addr = node->unicast_addr;
common->ctx.send_ttl = MSG_SEND_TTL;
common->msg_timeout = MSG_TIMEOUT;
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
common->msg_role = MSG_ROLE;
#endif
}

static esp_err_t prov_complete(uint16_t node_index, const esp_ble_mesh_octet16_t uuid,
Expand Down
9 changes: 9 additions & 0 deletions examples/bluetooth/esp_ble_mesh/wifi_coexist/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ static void provisioner_prov_complete(int node_idx, const uint8_t uuid[16], uint
.app_idx = node->app_idx,
.dst = node->unicast_addr,
.timeout = 0,
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
.role = ROLE_FAST_PROV,
#endif
};
err = example_send_config_appkey_add(config_client.model, &info, NULL);
if (err != ESP_OK) {
Expand Down Expand Up @@ -617,6 +620,9 @@ static void example_ble_mesh_config_client_cb(esp_ble_mesh_cfg_client_cb_event_t
.app_idx = node->app_idx,
.dst = node->unicast_addr,
.timeout = 0,
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
.role = ROLE_FAST_PROV,
#endif
};
err = example_send_fast_prov_info_set(fast_prov_client.model, &info, &set);
if (err != ESP_OK) {
Expand All @@ -639,6 +645,9 @@ static void example_ble_mesh_config_client_cb(esp_ble_mesh_cfg_client_cb_event_t
.app_idx = node->app_idx,
.dst = node->unicast_addr,
.timeout = 0,
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
.role = ROLE_FAST_PROV,
#endif
};
err = example_send_config_appkey_add(config_client.model, &info, NULL);
if (err != ESP_OK) {
Expand Down

0 comments on commit 272b409

Please sign in to comment.