mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 09:39:10 -04:00
ble_mesh: introduce a helper for send callback function
This commit is contained in:
parent
05128c98ec
commit
9a672caa7e
@ -785,7 +785,7 @@ int bt_mesh_net_resend(struct bt_mesh_subnet *sub, struct net_buf *buf,
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY) &&
|
||||
bt_mesh_proxy_relay(&buf->b, dst)) {
|
||||
net_buf_unref(buf);
|
||||
send_cb_finalize(cb, cb_data);
|
||||
} else {
|
||||
bt_mesh_adv_send(buf, cb, cb_data);
|
||||
}
|
||||
@ -901,15 +901,7 @@ int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct net_buf *buf,
|
||||
/* Notify completion if this only went
|
||||
* through the Mesh Proxy.
|
||||
*/
|
||||
if (cb) {
|
||||
if (cb->start) {
|
||||
cb->start(0, 0, cb_data);
|
||||
}
|
||||
|
||||
if (cb->end) {
|
||||
cb->end(0, cb_data);
|
||||
}
|
||||
}
|
||||
send_cb_finalize(cb, cb_data);
|
||||
|
||||
err = 0;
|
||||
goto done;
|
||||
|
@ -385,4 +385,20 @@ struct friend_cred *friend_cred_create(struct bt_mesh_subnet *sub, u16_t addr,
|
||||
void friend_cred_clear(struct friend_cred *cred);
|
||||
int friend_cred_del(u16_t net_idx, u16_t addr);
|
||||
|
||||
static inline void send_cb_finalize(const struct bt_mesh_send_cb *cb,
|
||||
void *cb_data)
|
||||
{
|
||||
if (!cb) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cb->start) {
|
||||
cb->start(0, 0, cb_data);
|
||||
}
|
||||
|
||||
if (cb->end) {
|
||||
cb->end(0, cb_data);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _NET_H_ */
|
||||
|
@ -148,6 +148,7 @@ static int send_unseg(struct bt_mesh_net_tx *tx, struct net_buf_simple *sdu,
|
||||
* out through the Friend Queue.
|
||||
*/
|
||||
net_buf_unref(buf);
|
||||
send_cb_finalize(cb, cb_data);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -435,14 +436,7 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu,
|
||||
* there's no other way to track this (at least currently)
|
||||
* with the Friend Queue.
|
||||
*/
|
||||
if (cb) {
|
||||
if (cb->start) {
|
||||
cb->start(0, 0, cb_data);
|
||||
}
|
||||
if (cb->end) {
|
||||
cb->end(0, cb_data);
|
||||
}
|
||||
}
|
||||
send_cb_finalize(cb, cb_data);
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user