本文整理汇总了C++中bt_uuid16_create函数的典型用法代码示例。如果您正苦于以下问题:C++ bt_uuid16_create函数的具体用法?C++ bt_uuid16_create怎么用?C++ bt_uuid16_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bt_uuid16_create函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: populate_gatt_service
static void populate_gatt_service(struct server *server)
{
bt_uuid_t uuid;
struct gatt_db_attribute *service, *svc_chngd;
/* Add the GATT service */
bt_uuid16_create(&uuid, UUID_GATT);
service = gatt_db_add_service(server->db, &uuid, true, 4);
bt_uuid16_create(&uuid, GATT_CHARAC_SERVICE_CHANGED);
svc_chngd = gatt_db_service_add_characteristic(service, &uuid,
BT_ATT_PERM_READ,
BT_GATT_CHRC_PROP_READ | BT_GATT_CHRC_PROP_INDICATE,
gatt_service_changed_cb,
NULL, server);
server->gatt_svc_chngd_handle = gatt_db_attribute_get_handle(svc_chngd);
bt_uuid16_create(&uuid, GATT_CLIENT_CHARAC_CFG_UUID);
gatt_db_service_add_descriptor(service, &uuid,
BT_ATT_PERM_READ | BT_ATT_PERM_WRITE,
gatt_svc_chngd_ccc_read_cb,
gatt_svc_chngd_ccc_write_cb, server);
gatt_db_service_set_active(service, true);
}
示例2: bt_scpp_attach
bool bt_scpp_attach(struct bt_scpp *scan, void *attrib)
{
bt_uuid_t iwin_uuid, refresh_uuid;
if (!scan || scan->attrib || !scan->primary)
return false;
scan->attrib = g_attrib_ref(attrib);
if (scan->iwhandle)
write_scan_params(scan->attrib, scan->iwhandle, scan->interval,
scan->window);
else {
bt_uuid16_create(&iwin_uuid, SCAN_INTERVAL_WIN_UUID);
discover_char(scan, scan->attrib, scan->primary->range.start,
scan->primary->range.end, &iwin_uuid,
iwin_discovered_cb, scan);
}
if (scan->refresh_handle)
scan->refresh_cb_id = g_attrib_register(scan->attrib,
ATT_OP_HANDLE_NOTIFY, scan->refresh_handle,
refresh_value_cb, scan, NULL);
else {
bt_uuid16_create(&refresh_uuid, SCAN_REFRESH_UUID);
discover_char(scan, scan->attrib, scan->primary->range.start,
scan->primary->range.end, &refresh_uuid,
refresh_discovered_cb, scan);
}
return true;
}
示例3: populate_gap_service
static void populate_gap_service(struct server *server)
{
bt_uuid_t uuid;
struct gatt_db_attribute *service, *tmp;
uint16_t appearance;
/* Add the GAP service */
bt_uuid16_create(&uuid, UUID_GAP);
service = gatt_db_add_service(server->db, &uuid, true, 6);
/*
* Device Name characteristic. Make the value dynamically read and
* written via callbacks.
*/
bt_uuid16_create(&uuid, GATT_CHARAC_DEVICE_NAME);
gatt_db_service_add_characteristic(service, &uuid,
BT_ATT_PERM_READ | BT_ATT_PERM_WRITE,
BT_GATT_CHRC_PROP_READ,
gap_device_name_read_cb,
gap_device_name_write_cb,
server);
bt_uuid16_create(&uuid, GATT_CHARAC_EXT_PROPER_UUID);
gatt_db_service_add_descriptor(service, &uuid, BT_ATT_PERM_READ,
gap_device_name_ext_prop_read_cb,
NULL, server);
/*
* Appearance characteristic. Reads and writes should obtain the value
* from the database.
*/
bt_uuid16_create(&uuid, GATT_CHARAC_APPEARANCE);
tmp = gatt_db_service_add_characteristic(service, &uuid,
BT_ATT_PERM_READ,
BT_GATT_CHRC_PROP_READ,
NULL, NULL, server);
/*
* Write the appearance value to the database, since we're not using a
* callback.
*/
put_le16(128, &appearance);
gatt_db_attribute_write(tmp, 0, (void *) &appearance,
sizeof(appearance),
BT_ATT_OP_WRITE_REQ,
NULL, confirm_write,
NULL);
gatt_db_service_set_active(service, true);
}
示例4: populate_hr_service
static void populate_hr_service(struct server *server)
{
bt_uuid_t uuid;
struct gatt_db_attribute *service, *hr_msrmt, *body;
uint8_t body_loc = 1; /* "Chest" */
/* Add Heart Rate Service */
bt_uuid16_create(&uuid, UUID_HEART_RATE);
service = gatt_db_add_service(server->db, &uuid, true, 8);
server->hr_handle = gatt_db_attribute_get_handle(service);
/* HR Measurement Characteristic */
bt_uuid16_create(&uuid, UUID_HEART_RATE_MSRMT);
hr_msrmt = gatt_db_service_add_characteristic(service, &uuid,
BT_ATT_PERM_NONE,
BT_GATT_CHRC_PROP_NOTIFY,
NULL, NULL, NULL);
server->hr_msrmt_handle = gatt_db_attribute_get_handle(hr_msrmt);
bt_uuid16_create(&uuid, GATT_CLIENT_CHARAC_CFG_UUID);
gatt_db_service_add_descriptor(service, &uuid,
BT_ATT_PERM_READ | BT_ATT_PERM_WRITE,
hr_msrmt_ccc_read_cb,
hr_msrmt_ccc_write_cb, server);
/*
* Body Sensor Location Characteristic. Make reads obtain the value from
* the database.
*/
bt_uuid16_create(&uuid, UUID_HEART_RATE_BODY);
body = gatt_db_service_add_characteristic(service, &uuid,
BT_ATT_PERM_READ,
BT_GATT_CHRC_PROP_READ,
NULL, NULL, server);
gatt_db_attribute_write(body, 0, (void *) &body_loc, sizeof(body_loc),
BT_ATT_OP_WRITE_REQ,
NULL, confirm_write,
NULL);
/* HR Control Point Characteristic */
bt_uuid16_create(&uuid, UUID_HEART_RATE_CTRL);
gatt_db_service_add_characteristic(service, &uuid,
BT_ATT_PERM_WRITE,
BT_GATT_CHRC_PROP_WRITE,
NULL, hr_control_point_write_cb,
server);
if (server->hr_visible)
gatt_db_service_set_active(service, true);
}
示例5: register_vendor_service
static void register_vendor_service(struct gatt_example_adapter *adapter,
uint16_t range[2])
{
uint16_t start_handle, h;
const int svc_size = 3;
uint8_t atval[256];
bt_uuid_t uuid;
bt_uuid16_create(&uuid, VENDOR_SPECIFIC_SVC_UUID);
start_handle = attrib_db_find_avail(adapter->adapter, &uuid, svc_size);
if (start_handle == 0) {
error("Not enough free handles to register service");
return;
}
DBG("start_handle=0x%04x", start_handle);
h = start_handle;
/* Secondary Service: Vendor Specific Service */
bt_uuid16_create(&uuid, GATT_SND_SVC_UUID);
att_put_u16(VENDOR_SPECIFIC_SVC_UUID, &atval[0]);
attrib_db_add(adapter->adapter, h++, &uuid, ATT_NONE, ATT_NOT_PERMITTED,
atval, 2);
/* Vendor Specific Type characteristic definition */
bt_uuid16_create(&uuid, GATT_CHARAC_UUID);
atval[0] = ATT_CHAR_PROPER_READ;
att_put_u16(h + 1, &atval[1]);
att_put_u16(VENDOR_SPECIFIC_TYPE_UUID, &atval[3]);
attrib_db_add(adapter->adapter, h++, &uuid, ATT_NONE, ATT_NOT_PERMITTED,
atval, 5);
/* Vendor Specific Type characteristic value */
bt_uuid16_create(&uuid, VENDOR_SPECIFIC_TYPE_UUID);
atval[0] = 0x56;
atval[1] = 0x65;
atval[2] = 0x6E;
atval[3] = 0x64;
atval[4] = 0x6F;
atval[5] = 0x72;
attrib_db_add(adapter->adapter, h, &uuid, ATT_NONE, ATT_NOT_PERMITTED,
atval, 6);
g_assert(h - start_handle + 1 == svc_size);
range[0] = start_handle;
range[1] = start_handle + svc_size - 1;
}
示例6: refresh_discovered_cb
static void refresh_discovered_cb(uint8_t status, GSList *chars,
void *user_data)
{
struct scan *scan = user_data;
struct gatt_char *chr;
uint16_t start, end;
bt_uuid_t uuid;
if (status) {
error("Scan Refresh %s", att_ecode2str(status));
return;
}
if (!chars) {
DBG("Scan Refresh not supported");
return;
}
chr = chars->data;
DBG("Scan Refresh handle: 0x%04x", chr->value_handle);
start = chr->value_handle + 1;
end = scan->range.end;
if (start > end)
return;
scan->refresh_handle = chr->value_handle;
bt_uuid16_create(&uuid, GATT_CLIENT_CHARAC_CFG_UUID);
gatt_discover_desc(scan->attrib, start, end, &uuid,
discover_descriptor_cb, user_data);
}
示例7: gap_accept
static int gap_accept(struct btd_service *service)
{
struct btd_device *device = btd_service_get_device(service);
struct gatt_db *db = btd_device_get_gatt_db(device);
struct bt_gatt_client *client = btd_device_get_gatt_client(device);
struct gas *gas = btd_service_get_user_data(service);
char addr[18];
bt_uuid_t gap_uuid;
ba2str(device_get_address(device), addr);
DBG("GAP profile accept (%s)", addr);
if (!gas) {
error("GAP service not handled by profile");
return -1;
}
gas->db = gatt_db_ref(db);
gas->client = bt_gatt_client_ref(client);
/* Handle the GAP services */
bt_uuid16_create(&gap_uuid, GAP_UUID16);
gatt_db_foreach_service(db, &gap_uuid, foreach_gap_service, gas);
if (!gas->attr) {
error("GAP attribute not found");
gas_reset(gas);
return -1;
}
btd_service_connecting_complete(service, 0);
return 0;
}
示例8: gatt_discover_char
guint gatt_discover_char(GAttrib *attrib, uint16_t start, uint16_t end,
bt_uuid_t *uuid, gatt_cb_t func,
gpointer user_data)
{
size_t buflen;
uint8_t *buf = g_attrib_get_buffer(attrib, &buflen);
struct discover_char *dc;
bt_uuid_t type_uuid;
guint16 plen;
bt_uuid16_create(&type_uuid, GATT_CHARAC_UUID);
plen = enc_read_by_type_req(start, end, &type_uuid, buf, buflen);
if (plen == 0)
return 0;
dc = g_try_new0(struct discover_char, 1);
if (dc == NULL)
return 0;
dc->attrib = g_attrib_ref(attrib);
dc->cb = func;
dc->user_data = user_data;
dc->end = end;
dc->uuid = g_memdup(uuid, sizeof(bt_uuid_t));
return g_attrib_send(attrib, 0, buf, plen, char_discovered_cb,
dc, NULL);
}
示例9: encode_discover_primary
static guint16 encode_discover_primary(uint16_t start, uint16_t end,
bt_uuid_t *uuid, uint8_t *pdu, size_t len)
{
bt_uuid_t prim;
guint16 plen;
bt_uuid16_create(&prim, GATT_PRIM_SVC_UUID);
if (uuid == NULL) {
/* Discover all primary services */
plen = enc_read_by_grp_req(start, end, &prim, pdu, len);
} else {
uint8_t value[16];
size_t vlen;
/* Discover primary service by service UUID */
put_uuid_le(uuid, value);
vlen = bt_uuid_len(uuid);
plen = enc_find_by_type_req(start, end, &prim, value, vlen,
pdu, len);
}
return plen;
}
示例10: gatt_db_attribute_get_service_uuid
bool gatt_db_attribute_get_service_uuid(const struct gatt_db_attribute *attrib,
bt_uuid_t *uuid)
{
struct gatt_db_service *service;
if (!attrib || !uuid)
return false;
service = attrib->service;
if (service->attributes[0]->value_len == sizeof(uint16_t)) {
uint16_t value;
value = get_le16(service->attributes[0]->value);
bt_uuid16_create(uuid, value);
return true;
}
if (service->attributes[0]->value_len == sizeof(uint128_t)) {
uint128_t value;
bswap_128(service->attributes[0]->value, &value);
bt_uuid128_create(uuid, value);
return true;
}
return false;
}
示例11: bas_discovered_cb
static void bas_discovered_cb(uint8_t status, GSList *chars, void *user_data)
{
struct gatt_request *req = user_data;
struct bt_bas *bas = req->user_data;
struct gatt_char *chr;
uint16_t start, end;
bt_uuid_t uuid;
destroy_gatt_req(req);
if (status) {
error("Battery: %s", att_ecode2str(status));
return;
}
chr = chars->data;
bas->handle = chr->value_handle;
DBG("Battery handle: 0x%04x", bas->handle);
read_char(bas, bas->attrib, bas->handle, read_value_cb, bas);
start = chr->value_handle + 1;
end = bas->primary->range.end;
bt_uuid16_create(&uuid, GATT_CLIENT_CHARAC_CFG_UUID);
discover_desc(bas, bas->attrib, start, end, &uuid,
discover_descriptor_cb, bas);
}
示例12: external_report_reference_cb
static void external_report_reference_cb(guint8 status, const guint8 *pdu,
guint16 plen, gpointer user_data)
{
struct hog_device *hogdev = user_data;
uint16_t uuid16;
bt_uuid_t uuid;
if (status != 0) {
error("Read External Report Reference descriptor failed: %s",
att_ecode2str(status));
return;
}
if (plen != 3) {
error("Malformed ATT read response");
return;
}
uuid16 = get_le16(&pdu[1]);
DBG("External report reference read, external report characteristic "
"UUID: 0x%04x", uuid16);
bt_uuid16_create(&uuid, uuid16);
gatt_discover_char(hogdev->attrib, 0x00, 0xff, &uuid,
external_service_char_cb, hogdev);
}
示例13: dec_find_by_type_req
uint16_t dec_find_by_type_req(const uint8_t *pdu, size_t len, uint16_t *start,
uint16_t *end, bt_uuid_t *uuid,
uint8_t *value, size_t *vlen)
{
if (pdu == NULL)
return 0;
if (len < 7)
return 0;
/* Attribute Opcode (1 octet) */
if (pdu[0] != ATT_OP_FIND_BY_TYPE_REQ)
return 0;
/* First requested handle number (2 octets) */
*start = get_le16(&pdu[1]);
/* Last requested handle number (2 octets) */
*end = get_le16(&pdu[3]);
/* 16-bit UUID to find (2 octets) */
bt_uuid16_create(uuid, get_le16(&pdu[5]));
/* Attribute value to find */
*vlen = len - 7;
if (*vlen > 0)
memcpy(value, pdu + 7, *vlen);
return len;
}
示例14: register_phone_alert_service
static void register_phone_alert_service(struct alert_adapter *al_adapter)
{
bt_uuid_t uuid;
bt_uuid16_create(&uuid, PHONE_ALERT_STATUS_SVC_UUID);
/* Phone Alert Status Service */
gatt_service_add(al_adapter->adapter, GATT_PRIM_SVC_UUID, &uuid,
/* Alert Status characteristic */
GATT_OPT_CHR_UUID, ALERT_STATUS_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
ATT_CHAR_PROPER_NOTIFY,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
alert_status_read, al_adapter->adapter,
GATT_OPT_CCC_GET_HANDLE,
&al_adapter->hnd_ccc[NOTIFY_ALERT_STATUS],
GATT_OPT_CHR_VALUE_GET_HANDLE,
&al_adapter->hnd_value[NOTIFY_ALERT_STATUS],
/* Ringer Control Point characteristic */
GATT_OPT_CHR_UUID, RINGER_CP_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE_WITHOUT_RESP,
GATT_OPT_CHR_VALUE_CB, ATTRIB_WRITE,
ringer_cp_write, NULL,
/* Ringer Setting characteristic */
GATT_OPT_CHR_UUID, RINGER_SETTING_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
ATT_CHAR_PROPER_NOTIFY,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
ringer_setting_read, al_adapter->adapter,
GATT_OPT_CCC_GET_HANDLE,
&al_adapter->hnd_ccc[NOTIFY_RINGER_SETTING],
GATT_OPT_CHR_VALUE_GET_HANDLE,
&al_adapter->hnd_value[NOTIFY_RINGER_SETTING],
GATT_OPT_INVALID);
}
示例15: encode_discover_primary
static guint16 encode_discover_primary(uint16_t start, uint16_t end,
bt_uuid_t *uuid, uint8_t *pdu, size_t len)
{
bt_uuid_t prim;
guint16 plen;
bt_uuid16_create(&prim, GATT_PRIM_SVC_UUID);
if (uuid == NULL) {
/* Discover all primary services */
plen = enc_read_by_grp_req(start, end, &prim, pdu, len);
} else {
uint16_t u16;
uint128_t u128;
const void *value;
size_t vlen;
/* Discover primary service by service UUID */
if (uuid->type == BT_UUID16) {
u16 = htobs(uuid->value.u16);
value = &u16;
vlen = sizeof(u16);
} else {
htob128(&uuid->value.u128, &u128);
value = &u128;
vlen = sizeof(u128);
}
plen = enc_find_by_type_req(start, end, &prim, value, vlen,
pdu, len);
}
return plen;
}