Is there a working example of reading RSSI values in a BLE connection?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

Hi,

I've looked on this site and tried some project code left with some of the discussions.

Forum Links I've tried:

PSoC6 RSSI value measurement issue

Is it possible to read RSSI value when core is in Deepsleep

I'm trying to read the RSSI values of received BLE messages with no real success.

Are there any working examples of accomplishing this goal?

I'm probably missing something simple.

Len

Len
"Engineering is an Art. The Art of Compromise."
1 Solution
ShipingW_81
Moderator
Moderator
Moderator
500 replies posted 250 solutions authored 250 replies posted

Assuming you send data through Notification.

To get RSSI value, Cy_BLE_GetRssiPeer() is called at every time event #CY_BLE_EVT_GATTC_HANDLE_VALUE_NTF is generated. The RSSI value is informed through #CY_BLE_EVT_GET_RSSI_COMPLETE.

The parameter generated along with #CY_BLE_EVT_GET_RSSI_COMPLETE must be cast to proper format to show correct RSSI value, as below capture shows -

pastedImage_3.png

View solution in original post

5 Replies
ShipingW_81
Moderator
Moderator
Moderator
500 replies posted 250 solutions authored 250 replies posted

Assuming you send data through Notification.

To get RSSI value, Cy_BLE_GetRssiPeer() is called at every time event #CY_BLE_EVT_GATTC_HANDLE_VALUE_NTF is generated. The RSSI value is informed through #CY_BLE_EVT_GET_RSSI_COMPLETE.

The parameter generated along with #CY_BLE_EVT_GET_RSSI_COMPLETE must be cast to proper format to show correct RSSI value, as below capture shows -

pastedImage_3.png

Wang,

Thank you.  I've modified the project in PSoC6 RSSI value measurement issue

with your code suggestion and got it to work.

Next I'm going to modify the CE222046_GATT_Services projects to include RSSI info.  Cross your fingers!

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
lock attach
Attachments are accessible only for community members.

WangS,

Thank you for your help.  With your suggestions I have been partially successful.

Let me explain what I'm trying to do.

I have an application that is relatively simple.

In advertising mode, I'm trying to read both RSSI and Tx Power level for the packets received at the scanning end.

In connection mode, I'm trying to read both RSSI and Tx Power level for the Peripheral packets received at the Connection end.

Attached is a project.  It successfully gets the RSSI event but occasionally gets the Tx Power Level event.

Do I have to coordinate the Cy_BLE_GetRssiPeer() and Cy_BLE_GetTxPowerLevel() calls?

Second question:  Is there a way for the RSSI and Tx Pwr level to be returned once the Peripheral packet is received?

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
lock attach
Attachments are accessible only for community members.

WangS,

I believe I might have solved the post above.  However, it might not be elegant.

The way I get new RSSI and TxPowerLevel for each incoming LL_DATA packet is to decode the connection parameters and determine the connection Interval.  I then start up a SysTick at the connection Interval.  In the SysTick ISR, I re-request Cy_BLE_GetRssiPeer() and Cy_BLE_GetTxPowerLevel() calls.  As I said, it works but is not elegant.

A more elegant way is to get a BLE event every time the LL_DATA packet is received,  I can then issue Cy_BLE_GetRssiPeer() and Cy_BLE_GetTxPowerLevel() calls without the need of the SysTick ISR.

Is there a BLE event for the received LL_DATA packet?

Attached is an improved RSSI measurement project for those interested.

Len

Update 12.24.2019:  I found a possible solution.  I'm using the BLE  Inter-Processor-Communication (IPC) interrupt callback.  I'm using CY_BLE_INTR_CALLBACK_BLESS_STACK_ISR as the interrupt event.  It may still not be as efficient as I need but it appears to be working.

Happy Holidays to everyone!

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

Thank you! I just could not get those casts right, even though I tried modelling one on the Cypress-authored CY_BLE_EVT_GET_DEVICE_ADDR_COMPLETE event that does something similar to extract the BD Address. But though it would compile, it just wouldn't return anything other than zero.

I must admit to not being a fan of all this casting in the BLE stack. I'm much more used just to using simple casting for satisfying static type checkers and have used several other BLE stacks that didn't require it.

0 Likes