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 38ab2c6ae4SMatthias Ringwald #define __BTSTACK_FILE__ "device_id_server.c" 39ab2c6ae4SMatthias Ringwald 40c4b3290dSMatthias Ringwald /* 41c4b3290dSMatthias Ringwald * device_id_server.c 42c4b3290dSMatthias Ringwald * 43c4b3290dSMatthias Ringwald * Creates Device ID SDP Records 44c4b3290dSMatthias Ringwald */ 45c4b3290dSMatthias Ringwald 4659fb9ebdSMatthias Ringwald #include "classic/device_id_server.h" 47c4b3290dSMatthias Ringwald 48c4b3290dSMatthias Ringwald #include <string.h> 49c4b3290dSMatthias Ringwald 50c4b3290dSMatthias Ringwald #include "bluetooth.h" 51c4b3290dSMatthias Ringwald #include "bluetooth_sdp.h" 52c4b3290dSMatthias Ringwald #include "btstack_config.h" 53c4b3290dSMatthias Ringwald #include "classic/core.h" 54c4b3290dSMatthias Ringwald #include "classic/sdp_util.h" 55c4b3290dSMatthias Ringwald 56c4b3290dSMatthias 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){ 57c4b3290dSMatthias Ringwald 58c4b3290dSMatthias Ringwald uint8_t* attribute; 59c4b3290dSMatthias Ringwald de_create_sequence(service); 60c4b3290dSMatthias Ringwald 61c4b3290dSMatthias Ringwald // 0x0000 "Service Record Handle" 62c4b3290dSMatthias Ringwald de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_RECORD_HANDLE); 63c4b3290dSMatthias Ringwald de_add_number(service, DE_UINT, DE_SIZE_32, service_record_handle); 64c4b3290dSMatthias Ringwald 65c4b3290dSMatthias Ringwald // 0x0001 "Service Class ID List" 66d38c4adfSMatthias Ringwald de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST); 67c4b3290dSMatthias Ringwald attribute = de_push_sequence(service); 68c4b3290dSMatthias Ringwald { 69c4b3290dSMatthias Ringwald de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_SERVICE_CLASS_PNP_INFORMATION ); 70c4b3290dSMatthias Ringwald } 71c4b3290dSMatthias Ringwald de_pop_sequence(service, attribute); 72c4b3290dSMatthias Ringwald 73c4b3290dSMatthias Ringwald // 0x0005 "Public Browse Group" 74235946f1SMatthias Ringwald de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_BROWSE_GROUP_LIST); // public browse group 75c4b3290dSMatthias Ringwald attribute = de_push_sequence(service); 76c4b3290dSMatthias Ringwald { 77235946f1SMatthias Ringwald de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PUBLIC_BROWSE_ROOT ); 78c4b3290dSMatthias Ringwald } 79c4b3290dSMatthias Ringwald de_pop_sequence(service, attribute); 80c4b3290dSMatthias Ringwald 81c4b3290dSMatthias Ringwald // 0x0200 "SpecificationID" 82c4b3290dSMatthias Ringwald de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SPECIFICATION_ID); 83f971afabSMatthias Ringwald de_add_number(service, DE_UINT, DE_SIZE_16, 0x0103); // v1.3 84c4b3290dSMatthias Ringwald 85c4b3290dSMatthias Ringwald // 0x0201 "VendorID" 86c4b3290dSMatthias Ringwald de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_VENDOR_ID); 87c4b3290dSMatthias Ringwald de_add_number(service, DE_UINT, DE_SIZE_16, vendor_id); 88c4b3290dSMatthias Ringwald 89c4b3290dSMatthias Ringwald // 0x0202 "ProductID" 90c4b3290dSMatthias Ringwald de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PRODUCT_ID); 91c4b3290dSMatthias Ringwald de_add_number(service, DE_UINT, DE_SIZE_16, product_id); 92c4b3290dSMatthias Ringwald 93c4b3290dSMatthias Ringwald // 0x0203 "Version" 94c4b3290dSMatthias Ringwald de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_VERSION); 95c4b3290dSMatthias Ringwald de_add_number(service, DE_UINT, DE_SIZE_16, version); 96c4b3290dSMatthias Ringwald 97c4b3290dSMatthias Ringwald // 0x0204 "PrimaryRecord" 98c4b3290dSMatthias Ringwald de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PRIMARY_RECORD); 99*c1b01f87SMatthias Ringwald de_add_number(service, DE_BOOL, DE_SIZE_8, 1); // yes, this is the primary record - there are no others 100c4b3290dSMatthias Ringwald 101c4b3290dSMatthias Ringwald // 0x0205 "VendorIDSource" 102c4b3290dSMatthias Ringwald de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_VENDOR_ID_SOURCE); 103c4b3290dSMatthias Ringwald de_add_number(service, DE_UINT, DE_SIZE_16, vendor_id_source); 104c4b3290dSMatthias Ringwald } 105