ESP32 BLE Mesh Client Example - Node Address Problem

gandiii
Posts: 5
Joined: Tue Jul 09, 2019 3:45 pm

ESP32 BLE Mesh Client Example - Node Address Problem

Postby gandiii » Tue Jul 09, 2019 4:07 pm

Hi,

I am using the ble_mesh_client_model example from branch ble_mesh_release/esp-ble-mesh-v0.6.1.
My intention is to connect a generic onoff server, running on a nrf52 board, and a generic
onoff client, running on an ESP32 LyraT board.
I modified the example to perform a esp_ble_mesh_generic_client_set_state if the
touch button is hit.

The documentation of the example says that the address of the destination should be entered
through the uart interface. But I want to send the message to all available nodes, and so I set
the address to:

Code: Select all

common.ctx.addr = ESP_BLE_MESH_ADDR_ALL_NODES;
Using this address I get the following error message:

Code: Select all

E (59555) BLE_MESH: model_send, Model not bound to AppKey 0xffff
E (59555) BLE_MESH: gen_set_state, Failed to send Generic Set message (err -22)
I (60565) ble_mesh_client: esp_ble_mesh_generic_cb: event is 1, error code is -22, opcode is 0x8202
I (60565) ble_mesh_client: ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT
I (60575) ble_mesh_client: ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET: onoff 0
I am a bit confused about the terminology of node address and AppKey?
Is there something I am missing?

Thanks in advance

Wangcheng
Posts: 73
Joined: Wed Mar 06, 2019 3:26 am

Re: ESP32 BLE Mesh Client Example - Node Address Problem

Postby Wangcheng » Wed Jul 10, 2019 7:35 am

gandiii wrote:
Tue Jul 09, 2019 4:07 pm
Hi,

I am using the ble_mesh_client_model example from branch ble_mesh_release/esp-ble-mesh-v0.6.1.
My intention is to connect a generic onoff server, running on a nrf52 board, and a generic
onoff client, running on an ESP32 LyraT board.
I modified the example to perform a esp_ble_mesh_generic_client_set_state if the
touch button is hit.

The documentation of the example says that the address of the destination should be entered
through the uart interface. But I want to send the message to all available nodes, and so I set
the address to:

Code: Select all

common.ctx.addr = ESP_BLE_MESH_ADDR_ALL_NODES;
Using this address I get the following error message:

Code: Select all

E (59555) BLE_MESH: model_send, Model not bound to AppKey 0xffff
E (59555) BLE_MESH: gen_set_state, Failed to send Generic Set message (err -22)
I (60565) ble_mesh_client: esp_ble_mesh_generic_cb: event is 1, error code is -22, opcode is 0x8202
I (60565) ble_mesh_client: ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT
I (60575) ble_mesh_client: ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET: onoff 0
I am a bit confused about the terminology of node address and AppKey?
Is there something I am missing?

Thanks in advance
Hi gandiii ,
nrf52 board(OnOff server model)
ESP32 LyraT board(OnOff client model)
1. The model of the node needs the same appkey before communication.
2. You need to bind appkey to the corresponding model of the two nodes via app. The method is described in the documentation

gandiii
Posts: 5
Joined: Tue Jul 09, 2019 3:45 pm

Re: ESP32 BLE Mesh Client Example - Node Address Problem

Postby gandiii » Wed Jul 10, 2019 9:13 am

Hi,

both devices are provisioned and configured as shown in these pictures:
Screenshot_20190710-104447.jpg
Screenshot_20190710-104447.jpg (36.38 KiB) Viewed 10360 times
Screenshot_20190710-104458.jpg
Screenshot_20190710-104458.jpg (38.98 KiB) Viewed 10360 times
I am now using a different ESP32 board, since I wasn't able to connect to
the LyraT anymore.
After the configuration, and triggering the routine to set the value on the server,
I got the following lines:

Code: Select all

E (59764) BLE_MESH: bt_mesh_trans_send, Failed to get AppKey
E (59764) BLE_MESH: gen_set_state, Failed to send Generic Set message (err -22)
I (59764) ble_mesh_client: esp_ble_mesh_generic_cb: event is 1, error code is -22, opcode is 0x8202
I (59774) ble_mesh_client: ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT
I (59784) ble_mesh_client: ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET: onoff 0
The variable common.ctx.app_idx was set to 0xffff after binding the model within the app.

Edit:
It is now working by setting the app key to 0x00 by hand.
Is there a callback I am missing which tells me the app key index I have
set during the configuration with the smart phone?

Wangcheng
Posts: 73
Joined: Wed Mar 06, 2019 3:26 am

Re: ESP32 BLE Mesh Client Example - Node Address Problem

Postby Wangcheng » Thu Jul 11, 2019 2:04 am

gandiii wrote:
Wed Jul 10, 2019 9:13 am
Hi,

both devices are provisioned and configured as shown in these pictures:
Screenshot_20190710-104447.jpg Screenshot_20190710-104458.jpg

I am now using a different ESP32 board, since I wasn't able to connect to
the LyraT anymore.
After the configuration, and triggering the routine to set the value on the server,
I got the following lines:

Code: Select all

E (59764) BLE_MESH: bt_mesh_trans_send, Failed to get AppKey
E (59764) BLE_MESH: gen_set_state, Failed to send Generic Set message (err -22)
I (59764) ble_mesh_client: esp_ble_mesh_generic_cb: event is 1, error code is -22, opcode is 0x8202
I (59774) ble_mesh_client: ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT
I (59784) ble_mesh_client: ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET: onoff 0
The variable common.ctx.app_idx was set to 0xffff after binding the model within the app.

