gatt_client.c (6535961a1f105e850ecdf294c128b9fc982ee05a) gatt_client.c (c839c6f943a092feb48f0fe1470f7b8a1cc49f3b)
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

--- 2073 unchanged lines hidden (view full) ---

2082}
2083
2084void gatt_client_deserialize_service(const uint8_t *packet, int offset, gatt_client_service_t *service){
2085 service->start_group_handle = little_endian_read_16(packet, offset);
2086 service->end_group_handle = little_endian_read_16(packet, offset + 2);
2087 reverse_128(&packet[offset + 4], service->uuid128);
2088 if (uuid_has_bluetooth_prefix(service->uuid128)){
2089 service->uuid16 = big_endian_read_32(service->uuid128, 0);
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

--- 2073 unchanged lines hidden (view full) ---

2082}
2083
2084void gatt_client_deserialize_service(const uint8_t *packet, int offset, gatt_client_service_t *service){
2085 service->start_group_handle = little_endian_read_16(packet, offset);
2086 service->end_group_handle = little_endian_read_16(packet, offset + 2);
2087 reverse_128(&packet[offset + 4], service->uuid128);
2088 if (uuid_has_bluetooth_prefix(service->uuid128)){
2089 service->uuid16 = big_endian_read_32(service->uuid128, 0);
2090 } else {
2091 service->uuid16 = 0;
2090 }
2091}
2092
2093void gatt_client_deserialize_characteristic(const uint8_t * packet, int offset, gatt_client_characteristic_t * characteristic){
2094 characteristic->start_handle = little_endian_read_16(packet, offset);
2095 characteristic->value_handle = little_endian_read_16(packet, offset + 2);
2096 characteristic->end_handle = little_endian_read_16(packet, offset + 4);
2097 characteristic->properties = little_endian_read_16(packet, offset + 6);
2098 reverse_128(&packet[offset+8], characteristic->uuid128);
2099 if (uuid_has_bluetooth_prefix(characteristic->uuid128)){
2100 characteristic->uuid16 = big_endian_read_32(characteristic->uuid128, 0);
2092 }
2093}
2094
2095void gatt_client_deserialize_characteristic(const uint8_t * packet, int offset, gatt_client_characteristic_t * characteristic){
2096 characteristic->start_handle = little_endian_read_16(packet, offset);
2097 characteristic->value_handle = little_endian_read_16(packet, offset + 2);
2098 characteristic->end_handle = little_endian_read_16(packet, offset + 4);
2099 characteristic->properties = little_endian_read_16(packet, offset + 6);
2100 reverse_128(&packet[offset+8], characteristic->uuid128);
2101 if (uuid_has_bluetooth_prefix(characteristic->uuid128)){
2102 characteristic->uuid16 = big_endian_read_32(characteristic->uuid128, 0);
2103 } else {
2104 characteristic->uuid16 = 0;
2101 }
2102}
2103
2104void gatt_client_deserialize_characteristic_descriptor(const uint8_t * packet, int offset, gatt_client_characteristic_descriptor_t * descriptor){
2105 descriptor->handle = little_endian_read_16(packet, offset);
2106 reverse_128(&packet[offset+2], descriptor->uuid128);
2107 if (uuid_has_bluetooth_prefix(descriptor->uuid128)){
2108 descriptor->uuid16 = big_endian_read_32(descriptor->uuid128, 0);
2105 }
2106}
2107
2108void gatt_client_deserialize_characteristic_descriptor(const uint8_t * packet, int offset, gatt_client_characteristic_descriptor_t * descriptor){
2109 descriptor->handle = little_endian_read_16(packet, offset);
2110 reverse_128(&packet[offset+2], descriptor->uuid128);
2111 if (uuid_has_bluetooth_prefix(descriptor->uuid128)){
2112 descriptor->uuid16 = big_endian_read_32(descriptor->uuid128, 0);
2113 } else {
2114 descriptor->uuid16 = 0;
2109 }
2110}
2111
2112void gatt_client_send_mtu_negotiation(btstack_packet_handler_t callback, hci_con_handle_t con_handle){
2113 gatt_client_t * context = provide_context_for_conn_handle(con_handle);
2114 if (context == NULL) return;
2115 if (context->mtu_state == MTU_AUTO_EXCHANGE_DISABLED){
2116 context->callback = callback;

--- 13 unchanged lines hidden ---
2115 }
2116}
2117
2118void gatt_client_send_mtu_negotiation(btstack_packet_handler_t callback, hci_con_handle_t con_handle){
2119 gatt_client_t * context = provide_context_for_conn_handle(con_handle);
2120 if (context == NULL) return;
2121 if (context->mtu_state == MTU_AUTO_EXCHANGE_DISABLED){
2122 context->callback = callback;

--- 13 unchanged lines hidden ---