zoukankan      html  css  js  c++  java
  • nrf51822, How to use a vendor specific UUID?


    Using a vendor specific UUID is basically a two-step process:

    1. Add your custom base UUID to the stack by using sd_ble_uuid_vs_add(). Store the value returned to you in the p_type parameter of this function call.


    2. Set the type of all ble_uuid_t  that should use this base to the value returned to you from sd_ble_uuid_vs_add(). When you set this field to your custom type instead of to BLE_UUID_TYPE_BLE, the value will be used on top of the custom base UUID you specified instead of on top of the Bluetooth SIG base.

    Behind the scenes, sd_ble_uuid_vs_add() will add the base UUID to the softdevice's internal list of base UUIDs, and return the table index for this UUID in the type field. When using the type in a ble_uuid_t later, the softdevice can look up the base used in this same table by using this index.

    I've also attached a small pseudo-code snippet that shows the essentials of this scheme.


    uint32_t sd_ble_uuid_vs_add ( ble_uuid128_t const *const  p_vs_uuid,
        uint8_t *const  p_uuid_type 
      )  
    Add a Vendor Specific UUID.

    This call enables the application to add a vendor specific UUID to the BLE stack's table, for later use all other modules and APIs. This then allows the application to use the shorter, 24-bit ble_uuid_t format when dealing with both 16-bit and 128-bit UUIDs without having to check for lengths and having split code paths. The way that this is accomplished is by extending the grouping mechanism that the Bluetooth SIG standard base UUID uses for all other 128-bit UUIDs.

    Parameters
    [in] p_vs_uuid Pointer to a 16-octet (128-bit) little endian Vendor Specific UUID disregarding bytes 12 and 13.
    [out] p_uuid_type Pointer where the type field in ble_uuid_t corresponding to this UUID will be stored.
    for example:

    service_init:
    	uint32_t   err_code;
        ble_uuid_t ble_uuid;
        ble_uuid128_t nus_base_uuid = {0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x00, 0x00, 0x40, 0x6E};
        
        // Add custom base UUID
        err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &p_nus->uuid_type);
        if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }
    	
    	// Add service
        ble_uuid.type = p_nus->uuid_type;
        ble_uuid.uuid = BLE_UUID_NUS_SERVICE;
    
        err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_nus->service_handle);
        if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }
    	
    	...
    char_add:
    	ble_uuid.type = p_nus->uuid_type;
        ble_uuid.uuid = BLE_UUID_NUS_RX_CHARACTERISTIC;
        ...
    	return sd_ble_gatts_characteristic_add(p_nus->service_handle, &char_md,
                                                   &attr_char_value,
                                                   &p_nus->rx_handles)


  • 相关阅读:
    复合表达式
    用DOM4J解析XML文件案例
    XPath可以快速定位到Xml中的节点或者属性。XPath语法很简单,但是强大够用,它也是使用xslt的基础知识。
    java base64编码和解码
    String空格删除和java删除字符串最后一个字符的几种方法
    java解析xml汇总
    XML解析——Java中XML的四种解析方式
    Java 读写Properties配置文件
    Spring + Mybatis 使用 PageHelper 插件分页
    Mybatis分页插件-PageHelper的使用
  • 原文地址:https://www.cnblogs.com/blfshiye/p/5388353.html
Copyright © 2011-2022 走看看