gatt_client.c (8183ac30e3e8b86d5fa7520022dfb6ea66927e2a) | gatt_client.c (a94d23eaebfede58bf9fb58975795b387dd511df) |
---|---|
1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 2646 unchanged lines hidden (view full) --- 2655uint8_t gatt_client_discover_characteristics_for_service_by_uuid16(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t * service, uint16_t uuid16){ 2656 return gatt_client_discover_characteristics_for_handle_range_by_uuid16(callback, con_handle, service->start_group_handle, service->end_group_handle, uuid16); 2657} 2658 2659uint8_t gatt_client_discover_characteristics_for_service_by_uuid128(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t * service, const uint8_t * uuid128){ 2660 return gatt_client_discover_characteristics_for_handle_range_by_uuid128(callback, con_handle, service->start_group_handle, service->end_group_handle, uuid128); 2661} 2662 | 1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 2646 unchanged lines hidden (view full) --- 2655uint8_t gatt_client_discover_characteristics_for_service_by_uuid16(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t * service, uint16_t uuid16){ 2656 return gatt_client_discover_characteristics_for_handle_range_by_uuid16(callback, con_handle, service->start_group_handle, service->end_group_handle, uuid16); 2657} 2658 2659uint8_t gatt_client_discover_characteristics_for_service_by_uuid128(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t * service, const uint8_t * uuid128){ 2660 return gatt_client_discover_characteristics_for_handle_range_by_uuid128(callback, con_handle, service->start_group_handle, service->end_group_handle, uuid128); 2661} 2662 |
2663uint8_t gatt_client_discover_characteristic_descriptors(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic){ | 2663uint8_t gatt_client_discover_characteristic_descriptors_with_context(btstack_packet_handler_t callback, hci_con_handle_t con_handle, 2664 gatt_client_characteristic_t * characteristic, uint16_t service_id, uint16_t connection_id){ |
2664 gatt_client_t * gatt_client; 2665 uint8_t status = gatt_client_provide_context_for_request(con_handle, &gatt_client); 2666 if (status != ERROR_CODE_SUCCESS){ 2667 return status; 2668 } 2669 | 2665 gatt_client_t * gatt_client; 2666 uint8_t status = gatt_client_provide_context_for_request(con_handle, &gatt_client); 2667 if (status != ERROR_CODE_SUCCESS){ 2668 return status; 2669 } 2670 |
2671 gatt_client->service_id = service_id; 2672 gatt_client->connection_id = connection_id; 2673 |
|
2670 // check if there is space for characteristics descriptors 2671 if (characteristic->end_handle > characteristic->value_handle){ 2672 gatt_client->callback = callback; 2673 gatt_client->start_group_handle = characteristic->value_handle + 1u; 2674 gatt_client->end_group_handle = characteristic->end_handle; 2675 gatt_client->state = P_W2_SEND_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY; 2676 gatt_client_run(); 2677 } else { 2678 // schedule gatt complete event on next run loop iteration otherwise 2679 gatt_client->state = P_W2_EMIT_QUERY_COMPLETE_EVENT; 2680 gatt_client_deferred_event_emit.callback = gatt_client_emit_events; 2681 btstack_run_loop_execute_on_main_thread(&gatt_client_deferred_event_emit); 2682 } 2683 return ERROR_CODE_SUCCESS; 2684} 2685 | 2674 // check if there is space for characteristics descriptors 2675 if (characteristic->end_handle > characteristic->value_handle){ 2676 gatt_client->callback = callback; 2677 gatt_client->start_group_handle = characteristic->value_handle + 1u; 2678 gatt_client->end_group_handle = characteristic->end_handle; 2679 gatt_client->state = P_W2_SEND_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY; 2680 gatt_client_run(); 2681 } else { 2682 // schedule gatt complete event on next run loop iteration otherwise 2683 gatt_client->state = P_W2_EMIT_QUERY_COMPLETE_EVENT; 2684 gatt_client_deferred_event_emit.callback = gatt_client_emit_events; 2685 btstack_run_loop_execute_on_main_thread(&gatt_client_deferred_event_emit); 2686 } 2687 return ERROR_CODE_SUCCESS; 2688} 2689 |
2690uint8_t gatt_client_discover_characteristic_descriptors(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic){ 2691 return gatt_client_discover_characteristic_descriptors_with_context(callback, con_handle, characteristic, 0, 0); 2692} 2693 |
|
2686uint8_t gatt_client_read_value_of_characteristic_using_value_handle(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle){ 2687 gatt_client_t * gatt_client; 2688 uint8_t status = gatt_client_provide_context_for_request(con_handle, &gatt_client); 2689 if (status != ERROR_CODE_SUCCESS){ 2690 return status; 2691 } 2692 2693 gatt_client->callback = callback; --- 1099 unchanged lines hidden --- | 2694uint8_t gatt_client_read_value_of_characteristic_using_value_handle(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle){ 2695 gatt_client_t * gatt_client; 2696 uint8_t status = gatt_client_provide_context_for_request(con_handle, &gatt_client); 2697 if (status != ERROR_CODE_SUCCESS){ 2698 return status; 2699 } 2700 2701 gatt_client->callback = callback; --- 1099 unchanged lines hidden --- |