From 3ce3a4ebf36665ae721baa69967ec5d15af9f6ce Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Mon, 24 Jul 2017 11:53:29 +0200 Subject: [PATCH] btstack_uart_block: allow to 'unset' a callback by setting it to NULL. Update code for freertos and embedded to implement this --- platform/embedded/btstack_uart_block_embedded.c | 12 +++++++++--- platform/freertos/btstack_uart_block_freertos.c | 8 ++++++-- src/btstack_uart_block.h | 4 ++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/platform/embedded/btstack_uart_block_embedded.c b/platform/embedded/btstack_uart_block_embedded.c index 9c84a0c27..52c5bccf3 100644 --- a/platform/embedded/btstack_uart_block_embedded.c +++ b/platform/embedded/btstack_uart_block_embedded.c @@ -92,15 +92,21 @@ static void btstack_uart_embedded_process(btstack_data_source_t *ds, btstack_dat case DATA_SOURCE_CALLBACK_POLL: if (send_complete){ send_complete = 0; - block_sent(); + if (block_sent){ + block_sent(); + } } if (receive_complete){ receive_complete = 0; - block_received(); + if (block_received){ + block_received(); + } } if (wakeup_event){ wakeup_event = 0; - wakeup_handler(); + if (wakeup_handler){ + wakeup_handler(); + } } break; default: diff --git a/platform/freertos/btstack_uart_block_freertos.c b/platform/freertos/btstack_uart_block_freertos.c index 9a5239d5b..ba8d220be 100644 --- a/platform/freertos/btstack_uart_block_freertos.c +++ b/platform/freertos/btstack_uart_block_freertos.c @@ -86,11 +86,15 @@ static void btstack_uart_block_freertos_process(btstack_data_source_t *ds, btsta case DATA_SOURCE_CALLBACK_POLL: if (send_complete){ send_complete = 0; - block_sent(); + if (block_sent){ + block_sent(); + } } if (receive_complete){ receive_complete = 0; - block_received(); + if (block_received){ + block_received(); + } } break; default: diff --git a/src/btstack_uart_block.h b/src/btstack_uart_block.h index f13cd4353..2797b5d58 100644 --- a/src/btstack_uart_block.h +++ b/src/btstack_uart_block.h @@ -86,12 +86,12 @@ typedef struct { int (*close)(void); /** - * set callback for block received + * set callback for block received. NULL disables callback */ void (*set_block_received)(void (*block_handler)(void)); /** - * set callback for sent + * set callback for sent. NULL disables callback */ void (*set_block_sent)(void (*block_handler)(void));