大家好:
我是新手小白,请教一个BLE_MESH周期性发布的一个问题。以标准on_off_cli模型为例,我想让on_off_sever模型通过发布的消息实现周期性的开关,可以通过模型设置发布的周期和地址,但是有个问题发布的消息无法回调更新(on_off状态和tid)。标准模型没有ESP_BLE_MESH_MODEL_PUBLISH_UPDATE_EVT这个事件,只有自定义模型才有。那如果我想用标准模型来实现发布自动更新消息该怎么做?如果需要手动周期性更新消息,那设置周期发布有什么用?我直接手动周期发布就可以了。请各路大神赐教,谢谢!
typedef struct {
/** Pointer to the model to which the context belongs. Initialized by the stack. */
esp_ble_mesh_model_t *model;
uint16_t publish_addr; /*!< Publish Address. */
uint16_t app_idx:12, /*!< Publish AppKey Index. */
cred:1, /*!< Friendship Credentials Flag. */
send_rel:1; /*!< Force reliable sending (segment acks) */
uint8_t ttl; /*!< Publish Time to Live. */
uint8_t retransmit; /*!< Retransmit Count & Interval Steps. */
uint8_t period; /*!< Publish Period. */
uint8_t period_div:4, /*!< Divisor for the Period. */
fast_period:1, /*!< Use FastPeriodDivisor */
count:3; /*!< Retransmissions left. */
uint32_t period_start; /*!< Start of the current period. */
/** @brief Publication buffer, containing the publication message.
*
* This will get correctly created when the publication context
* has been defined using the ESP_BLE_MESH_MODEL_PUB_DEFINE macro.
*
* ESP_BLE_MESH_MODEL_PUB_DEFINE(name, size);
*/
struct net_buf_simple *msg;
/** Callback used to update publish message. Initialized by the stack. */
esp_ble_mesh_cb_t update;//这个似乎用于更新的,但是不知道怎么用
/** Publish Period Timer. Initialized by the stack. */
struct k_delayed_work timer;
/** Role of the device that is going to publish messages */
uint8_t dev_role;
} esp_ble_mesh_model_pub_t;//模型的发布参数
/** This enum value is the event of Generic Client Model */
typedef enum {
ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT,
ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT,
ESP_BLE_MESH_GENERIC_CLIENT_PUBLISH_EVT,//发布完成的事件,不是发布之前
ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT,
ESP_BLE_MESH_GENERIC_CLIENT_EVT_MAX,
} esp_ble_mesh_generic_client_cb_event_t;//标准模型
typedef enum {
ESP_BLE_MESH_MODEL_OPERATION_EVT, /*!< User-defined models receive messages from peer devices (e.g. get, set, status, etc) event */
ESP_BLE_MESH_MODEL_SEND_COMP_EVT, /*!< User-defined models send messages completion event */
ESP_BLE_MESH_MODEL_PUBLISH_COMP_EVT, /*!< User-defined models publish messages completion event */
ESP_BLE_MESH_CLIENT_MODEL_RECV_PUBLISH_MSG_EVT, /*!< User-defined client models receive publish messages event */
ESP_BLE_MESH_CLIENT_MODEL_SEND_TIMEOUT_EVT, /*!< Timeout event for the user-defined client models that failed to receive response from peer server models */
ESP_BLE_MESH_MODEL_PUBLISH_UPDATE_EVT, /*!< When a model is configured to publish messages periodically, this event will occur during every publish period */
ESP_BLE_MESH_SERVER_MODEL_UPDATE_STATE_COMP_EVT, /*!< Server models update state value completion event */
ESP_BLE_MESH_MODEL_EVT_MAX,
} esp_ble_mesh_model_cb_event_t;//自定义模型
ble_mesh_model发布消息的问题
-
whj3900829
- Posts: 1
- Joined: Mon Apr 14, 2025 2:04 am
Jump to
- English Forum
- Explore
- News
- General Discussion
- FAQ
- Documentation
- Documentation
- Sample Code
- Discussion Forum
- ESP32-S31
- Hardware
- ESP-IDF
- ESP-BOX
- ESP-ADF
- ESP-MDF
- ESP-WHO
- ESP-SkaiNet
- ESP32 Arduino
- IDEs for ESP-IDF
- ESP-AT
- ESP IoT Solution
- ESP RainMaker
- Rust
- ESP8266
- Report Bugs
- Showcase
- Chinese Forum 中文社区
- 活动区
- 乐鑫活动专区
- 讨论区
- ESP32-S31 中文讨论版
- 喵伴 中文讨论版
- ESP-IDF 中文讨论版
- 《ESP32-C3 物联网工程开发实战》书籍讨论版
- 中文文档讨论版
- ESP-AT 中文讨论版
- ESP-BOX 中文讨论版
- ESP IoT Solution 中文讨论版
- ESP-ADF 中文讨论版
- ESP Mesh 中文讨论版
- ESP Cloud 中文讨论版
- ESP-WHO 中文讨论版
- ESP-SkaiNet 中文讨论版
- ESP 生产支持讨论版
- 硬件问题讨论
- 项目展示
Who is online
Users browsing this forum: No registered users and 1 guest
- All times are UTC
- Top
- Delete cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. ESP8266EX and ESP32 are some of our products.
Information
Espressif ESP32 ... Available now!