From e1f5c41c6d44c1753089155b92bab66644612883 Mon Sep 17 00:00:00 2001 From: Adam Greenwood-Byrne Date: Tue, 11 Aug 2020 09:09:13 +0100 Subject: [PATCH] Fixed connection timing issue --- part7-bluetooth/bt.c | 5 +++-- part7-bluetooth/bt.h | 1 + part7-bluetooth/kernel.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/part7-bluetooth/bt.c b/part7-bluetooth/bt.c index ef2acfd..b494df0 100644 --- a/part7-bluetooth/bt.c +++ b/part7-bluetooth/bt.c @@ -262,8 +262,9 @@ void startActiveScanning() { unsigned int p = BleScanInterval / BleScanDivisor; unsigned int q = BleScanWindow / BleScanDivisor; - setLEwhitelist(); - setLEscanparameters(LL_SCAN_ACTIVE, lo(p), hi(p), lo(q), hi(q), 0, 1); + //setLEwhitelist(); + //setLEscanparameters(LL_SCAN_ACTIVE, lo(p), hi(p), lo(q), hi(q), 0, 1); + setLEscanparameters(LL_SCAN_ACTIVE, lo(p), hi(p), lo(q), hi(q), 0, 0); setLEscanenable(1, 0); } diff --git a/part7-bluetooth/bt.h b/part7-bluetooth/bt.h index f364a3d..f11e2d6 100644 --- a/part7-bluetooth/bt.h +++ b/part7-bluetooth/bt.h @@ -11,3 +11,4 @@ void startActiveScanning(); void stopScanning(); void startActiveAdvertising(); void connect(unsigned char *addr); +void bt_flushrx(); diff --git a/part7-bluetooth/kernel.c b/part7-bluetooth/kernel.c index 7a5acca..65428ad 100644 --- a/part7-bluetooth/kernel.c +++ b/part7-bluetooth/kernel.c @@ -171,9 +171,9 @@ void main() startActiveScanning(); uart_writeText("Waiting for echo: "); while (!(got_echo_sid && got_echo_name)) bt_search(); + stopScanning(); for (int c=0;c<=5;c++) uart_byte(echo_addr[c]); uart_writeText("\n"); - stopScanning(); // Ask to connect to the echo uart_writeText("Connecting to echo: ");