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

User avatar
fb_iceg
Posts: 18
Joined: Tue Aug 22, 2023 7:29 am

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

Postby fb_iceg » Tue Mar 19, 2024 1:51 am

找到一个 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这个事件如何触发呢?

chegewara
Posts: 2375
Joined: Wed Jun 14, 2017 9:00 pm

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

Postby chegewara » Tue Mar 19, 2024 2:47 am

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.

User avatar
fb_iceg
Posts: 18
Joined: Tue Aug 22, 2023 7:29 am

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

Postby fb_iceg » Fri Mar 29, 2024 10:29 am

已经解决了,
先订阅一个组播地址之后,客户端直接向组播地址发送数据就可以了

Who is online

Users browsing this forum: No registered users and 34 guests