From cd7b9db2326a02959cf39a9b178ed39a6dfc98c9 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Tue, 29 Nov 2016 16:49:27 +0100 Subject: [PATCH 1/3] example: fix path to SBC files - avoid .o in src folder --- example/Makefile.inc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/example/Makefile.inc b/example/Makefile.inc index 1f96e3e4f..1661d64a2 100644 --- a/example/Makefile.inc +++ b/example/Makefile.inc @@ -77,15 +77,15 @@ include ${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/Makefile.inc include ${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/Makefile.inc SBC_DECODER += \ - ${BTSTACK_ROOT}/src/classic/btstack_sbc_plc.c \ - ${BTSTACK_ROOT}/src/classic/btstack_sbc_bludroid.c \ + btstack_sbc_plc.c \ + btstack_sbc_bludroid.c \ SBC_ENCODER += \ - ${BTSTACK_ROOT}/src/classic/btstack_sbc_bludroid.c \ - ${BTSTACK_ROOT}/src/classic/hfp_msbc.c \ + btstack_sbc_bludroid.c \ + hfp_msbc.c \ CVSD_PLC = \ - ${BTSTACK_ROOT}/src/classic/btstack_cvsd_plc.c \ + btstack_cvsd_plc.c \ EXAMPLES = \ From d198cb2001c71ed11c02a023a3935c0b981a0baa Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Wed, 30 Nov 2016 11:10:13 +0100 Subject: [PATCH 2/3] stdin: drop unused blocking helper functions btstack_stdin_query_int and btstack_stdin_query_hex --- platform/posix/stdin_support.c | 16 ---------------- platform/posix/stdin_support.h | 4 ---- 2 files changed, 20 deletions(-) diff --git a/platform/posix/stdin_support.c b/platform/posix/stdin_support.c index f6ce1f034..0766d6029 100644 --- a/platform/posix/stdin_support.c +++ b/platform/posix/stdin_support.c @@ -110,19 +110,3 @@ static int getstring(char *line, int size) return i; } -uint32_t btstack_stdin_query_int(const char * fieldName){ - printf("Please enter new int value for %s:\n", fieldName); - char buffer[80]; - getstring(buffer, sizeof(buffer)); - return atoi(buffer); -} - -uint32_t btstack_stdin_query_hex(const char * fieldName){ - printf("Please enter new hex value for %s:\n", fieldName); - char buffer[80]; - getstring(buffer, sizeof(buffer)); - uint32_t value; - sscanf(buffer, "%x", &value); - return value; -} - diff --git a/platform/posix/stdin_support.h b/platform/posix/stdin_support.h index ce6fdc70f..ff57ea26f 100644 --- a/platform/posix/stdin_support.h +++ b/platform/posix/stdin_support.h @@ -50,10 +50,6 @@ void btstack_stdin_setup(void (*stdin_handler)(btstack_data_source_t *_ds, btsta // gets called by main.c void btstack_stdin_reset(void); -// -uint32_t btstack_stdin_query_int(const char * fieldName); -uint32_t btstack_stdin_query_hex(const char * fieldName); - #if defined __cplusplus } #endif From a1dc4edb4302a6d76a764dd94c81931a3d4d5cfa Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Wed, 30 Nov 2016 11:29:55 +0100 Subject: [PATCH 3/3] stdin: add btstack_stdin_read() and use in examples --- example/hfp_ag_demo.c | 2 +- example/hfp_hf_demo.c | 3 ++- example/hsp_ag_demo.c | 4 ++-- example/hsp_hs_demo.c | 4 ++-- platform/posix/stdin_support.c | 11 +++++++++++ platform/posix/stdin_support.h | 3 +++ 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/example/hfp_ag_demo.c b/example/hfp_ag_demo.c index 707b6251f..902cc7ce0 100644 --- a/example/hfp_ag_demo.c +++ b/example/hfp_ag_demo.c @@ -335,7 +335,7 @@ static void show_usage(void){ } static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callback_type_t callback_type){ - read(ds->fd, &cmd, 1); + cmd = btstack_stdin_read(); switch (cmd){ case 'a': log_info("USER:\'%c\'", cmd); diff --git a/example/hfp_hf_demo.c b/example/hfp_hf_demo.c index 7592dd108..458110279 100644 --- a/example/hfp_hf_demo.c +++ b/example/hfp_hf_demo.c @@ -152,7 +152,8 @@ static void show_usage(void){ } static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callback_type_t callback_type){ - read(ds->fd, &cmd, 1); + + cmd = btstack_stdin_read(); if (cmd >= '0' && cmd <= '9'){ printf("DTMF Code: %c\n", cmd); diff --git a/example/hsp_ag_demo.c b/example/hsp_ag_demo.c index a395e8eda..8aeb22519 100644 --- a/example/hsp_ag_demo.c +++ b/example/hsp_ag_demo.c @@ -121,8 +121,8 @@ static void show_usage(void){ #ifdef HAVE_POSIX_STDIN static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callback_type_t callback_type){ - char buffer; - read(ds->fd, &buffer, 1); + + char buffer = btstack_stdin_read(); switch (buffer){ case 'c': diff --git a/example/hsp_hs_demo.c b/example/hsp_hs_demo.c index 6b01a4c24..fcdd238ae 100644 --- a/example/hsp_hs_demo.c +++ b/example/hsp_hs_demo.c @@ -121,8 +121,8 @@ static void show_usage(void){ #ifdef HAVE_POSIX_STDIN static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callback_type_t callback_type){ - char buffer; - read(ds->fd, &buffer, 1); + + char buffer = btstack_stdin_read(); switch (buffer){ case 'c': diff --git a/platform/posix/stdin_support.c b/platform/posix/stdin_support.c index 0766d6029..57c9d2743 100644 --- a/platform/posix/stdin_support.c +++ b/platform/posix/stdin_support.c @@ -37,6 +37,8 @@ #include #include +#include + #include "btstack_run_loop.h" #include @@ -89,6 +91,7 @@ void btstack_stdin_reset(void){ #endif } +#if 0 static int getstring(char *line, int size) { int i = 0; @@ -109,4 +112,12 @@ static int getstring(char *line, int size) line[i] = 0; return i; } +#endif + +// read single byte after data source callback was triggered +char btstack_stdin_read(void){ + char buffer; + read(stdin_source.fd, &buffer, 1); + return buffer; +} diff --git a/platform/posix/stdin_support.h b/platform/posix/stdin_support.h index ff57ea26f..487d0aa1b 100644 --- a/platform/posix/stdin_support.h +++ b/platform/posix/stdin_support.h @@ -47,6 +47,9 @@ extern "C" { // setup handler for command line interface void btstack_stdin_setup(void (*stdin_handler)(btstack_data_source_t *_ds, btstack_data_source_callback_type_t callback_type)); +// read single byte after data source callback was triggered +char btstack_stdin_read(void); + // gets called by main.c void btstack_stdin_reset(void);