How can read RSSI value. I have two board(CC2340R5).
I am using basic_ble project.
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
How can read RSSI value. I have two board(CC2340R5).
I am using basic_ble project.
Hi,
Thank you for reaching out.
Add an event handler:
BLEAppUtil_EventHandler_t peripheralConnNotiHandler = { .handlerType = BLEAPPUTIL_CONN_NOTI_TYPE, .pEventHandler = Peripheral_GAPConnReportHandler, .eventMask = BLEAPPUTIL_CONN_NOTI_CONN_EVENT_ALL, };
Create the handling function for the newly created event:
void Peripheral_GAPConnReportHandler(uint32 event, BLEAppUtil_msgHdr_t *pMsgData) { switch(event) { case BLEAPPUTIL_CONN_NOTI_CONN_EVENT_ALL: { Gap_ConnEventRpt_t *report = (Gap_ConnEventRpt_t *)pMsgData; int8_t rssi = report->lastRssi; //Your code break; } default: { break; } } }
Under BLEAPPUTIL_LINK_ESTABLISHED_EVENT, ensure you register the connection for the event:
case BLEAPPUTIL_LINK_ESTABLISHED_EVENT: { gapEstLinkReqEvent_t *gapEstMsg = (gapEstLinkReqEvent_t *)pMsgData; BLEAppUtil_registerConnNotifHandler(gapEstMsg->connectionHandle); //...
In Peripheral_start(), register the event handler:
bStatus_t Peripheral_start() { bStatus_t status = SUCCESS; //... status = BLEAppUtil_registerEventHandler(&peripheralConnNotiHandler); if(status != SUCCESS) { // Return status value return(status); } //...
Add an event handler
BLEAppUtil_EventHandler_t centralConnNotiHandler = { .handlerType = BLEAPPUTIL_CONN_NOTI_TYPE, .pEventHandler = Central_GAPConnReportHandler, .eventMask = BLEAPPUTIL_CONN_NOTI_CONN_EVENT_ALL, };
Create the handling function of the newly created event:
void Central_GAPConnReportHandler(uint32 event, BLEAppUtil_msgHdr_t *pMsgData) { switch(event) { case BLEAPPUTIL_CONN_NOTI_CONN_EVENT_ALL: { volatile Gap_ConnEventRpt_t *report = (Gap_ConnEventRpt_t *)pMsgData; int8_t rssi = report->lastRssi; //Your code break; } default: { break; } } }
In Central_start(), register the event handler:
bStatus_t Central_start() { bStatus_t status = SUCCESS; //... status = BLEAppUtil_registerEventHandler(¢ralConnNotiHandler); if(status != SUCCESS) { // Return status value return(status); } //...
In app_connection.c, register the newly formed connection:
void Connection_ConnEventHandler(uint32 event, BLEAppUtil_msgHdr_t *pMsgData) { switch(event) { case BLEAPPUTIL_LINK_ESTABLISHED_EVENT: { //... // Register to connection notifications BLEAppUtil_registerConnNotifHandler(gapEstMsg->connectionHandle); //... break; } //...
Once these changes are implemented you should receive the RSSI at each connection event!
I hope this will help,
Best regards,
So what is happening in my peripheral side the value is shown but Central side not working.
I don't known why the RSSI value is not show in Central side.
Regards,
Umesh
Hi,
Can you please describe the debugging steps you have taken so far?
Among others, have you verified whether the code run by Central_GAPConnReportHandler(). This can be checked using a breakpoint.
If needed, please refer to the debugging guide: https://software-dl.ti.com/simplelink/esd/simplelink_lowpower_f3_sdk/7.20.01.10/exports/docs/ble5stack/ble_user_guide/html/ble-stack-5.x-guide/debugging-index-cc23xx.html
Best regards,