spp_server.c (5c51cbf6cdcfb0e60ae824cf096ff284e6909e75) | spp_server.c (6e46b7411f30c40b7603749c02f051634c6af1ca) |
---|---|
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 |
56static const char * spp_server_default_sdp_service_name = "SPP"; 57 |
|
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); --- 56 unchanged lines hidden (view full) --- 120 de_add_number(sppProfile, DE_UUID, DE_SIZE_16, BLUETOOTH_SERVICE_CLASS_SERIAL_PORT); 121 de_add_number(sppProfile, DE_UINT, DE_SIZE_16, 0x0102); 122 } 123 de_pop_sequence(attribute, sppProfile); 124 } 125 de_pop_sequence(service, attribute); 126 127 // 0x0100 "ServiceName" | 58static 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){ 59 60 uint8_t* attribute; 61 de_create_sequence(service); 62 63 // 0x0000 "Service Record Handle" 64 de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_RECORD_HANDLE); 65 de_add_number(service, DE_UINT, DE_SIZE_32, service_record_handle); --- 56 unchanged lines hidden (view full) --- 122 de_add_number(sppProfile, DE_UUID, DE_SIZE_16, BLUETOOTH_SERVICE_CLASS_SERIAL_PORT); 123 de_add_number(sppProfile, DE_UINT, DE_SIZE_16, 0x0102); 124 } 125 de_pop_sequence(attribute, sppProfile); 126 } 127 de_pop_sequence(service, attribute); 128 129 // 0x0100 "ServiceName" |
128 de_add_number(service, DE_UINT, DE_SIZE_16, 0x0100); 129 de_add_data(service, DE_STRING, (uint16_t) strlen(name), (uint8_t *) name); | 130 if (name == NULL){ 131 name = spp_server_default_sdp_service_name; 132 } 133 if (strlen(name) > 0){ 134 de_add_number(service, DE_UINT, DE_SIZE_16, 0x0100); 135 de_add_data(service, DE_STRING, (uint16_t) strlen(name), (uint8_t *) name); 136 } |
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} | 137} 138 139void spp_create_sdp_record(uint8_t *service, uint32_t service_record_handle, int rfcomm_channel, const char *name){ 140 spp_create_sdp_record_internal(service, service_record_handle, NULL, rfcomm_channel, name); 141} 142 143void spp_create_custom_sdp_record(uint8_t *service, uint32_t service_record_handle, const uint8_t * service_uuid128, int rfcomm_channel, const char *name){ 144 spp_create_sdp_record_internal(service, service_record_handle, service_uuid128, rfcomm_channel, name); 145} |