FRDMKW36-How to get RSSI value when connected with smartphone by BLE

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FRDMKW36-How to get RSSI value when connected with smartphone by BLE

Jump to solution
2,243 Views
Lincoln
Contributor III

Hi all,

I used Proximity sample code to connect with a smartphone, then here comes two value which in IoT Toolbox app: RSSI and Tx Power. The rssi value keeps changing which seems normal, but the tx power is always zero. 

I have two questions to ask, 

1. How do I print the rssi value on the console to monitor it?

Here is my code,

static void RssiMeasurementTimerCallback(deviceId_t peerDeviceId, gapConnectionEvent_t* pConnectionEvent)
{
(void)Gap_ReadRssi(peerDeviceId);
int8_t rssi_val;
rssi_val = pConnectionEvent->eventData.rssi_dBm;
PRINTF("rssi: %d\n",rssi_val);
}

I set a timer to trigger it, but the value is 0 all the time.

2. Why the tx power value is always zero?

Thank you.

Labels (2)
0 Kudos
Reply
1 Solution
2,184 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi @Lincoln,

Please look at the next API and the comments that we provide.

* \remarks The result is contained in the gConnEvtRssiRead_c connection event. The RSSI
* value is a signed byte, and the unit is dBm. If the RSSI cannot be read, the gConnEvtPowerReadFailure_c
* connection event is generated.
********************************************************************************** */
#define Gap_ReadRssi(deviceId)

Regards,

Mario

View solution in original post

0 Kudos
Reply
5 Replies
2,230 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi @Lincoln,

I hope you are doing great.

1. Be sure that the debug pins are enabled for the Print API.

/* Init hardware */
BOARD_InitPins();
BOARD_BootClockRUN();
BOARD_InitDebugConsole();

2. Please look at the next line of the code. The TX Power is not changing, it will depend on the setup that you have.

static txsConfig_t serviceTxPowerConfig = {(uint16_t)service_tx_power, 0x00};

 

Regards,

Mario

0 Kudos
Reply
2,211 Views
Lincoln
Contributor III

Hi @mario_castaneda ,

Thanks for your advise, but here comes another problem. After I add the init hardware code about Print API and run it again, it shows this fault below when i connected to IoT Toolbox, then it loss of connection immediately.

(My code is attached below)

Lincoln_Holmes_0-1628045599301.png

 

Tags (1)
0 Kudos
Reply
2,209 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi @Lincoln,

You have to initialize the clock and the UART pins. Please look at the wireless uart example or the QPPS as a reference for this setup.

Regards,

Mario

0 Kudos
Reply
2,197 Views
Lincoln
Contributor III

Hi @mario_castaneda,

Thank you for the response, the fault issue is resolved and the connection is stable. As I ask previously, I want to monitor the Rssi value on the console, I checked this function: Gap_ReadRssi(peerDeviceId) is working successfully, but it is always printing Rssi value as zero on the console.

Is the rssi value would be updated automatically or i have to trigger

gapConnectionEventType_t -> gConnEvtRssiRead_c to update it, if it's needed then how can I achieve it?
 
Best Regards,
Lincoln
0 Kudos
Reply
2,185 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi @Lincoln,

Please look at the next API and the comments that we provide.

* \remarks The result is contained in the gConnEvtRssiRead_c connection event. The RSSI
* value is a signed byte, and the unit is dBm. If the RSSI cannot be read, the gConnEvtPowerReadFailure_c
* connection event is generated.
********************************************************************************** */
#define Gap_ReadRssi(deviceId)

Regards,

Mario

0 Kudos
Reply