forked from espressif/esp-idf
Merge branch 'bugfix/struct_init_order_blemesh' into 'master'
ble mesh: Modify the structure initialization order to meet C++ requirements See merge request espressif/esp-idf!18077
This commit is contained in:
@@ -71,6 +71,14 @@ typedef uint8_t esp_ble_mesh_octet8_t[ESP_BLE_MESH_OCTET8_LEN];
|
|||||||
#define ESP_BLE_MESH_KEY_PRIMARY 0x0000
|
#define ESP_BLE_MESH_KEY_PRIMARY 0x0000
|
||||||
#define ESP_BLE_MESH_KEY_ANY 0xFFFF
|
#define ESP_BLE_MESH_KEY_ANY 0xFFFF
|
||||||
|
|
||||||
|
/*!< Internal macros used to initialize array members */
|
||||||
|
#define ESP_BLE_MESH_KEY_UNUSED_ELT_(IDX, _) ESP_BLE_MESH_KEY_UNUSED
|
||||||
|
#define ESP_BLE_MESH_ADDR_UNASSIGNED_ELT_(IDX, _) ESP_BLE_MESH_ADDR_UNASSIGNED
|
||||||
|
#define ESP_BLE_MESH_MODEL_KEYS_UNUSED \
|
||||||
|
{ LISTIFY(CONFIG_BLE_MESH_MODEL_KEY_COUNT, ESP_BLE_MESH_KEY_UNUSED_ELT_, (,)) }
|
||||||
|
#define ESP_BLE_MESH_MODEL_GROUPS_UNASSIGNED \
|
||||||
|
{ LISTIFY(CONFIG_BLE_MESH_MODEL_GROUP_COUNT, ESP_BLE_MESH_ADDR_UNASSIGNED_ELT_, (,)) }
|
||||||
|
|
||||||
/*!< Primary Network Key index */
|
/*!< Primary Network Key index */
|
||||||
#define ESP_BLE_MESH_NET_PRIMARY 0x000
|
#define ESP_BLE_MESH_NET_PRIMARY 0x000
|
||||||
|
|
||||||
@@ -286,26 +294,24 @@ typedef enum {
|
|||||||
#define ESP_BLE_MESH_SIG_MODEL(_id, _op, _pub, _user_data) \
|
#define ESP_BLE_MESH_SIG_MODEL(_id, _op, _pub, _user_data) \
|
||||||
{ \
|
{ \
|
||||||
.model_id = (_id), \
|
.model_id = (_id), \
|
||||||
.op = _op, \
|
|
||||||
.keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \
|
|
||||||
ESP_BLE_MESH_KEY_UNUSED }, \
|
|
||||||
.pub = _pub, \
|
.pub = _pub, \
|
||||||
.groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \
|
.keys = ESP_BLE_MESH_MODEL_KEYS_UNUSED, \
|
||||||
ESP_BLE_MESH_ADDR_UNASSIGNED }, \
|
.groups = ESP_BLE_MESH_MODEL_GROUPS_UNASSIGNED, \
|
||||||
|
.op = _op, \
|
||||||
.user_data = _user_data, \
|
.user_data = _user_data, \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!< This macro is associated with BLE_MESH_MODEL_VND_CB in mesh_access.h */
|
/*!< This macro is associated with BLE_MESH_MODEL_VND_CB in mesh_access.h */
|
||||||
#define ESP_BLE_MESH_VENDOR_MODEL(_company, _id, _op, _pub, _user_data) \
|
#define ESP_BLE_MESH_VENDOR_MODEL(_company, _id, _op, _pub, _user_data) \
|
||||||
{ \
|
{ \
|
||||||
.vnd.company_id = (_company), \
|
.vnd = { \
|
||||||
.vnd.model_id = (_id), \
|
.company_id = (_company), \
|
||||||
.op = _op, \
|
.model_id = (_id), \
|
||||||
|
}, \
|
||||||
.pub = _pub, \
|
.pub = _pub, \
|
||||||
.keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \
|
.keys = ESP_BLE_MESH_MODEL_KEYS_UNUSED, \
|
||||||
ESP_BLE_MESH_KEY_UNUSED }, \
|
.groups = ESP_BLE_MESH_MODEL_GROUPS_UNASSIGNED, \
|
||||||
.groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \
|
.op = _op, \
|
||||||
ESP_BLE_MESH_ADDR_UNASSIGNED }, \
|
|
||||||
.user_data = _user_data, \
|
.user_data = _user_data, \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,8 +330,8 @@ typedef enum {
|
|||||||
{ \
|
{ \
|
||||||
.location = (_loc), \
|
.location = (_loc), \
|
||||||
.sig_model_count = ARRAY_SIZE(_mods), \
|
.sig_model_count = ARRAY_SIZE(_mods), \
|
||||||
.sig_models = (_mods), \
|
|
||||||
.vnd_model_count = ARRAY_SIZE(_vnd_mods), \
|
.vnd_model_count = ARRAY_SIZE(_vnd_mods), \
|
||||||
|
.sig_models = (_mods), \
|
||||||
.vnd_models = (_vnd_mods), \
|
.vnd_models = (_vnd_mods), \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -492,8 +498,9 @@ typedef struct {
|
|||||||
#define ESP_BLE_MESH_MODEL_PUB_DEFINE(_name, _msg_len, _role) \
|
#define ESP_BLE_MESH_MODEL_PUB_DEFINE(_name, _msg_len, _role) \
|
||||||
NET_BUF_SIMPLE_DEFINE_STATIC(bt_mesh_pub_msg_##_name, _msg_len); \
|
NET_BUF_SIMPLE_DEFINE_STATIC(bt_mesh_pub_msg_##_name, _msg_len); \
|
||||||
static esp_ble_mesh_model_pub_t _name = { \
|
static esp_ble_mesh_model_pub_t _name = { \
|
||||||
.update = (uint32_t)NULL, \
|
|
||||||
.msg = &bt_mesh_pub_msg_##_name, \
|
.msg = &bt_mesh_pub_msg_##_name, \
|
||||||
|
.update = (uint32_t)NULL, \
|
||||||
|
.dev_role = _role, \
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @def ESP_BLE_MESH_MODEL_OP
|
/** @def ESP_BLE_MESH_MODEL_OP
|
||||||
|
@@ -840,22 +840,22 @@ struct net_buf_pool {
|
|||||||
#if CONFIG_BLE_MESH_NET_BUF_POOL_USAGE
|
#if CONFIG_BLE_MESH_NET_BUF_POOL_USAGE
|
||||||
#define NET_BUF_POOL_INITIALIZER(_pool, _alloc, _bufs, _count, _destroy) \
|
#define NET_BUF_POOL_INITIALIZER(_pool, _alloc, _bufs, _count, _destroy) \
|
||||||
{ \
|
{ \
|
||||||
.alloc = _alloc, \
|
|
||||||
.__bufs = (struct net_buf *)_bufs, \
|
|
||||||
.buf_count = _count, \
|
.buf_count = _count, \
|
||||||
.uninit_count = _count, \
|
.uninit_count = _count, \
|
||||||
.avail_count = _count, \
|
.avail_count = _count, \
|
||||||
.destroy = _destroy, \
|
|
||||||
.name = STRINGIFY(_pool), \
|
.name = STRINGIFY(_pool), \
|
||||||
|
.destroy = _destroy, \
|
||||||
|
.alloc = _alloc, \
|
||||||
|
.__bufs = (struct net_buf *)_bufs, \
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define NET_BUF_POOL_INITIALIZER(_pool, _alloc, _bufs, _count, _destroy) \
|
#define NET_BUF_POOL_INITIALIZER(_pool, _alloc, _bufs, _count, _destroy) \
|
||||||
{ \
|
{ \
|
||||||
.alloc = _alloc, \
|
|
||||||
.__bufs = (struct net_buf *)_bufs, \
|
|
||||||
.buf_count = _count, \
|
.buf_count = _count, \
|
||||||
.uninit_count = _count, \
|
.uninit_count = _count, \
|
||||||
.destroy = _destroy, \
|
.destroy = _destroy, \
|
||||||
|
.alloc = _alloc, \
|
||||||
|
.__bufs = (struct net_buf *)_bufs, \
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_BLE_MESH_NET_BUF_POOL_USAGE */
|
#endif /* CONFIG_BLE_MESH_NET_BUF_POOL_USAGE */
|
||||||
|
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include "esp_bit_defs.h"
|
#include "esp_bit_defs.h"
|
||||||
#include "mesh/types.h"
|
#include "mesh/types.h"
|
||||||
|
#include "utils_loops.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -180,6 +181,40 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
#define Z_IS_ENABLED3(ignore_this, val, ...) val
|
#define Z_IS_ENABLED3(ignore_this, val, ...) val
|
||||||
|
|
||||||
|
/* Used to remove brackets from around a single argument. */
|
||||||
|
#define __DEBRACKET(...) __VA_ARGS__
|
||||||
|
|
||||||
|
#define UTIL_CAT(a, ...) UTIL_PRIMITIVE_CAT(a, __VA_ARGS__)
|
||||||
|
#define UTIL_PRIMITIVE_CAT(a, ...) a##__VA_ARGS__
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Generates a sequence of code with configurable separator.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* #define FOO(i, _) MY_PWM ## i
|
||||||
|
* { LISTIFY(PWM_COUNT, FOO, (,)) }
|
||||||
|
*
|
||||||
|
* The above two lines expand to:
|
||||||
|
*
|
||||||
|
* { MY_PWM0 , MY_PWM1 }
|
||||||
|
*
|
||||||
|
* @param LEN The length of the sequence. Must be an integer literal less
|
||||||
|
* than 255.
|
||||||
|
* @param F A macro function that accepts at least two arguments:
|
||||||
|
* <tt>F(i, ...)</tt>. @p F is called repeatedly in the expansion.
|
||||||
|
* Its first argument @p i is the index in the sequence, and
|
||||||
|
* the variable list of arguments passed to LISTIFY are passed
|
||||||
|
* through to @p F.
|
||||||
|
*
|
||||||
|
* @param sep Separator (e.g. comma or semicolon). Must be in parentheses;
|
||||||
|
* this is required to enable providing a comma as separator.
|
||||||
|
*
|
||||||
|
* @note Calling LISTIFY with undefined arguments has undefined
|
||||||
|
* behavior.
|
||||||
|
*/
|
||||||
|
#define LISTIFY(LEN, F, sep, ...) UTIL_CAT(Z_UTIL_LISTIFY_, LEN)(F, sep, __VA_ARGS__)
|
||||||
|
|
||||||
const char *bt_hex(const void *buf, size_t len);
|
const char *bt_hex(const void *buf, size_t len);
|
||||||
|
|
||||||
void mem_rcopy(uint8_t *dst, uint8_t const *src, uint16_t len);
|
void mem_rcopy(uint8_t *dst, uint8_t const *src, uint16_t len);
|
||||||
|
1051
components/bt/esp_ble_mesh/common/include/mesh/utils_loops.h
Normal file
1051
components/bt/esp_ble_mesh/common/include/mesh/utils_loops.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -54,8 +54,8 @@ extern "C" {
|
|||||||
{ \
|
{ \
|
||||||
.loc = (_loc), \
|
.loc = (_loc), \
|
||||||
.model_count = ARRAY_SIZE(_mods), \
|
.model_count = ARRAY_SIZE(_mods), \
|
||||||
.models = (_mods), \
|
|
||||||
.vnd_model_count = ARRAY_SIZE(_vnd_mods), \
|
.vnd_model_count = ARRAY_SIZE(_vnd_mods), \
|
||||||
|
.models = (_mods), \
|
||||||
.vnd_models = (_vnd_mods), \
|
.vnd_models = (_vnd_mods), \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,14 +306,12 @@ struct bt_mesh_model_op {
|
|||||||
#define BLE_MESH_MODEL_CB(_id, _op, _pub, _user_data, _cb) \
|
#define BLE_MESH_MODEL_CB(_id, _op, _pub, _user_data, _cb) \
|
||||||
{ \
|
{ \
|
||||||
.id = (_id), \
|
.id = (_id), \
|
||||||
.op = (_op), \
|
|
||||||
.keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \
|
|
||||||
BLE_MESH_KEY_UNUSED }, \
|
|
||||||
.pub = (_pub), \
|
.pub = (_pub), \
|
||||||
.groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \
|
.keys = ESP_BLE_MESH_MODEL_KEYS_UNUSED, \
|
||||||
BLE_MESH_ADDR_UNASSIGNED }, \
|
.groups = ESP_BLE_MESH_MODEL_GROUPS_UNASSIGNED, \
|
||||||
.user_data = (_user_data), \
|
.op = (_op), \
|
||||||
.cb = (_cb), \
|
.cb = (_cb), \
|
||||||
|
.user_data = (_user_data), \
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @def BLE_MESH_MODEL_VND_CB
|
/** @def BLE_MESH_MODEL_VND_CB
|
||||||
@@ -331,14 +329,12 @@ struct bt_mesh_model_op {
|
|||||||
{ \
|
{ \
|
||||||
.vnd.company = (_company), \
|
.vnd.company = (_company), \
|
||||||
.vnd.id = (_id), \
|
.vnd.id = (_id), \
|
||||||
.op = (_op), \
|
|
||||||
.pub = (_pub), \
|
.pub = (_pub), \
|
||||||
.keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \
|
.keys = ESP_BLE_MESH_MODEL_KEYS_UNUSED, \
|
||||||
BLE_MESH_KEY_UNUSED }, \
|
.groups = ESP_BLE_MESH_MODEL_GROUPS_UNASSIGNED, \
|
||||||
.groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \
|
.op = (_op), \
|
||||||
BLE_MESH_ADDR_UNASSIGNED }, \
|
|
||||||
.user_data = (_user_data), \
|
|
||||||
.cb = (_cb), \
|
.cb = (_cb), \
|
||||||
|
.user_data = (_user_data), \
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @def BLE_MESH_TRANSMIT
|
/** @def BLE_MESH_TRANSMIT
|
||||||
@@ -475,8 +471,8 @@ struct bt_mesh_model_pub {
|
|||||||
#define BLE_MESH_MODEL_PUB_DEFINE(_name, _update, _msg_len) \
|
#define BLE_MESH_MODEL_PUB_DEFINE(_name, _update, _msg_len) \
|
||||||
NET_BUF_SIMPLE_DEFINE_STATIC(bt_mesh_pub_msg_##_name, _msg_len); \
|
NET_BUF_SIMPLE_DEFINE_STATIC(bt_mesh_pub_msg_##_name, _msg_len); \
|
||||||
static struct bt_mesh_model_pub _name = { \
|
static struct bt_mesh_model_pub _name = { \
|
||||||
.update = _update, \
|
|
||||||
.msg = &bt_mesh_pub_msg_##_name, \
|
.msg = &bt_mesh_pub_msg_##_name, \
|
||||||
|
.update = _update, \
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Model callback functions. */
|
/** Model callback functions. */
|
||||||
|
@@ -596,9 +596,9 @@ struct bt_mesh_gatt_attr {
|
|||||||
#define BLE_MESH_GATT_PRIMARY_SERVICE(_service) \
|
#define BLE_MESH_GATT_PRIMARY_SERVICE(_service) \
|
||||||
{ \
|
{ \
|
||||||
.uuid = BLE_MESH_UUID_GATT_PRIMARY, \
|
.uuid = BLE_MESH_UUID_GATT_PRIMARY, \
|
||||||
.perm = BLE_MESH_GATT_PERM_READ, \
|
|
||||||
.read = bt_mesh_gatts_attr_read_service, \
|
.read = bt_mesh_gatts_attr_read_service, \
|
||||||
.user_data = _service, \
|
.user_data = _service, \
|
||||||
|
.perm = BLE_MESH_GATT_PERM_READ, \
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @def BLE_MESH_GATT_SECONDARY_SERVICE
|
/** @def BLE_MESH_GATT_SECONDARY_SERVICE
|
||||||
@@ -611,9 +611,9 @@ struct bt_mesh_gatt_attr {
|
|||||||
#define BLE_MESH_GATT_SECONDARY_SERVICE(_service) \
|
#define BLE_MESH_GATT_SECONDARY_SERVICE(_service) \
|
||||||
{ \
|
{ \
|
||||||
.uuid = BLE_MESH_UUID_GATT_SECONDARY, \
|
.uuid = BLE_MESH_UUID_GATT_SECONDARY, \
|
||||||
.perm = BLE_MESH_GATT_PERM_READ, \
|
|
||||||
.read = bt_mesh_gatts_attr_read_service, \
|
.read = bt_mesh_gatts_attr_read_service, \
|
||||||
.user_data = _service, \
|
.user_data = _service, \
|
||||||
|
.perm = BLE_MESH_GATT_PERM_READ, \
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @def BLE_MESH_GATT_INCLUDE_SERVICE
|
/** @def BLE_MESH_GATT_INCLUDE_SERVICE
|
||||||
@@ -626,9 +626,9 @@ struct bt_mesh_gatt_attr {
|
|||||||
#define BLE_MESH_GATT_INCLUDE_SERVICE(_service_incl) \
|
#define BLE_MESH_GATT_INCLUDE_SERVICE(_service_incl) \
|
||||||
{ \
|
{ \
|
||||||
.uuid = BLE_MESH_UUID_GATT_INCLUDE, \
|
.uuid = BLE_MESH_UUID_GATT_INCLUDE, \
|
||||||
.perm = BLE_MESH_GATT_PERM_READ, \
|
|
||||||
.read = bt_mesh_gatts_attr_read_included, \
|
.read = bt_mesh_gatts_attr_read_included, \
|
||||||
.user_data = _service_incl, \
|
.user_data = _service_incl, \
|
||||||
|
.perm = BLE_MESH_GATT_PERM_READ, \
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @def BLE_MESH_GATT_CHARACTERISTIC
|
/** @def BLE_MESH_GATT_CHARACTERISTIC
|
||||||
@@ -642,10 +642,10 @@ struct bt_mesh_gatt_attr {
|
|||||||
#define BLE_MESH_GATT_CHARACTERISTIC(_uuid, _props) \
|
#define BLE_MESH_GATT_CHARACTERISTIC(_uuid, _props) \
|
||||||
{ \
|
{ \
|
||||||
.uuid = BLE_MESH_UUID_GATT_CHRC, \
|
.uuid = BLE_MESH_UUID_GATT_CHRC, \
|
||||||
.perm = BLE_MESH_GATT_PERM_READ, \
|
|
||||||
.read = bt_mesh_gatts_attr_read_chrc, \
|
.read = bt_mesh_gatts_attr_read_chrc, \
|
||||||
.user_data = (&(struct bt_mesh_gatt_char) { .uuid = _uuid, \
|
.user_data = (&(struct bt_mesh_gatt_char) { .uuid = _uuid, \
|
||||||
.properties = _props, }), \
|
.properties = _props, }), \
|
||||||
|
.perm = BLE_MESH_GATT_PERM_READ, \
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @def BLE_MESH_GATT_DESCRIPTOR
|
/** @def BLE_MESH_GATT_DESCRIPTOR
|
||||||
@@ -662,10 +662,10 @@ struct bt_mesh_gatt_attr {
|
|||||||
#define BLE_MESH_GATT_DESCRIPTOR(_uuid, _perm, _read, _write, _value) \
|
#define BLE_MESH_GATT_DESCRIPTOR(_uuid, _perm, _read, _write, _value) \
|
||||||
{ \
|
{ \
|
||||||
.uuid = _uuid, \
|
.uuid = _uuid, \
|
||||||
.perm = _perm, \
|
|
||||||
.read = _read, \
|
.read = _read, \
|
||||||
.write = _write, \
|
.write = _write, \
|
||||||
.user_data = _value, \
|
.user_data = _value, \
|
||||||
|
.perm = _perm, \
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @def BLE_MESH_GATT_SERVICE
|
/** @def BLE_MESH_GATT_SERVICE
|
||||||
|
@@ -238,6 +238,11 @@ typedef union {
|
|||||||
esp_ble_mesh_rpr_link_report_t link_report; /*!< For ESP_BLE_MESH_MODEL_OP_RPR_LINK_REPORT */
|
esp_ble_mesh_rpr_link_report_t link_report; /*!< For ESP_BLE_MESH_MODEL_OP_RPR_LINK_REPORT */
|
||||||
} esp_ble_mesh_rpr_client_recv_cb_t;
|
} esp_ble_mesh_rpr_client_recv_cb_t;
|
||||||
|
|
||||||
|
/** This enum value is the event type of the performed action */
|
||||||
|
typedef enum {
|
||||||
|
ESP_BLE_MESH_START_RPR_COMP_SUB_EVT,
|
||||||
|
} esp_ble_mesh_rpr_client_act_evt_t;
|
||||||
|
|
||||||
/** Remote Provisioning Client model callback parameters */
|
/** Remote Provisioning Client model callback parameters */
|
||||||
typedef union {
|
typedef union {
|
||||||
/** Event parameters of sending messages */
|
/** Event parameters of sending messages */
|
||||||
@@ -252,10 +257,7 @@ typedef union {
|
|||||||
} recv; /*!< Event parameters of receiving messages */
|
} recv; /*!< Event parameters of receiving messages */
|
||||||
/** Event parameters of performed actions */
|
/** Event parameters of performed actions */
|
||||||
struct {
|
struct {
|
||||||
/** Event type of the performed action */
|
esp_ble_mesh_rpr_client_act_evt_t sub_evt; /*!< Event type of the performed action */
|
||||||
enum {
|
|
||||||
ESP_BLE_MESH_START_RPR_COMP_SUB_EVT,
|
|
||||||
} sub_evt; /*!< Event type of the performed action */
|
|
||||||
/**
|
/**
|
||||||
* @brief ESP_BLE_MESH_START_RPR_COMP_SUB_EVT
|
* @brief ESP_BLE_MESH_START_RPR_COMP_SUB_EVT
|
||||||
*/
|
*/
|
||||||
|
@@ -73,23 +73,23 @@ static uint8_t dev_uuid[16] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_cfg_srv_t config_server = {
|
static esp_ble_mesh_cfg_srv_t config_server = {
|
||||||
|
/* 3 transmissions with 20ms interval */
|
||||||
|
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.relay = ESP_BLE_MESH_RELAY_ENABLED,
|
.relay = ESP_BLE_MESH_RELAY_ENABLED,
|
||||||
|
/* 3 transmissions with 20ms interval */
|
||||||
|
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
||||||
#if defined(CONFIG_BLE_MESH_FRIEND)
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
|
||||||
#else
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
||||||
#else
|
#else
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_BLE_MESH_FRIEND)
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
||||||
|
#else
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
||||||
#endif
|
#endif
|
||||||
.default_ttl = 7,
|
.default_ttl = 7,
|
||||||
/* 3 transmissions with 20ms interval */
|
|
||||||
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
/* 3 transmissions with 20ms interval */
|
|
||||||
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t test_ids[1] = {0x00};
|
uint8_t test_ids[1] = {0x00};
|
||||||
@@ -97,15 +97,19 @@ uint8_t test_ids[1] = {0x00};
|
|||||||
/** ESP BLE Mesh Health Server Model Context */
|
/** ESP BLE Mesh Health Server Model Context */
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(health_pub, 2 + 11, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(health_pub, 2 + 11, ROLE_NODE);
|
||||||
static esp_ble_mesh_health_srv_t health_server = {
|
static esp_ble_mesh_health_srv_t health_server = {
|
||||||
.health_test.id_count = 1,
|
.health_test = {
|
||||||
.health_test.test_ids = test_ids,
|
.id_count = 1,
|
||||||
|
.test_ids = test_ids,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_MESH_MODEL_GEN_ONOFF_SRV
|
#ifdef CONFIG_MESH_MODEL_GEN_ONOFF_SRV
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_0, 2 + 3, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_0, 2 + 3, ROLE_NODE);
|
||||||
static esp_ble_mesh_gen_onoff_srv_t onoff_server_0 = {
|
static esp_ble_mesh_gen_onoff_srv_t onoff_server_0 = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.rsp_ctrl = {
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -116,16 +120,20 @@ static esp_ble_mesh_light_lightness_state_t lightness_state;
|
|||||||
/* Light Lightness Server related context */
|
/* Light Lightness Server related context */
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(lightness_pub, 2 + 5, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(lightness_pub, 2 + 5, ROLE_NODE);
|
||||||
static esp_ble_mesh_light_lightness_srv_t lightness_server = {
|
static esp_ble_mesh_light_lightness_srv_t lightness_server = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.rsp_ctrl = {
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
},
|
||||||
.state = &lightness_state,
|
.state = &lightness_state,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Light Lightness Setup Server related context */
|
/* Light Lightness Setup Server related context */
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(lightness_setup_pub, 2 + 5, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(lightness_setup_pub, 2 + 5, ROLE_NODE);
|
||||||
static esp_ble_mesh_light_lightness_setup_srv_t lightness_setup_server = {
|
static esp_ble_mesh_light_lightness_setup_srv_t lightness_setup_server = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.rsp_ctrl = {
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
},
|
||||||
.state = &lightness_state,
|
.state = &lightness_state,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -137,16 +145,20 @@ static esp_ble_mesh_light_ctl_state_t ctl_state;
|
|||||||
/* Light CTL Server related context */
|
/* Light CTL Server related context */
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(ctl_pub, 2 + 9, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(ctl_pub, 2 + 9, ROLE_NODE);
|
||||||
static esp_ble_mesh_light_ctl_srv_t ctl_server = {
|
static esp_ble_mesh_light_ctl_srv_t ctl_server = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.rsp_ctrl = {
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
},
|
||||||
.state = &ctl_state,
|
.state = &ctl_state,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Light CTL Setup Server related context */
|
/* Light CTL Setup Server related context */
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(ctl_setup_pub, 2 + 6, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(ctl_setup_pub, 2 + 6, ROLE_NODE);
|
||||||
static esp_ble_mesh_light_ctl_setup_srv_t ctl_setup_server = {
|
static esp_ble_mesh_light_ctl_setup_srv_t ctl_setup_server = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.rsp_ctrl = {
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
},
|
||||||
.state = &ctl_state,
|
.state = &ctl_state,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -158,16 +170,20 @@ static esp_ble_mesh_light_hsl_state_t hsl_state;
|
|||||||
/* Light HSL Server related context */
|
/* Light HSL Server related context */
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(hsl_pub, 2 + 9, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(hsl_pub, 2 + 9, ROLE_NODE);
|
||||||
static esp_ble_mesh_light_hsl_srv_t hsl_server = {
|
static esp_ble_mesh_light_hsl_srv_t hsl_server = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.rsp_ctrl = {
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
},
|
||||||
.state = &hsl_state,
|
.state = &hsl_state,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Light HSL Setup Server related context */
|
/* Light HSL Setup Server related context */
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(hsl_setup_pub, 2 + 9, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(hsl_setup_pub, 2 + 9, ROLE_NODE);
|
||||||
static esp_ble_mesh_light_hsl_setup_srv_t hsl_setup_server = {
|
static esp_ble_mesh_light_hsl_setup_srv_t hsl_setup_server = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.rsp_ctrl = {
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
},
|
||||||
.state = &hsl_state,
|
.state = &hsl_state,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -214,14 +230,18 @@ static esp_ble_mesh_model_t ali_vnd_models[] = {
|
|||||||
|
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_1, 2 + 3, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_1, 2 + 3, ROLE_NODE);
|
||||||
static esp_ble_mesh_gen_onoff_srv_t onoff_server_1 = {
|
static esp_ble_mesh_gen_onoff_srv_t onoff_server_1 = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
.rsp_ctrl = {
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_2, 2 + 3, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_2, 2 + 3, ROLE_NODE);
|
||||||
static esp_ble_mesh_gen_onoff_srv_t onoff_server_2 = {
|
static esp_ble_mesh_gen_onoff_srv_t onoff_server_2 = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.rsp_ctrl = {
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_model_t extend_model_0[] = {
|
static esp_ble_mesh_model_t extend_model_0[] = {
|
||||||
@@ -240,8 +260,8 @@ esp_ble_mesh_elem_t elements[] = {
|
|||||||
|
|
||||||
static esp_ble_mesh_comp_t composition = {
|
static esp_ble_mesh_comp_t composition = {
|
||||||
.cid = CID_ALIBABA,
|
.cid = CID_ALIBABA,
|
||||||
.elements = elements,
|
|
||||||
.element_count = ARRAY_SIZE(elements),
|
.element_count = ARRAY_SIZE(elements),
|
||||||
|
.elements = elements,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Disable OOB security for SILabs Android app */
|
/* Disable OOB security for SILabs Android app */
|
||||||
@@ -497,7 +517,7 @@ void user_genie_event_handle(genie_event_t event, void *p_arg)
|
|||||||
case GENIE_EVT_SDK_COLOR_ACTION: {
|
case GENIE_EVT_SDK_COLOR_ACTION: {
|
||||||
ESP_LOGI(TAG, "GENIE_EVT_SDK_COLOR_ACTION");
|
ESP_LOGI(TAG, "GENIE_EVT_SDK_COLOR_ACTION");
|
||||||
#ifdef CONFIG_MESH_MODEL_HSL_SRV
|
#ifdef CONFIG_MESH_MODEL_HSL_SRV
|
||||||
uint8_t *p_data = p_arg;
|
uint8_t *p_data = (uint8_t *)p_arg;
|
||||||
|
|
||||||
uint16_t lightness = *p_data++;
|
uint16_t lightness = *p_data++;
|
||||||
lightness += (*p_data++ << 8);
|
lightness += (*p_data++ << 8);
|
||||||
@@ -1064,7 +1084,7 @@ static void example_ble_mesh_generic_server_cb(esp_ble_mesh_generic_server_cb_ev
|
|||||||
case ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT:
|
case ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT:
|
||||||
ESP_LOGI(TAG, "ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT");
|
ESP_LOGI(TAG, "ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT");
|
||||||
if (param->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET) {
|
if (param->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET) {
|
||||||
esp_ble_mesh_gen_onoff_srv_t *srv = param->model->user_data;
|
esp_ble_mesh_gen_onoff_srv_t *srv = (esp_ble_mesh_gen_onoff_srv_t *)param->model->user_data;
|
||||||
ESP_LOGI(TAG, "onoff: 0x%02x", srv->state.onoff);
|
ESP_LOGI(TAG, "onoff: 0x%02x", srv->state.onoff);
|
||||||
esp_ble_mesh_server_model_send_msg(param->model, ¶m->ctx,
|
esp_ble_mesh_server_model_send_msg(param->model, ¶m->ctx,
|
||||||
ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_STATUS, sizeof(srv->state.onoff), &srv->state.onoff);
|
ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_STATUS, sizeof(srv->state.onoff), &srv->state.onoff);
|
||||||
@@ -1080,7 +1100,7 @@ static void example_ble_mesh_generic_server_cb(esp_ble_mesh_generic_server_cb_ev
|
|||||||
param->value.set.onoff.trans_time, param->value.set.onoff.delay);
|
param->value.set.onoff.trans_time, param->value.set.onoff.delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_ble_mesh_gen_onoff_srv_t *srv = param->model->user_data;
|
esp_ble_mesh_gen_onoff_srv_t *srv = (esp_ble_mesh_gen_onoff_srv_t *)param->model->user_data;
|
||||||
if (param->value.set.onoff.op_en == false) {
|
if (param->value.set.onoff.op_en == false) {
|
||||||
srv->state.onoff = param->value.set.onoff.onoff;
|
srv->state.onoff = param->value.set.onoff.onoff;
|
||||||
} else {
|
} else {
|
||||||
@@ -1287,7 +1307,7 @@ static esp_err_t ble_mesh_init(void)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT));
|
ESP_ERROR_CHECK(esp_ble_mesh_node_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT)));
|
||||||
|
|
||||||
if (esp_ble_mesh_node_is_provisioned()) {
|
if (esp_ble_mesh_node_is_provisioned()) {
|
||||||
ESP_LOGW(TAG, "node already provisioned");
|
ESP_LOGW(TAG, "node already provisioned");
|
||||||
|
@@ -9,14 +9,13 @@
|
|||||||
#ifndef _BOARD_H_
|
#ifndef _BOARD_H_
|
||||||
#define _BOARD_H_
|
#define _BOARD_H_
|
||||||
|
|
||||||
#include "driver/gpio.h"
|
|
||||||
|
|
||||||
#include "lightbulb.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /**< __cplusplus */
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
#include "lightbulb.h"
|
||||||
|
|
||||||
#define LED_ON 1
|
#define LED_ON 1
|
||||||
#define LED_OFF 0
|
#define LED_OFF 0
|
||||||
|
|
||||||
@@ -81,4 +80,4 @@ uint8_t *mac_str2hex(const char *mac_str, uint8_t *mac_hex);
|
|||||||
}
|
}
|
||||||
#endif /**< __cplusplus */
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
#endif
|
#endif /* _BOARD_H_ */
|
||||||
|
@@ -7,10 +7,18 @@
|
|||||||
#ifndef _BLE_MESH_EXAMPLE_INIT_H_
|
#ifndef _BLE_MESH_EXAMPLE_INIT_H_
|
||||||
#define _BLE_MESH_EXAMPLE_INIT_H_
|
#define _BLE_MESH_EXAMPLE_INIT_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
|
|
||||||
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid);
|
void ble_mesh_get_dev_uuid(uint8_t *dev_uuid);
|
||||||
|
|
||||||
esp_err_t bluetooth_init(void);
|
esp_err_t bluetooth_init(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
#endif /* _BLE_MESH_EXAMPLE_INIT_H_ */
|
#endif /* _BLE_MESH_EXAMPLE_INIT_H_ */
|
||||||
|
@@ -7,6 +7,10 @@
|
|||||||
#ifndef _BLE_MESH_EXAMPLE_NVS_H_
|
#ifndef _BLE_MESH_EXAMPLE_NVS_H_
|
||||||
#define _BLE_MESH_EXAMPLE_NVS_H_
|
#define _BLE_MESH_EXAMPLE_NVS_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
#include "nvs_flash.h"
|
#include "nvs_flash.h"
|
||||||
@@ -21,4 +25,8 @@ esp_err_t ble_mesh_nvs_restore(nvs_handle_t handle, const char *key, void *data,
|
|||||||
|
|
||||||
esp_err_t ble_mesh_nvs_erase(nvs_handle_t handle, const char *key);
|
esp_err_t ble_mesh_nvs_erase(nvs_handle_t handle, const char *key);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
#endif /* _BLE_MESH_EXAMPLE_NVS_H_ */
|
#endif /* _BLE_MESH_EXAMPLE_NVS_H_ */
|
||||||
|
@@ -7,6 +7,10 @@
|
|||||||
#ifndef _BLE_MESH_FAST_PROV_CLIENT_MODEL_H_
|
#ifndef _BLE_MESH_FAST_PROV_CLIENT_MODEL_H_
|
||||||
#define _BLE_MESH_FAST_PROV_CLIENT_MODEL_H_
|
#define _BLE_MESH_FAST_PROV_CLIENT_MODEL_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "esp_ble_mesh_defs.h"
|
#include "esp_ble_mesh_defs.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -25,4 +29,8 @@ esp_err_t example_fast_prov_client_recv_status(esp_ble_mesh_model_t *model,
|
|||||||
esp_ble_mesh_msg_ctx_t *ctx,
|
esp_ble_mesh_msg_ctx_t *ctx,
|
||||||
uint16_t len, const uint8_t *data);
|
uint16_t len, const uint8_t *data);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _BLE_MESH_FAST_PROV_CLIENT_MODEL_H_ */
|
#endif /* _BLE_MESH_FAST_PROV_CLIENT_MODEL_H_ */
|
||||||
|
@@ -7,6 +7,10 @@
|
|||||||
#ifndef _BLE_MESH_FAST_PROV_COMMON_H_
|
#ifndef _BLE_MESH_FAST_PROV_COMMON_H_
|
||||||
#define _BLE_MESH_FAST_PROV_COMMON_H_
|
#define _BLE_MESH_FAST_PROV_COMMON_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "esp_ble_mesh_defs.h"
|
#include "esp_ble_mesh_defs.h"
|
||||||
#include "esp_ble_mesh_config_model_api.h"
|
#include "esp_ble_mesh_config_model_api.h"
|
||||||
|
|
||||||
@@ -109,4 +113,8 @@ typedef struct {
|
|||||||
uint8_t status_act; /* Indicate the result of action */
|
uint8_t status_act; /* Indicate the result of action */
|
||||||
} example_fast_prov_net_key_status_t;
|
} example_fast_prov_net_key_status_t;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _BLE_MESH_FAST_PROV_COMMON_H_ */
|
#endif /* _BLE_MESH_FAST_PROV_COMMON_H_ */
|
||||||
|
@@ -7,6 +7,10 @@
|
|||||||
#ifndef _BLE_MESH_FAST_PROV_OPERATION_H_
|
#ifndef _BLE_MESH_FAST_PROV_OPERATION_H_
|
||||||
#define _BLE_MESH_FAST_PROV_OPERATION_H_
|
#define _BLE_MESH_FAST_PROV_OPERATION_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "ble_mesh_fast_prov_common.h"
|
#include "ble_mesh_fast_prov_common.h"
|
||||||
|
|
||||||
esp_err_t example_store_node_info(const uint8_t uuid[16], uint16_t node_addr,
|
esp_err_t example_store_node_info(const uint8_t uuid[16], uint16_t node_addr,
|
||||||
@@ -58,4 +62,8 @@ esp_err_t example_send_fast_prov_status_msg(esp_ble_mesh_model_t *model,
|
|||||||
esp_ble_mesh_msg_ctx_t *ctx,
|
esp_ble_mesh_msg_ctx_t *ctx,
|
||||||
uint32_t opcode, struct net_buf_simple *msg);
|
uint32_t opcode, struct net_buf_simple *msg);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _BLE_MESH_FAST_PROV_OPERATION_H_ */
|
#endif /* _BLE_MESH_FAST_PROV_OPERATION_H_ */
|
||||||
|
@@ -7,6 +7,10 @@
|
|||||||
#ifndef _BLE_MESH_FAST_PROV_SERVER_MODEL_H_
|
#ifndef _BLE_MESH_FAST_PROV_SERVER_MODEL_H_
|
||||||
#define _BLE_MESH_FAST_PROV_SERVER_MODEL_H_
|
#define _BLE_MESH_FAST_PROV_SERVER_MODEL_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "ble_mesh_fast_prov_common.h"
|
#include "ble_mesh_fast_prov_common.h"
|
||||||
|
|
||||||
#define DISABLE_FAST_PROV_TIMEOUT K_SECONDS(10)
|
#define DISABLE_FAST_PROV_TIMEOUT K_SECONDS(10)
|
||||||
@@ -91,4 +95,8 @@ esp_err_t example_handle_fast_prov_status_send_comp_evt(int err_code, uint32_t o
|
|||||||
|
|
||||||
esp_err_t example_fast_prov_server_init(esp_ble_mesh_model_t *model);
|
esp_err_t example_fast_prov_server_init(esp_ble_mesh_model_t *model);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _BLE_MESH_FAST_PROV_SERVER_MODEL_H_ */
|
#endif /* _BLE_MESH_FAST_PROV_SERVER_MODEL_H_ */
|
||||||
|
@@ -10,6 +10,10 @@
|
|||||||
#ifndef _BOARD_H_
|
#ifndef _BOARD_H_
|
||||||
#define _BOARD_H_
|
#define _BOARD_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
#include "esp_ble_mesh_defs.h"
|
#include "esp_ble_mesh_defs.h"
|
||||||
|
|
||||||
@@ -53,4 +57,8 @@ void board_led_operation(uint8_t r, uint8_t g, uint8_t b);
|
|||||||
|
|
||||||
void board_init(void);
|
void board_init(void);
|
||||||
|
|
||||||
#endif
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _BOARD_H_ */
|
||||||
|
@@ -61,13 +61,7 @@ typedef struct {
|
|||||||
uint8_t tid;
|
uint8_t tid;
|
||||||
} esp_ble_mesh_node_info_t;
|
} esp_ble_mesh_node_info_t;
|
||||||
|
|
||||||
static esp_ble_mesh_node_info_t nodes[CONFIG_BLE_MESH_MAX_PROV_NODES] = {
|
static esp_ble_mesh_node_info_t nodes[CONFIG_BLE_MESH_MAX_PROV_NODES] = {0};
|
||||||
[0 ... (CONFIG_BLE_MESH_MAX_PROV_NODES - 1)] = {
|
|
||||||
.unicast = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
|
||||||
.elem_num = 0,
|
|
||||||
.onoff = LED_OFF,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static uint16_t last_node_idx;
|
static uint16_t last_node_idx;
|
||||||
static uint16_t curr_node_idx;
|
static uint16_t curr_node_idx;
|
||||||
@@ -86,22 +80,22 @@ static esp_ble_mesh_client_t directed_forwarding_client;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static esp_ble_mesh_cfg_srv_t config_server = {
|
static esp_ble_mesh_cfg_srv_t config_server = {
|
||||||
|
/* 3 transmissions with 20ms interval */
|
||||||
|
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.relay = ESP_BLE_MESH_RELAY_DISABLED,
|
.relay = ESP_BLE_MESH_RELAY_DISABLED,
|
||||||
|
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
||||||
#if defined(CONFIG_BLE_MESH_FRIEND)
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
|
||||||
#else
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
||||||
#else
|
#else
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_BLE_MESH_FRIEND)
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
||||||
|
#else
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
||||||
#endif
|
#endif
|
||||||
.default_ttl = 7,
|
.default_ttl = 7,
|
||||||
/* 3 transmissions with 20ms interval */
|
|
||||||
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#if CONFIG_BLE_MESH_DF_SRV
|
#if CONFIG_BLE_MESH_DF_SRV
|
||||||
@@ -168,8 +162,8 @@ static esp_ble_mesh_elem_t elements[] = {
|
|||||||
|
|
||||||
static esp_ble_mesh_comp_t composition = {
|
static esp_ble_mesh_comp_t composition = {
|
||||||
.cid = CID_ESP,
|
.cid = CID_ESP,
|
||||||
.elements = elements,
|
|
||||||
.element_count = ARRAY_SIZE(elements),
|
.element_count = ARRAY_SIZE(elements),
|
||||||
|
.elements = elements,
|
||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_prov_t provision = {
|
static esp_ble_mesh_prov_t provision = {
|
||||||
@@ -432,10 +426,10 @@ static void recv_unprov_adv_pkt(uint8_t dev_uuid[16], uint8_t addr[BD_ADDR_LEN],
|
|||||||
ESP_LOGI(TAG, "oob info: %d, bearer: %s", oob_info, (bearer & ESP_BLE_MESH_PROV_ADV) ? "PB-ADV" : "PB-GATT");
|
ESP_LOGI(TAG, "oob info: %d, bearer: %s", oob_info, (bearer & ESP_BLE_MESH_PROV_ADV) ? "PB-ADV" : "PB-GATT");
|
||||||
|
|
||||||
memcpy(add_dev.addr, addr, BD_ADDR_LEN);
|
memcpy(add_dev.addr, addr, BD_ADDR_LEN);
|
||||||
add_dev.addr_type = (uint8_t)addr_type;
|
add_dev.addr_type = (esp_ble_mesh_addr_type_t)addr_type;
|
||||||
memcpy(add_dev.uuid, dev_uuid, 16);
|
memcpy(add_dev.uuid, dev_uuid, 16);
|
||||||
add_dev.oob_info = oob_info;
|
add_dev.oob_info = oob_info;
|
||||||
add_dev.bearer = (uint8_t)bearer;
|
add_dev.bearer = (esp_ble_mesh_prov_bearer_t)bearer;
|
||||||
/* Note: If unprovisioned device adv packets have not been received, we should not add
|
/* Note: If unprovisioned device adv packets have not been received, we should not add
|
||||||
device with ADD_DEV_START_PROV_NOW_FLAG set. */
|
device with ADD_DEV_START_PROV_NOW_FLAG set. */
|
||||||
err = esp_ble_mesh_provisioner_add_unprov_dev(&add_dev,
|
err = esp_ble_mesh_provisioner_add_unprov_dev(&add_dev,
|
||||||
@@ -770,7 +764,7 @@ static void example_ble_mesh_directed_forwarding_client_cb(esp_ble_mesh_df_clien
|
|||||||
esp_ble_mesh_df_client_cb_param_t *param)
|
esp_ble_mesh_df_client_cb_param_t *param)
|
||||||
{
|
{
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case ESP_BLE_MESH_DF_CLIENT_RECV_SET_RSP_EVT:
|
case ESP_BLE_MESH_DF_CLIENT_RECV_SET_RSP_EVT: {
|
||||||
ESP_LOGW(TAG, "Directed Forwarding Set, opcode 0x%04x, from 0x%04x", param->params->opcode, param->params->ctx.addr);
|
ESP_LOGW(TAG, "Directed Forwarding Set, opcode 0x%04x, from 0x%04x", param->params->opcode, param->params->ctx.addr);
|
||||||
switch (param->params->opcode) {
|
switch (param->params->opcode) {
|
||||||
case ESP_BLE_MESH_MODEL_OP_DIRECTED_CONTROL_SET:
|
case ESP_BLE_MESH_MODEL_OP_DIRECTED_CONTROL_SET:
|
||||||
@@ -782,11 +776,13 @@ static void example_ble_mesh_directed_forwarding_client_cb(esp_ble_mesh_df_clien
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ESP_BLE_MESH_DF_CLIENT_SEND_TIMEOUT_EVT:
|
}
|
||||||
|
case ESP_BLE_MESH_DF_CLIENT_SEND_TIMEOUT_EVT: {
|
||||||
ESP_LOGW(TAG, "Directed Forwarding Timeout, opcode 0x%04x, to 0x%04x", param->params->opcode, param->params->ctx.addr);
|
ESP_LOGW(TAG, "Directed Forwarding Timeout, opcode 0x%04x, to 0x%04x", param->params->opcode, param->params->ctx.addr);
|
||||||
esp_ble_mesh_node_info_t node = {.unicast = param->params->ctx.addr};
|
esp_ble_mesh_node_info_t node = {.unicast = param->params->ctx.addr};
|
||||||
example_ble_mesh_send_directed_forwarding_srv_control_set(&node);
|
example_ble_mesh_send_directed_forwarding_srv_control_set(&node);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -795,9 +791,10 @@ static void example_ble_mesh_directed_forwarding_client_cb(esp_ble_mesh_df_clien
|
|||||||
static void example_ble_mesh_directed_forwarding_server_cb(esp_ble_mesh_df_server_cb_event_t event,
|
static void example_ble_mesh_directed_forwarding_server_cb(esp_ble_mesh_df_server_cb_event_t event,
|
||||||
esp_ble_mesh_df_server_cb_param_t *param)
|
esp_ble_mesh_df_server_cb_param_t *param)
|
||||||
{
|
{
|
||||||
esp_ble_mesh_df_server_table_change_t change = {0};
|
esp_ble_mesh_df_server_table_change_t change;
|
||||||
esp_ble_mesh_uar_t path_origin;
|
esp_ble_mesh_uar_t path_origin;
|
||||||
esp_ble_mesh_uar_t path_target;
|
esp_ble_mesh_uar_t path_target;
|
||||||
|
memset(&change, 0, sizeof(esp_ble_mesh_df_server_table_change_t));
|
||||||
|
|
||||||
if (event == ESP_BLE_MESH_DF_SERVER_TABLE_CHANGE_EVT) {
|
if (event == ESP_BLE_MESH_DF_SERVER_TABLE_CHANGE_EVT) {
|
||||||
memcpy(&change, ¶m->value.table_change, sizeof(esp_ble_mesh_df_server_table_change_t));
|
memcpy(&change, ¶m->value.table_change, sizeof(esp_ble_mesh_df_server_table_change_t));
|
||||||
@@ -817,6 +814,7 @@ static void example_ble_mesh_directed_forwarding_server_cb(esp_ble_mesh_df_serve
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ESP_LOGW(TAG, "Unknown action %d", change.action);
|
ESP_LOGW(TAG, "Unknown action %d", change.action);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -857,7 +855,7 @@ static esp_err_t ble_mesh_init(void)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_ble_mesh_provisioner_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);
|
err = esp_ble_mesh_provisioner_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT));
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Failed to enable mesh provisioner (err %d)", err);
|
ESP_LOGE(TAG, "Failed to enable mesh provisioner (err %d)", err);
|
||||||
return err;
|
return err;
|
||||||
|
@@ -10,6 +10,10 @@
|
|||||||
#ifndef _BOARD_H_
|
#ifndef _BOARD_H_
|
||||||
#define _BOARD_H_
|
#define _BOARD_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
|
|
||||||
#if defined(CONFIG_BLE_MESH_ESP_WROOM_32)
|
#if defined(CONFIG_BLE_MESH_ESP_WROOM_32)
|
||||||
@@ -44,4 +48,8 @@ void board_led_operation(uint8_t r, uint8_t g, uint8_t b);
|
|||||||
void board_led_operation_auto_close(uint8_t r, uint8_t g, uint8_t b, uint32_t ms);
|
void board_led_operation_auto_close(uint8_t r, uint8_t g, uint8_t b, uint32_t ms);
|
||||||
void board_init(void);
|
void board_init(void);
|
||||||
|
|
||||||
#endif
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _BOARD_H_ */
|
||||||
|
@@ -49,22 +49,22 @@ static uint8_t dev_uuid[16] = { 0xaa, 0x55 };
|
|||||||
static uint8_t app_key[16] = {0};
|
static uint8_t app_key[16] = {0};
|
||||||
|
|
||||||
static esp_ble_mesh_cfg_srv_t config_server = {
|
static esp_ble_mesh_cfg_srv_t config_server = {
|
||||||
|
/* 3 transmissions with 20ms interval */
|
||||||
|
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.relay = ESP_BLE_MESH_RELAY_ENABLED,
|
.relay = ESP_BLE_MESH_RELAY_ENABLED,
|
||||||
|
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
||||||
#if defined(CONFIG_BLE_MESH_FRIEND)
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
|
||||||
#else
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
||||||
#else
|
#else
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_BLE_MESH_FRIEND)
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
||||||
|
#else
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
||||||
#endif
|
#endif
|
||||||
.default_ttl = 7,
|
.default_ttl = 7,
|
||||||
/* 3 transmissions with 20ms interval */
|
|
||||||
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#if CONFIG_BLE_MESH_DF_SRV
|
#if CONFIG_BLE_MESH_DF_SRV
|
||||||
@@ -96,8 +96,10 @@ static esp_ble_mesh_df_srv_t directed_forwarding_server = {
|
|||||||
|
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_0, 2 + 3, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_0, 2 + 3, ROLE_NODE);
|
||||||
static esp_ble_mesh_gen_onoff_srv_t onoff_server_0 = {
|
static esp_ble_mesh_gen_onoff_srv_t onoff_server_0 = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.rsp_ctrl ={
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_model_t root_models[] = {
|
static esp_ble_mesh_model_t root_models[] = {
|
||||||
@@ -124,8 +126,8 @@ static esp_ble_mesh_elem_t elements[] = {
|
|||||||
|
|
||||||
static esp_ble_mesh_comp_t composition = {
|
static esp_ble_mesh_comp_t composition = {
|
||||||
.cid = CID_ESP,
|
.cid = CID_ESP,
|
||||||
.elements = elements,
|
|
||||||
.element_count = ARRAY_SIZE(elements),
|
.element_count = ARRAY_SIZE(elements),
|
||||||
|
.elements = elements,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Disable OOB security for SILabs Android app */
|
/* Disable OOB security for SILabs Android app */
|
||||||
@@ -134,8 +136,8 @@ static esp_ble_mesh_prov_t provision = {
|
|||||||
#if 0
|
#if 0
|
||||||
.output_size = 4,
|
.output_size = 4,
|
||||||
.output_actions = ESP_BLE_MESH_DISPLAY_NUMBER,
|
.output_actions = ESP_BLE_MESH_DISPLAY_NUMBER,
|
||||||
.input_actions = ESP_BLE_MESH_PUSH,
|
|
||||||
.input_size = 4,
|
.input_size = 4,
|
||||||
|
.input_actions = ESP_BLE_MESH_PUSH,
|
||||||
#else
|
#else
|
||||||
.output_size = 0,
|
.output_size = 0,
|
||||||
.output_actions = 0,
|
.output_actions = 0,
|
||||||
@@ -200,7 +202,7 @@ static void example_handle_gen_onoff_msg(esp_ble_mesh_model_t *model,
|
|||||||
esp_ble_mesh_msg_ctx_t *ctx,
|
esp_ble_mesh_msg_ctx_t *ctx,
|
||||||
esp_ble_mesh_server_recv_gen_onoff_set_t *set)
|
esp_ble_mesh_server_recv_gen_onoff_set_t *set)
|
||||||
{
|
{
|
||||||
esp_ble_mesh_gen_onoff_srv_t *srv = model->user_data;
|
esp_ble_mesh_gen_onoff_srv_t *srv = (esp_ble_mesh_gen_onoff_srv_t *)model->user_data;
|
||||||
|
|
||||||
switch (ctx->recv_op) {
|
switch (ctx->recv_op) {
|
||||||
case ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET:
|
case ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET:
|
||||||
@@ -305,7 +307,7 @@ static void example_ble_mesh_generic_server_cb(esp_ble_mesh_generic_server_cb_ev
|
|||||||
case ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT:
|
case ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT:
|
||||||
ESP_LOGI(TAG, "ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT");
|
ESP_LOGI(TAG, "ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT");
|
||||||
if (param->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET) {
|
if (param->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET) {
|
||||||
srv = param->model->user_data;
|
srv = (esp_ble_mesh_gen_onoff_srv_t *)param->model->user_data;
|
||||||
ESP_LOGI(TAG, "onoff 0x%02x", srv->state.onoff);
|
ESP_LOGI(TAG, "onoff 0x%02x", srv->state.onoff);
|
||||||
example_handle_gen_onoff_msg(param->model, ¶m->ctx, NULL);
|
example_handle_gen_onoff_msg(param->model, ¶m->ctx, NULL);
|
||||||
}
|
}
|
||||||
@@ -365,9 +367,10 @@ static void example_ble_mesh_config_server_cb(esp_ble_mesh_cfg_server_cb_event_t
|
|||||||
static void example_ble_mesh_directed_forwarding_server_cb(esp_ble_mesh_df_server_cb_event_t event,
|
static void example_ble_mesh_directed_forwarding_server_cb(esp_ble_mesh_df_server_cb_event_t event,
|
||||||
esp_ble_mesh_df_server_cb_param_t *param)
|
esp_ble_mesh_df_server_cb_param_t *param)
|
||||||
{
|
{
|
||||||
esp_ble_mesh_df_server_table_change_t change = {0};
|
esp_ble_mesh_df_server_table_change_t change;
|
||||||
esp_ble_mesh_uar_t path_origin;
|
esp_ble_mesh_uar_t path_origin;
|
||||||
esp_ble_mesh_uar_t path_target;
|
esp_ble_mesh_uar_t path_target;
|
||||||
|
memset(&change, 0, sizeof(esp_ble_mesh_df_server_table_change_t));
|
||||||
|
|
||||||
if (event == ESP_BLE_MESH_DF_SERVER_TABLE_CHANGE_EVT) {
|
if (event == ESP_BLE_MESH_DF_SERVER_TABLE_CHANGE_EVT) {
|
||||||
memcpy(&change, ¶m->value.table_change, sizeof(esp_ble_mesh_df_server_table_change_t));
|
memcpy(&change, ¶m->value.table_change, sizeof(esp_ble_mesh_df_server_table_change_t));
|
||||||
@@ -456,7 +459,7 @@ static esp_err_t ble_mesh_init(void)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV|ESP_BLE_MESH_PROV_GATT);
|
err = esp_ble_mesh_node_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT));
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Failed to enable mesh node (err %d)", err);
|
ESP_LOGE(TAG, "Failed to enable mesh node (err %d)", err);
|
||||||
return err;
|
return err;
|
||||||
|
@@ -41,22 +41,22 @@ static const esp_ble_mesh_client_op_pair_t fast_prov_cli_op_pair[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_cfg_srv_t config_server = {
|
static esp_ble_mesh_cfg_srv_t config_server = {
|
||||||
|
/* 3 transmissions with a 20ms interval */
|
||||||
|
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.relay = ESP_BLE_MESH_RELAY_DISABLED,
|
.relay = ESP_BLE_MESH_RELAY_DISABLED,
|
||||||
|
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
||||||
#if defined(CONFIG_BLE_MESH_FRIEND)
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
|
||||||
#else
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
||||||
#else
|
#else
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_BLE_MESH_FRIEND)
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
||||||
|
#else
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
||||||
#endif
|
#endif
|
||||||
.default_ttl = 7,
|
.default_ttl = 7,
|
||||||
/* 3 transmissions with a 20ms interval */
|
|
||||||
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
};
|
};
|
||||||
esp_ble_mesh_client_t config_client;
|
esp_ble_mesh_client_t config_client;
|
||||||
esp_ble_mesh_client_t gen_onoff_client;
|
esp_ble_mesh_client_t gen_onoff_client;
|
||||||
@@ -89,8 +89,8 @@ static esp_ble_mesh_elem_t elements[] = {
|
|||||||
|
|
||||||
static esp_ble_mesh_comp_t comp = {
|
static esp_ble_mesh_comp_t comp = {
|
||||||
.cid = CID_ESP,
|
.cid = CID_ESP,
|
||||||
.elements = elements,
|
|
||||||
.element_count = ARRAY_SIZE(elements),
|
.element_count = ARRAY_SIZE(elements),
|
||||||
|
.elements = elements,
|
||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_prov_t prov = {
|
static esp_ble_mesh_prov_t prov = {
|
||||||
@@ -213,10 +213,10 @@ static void example_recv_unprov_adv_pkt(uint8_t dev_uuid[16], uint8_t addr[BLE_M
|
|||||||
|
|
||||||
add:
|
add:
|
||||||
memcpy(add_dev.addr, addr, 6);
|
memcpy(add_dev.addr, addr, 6);
|
||||||
add_dev.addr_type = (uint8_t)addr_type;
|
add_dev.addr_type = (esp_ble_mesh_addr_type_t)addr_type;
|
||||||
memcpy(add_dev.uuid, dev_uuid, 16);
|
memcpy(add_dev.uuid, dev_uuid, 16);
|
||||||
add_dev.oob_info = oob_info;
|
add_dev.oob_info = oob_info;
|
||||||
add_dev.bearer = (uint8_t)bearer;
|
add_dev.bearer = (esp_ble_mesh_prov_bearer_t)bearer;
|
||||||
flag = ADD_DEV_RM_AFTER_PROV_FLAG | ADD_DEV_START_PROV_NOW_FLAG | ADD_DEV_FLUSHABLE_DEV_FLAG;
|
flag = ADD_DEV_RM_AFTER_PROV_FLAG | ADD_DEV_START_PROV_NOW_FLAG | ADD_DEV_FLUSHABLE_DEV_FLAG;
|
||||||
err = esp_ble_mesh_provisioner_add_unprov_dev(&add_dev, flag);
|
err = esp_ble_mesh_provisioner_add_unprov_dev(&add_dev, flag);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
@@ -557,7 +557,7 @@ static esp_err_t ble_mesh_init(void)
|
|||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_ble_mesh_provisioner_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);
|
err = esp_ble_mesh_provisioner_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT));
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "%s: Failed to enable provisioning", __func__);
|
ESP_LOGE(TAG, "%s: Failed to enable provisioning", __func__);
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
|
@@ -8,6 +8,10 @@
|
|||||||
#ifndef _BOARD_H_
|
#ifndef _BOARD_H_
|
||||||
#define _BOARD_H_
|
#define _BOARD_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
#include "esp_ble_mesh_defs.h"
|
#include "esp_ble_mesh_defs.h"
|
||||||
@@ -53,4 +57,8 @@ void board_led_operation(uint8_t pin, uint8_t onoff);
|
|||||||
|
|
||||||
esp_err_t board_init(void);
|
esp_err_t board_init(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -48,22 +48,22 @@ esp_ble_mesh_client_t config_client;
|
|||||||
|
|
||||||
/* Configuration Server Model user_data */
|
/* Configuration Server Model user_data */
|
||||||
esp_ble_mesh_cfg_srv_t config_server = {
|
esp_ble_mesh_cfg_srv_t config_server = {
|
||||||
|
/* 3 transmissions with 20ms interval */
|
||||||
|
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.relay = ESP_BLE_MESH_RELAY_ENABLED,
|
.relay = ESP_BLE_MESH_RELAY_ENABLED,
|
||||||
|
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.beacon = ESP_BLE_MESH_BEACON_DISABLED,
|
.beacon = ESP_BLE_MESH_BEACON_DISABLED,
|
||||||
#if defined(CONFIG_BLE_MESH_FRIEND)
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
|
||||||
#else
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
||||||
#else
|
#else
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_BLE_MESH_FRIEND)
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
||||||
|
#else
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
||||||
#endif
|
#endif
|
||||||
.default_ttl = 7,
|
.default_ttl = 7,
|
||||||
/* 3 transmissions with 20ms interval */
|
|
||||||
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Fast Prov Client Model user_data */
|
/* Fast Prov Client Model user_data */
|
||||||
@@ -77,6 +77,7 @@ example_fast_prov_server_t fast_prov_server = {
|
|||||||
.primary_role = false,
|
.primary_role = false,
|
||||||
.max_node_num = 6,
|
.max_node_num = 6,
|
||||||
.prov_node_cnt = 0x0,
|
.prov_node_cnt = 0x0,
|
||||||
|
.app_idx = ESP_BLE_MESH_KEY_UNUSED,
|
||||||
.unicast_min = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
.unicast_min = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
||||||
.unicast_max = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
.unicast_max = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
||||||
.unicast_cur = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
.unicast_cur = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
||||||
@@ -84,7 +85,6 @@ example_fast_prov_server_t fast_prov_server = {
|
|||||||
.flags = 0x0,
|
.flags = 0x0,
|
||||||
.iv_index = 0x0,
|
.iv_index = 0x0,
|
||||||
.net_idx = ESP_BLE_MESH_KEY_UNUSED,
|
.net_idx = ESP_BLE_MESH_KEY_UNUSED,
|
||||||
.app_idx = ESP_BLE_MESH_KEY_UNUSED,
|
|
||||||
.group_addr = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
.group_addr = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
||||||
.prim_prov_addr = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
.prim_prov_addr = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
||||||
.match_len = 0x0,
|
.match_len = 0x0,
|
||||||
@@ -94,8 +94,10 @@ example_fast_prov_server_t fast_prov_server = {
|
|||||||
|
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub, 2 + 3, ROLE_FAST_PROV);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub, 2 + 3, ROLE_FAST_PROV);
|
||||||
static esp_ble_mesh_gen_onoff_srv_t onoff_server = {
|
static esp_ble_mesh_gen_onoff_srv_t onoff_server = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.rsp_ctrl = {
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_model_op_t fast_prov_srv_op[] = {
|
static esp_ble_mesh_model_op_t fast_prov_srv_op[] = {
|
||||||
@@ -134,8 +136,8 @@ static esp_ble_mesh_elem_t elements[] = {
|
|||||||
|
|
||||||
static esp_ble_mesh_comp_t comp = {
|
static esp_ble_mesh_comp_t comp = {
|
||||||
.cid = CID_ESP,
|
.cid = CID_ESP,
|
||||||
.elements = elements,
|
|
||||||
.element_count = ARRAY_SIZE(elements),
|
.element_count = ARRAY_SIZE(elements),
|
||||||
|
.elements = elements,
|
||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_prov_t prov = {
|
static esp_ble_mesh_prov_t prov = {
|
||||||
@@ -311,9 +313,9 @@ static void example_recv_unprov_adv_pkt(uint8_t dev_uuid[16], uint8_t addr[BLE_M
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add_dev.addr_type = (uint8_t)addr_type;
|
add_dev.addr_type = (esp_ble_mesh_addr_type_t)addr_type;
|
||||||
add_dev.oob_info = oob_info;
|
add_dev.oob_info = oob_info;
|
||||||
add_dev.bearer = (uint8_t)bearer;
|
add_dev.bearer = (esp_ble_mesh_prov_bearer_t)bearer;
|
||||||
memcpy(add_dev.uuid, dev_uuid, 16);
|
memcpy(add_dev.uuid, dev_uuid, 16);
|
||||||
memcpy(add_dev.addr, addr, BLE_MESH_ADDR_LEN);
|
memcpy(add_dev.addr, addr, BLE_MESH_ADDR_LEN);
|
||||||
flag = ADD_DEV_RM_AFTER_PROV_FLAG | ADD_DEV_START_PROV_NOW_FLAG | ADD_DEV_FLUSHABLE_DEV_FLAG;
|
flag = ADD_DEV_RM_AFTER_PROV_FLAG | ADD_DEV_START_PROV_NOW_FLAG | ADD_DEV_FLUSHABLE_DEV_FLAG;
|
||||||
@@ -454,8 +456,8 @@ static void example_ble_mesh_custom_model_cb(esp_ble_mesh_model_cb_event_t event
|
|||||||
case ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NODE_GROUP_DELETE: {
|
case ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NODE_GROUP_DELETE: {
|
||||||
ESP_LOGI(TAG, "%s: Fast prov server receives msg, opcode 0x%04" PRIx32, __func__, opcode);
|
ESP_LOGI(TAG, "%s: Fast prov server receives msg, opcode 0x%04" PRIx32, __func__, opcode);
|
||||||
struct net_buf_simple buf = {
|
struct net_buf_simple buf = {
|
||||||
.len = param->model_operation.length,
|
|
||||||
.data = param->model_operation.msg,
|
.data = param->model_operation.msg,
|
||||||
|
.len = param->model_operation.length,
|
||||||
};
|
};
|
||||||
err = example_fast_prov_server_recv_msg(param->model_operation.model,
|
err = example_fast_prov_server_recv_msg(param->model_operation.model,
|
||||||
param->model_operation.ctx, &buf);
|
param->model_operation.ctx, &buf);
|
||||||
@@ -733,7 +735,7 @@ static esp_err_t ble_mesh_init(void)
|
|||||||
|
|
||||||
k_delayed_work_init(&send_self_prov_node_addr_timer, example_send_self_prov_node_addr);
|
k_delayed_work_init(&send_self_prov_node_addr_timer, example_send_self_prov_node_addr);
|
||||||
|
|
||||||
err = esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);
|
err = esp_ble_mesh_node_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT));
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "%s: Failed to enable node provisioning", __func__);
|
ESP_LOGE(TAG, "%s: Failed to enable node provisioning", __func__);
|
||||||
return err;
|
return err;
|
||||||
|
@@ -10,6 +10,10 @@
|
|||||||
#ifndef _BOARD_H_
|
#ifndef _BOARD_H_
|
||||||
#define _BOARD_H_
|
#define _BOARD_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
#include "esp_ble_mesh_defs.h"
|
#include "esp_ble_mesh_defs.h"
|
||||||
|
|
||||||
@@ -53,4 +57,8 @@ void board_led_operation(uint8_t pin, uint8_t onoff);
|
|||||||
|
|
||||||
void board_init(void);
|
void board_init(void);
|
||||||
|
|
||||||
#endif
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _BOARD_H_ */
|
||||||
|
@@ -48,22 +48,22 @@ static const char * NVS_KEY = "onoff_client";
|
|||||||
static esp_ble_mesh_client_t onoff_client;
|
static esp_ble_mesh_client_t onoff_client;
|
||||||
|
|
||||||
static esp_ble_mesh_cfg_srv_t config_server = {
|
static esp_ble_mesh_cfg_srv_t config_server = {
|
||||||
.relay = ESP_BLE_MESH_RELAY_ENABLED,
|
/* 3 transmissions with 20ms interval */
|
||||||
|
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
|
.relay = ESP_BLE_MESH_RELAY_DISABLED,
|
||||||
|
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
||||||
#if defined(CONFIG_BLE_MESH_FRIEND)
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
|
||||||
#else
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
||||||
#else
|
#else
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_BLE_MESH_FRIEND)
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
||||||
|
#else
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
||||||
#endif
|
#endif
|
||||||
.default_ttl = 7,
|
.default_ttl = 7,
|
||||||
/* 3 transmissions with 20ms interval */
|
|
||||||
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_cli_pub, 2 + 1, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_cli_pub, 2 + 1, ROLE_NODE);
|
||||||
@@ -79,8 +79,8 @@ static esp_ble_mesh_elem_t elements[] = {
|
|||||||
|
|
||||||
static esp_ble_mesh_comp_t composition = {
|
static esp_ble_mesh_comp_t composition = {
|
||||||
.cid = CID_ESP,
|
.cid = CID_ESP,
|
||||||
.elements = elements,
|
|
||||||
.element_count = ARRAY_SIZE(elements),
|
.element_count = ARRAY_SIZE(elements),
|
||||||
|
.elements = elements,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Disable OOB security for SILabs Android app */
|
/* Disable OOB security for SILabs Android app */
|
||||||
@@ -89,8 +89,8 @@ static esp_ble_mesh_prov_t provision = {
|
|||||||
#if 0
|
#if 0
|
||||||
.output_size = 4,
|
.output_size = 4,
|
||||||
.output_actions = ESP_BLE_MESH_DISPLAY_NUMBER,
|
.output_actions = ESP_BLE_MESH_DISPLAY_NUMBER,
|
||||||
.input_actions = ESP_BLE_MESH_PUSH,
|
|
||||||
.input_size = 4,
|
.input_size = 4,
|
||||||
|
.input_actions = ESP_BLE_MESH_PUSH,
|
||||||
#else
|
#else
|
||||||
.output_size = 0,
|
.output_size = 0,
|
||||||
.output_actions = 0,
|
.output_actions = 0,
|
||||||
@@ -279,7 +279,7 @@ static esp_err_t ble_mesh_init(void)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);
|
err = esp_ble_mesh_node_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT));
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Failed to enable mesh node (err %d)", err);
|
ESP_LOGE(TAG, "Failed to enable mesh node (err %d)", err);
|
||||||
return err;
|
return err;
|
||||||
|
@@ -10,6 +10,10 @@
|
|||||||
#ifndef _BOARD_H_
|
#ifndef _BOARD_H_
|
||||||
#define _BOARD_H_
|
#define _BOARD_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
|
|
||||||
#if defined(CONFIG_BLE_MESH_ESP_WROOM_32)
|
#if defined(CONFIG_BLE_MESH_ESP_WROOM_32)
|
||||||
@@ -52,4 +56,8 @@ void board_led_operation(uint8_t pin, uint8_t onoff);
|
|||||||
|
|
||||||
void board_init(void);
|
void board_init(void);
|
||||||
|
|
||||||
#endif
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _BOARD_H_ */
|
||||||
|
@@ -34,40 +34,46 @@ extern struct _led_state led_state[3];
|
|||||||
static uint8_t dev_uuid[16] = { 0xdd, 0xdd };
|
static uint8_t dev_uuid[16] = { 0xdd, 0xdd };
|
||||||
|
|
||||||
static esp_ble_mesh_cfg_srv_t config_server = {
|
static esp_ble_mesh_cfg_srv_t config_server = {
|
||||||
.relay = ESP_BLE_MESH_RELAY_ENABLED,
|
/* 3 transmissions with 20ms interval */
|
||||||
|
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
|
.relay = ESP_BLE_MESH_RELAY_DISABLED,
|
||||||
|
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
||||||
#if defined(CONFIG_BLE_MESH_FRIEND)
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
|
||||||
#else
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
||||||
#else
|
#else
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_BLE_MESH_FRIEND)
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
||||||
|
#else
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
||||||
#endif
|
#endif
|
||||||
.default_ttl = 7,
|
.default_ttl = 7,
|
||||||
/* 3 transmissions with 20ms interval */
|
|
||||||
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_0, 2 + 3, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_0, 2 + 3, ROLE_NODE);
|
||||||
static esp_ble_mesh_gen_onoff_srv_t onoff_server_0 = {
|
static esp_ble_mesh_gen_onoff_srv_t onoff_server_0 = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.rsp_ctrl = {
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_1, 2 + 3, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_1, 2 + 3, ROLE_NODE);
|
||||||
static esp_ble_mesh_gen_onoff_srv_t onoff_server_1 = {
|
static esp_ble_mesh_gen_onoff_srv_t onoff_server_1 = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
.rsp_ctrl = {
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_2, 2 + 3, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_2, 2 + 3, ROLE_NODE);
|
||||||
static esp_ble_mesh_gen_onoff_srv_t onoff_server_2 = {
|
static esp_ble_mesh_gen_onoff_srv_t onoff_server_2 = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.rsp_ctrl = {
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_model_t root_models[] = {
|
static esp_ble_mesh_model_t root_models[] = {
|
||||||
@@ -91,8 +97,8 @@ static esp_ble_mesh_elem_t elements[] = {
|
|||||||
|
|
||||||
static esp_ble_mesh_comp_t composition = {
|
static esp_ble_mesh_comp_t composition = {
|
||||||
.cid = CID_ESP,
|
.cid = CID_ESP,
|
||||||
.elements = elements,
|
|
||||||
.element_count = ARRAY_SIZE(elements),
|
.element_count = ARRAY_SIZE(elements),
|
||||||
|
.elements = elements,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Disable OOB security for SILabs Android app */
|
/* Disable OOB security for SILabs Android app */
|
||||||
@@ -101,8 +107,8 @@ static esp_ble_mesh_prov_t provision = {
|
|||||||
#if 0
|
#if 0
|
||||||
.output_size = 4,
|
.output_size = 4,
|
||||||
.output_actions = ESP_BLE_MESH_DISPLAY_NUMBER,
|
.output_actions = ESP_BLE_MESH_DISPLAY_NUMBER,
|
||||||
.input_actions = ESP_BLE_MESH_PUSH,
|
|
||||||
.input_size = 4,
|
.input_size = 4,
|
||||||
|
.input_actions = ESP_BLE_MESH_PUSH,
|
||||||
#else
|
#else
|
||||||
.output_size = 0,
|
.output_size = 0,
|
||||||
.output_actions = 0,
|
.output_actions = 0,
|
||||||
@@ -146,7 +152,7 @@ static void example_handle_gen_onoff_msg(esp_ble_mesh_model_t *model,
|
|||||||
esp_ble_mesh_msg_ctx_t *ctx,
|
esp_ble_mesh_msg_ctx_t *ctx,
|
||||||
esp_ble_mesh_server_recv_gen_onoff_set_t *set)
|
esp_ble_mesh_server_recv_gen_onoff_set_t *set)
|
||||||
{
|
{
|
||||||
esp_ble_mesh_gen_onoff_srv_t *srv = model->user_data;
|
esp_ble_mesh_gen_onoff_srv_t *srv = (esp_ble_mesh_gen_onoff_srv_t *)model->user_data;
|
||||||
|
|
||||||
switch (ctx->recv_op) {
|
switch (ctx->recv_op) {
|
||||||
case ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET:
|
case ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET:
|
||||||
@@ -227,7 +233,7 @@ static void example_ble_mesh_generic_server_cb(esp_ble_mesh_generic_server_cb_ev
|
|||||||
case ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT:
|
case ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT:
|
||||||
ESP_LOGI(TAG, "ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT");
|
ESP_LOGI(TAG, "ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT");
|
||||||
if (param->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET) {
|
if (param->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET) {
|
||||||
srv = param->model->user_data;
|
srv = (esp_ble_mesh_gen_onoff_srv_t *)param->model->user_data;
|
||||||
ESP_LOGI(TAG, "onoff 0x%02x", srv->state.onoff);
|
ESP_LOGI(TAG, "onoff 0x%02x", srv->state.onoff);
|
||||||
example_handle_gen_onoff_msg(param->model, ¶m->ctx, NULL);
|
example_handle_gen_onoff_msg(param->model, ¶m->ctx, NULL);
|
||||||
}
|
}
|
||||||
@@ -298,7 +304,7 @@ static esp_err_t ble_mesh_init(void)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);
|
err = esp_ble_mesh_node_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT));
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Failed to enable mesh node (err %d)", err);
|
ESP_LOGE(TAG, "Failed to enable mesh node (err %d)", err);
|
||||||
return err;
|
return err;
|
||||||
|
@@ -50,13 +50,7 @@ typedef struct {
|
|||||||
uint8_t onoff;
|
uint8_t onoff;
|
||||||
} esp_ble_mesh_node_info_t;
|
} esp_ble_mesh_node_info_t;
|
||||||
|
|
||||||
static esp_ble_mesh_node_info_t nodes[CONFIG_BLE_MESH_MAX_PROV_NODES] = {
|
static esp_ble_mesh_node_info_t nodes[CONFIG_BLE_MESH_MAX_PROV_NODES] = {0};
|
||||||
[0 ... (CONFIG_BLE_MESH_MAX_PROV_NODES - 1)] = {
|
|
||||||
.unicast = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
|
||||||
.elem_num = 0,
|
|
||||||
.onoff = LED_OFF,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct esp_ble_mesh_key {
|
static struct esp_ble_mesh_key {
|
||||||
uint16_t net_idx;
|
uint16_t net_idx;
|
||||||
@@ -68,22 +62,22 @@ static esp_ble_mesh_client_t config_client;
|
|||||||
static esp_ble_mesh_client_t onoff_client;
|
static esp_ble_mesh_client_t onoff_client;
|
||||||
|
|
||||||
static esp_ble_mesh_cfg_srv_t config_server = {
|
static esp_ble_mesh_cfg_srv_t config_server = {
|
||||||
|
/* 3 transmissions with 20ms interval */
|
||||||
|
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.relay = ESP_BLE_MESH_RELAY_DISABLED,
|
.relay = ESP_BLE_MESH_RELAY_DISABLED,
|
||||||
|
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
||||||
#if defined(CONFIG_BLE_MESH_FRIEND)
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
|
||||||
#else
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
||||||
#else
|
#else
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_BLE_MESH_FRIEND)
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
||||||
|
#else
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
||||||
#endif
|
#endif
|
||||||
.default_ttl = 7,
|
.default_ttl = 7,
|
||||||
/* 3 transmissions with 20ms interval */
|
|
||||||
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_model_t root_models[] = {
|
static esp_ble_mesh_model_t root_models[] = {
|
||||||
@@ -98,8 +92,8 @@ static esp_ble_mesh_elem_t elements[] = {
|
|||||||
|
|
||||||
static esp_ble_mesh_comp_t composition = {
|
static esp_ble_mesh_comp_t composition = {
|
||||||
.cid = CID_ESP,
|
.cid = CID_ESP,
|
||||||
.elements = elements,
|
|
||||||
.element_count = ARRAY_SIZE(elements),
|
.element_count = ARRAY_SIZE(elements),
|
||||||
|
.elements = elements,
|
||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_prov_t provision = {
|
static esp_ble_mesh_prov_t provision = {
|
||||||
@@ -259,14 +253,14 @@ static void recv_unprov_adv_pkt(uint8_t dev_uuid[16], uint8_t addr[BD_ADDR_LEN],
|
|||||||
ESP_LOGI(TAG, "oob info: %d, bearer: %s", oob_info, (bearer & ESP_BLE_MESH_PROV_ADV) ? "PB-ADV" : "PB-GATT");
|
ESP_LOGI(TAG, "oob info: %d, bearer: %s", oob_info, (bearer & ESP_BLE_MESH_PROV_ADV) ? "PB-ADV" : "PB-GATT");
|
||||||
|
|
||||||
memcpy(add_dev.addr, addr, BD_ADDR_LEN);
|
memcpy(add_dev.addr, addr, BD_ADDR_LEN);
|
||||||
add_dev.addr_type = (uint8_t)addr_type;
|
add_dev.addr_type = (esp_ble_mesh_addr_type_t)addr_type;
|
||||||
memcpy(add_dev.uuid, dev_uuid, 16);
|
memcpy(add_dev.uuid, dev_uuid, 16);
|
||||||
add_dev.oob_info = oob_info;
|
add_dev.oob_info = oob_info;
|
||||||
add_dev.bearer = (uint8_t)bearer;
|
add_dev.bearer = (esp_ble_mesh_prov_bearer_t)bearer;
|
||||||
/* Note: If unprovisioned device adv packets have not been received, we should not add
|
/* Note: If unprovisioned device adv packets have not been received, we should not add
|
||||||
device with ADD_DEV_START_PROV_NOW_FLAG set. */
|
device with ADD_DEV_START_PROV_NOW_FLAG set. */
|
||||||
err = esp_ble_mesh_provisioner_add_unprov_dev(&add_dev,
|
err = esp_ble_mesh_provisioner_add_unprov_dev(&add_dev,
|
||||||
ADD_DEV_RM_AFTER_PROV_FLAG | ADD_DEV_START_PROV_NOW_FLAG | ADD_DEV_FLUSHABLE_DEV_FLAG);
|
(esp_ble_mesh_dev_add_flag_t)(ADD_DEV_RM_AFTER_PROV_FLAG | ADD_DEV_START_PROV_NOW_FLAG | ADD_DEV_FLUSHABLE_DEV_FLAG));
|
||||||
if (err) {
|
if (err) {
|
||||||
ESP_LOGE(TAG, "%s: Add unprovisioned device into queue failed", __func__);
|
ESP_LOGE(TAG, "%s: Add unprovisioned device into queue failed", __func__);
|
||||||
}
|
}
|
||||||
@@ -608,7 +602,7 @@ static esp_err_t ble_mesh_init(void)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_ble_mesh_provisioner_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);
|
err = esp_ble_mesh_provisioner_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT));
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Failed to enable mesh provisioner (err %d)", err);
|
ESP_LOGE(TAG, "Failed to enable mesh provisioner (err %d)", err);
|
||||||
return err;
|
return err;
|
||||||
|
@@ -10,6 +10,10 @@
|
|||||||
#ifndef _BOARD_H_
|
#ifndef _BOARD_H_
|
||||||
#define _BOARD_H_
|
#define _BOARD_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
|
|
||||||
#if defined(CONFIG_BLE_MESH_ESP_WROOM_32)
|
#if defined(CONFIG_BLE_MESH_ESP_WROOM_32)
|
||||||
@@ -47,4 +51,8 @@ void board_led_operation(uint8_t r, uint8_t g, uint8_t b);
|
|||||||
|
|
||||||
void board_init(void);
|
void board_init(void);
|
||||||
|
|
||||||
#endif
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _BOARD_H_ */
|
||||||
|
@@ -65,13 +65,7 @@ typedef struct {
|
|||||||
uint32_t **vnd_models;
|
uint32_t **vnd_models;
|
||||||
} esp_ble_mesh_node_info_t;
|
} esp_ble_mesh_node_info_t;
|
||||||
|
|
||||||
static esp_ble_mesh_node_info_t nodes[CONFIG_BLE_MESH_MAX_PROV_NODES] = {
|
static esp_ble_mesh_node_info_t nodes[CONFIG_BLE_MESH_MAX_PROV_NODES] = {0};
|
||||||
[0 ... (CONFIG_BLE_MESH_MAX_PROV_NODES - 1)] = {
|
|
||||||
.unicast = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
|
||||||
.elem_num = 0,
|
|
||||||
.onoff = LED_OFF,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct esp_ble_mesh_key {
|
static struct esp_ble_mesh_key {
|
||||||
uint16_t net_idx;
|
uint16_t net_idx;
|
||||||
@@ -86,22 +80,22 @@ static esp_ble_mesh_client_t config_client;
|
|||||||
static esp_ble_mesh_client_t onoff_client;
|
static esp_ble_mesh_client_t onoff_client;
|
||||||
|
|
||||||
static esp_ble_mesh_cfg_srv_t config_server = {
|
static esp_ble_mesh_cfg_srv_t config_server = {
|
||||||
|
/* 3 transmissions with 20ms interval */
|
||||||
|
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.relay = ESP_BLE_MESH_RELAY_DISABLED,
|
.relay = ESP_BLE_MESH_RELAY_DISABLED,
|
||||||
|
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
||||||
#if defined(CONFIG_BLE_MESH_FRIEND)
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
|
||||||
#else
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
||||||
#else
|
#else
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_BLE_MESH_FRIEND)
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
||||||
|
#else
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
||||||
#endif
|
#endif
|
||||||
.default_ttl = 7,
|
.default_ttl = 7,
|
||||||
/* 3 transmissions with 20ms interval */
|
|
||||||
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_model_t root_models[] = {
|
static esp_ble_mesh_model_t root_models[] = {
|
||||||
@@ -119,8 +113,8 @@ static esp_ble_mesh_elem_t elements[] = {
|
|||||||
|
|
||||||
static esp_ble_mesh_comp_t composition = {
|
static esp_ble_mesh_comp_t composition = {
|
||||||
.cid = CID_ESP,
|
.cid = CID_ESP,
|
||||||
.elements = elements,
|
|
||||||
.element_count = ARRAY_SIZE(elements),
|
.element_count = ARRAY_SIZE(elements),
|
||||||
|
.elements = elements,
|
||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_prov_t provision = {
|
static esp_ble_mesh_prov_t provision = {
|
||||||
@@ -281,10 +275,10 @@ static void recv_unprov_adv_pkt(uint8_t dev_uuid[16], uint8_t addr[BD_ADDR_LEN],
|
|||||||
ESP_LOGI(TAG, "oob info: %d, bearer: %s", oob_info, (bearer & ESP_BLE_MESH_PROV_ADV) ? "PB-ADV" : "PB-GATT");
|
ESP_LOGI(TAG, "oob info: %d, bearer: %s", oob_info, (bearer & ESP_BLE_MESH_PROV_ADV) ? "PB-ADV" : "PB-GATT");
|
||||||
|
|
||||||
memcpy(add_dev.addr, addr, BD_ADDR_LEN);
|
memcpy(add_dev.addr, addr, BD_ADDR_LEN);
|
||||||
add_dev.addr_type = (uint8_t)addr_type;
|
add_dev.addr_type = (esp_ble_mesh_addr_type_t)addr_type;
|
||||||
memcpy(add_dev.uuid, dev_uuid, 16);
|
memcpy(add_dev.uuid, dev_uuid, 16);
|
||||||
add_dev.oob_info = oob_info;
|
add_dev.oob_info = oob_info;
|
||||||
add_dev.bearer = (uint8_t)bearer;
|
add_dev.bearer = (esp_ble_mesh_prov_bearer_t)bearer;
|
||||||
/* Note: If unprovisioned device adv packets have not been received, we should not add
|
/* Note: If unprovisioned device adv packets have not been received, we should not add
|
||||||
device with ADD_DEV_START_PROV_NOW_FLAG set. */
|
device with ADD_DEV_START_PROV_NOW_FLAG set. */
|
||||||
err = esp_ble_mesh_provisioner_add_unprov_dev(&add_dev,
|
err = esp_ble_mesh_provisioner_add_unprov_dev(&add_dev,
|
||||||
@@ -967,7 +961,7 @@ static void example_ble_mesh_remote_prov_client_callback(esp_ble_mesh_rpr_client
|
|||||||
if (param->recv.val.link_report.status == ESP_BLE_MESH_RPR_STATUS_SUCCESS) {
|
if (param->recv.val.link_report.status == ESP_BLE_MESH_RPR_STATUS_SUCCESS) {
|
||||||
switch (param->recv.val.link_report.rpr_state)
|
switch (param->recv.val.link_report.rpr_state)
|
||||||
{
|
{
|
||||||
case ESP_BLE_MESH_RPR_LINK_ACTIVE:
|
case ESP_BLE_MESH_RPR_LINK_ACTIVE: {
|
||||||
ESP_LOGI(TAG, "Remote Provisioning Server(addr: 0x%04x) Link Open Success", addr);
|
ESP_LOGI(TAG, "Remote Provisioning Server(addr: 0x%04x) Link Open Success", addr);
|
||||||
esp_ble_mesh_rpr_client_act_param_t param = {0};
|
esp_ble_mesh_rpr_client_act_param_t param = {0};
|
||||||
param.start_rpr.model = remote_prov_client.model;
|
param.start_rpr.model = remote_prov_client.model;
|
||||||
@@ -981,6 +975,7 @@ static void example_ble_mesh_remote_prov_client_callback(esp_ble_mesh_rpr_client
|
|||||||
}
|
}
|
||||||
board_led_operation(LED_OFF, LED_ON, LED_OFF);
|
board_led_operation(LED_OFF, LED_ON, LED_OFF);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
ESP_LOGI(TAG, "Remote Provisioning Server(addr: 0x%04x) Status error", addr);
|
ESP_LOGI(TAG, "Remote Provisioning Server(addr: 0x%04x) Status error", addr);
|
||||||
break;
|
break;
|
||||||
@@ -1096,7 +1091,7 @@ static esp_err_t ble_mesh_init(void)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_ble_mesh_provisioner_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);
|
err = esp_ble_mesh_provisioner_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT));
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Failed to enable mesh provisioner (err %d)", err);
|
ESP_LOGE(TAG, "Failed to enable mesh provisioner (err %d)", err);
|
||||||
return err;
|
return err;
|
||||||
|
@@ -10,6 +10,10 @@
|
|||||||
#ifndef _BOARD_H_
|
#ifndef _BOARD_H_
|
||||||
#define _BOARD_H_
|
#define _BOARD_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
|
|
||||||
#if defined(CONFIG_BLE_MESH_ESP_WROOM_32)
|
#if defined(CONFIG_BLE_MESH_ESP_WROOM_32)
|
||||||
@@ -47,4 +51,8 @@ void board_led_operation(uint8_t r, uint8_t g, uint8_t b);
|
|||||||
|
|
||||||
void board_init(void);
|
void board_init(void);
|
||||||
|
|
||||||
#endif
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _BOARD_H_ */
|
||||||
|
@@ -35,40 +35,46 @@
|
|||||||
static uint8_t dev_uuid[16] = { 0x55, 0xaa };
|
static uint8_t dev_uuid[16] = { 0x55, 0xaa };
|
||||||
|
|
||||||
static esp_ble_mesh_cfg_srv_t config_server = {
|
static esp_ble_mesh_cfg_srv_t config_server = {
|
||||||
|
/* 3 transmissions with 20ms interval */
|
||||||
|
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.relay = ESP_BLE_MESH_RELAY_ENABLED,
|
.relay = ESP_BLE_MESH_RELAY_ENABLED,
|
||||||
|
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
||||||
#if defined(CONFIG_BLE_MESH_FRIEND)
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
|
||||||
#else
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
||||||
#else
|
#else
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_BLE_MESH_FRIEND)
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
||||||
|
#else
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
||||||
#endif
|
#endif
|
||||||
.default_ttl = 7,
|
.default_ttl = 7,
|
||||||
/* 3 transmissions with 20ms interval */
|
|
||||||
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_0, 2 + 3, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_0, 2 + 3, ROLE_NODE);
|
||||||
static esp_ble_mesh_gen_onoff_srv_t onoff_server_0 = {
|
static esp_ble_mesh_gen_onoff_srv_t onoff_server_0 = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.rsp_ctrl = {
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_1, 2 + 3, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_1, 2 + 3, ROLE_NODE);
|
||||||
static esp_ble_mesh_gen_onoff_srv_t onoff_server_1 = {
|
static esp_ble_mesh_gen_onoff_srv_t onoff_server_1 = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
.rsp_ctrl = {
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_2, 2 + 3, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_2, 2 + 3, ROLE_NODE);
|
||||||
static esp_ble_mesh_gen_onoff_srv_t onoff_server_2 = {
|
static esp_ble_mesh_gen_onoff_srv_t onoff_server_2 = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.rsp_ctrl = {
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_model_t root_models[] = {
|
static esp_ble_mesh_model_t root_models[] = {
|
||||||
@@ -95,8 +101,8 @@ static esp_ble_mesh_elem_t elements[] = {
|
|||||||
|
|
||||||
static esp_ble_mesh_comp_t composition = {
|
static esp_ble_mesh_comp_t composition = {
|
||||||
.cid = CID_ESP,
|
.cid = CID_ESP,
|
||||||
.elements = elements,
|
|
||||||
.element_count = ARRAY_SIZE(elements),
|
.element_count = ARRAY_SIZE(elements),
|
||||||
|
.elements = elements,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Disable OOB security for SILabs Android app */
|
/* Disable OOB security for SILabs Android app */
|
||||||
@@ -105,8 +111,8 @@ static esp_ble_mesh_prov_t provision = {
|
|||||||
#if 0
|
#if 0
|
||||||
.output_size = 4,
|
.output_size = 4,
|
||||||
.output_actions = ESP_BLE_MESH_DISPLAY_NUMBER,
|
.output_actions = ESP_BLE_MESH_DISPLAY_NUMBER,
|
||||||
.input_actions = ESP_BLE_MESH_PUSH,
|
|
||||||
.input_size = 4,
|
.input_size = 4,
|
||||||
|
.input_actions = ESP_BLE_MESH_PUSH,
|
||||||
#else
|
#else
|
||||||
.output_size = 0,
|
.output_size = 0,
|
||||||
.output_actions = 0,
|
.output_actions = 0,
|
||||||
@@ -150,7 +156,7 @@ static void example_handle_gen_onoff_msg(esp_ble_mesh_model_t *model,
|
|||||||
esp_ble_mesh_msg_ctx_t *ctx,
|
esp_ble_mesh_msg_ctx_t *ctx,
|
||||||
esp_ble_mesh_server_recv_gen_onoff_set_t *set)
|
esp_ble_mesh_server_recv_gen_onoff_set_t *set)
|
||||||
{
|
{
|
||||||
esp_ble_mesh_gen_onoff_srv_t *srv = model->user_data;
|
esp_ble_mesh_gen_onoff_srv_t *srv = (esp_ble_mesh_gen_onoff_srv_t *)model->user_data;
|
||||||
|
|
||||||
switch (ctx->recv_op) {
|
switch (ctx->recv_op) {
|
||||||
case ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET:
|
case ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET:
|
||||||
@@ -232,7 +238,7 @@ static void example_ble_mesh_generic_server_cb(esp_ble_mesh_generic_server_cb_ev
|
|||||||
case ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT:
|
case ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT:
|
||||||
ESP_LOGI(TAG, "ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT");
|
ESP_LOGI(TAG, "ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT");
|
||||||
if (param->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET) {
|
if (param->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET) {
|
||||||
srv = param->model->user_data;
|
srv = (esp_ble_mesh_gen_onoff_srv_t *)param->model->user_data;
|
||||||
ESP_LOGI(TAG, "onoff 0x%02x", srv->state.onoff);
|
ESP_LOGI(TAG, "onoff 0x%02x", srv->state.onoff);
|
||||||
example_handle_gen_onoff_msg(param->model, ¶m->ctx, NULL);
|
example_handle_gen_onoff_msg(param->model, ¶m->ctx, NULL);
|
||||||
}
|
}
|
||||||
@@ -425,7 +431,7 @@ static esp_err_t ble_mesh_init(void)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);
|
err = esp_ble_mesh_node_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT));
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Failed to enable mesh node (err %d)", err);
|
ESP_LOGE(TAG, "Failed to enable mesh node (err %d)", err);
|
||||||
return err;
|
return err;
|
||||||
@@ -434,6 +440,7 @@ static esp_err_t ble_mesh_init(void)
|
|||||||
ESP_LOGI(TAG, "BLE Mesh Node initialized");
|
ESP_LOGI(TAG, "BLE Mesh Node initialized");
|
||||||
|
|
||||||
board_led_operation(LED_ON, LED_OFF, LED_OFF);
|
board_led_operation(LED_ON, LED_OFF, LED_OFF);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,6 +10,10 @@
|
|||||||
#ifndef _BOARD_H_
|
#ifndef _BOARD_H_
|
||||||
#define _BOARD_H_
|
#define _BOARD_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
|
|
||||||
#if defined(CONFIG_BLE_MESH_ESP_WROOM_32)
|
#if defined(CONFIG_BLE_MESH_ESP_WROOM_32)
|
||||||
@@ -47,4 +51,8 @@ void board_led_operation(uint8_t r, uint8_t g, uint8_t b);
|
|||||||
|
|
||||||
void board_init(void);
|
void board_init(void);
|
||||||
|
|
||||||
#endif
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _BOARD_H_ */
|
||||||
|
@@ -32,40 +32,46 @@
|
|||||||
static uint8_t dev_uuid[16] = { 0x55, 0x55 };
|
static uint8_t dev_uuid[16] = { 0x55, 0x55 };
|
||||||
|
|
||||||
static esp_ble_mesh_cfg_srv_t config_server = {
|
static esp_ble_mesh_cfg_srv_t config_server = {
|
||||||
|
/* 3 transmissions with 20ms interval */
|
||||||
|
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.relay = ESP_BLE_MESH_RELAY_ENABLED,
|
.relay = ESP_BLE_MESH_RELAY_ENABLED,
|
||||||
|
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
||||||
#if defined(CONFIG_BLE_MESH_FRIEND)
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
|
||||||
#else
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
||||||
#else
|
#else
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_BLE_MESH_FRIEND)
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
||||||
|
#else
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
||||||
#endif
|
#endif
|
||||||
.default_ttl = 7,
|
.default_ttl = 7,
|
||||||
/* 3 transmissions with 20ms interval */
|
|
||||||
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_0, 2 + 3, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_0, 2 + 3, ROLE_NODE);
|
||||||
static esp_ble_mesh_gen_onoff_srv_t onoff_server_0 = {
|
static esp_ble_mesh_gen_onoff_srv_t onoff_server_0 = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.rsp_ctrl = {
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_1, 2 + 3, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_1, 2 + 3, ROLE_NODE);
|
||||||
static esp_ble_mesh_gen_onoff_srv_t onoff_server_1 = {
|
static esp_ble_mesh_gen_onoff_srv_t onoff_server_1 = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
.rsp_ctrl = {
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_2, 2 + 3, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_2, 2 + 3, ROLE_NODE);
|
||||||
static esp_ble_mesh_gen_onoff_srv_t onoff_server_2 = {
|
static esp_ble_mesh_gen_onoff_srv_t onoff_server_2 = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
.rsp_ctrl = {
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_model_t root_models[] = {
|
static esp_ble_mesh_model_t root_models[] = {
|
||||||
@@ -89,8 +95,8 @@ static esp_ble_mesh_elem_t elements[] = {
|
|||||||
|
|
||||||
static esp_ble_mesh_comp_t composition = {
|
static esp_ble_mesh_comp_t composition = {
|
||||||
.cid = CID_ESP,
|
.cid = CID_ESP,
|
||||||
.elements = elements,
|
|
||||||
.element_count = ARRAY_SIZE(elements),
|
.element_count = ARRAY_SIZE(elements),
|
||||||
|
.elements = elements,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Disable OOB security for SILabs Android app */
|
/* Disable OOB security for SILabs Android app */
|
||||||
@@ -99,8 +105,8 @@ static esp_ble_mesh_prov_t provision = {
|
|||||||
#if 0
|
#if 0
|
||||||
.output_size = 4,
|
.output_size = 4,
|
||||||
.output_actions = ESP_BLE_MESH_DISPLAY_NUMBER,
|
.output_actions = ESP_BLE_MESH_DISPLAY_NUMBER,
|
||||||
.input_actions = ESP_BLE_MESH_PUSH,
|
|
||||||
.input_size = 4,
|
.input_size = 4,
|
||||||
|
.input_actions = ESP_BLE_MESH_PUSH,
|
||||||
#else
|
#else
|
||||||
.output_size = 0,
|
.output_size = 0,
|
||||||
.output_actions = 0,
|
.output_actions = 0,
|
||||||
@@ -144,7 +150,7 @@ static void example_handle_gen_onoff_msg(esp_ble_mesh_model_t *model,
|
|||||||
esp_ble_mesh_msg_ctx_t *ctx,
|
esp_ble_mesh_msg_ctx_t *ctx,
|
||||||
esp_ble_mesh_server_recv_gen_onoff_set_t *set)
|
esp_ble_mesh_server_recv_gen_onoff_set_t *set)
|
||||||
{
|
{
|
||||||
esp_ble_mesh_gen_onoff_srv_t *srv = model->user_data;
|
esp_ble_mesh_gen_onoff_srv_t *srv = (esp_ble_mesh_gen_onoff_srv_t *)model->user_data;
|
||||||
|
|
||||||
switch (ctx->recv_op) {
|
switch (ctx->recv_op) {
|
||||||
case ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET:
|
case ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET:
|
||||||
@@ -226,7 +232,7 @@ static void example_ble_mesh_generic_server_cb(esp_ble_mesh_generic_server_cb_ev
|
|||||||
case ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT:
|
case ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT:
|
||||||
ESP_LOGI(TAG, "ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT");
|
ESP_LOGI(TAG, "ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT");
|
||||||
if (param->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET) {
|
if (param->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET) {
|
||||||
srv = param->model->user_data;
|
srv = (esp_ble_mesh_gen_onoff_srv_t *)param->model->user_data;
|
||||||
ESP_LOGI(TAG, "onoff 0x%02x", srv->state.onoff);
|
ESP_LOGI(TAG, "onoff 0x%02x", srv->state.onoff);
|
||||||
example_handle_gen_onoff_msg(param->model, ¶m->ctx, NULL);
|
example_handle_gen_onoff_msg(param->model, ¶m->ctx, NULL);
|
||||||
}
|
}
|
||||||
@@ -299,7 +305,7 @@ static esp_err_t ble_mesh_init(void)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);
|
err = esp_ble_mesh_node_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT));
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Failed to enable mesh node (err %d)", err);
|
ESP_LOGE(TAG, "Failed to enable mesh node (err %d)", err);
|
||||||
return err;
|
return err;
|
||||||
|
@@ -10,6 +10,14 @@
|
|||||||
#ifndef _BOARD_H_
|
#ifndef _BOARD_H_
|
||||||
#define _BOARD_H_
|
#define _BOARD_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
void board_init(void);
|
void board_init(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
#endif /* _BOARD_H_ */
|
#endif /* _BOARD_H_ */
|
||||||
|
@@ -53,7 +53,10 @@ static struct esp_ble_mesh_key {
|
|||||||
} prov_key;
|
} prov_key;
|
||||||
|
|
||||||
static esp_ble_mesh_cfg_srv_t config_server = {
|
static esp_ble_mesh_cfg_srv_t config_server = {
|
||||||
|
/* 3 transmissions with 20ms interval */
|
||||||
|
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.relay = ESP_BLE_MESH_RELAY_DISABLED,
|
.relay = ESP_BLE_MESH_RELAY_DISABLED,
|
||||||
|
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.beacon = ESP_BLE_MESH_BEACON_DISABLED,
|
.beacon = ESP_BLE_MESH_BEACON_DISABLED,
|
||||||
#if defined(CONFIG_BLE_MESH_FRIEND)
|
#if defined(CONFIG_BLE_MESH_FRIEND)
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
||||||
@@ -61,9 +64,6 @@ static esp_ble_mesh_cfg_srv_t config_server = {
|
|||||||
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
||||||
#endif
|
#endif
|
||||||
.default_ttl = 7,
|
.default_ttl = 7,
|
||||||
/* 3 transmissions with 20ms interval */
|
|
||||||
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_client_t config_client;
|
static esp_ble_mesh_client_t config_client;
|
||||||
@@ -81,8 +81,8 @@ static esp_ble_mesh_elem_t elements[] = {
|
|||||||
|
|
||||||
static esp_ble_mesh_comp_t composition = {
|
static esp_ble_mesh_comp_t composition = {
|
||||||
.cid = CID_ESP,
|
.cid = CID_ESP,
|
||||||
.elements = elements,
|
|
||||||
.element_count = ARRAY_SIZE(elements),
|
.element_count = ARRAY_SIZE(elements),
|
||||||
|
.elements = elements,
|
||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_prov_t provision = {
|
static esp_ble_mesh_prov_t provision = {
|
||||||
@@ -164,10 +164,10 @@ static void recv_unprov_adv_pkt(uint8_t dev_uuid[ESP_BLE_MESH_OCTET16_LEN], uint
|
|||||||
ESP_LOGI(TAG, "oob info 0x%04x, bearer %s", oob_info, (bearer & ESP_BLE_MESH_PROV_ADV) ? "PB-ADV" : "PB-GATT");
|
ESP_LOGI(TAG, "oob info 0x%04x, bearer %s", oob_info, (bearer & ESP_BLE_MESH_PROV_ADV) ? "PB-ADV" : "PB-GATT");
|
||||||
|
|
||||||
memcpy(add_dev.addr, addr, BD_ADDR_LEN);
|
memcpy(add_dev.addr, addr, BD_ADDR_LEN);
|
||||||
add_dev.addr_type = (uint8_t)addr_type;
|
add_dev.addr_type = (esp_ble_mesh_addr_type_t)addr_type;
|
||||||
memcpy(add_dev.uuid, dev_uuid, ESP_BLE_MESH_OCTET16_LEN);
|
memcpy(add_dev.uuid, dev_uuid, ESP_BLE_MESH_OCTET16_LEN);
|
||||||
add_dev.oob_info = oob_info;
|
add_dev.oob_info = oob_info;
|
||||||
add_dev.bearer = (uint8_t)bearer;
|
add_dev.bearer = (esp_ble_mesh_prov_bearer_t)bearer;
|
||||||
/* Note: If unprovisioned device adv packets have not been received, we should not add
|
/* Note: If unprovisioned device adv packets have not been received, we should not add
|
||||||
device with ADD_DEV_START_PROV_NOW_FLAG set. */
|
device with ADD_DEV_START_PROV_NOW_FLAG set. */
|
||||||
err = esp_ble_mesh_provisioner_add_unprov_dev(&add_dev,
|
err = esp_ble_mesh_provisioner_add_unprov_dev(&add_dev,
|
||||||
@@ -648,7 +648,7 @@ static esp_err_t ble_mesh_init(void)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_ble_mesh_provisioner_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);
|
err = esp_ble_mesh_provisioner_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT));
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Failed to enable mesh provisioner");
|
ESP_LOGE(TAG, "Failed to enable mesh provisioner");
|
||||||
return err;
|
return err;
|
||||||
|
@@ -10,6 +10,10 @@
|
|||||||
#ifndef _BOARD_H_
|
#ifndef _BOARD_H_
|
||||||
#define _BOARD_H_
|
#define _BOARD_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
|
|
||||||
#if defined(CONFIG_BLE_MESH_ESP_WROOM_32)
|
#if defined(CONFIG_BLE_MESH_ESP_WROOM_32)
|
||||||
@@ -52,4 +56,8 @@ void board_led_operation(uint8_t pin, uint8_t onoff);
|
|||||||
|
|
||||||
void board_init(void);
|
void board_init(void);
|
||||||
|
|
||||||
#endif
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _BOARD_H_ */
|
||||||
|
@@ -49,22 +49,22 @@ static int8_t outdoor_temp = 60; /* Outdoor temperature is 30 Degrees Celsius
|
|||||||
static uint8_t dev_uuid[ESP_BLE_MESH_OCTET16_LEN] = { 0x32, 0x10 };
|
static uint8_t dev_uuid[ESP_BLE_MESH_OCTET16_LEN] = { 0x32, 0x10 };
|
||||||
|
|
||||||
static esp_ble_mesh_cfg_srv_t config_server = {
|
static esp_ble_mesh_cfg_srv_t config_server = {
|
||||||
|
/* 3 transmissions with 20ms interval */
|
||||||
|
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.relay = ESP_BLE_MESH_RELAY_ENABLED,
|
.relay = ESP_BLE_MESH_RELAY_ENABLED,
|
||||||
|
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
||||||
#if defined(CONFIG_BLE_MESH_FRIEND)
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
|
||||||
#else
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
||||||
#else
|
#else
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_BLE_MESH_FRIEND)
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
||||||
|
#else
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
||||||
#endif
|
#endif
|
||||||
.default_ttl = 7,
|
.default_ttl = 7,
|
||||||
/* 3 transmissions with 20ms interval */
|
|
||||||
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
NET_BUF_SIMPLE_DEFINE_STATIC(sensor_data_0, 1);
|
NET_BUF_SIMPLE_DEFINE_STATIC(sensor_data_0, 1);
|
||||||
@@ -89,41 +89,53 @@ static esp_ble_mesh_sensor_state_t sensor_states[2] = {
|
|||||||
* Sensor Descriptor state represents the attributes describing the sensor
|
* Sensor Descriptor state represents the attributes describing the sensor
|
||||||
* data. This state does not change throughout the lifetime of an element.
|
* data. This state does not change throughout the lifetime of an element.
|
||||||
*/
|
*/
|
||||||
.descriptor.positive_tolerance = SENSOR_POSITIVE_TOLERANCE,
|
.descriptor = {
|
||||||
.descriptor.negative_tolerance = SENSOR_NEGATIVE_TOLERANCE,
|
.positive_tolerance = SENSOR_POSITIVE_TOLERANCE,
|
||||||
.descriptor.sampling_function = SENSOR_SAMPLE_FUNCTION,
|
.negative_tolerance = SENSOR_NEGATIVE_TOLERANCE,
|
||||||
.descriptor.measure_period = SENSOR_MEASURE_PERIOD,
|
.sampling_function = SENSOR_SAMPLE_FUNCTION,
|
||||||
.descriptor.update_interval = SENSOR_UPDATE_INTERVAL,
|
.measure_period = SENSOR_MEASURE_PERIOD,
|
||||||
.sensor_data.format = ESP_BLE_MESH_SENSOR_DATA_FORMAT_A,
|
.update_interval = SENSOR_UPDATE_INTERVAL,
|
||||||
.sensor_data.length = 0, /* 0 represents the length is 1 */
|
},
|
||||||
.sensor_data.raw_value = &sensor_data_0,
|
.sensor_data = {
|
||||||
|
.format = ESP_BLE_MESH_SENSOR_DATA_FORMAT_A,
|
||||||
|
.length = 0, /* 0 represents the length is 1 */
|
||||||
|
.raw_value = &sensor_data_0,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
[1] = {
|
[1] = {
|
||||||
.sensor_property_id = SENSOR_PROPERTY_ID_1,
|
.sensor_property_id = SENSOR_PROPERTY_ID_1,
|
||||||
.descriptor.positive_tolerance = SENSOR_POSITIVE_TOLERANCE,
|
.descriptor = {
|
||||||
.descriptor.negative_tolerance = SENSOR_NEGATIVE_TOLERANCE,
|
.positive_tolerance = SENSOR_POSITIVE_TOLERANCE,
|
||||||
.descriptor.sampling_function = SENSOR_SAMPLE_FUNCTION,
|
.negative_tolerance = SENSOR_NEGATIVE_TOLERANCE,
|
||||||
.descriptor.measure_period = SENSOR_MEASURE_PERIOD,
|
.sampling_function = SENSOR_SAMPLE_FUNCTION,
|
||||||
.descriptor.update_interval = SENSOR_UPDATE_INTERVAL,
|
.measure_period = SENSOR_MEASURE_PERIOD,
|
||||||
.sensor_data.format = ESP_BLE_MESH_SENSOR_DATA_FORMAT_A,
|
.update_interval = SENSOR_UPDATE_INTERVAL,
|
||||||
.sensor_data.length = 0, /* 0 represents the length is 1 */
|
},
|
||||||
.sensor_data.raw_value = &sensor_data_1,
|
.sensor_data = {
|
||||||
|
.format = ESP_BLE_MESH_SENSOR_DATA_FORMAT_A,
|
||||||
|
.length = 0, /* 0 represents the length is 1 */
|
||||||
|
.raw_value = &sensor_data_1,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/* 20 octets is large enough to hold two Sensor Descriptor state values. */
|
/* 20 octets is large enough to hold two Sensor Descriptor state values. */
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(sensor_pub, 20, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(sensor_pub, 20, ROLE_NODE);
|
||||||
static esp_ble_mesh_sensor_srv_t sensor_server = {
|
static esp_ble_mesh_sensor_srv_t sensor_server = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
.rsp_ctrl = {
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
||||||
|
},
|
||||||
.state_count = ARRAY_SIZE(sensor_states),
|
.state_count = ARRAY_SIZE(sensor_states),
|
||||||
.states = sensor_states,
|
.states = sensor_states,
|
||||||
};
|
};
|
||||||
|
|
||||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(sensor_setup_pub, 20, ROLE_NODE);
|
ESP_BLE_MESH_MODEL_PUB_DEFINE(sensor_setup_pub, 20, ROLE_NODE);
|
||||||
static esp_ble_mesh_sensor_setup_srv_t sensor_setup_server = {
|
static esp_ble_mesh_sensor_setup_srv_t sensor_setup_server = {
|
||||||
.rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
.rsp_ctrl = {
|
||||||
.rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
.get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
||||||
|
.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP,
|
||||||
|
},
|
||||||
.state_count = ARRAY_SIZE(sensor_states),
|
.state_count = ARRAY_SIZE(sensor_states),
|
||||||
.states = sensor_states,
|
.states = sensor_states,
|
||||||
};
|
};
|
||||||
@@ -140,8 +152,8 @@ static esp_ble_mesh_elem_t elements[] = {
|
|||||||
|
|
||||||
static esp_ble_mesh_comp_t composition = {
|
static esp_ble_mesh_comp_t composition = {
|
||||||
.cid = CID_ESP,
|
.cid = CID_ESP,
|
||||||
.elements = elements,
|
|
||||||
.element_count = ARRAY_SIZE(elements),
|
.element_count = ARRAY_SIZE(elements),
|
||||||
|
.elements = elements,
|
||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_prov_t provision = {
|
static esp_ble_mesh_prov_t provision = {
|
||||||
@@ -244,7 +256,7 @@ static void example_ble_mesh_send_sensor_descriptor_status(esp_ble_mesh_sensor_s
|
|||||||
esp_err_t err;
|
esp_err_t err;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
status = calloc(1, ARRAY_SIZE(sensor_states) * ESP_BLE_MESH_SENSOR_DESCRIPTOR_LEN);
|
status = (uint8_t *)calloc(1, ARRAY_SIZE(sensor_states) * ESP_BLE_MESH_SENSOR_DESCRIPTOR_LEN);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
ESP_LOGE(TAG, "No memory for sensor descriptor status!");
|
ESP_LOGE(TAG, "No memory for sensor descriptor status!");
|
||||||
return;
|
return;
|
||||||
@@ -427,7 +439,7 @@ static void example_ble_mesh_send_sensor_status(esp_ble_mesh_sensor_server_cb_pa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
status = calloc(1, buf_size);
|
status = (uint8_t *)calloc(1, buf_size);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
ESP_LOGE(TAG, "No memory for sensor status!");
|
ESP_LOGE(TAG, "No memory for sensor status!");
|
||||||
return;
|
return;
|
||||||
@@ -485,7 +497,7 @@ static void example_ble_mesh_send_sensor_column_status(esp_ble_mesh_sensor_serve
|
|||||||
|
|
||||||
length = ESP_BLE_MESH_SENSOR_PROPERTY_ID_LEN +param->value.get.sensor_column.raw_value_x->len;
|
length = ESP_BLE_MESH_SENSOR_PROPERTY_ID_LEN +param->value.get.sensor_column.raw_value_x->len;
|
||||||
|
|
||||||
status = calloc(1, length);
|
status = (uint8_t *)calloc(1, length);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
ESP_LOGE(TAG, "No memory for sensor column status!");
|
ESP_LOGE(TAG, "No memory for sensor column status!");
|
||||||
return;
|
return;
|
||||||
@@ -599,7 +611,7 @@ static esp_err_t ble_mesh_init(void)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);
|
err = esp_ble_mesh_node_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT));
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Failed to enable mesh node");
|
ESP_LOGE(TAG, "Failed to enable mesh node");
|
||||||
return err;
|
return err;
|
||||||
|
@@ -10,6 +10,14 @@
|
|||||||
#ifndef _BOARD_H_
|
#ifndef _BOARD_H_
|
||||||
#define _BOARD_H_
|
#define _BOARD_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
void board_init(void);
|
void board_init(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
#endif /* _BOARD_H_ */
|
#endif /* _BOARD_H_ */
|
||||||
|
@@ -70,7 +70,10 @@ static struct esp_ble_mesh_key {
|
|||||||
} prov_key;
|
} prov_key;
|
||||||
|
|
||||||
static esp_ble_mesh_cfg_srv_t config_server = {
|
static esp_ble_mesh_cfg_srv_t config_server = {
|
||||||
|
/* 3 transmissions with 20ms interval */
|
||||||
|
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.relay = ESP_BLE_MESH_RELAY_DISABLED,
|
.relay = ESP_BLE_MESH_RELAY_DISABLED,
|
||||||
|
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.beacon = ESP_BLE_MESH_BEACON_DISABLED,
|
.beacon = ESP_BLE_MESH_BEACON_DISABLED,
|
||||||
#if defined(CONFIG_BLE_MESH_FRIEND)
|
#if defined(CONFIG_BLE_MESH_FRIEND)
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
||||||
@@ -78,9 +81,6 @@ static esp_ble_mesh_cfg_srv_t config_server = {
|
|||||||
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
||||||
#endif
|
#endif
|
||||||
.default_ttl = 7,
|
.default_ttl = 7,
|
||||||
/* 3 transmissions with 20ms interval */
|
|
||||||
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_client_t config_client;
|
static esp_ble_mesh_client_t config_client;
|
||||||
@@ -115,8 +115,8 @@ static esp_ble_mesh_elem_t elements[] = {
|
|||||||
|
|
||||||
static esp_ble_mesh_comp_t composition = {
|
static esp_ble_mesh_comp_t composition = {
|
||||||
.cid = CID_ESP,
|
.cid = CID_ESP,
|
||||||
.elements = elements,
|
|
||||||
.element_count = ARRAY_SIZE(elements),
|
.element_count = ARRAY_SIZE(elements),
|
||||||
|
.elements = elements,
|
||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_prov_t provision = {
|
static esp_ble_mesh_prov_t provision = {
|
||||||
@@ -219,10 +219,10 @@ static void recv_unprov_adv_pkt(uint8_t dev_uuid[ESP_BLE_MESH_OCTET16_LEN], uint
|
|||||||
ESP_LOGI(TAG, "oob info 0x%04x, bearer %s", oob_info, (bearer & ESP_BLE_MESH_PROV_ADV) ? "PB-ADV" : "PB-GATT");
|
ESP_LOGI(TAG, "oob info 0x%04x, bearer %s", oob_info, (bearer & ESP_BLE_MESH_PROV_ADV) ? "PB-ADV" : "PB-GATT");
|
||||||
|
|
||||||
memcpy(add_dev.addr, addr, BD_ADDR_LEN);
|
memcpy(add_dev.addr, addr, BD_ADDR_LEN);
|
||||||
add_dev.addr_type = (uint8_t)addr_type;
|
add_dev.addr_type = (esp_ble_mesh_addr_type_t)addr_type;
|
||||||
memcpy(add_dev.uuid, dev_uuid, ESP_BLE_MESH_OCTET16_LEN);
|
memcpy(add_dev.uuid, dev_uuid, ESP_BLE_MESH_OCTET16_LEN);
|
||||||
add_dev.oob_info = oob_info;
|
add_dev.oob_info = oob_info;
|
||||||
add_dev.bearer = (uint8_t)bearer;
|
add_dev.bearer = (esp_ble_mesh_prov_bearer_t)bearer;
|
||||||
/* Note: If unprovisioned device adv packets have not been received, we should not add
|
/* Note: If unprovisioned device adv packets have not been received, we should not add
|
||||||
device with ADD_DEV_START_PROV_NOW_FLAG set. */
|
device with ADD_DEV_START_PROV_NOW_FLAG set. */
|
||||||
err = esp_ble_mesh_provisioner_add_unprov_dev(&add_dev,
|
err = esp_ble_mesh_provisioner_add_unprov_dev(&add_dev,
|
||||||
@@ -541,7 +541,7 @@ static esp_err_t ble_mesh_init(void)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_ble_mesh_provisioner_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);
|
err = esp_ble_mesh_provisioner_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT));
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Failed to enable mesh provisioner");
|
ESP_LOGE(TAG, "Failed to enable mesh provisioner");
|
||||||
return err;
|
return err;
|
||||||
|
@@ -10,6 +10,10 @@
|
|||||||
#ifndef _BOARD_H_
|
#ifndef _BOARD_H_
|
||||||
#define _BOARD_H_
|
#define _BOARD_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
|
|
||||||
#if defined(CONFIG_BLE_MESH_ESP_WROOM_32)
|
#if defined(CONFIG_BLE_MESH_ESP_WROOM_32)
|
||||||
@@ -52,4 +56,8 @@ void board_led_operation(uint8_t pin, uint8_t onoff);
|
|||||||
|
|
||||||
void board_init(void);
|
void board_init(void);
|
||||||
|
|
||||||
#endif
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /**< __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _BOARD_H_ */
|
||||||
|
@@ -38,22 +38,22 @@
|
|||||||
static uint8_t dev_uuid[ESP_BLE_MESH_OCTET16_LEN] = { 0x32, 0x10 };
|
static uint8_t dev_uuid[ESP_BLE_MESH_OCTET16_LEN] = { 0x32, 0x10 };
|
||||||
|
|
||||||
static esp_ble_mesh_cfg_srv_t config_server = {
|
static esp_ble_mesh_cfg_srv_t config_server = {
|
||||||
.relay = ESP_BLE_MESH_RELAY_ENABLED,
|
/* 3 transmissions with 20ms interval */
|
||||||
|
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
|
.relay = ESP_BLE_MESH_RELAY_DISABLED,
|
||||||
|
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
.beacon = ESP_BLE_MESH_BEACON_ENABLED,
|
||||||
#if defined(CONFIG_BLE_MESH_FRIEND)
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
|
||||||
#else
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
||||||
#else
|
#else
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_BLE_MESH_FRIEND)
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
||||||
|
#else
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
||||||
#endif
|
#endif
|
||||||
.default_ttl = 7,
|
.default_ttl = 7,
|
||||||
/* 3 transmissions with 20ms interval */
|
|
||||||
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_model_t root_models[] = {
|
static esp_ble_mesh_model_t root_models[] = {
|
||||||
@@ -76,8 +76,8 @@ static esp_ble_mesh_elem_t elements[] = {
|
|||||||
|
|
||||||
static esp_ble_mesh_comp_t composition = {
|
static esp_ble_mesh_comp_t composition = {
|
||||||
.cid = CID_ESP,
|
.cid = CID_ESP,
|
||||||
.elements = elements,
|
|
||||||
.element_count = ARRAY_SIZE(elements),
|
.element_count = ARRAY_SIZE(elements),
|
||||||
|
.elements = elements,
|
||||||
};
|
};
|
||||||
|
|
||||||
static esp_ble_mesh_prov_t provision = {
|
static esp_ble_mesh_prov_t provision = {
|
||||||
@@ -193,7 +193,7 @@ static esp_err_t ble_mesh_init(void)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT);
|
err = esp_ble_mesh_node_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT));
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "Failed to enable mesh node");
|
ESP_LOGE(TAG, "Failed to enable mesh node");
|
||||||
return err;
|
return err;
|
||||||
|
@@ -61,22 +61,22 @@ esp_ble_mesh_client_t config_client;
|
|||||||
|
|
||||||
/* Configuration Server Model user_data */
|
/* Configuration Server Model user_data */
|
||||||
esp_ble_mesh_cfg_srv_t config_server = {
|
esp_ble_mesh_cfg_srv_t config_server = {
|
||||||
|
/* 3 transmissions with 20ms interval */
|
||||||
|
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.relay = ESP_BLE_MESH_RELAY_ENABLED,
|
.relay = ESP_BLE_MESH_RELAY_ENABLED,
|
||||||
|
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
||||||
.beacon = ESP_BLE_MESH_BEACON_DISABLED,
|
.beacon = ESP_BLE_MESH_BEACON_DISABLED,
|
||||||
#if defined(CONFIG_BLE_MESH_FRIEND)
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
|
||||||
#else
|
|
||||||
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER)
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED,
|
||||||
#else
|
#else
|
||||||
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
.gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED,
|
||||||
|
#endif
|
||||||
|
#if defined(CONFIG_BLE_MESH_FRIEND)
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_ENABLED,
|
||||||
|
#else
|
||||||
|
.friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED,
|
||||||
#endif
|
#endif
|
||||||
.default_ttl = 7,
|
.default_ttl = 7,
|
||||||
/* 3 transmissions with 20ms interval */
|
|
||||||
.net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
.relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Fast Prov Client Model user_data */
|
/* Fast Prov Client Model user_data */
|
||||||
@@ -90,6 +90,7 @@ example_fast_prov_server_t fast_prov_server = {
|
|||||||
.primary_role = false,
|
.primary_role = false,
|
||||||
.max_node_num = 6,
|
.max_node_num = 6,
|
||||||
.prov_node_cnt = 0x0,
|
.prov_node_cnt = 0x0,
|
||||||
|
.app_idx = ESP_BLE_MESH_KEY_UNUSED,
|
||||||
.unicast_min = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
.unicast_min = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
||||||
.unicast_max = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
.unicast_max = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
||||||
.unicast_cur = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
.unicast_cur = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
||||||
@@ -97,7 +98,6 @@ example_fast_prov_server_t fast_prov_server = {
|
|||||||
.flags = 0x0,
|
.flags = 0x0,
|
||||||
.iv_index = 0x0,
|
.iv_index = 0x0,
|
||||||
.net_idx = ESP_BLE_MESH_KEY_UNUSED,
|
.net_idx = ESP_BLE_MESH_KEY_UNUSED,
|
||||||
.app_idx = ESP_BLE_MESH_KEY_UNUSED,
|
|
||||||
.group_addr = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
.group_addr = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
||||||
.prim_prov_addr = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
.prim_prov_addr = ESP_BLE_MESH_ADDR_UNASSIGNED,
|
||||||
.match_len = 0x0,
|
.match_len = 0x0,
|
||||||
@@ -323,9 +323,9 @@ static void example_recv_unprov_adv_pkt(uint8_t dev_uuid[16], uint8_t addr[BLE_M
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add_dev.addr_type = (uint8_t)addr_type;
|
add_dev.addr_type = (esp_ble_mesh_addr_type_t)addr_type;
|
||||||
add_dev.oob_info = oob_info;
|
add_dev.oob_info = oob_info;
|
||||||
add_dev.bearer = (uint8_t)bearer;
|
add_dev.bearer = (esp_ble_mesh_prov_bearer_t)bearer;
|
||||||
memcpy(add_dev.uuid, dev_uuid, 16);
|
memcpy(add_dev.uuid, dev_uuid, 16);
|
||||||
memcpy(add_dev.addr, addr, BLE_MESH_ADDR_LEN);
|
memcpy(add_dev.addr, addr, BLE_MESH_ADDR_LEN);
|
||||||
flag = ADD_DEV_RM_AFTER_PROV_FLAG | ADD_DEV_START_PROV_NOW_FLAG | ADD_DEV_FLUSHABLE_DEV_FLAG;
|
flag = ADD_DEV_RM_AFTER_PROV_FLAG | ADD_DEV_START_PROV_NOW_FLAG | ADD_DEV_FLUSHABLE_DEV_FLAG;
|
||||||
@@ -466,8 +466,8 @@ static void example_ble_mesh_custom_model_cb(esp_ble_mesh_model_cb_event_t event
|
|||||||
case ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NODE_GROUP_DELETE: {
|
case ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NODE_GROUP_DELETE: {
|
||||||
ESP_LOGI(TAG, "%s: Fast prov server receives msg, opcode 0x%04" PRIx32, __func__, opcode);
|
ESP_LOGI(TAG, "%s: Fast prov server receives msg, opcode 0x%04" PRIx32, __func__, opcode);
|
||||||
struct net_buf_simple buf = {
|
struct net_buf_simple buf = {
|
||||||
.len = param->model_operation.length,
|
|
||||||
.data = param->model_operation.msg,
|
.data = param->model_operation.msg,
|
||||||
|
.len = param->model_operation.length,
|
||||||
};
|
};
|
||||||
err = example_fast_prov_server_recv_msg(param->model_operation.model,
|
err = example_fast_prov_server_recv_msg(param->model_operation.model,
|
||||||
param->model_operation.ctx, &buf);
|
param->model_operation.ctx, &buf);
|
||||||
|
Reference in New Issue
Block a user