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.

求助:Observe如何获取Peripheral广播中的数据?



static uint8 advertData[] =
{
// Flags; this sets the device to use limited discoverable
// mode (advertises for 30 seconds at a time) instead of general
// discoverable mode (advertises indefinitely)
0x02, // length of this data
GAP_ADTYPE_FLAGS,
DEFAULT_DISCOVERABLE_MODE | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,

// service UUID, to notify central devices what services are included
// in this peripheral
0x03, // length of this data
GAP_ADTYPE_16BIT_MORE, // some of the UUID's, but not all
LO_UINT16( SIMPLEPROFILE_SERV_UUID ),
HI_UINT16( SIMPLEPROFILE_SERV_UUID ),

};

如上述是从机的广播数据,我如何在Observe中获取它的信息呢?Observe中的这个数组simpleBLEDevList,只找到获取addr,求解答,谢谢

  • Kevin,

    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;

    看看 pEvent->deviceInfo里面的pEvtData 里面有什么?

  • 谢谢YAN,帮我解决苦恼很久的问题,另外还想问一下,*pEvtData接收到的是advertData数组内的所有数据吗,还是有具体的函数对*pEvtData进行处理,期待您的解答。

  • Kevin,

    能收到所有数据。

    处理在 SimpleBLECentral.c 中,simpleBLECentralEventCB() 函数,case GAP_DEVICE_INFO_EVENT: 下面。

  • 请问,广播的数据,可以随时改变吗?我想一广播的形式传信息,不知道怎么随时更改广播数据。

  • Hui,

    可以随时修改广播数据。

    可以修改 scanRspData[] 和 advertData[] 来实现。