Skip to content
Permalink
Browse files

Bluetooth: Make RSSI value available to mesh applications

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 <tobias.svehagen@gmail.com>
  • Loading branch information...
tsvehagen authored and jhedberg committed Jun 11, 2019
1 parent 4ddbc00 commit 4866fa9e58d801236bbe92e7434d34e2ef44bf76
@@ -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;

@@ -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;
}
@@ -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);
@@ -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 */

0 comments on commit 4866fa9

Please sign in to comment.
You can’t perform that action at this time.