Prvni ulozeni z chegewara githubu
This commit is contained in:
@ -0,0 +1,182 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_BLE_API_H_
|
||||
#define _ESP_BLE_MESH_BLE_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** This enum value is the event of BLE operations */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT, /*!< Start BLE advertising completion event */
|
||||
ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT, /*!< Stop BLE advertising completion event */
|
||||
ESP_BLE_MESH_START_BLE_SCANNING_COMP_EVT, /*!< Start BLE scanning completion event */
|
||||
ESP_BLE_MESH_STOP_BLE_SCANNING_COMP_EVT, /*!< Stop BLE scanning completion event */
|
||||
ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT, /*!< Scanning BLE advertising packets event */
|
||||
ESP_BLE_MESH_BLE_EVT_MAX,
|
||||
} esp_ble_mesh_ble_cb_event_t;
|
||||
|
||||
/** BLE operation callback parameters */
|
||||
typedef union {
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT
|
||||
*/
|
||||
struct {
|
||||
int err_code; /*!< Indicate the result of starting BLE advertising */
|
||||
uint8_t index; /*!< Index of the BLE advertising */
|
||||
} start_ble_advertising_comp; /*!< Event parameters of ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT
|
||||
*/
|
||||
struct {
|
||||
int err_code; /*!< Indicate the result of stopping BLE advertising */
|
||||
uint8_t index; /*!< Index of the BLE advertising */
|
||||
} stop_ble_advertising_comp; /*!< Event parameters of ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_START_BLE_SCANNING_COMP_EVT
|
||||
*/
|
||||
struct {
|
||||
int err_code; /*!< Indicate the result of starting BLE scanning */
|
||||
} start_ble_scan_comp; /*!< Event parameters of ESP_BLE_MESH_START_BLE_SCANNING_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_STOP_BLE_SCANNING_COMP_EVT
|
||||
*/
|
||||
struct {
|
||||
int err_code; /*!< Indicate the result of stopping BLE scanning */
|
||||
} stop_ble_scan_comp; /*!< Event parameters of ESP_BLE_MESH_STOP_BLE_SCANNING_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT
|
||||
*/
|
||||
struct {
|
||||
uint8_t addr[6]; /*!< Device address */
|
||||
uint8_t addr_type; /*!< Device address type */
|
||||
uint8_t adv_type; /*!< Advertising data type */
|
||||
uint8_t *data; /*!< Advertising data */
|
||||
uint16_t length; /*!< Advertising data length */
|
||||
int8_t rssi; /*!< RSSI of the advertising packet */
|
||||
} scan_ble_adv_pkt; /*!< Event parameters of ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT */
|
||||
} esp_ble_mesh_ble_cb_param_t;
|
||||
|
||||
/**
|
||||
* @brief BLE scanning callback function type
|
||||
*
|
||||
* @param event: BLE scanning callback event type
|
||||
* @param param: BLE scanning callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_ble_cb_t)(esp_ble_mesh_ble_cb_event_t event,
|
||||
esp_ble_mesh_ble_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE scanning callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the BLE scaning callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_ble_callback(esp_ble_mesh_ble_cb_t callback);
|
||||
|
||||
/** Count for sending BLE advertising packet infinitely */
|
||||
#define ESP_BLE_MESH_BLE_ADV_INFINITE 0xFFFF
|
||||
|
||||
/*!< This enum value is the priority of BLE advertising packet */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_BLE_ADV_PRIO_LOW,
|
||||
ESP_BLE_MESH_BLE_ADV_PRIO_HIGH,
|
||||
} esp_ble_mesh_ble_adv_priority_t;
|
||||
|
||||
/** Context of BLE advertising parameters. */
|
||||
typedef struct {
|
||||
uint16_t interval; /*!< BLE advertising interval */
|
||||
uint8_t adv_type; /*!< BLE advertising type */
|
||||
uint8_t own_addr_type; /*!< Own address type */
|
||||
uint8_t peer_addr_type; /*!< Peer address type */
|
||||
uint8_t peer_addr[BD_ADDR_LEN]; /*!< Peer address */
|
||||
uint16_t duration; /*!< Duration is milliseconds */
|
||||
uint16_t period; /*!< Period in milliseconds */
|
||||
uint16_t count; /*!< Number of advertising duration */
|
||||
uint8_t priority:2; /*!< Priority of BLE advertising packet */
|
||||
} esp_ble_mesh_ble_adv_param_t;
|
||||
|
||||
/** Context of BLE advertising data. */
|
||||
typedef struct {
|
||||
uint8_t adv_data_len; /*!< Advertising data length */
|
||||
uint8_t adv_data[31]; /*!< Advertising data */
|
||||
uint8_t scan_rsp_data_len; /*!< Scan response data length */
|
||||
uint8_t scan_rsp_data[31]; /*!< Scan response data */
|
||||
} esp_ble_mesh_ble_adv_data_t;
|
||||
|
||||
/**
|
||||
* @brief This function is called to start BLE advertising with the corresponding data
|
||||
* and parameters while BLE Mesh is working at the same time.
|
||||
*
|
||||
* @note 1. When this function is called, the BLE advertising packet will be posted to
|
||||
* the BLE mesh adv queue in the mesh stack and waited to be sent.
|
||||
* 2. In the BLE advertising parameters, the "duration" means the time used for
|
||||
* sending the BLE advertising packet each time, it shall not be smaller than the
|
||||
* advertising interval. When the packet is sent successfully, it will be posted
|
||||
* to the adv queue again after the "period" time if the "count" is bigger than 0.
|
||||
* The "count" means how many durations the packet will be sent after it is sent
|
||||
* successfully for the first time. And if the "count" is set to 0xFFFF, which
|
||||
* means the packet will be sent infinitely.
|
||||
* 3. The "priority" means the priority of BLE advertising packet compared with
|
||||
* BLE Mesh packets. Currently two options (i.e. low/high) are provided. If the
|
||||
* "priority" is high, the BLE advertising packet will be posted to the front of
|
||||
* adv queue. Otherwise it will be posted to the back of adv queue.
|
||||
*
|
||||
* @param[in] param: Pointer to the BLE advertising parameters
|
||||
* @param[in] data: Pointer to the BLE advertising data and scan response data
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_start_ble_advertising(const esp_ble_mesh_ble_adv_param_t *param,
|
||||
const esp_ble_mesh_ble_adv_data_t *data);
|
||||
|
||||
/**
|
||||
* @brief This function is called to stop BLE advertising with the corresponding index.
|
||||
*
|
||||
* @param[in] index: Index of BLE advertising
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_stop_ble_advertising(uint8_t index);
|
||||
|
||||
/** Context of BLE scanning parameters. */
|
||||
typedef struct {
|
||||
uint32_t duration; /*!< Duration used to scan normal BLE advertising packets */
|
||||
} esp_ble_mesh_ble_scan_param_t;
|
||||
|
||||
/**
|
||||
* @brief This function is called to start scanning normal BLE advertising packets
|
||||
* and notifying the packets to the application layer.
|
||||
*
|
||||
* @param[in] param: Pointer to the BLE scanning parameters
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_start_ble_scanning(esp_ble_mesh_ble_scan_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief This function is called to stop notifying normal BLE advertising packets
|
||||
* to the application layer.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_stop_ble_scanning(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_BLE_API_H_ */
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_COMMON_API_H_
|
||||
#define _ESP_BLE_MESH_COMMON_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialize BLE Mesh module.
|
||||
* This API initializes provisioning capabilities and composition data information.
|
||||
*
|
||||
* @note After calling this API, the device needs to call esp_ble_mesh_prov_enable()
|
||||
* to enable provisioning functionality again.
|
||||
*
|
||||
* @param[in] prov: Pointer to the device provisioning capabilities. This pointer must
|
||||
* remain valid during the lifetime of the BLE Mesh device.
|
||||
* @param[in] comp: Pointer to the device composition data information. This pointer
|
||||
* must remain valid during the lifetime of the BLE Mesh device.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp);
|
||||
|
||||
/**
|
||||
* @brief De-initialize BLE Mesh module.
|
||||
*
|
||||
* @note This function shall be invoked after esp_ble_mesh_client_model_deinit().
|
||||
*
|
||||
* @param[in] param: Pointer to the structure of BLE Mesh deinit parameters.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_deinit(esp_ble_mesh_deinit_param_t *param);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_COMMON_API_H_ */
|
@ -0,0 +1,207 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_LOCAL_DATA_OPERATION_API_H_
|
||||
#define _ESP_BLE_MESH_LOCAL_DATA_OPERATION_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Get the model publish period, the unit is ms.
|
||||
*
|
||||
* @param[in] model: Model instance pointer.
|
||||
*
|
||||
* @return Publish period value on success, 0 or (negative) error code from errno.h on failure.
|
||||
*
|
||||
*/
|
||||
int32_t esp_ble_mesh_get_model_publish_period(esp_ble_mesh_model_t *model);
|
||||
|
||||
/**
|
||||
* @brief Get the address of the primary element.
|
||||
*
|
||||
* @return Address of the primary element on success, or
|
||||
* ESP_BLE_MESH_ADDR_UNASSIGNED on failure which means the device has not been provisioned.
|
||||
*
|
||||
*/
|
||||
uint16_t esp_ble_mesh_get_primary_element_address(void);
|
||||
|
||||
/**
|
||||
* @brief Check if the model has subscribed to the given group address.
|
||||
* Note: E.g., once a status message is received and the destination address
|
||||
* is a group address, the model uses this API to check if it is successfully subscribed
|
||||
* to the given group address.
|
||||
*
|
||||
* @param[in] model: Pointer to the model.
|
||||
* @param[in] group_addr: Group address.
|
||||
*
|
||||
* @return Pointer to the group address within the Subscription List of the model on success, or
|
||||
* NULL on failure which means the model has not subscribed to the given group address.
|
||||
* Note: With the pointer to the group address returned, you can reset the group address
|
||||
* to 0x0000 in order to unsubscribe the model from the group.
|
||||
*
|
||||
*/
|
||||
uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model,
|
||||
uint16_t group_addr);
|
||||
|
||||
/**
|
||||
* @brief Find the BLE Mesh element pointer via the element address.
|
||||
*
|
||||
* @param[in] element_addr: Element address.
|
||||
*
|
||||
* @return Pointer to the element on success, or NULL on failure.
|
||||
*
|
||||
*/
|
||||
esp_ble_mesh_elem_t *esp_ble_mesh_find_element(uint16_t element_addr);
|
||||
|
||||
/**
|
||||
* @brief Get the number of elements that have been registered.
|
||||
*
|
||||
* @return Number of elements.
|
||||
*
|
||||
*/
|
||||
uint8_t esp_ble_mesh_get_element_count(void);
|
||||
|
||||
/**
|
||||
* @brief Find the Vendor specific model with the given element,
|
||||
* the company ID and the Vendor Model ID.
|
||||
*
|
||||
* @param[in] element: Element to which the model belongs.
|
||||
* @param[in] company_id: A 16-bit company identifier assigned by the Bluetooth SIG.
|
||||
* @param[in] model_id: A 16-bit vendor-assigned model identifier.
|
||||
*
|
||||
* @return Pointer to the Vendor Model on success, or NULL on failure which means the Vendor Model is not found.
|
||||
*
|
||||
*/
|
||||
esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *element,
|
||||
uint16_t company_id, uint16_t model_id);
|
||||
|
||||
/**
|
||||
* @brief Find the SIG model with the given element and Model id.
|
||||
*
|
||||
* @param[in] element: Element to which the model belongs.
|
||||
* @param[in] model_id: SIG model identifier.
|
||||
*
|
||||
* @return Pointer to the SIG Model on success, or NULL on failure which means the SIG Model is not found.
|
||||
*
|
||||
*/
|
||||
esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element,
|
||||
uint16_t model_id);
|
||||
|
||||
/**
|
||||
* @brief Get the Composition data which has been registered.
|
||||
*
|
||||
* @return Pointer to the Composition data on success, or NULL on failure which means the Composition data is not initialized.
|
||||
*
|
||||
*/
|
||||
const esp_ble_mesh_comp_t *esp_ble_mesh_get_composition_data(void);
|
||||
|
||||
/**
|
||||
* @brief A local model of node or Provisioner subscribes a group address.
|
||||
*
|
||||
* @note This function shall not be invoked before node is provisioned or Provisioner is enabled.
|
||||
*
|
||||
* @param[in] element_addr: Unicast address of the element to which the model belongs.
|
||||
* @param[in] company_id: A 16-bit company identifier.
|
||||
* @param[in] model_id: A 16-bit model identifier.
|
||||
* @param[in] group_addr: The group address to be subscribed.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_model_subscribe_group_addr(uint16_t element_addr, uint16_t company_id,
|
||||
uint16_t model_id, uint16_t group_addr);
|
||||
|
||||
/**
|
||||
* @brief A local model of node or Provisioner unsubscribes a group address.
|
||||
*
|
||||
* @note This function shall not be invoked before node is provisioned or Provisioner is enabled.
|
||||
*
|
||||
* @param[in] element_addr: Unicast address of the element to which the model belongs.
|
||||
* @param[in] company_id: A 16-bit company identifier.
|
||||
* @param[in] model_id: A 16-bit model identifier.
|
||||
* @param[in] group_addr: The subscribed group address.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_model_unsubscribe_group_addr(uint16_t element_addr, uint16_t company_id,
|
||||
uint16_t model_id, uint16_t group_addr);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Node to get the local NetKey.
|
||||
*
|
||||
* @param[in] net_idx: NetKey index.
|
||||
*
|
||||
* @return NetKey on success, or NULL on failure.
|
||||
*
|
||||
*/
|
||||
const uint8_t *esp_ble_mesh_node_get_local_net_key(uint16_t net_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Node to get the local AppKey.
|
||||
*
|
||||
* @param[in] app_idx: AppKey index.
|
||||
*
|
||||
* @return AppKey on success, or NULL on failure.
|
||||
*
|
||||
*/
|
||||
const uint8_t *esp_ble_mesh_node_get_local_app_key(uint16_t app_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Node to add a local NetKey.
|
||||
*
|
||||
* @param[in] net_key: NetKey to be added.
|
||||
* @param[in] net_idx: NetKey Index.
|
||||
*
|
||||
* @note This function can only be called after the device is provisioned.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_node_add_local_net_key(const uint8_t net_key[16], uint16_t net_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Node to add a local AppKey.
|
||||
*
|
||||
* @param[in] app_key: AppKey to be added.
|
||||
* @param[in] net_idx: NetKey Index.
|
||||
* @param[in] app_idx: AppKey Index.
|
||||
*
|
||||
* @note The net_idx must be an existing one.
|
||||
* This function can only be called after the device is provisioned.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_node_add_local_app_key(const uint8_t app_key[16], uint16_t net_idx, uint16_t app_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Node to bind AppKey to model locally.
|
||||
*
|
||||
* @param[in] element_addr: Node local element address
|
||||
* @param[in] company_id: Node local company id
|
||||
* @param[in] model_id: Node local model id
|
||||
* @param[in] app_idx: Node local appkey index
|
||||
*
|
||||
* @note If going to bind app_key with local vendor model, the company_id
|
||||
* shall be set to 0xFFFF.
|
||||
* This function can only be called after the device is provisioned.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_node_bind_app_key_to_local_model(uint16_t element_addr, uint16_t company_id,
|
||||
uint16_t model_id, uint16_t app_idx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_LOCAL_DATA_OPERATION_API_H_ */
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_LOW_POWER_API_H_
|
||||
#define _ESP_BLE_MESH_LOW_POWER_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable BLE Mesh device LPN functionality.
|
||||
*
|
||||
* @note This API enables LPN functionality. Once called, the proper
|
||||
* Friend Request will be sent.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_lpn_enable(void);
|
||||
|
||||
/**
|
||||
* @brief Disable BLE Mesh device LPN functionality.
|
||||
*
|
||||
* @param[in] force: when disabling LPN functionality, use this flag to indicate
|
||||
* whether directly clear corresponding information or just
|
||||
* send friend clear to disable it if friendship has already
|
||||
* been established.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_lpn_disable(bool force);
|
||||
|
||||
/**
|
||||
* @brief LPN tries to poll messages from the Friend Node.
|
||||
*
|
||||
* @note The Friend Poll message is sent by a Low Power node to ask the Friend
|
||||
* node to send a message that it has stored for the Low Power node.
|
||||
* Users can call this API to send Friend Poll message manually. If this
|
||||
* API is not invoked, the bottom layer of the Low Power node will send
|
||||
* Friend Poll before the PollTimeout timer expires.
|
||||
* If the corresponding Friend Update is received and MD is set to 0,
|
||||
* which means there are no messages for the Low Power node, then the
|
||||
* Low Power node will stop scanning.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_lpn_poll(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_LOW_POWER_API_H_ */
|
@ -0,0 +1,648 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_NETWORKING_API_H_
|
||||
#define _ESP_BLE_MESH_NETWORKING_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @brief: event, event code of user-defined model events; param, parameters of user-defined model events */
|
||||
typedef void (* esp_ble_mesh_model_cb_t)(esp_ble_mesh_model_cb_event_t event,
|
||||
esp_ble_mesh_model_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh callback for user-defined models' operations.
|
||||
* This callback can report the following events generated for the user-defined models:
|
||||
* - Call back the messages received by user-defined client and server models to the
|
||||
* application layer;
|
||||
* - If users call esp_ble_mesh_server/client_model_send, this callback notifies the
|
||||
* application layer of the send_complete event;
|
||||
* - If user-defined client model sends a message that requires response, and the response
|
||||
* message is received after the timer expires, the response message will be reported
|
||||
* to the application layer as published by a peer device;
|
||||
* - If the user-defined client model fails to receive the response message during a specified
|
||||
* period of time, a timeout event will be reported to the application layer.
|
||||
*
|
||||
* @note The client models (i.e. Config Client model, Health Client model, Generic
|
||||
* Client models, Sensor Client model, Scene Client model and Lighting Client models)
|
||||
* that have been realized internally have their specific register functions.
|
||||
* For example, esp_ble_mesh_register_config_client_callback is the register
|
||||
* function for Config Client Model.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_custom_model_callback(esp_ble_mesh_model_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Add the message opcode to the beginning of the model message
|
||||
* before sending or publishing the model message.
|
||||
*
|
||||
* @note This API is only used to set the opcode of the message.
|
||||
*
|
||||
* @param[in] data: Pointer to the message data.
|
||||
* @param[in] opcode: The message opcode.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_model_msg_opcode_init(uint8_t *data, uint32_t opcode);
|
||||
|
||||
/**
|
||||
* @brief Initialize the user-defined client model. All user-defined client models
|
||||
* shall call this function to initialize the client model internal data.
|
||||
* Node: Before calling this API, the op_pair_size and op_pair variabled within
|
||||
* the user_data(defined using esp_ble_mesh_client_t_) of the client model
|
||||
* need to be initialized.
|
||||
*
|
||||
* @param[in] model: BLE Mesh Client model to which the message belongs.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_client_model_init(esp_ble_mesh_model_t *model);
|
||||
|
||||
/**
|
||||
* @brief De-initialize the user-defined client model.
|
||||
*
|
||||
* @note This function shall be invoked before esp_ble_mesh_deinit() is called.
|
||||
*
|
||||
* @param[in] model: Pointer of the Client model.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model);
|
||||
|
||||
/**
|
||||
* @brief Send server model messages(such as server model status messages).
|
||||
*
|
||||
* @param[in] model: BLE Mesh Server Model to which the message belongs.
|
||||
* @param[in] ctx: Message context, includes keys, TTL, etc.
|
||||
* @param[in] opcode: Message opcode.
|
||||
* @param[in] length: Message length (exclude the message opcode).
|
||||
* @param[in] data: Parameters of Access Payload (exclude the message opcode) to be sent.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_msg_ctx_t *ctx,
|
||||
uint32_t opcode,
|
||||
uint16_t length, uint8_t *data);
|
||||
|
||||
/**
|
||||
* @brief Send client model message (such as model get, set, etc).
|
||||
*
|
||||
* @param[in] model: BLE Mesh Client Model to which the message belongs.
|
||||
* @param[in] ctx: Message context, includes keys, TTL, etc.
|
||||
* @param[in] opcode: Message opcode.
|
||||
* @param[in] length: Message length (exclude the message opcode).
|
||||
* @param[in] data: Parameters of the Access Payload (exclude the message opcode) to be sent.
|
||||
* @param[in] msg_timeout: Time to get response to the message (in milliseconds).
|
||||
* @param[in] need_rsp: TRUE if the opcode requires the peer device to reply, FALSE otherwise.
|
||||
* @param[in] device_role: Role of the device (Node/Provisioner) that sends the message.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_client_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_msg_ctx_t *ctx,
|
||||
uint32_t opcode,
|
||||
uint16_t length, uint8_t *data,
|
||||
int32_t msg_timeout, bool need_rsp,
|
||||
esp_ble_mesh_dev_role_t device_role);
|
||||
|
||||
/**
|
||||
* @brief Send a model publication message.
|
||||
*
|
||||
* @note Before calling this function, the user needs to ensure that the model
|
||||
* publication message (@ref esp_ble_mesh_model_pub_t.msg) contains a valid
|
||||
* message to be sent. And if users want to update the publishing message,
|
||||
* this API should be called in ESP_BLE_MESH_MODEL_PUBLISH_UPDATE_EVT
|
||||
* with the message updated.
|
||||
*
|
||||
*
|
||||
* @param[in] model: Mesh (client) Model publishing the message.
|
||||
* @param[in] opcode: Message opcode.
|
||||
* @param[in] length: Message length (exclude the message opcode).
|
||||
* @param[in] data: Parameters of the Access Payload (exclude the message opcode) to be sent.
|
||||
* @param[in] device_role: Role of the device (node/provisioner) publishing the message of the type esp_ble_mesh_dev_role_t.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_model_publish(esp_ble_mesh_model_t *model, uint32_t opcode,
|
||||
uint16_t length, uint8_t *data,
|
||||
esp_ble_mesh_dev_role_t device_role);
|
||||
|
||||
/**
|
||||
* @brief Update a server model state value. If the model publication
|
||||
* state is set properly (e.g. publish address is set to a valid
|
||||
* address), it will publish corresponding status message.
|
||||
*
|
||||
* @note Currently this API is used to update bound state value, not
|
||||
* for all server model states.
|
||||
*
|
||||
* @param[in] model: Server model which is going to update the state.
|
||||
* @param[in] type: Server model state type.
|
||||
* @param[in] value: Server model state value.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_server_model_update_state(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_server_state_type_t type,
|
||||
esp_ble_mesh_server_state_value_t *value);
|
||||
|
||||
/**
|
||||
* @brief Reset the provisioning procedure of the local BLE Mesh node.
|
||||
*
|
||||
* @note All provisioning information in this node will be deleted and the node
|
||||
* needs to be reprovisioned. The API function esp_ble_mesh_node_prov_enable()
|
||||
* needs to be called to start a new provisioning procedure.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_node_local_reset(void);
|
||||
|
||||
/**
|
||||
* @brief This function is called to set the node (provisioned device) name.
|
||||
*
|
||||
* @param[in] index: Index of the node in the node queue.
|
||||
* @param[in] name: Name (end by '\0') to be set for the node.
|
||||
*
|
||||
* @note index is obtained from the parameters of ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_set_node_name(uint16_t index, const char *name);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get the node (provisioned device) name.
|
||||
*
|
||||
* @param[in] index: Index of the node in the node queue.
|
||||
*
|
||||
* @note index is obtained from the parameters of ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT.
|
||||
*
|
||||
* @return Node name on success, or NULL on failure.
|
||||
*
|
||||
*/
|
||||
const char *esp_ble_mesh_provisioner_get_node_name(uint16_t index);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get the node (provisioned device) index.
|
||||
*
|
||||
* @param[in] name: Name of the node (end by '\0').
|
||||
*
|
||||
* @return Node index on success, or an invalid value (0xFFFF) on failure.
|
||||
*
|
||||
*/
|
||||
uint16_t esp_ble_mesh_provisioner_get_node_index(const char *name);
|
||||
|
||||
/**
|
||||
* @brief This function is called to store the Composition Data of the node.
|
||||
*
|
||||
* @param[in] unicast_addr: Element address of the node
|
||||
* @param[in] data: Pointer of Composition Data
|
||||
* @param[in] length: Length of Composition Data
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr,
|
||||
uint8_t *data, uint16_t length);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get the provisioned node information
|
||||
* with the node device uuid.
|
||||
*
|
||||
* @param[in] uuid: Device UUID of the node
|
||||
*
|
||||
* @return Pointer of the node info struct or NULL on failure.
|
||||
*
|
||||
*/
|
||||
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_uuid(const uint8_t uuid[16]);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get the provisioned node information
|
||||
* with the node unicast address.
|
||||
*
|
||||
* @param[in] unicast_addr: Unicast address of the node
|
||||
*
|
||||
* @return Pointer of the node info struct or NULL on failure.
|
||||
*
|
||||
*/
|
||||
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_addr(uint16_t unicast_addr);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get the provisioned node information
|
||||
* with the node name.
|
||||
*
|
||||
* @param[in] name: Name of the node (end by '\0').
|
||||
*
|
||||
* @return Pointer of the node info struct or NULL on failure.
|
||||
*
|
||||
*/
|
||||
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_name(const char *name);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to get provisioned node count.
|
||||
*
|
||||
* @return Number of the provisioned nodes.
|
||||
*
|
||||
*/
|
||||
uint16_t esp_ble_mesh_provisioner_get_prov_node_count(void);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to get the entry of the node table.
|
||||
*
|
||||
* @note After invoking the function to get the entry of nodes, users can use the "for"
|
||||
* loop combined with the macro CONFIG_BLE_MESH_MAX_PROV_NODES to get each node's
|
||||
* information. Before trying to read the node's information, users need to check
|
||||
* if the node exists, i.e. if the *(esp_ble_mesh_node_t **node) is NULL.
|
||||
* For example:
|
||||
* ```
|
||||
* const esp_ble_mesh_node_t **entry = esp_ble_mesh_provisioner_get_node_table_entry();
|
||||
* for (int i = 0; i < CONFIG_BLE_MESH_MAX_PROV_NODES; i++) {
|
||||
* const esp_ble_mesh_node_t *node = entry[i];
|
||||
* if (node) {
|
||||
* ......
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @return Pointer to the start of the node table.
|
||||
*
|
||||
*/
|
||||
const esp_ble_mesh_node_t **esp_ble_mesh_provisioner_get_node_table_entry(void);
|
||||
|
||||
/**
|
||||
* @brief This function is called to delete the provisioned node information
|
||||
* with the node device uuid.
|
||||
*
|
||||
* @param[in] uuid: Device UUID of the node
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_delete_node_with_uuid(const uint8_t uuid[16]);
|
||||
|
||||
/**
|
||||
* @brief This function is called to delete the provisioned node information
|
||||
* with the node unicast address.
|
||||
*
|
||||
* @param[in] unicast_addr: Unicast address of the node
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_delete_node_with_addr(uint16_t unicast_addr);
|
||||
|
||||
/**
|
||||
* @brief This function is called to add a local AppKey for Provisioner.
|
||||
*
|
||||
* @param[in] app_key: The app key to be set for the local BLE Mesh stack.
|
||||
* @param[in] net_idx: The network key index.
|
||||
* @param[in] app_idx: The app key index.
|
||||
*
|
||||
* @note app_key: If set to NULL, app_key will be generated internally.
|
||||
* net_idx: Should be an existing one.
|
||||
* app_idx: If it is going to be generated internally, it should be set to
|
||||
* 0xFFFF, and the new app_idx will be reported via an event.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
|
||||
uint16_t net_idx, uint16_t app_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is used to update a local AppKey for Provisioner.
|
||||
*
|
||||
* @param[in] app_key: Value of the AppKey.
|
||||
* @param[in] net_idx: Corresponding NetKey Index.
|
||||
* @param[in] app_idx: The AppKey Index
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_update_local_app_key(const uint8_t app_key[16],
|
||||
uint16_t net_idx, uint16_t app_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to get the local app key value.
|
||||
*
|
||||
* @param[in] net_idx: Network key index.
|
||||
* @param[in] app_idx: Application key index.
|
||||
*
|
||||
* @return App key on success, or NULL on failure.
|
||||
*
|
||||
*/
|
||||
const uint8_t *esp_ble_mesh_provisioner_get_local_app_key(uint16_t net_idx, uint16_t app_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to bind own model with proper app key.
|
||||
*
|
||||
* @param[in] element_addr: Provisioner local element address
|
||||
* @param[in] app_idx: Provisioner local appkey index
|
||||
* @param[in] model_id: Provisioner local model id
|
||||
* @param[in] company_id: Provisioner local company id
|
||||
*
|
||||
* @note company_id: If going to bind app_key with local vendor model, company_id
|
||||
* should be set to 0xFFFF.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_addr, uint16_t app_idx,
|
||||
uint16_t model_id, uint16_t company_id);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to add local network key.
|
||||
*
|
||||
* @param[in] net_key: The network key to be added to the Provisioner local BLE Mesh stack.
|
||||
* @param[in] net_idx: The network key index.
|
||||
*
|
||||
* @note net_key: If set to NULL, net_key will be generated internally.
|
||||
* net_idx: If it is going to be generated internally, it should be set to
|
||||
* 0xFFFF, and the new net_idx will be reported via an event.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_add_local_net_key(const uint8_t net_key[16], uint16_t net_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to update a local network key.
|
||||
*
|
||||
* @param[in] net_key: Value of the NetKey.
|
||||
* @param[in] net_idx: The NetKey Index.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_update_local_net_key(const uint8_t net_key[16], uint16_t net_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to get the local network key value.
|
||||
*
|
||||
* @param[in] net_idx: Network key index.
|
||||
*
|
||||
* @return Network key on success, or NULL on failure.
|
||||
*
|
||||
*/
|
||||
const uint8_t *esp_ble_mesh_provisioner_get_local_net_key(uint16_t net_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to enable or disable receiving
|
||||
* heartbeat messages.
|
||||
*
|
||||
* @note If enabling receiving heartbeat message successfully, the filter will
|
||||
* be an empty rejectlist by default, which means all heartbeat messages
|
||||
* received by the Provisioner will be reported to the application layer.
|
||||
*
|
||||
* @param[in] enable: Enable or disable receiving heartbeat messages.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_recv_heartbeat(bool enable);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to set the heartbeat filter type.
|
||||
*
|
||||
* @note 1. If the filter type is not the same with the current value, then all the
|
||||
* filter entries will be cleaned.
|
||||
* 2. If the previous type is rejectlist, and changed to acceptlist, then the
|
||||
* filter will be an empty acceptlist, which means no heartbeat messages
|
||||
* will be reported. Users need to add SRC or DST into the filter entry,
|
||||
* then heartbeat messages from the SRC or to the DST will be reported.
|
||||
*
|
||||
* @param[in] type: Heartbeat filter type (acceptlist or rejectlist).
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_set_heartbeat_filter_type(uint8_t type);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to add or remove a heartbeat filter entry.
|
||||
*
|
||||
* @note 1. If the operation is "ADD", the "hb_src" can be set to the SRC (can only be a
|
||||
* unicast address) of heartbeat messages, and the "hb_dst" can be set to the
|
||||
* DST (unicast address or group address), at least one of them needs to be set.
|
||||
* - If only one of them is set, the filter entry will only use the configured
|
||||
* SRC or DST to filter heartbeat messages.
|
||||
* - If both of them are set, the SRC and DST will both be used to decide if a
|
||||
* heartbeat message will be handled.
|
||||
* - If SRC or DST already exists in some filter entry, then the corresponding
|
||||
* entry will be cleaned firstly, then a new entry will be allocated to store
|
||||
* the information.
|
||||
* 2. If the operation is "REMOVE", the "hb_src" can be set to the SRC (can only be
|
||||
* a unicast address) of heartbeat messages, and the "hb_dst" can be set to the
|
||||
* DST (unicast address or group address), at least one of them needs to be set.
|
||||
* - The filter entry with the same SRC or DST will be removed.
|
||||
*
|
||||
* @param[in] op: Add or REMOVE
|
||||
* @param[in] info: Heartbeat filter entry information, including:
|
||||
* hb_src - Heartbeat source address;
|
||||
* hb_dst - Heartbeat destination address;
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_set_heartbeat_filter_info(uint8_t op, esp_ble_mesh_heartbeat_filter_info_t *info);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to directly erase the mesh
|
||||
* information from nvs namespace.
|
||||
*
|
||||
* @note This function can be invoked when the mesh stack is not initialized
|
||||
* or has been de-initialized.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_direct_erase_settings(void);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to open a nvs namespace
|
||||
* for storing mesh information.
|
||||
*
|
||||
* @note Before open another nvs namespace, the previously opened nvs
|
||||
* namespace must be closed firstly.
|
||||
*
|
||||
* @param[in] index: Settings index.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_open_settings_with_index(uint8_t index);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to open a nvs namespace
|
||||
* for storing mesh information.
|
||||
*
|
||||
* @note Before open another nvs namespace, the previously opened nvs
|
||||
* namespace must be closed firstly.
|
||||
*
|
||||
* @param[in] uid: Settings user id.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_open_settings_with_uid(const char *uid);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to close a nvs namespace
|
||||
* which is opened previously for storing mesh information.
|
||||
*
|
||||
* @note 1. Before closing the nvs namespace, it must be open.
|
||||
* 2. When the function is invoked, the Provisioner functionality
|
||||
* will be disabled firstly, and:
|
||||
* a) If the "erase" flag is set to false, the mesh information
|
||||
* will be cleaned (e.g. removing NetKey, AppKey, nodes, etc)
|
||||
* from the mesh stack.
|
||||
* b) If the "erase" flag is set to true, the mesh information
|
||||
* stored in the nvs namespace will also be erased besides
|
||||
* been cleaned from the mesh stack.
|
||||
* 3. If Provisioner tries to work properly again, we can invoke the
|
||||
* open function to open a new nvs namespace or a previously added
|
||||
* one, and restore the mesh information from it if not erased.
|
||||
* 4. The working process shall be as following:
|
||||
* a) Open settings A
|
||||
* b) Start to provision and control nodes
|
||||
* c) Close settings A
|
||||
* d) Open settings B
|
||||
* e) Start to provision and control other nodes
|
||||
* f) Close settings B
|
||||
* g) ......
|
||||
*
|
||||
* @param[in] index: Settings index.
|
||||
* @param[in] erase: Indicate if erasing mesh information.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_close_settings_with_index(uint8_t index, bool erase);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to close a nvs namespace
|
||||
* which is opened previously for storing mesh information.
|
||||
*
|
||||
* @note 1. Before closing the nvs namespace, it must be open.
|
||||
* 2. When the function is invoked, the Provisioner functionality
|
||||
* will be disabled firstly, and:
|
||||
* a) If the "erase" flag is set to false, the mesh information
|
||||
* will be cleaned (e.g. removing NetKey, AppKey, nodes, etc)
|
||||
* from the mesh stack.
|
||||
* b) If the "erase" flag is set to true, the mesh information
|
||||
* stored in the nvs namespace will also be erased besides
|
||||
* been cleaned from the mesh stack.
|
||||
* 3. If Provisioner tries to work properly again, we can invoke the
|
||||
* open function to open a new nvs namespace or a previously added
|
||||
* one, and restore the mesh information from it if not erased.
|
||||
* 4. The working process shall be as following:
|
||||
* a) Open settings A
|
||||
* b) Start to provision and control nodes
|
||||
* c) Close settings A
|
||||
* d) Open settings B
|
||||
* e) Start to provision and control other nodes
|
||||
* f) Close settings B
|
||||
* g) ......
|
||||
*
|
||||
* @param[in] uid: Settings user id.
|
||||
* @param[in] erase: Indicate if erasing mesh information.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_close_settings_with_uid(const char *uid, bool erase);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to erase the mesh information
|
||||
* and settings user id from a nvs namespace.
|
||||
*
|
||||
* @note When this function is called, the nvs namespace must not be open.
|
||||
* This function is used to erase the mesh information and settings
|
||||
* user id which are not used currently.
|
||||
*
|
||||
* @param[in] index: Settings index.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_delete_settings_with_index(uint8_t index);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to erase the mesh information
|
||||
* and settings user id from a nvs namespace.
|
||||
*
|
||||
* @note When this function is called, the nvs namespace must not be open.
|
||||
* This function is used to erase the mesh information and settings
|
||||
* user id which are not used currently.
|
||||
*
|
||||
* @param[in] uid: Settings user id.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_delete_settings_with_uid(const char *uid);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to get settings user id.
|
||||
*
|
||||
* @param[in] index: Settings index.
|
||||
*
|
||||
* @return Setting user id on success or NULL on failure.
|
||||
*
|
||||
*/
|
||||
const char *esp_ble_mesh_provisioner_get_settings_uid(uint8_t index);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to get settings index.
|
||||
*
|
||||
* @param[in] uid: Settings user id.
|
||||
*
|
||||
* @return Settings index.
|
||||
*
|
||||
*/
|
||||
uint8_t esp_ble_mesh_provisioner_get_settings_index(const char *uid);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to get the number of free
|
||||
* settings user id.
|
||||
*
|
||||
* @return Number of free settings user id.
|
||||
*
|
||||
*/
|
||||
uint8_t esp_ble_mesh_provisioner_get_free_settings_count(void);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get fast provisioning application key.
|
||||
*
|
||||
* @param[in] net_idx: Network key index.
|
||||
* @param[in] app_idx: Application key index.
|
||||
*
|
||||
* @return Application key on success, or NULL on failure.
|
||||
*
|
||||
*/
|
||||
const uint8_t *esp_ble_mesh_get_fast_prov_app_key(uint16_t net_idx, uint16_t app_idx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_NETWORKING_API_H_ */
|
@ -0,0 +1,394 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_PROVISIONING_API_H_
|
||||
#define _ESP_BLE_MESH_PROVISIONING_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @brief: event, event code of provisioning events; param, parameters of provisioning events */
|
||||
typedef void (* esp_ble_mesh_prov_cb_t)(esp_ble_mesh_prov_cb_event_t event,
|
||||
esp_ble_mesh_prov_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh provisioning callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_prov_callback(esp_ble_mesh_prov_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Check if a device has been provisioned.
|
||||
*
|
||||
* @return TRUE if the device is provisioned, FALSE if the device is unprovisioned.
|
||||
*
|
||||
*/
|
||||
bool esp_ble_mesh_node_is_provisioned(void);
|
||||
|
||||
/**
|
||||
* @brief Enable specific provisioning bearers to get the device ready for provisioning.
|
||||
*
|
||||
* @note PB-ADV: send unprovisioned device beacon.
|
||||
* PB-GATT: send connectable advertising packets.
|
||||
*
|
||||
* @param bearers: Bit-wise OR of provisioning bearers.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_node_prov_enable(esp_ble_mesh_prov_bearer_t bearers);
|
||||
|
||||
/**
|
||||
* @brief Disable specific provisioning bearers to make a device inaccessible for provisioning.
|
||||
*
|
||||
* @param bearers: Bit-wise OR of provisioning bearers.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers);
|
||||
|
||||
/**
|
||||
* @brief Unprovisioned device set own oob public key & private key pair.
|
||||
*
|
||||
* @note In order to avoid suffering brute-forcing attack (CVE-2020-26559).
|
||||
* The Bluetooth SIG recommends that potentially vulnerable mesh provisioners
|
||||
* use an out-of-band mechanism to exchange the public keys.
|
||||
* So as an unprovisioned device, it should use this function to input
|
||||
* the Public Key exchanged through the out-of-band mechanism.
|
||||
*
|
||||
* @param[in] pub_key_x: Unprovisioned device's Public Key X
|
||||
* @param[in] pub_key_y: Unprovisioned device's Public Key Y
|
||||
* @param[in] private_key: Unprovisioned device's Private Key
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_node_set_oob_pub_key(uint8_t pub_key_x[32], uint8_t pub_key_y[32],
|
||||
uint8_t private_key[32]);
|
||||
|
||||
/**
|
||||
* @brief Provide provisioning input OOB number.
|
||||
*
|
||||
* @note This is intended to be called if the user has received ESP_BLE_MESH_NODE_PROV_INPUT_EVT
|
||||
* with ESP_BLE_MESH_ENTER_NUMBER as the action.
|
||||
*
|
||||
* @param[in] number: Number input by device.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_node_input_number(uint32_t number);
|
||||
|
||||
/**
|
||||
* @brief Provide provisioning input OOB string.
|
||||
*
|
||||
* @note This is intended to be called if the user has received ESP_BLE_MESH_NODE_PROV_INPUT_EVT
|
||||
* with ESP_BLE_MESH_ENTER_STRING as the action.
|
||||
*
|
||||
* @param[in] string: String input by device.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_node_input_string(const char *string);
|
||||
|
||||
/**
|
||||
* @brief Using this function, an unprovisioned device can set its own device name,
|
||||
* which will be broadcasted in its advertising data.
|
||||
*
|
||||
* @param[in] name: Unprovisioned device name
|
||||
*
|
||||
* @note This API applicable to PB-GATT mode only by setting the name to the scan response data,
|
||||
* it doesn't apply to PB-ADV mode.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name);
|
||||
|
||||
/**
|
||||
* @brief Provisioner inputs unprovisioned device's oob public key.
|
||||
*
|
||||
* @note In order to avoid suffering brute-forcing attack (CVE-2020-26559).
|
||||
* The Bluetooth SIG recommends that potentially vulnerable mesh provisioners
|
||||
* use an out-of-band mechanism to exchange the public keys.
|
||||
*
|
||||
* @param[in] link_idx: The provisioning link index
|
||||
* @param[in] pub_key_x: Unprovisioned device's Public Key X
|
||||
* @param[in] pub_key_y: Unprovisioned device's Public Key Y
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_read_oob_pub_key(uint8_t link_idx, uint8_t pub_key_x[32],
|
||||
uint8_t pub_key_y[32]);
|
||||
|
||||
/**
|
||||
* @brief Provide provisioning input OOB string.
|
||||
*
|
||||
* This is intended to be called after the esp_ble_mesh_prov_t prov_input_num
|
||||
* callback has been called with ESP_BLE_MESH_ENTER_STRING as the action.
|
||||
*
|
||||
* @param[in] string: String input by Provisioner.
|
||||
* @param[in] link_idx: The provisioning link index.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_input_string(const char *string, uint8_t link_idx);
|
||||
|
||||
/**
|
||||
* @brief Provide provisioning input OOB number.
|
||||
*
|
||||
* This is intended to be called after the esp_ble_mesh_prov_t prov_input_num
|
||||
* callback has been called with ESP_BLE_MESH_ENTER_NUMBER as the action.
|
||||
*
|
||||
* @param[in] number: Number input by Provisioner.
|
||||
* @param[in] link_idx: The provisioning link index.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_input_number(uint32_t number, uint8_t link_idx);
|
||||
|
||||
/**
|
||||
* @brief Enable one or more provisioning bearers.
|
||||
*
|
||||
* @param[in] bearers: Bit-wise OR of provisioning bearers.
|
||||
*
|
||||
* @note PB-ADV: Enable BLE scan.
|
||||
* PB-GATT: Initialize corresponding BLE Mesh Proxy info.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_prov_enable(esp_ble_mesh_prov_bearer_t bearers);
|
||||
|
||||
/**
|
||||
* @brief Disable one or more provisioning bearers.
|
||||
*
|
||||
* @param[in] bearers: Bit-wise OR of provisioning bearers.
|
||||
*
|
||||
* @note PB-ADV: Disable BLE scan.
|
||||
* PB-GATT: Break any existing BLE Mesh Provisioning connections.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_prov_disable(esp_ble_mesh_prov_bearer_t bearers);
|
||||
|
||||
/**
|
||||
* @brief Add unprovisioned device info to the unprov_dev queue.
|
||||
*
|
||||
* @param[in] add_dev: Pointer to a struct containing the device information
|
||||
* @param[in] flags: Flags indicate several operations on the device information
|
||||
* - Remove device information from queue after device has been provisioned (BIT0)
|
||||
* - Start provisioning immediately after device is added to queue (BIT1)
|
||||
* - Device can be removed if device queue is full (BIT2)
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
* @note: 1. Currently address type only supports public address and static random address.
|
||||
* 2. If device UUID and/or device address as well as address type already exist in the
|
||||
* device queue, but the bearer is different from the existing one, add operation
|
||||
* will also be successful and it will update the provision bearer supported by
|
||||
* the device.
|
||||
* 3. For example, if the Provisioner wants to add an unprovisioned device info before
|
||||
* receiving its unprovisioned device beacon or Mesh Provisioning advertising packets,
|
||||
* the Provisioner can use this API to add the device info with each one or both of
|
||||
* device UUID and device address added. When the Provisioner gets the device's
|
||||
* advertising packets, it will start provisioning the device internally.
|
||||
* - In this situation, the Provisioner can set bearers with each one or both of
|
||||
* ESP_BLE_MESH_PROV_ADV and ESP_BLE_MESH_PROV_GATT enabled, and cannot set flags
|
||||
* with ADD_DEV_START_PROV_NOW_FLAG enabled.
|
||||
* 4. Another example is when the Provisioner receives the unprovisioned device's beacon or
|
||||
* Mesh Provisioning advertising packets, the advertising packets will be reported on to
|
||||
* the application layer using the callback registered by the function
|
||||
* esp_ble_mesh_register_prov_callback. And in the callback, the Provisioner
|
||||
* can call this API to start provisioning the device.
|
||||
* - If the Provisioner uses PB-ADV to provision, either one or both of device UUID and
|
||||
* device address can be added, bearers shall be set with ESP_BLE_MESH_PROV_ADV
|
||||
* enabled and the flags shall be set with ADD_DEV_START_PROV_NOW_FLAG enabled.
|
||||
* - If the Provisioner uses PB-GATT to provision, both the device UUID and device
|
||||
* address need to be added, bearers shall be set with ESP_BLE_MESH_PROV_GATT enabled,
|
||||
* and the flags shall be set with ADD_DEV_START_PROV_NOW_FLAG enabled.
|
||||
* - If the Provisioner just wants to store the unprovisioned device info when receiving
|
||||
* its advertising packets and start to provision it the next time (e.g. after receiving
|
||||
* its advertising packets again), then it can add the device info with either one or both
|
||||
* of device UUID and device address included. Bearers can be set with either one or both
|
||||
* of ESP_BLE_MESH_PROV_ADV and ESP_BLE_MESH_PROV_GATT enabled (recommend to enable the
|
||||
* bearer which will receive its advertising packets, because if the other bearer is
|
||||
* enabled, the Provisioner is not aware if the device supports the bearer), and flags
|
||||
* cannot be set with ADD_DEV_START_PROV_NOW_FLAG enabled.
|
||||
* - Note: ESP_BLE_MESH_PROV_ADV, ESP_BLE_MESH_PROV_GATT and ADD_DEV_START_PROV_NOW_FLAG
|
||||
* can not be enabled at the same time.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t *add_dev,
|
||||
esp_ble_mesh_dev_add_flag_t flags);
|
||||
|
||||
/** @brief Provision an unprovisioned device and assign a fixed unicast address for it in advance.
|
||||
*
|
||||
* @param[in] uuid: Device UUID of the unprovisioned device
|
||||
* @param[in] addr: Device address of the unprovisioned device
|
||||
* @param[in] addr_type: Device address type of the unprovisioned device
|
||||
* @param[in] bearer: Provisioning bearer going to be used by Provisioner
|
||||
* @param[in] oob_info: OOB info of the unprovisioned device
|
||||
* @param[in] unicast_addr: Unicast address going to be allocated for the unprovisioned device
|
||||
*
|
||||
* @return Zero on success or (negative) error code otherwise.
|
||||
*
|
||||
* @note: 1. Currently address type only supports public address and static random address.
|
||||
* 2. Bearer must be equal to ESP_BLE_MESH_PROV_ADV or ESP_BLE_MESH_PROV_GATT, since
|
||||
* Provisioner will start to provision a device immediately once this function is
|
||||
* invoked. And the input bearer must be identical with the one within the parameters
|
||||
* of the ESP_BLE_MESH_PROVISIONER_RECV_UNPROV_ADV_PKT_EVT event.
|
||||
* 3. If this function is used by a Provisioner to provision devices, the application
|
||||
* should take care of the assigned unicast address and avoid overlap of the unicast
|
||||
* addresses of different nodes.
|
||||
* 4. Recommend to use only one of the functions "esp_ble_mesh_provisioner_add_unprov_dev"
|
||||
* and "esp_ble_mesh_provisioner_prov_device_with_addr" by a Provisioner.
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_prov_device_with_addr(const uint8_t uuid[16],
|
||||
esp_ble_mesh_bd_addr_t addr,
|
||||
esp_ble_mesh_addr_type_t addr_type,
|
||||
esp_ble_mesh_prov_bearer_t bearer,
|
||||
uint16_t oob_info, uint16_t unicast_addr);
|
||||
|
||||
/**
|
||||
* @brief Delete device from queue, and reset current provisioning link with the device.
|
||||
*
|
||||
* @note If the device is in the queue, remove it from the queue; if the device is
|
||||
* being provisioned, terminate the provisioning procedure. Either one of the
|
||||
* device address or device UUID can be used as input.
|
||||
*
|
||||
* @param[in] del_dev: Pointer to a struct containing the device information.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_dev);
|
||||
|
||||
/**
|
||||
* @brief Callback for Provisioner that received advertising packets from unprovisioned devices which are
|
||||
* not in the unprovisioned device queue.
|
||||
*
|
||||
* Report on the unprovisioned device beacon and mesh provisioning service adv data to application.
|
||||
*
|
||||
* @param[in] addr: Pointer to the unprovisioned device address.
|
||||
* @param[in] addr_type: Unprovisioned device address type.
|
||||
* @param[in] adv_type: Adv packet type(ADV_IND or ADV_NONCONN_IND).
|
||||
* @param[in] dev_uuid: Unprovisioned device UUID pointer.
|
||||
* @param[in] oob_info: OOB information of the unprovisioned device.
|
||||
* @param[in] bearer: Adv packet received from PB-GATT or PB-ADV bearer.
|
||||
*
|
||||
*/
|
||||
typedef void (*esp_ble_mesh_prov_adv_cb_t)(const esp_ble_mesh_bd_addr_t addr, const esp_ble_mesh_addr_type_t addr_type,
|
||||
const uint8_t adv_type, const uint8_t *dev_uuid,
|
||||
uint16_t oob_info, esp_ble_mesh_prov_bearer_t bearer);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to set the part of the device UUID
|
||||
* to be compared before starting to provision.
|
||||
*
|
||||
* @param[in] match_val: Value to be compared with the part of the device UUID.
|
||||
* @param[in] match_len: Length of the compared match value.
|
||||
* @param[in] offset: Offset of the device UUID to be compared (based on zero).
|
||||
* @param[in] prov_after_match: Flag used to indicate whether provisioner should start to provision
|
||||
* the device immediately if the part of the UUID matches.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_set_dev_uuid_match(const uint8_t *match_val, uint8_t match_len,
|
||||
uint8_t offset, bool prov_after_match);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to set provisioning data information
|
||||
* before starting to provision.
|
||||
*
|
||||
* @param[in] prov_data_info: Pointer to a struct containing net_idx or flags or iv_index.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_set_prov_data_info(esp_ble_mesh_prov_data_info_t *prov_data_info);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to set static oob value used for provisioning.
|
||||
*
|
||||
* @note The Bluetooth SIG recommends that mesh implementations enforce a randomly selected
|
||||
* AuthValue using all of the available bits, where permitted by the implementation.
|
||||
* A large entropy helps ensure that a brute-force of the AuthValue, even a static
|
||||
* AuthValue, cannot normally be completed in a reasonable time (CVE-2020-26557).
|
||||
*
|
||||
* AuthValues selected using a cryptographically secure random or pseudorandom number
|
||||
* generator and having the maximum permitted entropy (128-bits) will be most difficult
|
||||
* to brute-force. AuthValues with reduced entropy or generated in a predictable manner
|
||||
* will not grant the same level of protection against this vulnerability. Selecting a
|
||||
* new AuthValue with each provisioning attempt can also make it more difficult to launch
|
||||
* a brute-force attack by requiring the attacker to restart the search with each
|
||||
* provisioning attempt (CVE-2020-26556).
|
||||
*
|
||||
* @param[in] value: Pointer to the static oob value.
|
||||
* @param[in] length: Length of the static oob value.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_set_static_oob_value(const uint8_t *value, uint8_t length);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to set own Primary element address.
|
||||
*
|
||||
* @note This API must be invoked when BLE Mesh initialization is completed successfully,
|
||||
* and can be invoked before Provisioner functionality is enabled.
|
||||
* Once this API is invoked successfully, the prov_unicast_addr value in the struct
|
||||
* esp_ble_mesh_prov_t will be ignored, and Provisioner will use this address as its
|
||||
* own primary element address.
|
||||
* And if the unicast address going to assigned for the next unprovisioned device is
|
||||
* smaller than the input address + element number of Provisioner, then the address
|
||||
* for the next unprovisioned device will be recalculated internally.
|
||||
*
|
||||
* @param[in] addr: Unicast address of the Primary element of Provisioner.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_set_primary_elem_addr(uint16_t addr);
|
||||
|
||||
/**
|
||||
* @brief This function is called to set provisioning data information before starting
|
||||
* fast provisioning.
|
||||
*
|
||||
* @param[in] fast_prov_info: Pointer to a struct containing unicast address range, net_idx, etc.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_set_fast_prov_info(esp_ble_mesh_fast_prov_info_t *fast_prov_info);
|
||||
|
||||
/**
|
||||
* @brief This function is called to start/suspend/exit fast provisioning.
|
||||
*
|
||||
* @param[in] action: fast provisioning action (i.e. enter, suspend, exit).
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_set_fast_prov_action(esp_ble_mesh_fast_prov_action_t action);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_PROVISIONING_API_H_ */
|
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_PROXY_API_H_
|
||||
#define _ESP_BLE_MESH_PROXY_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable advertising with Node Identity.
|
||||
*
|
||||
* @note This API requires that GATT Proxy support be enabled. Once called,
|
||||
* each subnet starts advertising using Node Identity for the next 60
|
||||
* seconds, and after 60s Network ID will be advertised.
|
||||
* Under normal conditions, the BLE Mesh Proxy Node Identity and
|
||||
* Network ID advertising will be enabled automatically by BLE Mesh
|
||||
* stack after the device is provisioned.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_identity_enable(void);
|
||||
|
||||
/**
|
||||
* @brief Enable BLE Mesh GATT Proxy Service.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_gatt_enable(void);
|
||||
|
||||
/**
|
||||
* @brief Disconnect the BLE Mesh GATT Proxy connection if there is any, and
|
||||
* disable the BLE Mesh GATT Proxy Service.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_gatt_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Proxy Client creates a connection with the Proxy Server.
|
||||
*
|
||||
* @param[in] addr: Device address of the Proxy Server.
|
||||
* @param[in] addr_type: Device address type(public or static random).
|
||||
* @param[in] net_idx: NetKey Index related with Network ID in the Mesh Proxy
|
||||
* advertising packet.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_client_connect(esp_ble_mesh_bd_addr_t addr,
|
||||
esp_ble_mesh_addr_type_t addr_type,
|
||||
uint16_t net_idx);
|
||||
|
||||
/**
|
||||
* @brief Proxy Client terminates a connection with the Proxy Server.
|
||||
*
|
||||
* @param[in] conn_handle: Proxy connection handle.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_client_disconnect(uint8_t conn_handle);
|
||||
|
||||
/**
|
||||
* @brief Proxy Client sets the filter type of the Proxy Server.
|
||||
*
|
||||
* @param[in] conn_handle: Proxy connection handle.
|
||||
* @param[in] net_idx: Corresponding NetKey Index.
|
||||
* @param[in] filter_type: whitelist or blacklist.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, uint16_t net_idx,
|
||||
esp_ble_mesh_proxy_filter_type_t filter_type);
|
||||
|
||||
/**
|
||||
* @brief Proxy Client adds address to the Proxy Server filter list.
|
||||
*
|
||||
* @param[in] conn_handle: Proxy connection handle.
|
||||
* @param[in] net_idx: Corresponding NetKey Index.
|
||||
* @param[in] addr: Pointer to the filter address.
|
||||
* @param[in] addr_num: Number of the filter address.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, uint16_t net_idx,
|
||||
uint16_t *addr, uint16_t addr_num);
|
||||
|
||||
/**
|
||||
* @brief Proxy Client removes address from the Proxy Server filter list.
|
||||
*
|
||||
* @param[in] conn_handle: Proxy connection handle.
|
||||
* @param[in] net_idx: Corresponding NetKey Index.
|
||||
* @param[in] addr: Pointer to the filter address.
|
||||
* @param[in] addr_num: Number of the filter address.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle, uint16_t net_idx,
|
||||
uint16_t *addr, uint16_t addr_num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_PROXY_API_H_ */
|
2275
tools/sdk/esp32/include/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h
Normal file
2275
tools/sdk/esp32/include/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,817 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_CONFIG_MODEL_API_H_
|
||||
#define _ESP_BLE_MESH_CONFIG_MODEL_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_CFG_SRV
|
||||
*
|
||||
* @brief Define a new Config Server Model.
|
||||
*
|
||||
* @note The Config Server Model can only be included by a Primary Element.
|
||||
*
|
||||
* @param srv_data Pointer to a unique Config Server Model user_data.
|
||||
*
|
||||
* @return New Config Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_CFG_SRV(srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_CONFIG_SRV, \
|
||||
NULL, NULL, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_CFG_CLI
|
||||
*
|
||||
* @brief Define a new Config Client Model.
|
||||
*
|
||||
* @note The Config Client Model can only be included by a Primary Element.
|
||||
*
|
||||
* @param cli_data Pointer to a unique struct esp_ble_mesh_client_t.
|
||||
*
|
||||
* @return New Config Client Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_CFG_CLI(cli_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_CONFIG_CLI, \
|
||||
NULL, NULL, cli_data)
|
||||
|
||||
/** Configuration Server Model context */
|
||||
typedef struct esp_ble_mesh_cfg_srv {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to Configuration Server Model */
|
||||
|
||||
uint8_t net_transmit; /*!< Network Transmit state */
|
||||
uint8_t relay; /*!< Relay Mode state */
|
||||
uint8_t relay_retransmit; /*!< Relay Retransmit state */
|
||||
uint8_t beacon; /*!< Secure Network Beacon state */
|
||||
uint8_t gatt_proxy; /*!< GATT Proxy state */
|
||||
uint8_t friend_state; /*!< Friend state */
|
||||
uint8_t default_ttl; /*!< Default TTL */
|
||||
|
||||
/** Heartbeat Publication */
|
||||
struct {
|
||||
struct k_delayed_work timer; /*!< Heartbeat Publication timer */
|
||||
|
||||
uint16_t dst; /*!< Destination address for Heartbeat messages */
|
||||
uint16_t count; /*!< Number of Heartbeat messages to be sent */
|
||||
uint8_t period; /*!< Period for sending Heartbeat messages */
|
||||
uint8_t ttl; /*!< TTL to be used when sending Heartbeat messages */
|
||||
uint16_t feature; /*!< Bit field indicating features that trigger Heartbeat messages when changed */
|
||||
uint16_t net_idx; /*!< NetKey Index used by Heartbeat Publication */
|
||||
} heartbeat_pub;
|
||||
|
||||
/** Heartbeat Subscription */
|
||||
struct {
|
||||
int64_t expiry; /*!< Timestamp when Heartbeat subscription period is expired */
|
||||
|
||||
uint16_t src; /*!< Source address for Heartbeat messages */
|
||||
uint16_t dst; /*!< Destination address for Heartbeat messages */
|
||||
uint16_t count; /*!< Number of Heartbeat messages received */
|
||||
uint8_t min_hops; /*!< Minimum hops when receiving Heartbeat messages */
|
||||
uint8_t max_hops; /*!< Maximum hops when receiving Heartbeat messages */
|
||||
|
||||
/** Optional heartbeat subscription tracking function */
|
||||
esp_ble_mesh_cb_t heartbeat_recv_cb;
|
||||
} heartbeat_sub;
|
||||
} esp_ble_mesh_cfg_srv_t;
|
||||
|
||||
/** Parameters of Config Composition Data Get. */
|
||||
typedef struct {
|
||||
uint8_t page; /*!< Page number of the Composition Data. */
|
||||
} esp_ble_mesh_cfg_composition_data_get_t;
|
||||
|
||||
/** Parameters of Config Model Publication Get. */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< The element address */
|
||||
uint16_t model_id; /*!< The model id */
|
||||
uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
|
||||
} esp_ble_mesh_cfg_model_pub_get_t;
|
||||
|
||||
/** Parameters of Config SIG Model Subscription Get. */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< The element address */
|
||||
uint16_t model_id; /*!< The model id */
|
||||
} esp_ble_mesh_cfg_sig_model_sub_get_t;
|
||||
|
||||
/** Parameters of Config Vendor Model Subscription Get. */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< The element address */
|
||||
uint16_t model_id; /*!< The model id */
|
||||
uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
|
||||
} esp_ble_mesh_cfg_vnd_model_sub_get_t;
|
||||
|
||||
/** Parameters of Config AppKey Get. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< The network key index */
|
||||
} esp_ble_mesh_cfg_app_key_get_t;
|
||||
|
||||
/** Parameters of Config Node Identity Get. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< The network key index */
|
||||
} esp_ble_mesh_cfg_node_identity_get_t;
|
||||
|
||||
/** Parameters of Config SIG Model App Get. */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< The element address */
|
||||
uint16_t model_id; /*!< The model id */
|
||||
} esp_ble_mesh_cfg_sig_model_app_get_t;
|
||||
|
||||
/** Parameters of Config Vendor Model App Get. */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< The element address */
|
||||
uint16_t model_id; /*!< The model id */
|
||||
uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
|
||||
} esp_ble_mesh_cfg_vnd_model_app_get_t;
|
||||
|
||||
/** Parameters of Config Key Refresh Phase Get. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< The network key index */
|
||||
} esp_ble_mesh_cfg_kr_phase_get_t;
|
||||
|
||||
/** Parameters of Config Low Power Node PollTimeout Get. */
|
||||
typedef struct {
|
||||
uint16_t lpn_addr; /*!< The unicast address of the Low Power node */
|
||||
} esp_ble_mesh_cfg_lpn_polltimeout_get_t;
|
||||
|
||||
/** Parameters of Config Beacon Set. */
|
||||
typedef struct {
|
||||
uint8_t beacon; /*!< New Secure Network Beacon state */
|
||||
} esp_ble_mesh_cfg_beacon_set_t;
|
||||
|
||||
/** Parameters of Config Default TTL Set. */
|
||||
typedef struct {
|
||||
uint8_t ttl; /*!< The default TTL state value */
|
||||
} esp_ble_mesh_cfg_default_ttl_set_t;
|
||||
|
||||
/** Parameters of Config Friend Set. */
|
||||
typedef struct {
|
||||
uint8_t friend_state; /*!< The friend state value */
|
||||
} esp_ble_mesh_cfg_friend_set_t;
|
||||
|
||||
/** Parameters of Config GATT Proxy Set. */
|
||||
typedef struct {
|
||||
uint8_t gatt_proxy; /*!< The GATT Proxy state value */
|
||||
} esp_ble_mesh_cfg_gatt_proxy_set_t;
|
||||
|
||||
/** Parameters of Config Relay Set. */
|
||||
typedef struct {
|
||||
uint8_t relay; /*!< The relay value */
|
||||
uint8_t relay_retransmit; /*!< The relay retransmit value */
|
||||
} esp_ble_mesh_cfg_relay_set_t;
|
||||
|
||||
/** Parameters of Config NetKey Add. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< The network key index */
|
||||
uint8_t net_key[16]; /*!< The network key value */
|
||||
} esp_ble_mesh_cfg_net_key_add_t;
|
||||
|
||||
/** Parameters of Config AppKey Add. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< The network key index */
|
||||
uint16_t app_idx; /*!< The app key index */
|
||||
uint8_t app_key[16]; /*!< The app key value */
|
||||
} esp_ble_mesh_cfg_app_key_add_t;
|
||||
|
||||
/** Parameters of Config Model App Bind. */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< The element address */
|
||||
uint16_t model_app_idx; /*!< Index of the app key to bind with the model */
|
||||
uint16_t model_id; /*!< The model id */
|
||||
uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
|
||||
} esp_ble_mesh_cfg_model_app_bind_t;
|
||||
|
||||
/** Parameters of Config Model Publication Set. */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< The element address */
|
||||
uint16_t publish_addr; /*!< Value of the publish address */
|
||||
uint16_t publish_app_idx; /*!< Index of the application key */
|
||||
bool cred_flag; /*!< Value of the Friendship Credential Flag */
|
||||
uint8_t publish_ttl; /*!< Default TTL value for the publishing messages */
|
||||
uint8_t publish_period; /*!< Period for periodic status publishing */
|
||||
uint8_t publish_retransmit; /*!< Number of retransmissions and number of 50-millisecond steps between retransmissions */
|
||||
uint16_t model_id; /*!< The model id */
|
||||
uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
|
||||
} esp_ble_mesh_cfg_model_pub_set_t;
|
||||
|
||||
/** Parameters of Config Model Subscription Add. */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< The element address */
|
||||
uint16_t sub_addr; /*!< The address to be added to the Subscription List */
|
||||
uint16_t model_id; /*!< The model id */
|
||||
uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
|
||||
} esp_ble_mesh_cfg_model_sub_add_t;
|
||||
|
||||
/** Parameters of Config Model Subscription Delete. */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< The element address */
|
||||
uint16_t sub_addr; /*!< The address to be removed from the Subscription List */
|
||||
uint16_t model_id; /*!< The model id */
|
||||
uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
|
||||
} esp_ble_mesh_cfg_model_sub_delete_t;
|
||||
|
||||
/** Parameters of Config Model Subscription Overwrite. */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< The element address */
|
||||
uint16_t sub_addr; /*!< The address to be added to the Subscription List */
|
||||
uint16_t model_id; /*!< The model id */
|
||||
uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
|
||||
} esp_ble_mesh_cfg_model_sub_overwrite_t;
|
||||
|
||||
/** Parameters of Config Model Subscription Virtual Address Add. */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< The element address */
|
||||
uint8_t label_uuid[16]; /*!< The Label UUID of the virtual address to be added to the Subscription List */
|
||||
uint16_t model_id; /*!< The model id */
|
||||
uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
|
||||
} esp_ble_mesh_cfg_model_sub_va_add_t;
|
||||
|
||||
/** Parameters of Config Model Subscription Virtual Address Delete. */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< The element address */
|
||||
uint8_t label_uuid[16]; /*!< The Label UUID of the virtual address to be removed from the Subscription List */
|
||||
uint16_t model_id; /*!< The model id */
|
||||
uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
|
||||
} esp_ble_mesh_cfg_model_sub_va_delete_t;
|
||||
|
||||
/** Parameters of Config Model Subscription Virtual Address Overwrite. */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< The element address */
|
||||
uint8_t label_uuid[16]; /*!< The Label UUID of the virtual address to be added to the Subscription List */
|
||||
uint16_t model_id; /*!< The model id */
|
||||
uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
|
||||
} esp_ble_mesh_cfg_model_sub_va_overwrite_t;
|
||||
|
||||
/** Parameters of Config Model Publication Virtual Address Set. */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< The element address */
|
||||
uint8_t label_uuid[16]; /*!< Value of the Label UUID publish address */
|
||||
uint16_t publish_app_idx; /*!< Index of the application key */
|
||||
bool cred_flag; /*!< Value of the Friendship Credential Flag */
|
||||
uint8_t publish_ttl; /*!< Default TTL value for the publishing messages */
|
||||
uint8_t publish_period; /*!< Period for periodic status publishing */
|
||||
uint8_t publish_retransmit; /*!< Number of retransmissions and number of 50-millisecond steps between retransmissions */
|
||||
uint16_t model_id; /*!< The model id */
|
||||
uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
|
||||
} esp_ble_mesh_cfg_model_pub_va_set_t;
|
||||
|
||||
/** Parameters of Config Model Subscription Delete All. */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< The element address */
|
||||
uint16_t model_id; /*!< The model id */
|
||||
uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
|
||||
} esp_ble_mesh_cfg_model_sub_delete_all_t;
|
||||
|
||||
/** Parameters of Config NetKey Update. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< The network key index */
|
||||
uint8_t net_key[16]; /*!< The network key value */
|
||||
} esp_ble_mesh_cfg_net_key_update_t;
|
||||
|
||||
/** Parameters of Config NetKey Delete. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< The network key index */
|
||||
} esp_ble_mesh_cfg_net_key_delete_t;
|
||||
|
||||
/** Parameters of Config AppKey Update. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< The network key index */
|
||||
uint16_t app_idx; /*!< The app key index */
|
||||
uint8_t app_key[16]; /*!< The app key value */
|
||||
} esp_ble_mesh_cfg_app_key_update_t;
|
||||
|
||||
/** Parameters of Config AppKey Delete. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< The network key index */
|
||||
uint16_t app_idx; /*!< The app key index */
|
||||
} esp_ble_mesh_cfg_app_key_delete_t;
|
||||
|
||||
/** Parameters of Config Node Identity Set. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< The network key index */
|
||||
uint8_t identity; /*!< New Node Identity state */
|
||||
} esp_ble_mesh_cfg_node_identity_set_t;
|
||||
|
||||
/** Parameters of Config Model App Unbind. */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< The element address */
|
||||
uint16_t model_app_idx; /*!< Index of the app key to bind with the model */
|
||||
uint16_t model_id; /*!< The model id */
|
||||
uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */
|
||||
} esp_ble_mesh_cfg_model_app_unbind_t;
|
||||
|
||||
/** Parameters of Config Key Refresh Phase Set. */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< The network key index */
|
||||
uint8_t transition; /*!< New Key Refresh Phase Transition */
|
||||
} esp_ble_mesh_cfg_kr_phase_set_t;
|
||||
|
||||
/** Parameters of Config Network Transmit Set. */
|
||||
typedef struct {
|
||||
uint8_t net_transmit; /*!< Network Transmit State */
|
||||
} esp_ble_mesh_cfg_net_transmit_set_t;
|
||||
|
||||
/** Parameters of Config Model Heartbeat Publication Set. */
|
||||
typedef struct {
|
||||
uint16_t dst; /*!< Destination address for Heartbeat messages */
|
||||
uint8_t count; /*!< Number of Heartbeat messages to be sent */
|
||||
uint8_t period; /*!< Period for sending Heartbeat messages */
|
||||
uint8_t ttl; /*!< TTL to be used when sending Heartbeat messages */
|
||||
uint16_t feature; /*!< Bit field indicating features that trigger Heartbeat messages when changed */
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
} esp_ble_mesh_cfg_heartbeat_pub_set_t;
|
||||
|
||||
/** Parameters of Config Model Heartbeat Subscription Set. */
|
||||
typedef struct {
|
||||
uint16_t src; /*!< Source address for Heartbeat messages */
|
||||
uint16_t dst; /*!< Destination address for Heartbeat messages */
|
||||
uint8_t period; /*!< Period for receiving Heartbeat messages */
|
||||
} esp_ble_mesh_cfg_heartbeat_sub_set_t;
|
||||
|
||||
/**
|
||||
* @brief For ESP_BLE_MESH_MODEL_OP_BEACON_GET
|
||||
* ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET
|
||||
* ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_GET
|
||||
* ESP_BLE_MESH_MODEL_OP_GATT_PROXY_GET
|
||||
* ESP_BLE_MESH_MODEL_OP_RELAY_GET
|
||||
* ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET
|
||||
* ESP_BLE_MESH_MODEL_OP_FRIEND_GET
|
||||
* ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_GET
|
||||
* ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_GET
|
||||
* the get_state parameter in the esp_ble_mesh_config_client_get_state function should not be set to NULL.
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_cfg_model_pub_get_t model_pub_get; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET. */
|
||||
esp_ble_mesh_cfg_composition_data_get_t comp_data_get; /*!< For ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET. */
|
||||
esp_ble_mesh_cfg_sig_model_sub_get_t sig_model_sub_get; /*!< For ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET */
|
||||
esp_ble_mesh_cfg_vnd_model_sub_get_t vnd_model_sub_get; /*!< For ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET */
|
||||
esp_ble_mesh_cfg_app_key_get_t app_key_get; /*!< For ESP_BLE_MESH_MODEL_OP_APP_KEY_GET. */
|
||||
esp_ble_mesh_cfg_node_identity_get_t node_identity_get; /*!< For ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET. */
|
||||
esp_ble_mesh_cfg_sig_model_app_get_t sig_model_app_get; /*!< For ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET */
|
||||
esp_ble_mesh_cfg_vnd_model_app_get_t vnd_model_app_get; /*!< For ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET */
|
||||
esp_ble_mesh_cfg_kr_phase_get_t kr_phase_get; /*!< For ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET */
|
||||
esp_ble_mesh_cfg_lpn_polltimeout_get_t lpn_pollto_get; /*!< For ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET */
|
||||
} esp_ble_mesh_cfg_client_get_state_t;
|
||||
|
||||
/**
|
||||
* @brief For ESP_BLE_MESH_MODEL_OP_BEACON_SET
|
||||
* ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_SET
|
||||
* ESP_BLE_MESH_MODEL_OP_GATT_PROXY_SET
|
||||
* ESP_BLE_MESH_MODEL_OP_RELAY_SET
|
||||
* ESP_BLE_MESH_MODEL_OP_MODEL_PUB_SET
|
||||
* ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD
|
||||
* ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_ADD
|
||||
* ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE
|
||||
* ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_DELETE
|
||||
* ESP_BLE_MESH_MODEL_OP_MODEL_SUB_OVERWRITE
|
||||
* ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_OVERWRITE
|
||||
* ESP_BLE_MESH_MODEL_OP_NET_KEY_ADD
|
||||
* ESP_BLE_MESH_MODEL_OP_APP_KEY_ADD
|
||||
* ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND
|
||||
* ESP_BLE_MESH_MODEL_OP_NODE_RESET
|
||||
* ESP_BLE_MESH_MODEL_OP_FRIEND_SET
|
||||
* ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_SET
|
||||
* ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_SET
|
||||
* the set_state parameter in the esp_ble_mesh_config_client_set_state function should not be set to NULL.
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_cfg_beacon_set_t beacon_set; /*!< For ESP_BLE_MESH_MODEL_OP_BEACON_SET */
|
||||
esp_ble_mesh_cfg_default_ttl_set_t default_ttl_set; /*!< For ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_SET */
|
||||
esp_ble_mesh_cfg_friend_set_t friend_set; /*!< For ESP_BLE_MESH_MODEL_OP_FRIEND_SET */
|
||||
esp_ble_mesh_cfg_gatt_proxy_set_t gatt_proxy_set; /*!< For ESP_BLE_MESH_MODEL_OP_GATT_PROXY_SET */
|
||||
esp_ble_mesh_cfg_relay_set_t relay_set; /*!< For ESP_BLE_MESH_MODEL_OP_RELAY_SET */
|
||||
esp_ble_mesh_cfg_net_key_add_t net_key_add; /*!< For ESP_BLE_MESH_MODEL_OP_NET_KEY_ADD */
|
||||
esp_ble_mesh_cfg_app_key_add_t app_key_add; /*!< For ESP_BLE_MESH_MODEL_OP_APP_KEY_ADD */
|
||||
esp_ble_mesh_cfg_model_app_bind_t model_app_bind; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND */
|
||||
esp_ble_mesh_cfg_model_pub_set_t model_pub_set; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_PUB_SET */
|
||||
esp_ble_mesh_cfg_model_sub_add_t model_sub_add; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD */
|
||||
esp_ble_mesh_cfg_model_sub_delete_t model_sub_delete; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE */
|
||||
esp_ble_mesh_cfg_model_sub_overwrite_t model_sub_overwrite; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_OVERWRITE */
|
||||
esp_ble_mesh_cfg_model_sub_va_add_t model_sub_va_add; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_ADD */
|
||||
esp_ble_mesh_cfg_model_sub_va_delete_t model_sub_va_delete; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_DELETE */
|
||||
esp_ble_mesh_cfg_model_sub_va_overwrite_t model_sub_va_overwrite; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_OVERWRITE */
|
||||
esp_ble_mesh_cfg_heartbeat_pub_set_t heartbeat_pub_set; /*!< For ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_SET */
|
||||
esp_ble_mesh_cfg_heartbeat_sub_set_t heartbeat_sub_set; /*!< For ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_SET */
|
||||
esp_ble_mesh_cfg_model_pub_va_set_t model_pub_va_set; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_PUB_VIRTUAL_ADDR_SET */
|
||||
esp_ble_mesh_cfg_model_sub_delete_all_t model_sub_delete_all; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE_ALL */
|
||||
esp_ble_mesh_cfg_net_key_update_t net_key_update; /*!< For ESP_BLE_MESH_MODEL_OP_NET_KEY_UPDATE */
|
||||
esp_ble_mesh_cfg_net_key_delete_t net_key_delete; /*!< For ESP_BLE_MESH_MODEL_OP_NET_KEY_DELETE */
|
||||
esp_ble_mesh_cfg_app_key_update_t app_key_update; /*!< For ESP_BLE_MESH_MODEL_OP_APP_KEY_UPDATE */
|
||||
esp_ble_mesh_cfg_app_key_delete_t app_key_delete; /*!< For ESP_BLE_MESH_MODEL_OP_APP_KEY_DELETE */
|
||||
esp_ble_mesh_cfg_node_identity_set_t node_identity_set; /*!< For ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_SET */
|
||||
esp_ble_mesh_cfg_model_app_unbind_t model_app_unbind; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_APP_UNBIND */
|
||||
esp_ble_mesh_cfg_kr_phase_set_t kr_phase_set; /*!< For ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_SET */
|
||||
esp_ble_mesh_cfg_net_transmit_set_t net_transmit_set; /*!< For ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_SET */
|
||||
} esp_ble_mesh_cfg_client_set_state_t;
|
||||
|
||||
/** Parameter of Config Beacon Status */
|
||||
typedef struct {
|
||||
uint8_t beacon; /*!< Secure Network Beacon state value */
|
||||
} esp_ble_mesh_cfg_beacon_status_cb_t;
|
||||
|
||||
/** Parameters of Config Composition Data Status */
|
||||
typedef struct {
|
||||
uint8_t page; /*!< Page number of the Composition Data */
|
||||
struct net_buf_simple *composition_data; /*!< Pointer to Composition Data for the identified page */
|
||||
} esp_ble_mesh_cfg_comp_data_status_cb_t;
|
||||
|
||||
/** Parameter of Config Default TTL Status */
|
||||
typedef struct {
|
||||
uint8_t default_ttl; /*!< Default TTL state value */
|
||||
} esp_ble_mesh_cfg_default_ttl_status_cb_t;
|
||||
|
||||
/** Parameter of Config GATT Proxy Status */
|
||||
typedef struct {
|
||||
uint8_t gatt_proxy; /*!< GATT Proxy state value */
|
||||
} esp_ble_mesh_cfg_gatt_proxy_status_cb_t;
|
||||
|
||||
/** Parameters of Config Relay Status */
|
||||
typedef struct {
|
||||
uint8_t relay; /*!< Relay state value */
|
||||
uint8_t retransmit; /*!< Relay retransmit value(number of retransmissions and number of 10-millisecond steps between retransmissions) */
|
||||
} esp_ble_mesh_cfg_relay_status_cb_t;
|
||||
|
||||
/** Parameters of Config Model Publication Status */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status Code for the request message */
|
||||
uint16_t element_addr; /*!< Address of the element */
|
||||
uint16_t publish_addr; /*!< Value of the publish address */
|
||||
uint16_t app_idx; /*!< Index of the application key */
|
||||
bool cred_flag; /*!< Value of the Friendship Credential Flag */
|
||||
uint8_t ttl; /*!< Default TTL value for the outgoing messages */
|
||||
uint8_t period; /*!< Period for periodic status publishing */
|
||||
uint8_t transmit; /*!< Number of retransmissions and number of 50-millisecond steps between retransmissions */
|
||||
uint16_t company_id; /*!< Company ID */
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
} esp_ble_mesh_cfg_model_pub_status_cb_t;
|
||||
|
||||
/** Parameters of Config Model Subscription Status */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status Code for the request message */
|
||||
uint16_t element_addr; /*!< Address of the element */
|
||||
uint16_t sub_addr; /*!< Value of the address */
|
||||
uint16_t company_id; /*!< Company ID */
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
} esp_ble_mesh_cfg_model_sub_status_cb_t;
|
||||
|
||||
/** Parameters of Config NetKey Status */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status Code for the request message */
|
||||
uint16_t net_idx; /*!< Index of the NetKey */
|
||||
} esp_ble_mesh_cfg_net_key_status_cb_t;
|
||||
|
||||
/** Parameters of Config AppKey Status */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status Code for the request message */
|
||||
uint16_t net_idx; /*!< Index of the NetKey */
|
||||
uint16_t app_idx; /*!< Index of the application key */
|
||||
} esp_ble_mesh_cfg_app_key_status_cb_t;
|
||||
|
||||
/** Parameters of Config Model App Status */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status Code for the request message */
|
||||
uint16_t element_addr; /*!< Address of the element */
|
||||
uint16_t app_idx; /*!< Index of the application key */
|
||||
uint16_t company_id; /*!< Company ID */
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
} esp_ble_mesh_cfg_mod_app_status_cb_t;
|
||||
|
||||
/** Parameter of Config Friend Status */
|
||||
typedef struct {
|
||||
uint8_t friend_state; /*!< Friend state value */
|
||||
} esp_ble_mesh_cfg_friend_status_cb_t;
|
||||
|
||||
/** Parameters of Config Heartbeat Publication Status */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status Code for the request message */
|
||||
uint16_t dst; /*!< Destination address for Heartbeat messages */
|
||||
uint8_t count; /*!< Number of Heartbeat messages remaining to be sent */
|
||||
uint8_t period; /*!< Period for sending Heartbeat messages */
|
||||
uint8_t ttl; /*!< TTL to be used when sending Heartbeat messages */
|
||||
uint16_t features; /*!< Features that trigger Heartbeat messages when changed */
|
||||
uint16_t net_idx; /*!< Index of the NetKey */
|
||||
} esp_ble_mesh_cfg_hb_pub_status_cb_t;
|
||||
|
||||
/** Parameters of Config Heartbeat Subscription Status */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status Code for the request message */
|
||||
uint16_t src; /*!< Source address for Heartbeat messages */
|
||||
uint16_t dst; /*!< Destination address for Heartbeat messages */
|
||||
uint8_t period; /*!< Remaining Period for processing Heartbeat messages */
|
||||
uint8_t count; /*!< Number of Heartbeat messages received */
|
||||
uint8_t min_hops; /*!< Minimum hops when receiving Heartbeat messages */
|
||||
uint8_t max_hops; /*!< Maximum hops when receiving Heartbeat messages */
|
||||
} esp_ble_mesh_cfg_hb_sub_status_cb_t;
|
||||
|
||||
/** Parameters of Config Network Transmit Status */
|
||||
typedef struct {
|
||||
uint8_t net_trans_count: 3; /*!< Number of transmissions for each Network PDU originating from the node */
|
||||
uint8_t net_trans_step : 5; /*!< Maximum hops when receiving Heartbeat messages */
|
||||
} esp_ble_mesh_cfg_net_trans_status_cb_t;
|
||||
|
||||
/** Parameters of Config SIG/Vendor Subscription List */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status Code for the request message */
|
||||
uint16_t element_addr; /*!< Address of the element */
|
||||
uint16_t company_id; /*!< Company ID */
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
struct net_buf_simple *sub_addr; /*!< A block of all addresses from the Subscription List */
|
||||
} esp_ble_mesh_cfg_model_sub_list_cb_t;
|
||||
|
||||
/** Parameter of Config NetKey List */
|
||||
typedef struct {
|
||||
struct net_buf_simple *net_idx; /*!< A list of NetKey Indexes known to the node */
|
||||
} esp_ble_mesh_cfg_net_key_list_cb_t;
|
||||
|
||||
/** Parameters of Config AppKey List */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status Code for the request message */
|
||||
uint16_t net_idx; /*!< NetKey Index of the NetKey that the AppKeys are bound to */
|
||||
struct net_buf_simple *app_idx; /*!< A list of AppKey indexes that are bound to the NetKey identified by NetKeyIndex */
|
||||
} esp_ble_mesh_cfg_app_key_list_cb_t;
|
||||
|
||||
/** Parameters of Config Node Identity Status */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status Code for the request message */
|
||||
uint16_t net_idx; /*!< Index of the NetKey */
|
||||
uint8_t identity; /*!< Node Identity state */
|
||||
} esp_ble_mesh_cfg_node_id_status_cb_t;
|
||||
|
||||
/** Parameters of Config SIG/Vendor Model App List */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status Code for the request message */
|
||||
uint16_t element_addr; /*!< Address of the element */
|
||||
uint16_t company_id; /*!< Company ID */
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
struct net_buf_simple *app_idx; /*!< All AppKey indexes bound to the Model */
|
||||
} esp_ble_mesh_cfg_model_app_list_cb_t;
|
||||
|
||||
/** Parameters of Config Key Refresh Phase Status */
|
||||
typedef struct {
|
||||
uint8_t status; /*!< Status Code for the request message */
|
||||
uint16_t net_idx; /*!< Index of the NetKey */
|
||||
uint8_t phase; /*!< Key Refresh Phase state */
|
||||
} esp_ble_mesh_cfg_kr_phase_status_cb_t;
|
||||
|
||||
/** Parameters of Config Low Power Node PollTimeout Status */
|
||||
typedef struct {
|
||||
uint16_t lpn_addr; /*!< The unicast address of the Low Power node */
|
||||
int32_t poll_timeout; /*!< The current value of the PollTimeout timer of the Low Power node */
|
||||
} esp_ble_mesh_cfg_lpn_pollto_status_cb_t;
|
||||
|
||||
/**
|
||||
* @brief Configuration Client Model received message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_cfg_beacon_status_cb_t beacon_status; /*!< The beacon status value */
|
||||
esp_ble_mesh_cfg_comp_data_status_cb_t comp_data_status; /*!< The composition data status value */
|
||||
esp_ble_mesh_cfg_default_ttl_status_cb_t default_ttl_status; /*!< The default_ttl status value */
|
||||
esp_ble_mesh_cfg_gatt_proxy_status_cb_t gatt_proxy_status; /*!< The gatt_proxy status value */
|
||||
esp_ble_mesh_cfg_relay_status_cb_t relay_status; /*!< The relay status value */
|
||||
esp_ble_mesh_cfg_model_pub_status_cb_t model_pub_status; /*!< The model publication status value */
|
||||
esp_ble_mesh_cfg_model_sub_status_cb_t model_sub_status; /*!< The model subscription status value */
|
||||
esp_ble_mesh_cfg_net_key_status_cb_t netkey_status; /*!< The netkey status value */
|
||||
esp_ble_mesh_cfg_app_key_status_cb_t appkey_status; /*!< The appkey status value */
|
||||
esp_ble_mesh_cfg_mod_app_status_cb_t model_app_status; /*!< The model app status value */
|
||||
esp_ble_mesh_cfg_friend_status_cb_t friend_status; /*!< The friend status value */
|
||||
esp_ble_mesh_cfg_hb_pub_status_cb_t heartbeat_pub_status; /*!< The heartbeat publication status value */
|
||||
esp_ble_mesh_cfg_hb_sub_status_cb_t heartbeat_sub_status; /*!< The heartbeat subscription status value */
|
||||
esp_ble_mesh_cfg_net_trans_status_cb_t net_transmit_status; /*!< The network transmit status value */
|
||||
esp_ble_mesh_cfg_model_sub_list_cb_t model_sub_list; /*!< The model subscription list value */
|
||||
esp_ble_mesh_cfg_net_key_list_cb_t netkey_list; /*!< The network key index list value */
|
||||
esp_ble_mesh_cfg_app_key_list_cb_t appkey_list; /*!< The application key index list value */
|
||||
esp_ble_mesh_cfg_node_id_status_cb_t node_identity_status; /*!< The node identity status value */
|
||||
esp_ble_mesh_cfg_model_app_list_cb_t model_app_list; /*!< The model application key index list value */
|
||||
esp_ble_mesh_cfg_kr_phase_status_cb_t kr_phase_status; /*!< The key refresh phase status value */
|
||||
esp_ble_mesh_cfg_lpn_pollto_status_cb_t lpn_timeout_status; /*!< The low power node poll timeout status value */
|
||||
} esp_ble_mesh_cfg_client_common_cb_param_t;
|
||||
|
||||
/** Configuration Client Model callback parameters */
|
||||
typedef struct {
|
||||
int error_code; /*!< Appropriate error code */
|
||||
esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters */
|
||||
esp_ble_mesh_cfg_client_common_cb_param_t status_cb; /*!< The config status message callback values */
|
||||
} esp_ble_mesh_cfg_client_cb_param_t;
|
||||
|
||||
/** This enum value is the event of Configuration Client Model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_CFG_CLIENT_GET_STATE_EVT,
|
||||
ESP_BLE_MESH_CFG_CLIENT_SET_STATE_EVT,
|
||||
ESP_BLE_MESH_CFG_CLIENT_PUBLISH_EVT,
|
||||
ESP_BLE_MESH_CFG_CLIENT_TIMEOUT_EVT,
|
||||
ESP_BLE_MESH_CFG_CLIENT_EVT_MAX,
|
||||
} esp_ble_mesh_cfg_client_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Configuration Server model related context.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< Element Address */
|
||||
uint16_t pub_addr; /*!< Publish Address */
|
||||
uint16_t app_idx; /*!< AppKey Index */
|
||||
bool cred_flag; /*!< Friendship Credential Flag */
|
||||
uint8_t pub_ttl; /*!< Publish TTL */
|
||||
uint8_t pub_period; /*!< Publish Period */
|
||||
uint8_t pub_retransmit; /*!< Publish Retransmit */
|
||||
uint16_t company_id; /*!< Company ID */
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
} esp_ble_mesh_state_change_cfg_mod_pub_set_t;
|
||||
|
||||
/** Parameters of Config Model Subscription Add */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< Element Address */
|
||||
uint16_t sub_addr; /*!< Subscription Address */
|
||||
uint16_t company_id; /*!< Company ID */
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
} esp_ble_mesh_state_change_cfg_model_sub_add_t;
|
||||
|
||||
/** Parameters of Config Model Subscription Delete */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< Element Address */
|
||||
uint16_t sub_addr; /*!< Subscription Address */
|
||||
uint16_t company_id; /*!< Company ID */
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
} esp_ble_mesh_state_change_cfg_model_sub_delete_t;
|
||||
|
||||
/** Parameters of Config NetKey Add */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint8_t net_key[16]; /*!< NetKey */
|
||||
} esp_ble_mesh_state_change_cfg_netkey_add_t;
|
||||
|
||||
/** Parameters of Config NetKey Update */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint8_t net_key[16]; /*!< NetKey */
|
||||
} esp_ble_mesh_state_change_cfg_netkey_update_t;
|
||||
|
||||
/** Parameter of Config NetKey Delete */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
} esp_ble_mesh_state_change_cfg_netkey_delete_t;
|
||||
|
||||
/** Parameters of Config AppKey Add */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint16_t app_idx; /*!< AppKey Index */
|
||||
uint8_t app_key[16]; /*!< AppKey */
|
||||
} esp_ble_mesh_state_change_cfg_appkey_add_t;
|
||||
|
||||
/** Parameters of Config AppKey Update */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint16_t app_idx; /*!< AppKey Index */
|
||||
uint8_t app_key[16]; /*!< AppKey */
|
||||
} esp_ble_mesh_state_change_cfg_appkey_update_t;
|
||||
|
||||
/** Parameters of Config AppKey Delete */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint16_t app_idx; /*!< AppKey Index */
|
||||
} esp_ble_mesh_state_change_cfg_appkey_delete_t;
|
||||
|
||||
/** Parameters of Config Model App Bind */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< Element Address */
|
||||
uint16_t app_idx; /*!< AppKey Index */
|
||||
uint16_t company_id; /*!< Company ID */
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
} esp_ble_mesh_state_change_cfg_model_app_bind_t;
|
||||
|
||||
/** Parameters of Config Model App Unbind */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< Element Address */
|
||||
uint16_t app_idx; /*!< AppKey Index */
|
||||
uint16_t company_id; /*!< Company ID */
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
} esp_ble_mesh_state_change_cfg_model_app_unbind_t;
|
||||
|
||||
/** Parameters of Config Key Refresh Phase Set */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint8_t kr_phase; /*!< New Key Refresh Phase Transition */
|
||||
} esp_ble_mesh_state_change_cfg_kr_phase_set_t;
|
||||
|
||||
/**
|
||||
* @brief Configuration Server model state change value union
|
||||
*/
|
||||
typedef union {
|
||||
/**
|
||||
* The recv_op in ctx can be used to decide which state is changed.
|
||||
*/
|
||||
esp_ble_mesh_state_change_cfg_mod_pub_set_t mod_pub_set; /*!< Config Model Publication Set */
|
||||
esp_ble_mesh_state_change_cfg_model_sub_add_t mod_sub_add; /*!< Config Model Subscription Add */
|
||||
esp_ble_mesh_state_change_cfg_model_sub_delete_t mod_sub_delete; /*!< Config Model Subscription Delete */
|
||||
esp_ble_mesh_state_change_cfg_netkey_add_t netkey_add; /*!< Config NetKey Add */
|
||||
esp_ble_mesh_state_change_cfg_netkey_update_t netkey_update; /*!< Config NetKey Update */
|
||||
esp_ble_mesh_state_change_cfg_netkey_delete_t netkey_delete; /*!< Config NetKey Delete */
|
||||
esp_ble_mesh_state_change_cfg_appkey_add_t appkey_add; /*!< Config AppKey Add */
|
||||
esp_ble_mesh_state_change_cfg_appkey_update_t appkey_update; /*!< Config AppKey Update */
|
||||
esp_ble_mesh_state_change_cfg_appkey_delete_t appkey_delete; /*!< Config AppKey Delete */
|
||||
esp_ble_mesh_state_change_cfg_model_app_bind_t mod_app_bind; /*!< Config Model App Bind */
|
||||
esp_ble_mesh_state_change_cfg_model_app_unbind_t mod_app_unbind; /*!< Config Model App Unbind */
|
||||
esp_ble_mesh_state_change_cfg_kr_phase_set_t kr_phase_set; /*!< Config Key Refresh Phase Set */
|
||||
} esp_ble_mesh_cfg_server_state_change_t;
|
||||
|
||||
/**
|
||||
* @brief Configuration Server model callback value union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_cfg_server_state_change_t state_change; /*!< ESP_BLE_MESH_CFG_SERVER_STATE_CHANGE_EVT */
|
||||
} esp_ble_mesh_cfg_server_cb_value_t;
|
||||
|
||||
/** Configuration Server model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received message */
|
||||
esp_ble_mesh_cfg_server_cb_value_t value; /*!< Value of the received configuration messages */
|
||||
} esp_ble_mesh_cfg_server_cb_param_t;
|
||||
|
||||
/** This enum value is the event of Configuration Server model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_CFG_SERVER_STATE_CHANGE_EVT,
|
||||
ESP_BLE_MESH_CFG_SERVER_EVT_MAX,
|
||||
} esp_ble_mesh_cfg_server_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth Mesh Config Client and Server Model functions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Configuration Client Model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_cfg_client_cb_t)(esp_ble_mesh_cfg_client_cb_event_t event,
|
||||
esp_ble_mesh_cfg_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Configuration Server Model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_cfg_server_cb_t)(esp_ble_mesh_cfg_server_cb_event_t event,
|
||||
esp_ble_mesh_cfg_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Config Client Model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_config_client_callback(esp_ble_mesh_cfg_client_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Config Server Model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_config_server_callback(esp_ble_mesh_cfg_server_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Get the value of Config Server Model states using the Config Client Model get messages.
|
||||
*
|
||||
* @note If you want to find the opcodes and corresponding meanings accepted by this API,
|
||||
* please refer to esp_ble_mesh_opcode_config_client_get_t in esp_ble_mesh_defs.h
|
||||
*
|
||||
* @param[in] params: Pointer to BLE Mesh common client parameters.
|
||||
* @param[in] get_state: Pointer to a union, each kind of opcode corresponds to one structure inside.
|
||||
* Shall not be set to NULL.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_cfg_client_get_state_t *get_state);
|
||||
|
||||
/**
|
||||
* @brief Set the value of the Configuration Server Model states using the Config Client Model set messages.
|
||||
*
|
||||
* @note If you want to find the opcodes and corresponding meanings accepted by this API,
|
||||
* please refer to esp_ble_mesh_opcode_config_client_set_t in esp_ble_mesh_defs.h
|
||||
*
|
||||
* @param[in] params: Pointer to BLE Mesh common client parameters.
|
||||
* @param[in] set_state: Pointer to a union, each kind of opcode corresponds to one structure inside.
|
||||
* Shall not be set to NULL.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_cfg_client_set_state_t *set_state);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_CONFIG_MODEL_API_H_ */
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,406 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_HEALTH_MODEL_API_H_
|
||||
#define _ESP_BLE_MESH_HEALTH_MODEL_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_HEALTH_SRV
|
||||
*
|
||||
* @brief Define a new Health Server Model.
|
||||
*
|
||||
* @note The Health Server Model can only be included by a Primary Element.
|
||||
*
|
||||
* @param srv Pointer to the unique struct esp_ble_mesh_health_srv_t.
|
||||
* @param pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
*
|
||||
* @return New Health Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_HEALTH_SRV(srv, pub) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_HEALTH_SRV, \
|
||||
NULL, pub, srv)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_HEALTH_CLI
|
||||
*
|
||||
* @brief Define a new Health Client Model.
|
||||
*
|
||||
* @note This API needs to be called for each element on which
|
||||
* the application needs to have a Health Client Model.
|
||||
*
|
||||
* @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
|
||||
*
|
||||
* @return New Health Client Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_HEALTH_CLI(cli_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_HEALTH_CLI, \
|
||||
NULL, NULL, cli_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_HEALTH_PUB_DEFINE
|
||||
*
|
||||
* A helper to define a health publication context
|
||||
*
|
||||
* @param _name Name given to the publication context variable.
|
||||
* @param _max Maximum number of faults the element can have.
|
||||
* @param _role Role of the device which contains the model.
|
||||
*/
|
||||
#define ESP_BLE_MESH_HEALTH_PUB_DEFINE(_name, _max, _role) \
|
||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(_name, (1 + 3 + (_max)), _role)
|
||||
|
||||
/**
|
||||
* SIG identifier of Health Fault Test.
|
||||
* 0x01 ~ 0xFF: Vendor Specific Test.
|
||||
*/
|
||||
#define ESP_BLE_MESH_HEALTH_STANDARD_TEST 0x00
|
||||
|
||||
/**
|
||||
* Fault values of Health Fault Test.
|
||||
* 0x33 ~ 0x7F: Reserved for Future Use.
|
||||
* 0x80 ~ 0xFF: Vendor Specific Warning/Error.
|
||||
*/
|
||||
#define ESP_BLE_MESH_NO_FAULT 0x00
|
||||
#define ESP_BLE_MESH_BATTERY_LOW_WARNING 0x01
|
||||
#define ESP_BLE_MESH_BATTERY_LOW_ERROR 0x02
|
||||
#define ESP_BLE_MESH_SUPPLY_VOLTAGE_TOO_LOW_WARNING 0x03
|
||||
#define ESP_BLE_MESH_SUPPLY_VOLTAGE_TOO_LOW_ERROR 0x04
|
||||
#define ESP_BLE_MESH_SUPPLY_VOLTAGE_TOO_HIGH_WARNING 0x05
|
||||
#define ESP_BLE_MESH_SUPPLY_VOLTAGE_TOO_HIGH_ERROR 0x06
|
||||
#define ESP_BLE_MESH_POWER_SUPPLY_INTERRUPTED_WARNING 0x07
|
||||
#define ESP_BLE_MESH_POWER_SUPPLY_INTERRUPTED_ERROR 0x08
|
||||
#define ESP_BLE_MESH_NO_LOAD_WARNING 0x09
|
||||
#define ESP_BLE_MESH_NO_LOAD_ERROR 0x0A
|
||||
#define ESP_BLE_MESH_OVERLOAD_WARNING 0x0B
|
||||
#define ESP_BLE_MESH_OVERLOAD_ERROR 0x0C
|
||||
#define ESP_BLE_MESH_OVERHEAT_WARNING 0x0D
|
||||
#define ESP_BLE_MESH_OVERHEAT_ERROR 0x0E
|
||||
#define ESP_BLE_MESH_CONDENSATION_WARNING 0x0F
|
||||
#define ESP_BLE_MESH_CONDENSATION_ERROR 0x10
|
||||
#define ESP_BLE_MESH_VIBRATION_WARNING 0x11
|
||||
#define ESP_BLE_MESH_VIBRATION_ERROR 0x12
|
||||
#define ESP_BLE_MESH_CONFIGURATION_WARNING 0x13
|
||||
#define ESP_BLE_MESH_CONFIGURATION_ERROR 0x14
|
||||
#define ESP_BLE_MESH_ELEMENT_NOT_CALIBRATED_WARNING 0x15
|
||||
#define ESP_BLE_MESH_ELEMENT_NOT_CALIBRATED_ERROR 0x16
|
||||
#define ESP_BLE_MESH_MEMORY_WARNING 0x17
|
||||
#define ESP_BLE_MESH_MEMORY_ERROR 0x18
|
||||
#define ESP_BLE_MESH_SELF_TEST_WARNING 0x19
|
||||
#define ESP_BLE_MESH_SELF_TEST_ERROR 0x1A
|
||||
#define ESP_BLE_MESH_INPUT_TOO_LOW_WARNING 0x1B
|
||||
#define ESP_BLE_MESH_INPUT_TOO_LOW_ERROR 0x1C
|
||||
#define ESP_BLE_MESH_INPUT_TOO_HIGH_WARNING 0x1D
|
||||
#define ESP_BLE_MESH_INPUT_TOO_HIGH_ERROR 0x1E
|
||||
#define ESP_BLE_MESH_INPUT_NO_CHANGE_WARNING 0x1F
|
||||
#define ESP_BLE_MESH_INPUT_NO_CHANGE_ERROR 0x20
|
||||
#define ESP_BLE_MESH_ACTUATOR_BLOCKED_WARNING 0x21
|
||||
#define ESP_BLE_MESH_ACTUATOR_BLOCKED_ERROR 0x22
|
||||
#define ESP_BLE_MESH_HOUSING_OPENED_WARNING 0x23
|
||||
#define ESP_BLE_MESH_HOUSING_OPENED_ERROR 0x24
|
||||
#define ESP_BLE_MESH_TAMPER_WARNING 0x25
|
||||
#define ESP_BLE_MESH_TAMPER_ERROR 0x26
|
||||
#define ESP_BLE_MESH_DEVICE_MOVED_WARNING 0x27
|
||||
#define ESP_BLE_MESH_DEVICE_MOVED_ERROR 0x28
|
||||
#define ESP_BLE_MESH_DEVICE_DROPPED_WARNING 0x29
|
||||
#define ESP_BLE_MESH_DEVICE_DROPPED_ERROR 0x2A
|
||||
#define ESP_BLE_MESH_OVERFLOW_WARNING 0x2B
|
||||
#define ESP_BLE_MESH_OVERFLOW_ERROR 0x2C
|
||||
#define ESP_BLE_MESH_EMPTY_WARNING 0x2D
|
||||
#define ESP_BLE_MESH_EMPTY_ERROR 0x2E
|
||||
#define ESP_BLE_MESH_INTERNAL_BUS_WARNING 0x2F
|
||||
#define ESP_BLE_MESH_INTERNAL_BUS_ERROR 0x30
|
||||
#define ESP_BLE_MESH_MECHANISM_JAMMED_WARNING 0x31
|
||||
#define ESP_BLE_MESH_MECHANISM_JAMMED_ERROR 0x32
|
||||
|
||||
/** ESP BLE Mesh Health Server callback */
|
||||
typedef struct {
|
||||
/** Clear health registered faults. Initialized by the stack. */
|
||||
esp_ble_mesh_cb_t fault_clear;
|
||||
|
||||
/** Run a specific health test. Initialized by the stack. */
|
||||
esp_ble_mesh_cb_t fault_test;
|
||||
|
||||
/** Health attention on callback. Initialized by the stack. */
|
||||
esp_ble_mesh_cb_t attention_on;
|
||||
|
||||
/** Health attention off callback. Initialized by the stack. */
|
||||
esp_ble_mesh_cb_t attention_off;
|
||||
} esp_ble_mesh_health_srv_cb_t;
|
||||
|
||||
#define ESP_BLE_MESH_HEALTH_FAULT_ARRAY_SIZE 32
|
||||
|
||||
/** ESP BLE Mesh Health Server test Context */
|
||||
typedef struct {
|
||||
uint8_t id_count; /*!< Number of Health self-test ID */
|
||||
const uint8_t *test_ids; /*!< Array of Health self-test IDs */
|
||||
uint16_t company_id; /*!< Company ID used to identify the Health Fault state */
|
||||
uint8_t prev_test_id; /*!< Current test ID of the health fault test */
|
||||
uint8_t current_faults[ESP_BLE_MESH_HEALTH_FAULT_ARRAY_SIZE]; /*!< Array of current faults */
|
||||
uint8_t registered_faults[ESP_BLE_MESH_HEALTH_FAULT_ARRAY_SIZE]; /*!< Array of registered faults */
|
||||
} __attribute__((packed)) esp_ble_mesh_health_test_t;
|
||||
|
||||
/** ESP BLE Mesh Health Server Model Context */
|
||||
typedef struct {
|
||||
/** Pointer to Health Server Model */
|
||||
esp_ble_mesh_model_t *model;
|
||||
|
||||
/** Health callback struct */
|
||||
esp_ble_mesh_health_srv_cb_t health_cb;
|
||||
|
||||
/** Attention Timer state */
|
||||
struct k_delayed_work attention_timer;
|
||||
|
||||
/** Attention Timer start flag */
|
||||
bool attention_timer_start;
|
||||
|
||||
/** Health Server fault test */
|
||||
esp_ble_mesh_health_test_t health_test;
|
||||
} esp_ble_mesh_health_srv_t;
|
||||
|
||||
/** Parameter of Health Fault Get */
|
||||
typedef struct {
|
||||
uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */
|
||||
} esp_ble_mesh_health_fault_get_t;
|
||||
|
||||
/** Parameter of Health Attention Set */
|
||||
typedef struct {
|
||||
uint8_t attention; /*!< Value of the Attention Timer state */
|
||||
} esp_ble_mesh_health_attention_set_t;
|
||||
|
||||
/** Parameter of Health Period Set */
|
||||
typedef struct {
|
||||
uint8_t fast_period_divisor; /*!< Divider for the Publish Period */
|
||||
} esp_ble_mesh_health_period_set_t;
|
||||
|
||||
/** Parameter of Health Fault Test */
|
||||
typedef struct {
|
||||
uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */
|
||||
uint8_t test_id; /*!< ID of a specific test to be performed */
|
||||
} esp_ble_mesh_health_fault_test_t;
|
||||
|
||||
/** Parameter of Health Fault Clear */
|
||||
typedef struct {
|
||||
uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */
|
||||
} esp_ble_mesh_health_fault_clear_t;
|
||||
|
||||
/**
|
||||
* @brief For ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET
|
||||
* ESP_BLE_MESH_MODEL_OP_ATTENTION_GET
|
||||
* ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET
|
||||
* the get_state parameter in the esp_ble_mesh_health_client_get_state function should not be set to NULL.
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_health_fault_get_t fault_get; /*!< For ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET. */
|
||||
} esp_ble_mesh_health_client_get_state_t;
|
||||
|
||||
/**
|
||||
* @brief For ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR
|
||||
* ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK
|
||||
* ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST
|
||||
* ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK
|
||||
* ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET
|
||||
* ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK
|
||||
* ESP_BLE_MESH_MODEL_OP_ATTENTION_SET
|
||||
* ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK
|
||||
* the set_state parameter in the esp_ble_mesh_health_client_set_state function should not be set to NULL.
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_health_attention_set_t attention_set; /*!< For ESP_BLE_MESH_MODEL_OP_ATTENTION_SET or ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK. */
|
||||
esp_ble_mesh_health_period_set_t period_set; /*!< For ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET or ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK. */
|
||||
esp_ble_mesh_health_fault_test_t fault_test; /*!< For ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST or ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK. */
|
||||
esp_ble_mesh_health_fault_clear_t fault_clear; /*!< For ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR or ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK. */
|
||||
} esp_ble_mesh_health_client_set_state_t;
|
||||
|
||||
/** Parameters of Health Current Status */
|
||||
typedef struct {
|
||||
uint8_t test_id; /*!< ID of a most recently performed test */
|
||||
uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */
|
||||
struct net_buf_simple *fault_array; /*!< FaultArray field contains a sequence of 1-octet fault values */
|
||||
} esp_ble_mesh_health_current_status_cb_t;
|
||||
|
||||
/** Parameters of Health Fault Status */
|
||||
typedef struct {
|
||||
uint8_t test_id; /*!< ID of a most recently performed test */
|
||||
uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */
|
||||
struct net_buf_simple *fault_array; /*!< FaultArray field contains a sequence of 1-octet fault values */
|
||||
} esp_ble_mesh_health_fault_status_cb_t;
|
||||
|
||||
/** Parameter of Health Period Status */
|
||||
typedef struct {
|
||||
uint8_t fast_period_divisor; /*!< Divider for the Publish Period */
|
||||
} esp_ble_mesh_health_period_status_cb_t;
|
||||
|
||||
/** Parameter of Health Attention Status */
|
||||
typedef struct {
|
||||
uint8_t attention; /*!< Value of the Attention Timer state */
|
||||
} esp_ble_mesh_health_attention_status_cb_t;
|
||||
|
||||
/**
|
||||
* @brief Health Client Model received message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_health_current_status_cb_t current_status; /*!< The health current status value */
|
||||
esp_ble_mesh_health_fault_status_cb_t fault_status; /*!< The health fault status value */
|
||||
esp_ble_mesh_health_period_status_cb_t period_status; /*!< The health period status value */
|
||||
esp_ble_mesh_health_attention_status_cb_t attention_status; /*!< The health attention status value */
|
||||
} esp_ble_mesh_health_client_common_cb_param_t;
|
||||
|
||||
/** Health Client Model callback parameters */
|
||||
typedef struct {
|
||||
int error_code; /*!< Appropriate error code */
|
||||
esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters. */
|
||||
esp_ble_mesh_health_client_common_cb_param_t status_cb; /*!< The health message status callback values */
|
||||
} esp_ble_mesh_health_client_cb_param_t;
|
||||
|
||||
/** This enum value is the event of Health Client Model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT,
|
||||
ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT,
|
||||
ESP_BLE_MESH_HEALTH_CLIENT_PUBLISH_EVT,
|
||||
ESP_BLE_MESH_HEALTH_CLIENT_TIMEOUT_EVT,
|
||||
ESP_BLE_MESH_HEALTH_CLIENT_EVT_MAX,
|
||||
} esp_ble_mesh_health_client_cb_event_t;
|
||||
|
||||
/** Parameter of publishing Health Current Status completion event */
|
||||
typedef struct {
|
||||
int error_code; /*!< The result of publishing Health Current Status */
|
||||
esp_ble_mesh_elem_t *element; /*!< Pointer to the element which contains the Health Server Model */
|
||||
} esp_ble_mesh_health_fault_update_comp_cb_t;
|
||||
|
||||
/** Parameters of Health Fault Clear event */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Health Server Model */
|
||||
uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */
|
||||
} esp_ble_mesh_health_fault_clear_cb_t;
|
||||
|
||||
/** Parameters of Health Fault Test event */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Health Server Model */
|
||||
uint8_t test_id; /*!< ID of a specific test to be performed */
|
||||
uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */
|
||||
} esp_ble_mesh_health_fault_test_cb_t;
|
||||
|
||||
/** Parameter of Health Attention On event */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Health Server Model */
|
||||
uint8_t time; /*!< Duration of attention timer on (in seconds) */
|
||||
} esp_ble_mesh_health_attention_on_cb_t;
|
||||
|
||||
/** Parameter of Health Attention Off event */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Health Server Model */
|
||||
} esp_ble_mesh_health_attention_off_cb_t;
|
||||
|
||||
/**
|
||||
* @brief Health Server Model callback parameters union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_health_fault_update_comp_cb_t fault_update_comp; /*!< ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMP_EVT */
|
||||
esp_ble_mesh_health_fault_clear_cb_t fault_clear; /*!< ESP_BLE_MESH_HEALTH_SERVER_FAULT_CLEAR_EVT */
|
||||
esp_ble_mesh_health_fault_test_cb_t fault_test; /*!< ESP_BLE_MESH_HEALTH_SERVER_FAULT_TEST_EVT */
|
||||
esp_ble_mesh_health_attention_on_cb_t attention_on; /*!< ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_ON_EVT */
|
||||
esp_ble_mesh_health_attention_off_cb_t attention_off; /*!< ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_OFF_EVT */
|
||||
} esp_ble_mesh_health_server_cb_param_t;
|
||||
|
||||
/** This enum value is the event of Health Server Model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMP_EVT,
|
||||
ESP_BLE_MESH_HEALTH_SERVER_FAULT_CLEAR_EVT,
|
||||
ESP_BLE_MESH_HEALTH_SERVER_FAULT_TEST_EVT,
|
||||
ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_ON_EVT,
|
||||
ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_OFF_EVT,
|
||||
ESP_BLE_MESH_HEALTH_SERVER_EVT_MAX,
|
||||
} esp_ble_mesh_health_server_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth Mesh Health Client and Server Model function.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Health Client Model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_health_client_cb_t)(esp_ble_mesh_health_client_cb_event_t event,
|
||||
esp_ble_mesh_health_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Health Server Model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_health_server_cb_t)(esp_ble_mesh_health_server_cb_event_t event,
|
||||
esp_ble_mesh_health_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Health Model callback, the callback will report Health Client & Server Model events.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_health_client_callback(esp_ble_mesh_health_client_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Health Server Model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_health_server_callback(esp_ble_mesh_health_server_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get the Health Server states using the Health Client Model get messages.
|
||||
*
|
||||
* @note If you want to find the opcodes and corresponding meanings accepted by this API,
|
||||
* please refer to esp_ble_mesh_opcode_health_client_get_t in esp_ble_mesh_defs.h
|
||||
*
|
||||
* @param[in] params: Pointer to BLE Mesh common client parameters.
|
||||
* @param[in] get_state: Pointer to a union, each kind of opcode corresponds to one structure inside.
|
||||
* Shall not be set to NULL.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_health_client_get_state_t *get_state);
|
||||
|
||||
/**
|
||||
* @brief This function is called to set the Health Server states using the Health Client Model set messages.
|
||||
*
|
||||
* @note If you want to find the opcodes and corresponding meanings accepted by this API,
|
||||
* please refer to esp_ble_mesh_opcode_health_client_set_t in esp_ble_mesh_defs.h
|
||||
*
|
||||
* @param[in] params: Pointer to BLE Mesh common client parameters.
|
||||
* @param[in] set_state: Pointer to a union, each kind of opcode corresponds to one structure inside.
|
||||
* Shall not be set to NULL.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_health_client_set_state_t *set_state);
|
||||
|
||||
/**
|
||||
* @brief This function is called by the Health Server Model to update the context of its Health Current status.
|
||||
*
|
||||
* @param[in] element: The element to which the Health Server Model belongs.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_health_server_fault_update(esp_ble_mesh_elem_t *element);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_HEALTH_MODEL_API_H_ */
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,709 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/** @file
|
||||
* @brief Bluetooth Mesh Sensor Client Model APIs.
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_SENSOR_MODEL_API_H_
|
||||
#define _ESP_BLE_MESH_SENSOR_MODEL_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_SENSOR_CLI
|
||||
*
|
||||
* @brief Define a new Sensor Client Model.
|
||||
*
|
||||
* @note This API needs to be called for each element on which
|
||||
* the application needs to have a Sensor Client Model.
|
||||
*
|
||||
* @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
|
||||
*
|
||||
* @return New Sensor Client Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_SENSOR_CLI(cli_pub, cli_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SENSOR_CLI, \
|
||||
NULL, cli_pub, cli_data)
|
||||
|
||||
/**
|
||||
* @brief Bluetooth Mesh Sensor Client Model Get and Set parameters structure.
|
||||
*/
|
||||
|
||||
/** Parameters of Sensor Descriptor Get */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
uint16_t property_id; /*!< Property ID of a sensor (optional) */
|
||||
} esp_ble_mesh_sensor_descriptor_get_t;
|
||||
|
||||
/** Parameter of Sensor Cadence Get */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property ID of a sensor */
|
||||
} esp_ble_mesh_sensor_cadence_get_t;
|
||||
|
||||
/** Parameters of Sensor Cadence Set */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property ID for the sensor */
|
||||
uint8_t fast_cadence_period_divisor : 7, /*!< Divisor for the publish period */
|
||||
status_trigger_type : 1; /*!< The unit and format of the Status Trigger Delta fields */
|
||||
struct net_buf_simple *status_trigger_delta_down; /*!< Delta down value that triggers a status message */
|
||||
struct net_buf_simple *status_trigger_delta_up; /*!< Delta up value that triggers a status message */
|
||||
uint8_t status_min_interval; /*!< Minimum interval between two consecutive Status messages */
|
||||
struct net_buf_simple *fast_cadence_low; /*!< Low value for the fast cadence range */
|
||||
struct net_buf_simple *fast_cadence_high; /*!< Fast value for the fast cadence range */
|
||||
} esp_ble_mesh_sensor_cadence_set_t;
|
||||
|
||||
/** Parameter of Sensor Settings Get */
|
||||
typedef struct {
|
||||
uint16_t sensor_property_id; /*!< Property ID of a sensor */
|
||||
} esp_ble_mesh_sensor_settings_get_t;
|
||||
|
||||
/** Parameters of Sensor Setting Get */
|
||||
typedef struct {
|
||||
uint16_t sensor_property_id; /*!< Property ID of a sensor */
|
||||
uint16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
|
||||
} esp_ble_mesh_sensor_setting_get_t;
|
||||
|
||||
/** Parameters of Sensor Setting Set */
|
||||
typedef struct {
|
||||
uint16_t sensor_property_id; /*!< Property ID identifying a sensor */
|
||||
uint16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
|
||||
struct net_buf_simple *sensor_setting_raw; /*!< Raw value for the setting */
|
||||
} esp_ble_mesh_sensor_setting_set_t;
|
||||
|
||||
/** Parameters of Sensor Get */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
uint16_t property_id; /*!< Property ID for the sensor (optional) */
|
||||
} esp_ble_mesh_sensor_get_t;
|
||||
|
||||
/** Parameters of Sensor Column Get */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property identifying a sensor */
|
||||
struct net_buf_simple *raw_value_x; /*!< Raw value identifying a column */
|
||||
} esp_ble_mesh_sensor_column_get_t;
|
||||
|
||||
/** Parameters of Sensor Series Get */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
uint16_t property_id; /*!< Property identifying a sensor */
|
||||
struct net_buf_simple *raw_value_x1; /*!< Raw value identifying a starting column (optional) */
|
||||
struct net_buf_simple *raw_value_x2; /*!< Raw value identifying an ending column (C.1) */
|
||||
} esp_ble_mesh_sensor_series_get_t;
|
||||
|
||||
/**
|
||||
* @brief Sensor Client Model get message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_sensor_descriptor_get_t descriptor_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET */
|
||||
esp_ble_mesh_sensor_cadence_get_t cadence_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_GET */
|
||||
esp_ble_mesh_sensor_settings_get_t settings_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SETTINGS_GET */
|
||||
esp_ble_mesh_sensor_setting_get_t setting_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_GET */
|
||||
esp_ble_mesh_sensor_get_t sensor_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_GET */
|
||||
esp_ble_mesh_sensor_column_get_t column_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET */
|
||||
esp_ble_mesh_sensor_series_get_t series_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET */
|
||||
} esp_ble_mesh_sensor_client_get_state_t;
|
||||
|
||||
/**
|
||||
* @brief Sensor Client Model set message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_sensor_cadence_set_t cadence_set; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET & ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK */
|
||||
esp_ble_mesh_sensor_setting_set_t setting_set; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET & ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK */
|
||||
} esp_ble_mesh_sensor_client_set_state_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth Mesh Sensor Client Model Get and Set callback parameters structure.
|
||||
*/
|
||||
|
||||
/** Parameter of Sensor Descriptor Status */
|
||||
typedef struct {
|
||||
struct net_buf_simple *descriptor; /*!< Sequence of 8-octet sensor descriptors (optional) */
|
||||
} esp_ble_mesh_sensor_descriptor_status_cb_t;
|
||||
|
||||
/** Parameters of Sensor Cadence Status */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property for the sensor */
|
||||
struct net_buf_simple *sensor_cadence_value; /*!< Value of sensor cadence state */
|
||||
} esp_ble_mesh_sensor_cadence_status_cb_t;
|
||||
|
||||
/** Parameters of Sensor Settings Status */
|
||||
typedef struct {
|
||||
uint16_t sensor_property_id; /*!< Property ID identifying a sensor */
|
||||
struct net_buf_simple *sensor_setting_property_ids; /*!< A sequence of N sensor setting property IDs (optional) */
|
||||
} esp_ble_mesh_sensor_settings_status_cb_t;
|
||||
|
||||
/** Parameters of Sensor Setting Status */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate id optional parameters are included */
|
||||
uint16_t sensor_property_id; /*!< Property ID identifying a sensor */
|
||||
uint16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
|
||||
uint8_t sensor_setting_access; /*!< Read/Write access rights for the setting (optional) */
|
||||
struct net_buf_simple *sensor_setting_raw; /*!< Raw value for the setting */
|
||||
} esp_ble_mesh_sensor_setting_status_cb_t;
|
||||
|
||||
/** Parameter of Sensor Status */
|
||||
typedef struct {
|
||||
struct net_buf_simple *marshalled_sensor_data; /*!< Value of sensor data state (optional) */
|
||||
} esp_ble_mesh_sensor_status_cb_t;
|
||||
|
||||
/** Parameters of Sensor Column Status */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property identifying a sensor and the Y axis */
|
||||
struct net_buf_simple *sensor_column_value; /*!< Left values of sensor column status */
|
||||
} esp_ble_mesh_sensor_column_status_cb_t;
|
||||
|
||||
/** Parameters of Sensor Series Status */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property identifying a sensor and the Y axis */
|
||||
struct net_buf_simple *sensor_series_value; /*!< Left values of sensor series status */
|
||||
} esp_ble_mesh_sensor_series_status_cb_t;
|
||||
|
||||
/**
|
||||
* @brief Sensor Client Model received message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_sensor_descriptor_status_cb_t descriptor_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS */
|
||||
esp_ble_mesh_sensor_cadence_status_cb_t cadence_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_STATUS */
|
||||
esp_ble_mesh_sensor_settings_status_cb_t settings_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SETTINGS_STATUS */
|
||||
esp_ble_mesh_sensor_setting_status_cb_t setting_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_STATUS */
|
||||
esp_ble_mesh_sensor_status_cb_t sensor_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_STATUS */
|
||||
esp_ble_mesh_sensor_column_status_cb_t column_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_STATUS */
|
||||
esp_ble_mesh_sensor_series_status_cb_t series_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_STATUS */
|
||||
} esp_ble_mesh_sensor_client_status_cb_t;
|
||||
|
||||
/** Sensor Client Model callback parameters */
|
||||
typedef struct {
|
||||
int error_code; /*!< 0: success,
|
||||
* otherwise failure. For the error code values please refer to errno.h file.
|
||||
* A negative sign is added to the standard error codes in errno.h. */
|
||||
esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters. */
|
||||
esp_ble_mesh_sensor_client_status_cb_t status_cb; /*!< The sensor status message callback values */
|
||||
} esp_ble_mesh_sensor_client_cb_param_t;
|
||||
|
||||
/** This enum value is the event of Sensor Client Model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT,
|
||||
ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT,
|
||||
ESP_BLE_MESH_SENSOR_CLIENT_PUBLISH_EVT,
|
||||
ESP_BLE_MESH_SENSOR_CLIENT_TIMEOUT_EVT,
|
||||
ESP_BLE_MESH_SENSOR_CLIENT_EVT_MAX,
|
||||
} esp_ble_mesh_sensor_client_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth Mesh Sensor Client Model function.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Sensor Client Model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_sensor_client_cb_t)(esp_ble_mesh_sensor_client_cb_event_t event,
|
||||
esp_ble_mesh_sensor_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Sensor Client Model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_sensor_client_callback(esp_ble_mesh_sensor_client_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Get the value of Sensor Server Model states using the Sensor Client Model get messages.
|
||||
*
|
||||
* @note If you want to know the opcodes and corresponding meanings accepted by this API,
|
||||
* please refer to esp_ble_mesh_sensor_message_opcode_t in esp_ble_mesh_defs.h
|
||||
*
|
||||
* @param[in] params: Pointer to BLE Mesh common client parameters.
|
||||
* @param[in] get_state: Pointer to sensor get message value.
|
||||
* Shall not be set to NULL.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_sensor_client_get_state_t *get_state);
|
||||
|
||||
/**
|
||||
* @brief Set the value of Sensor Server Model states using the Sensor Client Model set messages.
|
||||
*
|
||||
* @note If you want to know the opcodes and corresponding meanings accepted by this API,
|
||||
* please refer to esp_ble_mesh_sensor_message_opcode_t in esp_ble_mesh_defs.h
|
||||
*
|
||||
* @param[in] params: Pointer to BLE Mesh common client parameters.
|
||||
* @param[in] set_state: Pointer to sensor set message value.
|
||||
* Shall not be set to NULL.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_sensor_client_set_state_t *set_state);
|
||||
|
||||
/**
|
||||
* @brief Sensor Server Models related context.
|
||||
*/
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_SENSOR_SRV
|
||||
*
|
||||
* @brief Define a new Sensor Server Model.
|
||||
*
|
||||
* @note 1. The Sensor Server model is a root model. When this model is present
|
||||
* on an element, the corresponding Sensor Setup Server model shall
|
||||
* also be present.
|
||||
* 2. This model shall support model publication and model subscription.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_sensor_srv_t.
|
||||
*
|
||||
* @return New Sensor Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_SENSOR_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SENSOR_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_SENSOR_SETUP_SRV
|
||||
*
|
||||
* @brief Define a new Sensor Setup Server Model.
|
||||
*
|
||||
* @note 1. The Sensor Setup Server model extends the Sensor Server model.
|
||||
* 2. This model shall support model publication and model subscription.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_sensor_setup_srv_t.
|
||||
*
|
||||
* @return New Sensor Setup Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_SENSOR_SETUP_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
#define ESP_BLE_MESH_INVALID_SENSOR_PROPERTY_ID 0x0000 /*!< Invalid Sensor Property ID */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_PROPERTY_ID_LEN 0x02 /*!< Length of Sensor Property ID */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_DESCRIPTOR_LEN 0x08 /*!< Length of Sensor Descriptor state */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_UNSPECIFIED_POS_TOLERANCE 0x000 /*!< Unspecified Sensor Positive Tolerance */
|
||||
#define ESP_BLE_MESH_SENSOR_UNSPECIFIED_NEG_TOLERANCE 0x000 /*!< Unspecified Sensor Negative Tolerance */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_NOT_APPL_MEASURE_PERIOD 0x00 /*!< Not applicable Sensor Measurement Period */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_NOT_APPL_UPDATE_INTERVAL 0x00 /*!< Not applicable Sensor Update Interval */
|
||||
|
||||
#define ESP_BLE_MESH_INVALID_SENSOR_SETTING_PROPERTY_ID 0x0000 /*!< Invalid Sensor Setting Property ID */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_SETTING_PROPERTY_ID_LEN 0x02 /*!< Length of Sensor Setting Property ID */
|
||||
#define ESP_BLE_MESH_SENSOR_SETTING_ACCESS_LEN 0x01 /*!< Length of Sensor Setting Access */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_SETTING_ACCESS_READ 0x01 /*!< Sensor Setting Access - Read */
|
||||
#define ESP_BLE_MESH_SENSOR_SETTING_ACCESS_READ_WRITE 0x03 /*!< Sensor Setting Access - Read & Write */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_DIVISOR_TRIGGER_TYPE_LEN 0x01 /*!< Length of Sensor Divisor Trigger Type */
|
||||
#define ESP_BLE_MESH_SENSOR_STATUS_MIN_INTERVAL_LEN 0x01 /*!< Length of Sensor Status Min Interval */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_PERIOD_DIVISOR_MAX_VALUE 15 /*!< Maximum value of Sensor Period Divisor */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_STATUS_MIN_INTERVAL_MAX 26 /*!< Maximum value of Sensor Status Min Interval */
|
||||
|
||||
/**
|
||||
* Sensor Status Trigger Type - Format Type of the characteristic
|
||||
* that the Sensor Property ID state references
|
||||
*/
|
||||
#define ESP_BLE_MESH_SENSOR_STATUS_TRIGGER_TYPE_CHAR 0
|
||||
/** Sensor Status Trigger Type - Format Type "uint16" */
|
||||
#define ESP_BLE_MESH_SENSOR_STATUS_TRIGGER_TYPE_UINT16 1
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_A 0x00 /*!< Sensor Data Format A */
|
||||
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_B 0x01 /*!< Sensor Data Format B */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_A_MPID_LEN 0x02 /*!< MPID length of Sensor Data Format A */
|
||||
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_B_MPID_LEN 0x03 /*!< MPID length of Sensor Data Format B */
|
||||
|
||||
/**
|
||||
* Zero length of Sensor Data.
|
||||
*
|
||||
* Note:
|
||||
* The Length field is a 1-based uint7 value (valid range 0x0–0x7F,
|
||||
* representing range of 1–127). The value 0x7F represents a length
|
||||
* of zero.
|
||||
*/
|
||||
#define ESP_BLE_MESH_SENSOR_DATA_ZERO_LEN 0x7F
|
||||
|
||||
/** @def ESP_BLE_MESH_GET_SENSOR_DATA_FORMAT
|
||||
*
|
||||
* @brief Get format of the sensor data.
|
||||
*
|
||||
* @note Multiple sensor data may be concatenated. Make sure the _data pointer is
|
||||
* updated before getting the format of the corresponding sensor data.
|
||||
*
|
||||
* @param _data Pointer to the start of the sensor data.
|
||||
*
|
||||
* @return Format of the sensor data.
|
||||
*/
|
||||
#define ESP_BLE_MESH_GET_SENSOR_DATA_FORMAT(_data) (((_data)[0]) & BIT_MASK(1))
|
||||
|
||||
/** @def ESP_BLE_MESH_GET_SENSOR_DATA_LENGTH
|
||||
*
|
||||
* @brief Get length of the sensor data.
|
||||
*
|
||||
* @note Multiple sensor data may be concatenated. Make sure the _data pointer is
|
||||
* updated before getting the length of the corresponding sensor data.
|
||||
*
|
||||
* @param _data Pointer to the start of the sensor data.
|
||||
* @param _fmt Format of the sensor data.
|
||||
*
|
||||
* @return Length (zero-based) of the sensor data.
|
||||
*/
|
||||
#define ESP_BLE_MESH_GET_SENSOR_DATA_LENGTH(_data, _fmt) \
|
||||
(((_fmt) == ESP_BLE_MESH_SENSOR_DATA_FORMAT_A) ? ((((_data)[0]) >> 1) & BIT_MASK(4)) : ((((_data)[0]) >> 1) & BIT_MASK(7)))
|
||||
|
||||
/** @def ESP_BLE_MESH_GET_SENSOR_DATA_PROPERTY_ID
|
||||
*
|
||||
* @brief Get Sensor Property ID of the sensor data.
|
||||
*
|
||||
* @note Multiple sensor data may be concatenated. Make sure the _data pointer is
|
||||
* updated before getting Sensor Property ID of the corresponding sensor data.
|
||||
*
|
||||
* @param _data Pointer to the start of the sensor data.
|
||||
* @param _fmt Format of the sensor data.
|
||||
*
|
||||
* @return Sensor Property ID of the sensor data.
|
||||
*/
|
||||
#define ESP_BLE_MESH_GET_SENSOR_DATA_PROPERTY_ID(_data, _fmt) \
|
||||
(((_fmt) == ESP_BLE_MESH_SENSOR_DATA_FORMAT_A) ? ((((_data)[1]) << 3) | (((_data)[0]) >> 5)) : ((((_data)[2]) << 8) | ((_data)[1])))
|
||||
|
||||
/** @def ESP_BLE_MESH_SENSOR_DATA_FORMAT_A_MPID
|
||||
*
|
||||
* @brief Generate a MPID value for sensor data with Format A.
|
||||
*
|
||||
* @note 1. The Format field is 0b0 and indicates that Format A is used.
|
||||
* 2. The Length field is a 1-based uint4 value (valid range 0x0–0xF,
|
||||
* representing range of 1–16).
|
||||
* 3. The Property ID is an 11-bit bit field representing 11 LSb of a Property ID.
|
||||
* 4. This format may be used for Property Values that are not longer than 16
|
||||
* octets and for Property IDs less than 0x0800.
|
||||
*
|
||||
* @param _len Length of Sensor Raw value.
|
||||
* @param _id Sensor Property ID.
|
||||
*
|
||||
* @return 2-octet MPID value for sensor data with Format A.
|
||||
*
|
||||
*/
|
||||
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_A_MPID(_len, _id) \
|
||||
((((_id) & BIT_MASK(11)) << 5) | (((_len) & BIT_MASK(4)) << 1) | ESP_BLE_MESH_SENSOR_DATA_FORMAT_A)
|
||||
|
||||
/** @def ESP_BLE_MESH_SENSOR_DATA_FORMAT_B_MPID
|
||||
*
|
||||
* @brief Generate a MPID value for sensor data with Format B.
|
||||
*
|
||||
* @note 1. The Format field is 0b1 and indicates Format B is used.
|
||||
* 2. The Length field is a 1-based uint7 value (valid range 0x0–0x7F, representing
|
||||
* range of 1–127). The value 0x7F represents a length of zero.
|
||||
* 3. The Property ID is a 16-bit bit field representing a Property ID.
|
||||
* 4. This format may be used for Property Values not longer than 128 octets and for
|
||||
* any Property IDs. Property values longer than 128 octets are not supported by
|
||||
* the Sensor Status message.
|
||||
* 5. Exclude the generated 1-octet value, the 2-octet Sensor Property ID
|
||||
*
|
||||
* @param _len Length of Sensor Raw value.
|
||||
* @param _id Sensor Property ID.
|
||||
*
|
||||
* @return 3-octet MPID value for sensor data with Format B.
|
||||
*
|
||||
*/
|
||||
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_B_MPID(_len, _id) \
|
||||
(((_id) << 8) | (((_len) & BIT_MASK(7)) << 1) | ESP_BLE_MESH_SENSOR_DATA_FORMAT_B)
|
||||
|
||||
/** This enum value is value of Sensor Sampling Function */
|
||||
enum esp_ble_mesh_sensor_sample_func {
|
||||
ESP_BLE_MESH_SAMPLE_FUNC_UNSPECIFIED,
|
||||
ESP_BLE_MESH_SAMPLE_FUNC_INSTANTANEOUS,
|
||||
ESP_BLE_MESH_SAMPLE_FUNC_ARITHMETIC_MEAN,
|
||||
ESP_BLE_MESH_SAMPLE_FUNC_RMS,
|
||||
ESP_BLE_MESH_SAMPLE_FUNC_MAXIMUM,
|
||||
ESP_BLE_MESH_SAMPLE_FUNC_MINIMUM,
|
||||
ESP_BLE_MESH_SAMPLE_FUNC_ACCUMULATED,
|
||||
ESP_BLE_MESH_SAMPLE_FUNC_COUNT,
|
||||
};
|
||||
|
||||
/** Parameters of Sensor Descriptor state */
|
||||
typedef struct {
|
||||
uint32_t positive_tolerance : 12, /*!< The value of Sensor Positive Tolerance field */
|
||||
negative_tolerance : 12, /*!< The value of Sensor Negative Tolerance field */
|
||||
sampling_function : 8; /*!< The value of Sensor Sampling Function field */
|
||||
uint8_t measure_period; /*!< The value of Sensor Measurement Period field */
|
||||
uint8_t update_interval; /*!< The value of Sensor Update Interval field */
|
||||
} esp_ble_mesh_sensor_descriptor_t;
|
||||
|
||||
/** Parameters of Sensor Setting state */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< The value of Sensor Setting Property ID field */
|
||||
uint8_t access; /*!< The value of Sensor Setting Access field */
|
||||
struct net_buf_simple *raw; /*!< The value of Sensor Setting Raw field */
|
||||
} esp_ble_mesh_sensor_setting_t;
|
||||
|
||||
/** Parameters of Sensor Cadence state */
|
||||
typedef struct {
|
||||
uint8_t period_divisor : 7, /*!< The value of Fast Cadence Period Divisor field */
|
||||
trigger_type : 1; /*!< The value of Status Trigger Type field */
|
||||
/**
|
||||
* Note:
|
||||
* The parameter "size" in trigger_delta_down, trigger_delta_up, fast_cadence_low &
|
||||
* fast_cadence_high indicates the exact length of these four parameters, and they
|
||||
* are associated with the Sensor Property ID. Users need to initialize the "size"
|
||||
* precisely.
|
||||
*/
|
||||
struct net_buf_simple *trigger_delta_down; /*!< The value of Status Trigger Delta Down field */
|
||||
struct net_buf_simple *trigger_delta_up; /*!< The value of Status Trigger Delta Up field */
|
||||
uint8_t min_interval; /*!< The value of Status Min Interval field */
|
||||
struct net_buf_simple *fast_cadence_low; /*!< The value of Fast Cadence Low field */
|
||||
struct net_buf_simple *fast_cadence_high; /*!< The value of Fast Cadence High field */
|
||||
} esp_ble_mesh_sensor_cadence_t;
|
||||
|
||||
/** Parameters of Sensor Data state */
|
||||
typedef struct {
|
||||
/**
|
||||
* Format A: The Length field is a 1-based uint4 value (valid range 0x0–0xF,
|
||||
* representing range of 1 – 16).
|
||||
* Format B: The Length field is a 1-based uint7 value (valid range 0x0–0x7F,
|
||||
* representing range of 1 – 127). The value 0x7F represents a
|
||||
* length of zero.
|
||||
*/
|
||||
uint8_t format : 1, /*!< The value of the Sensor Data format */
|
||||
length : 7; /*!< The value of the Sensor Data length */
|
||||
struct net_buf_simple *raw_value; /*!< The value of Sensor Data raw value */
|
||||
} esp_ble_mesh_sensor_data_t;
|
||||
|
||||
/** Parameters of Sensor Series Column state */
|
||||
typedef struct {
|
||||
struct net_buf_simple *raw_value_x; /*!< The value of Sensor Raw Value X field */
|
||||
struct net_buf_simple *column_width; /*!< The value of Sensor Column Width field */
|
||||
struct net_buf_simple *raw_value_y; /*!< The value of Sensor Raw Value Y field */
|
||||
} esp_ble_mesh_sensor_series_column_t;
|
||||
|
||||
/** Parameters of Sensor states */
|
||||
typedef struct {
|
||||
uint16_t sensor_property_id; /*!< The value of Sensor Property ID field */
|
||||
|
||||
/* Constant throughout the lifetime of an element */
|
||||
esp_ble_mesh_sensor_descriptor_t descriptor; /*!< Parameters of the Sensor Descriptor state */
|
||||
|
||||
/**
|
||||
* Multiple Sensor Setting states may be present for each sensor.
|
||||
* The Sensor Setting Property ID values shall be unique for each
|
||||
* Sensor Property ID that identifies a sensor within an element.
|
||||
*/
|
||||
const uint8_t setting_count; /*!< */
|
||||
esp_ble_mesh_sensor_setting_t *settings; /*!< Parameters of the Sensor Setting state */
|
||||
|
||||
/**
|
||||
* The Sensor Cadence state may be not supported by sensors based
|
||||
* on device properties referencing "non-scalar characteristics"
|
||||
* such as "histograms" or "composite characteristics".
|
||||
*/
|
||||
esp_ble_mesh_sensor_cadence_t *cadence; /*!< Parameters of the Sensor Cadence state */
|
||||
|
||||
esp_ble_mesh_sensor_data_t sensor_data; /*!< Parameters of the Sensor Data state */
|
||||
|
||||
esp_ble_mesh_sensor_series_column_t series_column; /*!< Parameters of the Sensor Series Column state */
|
||||
} esp_ble_mesh_sensor_state_t;
|
||||
|
||||
/** User data of Sensor Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Sensor Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
const uint8_t state_count; /*!< Sensor state count */
|
||||
esp_ble_mesh_sensor_state_t *states; /*!< Parameters of the Sensor states */
|
||||
} esp_ble_mesh_sensor_srv_t;
|
||||
|
||||
/** User data of Sensor Setup Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Sensor Setup Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
const uint8_t state_count; /*!< Sensor state count */
|
||||
esp_ble_mesh_sensor_state_t *states; /*!< Parameters of the Sensor states */
|
||||
} esp_ble_mesh_sensor_setup_srv_t;
|
||||
|
||||
/** Parameters of Sensor Cadence Set state change event */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< The value of Sensor Property ID state */
|
||||
uint8_t period_divisor : 7, /*!< The value of Fast Cadence Period Divisor state */
|
||||
trigger_type : 1; /*!< The value of Status Trigger Type state */
|
||||
struct net_buf_simple *trigger_delta_down; /*!< The value of Status Trigger Delta Down state */
|
||||
struct net_buf_simple *trigger_delta_up; /*!< The value of Status Trigger Delta Up state */
|
||||
uint8_t min_interval; /*!< The value of Status Min Interval state */
|
||||
struct net_buf_simple *fast_cadence_low; /*!< The value of Fast Cadence Low state */
|
||||
struct net_buf_simple *fast_cadence_high; /*!< The value of Fast Cadence High state */
|
||||
} esp_ble_mesh_state_change_sensor_cadence_set_t;
|
||||
|
||||
/** Parameters of Sensor Setting Set state change event */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< The value of Sensor Property ID state */
|
||||
uint16_t setting_property_id; /*!< The value of Sensor Setting Property ID state */
|
||||
struct net_buf_simple *setting_value; /*!< The value of Sensor Property Value state */
|
||||
} esp_ble_mesh_state_change_sensor_setting_set_t;
|
||||
|
||||
/**
|
||||
* @brief Sensor Server Model state change value union
|
||||
*/
|
||||
typedef union {
|
||||
/**
|
||||
* The recv_op in ctx can be used to decide which state is changed.
|
||||
*/
|
||||
esp_ble_mesh_state_change_sensor_cadence_set_t sensor_cadence_set; /*!< Sensor Cadence Set */
|
||||
esp_ble_mesh_state_change_sensor_setting_set_t sensor_setting_set; /*!< Sensor Setting Set */
|
||||
} esp_ble_mesh_sensor_server_state_change_t;
|
||||
|
||||
/** Context of the received Sensor Descriptor Get message */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
uint16_t property_id; /*!< Property ID of a sensor (optional) */
|
||||
} esp_ble_mesh_server_recv_sensor_descriptor_get_t;
|
||||
|
||||
/** Context of the received Sensor Cadence Get message */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property ID of a sensor */
|
||||
} esp_ble_mesh_server_recv_sensor_cadence_get_t;
|
||||
|
||||
/** Context of the received Sensor Settings Get message */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property ID of a sensor */
|
||||
} esp_ble_mesh_server_recv_sensor_settings_get_t;
|
||||
|
||||
/** Context of the received Sensor Setting Get message */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property ID of a sensor */
|
||||
uint16_t setting_property_id; /*!< Setting ID identifying a setting within a sensor */
|
||||
} esp_ble_mesh_server_recv_sensor_setting_get_t;
|
||||
|
||||
/** Context of the received Sensor Get message */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
uint16_t property_id; /*!< Property ID for the sensor (optional) */
|
||||
} esp_ble_mesh_server_recv_sensor_get_t;
|
||||
|
||||
/** Context of the received Sensor Column Get message */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property identifying a sensor */
|
||||
struct net_buf_simple *raw_value_x; /*!< Raw value identifying a column */
|
||||
} esp_ble_mesh_server_recv_sensor_column_get_t;
|
||||
|
||||
/** Context of the received Sensor Series Get message */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
uint16_t property_id; /*!< Property identifying a sensor */
|
||||
struct net_buf_simple *raw_value; /*!< Raw value containing X1 and X2 (optional) */
|
||||
} esp_ble_mesh_server_recv_sensor_series_get_t;
|
||||
|
||||
/**
|
||||
* @brief Sensor Server Model received get message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_server_recv_sensor_descriptor_get_t sensor_descriptor; /*!< Sensor Descriptor Get */
|
||||
esp_ble_mesh_server_recv_sensor_cadence_get_t sensor_cadence; /*!< Sensor Cadence Get */
|
||||
esp_ble_mesh_server_recv_sensor_settings_get_t sensor_settings; /*!< Sensor Settings Get */
|
||||
esp_ble_mesh_server_recv_sensor_setting_get_t sensor_setting; /*!< Sensor Setting Get */
|
||||
esp_ble_mesh_server_recv_sensor_get_t sensor_data; /*!< Sensor Get */
|
||||
esp_ble_mesh_server_recv_sensor_column_get_t sensor_column; /*!< Sensor Column Get */
|
||||
esp_ble_mesh_server_recv_sensor_series_get_t sensor_series; /*!< Sensor Series Get */
|
||||
} esp_ble_mesh_sensor_server_recv_get_msg_t;
|
||||
|
||||
/** Context of the received Sensor Cadence Set message */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property ID for the sensor */
|
||||
struct net_buf_simple *cadence; /*!< Value of Sensor Cadence state */
|
||||
} esp_ble_mesh_server_recv_sensor_cadence_set_t;
|
||||
|
||||
/** Context of the received Sensor Setting Set message */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property ID identifying a sensor */
|
||||
uint16_t setting_property_id; /*!< Setting ID identifying a setting within a sensor */
|
||||
struct net_buf_simple *setting_raw; /*!< Raw value for the setting */
|
||||
} esp_ble_mesh_server_recv_sensor_setting_set_t;
|
||||
|
||||
/**
|
||||
* @brief Sensor Server Model received set message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_server_recv_sensor_cadence_set_t sensor_cadence; /*!< Sensor Cadence Set */
|
||||
esp_ble_mesh_server_recv_sensor_setting_set_t sensor_setting; /*!< Sensor Setting Set */
|
||||
} esp_ble_mesh_sensor_server_recv_set_msg_t;
|
||||
|
||||
/**
|
||||
* @brief Sensor Server Model callback value union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_sensor_server_state_change_t state_change; /*!< ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT */
|
||||
esp_ble_mesh_sensor_server_recv_get_msg_t get; /*!< ESP_BLE_MESH_SENSOR_SERVER_RECV_GET_MSG_EVT */
|
||||
esp_ble_mesh_sensor_server_recv_set_msg_t set; /*!< ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT */
|
||||
} esp_ble_mesh_sensor_server_cb_value_t;
|
||||
|
||||
/** Sensor Server Model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to Sensor Server Models */
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received messages */
|
||||
esp_ble_mesh_sensor_server_cb_value_t value; /*!< Value of the received Sensor Messages */
|
||||
} esp_ble_mesh_sensor_server_cb_param_t;
|
||||
|
||||
/** This enum value is the event of Sensor Server Model */
|
||||
typedef enum {
|
||||
/**
|
||||
* 1. When get_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, no event will be
|
||||
* callback to the application layer when Sensor Get messages are received.
|
||||
* 2. When set_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, this event will
|
||||
* be callback to the application layer when Sensor Set/Set Unack messages
|
||||
* are received.
|
||||
*/
|
||||
ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT,
|
||||
/**
|
||||
* When get_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
|
||||
* callback to the application layer when Sensor Get messages are received.
|
||||
*/
|
||||
ESP_BLE_MESH_SENSOR_SERVER_RECV_GET_MSG_EVT,
|
||||
/**
|
||||
* When set_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
|
||||
* callback to the application layer when Sensor Set/Set Unack messages are received.
|
||||
*/
|
||||
ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT,
|
||||
ESP_BLE_MESH_SENSOR_SERVER_EVT_MAX,
|
||||
} esp_ble_mesh_sensor_server_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth Mesh Sensor Server Model function.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Sensor Server Model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_sensor_server_cb_t)(esp_ble_mesh_sensor_server_cb_event_t event,
|
||||
esp_ble_mesh_sensor_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Sensor Server Model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_sensor_server_callback(esp_ble_mesh_sensor_server_cb_t callback);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_SENSOR_MODEL_API_H_ */
|
@ -0,0 +1,911 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/** @file
|
||||
* @brief Bluetooth Mesh Time and Scene Client Model APIs.
|
||||
*/
|
||||
|
||||
#ifndef _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_
|
||||
#define _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_TIME_CLI
|
||||
*
|
||||
* @brief Define a new Time Client Model.
|
||||
*
|
||||
* @note This API needs to be called for each element on which
|
||||
* the application needs to have a Time Client Model.
|
||||
*
|
||||
* @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
|
||||
*
|
||||
* @return New Time Client Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_TIME_CLI(cli_pub, cli_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_TIME_CLI, \
|
||||
NULL, cli_pub, cli_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_SCENE_CLI
|
||||
*
|
||||
* @brief Define a new Scene Client Model.
|
||||
*
|
||||
* @note This API needs to be called for each element on which
|
||||
* the application needs to have a Scene Client Model.
|
||||
*
|
||||
* @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
|
||||
*
|
||||
* @return New Scene Client Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_SCENE_CLI(cli_pub, cli_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCENE_CLI, \
|
||||
NULL, cli_pub, cli_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_SCHEDULER_CLI
|
||||
*
|
||||
* @brief Define a new Scheduler Client Model.
|
||||
*
|
||||
* @note This API needs to be called for each element on which
|
||||
* the application needs to have a Scheduler Client Model.
|
||||
*
|
||||
* @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param cli_data Pointer to the unique struct esp_ble_mesh_client_t.
|
||||
*
|
||||
* @return New Scheduler Client Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_SCHEDULER_CLI(cli_pub, cli_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCHEDULER_CLI, \
|
||||
NULL, cli_pub, cli_data)
|
||||
|
||||
/**
|
||||
* @brief Bluetooth Mesh Time Scene Client Model Get and Set parameters structure.
|
||||
*/
|
||||
|
||||
/** Parameters of Time Set */
|
||||
typedef struct {
|
||||
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
|
||||
uint8_t sub_second; /*!< The sub-second time in units of 1/256 second */
|
||||
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
|
||||
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
|
||||
uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
|
||||
uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
|
||||
} esp_ble_mesh_time_set_t;
|
||||
|
||||
/** Parameters of Time Zone Set */
|
||||
typedef struct {
|
||||
uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
|
||||
uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
|
||||
} esp_ble_mesh_time_zone_set_t;
|
||||
|
||||
/** Parameters of TAI-UTC Delta Set */
|
||||
typedef struct {
|
||||
uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
|
||||
uint16_t padding : 1; /*!< Always 0b0. Other values are Prohibited. */
|
||||
uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
|
||||
} esp_ble_mesh_tai_utc_delta_set_t;
|
||||
|
||||
/** Parameter of Time Role Set */
|
||||
typedef struct {
|
||||
uint8_t time_role; /*!< The Time Role for the element */
|
||||
} esp_ble_mesh_time_role_set_t;
|
||||
|
||||
/** Parameter of Scene Store */
|
||||
typedef struct {
|
||||
uint16_t scene_number; /*!< The number of scenes to be stored */
|
||||
} esp_ble_mesh_scene_store_t;
|
||||
|
||||
/** Parameters of Scene Recall */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
uint16_t scene_number; /*!< The number of scenes to be recalled */
|
||||
uint8_t tid; /*!< Transaction ID */
|
||||
uint8_t trans_time; /*!< Time to complete state transition (optional) */
|
||||
uint8_t delay; /*!< Indicate message execution delay (C.1) */
|
||||
} esp_ble_mesh_scene_recall_t;
|
||||
|
||||
/** Parameter of Scene Delete */
|
||||
typedef struct {
|
||||
uint16_t scene_number; /*!< The number of scenes to be deleted */
|
||||
} esp_ble_mesh_scene_delete_t;
|
||||
|
||||
/** Parameter of Scheduler Action Get */
|
||||
typedef struct {
|
||||
uint8_t index; /*!< Index of the Schedule Register entry to get */
|
||||
} esp_ble_mesh_scheduler_act_get_t;
|
||||
|
||||
/** Parameters of Scheduler Action Set */
|
||||
typedef struct {
|
||||
uint64_t index : 4; /*!< Index of the Schedule Register entry to set */
|
||||
uint64_t year : 7; /*!< Scheduled year for the action */
|
||||
uint64_t month : 12; /*!< Scheduled month for the action */
|
||||
uint64_t day : 5; /*!< Scheduled day of the month for the action */
|
||||
uint64_t hour : 5; /*!< Scheduled hour for the action */
|
||||
uint64_t minute : 6; /*!< Scheduled minute for the action */
|
||||
uint64_t second : 6; /*!< Scheduled second for the action */
|
||||
uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
|
||||
uint64_t action : 4; /*!< Action to be performed at the scheduled time */
|
||||
uint64_t trans_time : 8; /*!< Transition time for this action */
|
||||
uint16_t scene_number; /*!< Transition time for this action */
|
||||
} esp_ble_mesh_scheduler_act_set_t;
|
||||
|
||||
/**
|
||||
* @brief Time Scene Client Model get message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_scheduler_act_get_t scheduler_act_get; /*!< For ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET */
|
||||
} esp_ble_mesh_time_scene_client_get_state_t;
|
||||
|
||||
/**
|
||||
* @brief Time Scene Client Model set message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_time_set_t time_set; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_SET */
|
||||
esp_ble_mesh_time_zone_set_t time_zone_set; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_ZONE_SET */
|
||||
esp_ble_mesh_tai_utc_delta_set_t tai_utc_delta_set; /*!< For ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_SET */
|
||||
esp_ble_mesh_time_role_set_t time_role_set; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_ROLE_SET */
|
||||
esp_ble_mesh_scene_store_t scene_store; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_STORE & ESP_BLE_MESH_MODEL_OP_SCENE_STORE_UNACK */
|
||||
esp_ble_mesh_scene_recall_t scene_recall; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_RECALL & ESP_BLE_MESH_MODEL_OP_SCENE_RECALL_UNACK */
|
||||
esp_ble_mesh_scene_delete_t scene_delete; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_DELETE & ESP_BLE_MESH_MODEL_OP_SCENE_DELETE_UNACK */
|
||||
esp_ble_mesh_scheduler_act_set_t scheduler_act_set; /*!< For ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET & ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET_UNACK */
|
||||
} esp_ble_mesh_time_scene_client_set_state_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth Mesh Time Scene Client Model Get and Set callback parameters structure.
|
||||
*/
|
||||
|
||||
/** Parameters of Time Status */
|
||||
typedef struct {
|
||||
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
|
||||
uint8_t sub_second; /*!< The sub-second time in units of 1/256 second */
|
||||
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
|
||||
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
|
||||
uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
|
||||
uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
|
||||
} esp_ble_mesh_time_status_cb_t;
|
||||
|
||||
/** Parameters of Time Zone Status */
|
||||
typedef struct {
|
||||
uint8_t time_zone_offset_curr; /*!< Current local time zone offset */
|
||||
uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
|
||||
uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
|
||||
} esp_ble_mesh_time_zone_status_cb_t;
|
||||
|
||||
/** Parameters of TAI-UTC Delta Status */
|
||||
typedef struct {
|
||||
uint16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */
|
||||
uint16_t padding_1 : 1; /*!< Always 0b0. Other values are Prohibited. */
|
||||
uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
|
||||
uint16_t padding_2 : 1; /*!< Always 0b0. Other values are Prohibited. */
|
||||
uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
|
||||
} esp_ble_mesh_tai_utc_delta_status_cb_t;
|
||||
|
||||
/** Parameter of Time Role Status */
|
||||
typedef struct {
|
||||
uint8_t time_role; /*!< The Time Role for the element */
|
||||
} esp_ble_mesh_time_role_status_cb_t;
|
||||
|
||||
/** Parameters of Scene Status */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
uint8_t status_code; /*!< Status code of the last operation */
|
||||
uint16_t current_scene; /*!< Scene Number of the current scene */
|
||||
uint16_t target_scene; /*!< Scene Number of the target scene (optional) */
|
||||
uint8_t remain_time; /*!< Time to complete state transition (C.1) */
|
||||
} esp_ble_mesh_scene_status_cb_t;
|
||||
|
||||
/** Parameters of Scene Register Status */
|
||||
typedef struct {
|
||||
uint8_t status_code; /*!< Status code for the previous operation */
|
||||
uint16_t current_scene; /*!< Scene Number of the current scene */
|
||||
struct net_buf_simple *scenes; /*!< A list of scenes stored within an element */
|
||||
} esp_ble_mesh_scene_register_status_cb_t;
|
||||
|
||||
/** Parameter of Scheduler Status */
|
||||
typedef struct {
|
||||
uint16_t schedules; /*!< Bit field indicating defined Actions in the Schedule Register */
|
||||
} esp_ble_mesh_scheduler_status_cb_t;
|
||||
|
||||
/** Parameters of Scheduler Action Status */
|
||||
typedef struct {
|
||||
uint64_t index : 4; /*!< Enumerates (selects) a Schedule Register entry */
|
||||
uint64_t year : 7; /*!< Scheduled year for the action */
|
||||
uint64_t month : 12; /*!< Scheduled month for the action */
|
||||
uint64_t day : 5; /*!< Scheduled day of the month for the action */
|
||||
uint64_t hour : 5; /*!< Scheduled hour for the action */
|
||||
uint64_t minute : 6; /*!< Scheduled minute for the action */
|
||||
uint64_t second : 6; /*!< Scheduled second for the action */
|
||||
uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
|
||||
uint64_t action : 4; /*!< Action to be performed at the scheduled time */
|
||||
uint64_t trans_time : 8; /*!< Transition time for this action */
|
||||
uint16_t scene_number; /*!< Transition time for this action */
|
||||
} esp_ble_mesh_scheduler_act_status_cb_t;
|
||||
|
||||
/**
|
||||
* @brief Time Scene Client Model received message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_time_status_cb_t time_status; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_STATUS */
|
||||
esp_ble_mesh_time_zone_status_cb_t time_zone_status; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_ZONE_STATUS */
|
||||
esp_ble_mesh_tai_utc_delta_status_cb_t tai_utc_delta_status; /*!< For ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_STATUS */
|
||||
esp_ble_mesh_time_role_status_cb_t time_role_status; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_ROLE_STATUS */
|
||||
esp_ble_mesh_scene_status_cb_t scene_status; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_STATUS */
|
||||
esp_ble_mesh_scene_register_status_cb_t scene_register_status; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_STATUS */
|
||||
esp_ble_mesh_scheduler_status_cb_t scheduler_status; /*!< For ESP_BLE_MESH_MODEL_OP_SCHEDULER_STATUS */
|
||||
esp_ble_mesh_scheduler_act_status_cb_t scheduler_act_status; /*!< For ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_STATUS */
|
||||
} esp_ble_mesh_time_scene_client_status_cb_t;
|
||||
|
||||
/** Time Scene Client Model callback parameters */
|
||||
typedef struct {
|
||||
int error_code; /*!< Appropriate error code */
|
||||
esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters. */
|
||||
esp_ble_mesh_time_scene_client_status_cb_t status_cb; /*!< The scene status message callback values */
|
||||
} esp_ble_mesh_time_scene_client_cb_param_t;
|
||||
|
||||
/** This enum value is the event of Time Scene Client Model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT,
|
||||
ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT,
|
||||
ESP_BLE_MESH_TIME_SCENE_CLIENT_PUBLISH_EVT,
|
||||
ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT,
|
||||
ESP_BLE_MESH_TIME_SCENE_CLIENT_EVT_MAX,
|
||||
} esp_ble_mesh_time_scene_client_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth Mesh Time Scene Client Model function.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Time Scene Client Model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_time_scene_client_cb_t)(esp_ble_mesh_time_scene_client_cb_event_t event,
|
||||
esp_ble_mesh_time_scene_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Time Scene Client Model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_time_scene_client_callback(esp_ble_mesh_time_scene_client_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Get the value of Time Scene Server Model states using the Time Scene Client Model get messages.
|
||||
*
|
||||
* @note If you want to know the opcodes and corresponding meanings accepted by this API,
|
||||
* please refer to esp_ble_mesh_time_scene_message_opcode_t in esp_ble_mesh_defs.h
|
||||
*
|
||||
* @param[in] params: Pointer to BLE Mesh common client parameters.
|
||||
* @param[in] get_state: Pointer to time scene get message value.
|
||||
* Shall not be set to NULL.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_time_scene_client_get_state_t *get_state);
|
||||
|
||||
/**
|
||||
* @brief Set the value of Time Scene Server Model states using the Time Scene Client Model set messages.
|
||||
*
|
||||
* @note If you want to know the opcodes and corresponding meanings accepted by this API,
|
||||
* please refer to esp_ble_mesh_time_scene_message_opcode_t in esp_ble_mesh_defs.h
|
||||
*
|
||||
* @param[in] params: Pointer to BLE Mesh common client parameters.
|
||||
* @param[in] set_state: Pointer to time scene set message value.
|
||||
* Shall not be set to NULL.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_time_scene_client_set_state_t *set_state);
|
||||
|
||||
/**
|
||||
* @brief Time Scene Server Models related context.
|
||||
*/
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_TIME_SRV
|
||||
*
|
||||
* @brief Define a new Time Server Model.
|
||||
*
|
||||
* @note 1. The Time Server model is a root model. When this model is present on an
|
||||
* Element, the corresponding Time Setup Server model shall also be present.
|
||||
* 2. This model shall support model publication and model subscription.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_time_srv_t.
|
||||
*
|
||||
* @return New Time Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_TIME_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_TIME_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_TIME_SETUP_SRV
|
||||
*
|
||||
* @brief Define a new Time Setup Server Model.
|
||||
*
|
||||
* @note 1. The Time Setup Server model extends the Time Server model. Time is
|
||||
* sensitive information that is propagated across a mesh network.
|
||||
* 2. Only an authorized Time Client should be allowed to change the Time
|
||||
* and Time Role states. A dedicated application key Bluetooth SIG
|
||||
* Proprietary should be used on the Time Setup Server to restrict
|
||||
* access to the server to only authorized Time Clients.
|
||||
* 3. This model does not support subscribing nor publishing.
|
||||
*
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_time_setup_srv_t.
|
||||
*
|
||||
* @return New Time Setup Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_TIME_SETUP_SRV(srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_TIME_SETUP_SRV, \
|
||||
NULL, NULL, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_SCENE_SRV
|
||||
*
|
||||
* @brief Define a new Scene Server Model.
|
||||
*
|
||||
* @note 1. The Scene Server model is a root model. When this model is present
|
||||
* on an Element, the corresponding Scene Setup Server model shall
|
||||
* also be present.
|
||||
* 2. This model shall support model publication and model subscription.
|
||||
* 3. The model may be present only on the Primary element of a node.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_scene_srv_t.
|
||||
*
|
||||
* @return New Scene Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_SCENE_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCENE_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_SCENE_SETUP_SRV
|
||||
*
|
||||
* @brief Define a new Scene Setup Server Model.
|
||||
*
|
||||
* @note 1. The Scene Setup Server model extends the Scene Server model and
|
||||
* the Generic Default Transition Time Server model.
|
||||
* 2. This model shall support model subscription.
|
||||
* 3. The model may be present only on the Primary element of a node.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_scene_setup_srv_t.
|
||||
*
|
||||
* @return New Scene Setup Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_SCENE_SETUP_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCENE_SETUP_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_SCHEDULER_SRV
|
||||
*
|
||||
* @brief Define a new Scheduler Server Model.
|
||||
*
|
||||
* @note 1. The Scheduler Server model extends the Scene Server model. When
|
||||
* this model is present on an Element, the corresponding Scheduler
|
||||
* Setup Server model shall also be present.
|
||||
* 2. This model shall support model publication and model subscription.
|
||||
* 3. The model may be present only on the Primary element of a node.
|
||||
* 4. The model requires the Time Server model shall be present on the element.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_scheduler_srv_t.
|
||||
*
|
||||
* @return New Scheduler Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_SCHEDULER_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCHEDULER_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_SCHEDULER_SETUP_SRV
|
||||
*
|
||||
* @brief Define a new Scheduler Setup Server Model.
|
||||
*
|
||||
* @note 1. The Scheduler Setup Server model extends the Scheduler Server and
|
||||
* the Scene Setup Server models.
|
||||
* 2. This model shall support model subscription.
|
||||
* 3. The model may be present only on the Primary element of a node.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_scheduler_setup_srv_t.
|
||||
*
|
||||
* @return New Scheduler Setup Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_SCHEDULER_SETUP_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
#define ESP_BLE_MESH_UNKNOWN_TAI_SECONDS 0x0000000000 /*!< Unknown TAI Seconds */
|
||||
#define ESP_BLE_MESH_UNKNOWN_TAI_ZONE_CHANGE 0x0000000000 /*!< Unknown TAI of Zone Change */
|
||||
#define ESP_BLE_MESH_UNKNOWN_TAI_DELTA_CHANGE 0x0000000000 /*!< Unknown TAI of Delta Change */
|
||||
|
||||
#define ESP_BLE_MESH_TAI_UTC_DELTA_MAX_VALUE 0x7FFF /*!< Maximum TAI-UTC Delta value */
|
||||
|
||||
#define ESP_BLE_MESH_TAI_SECONDS_LEN 0x05 /*!< Length of TAI Seconds */
|
||||
#define ESP_BLE_MESH_TAI_OF_ZONE_CHANGE_LEN 0x05 /*!< Length of TAI of Zone Change */
|
||||
#define ESP_BLE_MESH_TAI_OF_DELTA_CHANGE_LEN 0x05 /*!< Length of TAI of Delta Change */
|
||||
|
||||
#define ESP_BLE_MESH_INVALID_SCENE_NUMBER 0x0000 /*!< Invalid Scene Number */
|
||||
#define ESP_BLE_MESH_SCENE_NUMBER_LEN 0x02 /*!< Length of the Scene Number */
|
||||
|
||||
#define ESP_BLE_MESH_SCHEDULE_YEAR_ANY_YEAR 0x64 /*!< Any year of the Scheduled year */
|
||||
|
||||
#define ESP_BLE_MESH_SCHEDULE_DAY_ANY_DAY 0x00 /*!< Any day of the Scheduled day */
|
||||
|
||||
#define ESP_BLE_MESH_SCHEDULE_HOUR_ANY_HOUR 0x18 /*!< Any hour of the Scheduled hour */
|
||||
#define ESP_BLE_MESH_SCHEDULE_HOUR_ONCE_A_DAY 0x19 /*!< Any hour of the Scheduled Day */
|
||||
|
||||
#define ESP_BLE_MESH_SCHEDULE_SEC_ANY_OF_HOUR 0x3C /*!< Any minute of the Scheduled hour */
|
||||
#define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_15_MIN 0x3D /*!< Every 15 minutes of the Scheduled hour */
|
||||
#define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_20_MIN 0x3E /*!< Every 20 minutes of the Scheduled hour */
|
||||
#define ESP_BLE_MESH_SCHEDULE_SEC_ONCE_AN_HOUR 0x3F /*!< Once of the Scheduled hour */
|
||||
|
||||
#define ESP_BLE_MESH_SCHEDULE_SEC_ANY_OF_MIN 0x3C /*!< Any second of the Scheduled minute */
|
||||
#define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_15_SEC 0x3D /*!< Every 15 seconds of the Scheduled minute */
|
||||
#define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_20_SEC 0x3E /*!< Every 20 seconds of the Scheduled minute */
|
||||
#define ESP_BLE_MESH_SCHEDULE_SEC_ONCE_AN_MIN 0x3F /*!< Once of the Scheduled minute */
|
||||
|
||||
#define ESP_BLE_MESH_SCHEDULE_ACT_TURN_OFF 0x00 /*!< Scheduled Action - Turn Off */
|
||||
#define ESP_BLE_MESH_SCHEDULE_ACT_TURN_ON 0x01 /*!< Scheduled Action - Turn On */
|
||||
#define ESP_BLE_MESH_SCHEDULE_ACT_SCENE_RECALL 0x02 /*!< Scheduled Action - Scene Recall */
|
||||
#define ESP_BLE_MESH_SCHEDULE_ACT_NO_ACTION 0x0F /*!< Scheduled Action - No Action */
|
||||
|
||||
#define ESP_BLE_MESH_SCHEDULE_SCENE_NO_SCENE 0x0000 /*!< Scheduled Scene - No Scene */
|
||||
|
||||
#define ESP_BLE_MESH_SCHEDULE_ENTRY_MAX_INDEX 0x0F /*!< Maximum number of Scheduled entries */
|
||||
|
||||
#define ESP_BLE_MESH_TIME_NONE 0x00 /*!< Time Role - None */
|
||||
#define ESP_BLE_MESH_TIME_AUTHORITY 0x01 /*!< Time Role - Mesh Time Authority */
|
||||
#define ESP_BLE_MESH_TIME_RELAY 0x02 /*!< Time Role - Mesh Time Relay */
|
||||
#define ESP_BLE_MESH_TIME_CLINET 0x03 /*!< Time Role - Mesh Time Client */
|
||||
|
||||
#define ESP_BLE_MESH_SCENE_SUCCESS 0x00 /*!< Scene operation - Success */
|
||||
#define ESP_BLE_MESH_SCENE_REG_FULL 0x01 /*!< Scene operation - Scene Register Full */
|
||||
#define ESP_BLE_MESH_SCENE_NOT_FOUND 0x02 /*!< Scene operation - Scene Not Found */
|
||||
|
||||
/** Parameters of Time state */
|
||||
typedef struct {
|
||||
struct {
|
||||
uint8_t tai_seconds[5]; /*!< The value of the TAI Seconds state */
|
||||
uint8_t subsecond; /*!< The value of the Subsecond field */
|
||||
uint8_t uncertainty; /*!< The value of the Uncertainty field */
|
||||
uint8_t time_zone_offset_curr; /*!< The value of the Time Zone Offset Current field */
|
||||
uint8_t time_zone_offset_new; /*!< The value of the Time Zone Offset New state */
|
||||
uint8_t tai_zone_change[5]; /*!< The value of the TAI of Zone Chaneg field */
|
||||
uint16_t time_authority : 1, /*!< The value of the Time Authority bit */
|
||||
tai_utc_delta_curr : 15; /*!< The value of the TAI-UTC Delta Current state */
|
||||
uint16_t tai_utc_delta_new : 15; /*!< The value of the TAI-UTC Delta New state */
|
||||
uint8_t tai_delta_change[5]; /*!< The value of the TAI of Delta Change field */
|
||||
} time; /*!< Parameters of the Time state */
|
||||
uint8_t time_role; /*!< The value of the Time Role state */
|
||||
} esp_ble_mesh_time_state_t;
|
||||
|
||||
/** User data of Time Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Time Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_time_state_t *state; /*!< Parameters of the Time state */
|
||||
} esp_ble_mesh_time_srv_t;
|
||||
|
||||
/** User data of Time Setup Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Time Setup Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_time_state_t *state; /*!< Parameters of the Time state */
|
||||
} esp_ble_mesh_time_setup_srv_t;
|
||||
|
||||
/**
|
||||
* 1. Scene Store is an operation of storing values of a present state of an element.
|
||||
* 2. The structure and meaning of the stored state is determined by a model. States
|
||||
* to be stored are specified by each model.
|
||||
* 3. The Scene Store operation shall persistently store all values of all states
|
||||
* marked as Stored with Scene for all models present on all elements of a node.
|
||||
* 4. If a model is extending another model, the extending model shall determine the
|
||||
* Stored with Scene behavior of that model.
|
||||
*/
|
||||
|
||||
/** Parameters of Scene Register state */
|
||||
typedef struct {
|
||||
uint16_t scene_number; /*!< The value of the Scene Number */
|
||||
uint8_t scene_type; /*!< The value of the Scene Type */
|
||||
/**
|
||||
* Scene value may use a union to represent later, the union contains
|
||||
* structures of all the model states which can be stored in a scene.
|
||||
*/
|
||||
struct net_buf_simple *scene_value; /*!< The value of the Scene Value */
|
||||
} esp_ble_mesh_scene_register_t;
|
||||
|
||||
/**
|
||||
* Parameters of Scenes state.
|
||||
*
|
||||
* Scenes serve as memory banks for storage of states (e.g., a power level
|
||||
* or a light level/color). Values of states of an element can be stored
|
||||
* as a scene and can be recalled later from the scene memory.
|
||||
*
|
||||
* A scene is represented by a Scene Number, which is a 16-bit non-zero,
|
||||
* mesh-wide value. (There can be a maximum of 65535 scenes in a mesh
|
||||
* network.) The meaning of a scene, as well as the state storage container
|
||||
* associated with it, are determined by a model.
|
||||
*
|
||||
* The Scenes state change may start numerous parallel model transitions.
|
||||
* In that case, each individual model handles the transition internally.
|
||||
*
|
||||
* The scene transition is defined as a group of individual model transitions
|
||||
* started by a Scene Recall operation. The scene transition is in progress
|
||||
* when at least one transition from the group of individual model transitions
|
||||
* is in progress.
|
||||
*/
|
||||
typedef struct {
|
||||
const uint16_t scene_count; /*!< The Scenes state's scene count */
|
||||
esp_ble_mesh_scene_register_t *scenes; /*!< Parameters of the Scenes state */
|
||||
|
||||
/**
|
||||
* The Current Scene state is a 16-bit value that contains either the Scene
|
||||
* Number of the currently active scene or a value of 0x0000 when no scene
|
||||
* is active.
|
||||
*
|
||||
* When a Scene Store operation or a Scene Recall operation completes with
|
||||
* success, the Current Scene state value shall be to the Scene Number used
|
||||
* during that operation.
|
||||
*
|
||||
* When the Current Scene Number is deleted from a Scene Register state as a
|
||||
* result of Scene Delete operation, the Current Scene state shall be set to
|
||||
* 0x0000.
|
||||
*
|
||||
* When any of the element's state that is marked as “Stored with Scene” has
|
||||
* changed not as a result of a Scene Recall operation, the value of the
|
||||
* Current Scene state shall be set to 0x0000.
|
||||
*
|
||||
* When a scene transition is in progress, the value of the Current Scene
|
||||
* state shall be set to 0x0000.
|
||||
*/
|
||||
uint16_t current_scene; /*!< The value of the Current Scene state */
|
||||
|
||||
/**
|
||||
* The Target Scene state is a 16-bit value that contains the target Scene
|
||||
* Number when a scene transition is in progress.
|
||||
*
|
||||
* When the scene transition is in progress and the target Scene Number is
|
||||
* deleted from a Scene Register state as a result of Scene Delete operation,
|
||||
* the Target Scene state shall be set to 0x0000.
|
||||
*
|
||||
* When the scene transition is in progress and a new Scene Number is stored
|
||||
* in the Scene Register as a result of Scene Store operation, the Target
|
||||
* Scene state shall be set to the new Scene Number.
|
||||
*
|
||||
* When the scene transition is not in progress, the value of the Target Scene
|
||||
* state shall be set to 0x0000.
|
||||
*/
|
||||
uint16_t target_scene; /*!< The value of the Target Scene state */
|
||||
|
||||
/* Indicate the status code for the last operation */
|
||||
uint8_t status_code; /*!< The status code of the last scene operation */
|
||||
|
||||
/* Indicate if scene transition is in progress */
|
||||
bool in_progress; /*!< Indicate if the scene transition is in progress */
|
||||
} esp_ble_mesh_scenes_state_t;
|
||||
|
||||
/** User data of Scene Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Scene Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_scenes_state_t *state; /*!< Parameters of the Scenes state */
|
||||
esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
|
||||
esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
|
||||
} esp_ble_mesh_scene_srv_t;
|
||||
|
||||
/** User data of Scene Setup Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Scene Setup Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_scenes_state_t *state; /*!< Parameters of the Scenes state */
|
||||
} esp_ble_mesh_scene_setup_srv_t;
|
||||
|
||||
/** Parameters of Scheduler Register state */
|
||||
typedef struct {
|
||||
bool in_use; /*!< Indicate if the registered schedule is in use */
|
||||
uint64_t year : 7, /*!< The value of Scheduled year for the action */
|
||||
month : 12, /*!< The value of Scheduled month for the action */
|
||||
day : 5, /*!< The value of Scheduled day of the month for the action */
|
||||
hour : 5, /*!< The value of Scheduled hour for the action */
|
||||
minute : 6, /*!< The value of Scheduled minute for the action */
|
||||
second : 6, /*!< The value of Scheduled second for the action */
|
||||
day_of_week : 7, /*!< The value of Schedule days of the week for the action */
|
||||
action : 4, /*!< The value of Action to be performed at the scheduled time */
|
||||
trans_time : 8; /*!< The value of Transition time for this action */
|
||||
uint16_t scene_number; /*!< The value of Scene Number to be used for some actions */
|
||||
} esp_ble_mesh_schedule_register_t;
|
||||
|
||||
/** Parameters of Scheduler state */
|
||||
typedef struct {
|
||||
const uint8_t schedule_count; /*!< Scheduler count */
|
||||
esp_ble_mesh_schedule_register_t *schedules; /*!< Up to 16 scheduled entries */
|
||||
} esp_ble_mesh_scheduler_state_t;
|
||||
|
||||
/** User data of Scheduler Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Scheduler Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_scheduler_state_t *state; /*!< Parameters of the Scheduler state */
|
||||
} esp_ble_mesh_scheduler_srv_t;
|
||||
|
||||
/** User data of Scheduler Setup Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Scheduler Setup Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_scheduler_state_t *state; /*!< Parameters of the Scheduler state */
|
||||
} esp_ble_mesh_scheduler_setup_srv_t;
|
||||
|
||||
/** Parameters of Time Set state change event */
|
||||
typedef struct {
|
||||
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
|
||||
uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */
|
||||
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
|
||||
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
|
||||
uint16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */
|
||||
uint8_t time_zone_offset_curr; /*!< The local time zone offset in 15-minute increments */
|
||||
} esp_ble_mesh_state_change_time_set_t;
|
||||
|
||||
/** Parameters of Time Status state change event */
|
||||
typedef struct {
|
||||
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
|
||||
uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */
|
||||
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
|
||||
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
|
||||
uint16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */
|
||||
uint8_t time_zone_offset_curr; /*!< The local time zone offset in 15-minute increments */
|
||||
} esp_ble_mesh_state_change_time_status_t;
|
||||
|
||||
/** Parameters of Time Zone Set state change event */
|
||||
typedef struct {
|
||||
uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
|
||||
uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
|
||||
} esp_ble_mesh_state_change_time_zone_set_t;
|
||||
|
||||
/** Parameters of TAI UTC Delta Set state change event */
|
||||
typedef struct {
|
||||
uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
|
||||
uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
|
||||
} esp_ble_mesh_state_change_tai_utc_delta_set_t;
|
||||
|
||||
/** Parameter of Time Role Set state change event */
|
||||
typedef struct {
|
||||
uint8_t time_role; /*!< The Time Role for the element */
|
||||
} esp_ble_mesh_state_change_time_role_set_t;
|
||||
|
||||
/** Parameter of Scene Store state change event */
|
||||
typedef struct {
|
||||
uint16_t scene_number; /*!< The number of scenes to be stored */
|
||||
} esp_ble_mesh_state_change_scene_store_t;
|
||||
|
||||
/** Parameter of Scene Recall state change event */
|
||||
typedef struct {
|
||||
uint16_t scene_number; /*!< The number of scenes to be recalled */
|
||||
} esp_ble_mesh_state_change_scene_recall_t;
|
||||
|
||||
/** Parameter of Scene Delete state change event */
|
||||
typedef struct {
|
||||
uint16_t scene_number; /*!< The number of scenes to be deleted */
|
||||
} esp_ble_mesh_state_change_scene_delete_t;
|
||||
|
||||
/** Parameter of Scheduler Action Set state change event */
|
||||
typedef struct {
|
||||
uint64_t index : 4; /*!< Index of the Schedule Register entry to set */
|
||||
uint64_t year : 7; /*!< Scheduled year for the action */
|
||||
uint64_t month : 12; /*!< Scheduled month for the action */
|
||||
uint64_t day : 5; /*!< Scheduled day of the month for the action */
|
||||
uint64_t hour : 5; /*!< Scheduled hour for the action */
|
||||
uint64_t minute : 6; /*!< Scheduled minute for the action */
|
||||
uint64_t second : 6; /*!< Scheduled second for the action */
|
||||
uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
|
||||
uint64_t action : 4; /*!< Action to be performed at the scheduled time */
|
||||
uint64_t trans_time : 8; /*!< Transition time for this action */
|
||||
uint16_t scene_number; /*!< Scene number to be used for some actions */
|
||||
} esp_ble_mesh_state_change_scheduler_act_set_t;
|
||||
|
||||
/**
|
||||
* @brief Time Scene Server Model state change value union
|
||||
*/
|
||||
typedef union {
|
||||
/**
|
||||
* The recv_op in ctx can be used to decide which state is changed.
|
||||
*/
|
||||
esp_ble_mesh_state_change_time_set_t time_set; /*!< Time Set */
|
||||
esp_ble_mesh_state_change_time_status_t time_status; /*!< Time Status */
|
||||
esp_ble_mesh_state_change_time_zone_set_t time_zone_set; /*!< Time Zone Set */
|
||||
esp_ble_mesh_state_change_tai_utc_delta_set_t tai_utc_delta_set; /*!< TAI UTC Delta Set */
|
||||
esp_ble_mesh_state_change_time_role_set_t time_role_set; /*!< Time Role Set */
|
||||
esp_ble_mesh_state_change_scene_store_t scene_store; /*!< Scene Store */
|
||||
esp_ble_mesh_state_change_scene_recall_t scene_recall; /*!< Scene Recall */
|
||||
esp_ble_mesh_state_change_scene_delete_t scene_delete; /*!< Scene Delete */
|
||||
esp_ble_mesh_state_change_scheduler_act_set_t scheduler_act_set; /*!< Scheduler Action Set */
|
||||
} esp_ble_mesh_time_scene_server_state_change_t;
|
||||
|
||||
/** Context of the received Scheduler Action Get message */
|
||||
typedef struct {
|
||||
uint8_t index; /*!< Index of the Schedule Register entry to get */
|
||||
} esp_ble_mesh_server_recv_scheduler_act_get_t;
|
||||
|
||||
/**
|
||||
* @brief Time Scene Server Model received get message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_server_recv_scheduler_act_get_t scheduler_act; /*!< Scheduler Action Get */
|
||||
} esp_ble_mesh_time_scene_server_recv_get_msg_t;
|
||||
|
||||
/** Context of the received Time Set message */
|
||||
typedef struct {
|
||||
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
|
||||
uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */
|
||||
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
|
||||
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
|
||||
uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
|
||||
uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
|
||||
} esp_ble_mesh_server_recv_time_set_t;
|
||||
|
||||
/** Context of the received Time Zone Set message */
|
||||
typedef struct {
|
||||
uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
|
||||
uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
|
||||
} esp_ble_mesh_server_recv_time_zone_set_t;
|
||||
|
||||
/** Context of the received TAI UTC Delta Set message */
|
||||
typedef struct {
|
||||
uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
|
||||
uint16_t padding : 1; /*!< Always 0b0. Other values are Prohibited. */
|
||||
uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
|
||||
} esp_ble_mesh_server_recv_tai_utc_delta_set_t;
|
||||
|
||||
/** Context of the received Time Role Set message */
|
||||
typedef struct {
|
||||
uint8_t time_role; /*!< The Time Role for the element */
|
||||
} esp_ble_mesh_server_recv_time_role_set_t;
|
||||
|
||||
/** Context of the received Scene Store message */
|
||||
typedef struct {
|
||||
uint16_t scene_number; /*!< The number of scenes to be stored */
|
||||
} esp_ble_mesh_server_recv_scene_store_t;
|
||||
|
||||
/** Context of the received Scene Recall message */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
uint16_t scene_number; /*!< The number of scenes to be recalled */
|
||||
uint8_t tid; /*!< Transaction ID */
|
||||
uint8_t trans_time; /*!< Time to complete state transition (optional) */
|
||||
uint8_t delay; /*!< Indicate message execution delay (C.1) */
|
||||
} esp_ble_mesh_server_recv_scene_recall_t;
|
||||
|
||||
/** Context of the received Scene Delete message */
|
||||
typedef struct {
|
||||
uint16_t scene_number; /*!< The number of scenes to be deleted */
|
||||
} esp_ble_mesh_server_recv_scene_delete_t;
|
||||
|
||||
/** Context of the received Scheduler Action Set message */
|
||||
typedef struct {
|
||||
uint64_t index : 4; /*!< Index of the Schedule Register entry to set */
|
||||
uint64_t year : 7; /*!< Scheduled year for the action */
|
||||
uint64_t month : 12; /*!< Scheduled month for the action */
|
||||
uint64_t day : 5; /*!< Scheduled day of the month for the action */
|
||||
uint64_t hour : 5; /*!< Scheduled hour for the action */
|
||||
uint64_t minute : 6; /*!< Scheduled minute for the action */
|
||||
uint64_t second : 6; /*!< Scheduled second for the action */
|
||||
uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
|
||||
uint64_t action : 4; /*!< Action to be performed at the scheduled time */
|
||||
uint64_t trans_time : 8; /*!< Transition time for this action */
|
||||
uint16_t scene_number; /*!< Scene number to be used for some actions */
|
||||
} esp_ble_mesh_server_recv_scheduler_act_set_t;
|
||||
|
||||
/**
|
||||
* @brief Time Scene Server Model received set message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_server_recv_time_set_t time; /*!< Time Set */
|
||||
esp_ble_mesh_server_recv_time_zone_set_t time_zone; /*!< Time Zone Set */
|
||||
esp_ble_mesh_server_recv_tai_utc_delta_set_t tai_utc_delta; /*!< TAI-UTC Delta Set */
|
||||
esp_ble_mesh_server_recv_time_role_set_t time_role; /*!< Time Role Set */
|
||||
esp_ble_mesh_server_recv_scene_store_t scene_store; /*!< Scene Store/Scene Store Unack */
|
||||
esp_ble_mesh_server_recv_scene_recall_t scene_recall; /*!< Scene Recall/Scene Recall Unack */
|
||||
esp_ble_mesh_server_recv_scene_delete_t scene_delete; /*!< Scene Delete/Scene Delete Unack */
|
||||
esp_ble_mesh_server_recv_scheduler_act_set_t scheduler_act; /*!< Scheduler Action Set/Scheduler Action Set Unack */
|
||||
} esp_ble_mesh_time_scene_server_recv_set_msg_t;
|
||||
|
||||
/** Context of the received Time Status message */
|
||||
typedef struct {
|
||||
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
|
||||
uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */
|
||||
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
|
||||
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
|
||||
uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
|
||||
uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
|
||||
} esp_ble_mesh_server_recv_time_status_t;
|
||||
|
||||
/**
|
||||
* @brief Time Scene Server Model received status message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_server_recv_time_status_t time_status; /*!< Time Status */
|
||||
} esp_ble_mesh_time_scene_server_recv_status_msg_t;
|
||||
|
||||
/**
|
||||
* @brief Time Scene Server Model callback value union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_time_scene_server_state_change_t state_change; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_STATE_CHANGE_EVT */
|
||||
esp_ble_mesh_time_scene_server_recv_get_msg_t get; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_GET_MSG_EVT */
|
||||
esp_ble_mesh_time_scene_server_recv_set_msg_t set; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_SET_MSG_EVT */
|
||||
esp_ble_mesh_time_scene_server_recv_status_msg_t status; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_STATUS_MSG_EVT */
|
||||
} esp_ble_mesh_time_scene_server_cb_value_t;
|
||||
|
||||
/** Time Scene Server Model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to Time and Scenes Server Models */
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received messages */
|
||||
esp_ble_mesh_time_scene_server_cb_value_t value; /*!< Value of the received Time and Scenes Messages */
|
||||
} esp_ble_mesh_time_scene_server_cb_param_t;
|
||||
|
||||
/** This enum value is the event of Time Scene Server Model */
|
||||
typedef enum {
|
||||
/**
|
||||
* 1. When get_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, no event will be
|
||||
* callback to the application layer when Time Scene Get messages are received.
|
||||
* 2. When set_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, this event will
|
||||
* be callback to the application layer when Time Scene Set/Set Unack messages
|
||||
* are received.
|
||||
*/
|
||||
ESP_BLE_MESH_TIME_SCENE_SERVER_STATE_CHANGE_EVT,
|
||||
/**
|
||||
* When get_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
|
||||
* callback to the application layer when Time Scene Get messages are received.
|
||||
*/
|
||||
ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_GET_MSG_EVT,
|
||||
/**
|
||||
* When set_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
|
||||
* callback to the application layer when Time Scene Set/Set Unack messages are received.
|
||||
*/
|
||||
ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_SET_MSG_EVT,
|
||||
/**
|
||||
* When status_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will
|
||||
* be callback to the application layer when TIme Status message is received.
|
||||
*/
|
||||
ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_STATUS_MSG_EVT,
|
||||
ESP_BLE_MESH_TIME_SCENE_SERVER_EVT_MAX,
|
||||
} esp_ble_mesh_time_scene_server_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth Mesh Time and Scenes Server Model function.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Time Scene Server Model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_time_scene_server_cb_t)(esp_ble_mesh_time_scene_server_cb_event_t event,
|
||||
esp_ble_mesh_time_scene_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Time and Scenes Server Model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_time_scene_server_callback(esp_ble_mesh_time_scene_server_cb_t callback);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_ */
|
Reference in New Issue
Block a user