This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
     new 76b9d1c80 nimble/ll: Simplify RSSI value update
76b9d1c80 is described below

commit 76b9d1c80743bd16708c885bac200fa5576f5dc0
Author: Mariusz Skamra <[email protected]>
AuthorDate: Thu Jan 15 10:15:13 2026 +0100

    nimble/ll: Simplify RSSI value update
    
    This updates the RSSI value with LNA introduced gain and RX power
    compensation value defined by user in one place.
    This makes the code cleaner and easier to maintain.
---
 nimble/controller/src/ble_ll.c          | 3 +++
 nimble/controller/src/ble_ll_conn.c     | 2 +-
 nimble/controller/src/ble_ll_scan.c     | 6 +++---
 nimble/controller/src/ble_ll_scan_aux.c | 4 ++--
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/nimble/controller/src/ble_ll.c b/nimble/controller/src/ble_ll.c
index bff525da7..b04db7666 100644
--- a/nimble/controller/src/ble_ll.c
+++ b/nimble/controller/src/ble_ll.c
@@ -1189,6 +1189,9 @@ ble_ll_rx_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr)
     ble_ll_trace_u32x3(BLE_LL_TRACE_ID_RX_END, pdu_type, len,
                        rxhdr->rxinfo.flags);
 
+    /* Update RSSI */
+    rxhdr->rxinfo.rssi -= ble_ll_rx_gain();
+
 #if MYNEWT_VAL(BLE_LL_EXT)
     if (BLE_MBUF_HDR_RX_STATE(rxhdr) == BLE_LL_STATE_EXTERNAL) {
         rc = ble_ll_ext_rx_isr_end(rxbuf, rxhdr);
diff --git a/nimble/controller/src/ble_ll_conn.c 
b/nimble/controller/src/ble_ll_conn.c
index cc073aaf6..a243bf8a8 100644
--- a/nimble/controller/src/ble_ll_conn.c
+++ b/nimble/controller/src/ble_ll_conn.c
@@ -3580,7 +3580,7 @@ ble_ll_conn_rx_data_pdu(struct os_mbuf *rxpdu, struct 
ble_mbuf_hdr *hdr)
 #endif
 
     /* Update RSSI */
-    connsm->conn_rssi = hdr->rxinfo.rssi - ble_ll_rx_gain();
+    connsm->conn_rssi = hdr->rxinfo.rssi;
 
     /*
      * If we are a peripheral, we can only start to use peripheral latency
diff --git a/nimble/controller/src/ble_ll_scan.c 
b/nimble/controller/src/ble_ll_scan.c
index 0f73fd2e8..6860de205 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -718,7 +718,7 @@ ble_ll_scan_send_adv_report(uint8_t pdu_type,
     if (scansm->ext_scanning) {
         rc = ble_ll_hci_send_legacy_ext_adv_report(evtype,
                                                    adva, adva_type,
-                                                   hdr->rxinfo.rssi - 
ble_ll_rx_gain(),
+                                                   hdr->rxinfo.rssi,
                                                    adv_data_len, om,
                                                    inita, inita_type);
 goto done;
@@ -727,12 +727,12 @@ goto done;
 
     if (subev == BLE_HCI_LE_SUBEV_DIRECT_ADV_RPT) {
         rc = ble_ll_hci_send_dir_adv_report(adva, adva_type, inita, inita_type,
-                                            hdr->rxinfo.rssi - 
ble_ll_rx_gain());
+                                            hdr->rxinfo.rssi);
         goto done;
     }
 
     rc = ble_ll_hci_send_adv_report(evtype, adva, adva_type,
-                                    hdr->rxinfo.rssi - ble_ll_rx_gain(),
+                                    hdr->rxinfo.rssi,
                                     adv_data_len, om);
 done:
     if (!rc && scansm->scan_filt_dups) {
diff --git a/nimble/controller/src/ble_ll_scan_aux.c 
b/nimble/controller/src/ble_ll_scan_aux.c
index 0cb734a24..3815380cb 100644
--- a/nimble/controller/src/ble_ll_scan_aux.c
+++ b/nimble/controller/src/ble_ll_scan_aux.c
@@ -435,7 +435,7 @@ ble_ll_hci_ev_update_ext_adv_report_from_ext(struct 
ble_hci_ev *hci_ev,
     report->pri_phy = rxinfo->phy;
     report->sec_phy = 0;
     report->sid = 0xff;
-    report->rssi = rxhdr->rxinfo.rssi - ble_ll_rx_gain();
+    report->rssi = rxhdr->rxinfo.rssi;
     report->periodic_itvl = 0;
     report->data_len = 0;
 
@@ -564,7 +564,7 @@ ble_ll_hci_ev_send_ext_adv_report(struct os_mbuf *rxpdu,
         hci_subev = (void *)(*hci_ev)->data;
         report = hci_subev->reports;
 
-        report->rssi = rxinfo->rssi - ble_ll_rx_gain();
+        report->rssi = rxinfo->rssi;
 
         report->data_len = MIN(max_data_len, data_len - offset);
         os_mbuf_copydata(rxpdu, offset, report->data_len, report->data);

Reply via email to