CC2540使用广播者和观察者问题
问题一:观察者扫描广播包时需要给广播着发送扫描信息吗?
问题二:观察者是怎么解析这个广播包的,其中扫描回应和广播包在协议栈里边的哪里进行区分的?
问题三:在两个广播者广播的情况下,观察者部分程序如下
case GAP_DEVICE_DISCOVERY_EVENT:
{
// discovery complete
simpleBLEScanning = FALSE;
// Copy results
simpleBLEScanRes = pEvent->discCmpl.numDevs;//扫描结果
osal_memcpy( simpleBLEDevList, pEvent->discCmpl.pDevList,
(sizeof( gapDevRec_t ) * pEvent->discCmpl.numDevs) );
HalUARTWrite (HAL_UART_PORT_0,bdAddr2Str( pEvent->deviceInfo.pEvtData),
osal_strlen((char*)bdAddr2Str( pEvent->deviceInfo.pEvtData)));
{
simpleBLEScanIdx++;
if ( simpleBLEScanIdx >= simpleBLEScanRes )
{
simpleBLEScanIdx = 0;
}
}
break;
但是在串口上显示的是0x4115EC2801700;请问这个是什么数据,一个广播设备和两个广播设备串口观察都是这个数据
1.如果“广播者”收到一个扫描请求包(SCAN_REQ PDU),该请求包含有它的设备地址,并且该“扫描者”为广播过滤策略所允许,那么“广播者”就会在同一信道上回应一个数据包(SCAN_RSP PDU)。当(SCAN_RSP PDU)发送完成后,或由于广播过滤策略阻止了该请求包,“广播者”就会移到下一个广播信道来发送另一个广播包(ADV_IND PUD),或关闭广播事件。
2.pEvent->deviceInfo.pEvtData:
Data field of advertisement or SCAN_RSP
3.如何解析包
#define GAP_ADTYPE_FLAGS 0x01 //!< Discovery Mode: @ref GAP_ADTYPE_FLAGS_MODES #define GAP_ADTYPE_16BIT_MORE 0x02 //!< Service: More 16-bit UUIDs available #define GAP_ADTYPE_16BIT_COMPLETE 0x03 //!< Service: Complete list of 16-bit UUIDs #define GAP_ADTYPE_32BIT_MORE 0x04 //!< Service: More 32-bit UUIDs available #define GAP_ADTYPE_32BIT_COMPLETE 0x05 //!< Service: Complete list of 32-bit UUIDs #define GAP_ADTYPE_128BIT_MORE 0x06 //!< Service: More 128-bit UUIDs available #define GAP_ADTYPE_128BIT_COMPLETE 0x07 //!< Service: Complete list of 128-bit UUIDs #define GAP_ADTYPE_LOCAL_NAME_SHORT 0x08 //!< Shortened local name #define GAP_ADTYPE_LOCAL_NAME_COMPLETE 0x09 //!< Complete local name #define GAP_ADTYPE_POWER_LEVEL 0x0A //!< TX Power Level: 0xXX: -127 to +127 dBm #define GAP_ADTYPE_OOB_CLASS_OF_DEVICE 0x0D //!< Simple Pairing OOB Tag: Class of device (3 octets) #define GAP_ADTYPE_OOB_SIMPLE_PAIRING_HASHC 0x0E //!< Simple Pairing OOB Tag: Simple Pairing Hash C (16 octets) #define GAP_ADTYPE_OOB_SIMPLE_PAIRING_RANDR 0x0F //!< Simple Pairing OOB Tag: Simple Pairing Randomizer R (16 octets) #define GAP_ADTYPE_SM_TK 0x10 //!< Security Manager TK Value #define GAP_ADTYPE_SM_OOB_FLAG 0x11 //!< Secutiry Manager OOB Flags #define GAP_ADTYPE_SLAVE_CONN_INTERVAL_RANGE 0x12 //!< Min and Max values of the connection interval (2 octets Min, 2 octets Max) (0xFFFF indicates no conn interval min or max) #define GAP_ADTYPE_SIGNED_DATA 0x13 //!< Signed Data field #define GAP_ADTYPE_SERVICES_LIST_16BIT 0x14 //!< Service Solicitation: list of 16-bit Service UUIDs #define GAP_ADTYPE_SERVICES_LIST_128BIT 0x15 //!< Service Solicitation: list of 128-bit Service UUIDs #define GAP_ADTYPE_SERVICE_DATA 0x16 //!< Service Data - 16-bit UUID #define GAP_ADTYPE_PUBLIC_TARGET_ADDR 0x17 //!< Public Target Address #define GAP_ADTYPE_RANDOM_TARGET_ADDR 0x18 //!< Random Target Address #define GAP_ADTYPE_APPEARANCE 0x19 //!< Appearance #define GAP_ADTYPE_ADV_INTERVAL 0x1A //!< Advertising Interval #define GAP_ADTYPE_LE_BD_ADDR 0x1B //!< LE Bluetooth Device Address #define GAP_ADTYPE_LE_ROLE 0x1C //!< LE Role #define GAP_ADTYPE_SIMPLE_PAIRING_HASHC_256 0x1D //!< Simple Pairing Hash C-256 #define GAP_ADTYPE_SIMPLE_PAIRING_RANDR_256 0x1E //!< Simple Pairing Randomizer R-256 #define GAP_ADTYPE_SERVICE_DATA_32BIT 0x20 //!< Service Data - 32-bit UUID #define GAP_ADTYPE_SERVICE_DATA_128BIT 0x21 //!< Service Data - 128-bit UUID #define GAP_ADTYPE_3D_INFO_DATA 0x3D //!< 3D Information Data #define GAP_ADTYPE_MANUFACTURER_SPECIFIC 0xFF //!< Manufacturer Specific Data: first 2 octets contain the Company Identifier Code followed by the additional manufacturer specific data /** @} End GAP_ADTYPE_DEFINES */
这个是包里面数据类型你可以在gap.h 中查到
5.如何区分包类型建议你参考一下这个帖子http://blog.csdn.net/feilusia/article/details/48711803
很详细,谢谢分享。