Skip to content

Commit

Permalink
Bluetooth: Make RSSI value available to mesh applications
Browse files Browse the repository at this point in the history
By moving the rssi value from the bt_mesh_net_rx struct to the
bt_mesh_msg_ctx struct, it will be available to applications via
the mesh op callbacks.

Signed-off-by: Tobias Svehagen <[email protected]>
  • Loading branch information
tsvehagen authored and jhedberg committed Jun 12, 2019
1 parent 4ddbc00 commit 4866fa9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions include/bluetooth/mesh/access.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ struct bt_mesh_msg_ctx {
/** Destination address of a received message. Not used for sending. */
u16_t recv_dst;

/** RSSI of received packet. Not used for sending. */
s8_t recv_rssi;

/** Received TTL value. Not used for sending. */
u8_t recv_ttl:7;

Expand Down
7 changes: 4 additions & 3 deletions subsys/bluetooth/host/mesh/friend.c
Original file line number Diff line number Diff line change
Expand Up @@ -876,20 +876,21 @@ int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
frnd->clear.frnd = sys_be16_to_cpu(msg->prev_addr);

BT_DBG("LPN 0x%04x rssi %d recv_delay %u poll_to %ums",
frnd->lpn, rx->rssi, frnd->recv_delay, frnd->poll_to);
frnd->lpn, rx->ctx.recv_rssi, frnd->recv_delay, frnd->poll_to);

if (BT_MESH_ADDR_IS_UNICAST(frnd->clear.frnd) &&
!bt_mesh_elem_find(frnd->clear.frnd)) {
clear_procedure_start(frnd);
}

k_delayed_work_submit(&frnd->timer,
offer_delay(frnd, rx->rssi, msg->criteria));
offer_delay(frnd, rx->ctx.recv_rssi,
msg->criteria));

friend_cred_create(rx->sub, frnd->lpn, frnd->lpn_counter,
frnd->counter);

enqueue_offer(frnd, rx->rssi);
enqueue_offer(frnd, rx->ctx.recv_rssi);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/host/mesh/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,7 @@ void bt_mesh_net_recv(struct net_buf_simple *data, s8_t rssi,
enum bt_mesh_net_if net_if)
{
NET_BUF_SIMPLE_DEFINE(buf, 29);
struct bt_mesh_net_rx rx = { .rssi = rssi };
struct bt_mesh_net_rx rx = { .ctx.recv_rssi = rssi };
struct net_buf_simple_state state;

BT_DBG("rssi %d net_if %u", rssi, net_if);
Expand Down
1 change: 0 additions & 1 deletion subsys/bluetooth/host/mesh/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ struct bt_mesh_net_rx {
net_if:2, /* Network interface */
local_match:1, /* Matched a local element */
friend_match:1; /* Matched an LPN we're friends for */
s8_t rssi;
};

/* Encoding context for Network/Transport data */
Expand Down

0 comments on commit 4866fa9

Please sign in to comment.