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)

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-08-02 07:20:37

nrf51822, How to use a vendor specific UUID?的相关文章

WiFi Vendor Specific IE

WPS OUI: 00-05-F2 OUI Type: 04 P2P OUI: 50-6F-9A OUI Type: 09 WFD OUI: 50-6F-9A OUI Type: 10

CSR8670的A2DP与AVRCP的应用笔记

1. A2DP 1.1. 基本概念 阅读A2DP SPEC V12的1.1章,可知: Advanced Audio Distribution Profile(A2DP) 典型应用是立体声音乐播放器的音乐到耳机或扬声器的播放 目的是用来传输高品质的单声道或立体声音频,环绕声不能用A2DP传输 A2DP不包括遥控功能,用户需要同AVRCP组合使用 情景模式相互依赖关系: 1.2. 编码格式 The Advanced Audio Distribution Profile (A2DP) defines

QEMU KVM Libvirt手册(7): 硬件虚拟化

在openstack中,如果我们启动一个虚拟机,我们会看到非常复杂的参数 qemu-system-x86_64 -enable-kvm -name instance-00000024 -S -machine pc-i440fx-trusty,accel=kvm,usb=off -cpu SandyBridge,+erms,+smep,+fsgsbase,+pdpe1gb,+rdrand,+f16c,+osxsave,+dca,+pcid,+pdcm,+xtpr,+tm2,+est,+smx,+v

Experiments with Bluetooth Low Energy (4.0) under Linux

Experiments with Bluetooth Low Energy (4.0) under Linux With iPhônes liberated from the apple authentication chip by it, and Android also having added support in the latest Android 4.3, Bluetooth Low Energy (4.0) is starting to look more interesting.

CC254x/CC2540/CC2541库函数速查(转)

hci.h 转自:http://blog.csdn.net/xiaoleiacmer/article/details/44036607#t1 [cpp] view plaincopy //分配内存,应用程序不应该调用这个函数. void *HCI_bm_alloc( uint16 size ); //检查连接时间参数和连接时间参数的组合是否有效 uint8 HCI_ValidConnTimeParams( uint16 connIntervalMin, uint16 connIntervalMa

hostapd wpa_supplicant madwifi详细分析(八)——wpa_supplicant的配置文件

距离上一篇文章的更新已经将近半年了,这半年忙项目忙得几乎没有什么时间给自己积累一些东西,也没什么心思转到这边来写点东西,当一个项目放到自己身上的时候,发现并不像开发一个模块或一个功能那么简单,涉及方方面面,各种琐碎的的事情会占据大量的时间. 前面写的关于hostapd的文章都太浅显了,一般都没怎么涉及到具体的功能,只是简单的分析了一下代码的流程,然而对于实际的功能开发和bug调试其实用处不大,后面的文章将从wpa_supplicant入手做进一步的了解.hostapd主要用于AP端的开发,比如路

Android wpa_supplcant 数据结构之--conf配置文件

1 配置文件 conf文件作为wpa_supplicant的配置文件,一般叫做 wpa_supplicant.conf .其中存储着wpa_supplicant的运行参数和以保存的网络列表. conf文件的路径,通过启动wpa_supplicant时的 –c 参数传入,初始化过程中赋值到wpa_s->confname,然后将数据读入wpa_s->conf中. wpa_supplicant的所有参数都定义在struct wpa_config中 struct wpa_config { //conf

[BlueZ] 2、使用bluetoothctl搜索、连接、配对、读写、使能notify蓝牙低功耗设备

星期三, 05. 九月 2018 02:03上午 - beautifulzzzz 1.前言 上一篇讲了如何编译安装BlueZ-5,本篇主要在于玩BlueZ,用命令行去操作BLE设备: [BlueZ] 1.Download install and use the BlueZ and hcitool on PI 3B+ 2.gatttool -- 老工具趟坑 刚开始跟着 Get Started with Bluetooth Low Energy on Linux 操作gatttool,发现坑太多(主

转载: HDMI 基础知识

转自:http://www.cnblogs.com/TaigaCon/p/3840653.html HDMI,全称为(High Definition Multimedia Interface)高清多媒体接口,主要用于传输高清音视频信号. HDMI引脚: HDMI有A,B,C,D,E五种引脚类型,目前市面中比较常见的就是Type A: 其中 1-9 都是TMDS数据传输实际上用到的引脚,分为0,1,2三组 10-12 为TMDS时钟信号,如当前Video Timing为[email protect