收取rssi

做的最顺利的。。。。找到语句。。一加就好使。。感天动地啊。。。。

在主节点上通知从节点要收他的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 }

 

转载于:https://www.cnblogs.com/fullest-life/p/5503131.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值