zoukankan      html  css  js  c++  java
  • 温故而知新

    1. 在外围设备和中心设备建立连接的过程:

    a) 从设备发射广播(广播中包含从设备的服务的 UUID 列表);

    b) 主设备扫描,让主设备扫描只是一个简单的 API ;

    c) 如果主设备扫描到设备后(正是根据从设备的广播而发现的,此时是没有建立连接但是主设备和从设备通信了),就会触发一个设备发现的事件;

    d) 在这个事件中根据 UUID 查找需要的服务,把符合要求的设备添加到设备列表中;

    e) 扫描完成事件这时也会被触发,在这个事件里发起向从设备的连接,向从设备的连接也是一个 API;

    f) 连接完成后同样也会触发一个事件,这时就可以找从设备的特征值了。

    warning:

    one) 从设备的广播中的 UUID 的列表数据格式大致如下:

    长度是以字节为单位的,如果 adlen = 2, adtype = 16bit, 那么也就是说 UUID 长度为16个字节的服务只有一个。

    还有这里的 adtype ,也就是地址类型,一般有三种类型,16位、32位、128位。

    two) GAP 层的事件:

    typedef union
    {
    gapEventHdr_t gap;               //!< GAP_MSG_EVENT and status.
    gapDeviceInitDoneEvent_t initDone;      //!< GAP initialization done.
    gapDeviceInfoEvent_t deviceInfo;       //!< Discovery device information event structure.
    gapDevDiscEvent_t discCmpl;         //!< Discovery complete event structure.
    gapEstLinkReqEvent_t linkCmpl;        //!< Link complete event structure.
    gapLinkUpdateEvent_t linkUpdate;      //!< Link update event structure.
    gapTerminateLinkEvent_t linkTerminate;   //!< Link terminated event structure.
    } gapCentralRoleEvent_t;

    three) 广播的消息都有些什么内容呢?

    /**
    * GAP_DEVICE_INFO_EVENT message format. This message is sent to the
    * app during a Device Discovery Request, when a new advertisement or scan
    * response is received.
    */
    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     这里竟然能得到rssi的值,以前都没注意!!!!
    uint8 dataLen;           //!< Length (in bytes) of the data field (evtData)
    uint8 *pEvtData;         //!< Data field of advertisement or SCAN_RSP
    } gapDeviceInfoEvent_t;

    four) 

    当你坚持做一件完全正确的事情,有可能在很长一段时间内,你的价值都是零。
  • 相关阅读:
    五:系统及数据库
    四:WEB源码扩展
    三:搭建安全拓展
    二:数据包扩展
    一:基础入门-概念名词
    LeetCode 11. Container With Most Water
    LeetCode 263. Ugly Number
    LeetCode 10. Regular Expression Matching
    LeetCode 58. Length of Last Word
    LeetCode 53. Maximum Subarray
  • 原文地址:https://www.cnblogs.com/lweleven/p/4779263.html
Copyright © 2011-2022 走看看