本人使用的蓝牙模块为网蜂的蓝牙4.0模块,不知道能否成功获取数据,在这里希望大家来一起讨论。解决有Sensortag套件没有相应设备支持的尴尬。。。
蓝牙4.0模块连接Sensortag获取传感器数据(一)
经过了对蓝牙协议数周的学习,大概了解了不懂协议栈原理:
现在已经连接上了sensortag,可以获取设备的地址和RSSI,但还有点疑问
- static void simpleBLECentralEventCB( gapCentralRoleEvent_t *pEvent )
- {
- switch ( pEvent->gap.opcode )
- {
- case GAP_DEVICE_INIT_DONE_EVENT:
- {
- LCD_WRITE_STRING( "BLE Central", HAL_LCD_LINE_1 );
- LCD_WRITE_STRING( bdAddr2Str( pEvent->initDone.devAddr ), HAL_LCD_LINE_2 );
- }
- break;
- case GAP_DEVICE_INFO_EVENT:
- {
- // if filtering device discovery results based on service UUID
- if ( DEFAULT_DEV_DISC_BY_SVC_UUID == TRUE )
- {
- // if ( simpleBLEFindSvcUuid( SIMPLEPROFILE_SERV_UUID,
- // pEvent->deviceInfo.pEvtData,
- // pEvent->deviceInfo.dataLen ) )
- // {
- simpleBLEAddDeviceInfo( pEvent->deviceInfo.addr, pEvent->deviceInfo.addrType );
- // }
- }
- }
- ......
疑问: 上面代码注释部分取消的话:主机串口打印扫描设备数为0 。但是注释上的话能连接上sensortag,并且打印设备地址和RSSI
下面列出相应UUID:
主机:
- // Simple Profile Service UUID
- #define SIMPLEPROFILE_SERV_UUID 0x180A //0xAA10
此处我把0xAA10改成了0x180A ,注:0x180A为sensortag的服务UUID:
- // Device Information Service UUIDs
- #define DEVINFO_SERV_UUID 0x180A // Service UUID
- #define DEVINFO_SYSTEM_ID_UUID 0x2A23 // System ID
- #define DEVINFO_MODEL_NUMBER_UUID 0x2A24 // Model Number String
- #define DEVINFO_SERIAL_NUMBER_UUID 0x2A25 // Serial Number String
- #define DEVINFO_FIRMWARE_REV_UUID 0x2A26 // Firmware Revision String
- #define DEVINFO_HARDWARE_REV_UUID 0x2A27 // Hardware Revision String
- #define DEVINFO_SOFTWARE_REV_UUID 0x2A28 // Software Revision String
- #define DEVINFO_MANUFACTURER_NAME_UUID 0x2A29 // Manufacturer Name String
- #define DEVINFO_11073_CERT_DATA_UUID 0x2A2A // IEEE 11073-20601 Regulatory Certification Data List
- #define DEVINFO_PNP_ID_UUID 0x2A50 // PnP ID
求大神解决上面的疑问