kopia lustrzana https://github.com/espressif/esp-idf
ble_mesh: example: Add result check during mesh init
rodzic
fd6071a0fc
commit
953810aa68
|
@ -272,12 +272,16 @@ static esp_err_t ble_mesh_init(void)
|
|||
esp_ble_mesh_register_config_server_callback(example_ble_mesh_config_server_cb);
|
||||
|
||||
err = esp_ble_mesh_init(&provision, &composition);
|
||||
if (err) {
|
||||
ESP_LOGE(TAG, "Initializing mesh failed (err %d)", err);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to initialize mesh stack (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);
|
||||
err = esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to enable mesh node (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "BLE Mesh Node initialized");
|
||||
|
||||
|
|
|
@ -285,19 +285,23 @@ static void example_ble_mesh_config_server_cb(esp_ble_mesh_cfg_server_cb_event_t
|
|||
|
||||
static esp_err_t ble_mesh_init(void)
|
||||
{
|
||||
esp_err_t err;
|
||||
esp_err_t err = ESP_OK;
|
||||
|
||||
esp_ble_mesh_register_prov_callback(example_ble_mesh_provisioning_cb);
|
||||
esp_ble_mesh_register_config_server_callback(example_ble_mesh_config_server_cb);
|
||||
esp_ble_mesh_register_generic_server_callback(example_ble_mesh_generic_server_cb);
|
||||
|
||||
err = esp_ble_mesh_init(&provision, &composition);
|
||||
if (err) {
|
||||
ESP_LOGE(TAG, "Initializing mesh failed (err %d)", err);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to initialize mesh stack (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);
|
||||
err = esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to enable mesh node (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "BLE Mesh Node initialized");
|
||||
|
||||
|
|
|
@ -584,7 +584,7 @@ static void example_ble_mesh_generic_client_cb(esp_ble_mesh_generic_client_cb_ev
|
|||
static esp_err_t ble_mesh_init(void)
|
||||
{
|
||||
uint8_t match[2] = {0xdd, 0xdd};
|
||||
esp_err_t err;
|
||||
esp_err_t err = ESP_OK;
|
||||
|
||||
prov_key.net_idx = ESP_BLE_MESH_KEY_PRIMARY;
|
||||
prov_key.app_idx = APP_KEY_IDX;
|
||||
|
@ -594,18 +594,29 @@ static esp_err_t ble_mesh_init(void)
|
|||
esp_ble_mesh_register_config_client_callback(example_ble_mesh_config_client_cb);
|
||||
esp_ble_mesh_register_generic_client_callback(example_ble_mesh_generic_client_cb);
|
||||
|
||||
|
||||
err = esp_ble_mesh_init(&provision, &composition);
|
||||
if (err) {
|
||||
ESP_LOGE(TAG, "Initializing mesh failed (err %d)", err);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to initialize mesh stack (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_ble_mesh_provisioner_set_dev_uuid_match(match, sizeof(match), 0x0, false);
|
||||
err = esp_ble_mesh_provisioner_set_dev_uuid_match(match, sizeof(match), 0x0, false);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to set matching device uuid (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_ble_mesh_provisioner_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);
|
||||
err = esp_ble_mesh_provisioner_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to enable mesh provisioner (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_ble_mesh_provisioner_add_local_app_key(prov_key.app_key, prov_key.net_idx, prov_key.app_idx);
|
||||
err = esp_ble_mesh_provisioner_add_local_app_key(prov_key.app_key, prov_key.net_idx, prov_key.app_idx);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to add local AppKey (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "BLE Mesh Provisioner initialized");
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue