spp_server.c (e501bae08349e058caa4648e0af3dd01cbd89d20) | spp_server.c (ec818a285cac0b16a0d9d9cbd32a15fe2cb1b33c) |
---|---|
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 --- 39 unchanged lines hidden (view full) --- 48#include <string.h> 49 50#include "bluetooth.h" 51#include "bluetooth_sdp.h" 52#include "btstack_config.h" 53#include "classic/core.h" 54#include "classic/sdp_util.h" 55 | 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 --- 39 unchanged lines hidden (view full) --- 48#include <string.h> 49 50#include "bluetooth.h" 51#include "bluetooth_sdp.h" 52#include "btstack_config.h" 53#include "classic/core.h" 54#include "classic/sdp_util.h" 55 |
56void spp_create_sdp_record(uint8_t *service, uint32_t service_record_handle, int rfcomm_channel, const char *name){ | 56static void spp_create_sdp_record_internal(uint8_t *service, uint32_t service_record_handle, const uint8_t * service_uuid128, int rfcomm_channel, const char *name){ |
57 58 uint8_t* attribute; 59 de_create_sequence(service); 60 61 // 0x0000 "Service Record Handle" 62 de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_RECORD_HANDLE); 63 de_add_number(service, DE_UINT, DE_SIZE_32, service_record_handle); 64 65 // 0x0001 "Service Class ID List" 66 de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST); 67 attribute = de_push_sequence(service); 68 { | 57 58 uint8_t* attribute; 59 de_create_sequence(service); 60 61 // 0x0000 "Service Record Handle" 62 de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_RECORD_HANDLE); 63 de_add_number(service, DE_UINT, DE_SIZE_32, service_record_handle); 64 65 // 0x0001 "Service Class ID List" 66 de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST); 67 attribute = de_push_sequence(service); 68 { |
69 de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_SERVICE_CLASS_SERIAL_PORT ); | 69 if (service_uuid128 == NULL){ 70 de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_SERVICE_CLASS_SERIAL_PORT ); 71 } else { 72 de_add_uuid128(attribute, (uint8_t *) service_uuid128); 73 } |
70 } 71 de_pop_sequence(service, attribute); 72 73 // 0x0004 "Protocol Descriptor List" 74 de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST); 75 attribute = de_push_sequence(service); 76 { 77 uint8_t* l2cpProtocol = de_push_sequence(attribute); --- 41 unchanged lines hidden (view full) --- 119 de_pop_sequence(attribute, sppProfile); 120 } 121 de_pop_sequence(service, attribute); 122 123 // 0x0100 "ServiceName" 124 de_add_number(service, DE_UINT, DE_SIZE_16, 0x0100); 125 de_add_data(service, DE_STRING, strlen(name), (uint8_t *) name); 126} | 74 } 75 de_pop_sequence(service, attribute); 76 77 // 0x0004 "Protocol Descriptor List" 78 de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST); 79 attribute = de_push_sequence(service); 80 { 81 uint8_t* l2cpProtocol = de_push_sequence(attribute); --- 41 unchanged lines hidden (view full) --- 123 de_pop_sequence(attribute, sppProfile); 124 } 125 de_pop_sequence(service, attribute); 126 127 // 0x0100 "ServiceName" 128 de_add_number(service, DE_UINT, DE_SIZE_16, 0x0100); 129 de_add_data(service, DE_STRING, strlen(name), (uint8_t *) name); 130} |
131 132void spp_create_sdp_record(uint8_t *service, uint32_t service_record_handle, int rfcomm_channel, const char *name){ 133 spp_create_sdp_record_internal(service, service_record_handle, NULL, rfcomm_channel, name); 134} 135 136void spp_create_custom_sdp_record(uint8_t *service, uint32_t service_record_handle, const uint8_t * service_uuid128, int rfcomm_channel, const char *name){ 137 spp_create_sdp_record_internal(service, service_record_handle, service_uuid128, rfcomm_channel, name); 138} |
|