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