Page 1 of 1

ESP32C6, BLE MESH,使用 Vendor,如何广播信息呢,

Posted: Tue Mar 19, 2024 1:51 am
by fb_iceg
找到一个 esp_ble_mesh_model_publish(),但是试了好多办法,都没有成功,

Code: Select all

esp_ble_mesh_model_pub_t vendor_model_pub_config;

static const esp_ble_mesh_client_op_pair_t vnd_op_pair[] = {
    { ESP_BLE_MESH_VND_MODEL_OP_SEND, ESP_BLE_MESH_VND_MODEL_OP_STATUS },
};

static esp_ble_mesh_client_t vendor_client = {
    .op_pair_size = ARRAY_SIZE(vnd_op_pair),
    .op_pair = vnd_op_pair,
};

static esp_ble_mesh_model_op_t vnd_op_status[] = {
    ESP_BLE_MESH_MODEL_OP(ESP_BLE_MESH_VND_MODEL_OP_STATUS, 2),
    ESP_BLE_MESH_MODEL_OP_END,
};

static esp_ble_mesh_model_t vnd_models_cli[] = {
    ESP_BLE_MESH_VENDOR_MODEL(CID_ESP, ESP_BLE_MESH_VND_MODEL_ID_CLIENT,
    vnd_op_status, &vendor_model_pub_config, &vendor_client),
};
esp_ble_mesh_model_publish()说明中提到 esp_ble_mesh_model_pub_t.msg 必须包含一个有效数据,且必须再事件ESP_BLE_MESH_MODEL_PUBLISH_UPDATE_EVT 中调用该函数,但是ESP_BLE_MESH_MODEL_PUBLISH_UPDATE_EVT这个事件如何触发呢?

Re: ESP32C6, BLE MESH,使用 Vendor,如何广播信息呢,

Posted: Tue Mar 19, 2024 2:47 am
by chegewara
Hi,
i will try to answer your question. You can use this function to publish vendor model data

Code: Select all

esp_ble_mesh_model_publish(model, ESP_BLE_MESH_VND_MODEL_OP_STATUS, len, data, ROLE_NODE);
As far as i know, but i may be wrong, its the only option to publish vendor model at the moment.
Remember to setup publish options (with provisioner) like address, period etc on that model.

Re: ESP32C6, BLE MESH,使用 Vendor,如何广播信息呢,

Posted: Fri Mar 29, 2024 10:29 am
by fb_iceg
已经解决了,
先订阅一个组播地址之后,客户端直接向组播地址发送数据就可以了