From 22d58ff8de23f4f8df27e78fade3aa864f1db00c Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Mon, 11 Nov 2024 22:55:02 +0100 Subject: [PATCH] sdp_server: add sdp_server_set_single_record_response --- src/classic/sdp_server.c | 18 ++++++++++++++++-- src/classic/sdp_server.h | 4 ++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/classic/sdp_server.c b/src/classic/sdp_server.c index 3943aef09..81abd3339 100644 --- a/src/classic/sdp_server.c +++ b/src/classic/sdp_server.c @@ -84,6 +84,10 @@ static uint16_t sdp_server_response_size; static uint16_t sdp_server_l2cap_waiting_list_cids[SDP_WAITING_LIST_MAX_COUNT]; static int sdp_server_l2cap_waiting_list_count; +#ifdef ENABLE_TESTING_SUPPORT +static bool sdp_server_testing_single_record_reponse = false; +#endif + void sdp_init(void){ sdp_server_next_service_record_handle = ((uint32_t) MAX_RESERVED_SERVICE_RECORD_HANDLE) + 2; // register with l2cap psm sevices - max MTU @@ -205,7 +209,12 @@ int sdp_handle_service_search_request(uint8_t * packet, uint16_t remote_mtu){ // calc maximumServiceRecordCount based on remote MTU uint16_t maxNrServiceRecordsPerResponse = (remote_mtu - (9+3))/4; - +#ifdef ENABLE_TESTING_SUPPORT + if (sdp_server_testing_single_record_reponse){ + maxNrServiceRecordsPerResponse = 1; + } +#endif + // continuation state contains index of next service record to examine int continuation = 0; uint16_t continuation_index = 0; @@ -299,7 +308,7 @@ int sdp_handle_service_attribute_request(uint8_t * packet, uint16_t remote_mtu){ if (maximumAttributeByteCount2 < maximumAttributeByteCount) { maximumAttributeByteCount = maximumAttributeByteCount2; } - + // continuation state contains the offset into the complete response uint16_t continuation_offset = 0; if (continuationState[0] == 2){ @@ -632,3 +641,8 @@ static void sdp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *p } } +#ifdef ENABLE_TESTING_SUPPORT +void sdp_server_set_single_record_response(bool enable){ + sdp_server_testing_single_record_reponse = enable; +} +#endif \ No newline at end of file diff --git a/src/classic/sdp_server.h b/src/classic/sdp_server.h index 316359db8..1b24b9503 100644 --- a/src/classic/sdp_server.h +++ b/src/classic/sdp_server.h @@ -111,6 +111,10 @@ void sdp_deinit(void); /* API_END */ +#ifdef ENABLE_TESTING_SUPPORT +void sdp_server_set_single_record_response(bool enabled); +#endif + #if defined __cplusplus }