Edit:
It is now working by setting the app key to 0x00 by hand.
Is there a callback I am missing which tells me the app key index I have
set during the configuration with the smart phone?
Adding appkey will trigger an event :ESP_BLE_MESH_MODEL_OP_APP_KEY_ADD
Binding appkey to model will trigger an event : ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND

gandiii
Posts: 5
Joined: Tue Jul 09, 2019 3:45 pm

Re: ESP32 BLE Mesh Client Example - Node Address Problem

Postby gandiii » Sat Jul 13, 2019 3:20 pm

Hi,

I have tried to figure out where the event is fired, but neither of these
callback functions are called after binding an app key to a model.

Code: Select all

esp_ble_mesh_register_prov_callback(esp_ble_mesh_prov_cb);
esp_ble_mesh_register_custom_model_callback(esp_ble_mesh_model_cb);
esp_ble_mesh_register_generic_client_callback(esp_ble_mesh_generic_cb);
I have tried to unbind and bind the key again several times.
There is also no event after setting the publishing address.

Wangcheng
Posts: 73
Joined: Wed Mar 06, 2019 3:26 am

Re: ESP32 BLE Mesh Client Example - Node Address Problem

Postby Wangcheng » Mon Jul 15, 2019 3:06 am

gandiii wrote:
Sat Jul 13, 2019 3:20 pm
Hi,

I have tried to figure out where the event is fired, but neither of these
callback functions are called after binding an app key to a model.

Code: Select all

esp_ble_mesh_register_prov_callback(esp_ble_mesh_prov_cb);
esp_ble_mesh_register_custom_model_callback(esp_ble_mesh_model_cb);
esp_ble_mesh_register_generic_client_callback(esp_ble_mesh_generic_cb);
I have tried to unbind and bind the key again several times.
There is also no event after setting the publishing address.
I have an easy way, you can add a print in this position. You can observe the operation of the application layer.
In the path: esp32-ble-mesh/components/bt/ble_mesh/mesh_core/access.c
function: void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
add: printf("-->%p-->\n",op->func);
op->func(model, &rx->ctx, buf);

nitesh2508
Posts: 13
Joined: Wed Jul 17, 2019 8:55 pm

Re: ESP32 BLE Mesh Client Example - Node Address Problem

Postby nitesh2508 » Tue Jul 30, 2019 8:11 pm

gandiii wrote:
Tue Jul 09, 2019 4:07 pm
Hi,

I am using the ble_mesh_client_model example from branch ble_mesh_release/esp-ble-mesh-v0.6.1.
My intention is to connect a generic onoff server, running on a nrf52 board, and a generic
onoff client, running on an ESP32 LyraT board.
I modified the example to perform a esp_ble_mesh_generic_client_set_state if the
touch button is hit.

The documentation of the example says that the address of the destination should be entered
through the uart interface. But I want to send the message to all available nodes, and so I set
the address to:

Code: Select all

common.ctx.addr = ESP_BLE_MESH_ADDR_ALL_NODES;
Using this address I get the following error message:

Code: Select all

E (59555) BLE_MESH: model_send, Model not bound to AppKey 0xffff
E (59555) BLE_MESH: gen_set_state, Failed to send Generic Set message (err -22)
I (60565) ble_mesh_client: esp_ble_mesh_generic_cb: event is 1, error code is -22, opcode is 0x8202
I (60565) ble_mesh_client: ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT
I (60575) ble_mesh_client: ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET: onoff 0
I am a bit confused about the terminology of node address and AppKey?
Is there something I am missing?

I am also going through same issue can u share a code snippet to understand how you're enabling generic client state when button is pressed?
Thanks in advance

Wangcheng
Posts: 73
Joined: Wed Mar 06, 2019 3:26 am

Re: ESP32 BLE Mesh Client Example - Node Address Problem

Postby Wangcheng » Wed Jul 31, 2019 2:38 am

nitesh2508 wrote:
Tue Jul 30, 2019 8:11 pm
gandiii wrote:
Tue Jul 09, 2019 4:07 pm
Hi,

I am using the ble_mesh_client_model example from branch ble_mesh_release/esp-ble-mesh-v0.6.1.
My intention is to connect a generic onoff server, running on a nrf52 board, and a generic
onoff client, running on an ESP32 LyraT board.
I modified the example to perform a esp_ble_mesh_generic_client_set_state if the
touch button is hit.

The documentation of the example says that the address of the destination should be entered
through the uart interface. But I want to send the message to all available nodes, and so I set
the address to:

Code: Select all

common.ctx.addr = ESP_BLE_MESH_ADDR_ALL_NODES;
Using this address I get the following error message:

Code: Select all

E (59555) BLE_MESH: model_send, Model not bound to AppKey 0xffff
E (59555) BLE_MESH: gen_set_state, Failed to send Generic Set message (err -22)
I (60565) ble_mesh_client: esp_ble_mesh_generic_cb: event is 1, error code is -22, opcode is 0x8202
I (60565) ble_mesh_client: ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT
I (60575) ble_mesh_client: ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET: onoff 0
I am a bit confused about the terminology of node address and AppKey?
Is there something I am missing?

I am also going through same issue can u share a code snippet to understand how you're enabling generic client state when button is pressed?
Thanks in advance
Hi,

You need to bind the device's node to Appkey.
The binding method is bound by the App or by the device.
There is a document in the ble_mesh_client project that describes in detail how to do this.
Maybe you only need to look at the pictures in the document.

Who is online

Users browsing this forum: jcolebaker and 157 guests