Lines Matching +full:data +full:- +full:role

4  * SPDX-License-Identifier: Apache-2.0
48 /* Remote role and features */
49 enum bt_gmap_role role; member
66 if (gmap_cli->conn != NULL) { in gmap_reset()
67 bt_conn_unref(gmap_cli->conn); in gmap_reset()
77 if (gmap_cli->conn == conn) { in client_by_conn()
89 bt_conn_unref(gmap_cli->conn); in disconnected()
90 gmap_cli->conn = NULL; in disconnected()
100 LOG_DBG("conn %p", (void *)gmap_cli->conn); in discover_complete()
102 atomic_clear_bit(gmap_cli->flags, GMAP_CLIENT_FLAG_BUSY); in discover_complete()
104 if (gmap_cb->discover != NULL) { in discover_complete()
105 gmap_cb->discover(gmap_cli->conn, 0, gmap_cli->role, gmap_cli->feat); in discover_complete()
111 struct bt_conn *conn = gmap_cli->conn; in discover_failed()
117 gmap_cb->discover(conn, err, 0, (struct bt_gmap_feat){0}); in discover_failed()
121 struct bt_gatt_read_params *params, const void *data, uint16_t len) in bgr_feat_read_cb() argument
129 LOG_DBG("conn %p att_err 0x%02x params %p data %p len %u", (void *)conn, att_err, params, in bgr_feat_read_cb()
130 data, len); in bgr_feat_read_cb()
132 if (data == NULL || att_err != BT_ATT_ERR_SUCCESS || len != sizeof(uint8_t)) { in bgr_feat_read_cb()
142 net_buf_simple_init_with_data(&buf, (void *)data, len); in bgr_feat_read_cb()
144 gmap_cli->feat.bgr_feat = net_buf_simple_pull_u8(&buf); in bgr_feat_read_cb()
145 LOG_DBG("bgr_feat 0x%02x", gmap_cli->feat.bgr_feat); in bgr_feat_read_cb()
154 LOG_DBG("conn %p handle 0x%04x", (void *)gmap_cli->conn, handle); in gmap_read_bgr_feat()
156 memset(&gmap_cli->params.read, 0, sizeof(gmap_cli->params.read)); in gmap_read_bgr_feat()
158 gmap_cli->params.read.func = bgr_feat_read_cb; in gmap_read_bgr_feat()
159 gmap_cli->params.read.handle_count = 1u; in gmap_read_bgr_feat()
160 gmap_cli->params.read.single.handle = handle; in gmap_read_bgr_feat()
161 gmap_cli->params.read.single.offset = 0u; in gmap_read_bgr_feat()
163 return bt_gatt_read(gmap_cli->conn, &gmap_cli->params.read); in gmap_read_bgr_feat()
178 discover_failed(gmap_cli, -ENOENT); in bgr_feat_discover_func()
183 chrc = attr->user_data; in bgr_feat_discover_func()
186 err = gmap_read_bgr_feat(gmap_cli, chrc->value_handle); in bgr_feat_discover_func()
196 LOG_DBG("conn %p", (void *)gmap_cli->conn); in gmap_discover_bgr_feat()
198 memset(&gmap_cli->params.discover, 0, sizeof(gmap_cli->params.discover)); in gmap_discover_bgr_feat()
200 gmap_cli->params.discover.func = bgr_feat_discover_func; in gmap_discover_bgr_feat()
201 gmap_cli->params.discover.uuid = gmap_bgr_feat_uuid; in gmap_discover_bgr_feat()
202 gmap_cli->params.discover.type = BT_GATT_DISCOVER_CHARACTERISTIC; in gmap_discover_bgr_feat()
203 gmap_cli->params.discover.start_handle = gmap_cli->svc_start_handle; in gmap_discover_bgr_feat()
204 gmap_cli->params.discover.end_handle = gmap_cli->svc_end_handle; in gmap_discover_bgr_feat()
206 return bt_gatt_discover(gmap_cli->conn, &gmap_cli->params.discover); in gmap_discover_bgr_feat()
210 struct bt_gatt_read_params *params, const void *data, uint16_t len) in bgs_feat_read_cb() argument
218 LOG_DBG("conn %p att_err 0x%02x params %p data %p len %u", (void *)conn, att_err, params, in bgs_feat_read_cb()
219 data, len); in bgs_feat_read_cb()
221 if (data == NULL || att_err != BT_ATT_ERR_SUCCESS || len != sizeof(uint8_t)) { in bgs_feat_read_cb()
231 net_buf_simple_init_with_data(&buf, (void *)data, len); in bgs_feat_read_cb()
233 gmap_cli->feat.bgs_feat = net_buf_simple_pull_u8(&buf); in bgs_feat_read_cb()
234 LOG_DBG("bgs_feat 0x%02x", gmap_cli->feat.bgs_feat); in bgs_feat_read_cb()
236 if ((gmap_cli->role & BT_GMAP_ROLE_BGR) != 0) { in bgs_feat_read_cb()
253 LOG_DBG("conn %p handle 0x%04x", (void *)gmap_cli->conn, handle); in gmap_read_bgs_feat()
255 memset(&gmap_cli->params.read, 0, sizeof(gmap_cli->params.read)); in gmap_read_bgs_feat()
257 gmap_cli->params.read.func = bgs_feat_read_cb; in gmap_read_bgs_feat()
258 gmap_cli->params.read.handle_count = 1u; in gmap_read_bgs_feat()
259 gmap_cli->params.read.single.handle = handle; in gmap_read_bgs_feat()
260 gmap_cli->params.read.single.offset = 0u; in gmap_read_bgs_feat()
262 return bt_gatt_read(gmap_cli->conn, &gmap_cli->params.read); in gmap_read_bgs_feat()
277 discover_failed(gmap_cli, -ENOENT); in bgs_feat_discover_func()
282 chrc = attr->user_data; in bgs_feat_discover_func()
285 err = gmap_read_bgs_feat(gmap_cli, chrc->value_handle); in bgs_feat_discover_func()
295 LOG_DBG("conn %p", (void *)gmap_cli->conn); in gmap_discover_bgs_feat()
297 memset(&gmap_cli->params.discover, 0, sizeof(gmap_cli->params.discover)); in gmap_discover_bgs_feat()
299 gmap_cli->params.discover.func = bgs_feat_discover_func; in gmap_discover_bgs_feat()
300 gmap_cli->params.discover.uuid = gmap_bgs_feat_uuid; in gmap_discover_bgs_feat()
301 gmap_cli->params.discover.type = BT_GATT_DISCOVER_CHARACTERISTIC; in gmap_discover_bgs_feat()
302 gmap_cli->params.discover.start_handle = gmap_cli->svc_start_handle; in gmap_discover_bgs_feat()
303 gmap_cli->params.discover.end_handle = gmap_cli->svc_end_handle; in gmap_discover_bgs_feat()
305 return bt_gatt_discover(gmap_cli->conn, &gmap_cli->params.discover); in gmap_discover_bgs_feat()
309 struct bt_gatt_read_params *params, const void *data, uint16_t len) in ugt_feat_read_cb() argument
317 LOG_DBG("conn %p att_err 0x%02x params %p data %p len %u", (void *)conn, att_err, params, in ugt_feat_read_cb()
318 data, len); in ugt_feat_read_cb()
320 if (data == NULL || att_err != BT_ATT_ERR_SUCCESS || len != sizeof(uint8_t)) { in ugt_feat_read_cb()
330 net_buf_simple_init_with_data(&buf, (void *)data, len); in ugt_feat_read_cb()
332 gmap_cli->feat.ugt_feat = net_buf_simple_pull_u8(&buf); in ugt_feat_read_cb()
333 LOG_DBG("ugt_feat 0x%02x", gmap_cli->feat.ugt_feat); in ugt_feat_read_cb()
335 if ((gmap_cli->role & BT_GMAP_ROLE_BGS) != 0) { in ugt_feat_read_cb()
337 } else if ((gmap_cli->role & BT_GMAP_ROLE_BGR) != 0) { in ugt_feat_read_cb()
354 LOG_DBG("conn %p handle 0x%04x", (void *)gmap_cli->conn, handle); in gmap_read_ugt_feat()
356 memset(&gmap_cli->params.read, 0, sizeof(gmap_cli->params.read)); in gmap_read_ugt_feat()
358 gmap_cli->params.read.func = ugt_feat_read_cb; in gmap_read_ugt_feat()
359 gmap_cli->params.read.handle_count = 1u; in gmap_read_ugt_feat()
360 gmap_cli->params.read.single.handle = handle; in gmap_read_ugt_feat()
361 gmap_cli->params.read.single.offset = 0u; in gmap_read_ugt_feat()
363 return bt_gatt_read(gmap_cli->conn, &gmap_cli->params.read); in gmap_read_ugt_feat()
378 discover_failed(gmap_cli, -ENOENT); in ugt_feat_discover_func()
383 chrc = attr->user_data; in ugt_feat_discover_func()
386 err = gmap_read_ugt_feat(gmap_cli, chrc->value_handle); in ugt_feat_discover_func()
396 LOG_DBG("conn %p", (void *)gmap_cli->conn); in gmap_discover_ugt_feat()
398 memset(&gmap_cli->params.discover, 0, sizeof(gmap_cli->params.discover)); in gmap_discover_ugt_feat()
400 gmap_cli->params.discover.func = ugt_feat_discover_func; in gmap_discover_ugt_feat()
401 gmap_cli->params.discover.uuid = gmap_ugt_feat_uuid; in gmap_discover_ugt_feat()
402 gmap_cli->params.discover.type = BT_GATT_DISCOVER_CHARACTERISTIC; in gmap_discover_ugt_feat()
403 gmap_cli->params.discover.start_handle = gmap_cli->svc_start_handle; in gmap_discover_ugt_feat()
404 gmap_cli->params.discover.end_handle = gmap_cli->svc_end_handle; in gmap_discover_ugt_feat()
406 return bt_gatt_discover(gmap_cli->conn, &gmap_cli->params.discover); in gmap_discover_ugt_feat()
410 struct bt_gatt_read_params *params, const void *data, uint16_t len) in ugg_feat_read_cb() argument
418 LOG_DBG("conn %p att_err 0x%02x params %p data %p len %u", (void *)conn, att_err, params, in ugg_feat_read_cb()
419 data, len); in ugg_feat_read_cb()
421 if (data == NULL || att_err != BT_ATT_ERR_SUCCESS || len != sizeof(uint8_t)) { in ugg_feat_read_cb()
431 net_buf_simple_init_with_data(&buf, (void *)data, len); in ugg_feat_read_cb()
433 gmap_cli->feat.ugg_feat = net_buf_simple_pull_u8(&buf); in ugg_feat_read_cb()
434 LOG_DBG("ugg_feat 0x%02x", gmap_cli->feat.ugg_feat); in ugg_feat_read_cb()
436 if ((gmap_cli->role & BT_GMAP_ROLE_UGT) != 0) { in ugg_feat_read_cb()
438 } else if ((gmap_cli->role & BT_GMAP_ROLE_BGS) != 0) { in ugg_feat_read_cb()
440 } else if ((gmap_cli->role & BT_GMAP_ROLE_BGR) != 0) { in ugg_feat_read_cb()
457 LOG_DBG("conn %p handle 0x%04x", (void *)gmap_cli->conn, handle); in gmap_read_ugg_feat()
459 memset(&gmap_cli->params.read, 0, sizeof(gmap_cli->params.read)); in gmap_read_ugg_feat()
461 gmap_cli->params.read.func = ugg_feat_read_cb; in gmap_read_ugg_feat()
462 gmap_cli->params.read.handle_count = 1u; in gmap_read_ugg_feat()
463 gmap_cli->params.read.single.handle = handle; in gmap_read_ugg_feat()
464 gmap_cli->params.read.single.offset = 0u; in gmap_read_ugg_feat()
466 return bt_gatt_read(gmap_cli->conn, &gmap_cli->params.read); in gmap_read_ugg_feat()
481 discover_failed(gmap_cli, -ENOENT); in ugg_feat_discover_func()
486 chrc = attr->user_data; in ugg_feat_discover_func()
489 err = gmap_read_ugg_feat(gmap_cli, chrc->value_handle); in ugg_feat_discover_func()
499 LOG_DBG("conn %p", (void *)gmap_cli->conn); in gmap_discover_ugg_feat()
501 memset(&gmap_cli->params.discover, 0, sizeof(gmap_cli->params.discover)); in gmap_discover_ugg_feat()
503 gmap_cli->params.discover.func = ugg_feat_discover_func; in gmap_discover_ugg_feat()
504 gmap_cli->params.discover.uuid = gmap_ugg_feat_uuid; in gmap_discover_ugg_feat()
505 gmap_cli->params.discover.type = BT_GATT_DISCOVER_CHARACTERISTIC; in gmap_discover_ugg_feat()
506 gmap_cli->params.discover.start_handle = gmap_cli->svc_start_handle; in gmap_discover_ugg_feat()
507 gmap_cli->params.discover.end_handle = gmap_cli->svc_end_handle; in gmap_discover_ugg_feat()
509 return bt_gatt_discover(gmap_cli->conn, &gmap_cli->params.discover); in gmap_discover_ugg_feat()
513 struct bt_gatt_read_params *params, const void *data, uint16_t len) in role_read_cb() argument
521 LOG_DBG("conn %p att_err 0x%02x params %p data %p len %u", (void *)conn, att_err, params, in role_read_cb()
522 data, len); in role_read_cb()
524 if (data == NULL || att_err != BT_ATT_ERR_SUCCESS || len != sizeof(uint8_t)) { in role_read_cb()
534 net_buf_simple_init_with_data(&buf, (void *)data, len); in role_read_cb()
536 gmap_cli->role = net_buf_simple_pull_u8(&buf); in role_read_cb()
537 LOG_DBG("role 0x%02x", gmap_cli->role); in role_read_cb()
539 if ((gmap_cli->role & BT_GMAP_ROLE_UGG) != 0) { in role_read_cb()
541 } else if ((gmap_cli->role & BT_GMAP_ROLE_UGT) != 0) { in role_read_cb()
543 } else if ((gmap_cli->role & BT_GMAP_ROLE_BGS) != 0) { in role_read_cb()
545 } else if ((gmap_cli->role & BT_GMAP_ROLE_BGR) != 0) { in role_read_cb()
549 err = -ECANCELED; in role_read_cb()
561 LOG_DBG("conn %p handle 0x%04x", (void *)gmap_cli->conn, handle); in gmap_read_role()
563 memset(&gmap_cli->params.read, 0, sizeof(gmap_cli->params.read)); in gmap_read_role()
565 gmap_cli->params.read.func = role_read_cb; in gmap_read_role()
566 gmap_cli->params.read.handle_count = 1u; in gmap_read_role()
567 gmap_cli->params.read.single.handle = handle; in gmap_read_role()
568 gmap_cli->params.read.single.offset = 0u; in gmap_read_role()
570 return bt_gatt_read(gmap_cli->conn, &gmap_cli->params.read); in gmap_read_role()
585 discover_failed(gmap_cli, -ENOENT); in role_discover_func()
590 chrc = attr->user_data; in role_discover_func()
593 err = gmap_read_role(gmap_cli, chrc->value_handle); in role_discover_func()
603 LOG_DBG("conn %p", (void *)gmap_cli->conn); in gmap_discover_role()
605 memset(&gmap_cli->params.discover, 0, sizeof(gmap_cli->params.discover)); in gmap_discover_role()
607 gmap_cli->params.discover.func = role_discover_func; in gmap_discover_role()
608 gmap_cli->params.discover.uuid = gmap_role_uuid; in gmap_discover_role()
609 gmap_cli->params.discover.type = BT_GATT_DISCOVER_CHARACTERISTIC; in gmap_discover_role()
610 gmap_cli->params.discover.start_handle = gmap_cli->svc_start_handle; in gmap_discover_role()
611 gmap_cli->params.discover.end_handle = gmap_cli->svc_end_handle; in gmap_discover_role()
613 return bt_gatt_discover(gmap_cli->conn, &gmap_cli->params.discover); in gmap_discover_role()
628 discover_failed(gmap_cli, -ENOENT); in gmas_discover_func()
633 svc = (struct bt_gatt_service_val *)attr->user_data; in gmas_discover_func()
634 gmap_cli->svc_start_handle = attr->handle; in gmas_discover_func()
635 gmap_cli->svc_end_handle = svc->end_handle; in gmas_discover_func()
653 return -EINVAL; in bt_gmap_discover()
658 if (atomic_test_and_set_bit(gmap_cli->flags, GMAP_CLIENT_FLAG_BUSY)) { in bt_gmap_discover()
661 return -EBUSY; in bt_gmap_discover()
666 gmap_cli->params.discover.func = gmas_discover_func; in bt_gmap_discover()
667 gmap_cli->params.discover.uuid = gmas_uuid; in bt_gmap_discover()
668 gmap_cli->params.discover.type = BT_GATT_DISCOVER_PRIMARY; in bt_gmap_discover()
669 gmap_cli->params.discover.start_handle = BT_ATT_FIRST_ATTRIBUTE_HANDLE; in bt_gmap_discover()
670 gmap_cli->params.discover.end_handle = BT_ATT_LAST_ATTRIBUTE_HANDLE; in bt_gmap_discover()
672 err = bt_gatt_discover(conn, &gmap_cli->params.discover); in bt_gmap_discover()
676 atomic_clear_bit(gmap_cli->flags, GMAP_CLIENT_FLAG_BUSY); in bt_gmap_discover()
678 return -ENOEXEC; in bt_gmap_discover()
681 gmap_cli->conn = bt_conn_ref(conn); in bt_gmap_discover()
691 return -EINVAL; in bt_gmap_cb_register()
697 return -EALREADY; in bt_gmap_cb_register()