• 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)


  • 相关阅读:
    查询端口号的连接情况
    mac环境下安装python3的requests包
    Apollo配置中心介绍
    简单工厂,工厂方法,抽象工厂模式对比
    全表查询sql执行链路排查
    logstash部署及项目日志输出到ES
    【SpringMVC入门系列】篇4:SpringMVC传值方式
    【设计模式】外观模式
    【SpringMVC入门系列】篇3:@RequestMapping & @RequestHeader & @CookieValue详解与REST风格请求
    【SpringMVC入门系列】篇1:SpringMVC基本使用与执行流程
  • 原文地址:https://www.cnblogs.com/blfshiye/p/5388353.html
Copyright © 2020-2023  润新知