做的最顺利的。。。。找到语句。。一加就好使。。感天动地啊。。。。
在主节点上通知从节点要收他的RSSI啦:
1 if ( !simpleBLERssi ) 2 { 3 simpleBLERssi = TRUE; 4 GAPCentralRole_StartRssi( simpleBLEConnHandle[connhandle[0]], DEFAULT_RSSI_PERIOD ); 5 } 6 else 7 { 8 simpleBLERssi = FALSE; 9 GAPCentralRole_CancelRssi( simpleBLEConnHandle[connhandle[0]] ); 10 11 LCD_WRITE_STRING( "RSSI Cancelled", HAL_LCD_LINE_1 ); 12 }
然后就会调用RSSI的回调函数:
1 static void simpleBLECentralRssiCB( uint16 connHandle, int8 rssi ) 2 { 3 4 LCD_WRITE_STRING_VALUE( "RSSI -dB:", (uint8) (-rssi), 10, HAL_LCD_LINE_1 ); 5 }
在LCD上显示出来啦!
还可以在从节点广播的时候直接获取:
1 case GAP_DEVICE_INFO_EVENT: 2 { 3 // if filtering device discovery results based on service UUID 4 if ( DEFAULT_DEV_DISC_BY_SVC_UUID == TRUE ) 5 { 6 if ( simpleBLEFindSvcUuid( SIMPLEPROFILE_SERV_UUID, 7 pEvent->deviceInfo.pEvtData, 8 pEvent->deviceInfo.dataLen ) ) 9 { 10 simpleBLEAddDeviceInfo( pEvent->deviceInfo.addr, pEvent->deviceInfo.addrType ); 11 } 12 } 13 14 15 uint8 newRSSI = -(pEvent->deviceInfo.rssi); 16 }