ble_mesh: stack: Avoid using assert in mesh stack

This commit is contained in:
lly 2020-08-21 15:15:06 +08:00
parent aa8fffcd73
commit 67055161c1
4 changed files with 19 additions and 10 deletions

View File

@ -447,7 +447,7 @@ static void mod_publish(struct k_work *work)
BT_DBG("%s", __func__);
period_ms = bt_mesh_model_pub_period_get(pub->mod);
BT_INFO("period %u ms", period_ms);
BT_INFO("Publish period %u ms", period_ms);
if (pub->count) {
err = publish_retransmit(pub->mod);
@ -469,14 +469,11 @@ static void mod_publish(struct k_work *work)
return;
}
__ASSERT_NO_MSG(pub->update != NULL);
/* Callback the model publish update event to the application layer.
* In the event, users can update the context of the publish message
* which will be published in the next period.
*/
err = pub->update(pub->mod);
if (err) {
if (pub->update && pub->update(pub->mod)) {
/* Cancel this publish attempt. */
BT_ERR("Update failed, skipping publish (err %d)", err);
pub->period_start = k_uptime_get_32();

View File

@ -559,7 +559,10 @@ static struct net_buf *encode_update(struct bt_mesh_friend *frnd, u8_t md)
NET_BUF_SIMPLE_DEFINE(sdu, 1 + sizeof(*upd));
struct bt_mesh_subnet *sub = friend_subnet_get(frnd->net_idx);
__ASSERT_NO_MSG(sub != NULL);
if (!sub) {
BT_ERR("Friend subnet 0x%04x not found", frnd->net_idx);
return NULL;
}
BT_DBG("lpn 0x%04x md 0x%02x", frnd->lpn, md);
@ -1194,7 +1197,10 @@ static void friend_timeout(struct k_work *work)
.end = buf_send_end,
};
__ASSERT_NO_MSG(frnd->pending_buf == 0U);
if (frnd->pending_buf != 0U) {
BT_ERR("Previous buffer not yet sent!");
return;
}
BT_DBG("lpn 0x%04x send_last %u last %p", frnd->lpn,
frnd->send_last, frnd->last);

View File

@ -834,7 +834,7 @@ static void lpn_timeout(struct k_work *work)
update_timeout(lpn);
break;
default:
__ASSERT(0, "Unhandled LPN state");
BT_ERR("Unhandled LPN state");
break;
}
}

View File

@ -660,7 +660,10 @@ static ssize_t prov_ccc_write(struct bt_mesh_conn *conn,
/* If a connection exists there must be a client */
client = find_client(conn);
__ASSERT(client, "No client for connection");
if (!client) {
BT_ERR("No client for connection %p", conn);
return 0;
}
if (client->filter_type == NONE) {
client->filter_type = PROV;
@ -795,7 +798,10 @@ static ssize_t proxy_ccc_write(struct bt_mesh_conn *conn,
/* If a connection exists there must be a client */
client = find_client(conn);
__ASSERT(client, "No client for connection");
if (!client) {
BT_ERR("No client for connection %p", conn);
return 0;
}
if (client->filter_type == NONE) {
client->filter_type = WHITELIST;