nrf51822, How to use a vendor specific UUID?
2016-04-13 18:50
459 查看
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.
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
for example:
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 | ||
) |
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. |
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)
相关文章推荐
- UIUItextfield输入类似银行卡号需要每四位加一个空格的实现
- 1-3 Bags,Queues and Stacks
- kendo ui treeview设置节点选中
- AVOSCloud(AVOSCloud.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode se
- iOS-UIView坐标系转换-convertRect toview
- does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), o
- UITextView 控制输入字数总结
- 错误: Unknown class XXX in Interface Builder file
- xml:Invalid byte 2 of 2-byte UTF-8 sequence
- android5.1添加Email分享,bluetooth分享
- 自定义UIActivityIndicatorView大小
- IOS-UI学习笔记(九宫格应用管理)
- 从客户端中检测到有潜在危险的 Request.Form 值
- easyui webapi
- 使用手势对UIImageView进行缩放、旋转和移动
- 使用手势对UIImageView进行缩放、旋转和移动
- Java集合(三):Queue队列
- MySQL关于Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
- POJ 3061 Subsequence
- Reveal逆向工程:分析任意iOS应用的UI界面