1e5836bafSMatthias Ringwald /*
2e5836bafSMatthias Ringwald * Copyright (C) 2014 BlueKitchen GmbH
3e5836bafSMatthias Ringwald *
4e5836bafSMatthias Ringwald * Redistribution and use in source and binary forms, with or without
5e5836bafSMatthias Ringwald * modification, are permitted provided that the following conditions
6e5836bafSMatthias Ringwald * are met:
7e5836bafSMatthias Ringwald *
8e5836bafSMatthias Ringwald * 1. Redistributions of source code must retain the above copyright
9e5836bafSMatthias Ringwald * notice, this list of conditions and the following disclaimer.
10e5836bafSMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright
11e5836bafSMatthias Ringwald * notice, this list of conditions and the following disclaimer in the
12e5836bafSMatthias Ringwald * documentation and/or other materials provided with the distribution.
13e5836bafSMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of
14e5836bafSMatthias Ringwald * contributors may be used to endorse or promote products derived
15e5836bafSMatthias Ringwald * from this software without specific prior written permission.
16e5836bafSMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for
17e5836bafSMatthias Ringwald * personal benefit and not for any commercial purpose or for
18e5836bafSMatthias Ringwald * monetary gain.
19e5836bafSMatthias Ringwald *
20e5836bafSMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21e5836bafSMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22e5836bafSMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23*2fca4dadSMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
24*2fca4dadSMilanka Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25e5836bafSMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26e5836bafSMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27e5836bafSMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28e5836bafSMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29e5836bafSMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30e5836bafSMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31e5836bafSMatthias Ringwald * SUCH DAMAGE.
32e5836bafSMatthias Ringwald *
33e5836bafSMatthias Ringwald * Please inquire about commercial licensing options at
34e5836bafSMatthias Ringwald * [email protected]
35e5836bafSMatthias Ringwald *
36e5836bafSMatthias Ringwald */
37e5836bafSMatthias Ringwald
38e5836bafSMatthias Ringwald #define BTSTACK_FILE__ "gatt_sdp.c"
39e5836bafSMatthias Ringwald
40e5836bafSMatthias Ringwald /*
41e5836bafSMatthias Ringwald * gatt_sdp.c
42e5836bafSMatthias Ringwald */
43e5836bafSMatthias Ringwald
44e5836bafSMatthias Ringwald #include "gatt_sdp.h"
45e5836bafSMatthias Ringwald
46e5836bafSMatthias Ringwald #include <string.h>
4784e3541eSMilanka Ringwald #include "bluetooth_gatt.h"
4884e3541eSMilanka Ringwald #include "bluetooth_psm.h"
49e5836bafSMatthias Ringwald #include "bluetooth_sdp.h"
50e5836bafSMatthias Ringwald #include "btstack_config.h"
51e5836bafSMatthias Ringwald #include "classic/core.h"
52e5836bafSMatthias Ringwald #include "classic/sdp_util.h"
5384e3541eSMilanka Ringwald #include "l2cap.h"
54e5836bafSMatthias Ringwald
gatt_create_sdp_record(uint8_t * service,uint32_t service_record_handle,uint16_t gatt_start_handle,uint16_t gatt_end_handle)55e5836bafSMatthias Ringwald void gatt_create_sdp_record(uint8_t *service, uint32_t service_record_handle, uint16_t gatt_start_handle, uint16_t gatt_end_handle){
56e5836bafSMatthias Ringwald
57e5836bafSMatthias Ringwald uint8_t* attribute;
58e5836bafSMatthias Ringwald de_create_sequence(service);
59e5836bafSMatthias Ringwald
60e5836bafSMatthias Ringwald // 0x0000 "Service Record Handle"
61e5836bafSMatthias Ringwald de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_RECORD_HANDLE);
62e5836bafSMatthias Ringwald de_add_number(service, DE_UINT, DE_SIZE_32, service_record_handle);
63e5836bafSMatthias Ringwald
64e5836bafSMatthias Ringwald // 0x0001 "Service Class ID List"
65e5836bafSMatthias Ringwald de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST);
66e5836bafSMatthias Ringwald attribute = de_push_sequence(service);
67e5836bafSMatthias Ringwald {
68e5836bafSMatthias Ringwald de_add_number(attribute, DE_UUID, DE_SIZE_32, ORG_BLUETOOTH_SERVICE_GENERIC_ATTRIBUTE);
69e5836bafSMatthias Ringwald }
70e5836bafSMatthias Ringwald de_pop_sequence(service, attribute);
71e5836bafSMatthias Ringwald
72e5836bafSMatthias Ringwald // 0x0004 "Protocol Descriptor List"
73e5836bafSMatthias Ringwald de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST);
74e5836bafSMatthias Ringwald attribute = de_push_sequence(service);
75e5836bafSMatthias Ringwald {
76e5836bafSMatthias Ringwald uint8_t* l2cap_protocol = de_push_sequence(attribute);
77e5836bafSMatthias Ringwald {
78e5836bafSMatthias Ringwald de_add_number(l2cap_protocol, DE_UUID, DE_SIZE_16, BLUETOOTH_PROTOCOL_L2CAP);
7984e3541eSMilanka Ringwald de_add_number(l2cap_protocol, DE_UINT, DE_SIZE_16, BLUETOOTH_PSM_ATT);
80e5836bafSMatthias Ringwald }
81e5836bafSMatthias Ringwald de_pop_sequence(attribute, l2cap_protocol);
82e5836bafSMatthias Ringwald
83e5836bafSMatthias Ringwald uint8_t* att_protocol = de_push_sequence(attribute);
84e5836bafSMatthias Ringwald {
85e5836bafSMatthias Ringwald de_add_number(att_protocol, DE_UUID, DE_SIZE_16, BLUETOOTH_PROTOCOL_ATT);
86e5836bafSMatthias Ringwald de_add_number(att_protocol, DE_UINT, DE_SIZE_16, gatt_start_handle);
87e5836bafSMatthias Ringwald de_add_number(att_protocol, DE_UINT, DE_SIZE_16, gatt_end_handle);
88e5836bafSMatthias Ringwald
89e5836bafSMatthias Ringwald }
90e5836bafSMatthias Ringwald de_pop_sequence(attribute, att_protocol);
91e5836bafSMatthias Ringwald }
92e5836bafSMatthias Ringwald de_pop_sequence(service, attribute);
93e5836bafSMatthias Ringwald
94e5836bafSMatthias Ringwald // 0x0005 "Public Browse Group"
95e5836bafSMatthias Ringwald de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_BROWSE_GROUP_LIST);
96e5836bafSMatthias Ringwald attribute = de_push_sequence(service);
97e5836bafSMatthias Ringwald {
98e5836bafSMatthias Ringwald de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PUBLIC_BROWSE_ROOT);
99e5836bafSMatthias Ringwald }
100e5836bafSMatthias Ringwald de_pop_sequence(service, attribute);
101e5836bafSMatthias Ringwald }
102