diff --git a/src/classic/spp_server.c b/src/classic/spp_server.c index 26b71e67f..2f4be8d73 100644 --- a/src/classic/spp_server.c +++ b/src/classic/spp_server.c @@ -53,7 +53,7 @@ #include "classic/core.h" #include "classic/sdp_util.h" -void spp_create_sdp_record(uint8_t *service, uint32_t service_record_handle, int rfcomm_channel, const char *name){ +static 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){ uint8_t* attribute; de_create_sequence(service); @@ -66,7 +66,11 @@ void spp_create_sdp_record(uint8_t *service, uint32_t service_record_handle, int de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST); attribute = de_push_sequence(service); { - de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_SERVICE_CLASS_SERIAL_PORT ); + if (service_uuid128 == NULL){ + de_add_number(attribute, DE_UUID, DE_SIZE_16, BLUETOOTH_SERVICE_CLASS_SERIAL_PORT ); + } else { + de_add_uuid128(attribute, (uint8_t *) service_uuid128); + } } de_pop_sequence(service, attribute); @@ -124,3 +128,11 @@ void spp_create_sdp_record(uint8_t *service, uint32_t service_record_handle, int de_add_number(service, DE_UINT, DE_SIZE_16, 0x0100); de_add_data(service, DE_STRING, strlen(name), (uint8_t *) name); } + +void spp_create_sdp_record(uint8_t *service, uint32_t service_record_handle, int rfcomm_channel, const char *name){ + spp_create_sdp_record_internal(service, service_record_handle, NULL, rfcomm_channel, name); +} + +void spp_create_custom_sdp_record(uint8_t *service, uint32_t service_record_handle, const uint8_t * service_uuid128, int rfcomm_channel, const char *name){ + spp_create_sdp_record_internal(service, service_record_handle, service_uuid128, rfcomm_channel, name); +} diff --git a/src/classic/spp_server.h b/src/classic/spp_server.h index a27410eca..695b10a33 100644 --- a/src/classic/spp_server.h +++ b/src/classic/spp_server.h @@ -53,7 +53,7 @@ extern "C" { /* API_START */ /** - * @brief Create SDP record for SPP service + * @brief Create SDP record for SPP service with official SPP Service Class * @param service buffer - needs to large enough * @param service_record_handle * @param rfcomm_channel @@ -61,6 +61,16 @@ extern "C" { */ void spp_create_sdp_record(uint8_t *service, uint32_t service_record_handle, int rfcomm_channel, const char *name); +/** + * @brief Create SDP record for SPP service with custom service UUID (e.g. for use with Android) + * @param service buffer - needs to large enough + * @param service_record_handle + * @param service_uuid128 buffer + * @param rfcomm_channel + * @param name + */ +void spp_create_custom_sdp_record(uint8_t *service, uint32_t service_record_handle, const uint8_t * service_uuid128, int rfcomm_channel, const char *name); + /* API_END */ #if defined __cplusplus