微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > How to Add a secondary service with 128 UUID, and use it as included service

How to Add a secondary service with 128 UUID, and use it as included service

时间:10-02 整理:3721RD 点击:
1. First, define a secondary service with 128 UUID, and some characteristic for this service
/*sample code*/
#define BT_SIG_UUID_VENDOR_SERVICE
{{0x12,0x34,0x56,0x78,0x90,0x13,0x57,0x91,0x24,0x68,0x82,0x11,0x22,0x33,0x44,0x55}}
BT_GATTS_NEW_SECONDARY_SERVICE_128(bt_if_vendor_secondary_service,
BT_SIG_UUID_VENDOR_SERVICE);
BT_GATTS_NEW_CHARC_16(bt_if_vendor_char1_manufacture_name, ...) ;
......

2. Add service records array into gatt server "bt_if_gatt_server[]"
/*sample code*/
static const bt_gatts_service_rec_t *bt_if_vendor_service_rec[] = {
(const bt_gatts_service_rec_t*) &bt_if_vendor_secondary_service,
(const bt_gatts_service_rec_t*) &bt_if_vendor_char1_manufacture_name,
......
};
static const bt_gatts_service_t bt_if_vendor_service = {
.starting_handle = 0x0500,
.ending_handle = 0x0522,
.required_encryption_key_size = 16,
.records = bt_if_vendor_service_rec
};
const bt_gatts_service_t * bt_if_gatt_server[] = {
&bt_if_gap_service,//0x0001
&bt_if_gatt_service_ro,//0x0010
&bt_if_bas_service,//0x0020
&bt_if_vendor_service,//0x500
NULL
};

3. Define include service which start/end handle same with secondary service, and add include service into primary service.
/*sample code*/
BT_GATTS_NEW_INCLUDED_SERVICE_128(bt_if_included_vendor_secondary_service, 0x0500,
0x0522);
static const bt_gatts_service_rec_t *bt_if_bas_service_rec[] = {
(const bt_gatts_service_rec_t*) &bt_if_bas_primary_service,
(const bt_gatts_service_rec_t*) &bt_if_included_vendor_secondary_service,
......
};

4. Build your project and use secondary service.

deeply thanks for your support

谢谢分享!

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top