Bluetooth: Mesh: Introduce a helper for send callback finalization
There are several places that require the send callbacks to be called immediately. Reduce the code a bit by introducing a helper for this. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
a62f609cd9
commit
104d30c989
3 changed files with 18 additions and 18 deletions
|
@ -897,15 +897,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;
|
||||
|
|
|
@ -362,3 +362,19 @@ struct friend_cred *friend_cred_create(struct bt_mesh_subnet *sub, u16_t addr,
|
|||
u16_t lpn_counter, u16_t frnd_counter);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -426,15 +426,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_BT_MESH_LOW_POWER) &&
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue