BLE mesh: Send message to group address

jokockx
Posts: 14
Joined: Wed Jul 03, 2019 9:12 am

BLE mesh: Send message to group address

Postby jokockx » Thu Aug 08, 2019 2:11 pm

I achieved to implement a provisioner which is able to:
- provision a node
- add and bind an application keys to both local client models as the server models in the node
I think that I was also able to add a subscription to a group address (100) to the model in the node. When I try to do so I get following logs:

Code: Select all

I (846956) BLUETOOTH: esp_ble_mesh_config_client_cb, error_code = 0x00, event = 0x01, addr: 0x0005, opcode: 0x801b
I (846956) BLUETOOTH: ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD
add_group_address:status=1,sub_addr=100,element_addr=5,model_id=4096
So, I think I'm doing things right uptill here.
Though, if I now try to send a message to the OnOff client using the group address (100) with the generic OnOff api, I get folowing error:

Code: Select all

E (872896) BLE_MESH: model_send, Failed to check DST
E (872896) BLE_MESH: gen_set_state, Failed to send Generic Set message (err -22)
I (872916) BLUETOOTH: esp_ble_mesh_generic_client_cb, error_code = 0xffffffea, event = 0x01, addr: 0x0064, opcode: 0x8203
E (872926) BLUETOOTH: Send generic client message failed, opcode 0x8203
This makes sense as the api seems to check for the destination address in the list of provisioned devices mesh_nodes based upon its unicast address. The group address is of course not present in this list.

Could someone help me out how I can get my OnOff set message to my OnOff Client using the group address?
Last edited by jokockx on Fri Aug 09, 2019 2:08 pm, edited 1 time in total.

jokockx
Posts: 14
Joined: Wed Jul 03, 2019 9:12 am

Re: Send message to group address

Postby jokockx » Fri Aug 09, 2019 1:53 pm

I added some funcitonality to my code to get the subscription list from the model I tried to add the subscription to. My assumption that the subscription in the node was successfull is probably false because I got an emty list back from this function. The code I used to add the subscription address was the following and the information I got back from this operation at callback is given in the original issue:

Code: Select all

esp_err_t esp_ble_mesh_set_msg_common(esp_ble_mesh_client_common_param_t *common,

        uint16_t unicast, int net_idx, uint16_t app_idx,
        esp_ble_mesh_model_t *model, uint32_t opcode)
{
    if (!common || !model) {
        return ESP_ERR_INVALID_ARG;
    }

    common->opcode = opcode;
    common->model = model;
    /** NetKey Index of the subnet through which to send the message. */
    common->ctx.net_idx = net_idx;
    common->ctx.app_idx = app_idx;
    /** Remote address **/
    common->ctx.addr = unicast;
    common->ctx.send_ttl = MSG_SEND_TTL;
    common->ctx.send_rel = MSG_SEND_REL;
    // MSG_TIMEOUT 0 such that the value from menuconfig will be used (in milliseconds)
    common->msg_timeout = 0;
    common->msg_role = MSG_ROLE;
    return ESP_OK;
}

int cfg_client_add_group_address(uint16_t element_addr, uint16_t sub_addr, uint16_t model_id) {
	int err;
	esp_ble_mesh_client_common_param_t common = {0};
	esp_ble_mesh_cfg_client_set_state_t set_state = {0};
	esp_ble_mesh_set_msg_common(&common, element_addr, 0, 0, config_client.model, ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD);
	set_state.model_sub_add.element_addr = element_addr;
	set_state.model_sub_add.sub_addr = sub_addr;
	set_state.model_sub_add.model_id = model_id;
	set_state.model_sub_add.company_id = CID_NVAL;
	err = esp_ble_mesh_config_client_set_state(&common, &set_state);
	if (err) {
		ESP_LOGE(TAGCFG, "%s: Config Model add subscription to group address to model", __func__);
		return err;
	}
	return err;
}


jokockx
Posts: 14
Joined: Wed Jul 03, 2019 9:12 am

Re: BLE mesh: Send message to group address

Postby jokockx » Mon Sep 09, 2019 1:47 pm

My issue is resolved. I tried to use an address from the unicast address space as a group address. Group addresses are in the range of 0xC000-0xFEFF.

Who is online

Users browsing this forum: DrMickeyLauer and 71 guests