xref: /btstack/src/classic/device_id_server.c (revision d38c4adf3a7ce438b3f5310fa2b822ce0be97536)
1c4b3290dSMatthias Ringwald /*
2c4b3290dSMatthias Ringwald  * Copyright (C) 2014 BlueKitchen GmbH
3c4b3290dSMatthias Ringwald  *
4c4b3290dSMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
5c4b3290dSMatthias Ringwald  * modification, are permitted provided that the following conditions
6c4b3290dSMatthias Ringwald  * are met:
7c4b3290dSMatthias Ringwald  *
8c4b3290dSMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
9c4b3290dSMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
10c4b3290dSMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
11c4b3290dSMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
12c4b3290dSMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
13c4b3290dSMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
14c4b3290dSMatthias Ringwald  *    contributors may be used to endorse or promote products derived
15c4b3290dSMatthias Ringwald  *    from this software without specific prior written permission.
16c4b3290dSMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
17c4b3290dSMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
18c4b3290dSMatthias Ringwald  *    monetary gain.
19c4b3290dSMatthias Ringwald  *
20c4b3290dSMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21c4b3290dSMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22c4b3290dSMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23c4b3290dSMatthias Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
24c4b3290dSMatthias Ringwald  * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25c4b3290dSMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26c4b3290dSMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27c4b3290dSMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28c4b3290dSMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29c4b3290dSMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30c4b3290dSMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31c4b3290dSMatthias Ringwald  * SUCH DAMAGE.
32c4b3290dSMatthias Ringwald  *
33c4b3290dSMatthias Ringwald  * Please inquire about commercial licensing options at
34c4b3290dSMatthias Ringwald  * [email protected]
35c4b3290dSMatthias Ringwald  *
36c4b3290dSMatthias Ringwald  */
37c4b3290dSMatthias Ringwald 
38c4b3290dSMatthias Ringwald /*
39c4b3290dSMatthias Ringwald  * device_id_server.c
40c4b3290dSMatthias Ringwald  *
41c4b3290dSMatthias Ringwald  * Creates Device ID SDP Records
42c4b3290dSMatthias Ringwald  */
43c4b3290dSMatthias Ringwald 
44c4b3290dSMatthias Ringwald #include "device_id_server.h"
45c4b3290dSMatthias Ringwald 
46c4b3290dSMatthias Ringwald #include <string.h>
47c4b3290dSMatthias Ringwald 
48c4b3290dSMatthias Ringwald #include "bluetooth.h"
49c4b3290dSMatthias Ringwald #include "bluetooth_sdp.h"
50c4b3290dSMatthias Ringwald #include "btstack_config.h"
51c4b3290dSMatthias Ringwald #include "classic/core.h"
52c4b3290dSMatthias Ringwald #include "classic/sdp_util.h"
53c4b3290dSMatthias Ringwald 
54c4b3290dSMatthias Ringwald void device_id_create_sdp_record(uint8_t *service, uint32_t service_record_handle, uint16_t vendor_id_source, uint16_t vendor_id, uint16_t product_id, uint16_t version){
55c4b3290dSMatthias Ringwald 
56c4b3290dSMatthias Ringwald 	uint8_t* attribute;
57c4b3290dSMatthias Ringwald 	de_create_sequence(service);
58c4b3290dSMatthias Ringwald 
59c4b3290dSMatthias Ringwald     // 0x0000 "Service Record Handle"
60c4b3290dSMatthias Ringwald 	de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_RECORD_HANDLE);
61c4b3290dSMatthias Ringwald 	de_add_number(service, DE_UINT, DE_SIZE_32, service_record_handle);
62c4b3290dSMatthias Ringwald 
63c4b3290dSMatthias Ringwald 	// 0x0001 "Service Class ID List"
64*d38c4adfSMatthias Ringwald 	de_add_number(service,  DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST);
65c4b3290dSMatthias Ringwald 	attribute = de_push_sequence(service);
66c4b3290dSMatthias Ringwald 	{
67c4b3290dSMatthias Ringwald 		de_add_number(attribute,  DE_UUID, DE_SIZE_16, BLUETOOTH_SERVICE_CLASS_PNP_INFORMATION );
68c4b3290dSMatthias Ringwald 	}
69c4b3290dSMatthias Ringwald 	de_pop_sequence(service, attribute);
70c4b3290dSMatthias Ringwald 
71c4b3290dSMatthias Ringwald 	// 0x0005 "Public Browse Group"
72c4b3290dSMatthias Ringwald 	de_add_number(service,  DE_UINT, DE_SIZE_16, SDP_BrowseGroupList); // public browse group
73c4b3290dSMatthias Ringwald 	attribute = de_push_sequence(service);
74c4b3290dSMatthias Ringwald 	{
75c4b3290dSMatthias Ringwald 		de_add_number(attribute,  DE_UUID, DE_SIZE_16, SDP_PublicBrowseGroup );
76c4b3290dSMatthias Ringwald 	}
77c4b3290dSMatthias Ringwald 	de_pop_sequence(service, attribute);
78c4b3290dSMatthias Ringwald 
79c4b3290dSMatthias Ringwald 	// 0x0200 "SpecificationID"
80c4b3290dSMatthias Ringwald 	de_add_number(service,  DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SPECIFICATION_ID);
81c4b3290dSMatthias Ringwald 	de_add_number(service,  DE_UINT, DE_SIZE_16, 0x0102);	// v1.2
82c4b3290dSMatthias Ringwald 
83c4b3290dSMatthias Ringwald 	// 0x0201 "VendorID"
84c4b3290dSMatthias Ringwald 	de_add_number(service,  DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_VENDOR_ID);
85c4b3290dSMatthias Ringwald 	de_add_number(service,  DE_UINT, DE_SIZE_16, vendor_id);
86c4b3290dSMatthias Ringwald 
87c4b3290dSMatthias Ringwald 	// 0x0202 "ProductID"
88c4b3290dSMatthias Ringwald 	de_add_number(service,  DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PRODUCT_ID);
89c4b3290dSMatthias Ringwald 	de_add_number(service,  DE_UINT, DE_SIZE_16, product_id);
90c4b3290dSMatthias Ringwald 
91c4b3290dSMatthias Ringwald 	// 0x0203 "Version"
92c4b3290dSMatthias Ringwald 	de_add_number(service,  DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_VERSION);
93c4b3290dSMatthias Ringwald 	de_add_number(service,  DE_UINT, DE_SIZE_16, version);
94c4b3290dSMatthias Ringwald 
95c4b3290dSMatthias Ringwald 	// 0x0204 "PrimaryRecord"
96c4b3290dSMatthias Ringwald 	de_add_number(service,  DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PRIMARY_RECORD);
97c4b3290dSMatthias Ringwald 	de_add_number(service,  DE_UINT, DE_SIZE_16, 1);	// yes, this is the primary record - there are no others
98c4b3290dSMatthias Ringwald 
99c4b3290dSMatthias Ringwald 	// 0x0205 "VendorIDSource"
100c4b3290dSMatthias Ringwald 	de_add_number(service,  DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_VENDOR_ID_SOURCE);
101c4b3290dSMatthias Ringwald 	de_add_number(service,  DE_UINT, DE_SIZE_16, vendor_id_source);
102c4b3290dSMatthias Ringwald }