我看 central.c 里面怎么没有 scan 的操作呢,抓包的时候也没有看到 ADV_SCAN_REG 的请求,但是我的手机发现BLEPeripheral的时候有这个请求的,请问这个有没有,我应该怎么做才能让BLECentral显示BLEPeripheral设备的名字呢?
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.
应该可以通过读
typedef struct
{
osal_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
uint8 opcode; //!< GAP_DEVICE_INFO_EVENT
uint8 eventType; //!< Advertisement Type: @ref GAP_ADVERTISEMENT_REPORT_TYPE_DEFINES
uint8 addrType; //!< address type: @ref GAP_ADDR_TYPE_DEFINES
uint8 addr[B_ADDR_LEN]; //!< Address of the advertisement or SCAN_RSP
int8 rssi; //!< Advertisement or SCAN_RSP RSSI
uint8 dataLen; //!< Length (in bytes) of the data field (evtData)
uint8 *pEvtData; //!< Data field of advertisement or SCAN_RSP
} gapDeviceInfoEvent_t;
里面的数据获取
请问您的Central设备的BD Address是FFFFFFFFFFFF吗?Central设备是不是以前连接过Peripheral设备?
Central设备在scan enable的时候会发送ADV_SCAN_REQ
在SimpleBLECentral的例程里,有让Central设备进入scan状态的代码,在simpleBLECentral_HandleKeys函数里面处理向上的按钮的代码。
如果您抓不到包,也请确认一下,您在Central的code里面,command发送的channel是不是和sniffer设置的是一样的,我这里使用的是channel39.
在simpleBLECentral.c可以看到,bStatus_t GAPCentralRole_StartDiscovery( uint8 mode, uint8 activeScan, uint8 whiteList );
最后会调到 bStatus_t GAP_DeviceDiscoveryRequest( gapDevDiscReq_t *pParams )吧。