ble_mesh: miscellaneous modifications
1. Clean up client_common.c 2. Clean up esp_ble_mesh directory 3. Update Kconfig.in 4. Format esp_ble_mesh files
This commit is contained in:
parent
30aa236219
commit
2bba9d7700
|
@ -311,9 +311,10 @@ if(CONFIG_BT_ENABLED)
|
||||||
|
|
||||||
if(CONFIG_BLE_MESH)
|
if(CONFIG_BLE_MESH)
|
||||||
list(APPEND include_dirs
|
list(APPEND include_dirs
|
||||||
|
"esp_ble_mesh/mesh_common/include"
|
||||||
"esp_ble_mesh/mesh_core"
|
"esp_ble_mesh/mesh_core"
|
||||||
"esp_ble_mesh/mesh_core/include"
|
"esp_ble_mesh/mesh_core/include"
|
||||||
"esp_ble_mesh/mesh_core/settings"
|
"esp_ble_mesh/mesh_core/storage"
|
||||||
"esp_ble_mesh/btc/include"
|
"esp_ble_mesh/btc/include"
|
||||||
"esp_ble_mesh/mesh_models/common/include"
|
"esp_ble_mesh/mesh_models/common/include"
|
||||||
"esp_ble_mesh/mesh_models/client/include"
|
"esp_ble_mesh/mesh_models/client/include"
|
||||||
|
@ -341,7 +342,13 @@ if(CONFIG_BT_ENABLED)
|
||||||
"esp_ble_mesh/btc/btc_ble_mesh_prov.c"
|
"esp_ble_mesh/btc/btc_ble_mesh_prov.c"
|
||||||
"esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c"
|
"esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c"
|
||||||
"esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c"
|
"esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c"
|
||||||
"esp_ble_mesh/mesh_core/settings/settings_nvs.c"
|
"esp_ble_mesh/mesh_common/mesh_aes_encrypt.c"
|
||||||
|
"esp_ble_mesh/mesh_common/mesh_atomic.c"
|
||||||
|
"esp_ble_mesh/mesh_common/mesh_buf.c"
|
||||||
|
"esp_ble_mesh/mesh_common/mesh_common.c"
|
||||||
|
"esp_ble_mesh/mesh_common/mesh_kernel.c"
|
||||||
|
"esp_ble_mesh/mesh_common/mesh_util.c"
|
||||||
|
"esp_ble_mesh/mesh_core/storage/settings_nvs.c"
|
||||||
"esp_ble_mesh/mesh_core/access.c"
|
"esp_ble_mesh/mesh_core/access.c"
|
||||||
"esp_ble_mesh/mesh_core/adv.c"
|
"esp_ble_mesh/mesh_core/adv.c"
|
||||||
"esp_ble_mesh/mesh_core/beacon.c"
|
"esp_ble_mesh/mesh_core/beacon.c"
|
||||||
|
@ -352,12 +359,7 @@ if(CONFIG_BT_ENABLED)
|
||||||
"esp_ble_mesh/mesh_core/health_cli.c"
|
"esp_ble_mesh/mesh_core/health_cli.c"
|
||||||
"esp_ble_mesh/mesh_core/health_srv.c"
|
"esp_ble_mesh/mesh_core/health_srv.c"
|
||||||
"esp_ble_mesh/mesh_core/lpn.c"
|
"esp_ble_mesh/mesh_core/lpn.c"
|
||||||
"esp_ble_mesh/mesh_core/mesh_aes_encrypt.c"
|
"esp_ble_mesh/mesh_core/main.c"
|
||||||
"esp_ble_mesh/mesh_core/mesh_atomic.c"
|
|
||||||
"esp_ble_mesh/mesh_core/mesh_buf.c"
|
|
||||||
"esp_ble_mesh/mesh_core/mesh_kernel.c"
|
|
||||||
"esp_ble_mesh/mesh_core/mesh_main.c"
|
|
||||||
"esp_ble_mesh/mesh_core/mesh_util.c"
|
|
||||||
"esp_ble_mesh/mesh_core/net.c"
|
"esp_ble_mesh/mesh_core/net.c"
|
||||||
"esp_ble_mesh/mesh_core/prov.c"
|
"esp_ble_mesh/mesh_core/prov.c"
|
||||||
"esp_ble_mesh/mesh_core/provisioner_beacon.c"
|
"esp_ble_mesh/mesh_core/provisioner_beacon.c"
|
||||||
|
@ -368,7 +370,6 @@ if(CONFIG_BT_ENABLED)
|
||||||
"esp_ble_mesh/mesh_core/settings.c"
|
"esp_ble_mesh/mesh_core/settings.c"
|
||||||
"esp_ble_mesh/mesh_core/test.c"
|
"esp_ble_mesh/mesh_core/test.c"
|
||||||
"esp_ble_mesh/mesh_core/transport.c"
|
"esp_ble_mesh/mesh_core/transport.c"
|
||||||
"esp_ble_mesh/mesh_models/common/mesh_common.c"
|
|
||||||
"esp_ble_mesh/mesh_models/client/client_common.c"
|
"esp_ble_mesh/mesh_models/client/client_common.c"
|
||||||
"esp_ble_mesh/mesh_models/client/generic_client.c"
|
"esp_ble_mesh/mesh_models/client/generic_client.c"
|
||||||
"esp_ble_mesh/mesh_models/client/lighting_client.c"
|
"esp_ble_mesh/mesh_models/client/lighting_client.c"
|
||||||
|
|
|
@ -140,9 +140,10 @@ endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef CONFIG_BLE_MESH
|
ifdef CONFIG_BLE_MESH
|
||||||
COMPONENT_ADD_INCLUDEDIRS += esp_ble_mesh/mesh_core \
|
COMPONENT_ADD_INCLUDEDIRS += esp_ble_mesh/mesh_common/include \
|
||||||
|
esp_ble_mesh/mesh_core \
|
||||||
esp_ble_mesh/mesh_core/include \
|
esp_ble_mesh/mesh_core/include \
|
||||||
esp_ble_mesh/mesh_core/settings \
|
esp_ble_mesh/mesh_core/storage \
|
||||||
esp_ble_mesh/btc/include \
|
esp_ble_mesh/btc/include \
|
||||||
esp_ble_mesh/mesh_models/common/include \
|
esp_ble_mesh/mesh_models/common/include \
|
||||||
esp_ble_mesh/mesh_models/client/include \
|
esp_ble_mesh/mesh_models/client/include \
|
||||||
|
@ -151,10 +152,10 @@ COMPONENT_ADD_INCLUDEDIRS += esp_ble_mesh/mesh_core \
|
||||||
esp_ble_mesh/api/models/include \
|
esp_ble_mesh/api/models/include \
|
||||||
esp_ble_mesh/api
|
esp_ble_mesh/api
|
||||||
|
|
||||||
COMPONENT_SRCDIRS += esp_ble_mesh/mesh_core \
|
COMPONENT_SRCDIRS += esp_ble_mesh/mesh_common \
|
||||||
esp_ble_mesh/mesh_core/settings \
|
esp_ble_mesh/mesh_core \
|
||||||
|
esp_ble_mesh/mesh_core/storage \
|
||||||
esp_ble_mesh/btc \
|
esp_ble_mesh/btc \
|
||||||
esp_ble_mesh/mesh_models/common \
|
|
||||||
esp_ble_mesh/mesh_models/client \
|
esp_ble_mesh/mesh_models/client \
|
||||||
esp_ble_mesh/mesh_models/server \
|
esp_ble_mesh/mesh_models/server \
|
||||||
esp_ble_mesh/api/core \
|
esp_ble_mesh/api/core \
|
||||||
|
|
|
@ -60,7 +60,7 @@ if BLE_MESH
|
||||||
config BLE_MESH_MAX_STORED_NODES
|
config BLE_MESH_MAX_STORED_NODES
|
||||||
int "Maximum number of nodes whose information can be stored"
|
int "Maximum number of nodes whose information can be stored"
|
||||||
default 20
|
default 20
|
||||||
range 1 1000
|
range BLE_MESH_MAX_PROV_NODES 1000
|
||||||
help
|
help
|
||||||
This option specifies the maximum number of nodes whose information can be
|
This option specifies the maximum number of nodes whose information can be
|
||||||
stored by a Provisioner in its upper layer.
|
stored by a Provisioner in its upper layer.
|
||||||
|
@ -71,7 +71,7 @@ if BLE_MESH
|
||||||
config BLE_MESH_MAX_PROV_NODES
|
config BLE_MESH_MAX_PROV_NODES
|
||||||
int "Maximum number of devices that can be provisioned by Provisioner"
|
int "Maximum number of devices that can be provisioned by Provisioner"
|
||||||
default 20
|
default 20
|
||||||
range 1 100
|
range 1 1000
|
||||||
help
|
help
|
||||||
This option specifies how many devices can be provisioned by a Provisioner.
|
This option specifies how many devices can be provisioned by a Provisioner.
|
||||||
This value indicates the maximum number of unprovisioned devices which can be
|
This value indicates the maximum number of unprovisioned devices which can be
|
||||||
|
@ -161,8 +161,8 @@ if BLE_MESH
|
||||||
config BLE_MESH_GATT_PROXY_SERVER
|
config BLE_MESH_GATT_PROXY_SERVER
|
||||||
bool "BLE Mesh GATT Proxy Server"
|
bool "BLE Mesh GATT Proxy Server"
|
||||||
select BLE_MESH_PROXY
|
select BLE_MESH_PROXY
|
||||||
default y if BLE_MESH_NODE
|
depends on BLE_MESH_NODE
|
||||||
default n if BLE_MESH_PROVISIONER
|
default y
|
||||||
help
|
help
|
||||||
This option enables support for Mesh GATT Proxy Service, i.e. the
|
This option enables support for Mesh GATT Proxy Service, i.e. the
|
||||||
ability to act as a proxy between a Mesh GATT Client and a Mesh network.
|
ability to act as a proxy between a Mesh GATT Client and a Mesh network.
|
||||||
|
@ -427,6 +427,8 @@ if BLE_MESH
|
||||||
|
|
||||||
config BLE_MESH_RELAY
|
config BLE_MESH_RELAY
|
||||||
bool "Relay support"
|
bool "Relay support"
|
||||||
|
depends on BLE_MESH_NODE
|
||||||
|
default y
|
||||||
help
|
help
|
||||||
Support for acting as a Mesh Relay Node. Enabling this option will allow
|
Support for acting as a Mesh Relay Node. Enabling this option will allow
|
||||||
a node to support the Relay feature, and the Relay feature can still
|
a node to support the Relay feature, and the Relay feature can still
|
||||||
|
@ -457,7 +459,7 @@ if BLE_MESH
|
||||||
|
|
||||||
config BLE_MESH_LOW_POWER
|
config BLE_MESH_LOW_POWER
|
||||||
bool "Support for Low Power features"
|
bool "Support for Low Power features"
|
||||||
select BLE_MESH_NODE
|
depends on BLE_MESH_NODE
|
||||||
help
|
help
|
||||||
Enable this option to operate as a Low Power Node. If low power consumption
|
Enable this option to operate as a Low Power Node. If low power consumption
|
||||||
is required by a node, this option should be enabled. And once the node
|
is required by a node, this option should be enabled. And once the node
|
||||||
|
@ -581,7 +583,7 @@ if BLE_MESH
|
||||||
config BLE_MESH_LPN_GROUPS
|
config BLE_MESH_LPN_GROUPS
|
||||||
int "Number of groups the LPN can subscribe to"
|
int "Number of groups the LPN can subscribe to"
|
||||||
range 0 16384
|
range 0 16384
|
||||||
default 2
|
default 8
|
||||||
help
|
help
|
||||||
Maximum number of groups to which the LPN can subscribe.
|
Maximum number of groups to which the LPN can subscribe.
|
||||||
|
|
||||||
|
@ -589,7 +591,7 @@ if BLE_MESH
|
||||||
|
|
||||||
config BLE_MESH_FRIEND
|
config BLE_MESH_FRIEND
|
||||||
bool "Support for acting as a Friend Node"
|
bool "Support for acting as a Friend Node"
|
||||||
select BLE_MESH_NODE
|
depends on BLE_MESH_NODE
|
||||||
help
|
help
|
||||||
Enable this option to be able to act as a Friend Node.
|
Enable this option to be able to act as a Friend Node.
|
||||||
|
|
||||||
|
@ -724,16 +726,6 @@ if BLE_MESH
|
||||||
|
|
||||||
endmenu #BLE Mesh NET BUF DEBUG LOG LEVEL
|
endmenu #BLE Mesh NET BUF DEBUG LOG LEVEL
|
||||||
|
|
||||||
config BLE_MESH_IRQ_LOCK
|
|
||||||
bool "Used the IRQ lock instead of task lock"
|
|
||||||
help
|
|
||||||
To improve the real-time requirements of bt controller in BLE Mesh,
|
|
||||||
task lock is used to replace IRQ lock.
|
|
||||||
With this option enabled, interrupt lock instead of the mutex will
|
|
||||||
be used and the BLE Mesh stack will try to change interrupt level to
|
|
||||||
protect some critical situations. Users need to ensure that this option
|
|
||||||
is disabled so mutex will be used in the bottom layer.
|
|
||||||
|
|
||||||
config BLE_MESH_CLIENT_MSG_TIMEOUT
|
config BLE_MESH_CLIENT_MSG_TIMEOUT
|
||||||
int "Timeout(ms) for client message response"
|
int "Timeout(ms) for client message response"
|
||||||
range 100 1200000
|
range 100 1200000
|
||||||
|
|
|
@ -41,7 +41,13 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
|
||||||
|
|
||||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||||
|
|
||||||
|
if (ctx && ctx->addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
|
||||||
|
LOG_ERROR("%s, Invalid destination address 0x0000", __func__);
|
||||||
|
return ESP_ERR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
|
||||||
if (device_role > ROLE_FAST_PROV) {
|
if (device_role > ROLE_FAST_PROV) {
|
||||||
|
LOG_ERROR("%s, Invalid device role 0x%02x", __func__, device_role);
|
||||||
return ESP_ERR_INVALID_ARG;
|
return ESP_ERR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,12 +103,12 @@ esp_err_t esp_ble_mesh_proxy_client_disconnect(uint8_t conn_handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle,
|
esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle,
|
||||||
uint16_t net_idx, uint8_t filter_type)
|
uint16_t net_idx, esp_ble_mesh_proxy_filter_type_t filter_type)
|
||||||
{
|
{
|
||||||
btc_ble_mesh_prov_args_t arg = {0};
|
btc_ble_mesh_prov_args_t arg = {0};
|
||||||
btc_msg_t msg = {0};
|
btc_msg_t msg = {0};
|
||||||
|
|
||||||
if (filter_type > 0x01) {
|
if (filter_type > PROXY_FILTER_BLACKLIST) {
|
||||||
return ESP_ERR_INVALID_ARG;
|
return ESP_ERR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,14 @@ esp_err_t esp_ble_mesh_lpn_disable(bool force);
|
||||||
/**
|
/**
|
||||||
* @brief LPN tries to poll messages from the Friend Node.
|
* @brief LPN tries to poll messages from the Friend Node.
|
||||||
*
|
*
|
||||||
* @note Once called, Friend Poll will be sent to the Friend Node.
|
* @note The Friend Poll message is sent by a Low Power node to ask the Friend
|
||||||
|
* node to send a message that it has stored for the Low Power node.
|
||||||
|
* Users can call this API to send Friend Poll message manually. If this
|
||||||
|
* API is not invoked, the bottom layer of the Low Power node will send
|
||||||
|
* Friend Poll before the PollTimeout timer expires.
|
||||||
|
* If the corresponding Friend Update is received and MD is set to 0,
|
||||||
|
* which means there are no messages for the Low Power node, then the
|
||||||
|
* Low Power node will stop scanning.
|
||||||
*
|
*
|
||||||
* @return ESP_OK on success or error code otherwise.
|
* @return ESP_OK on success or error code otherwise.
|
||||||
*
|
*
|
||||||
|
|
|
@ -84,7 +84,7 @@ esp_err_t esp_ble_mesh_proxy_client_disconnect(uint8_t conn_handle);
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle,
|
esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle,
|
||||||
uint16_t net_idx, uint8_t filter_type);
|
uint16_t net_idx, esp_ble_mesh_proxy_filter_type_t filter_type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Proxy Client adds address to the Proxy Server filter list.
|
* @brief Proxy Client adds address to the Proxy Server filter list.
|
||||||
|
|
|
@ -695,6 +695,12 @@ typedef enum {
|
||||||
FAST_PROV_ACT_MAX,
|
FAST_PROV_ACT_MAX,
|
||||||
} esp_ble_mesh_fast_prov_action_t;
|
} esp_ble_mesh_fast_prov_action_t;
|
||||||
|
|
||||||
|
/*!< This enum value is the type of proxy filter */
|
||||||
|
typedef enum {
|
||||||
|
PROXY_FILTER_WHITELIST,
|
||||||
|
PROXY_FILTER_BLACKLIST,
|
||||||
|
} esp_ble_mesh_proxy_filter_type_t;
|
||||||
|
|
||||||
/*!< This enum value is the event of node/provisioner/fast provisioning */
|
/*!< This enum value is the event of node/provisioner/fast provisioning */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ESP_BLE_MESH_PROV_REGISTER_COMP_EVT, /*!< Initialize BLE Mesh provisioning capabilities and internal data information completion event */
|
ESP_BLE_MESH_PROV_REGISTER_COMP_EVT, /*!< Initialize BLE Mesh provisioning capabilities and internal data information completion event */
|
||||||
|
|
|
@ -513,8 +513,8 @@ typedef struct {
|
||||||
|
|
||||||
/** Parameters of Config Network Transmit Status */
|
/** Parameters of Config Network Transmit Status */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t net_trans_count:3; /*!< Number of transmissions for each Network PDU originating from the node */
|
uint8_t net_trans_count: 3; /*!< Number of transmissions for each Network PDU originating from the node */
|
||||||
uint8_t net_trans_step :5; /*!< Maximum hops when receiving Heartbeat messages */
|
uint8_t net_trans_step : 5; /*!< Maximum hops when receiving Heartbeat messages */
|
||||||
} esp_ble_mesh_cfg_net_trans_status_cb_t;
|
} esp_ble_mesh_cfg_net_trans_status_cb_t;
|
||||||
|
|
||||||
/** Parameters of Config SIG/Vendor Subscription List */
|
/** Parameters of Config SIG/Vendor Subscription List */
|
||||||
|
|
|
@ -1816,7 +1816,9 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
|
||||||
/* Callback operation completion events */
|
/* Callback operation completion events */
|
||||||
btc_ble_mesh_prov_set_complete_cb(¶m, act);
|
btc_ble_mesh_prov_set_complete_cb(¶m, act);
|
||||||
|
|
||||||
|
if (msg->arg) {
|
||||||
btc_ble_mesh_prov_arg_deep_free(msg);
|
btc_ble_mesh_prov_arg_deep_free(msg);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -544,8 +544,8 @@ struct net_buf {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct net_buf_data_cb {
|
struct net_buf_data_cb {
|
||||||
u8_t * (*alloc)(struct net_buf *buf, size_t *size, s32_t timeout);
|
u8_t *(*alloc)(struct net_buf *buf, size_t *size, s32_t timeout);
|
||||||
u8_t * (*ref)(struct net_buf *buf, u8_t *data);
|
u8_t *(*ref)(struct net_buf *buf, u8_t *data);
|
||||||
void (*unref)(struct net_buf *buf, u8_t *data);
|
void (*unref)(struct net_buf *buf, u8_t *data);
|
||||||
};
|
};
|
||||||
|
|
|
@ -39,25 +39,16 @@ typedef struct alarm_t {
|
||||||
|
|
||||||
unsigned int bt_mesh_irq_lock(void)
|
unsigned int bt_mesh_irq_lock(void)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_BLE_MESH_IRQ_LOCK) && CONFIG_BLE_MESH_IRQ_LOCK
|
/* Changed by Espressif. In BLE Mesh, in order to improve the real-time
|
||||||
unsigned int key = XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL);
|
* requirements of bt controller, we use task lock instead of IRQ lock.
|
||||||
return key;
|
|
||||||
#else
|
|
||||||
/* Change by Espressif. In BLE Mesh, in order to improve the real-time
|
|
||||||
* requirements of bt controller, we use task lock to replace IRQ lock.
|
|
||||||
*/
|
*/
|
||||||
osi_mutex_lock(&bm_irq_lock, OSI_MUTEX_MAX_TIMEOUT);
|
osi_mutex_lock(&bm_irq_lock, OSI_MUTEX_MAX_TIMEOUT);
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_mesh_irq_unlock(unsigned int key)
|
void bt_mesh_irq_unlock(unsigned int key)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_BLE_MESH_IRQ_LOCK) && CONFIG_BLE_MESH_IRQ_LOCK
|
|
||||||
XTOS_RESTORE_INTLEVEL(key);
|
|
||||||
#else
|
|
||||||
osi_mutex_unlock(&bm_irq_lock);
|
osi_mutex_unlock(&bm_irq_lock);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s64_t k_uptime_get(void)
|
s64_t k_uptime_get(void)
|
|
@ -73,6 +73,8 @@
|
||||||
/* 2 transmissions, 20ms interval */
|
/* 2 transmissions, 20ms interval */
|
||||||
#define POLL_XMIT BLE_MESH_TRANSMIT(1, 20)
|
#define POLL_XMIT BLE_MESH_TRANSMIT(1, 20)
|
||||||
|
|
||||||
|
#define FIRST_POLL_ATTEMPTS 6
|
||||||
|
|
||||||
static void (*lpn_cb)(u16_t friend_addr, bool established);
|
static void (*lpn_cb)(u16_t friend_addr, bool established);
|
||||||
|
|
||||||
static const char *state2str(int state)
|
static const char *state2str(int state)
|
||||||
|
@ -743,7 +745,7 @@ static void update_timeout(struct bt_mesh_lpn *lpn)
|
||||||
bt_mesh_scan_disable();
|
bt_mesh_scan_disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lpn->req_attempts < 6) {
|
if (lpn->req_attempts < FIRST_POLL_ATTEMPTS) {
|
||||||
BT_WARN("Retrying first Friend Poll");
|
BT_WARN("Retrying first Friend Poll");
|
||||||
lpn->sent_req = 0U;
|
lpn->sent_req = 0U;
|
||||||
if (send_friend_poll() == 0) {
|
if (send_friend_poll() == 0) {
|
||||||
|
@ -795,7 +797,7 @@ static void lpn_timeout(struct k_work *work)
|
||||||
k_delayed_work_submit(&lpn->timer, FRIEND_REQ_RETRY_TIMEOUT);
|
k_delayed_work_submit(&lpn->timer, FRIEND_REQ_RETRY_TIMEOUT);
|
||||||
break;
|
break;
|
||||||
case BLE_MESH_LPN_OFFER_RECV:
|
case BLE_MESH_LPN_OFFER_RECV:
|
||||||
if (lpn->req_attempts < 6) {
|
if (lpn->req_attempts < FIRST_POLL_ATTEMPTS) {
|
||||||
BT_WARN("Retrying the first Friend Poll, %d attempts", lpn->req_attempts);
|
BT_WARN("Retrying the first Friend Poll, %d attempts", lpn->req_attempts);
|
||||||
lpn->sent_req = 0U;
|
lpn->sent_req = 0U;
|
||||||
send_friend_poll();
|
send_friend_poll();
|
||||||
|
|
|
@ -158,7 +158,7 @@ static int ble_on_subscribe(uint16_t conn_handle,
|
||||||
"attr_handle=%d\n",
|
"attr_handle=%d\n",
|
||||||
error->status, conn_handle, attr->handle);
|
error->status, conn_handle, attr->handle);
|
||||||
|
|
||||||
for (j = i+1; j < ARRAY_SIZE(bt_mesh_gattc_info); j++) {
|
for (j = i + 1; j < ARRAY_SIZE(bt_mesh_gattc_info); j++) {
|
||||||
if ((bt_mesh_gattc_info[j].conn.handle == conn_handle) && bt_mesh_gattc_info[j].ccc_handle) {
|
if ((bt_mesh_gattc_info[j].conn.handle == conn_handle) && bt_mesh_gattc_info[j].ccc_handle) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ static int dsc_disced(uint16_t conn_handle, const struct ble_gatt_error *error,
|
||||||
/* All descriptors in this characteristic discovered; start discovering
|
/* All descriptors in this characteristic discovered; start discovering
|
||||||
* descriptors in the next characteristic.
|
* descriptors in the next characteristic.
|
||||||
*/
|
*/
|
||||||
for (j = i+1; j < ARRAY_SIZE(bt_mesh_gattc_info); j++) {
|
for (j = i + 1; j < ARRAY_SIZE(bt_mesh_gattc_info); j++) {
|
||||||
if ((bt_mesh_gattc_info[j].conn.handle == conn_handle) && bt_mesh_gattc_info[j].data_out_handle) {
|
if ((bt_mesh_gattc_info[j].conn.handle == conn_handle) && bt_mesh_gattc_info[j].data_out_handle) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,7 @@ static int chr_disced(uint16_t conn_handle, const struct ble_gatt_error *error,
|
||||||
/* All characteristics in this service discovered; start discovering
|
/* All characteristics in this service discovered; start discovering
|
||||||
* characteristics in the next service.
|
* characteristics in the next service.
|
||||||
*/
|
*/
|
||||||
for (j = i+1; j < ARRAY_SIZE(bt_mesh_gattc_info); j++) {
|
for (j = i + 1; j < ARRAY_SIZE(bt_mesh_gattc_info); j++) {
|
||||||
if ((bt_mesh_gattc_info[j].conn.handle == conn_handle) && (bt_mesh_gattc_info[j].start_handle > bt_mesh_gattc_info[j].end_handle)) {
|
if ((bt_mesh_gattc_info[j].conn.handle == conn_handle) && (bt_mesh_gattc_info[j].start_handle > bt_mesh_gattc_info[j].end_handle)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1503,12 +1503,13 @@ static int dummy_access_cb(uint16_t conn_handle, uint16_t attr_handle,
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct ble_gatt_svc_def svc_defs [] = {
|
static const struct ble_gatt_svc_def svc_defs [] = {
|
||||||
#ifdef CONFIG_BLE_MESH_GATT_PROXY
|
#ifdef CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
||||||
{
|
{
|
||||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||||
.uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROXY_VAL),
|
.uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROXY_VAL),
|
||||||
.includes = NULL,
|
.includes = NULL,
|
||||||
.characteristics = (struct ble_gatt_chr_def[]) { {
|
.characteristics = (struct ble_gatt_chr_def[])
|
||||||
|
{ {
|
||||||
.uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROXY_DATA_IN_VAL),
|
.uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROXY_DATA_IN_VAL),
|
||||||
.access_cb = proxy_char_access_cb,
|
.access_cb = proxy_char_access_cb,
|
||||||
.flags = BLE_GATT_CHR_F_WRITE_NO_RSP,
|
.flags = BLE_GATT_CHR_F_WRITE_NO_RSP,
|
||||||
|
@ -1518,7 +1519,8 @@ static const struct ble_gatt_svc_def svc_defs [] = {
|
||||||
.flags = BLE_GATT_CHR_F_NOTIFY,
|
.flags = BLE_GATT_CHR_F_NOTIFY,
|
||||||
}, {
|
}, {
|
||||||
0, /* No more characteristics in this service. */
|
0, /* No more characteristics in this service. */
|
||||||
} },
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_BLE_MESH_PB_GATT
|
#ifdef CONFIG_BLE_MESH_PB_GATT
|
||||||
|
@ -1526,7 +1528,8 @@ static const struct ble_gatt_svc_def svc_defs [] = {
|
||||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||||
.uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROV_VAL),
|
.uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROV_VAL),
|
||||||
.includes = NULL,
|
.includes = NULL,
|
||||||
.characteristics = (struct ble_gatt_chr_def[]) { {
|
.characteristics = (struct ble_gatt_chr_def[])
|
||||||
|
{ {
|
||||||
.uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROV_DATA_IN_VAL),
|
.uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROV_DATA_IN_VAL),
|
||||||
.access_cb = proxy_char_access_cb,
|
.access_cb = proxy_char_access_cb,
|
||||||
.flags = BLE_GATT_CHR_F_WRITE_NO_RSP,
|
.flags = BLE_GATT_CHR_F_WRITE_NO_RSP,
|
||||||
|
@ -1536,7 +1539,8 @@ static const struct ble_gatt_svc_def svc_defs [] = {
|
||||||
.flags = BLE_GATT_CHR_F_NOTIFY,
|
.flags = BLE_GATT_CHR_F_NOTIFY,
|
||||||
}, {
|
}, {
|
||||||
0, /* No more characteristics in this service. */
|
0, /* No more characteristics in this service. */
|
||||||
} },
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
@ -1546,7 +1550,7 @@ static const struct ble_gatt_svc_def svc_defs [] = {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void gatt_register_cb(struct ble_gatt_register_ctxt *ctxt,
|
void gatt_register_cb(struct ble_gatt_register_ctxt *ctxt,
|
||||||
void * arg )
|
void *arg )
|
||||||
{
|
{
|
||||||
if (ctxt->op == BLE_GATT_REGISTER_OP_SVC) {
|
if (ctxt->op == BLE_GATT_REGISTER_OP_SVC) {
|
||||||
if (ble_uuid_cmp(ctxt->svc.svc_def->uuid, BLE_UUID16_DECLARE(BT_UUID_MESH_PROXY_VAL)) == 0) {
|
if (ble_uuid_cmp(ctxt->svc.svc_def->uuid, BLE_UUID16_DECLARE(BT_UUID_MESH_PROXY_VAL)) == 0) {
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#if CONFIG_BLE_MESH_NODE
|
#if CONFIG_BLE_MESH_NODE
|
||||||
|
|
||||||
/* Not support enabling Proxy Client and Proxy Server simultaneously */
|
/* Not support enabling Proxy Client and Proxy Server simultaneously */
|
||||||
_Static_assert(!(IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) && IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT)),
|
_Static_assert(!(IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) &&IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT)),
|
||||||
"Not support Proxy Server and Proxy Client simultaneously");
|
"Not support Proxy Server and Proxy Client simultaneously");
|
||||||
|
|
||||||
#define PDU_TYPE(data) (data[0] & BIT_MASK(6))
|
#define PDU_TYPE(data) (data[0] & BIT_MASK(6))
|
||||||
|
|
|
@ -26,6 +26,24 @@
|
||||||
#include "mesh.h"
|
#include "mesh.h"
|
||||||
#include "client_common.h"
|
#include "client_common.h"
|
||||||
|
|
||||||
|
static bt_mesh_client_node_t *bt_mesh_client_pick_node(sys_slist_t *list, u16_t tx_dst)
|
||||||
|
{
|
||||||
|
if (sys_slist_is_empty(list)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
sys_snode_t *cur = NULL; bt_mesh_client_node_t *node = NULL;
|
||||||
|
for (cur = sys_slist_peek_head(list);
|
||||||
|
cur != NULL; cur = sys_slist_peek_next(cur)) {
|
||||||
|
node = (bt_mesh_client_node_t *)cur;
|
||||||
|
if (node->ctx.addr == tx_dst) {
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(
|
bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(
|
||||||
struct bt_mesh_model *model,
|
struct bt_mesh_model *model,
|
||||||
struct bt_mesh_msg_ctx *ctx,
|
struct bt_mesh_msg_ctx *ctx,
|
||||||
|
@ -34,7 +52,6 @@ bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(
|
||||||
bt_mesh_client_internal_data_t *data = NULL;
|
bt_mesh_client_internal_data_t *data = NULL;
|
||||||
bt_mesh_client_user_data_t *cli = NULL;
|
bt_mesh_client_user_data_t *cli = NULL;
|
||||||
bt_mesh_client_node_t *node = NULL;
|
bt_mesh_client_node_t *node = NULL;
|
||||||
u32_t rsp;
|
|
||||||
|
|
||||||
if (!model || !ctx || !buf) {
|
if (!model || !ctx || !buf) {
|
||||||
BT_ERR("%s, Invalid parameter", __func__);
|
BT_ERR("%s, Invalid parameter", __func__);
|
||||||
|
@ -47,16 +64,14 @@ bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
rsp = ctx->recv_op;
|
|
||||||
|
|
||||||
/** If the received message address is not a unicast address,
|
/** If the received message address is not a unicast address,
|
||||||
* the address may be a group/virtual address, and we push
|
* the address may be a group/virtual address, and we push
|
||||||
* this message to the application layer.
|
* this message to the application layer.
|
||||||
*/
|
*/
|
||||||
if (!BLE_MESH_ADDR_IS_UNICAST(ctx->recv_dst)) {
|
if (!BLE_MESH_ADDR_IS_UNICAST(ctx->recv_dst)) {
|
||||||
BT_DBG("Unexpected status message 0x%x", rsp);
|
BT_DBG("Unexpected status message 0x%x", ctx->recv_op);
|
||||||
if (cli->publish_status && need_pub) {
|
if (cli->publish_status && need_pub) {
|
||||||
cli->publish_status(rsp, model, ctx, buf);
|
cli->publish_status(ctx->recv_op, model, ctx, buf);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -73,17 +88,17 @@ bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((node = bt_mesh_client_pick_node(&data->queue, ctx->addr)) == NULL) {
|
if ((node = bt_mesh_client_pick_node(&data->queue, ctx->addr)) == NULL) {
|
||||||
BT_DBG("Unexpected status message 0x%x", rsp);
|
BT_DBG("Unexpected status message 0x%x", ctx->recv_op);
|
||||||
if (cli->publish_status && need_pub) {
|
if (cli->publish_status && need_pub) {
|
||||||
cli->publish_status(rsp, model, ctx, buf);
|
cli->publish_status(ctx->recv_op, model, ctx, buf);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node->op_pending != rsp) {
|
if (node->op_pending != ctx->recv_op) {
|
||||||
BT_DBG("Unexpected status message 0x%x", rsp);
|
BT_DBG("Unexpected status message 0x%x", ctx->recv_op);
|
||||||
if (cli->publish_status && need_pub) {
|
if (cli->publish_status && need_pub) {
|
||||||
cli->publish_status(rsp, model, ctx, buf);
|
cli->publish_status(ctx->recv_op, model, ctx, buf);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -91,26 +106,7 @@ bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bt_mesh_client_find_opcode_in_list(sys_slist_t *list, u32_t opcode)
|
static bool bt_mesh_client_check_node_in_list(sys_slist_t *list, u16_t tx_dst)
|
||||||
{
|
|
||||||
if (sys_slist_is_empty(list)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
sys_snode_t *cur = NULL; bt_mesh_client_node_t *node = NULL;
|
|
||||||
for (cur = sys_slist_peek_head(list);
|
|
||||||
cur != NULL; cur = sys_slist_peek_next(cur)) {
|
|
||||||
node = (bt_mesh_client_node_t *)cur;
|
|
||||||
if (node->op_pending == opcode) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool bt_mesh_client_check_node_in_list(sys_slist_t *list, u16_t tx_dst)
|
|
||||||
{
|
{
|
||||||
if (sys_slist_is_empty(list)) {
|
if (sys_slist_is_empty(list)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -128,24 +124,6 @@ bool bt_mesh_client_check_node_in_list(sys_slist_t *list, u16_t tx_dst)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bt_mesh_client_node_t *bt_mesh_client_pick_node(sys_slist_t *list, u16_t tx_dst)
|
|
||||||
{
|
|
||||||
if (sys_slist_is_empty(list)) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
sys_snode_t *cur = NULL; bt_mesh_client_node_t *node = NULL;
|
|
||||||
for (cur = sys_slist_peek_head(list);
|
|
||||||
cur != NULL; cur = sys_slist_peek_next(cur)) {
|
|
||||||
node = (bt_mesh_client_node_t *)cur;
|
|
||||||
if (node->ctx.addr == tx_dst) {
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static u32_t bt_mesh_client_get_status_op(const bt_mesh_client_op_pair_t *op_pair,
|
static u32_t bt_mesh_client_get_status_op(const bt_mesh_client_op_pair_t *op_pair,
|
||||||
int size, u32_t opcode)
|
int size, u32_t opcode)
|
||||||
{
|
{
|
||||||
|
|
|
@ -98,12 +98,6 @@ bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(
|
||||||
struct bt_mesh_msg_ctx *ctx,
|
struct bt_mesh_msg_ctx *ctx,
|
||||||
struct net_buf_simple *buf, bool need_pub);
|
struct net_buf_simple *buf, bool need_pub);
|
||||||
|
|
||||||
bool bt_mesh_client_find_opcode_in_list(sys_slist_t *list, u32_t opcode);
|
|
||||||
|
|
||||||
bool bt_mesh_client_check_node_in_list(sys_slist_t *list, uint16_t tx_dst);
|
|
||||||
|
|
||||||
bt_mesh_client_node_t *bt_mesh_client_pick_node(sys_slist_t *list, u16_t tx_dst);
|
|
||||||
|
|
||||||
int bt_mesh_client_send_msg(struct bt_mesh_model *model,
|
int bt_mesh_client_send_msg(struct bt_mesh_model *model,
|
||||||
u32_t opcode,
|
u32_t opcode,
|
||||||
struct bt_mesh_msg_ctx *ctx,
|
struct bt_mesh_msg_ctx *ctx,
|
||||||
|
|
|
@ -2332,8 +2332,12 @@ const struct bt_mesh_model_op gen_client_prop_srv_op[] = {
|
||||||
|
|
||||||
static inline int property_id_compare(const void *p1, const void *p2)
|
static inline int property_id_compare(const void *p1, const void *p2)
|
||||||
{
|
{
|
||||||
if (*(u16_t *)p1 < *(u16_t *)p2) return -1;
|
if (*(u16_t *)p1 < * (u16_t *)p2) {
|
||||||
if (*(u16_t *)p1 > *(u16_t *)p2) return 1;
|
return -1;
|
||||||
|
}
|
||||||
|
if (*(u16_t *)p1 > *(u16_t *)p2) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,3 +223,5 @@ CONFIG_BLE_HOST_QUEUE_CONGESTION_CHECK CONFIG_BT_BLE_HOST_Q
|
||||||
CONFIG_SMP_ENABLE CONFIG_BT_SMP_ENABLE
|
CONFIG_SMP_ENABLE CONFIG_BT_SMP_ENABLE
|
||||||
CONFIG_BLE_ACTIVE_SCAN_REPORT_ADV_SCAN_RSP_INDIVIDUALLY CONFIG_BT_BLE_ACT_SCAN_REP_ADV_SCAN
|
CONFIG_BLE_ACTIVE_SCAN_REPORT_ADV_SCAN_RSP_INDIVIDUALLY CONFIG_BT_BLE_ACT_SCAN_REP_ADV_SCAN
|
||||||
CONFIG_BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT CONFIG_BT_BLE_ESTAB_LINK_CONN_TOUT
|
CONFIG_BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT CONFIG_BT_BLE_ESTAB_LINK_CONN_TOUT
|
||||||
|
|
||||||
|
CONFIG_BLE_MESH_GATT_PROXY CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
Loading…
Reference in a new issue