summaryrefslogtreecommitdiffstatshomepage
path: root/extmod/btstack/btstack_hci_uart.c
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2020-08-18 11:05:34 +1000
committerDamien George <damien@micropython.org>2020-09-08 12:53:24 +1000
commit99a29ec705b463290d5a2ac1eabc46fb7f2a83b0 (patch)
tree13918c236f68fea9de4425169877a9b932c4c4e2 /extmod/btstack/btstack_hci_uart.c
parent6077c63a450d7c2ab5e31e5845ecb5f1a4634b26 (diff)
downloadmicropython-99a29ec705b463290d5a2ac1eabc46fb7f2a83b0.tar.gz
micropython-99a29ec705b463290d5a2ac1eabc46fb7f2a83b0.zip
extmod/btstack: Detect HCI UART init failure.
Diffstat (limited to 'extmod/btstack/btstack_hci_uart.c')
-rw-r--r--extmod/btstack/btstack_hci_uart.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/extmod/btstack/btstack_hci_uart.c b/extmod/btstack/btstack_hci_uart.c
index 5c96e02dc0..ae18628a9c 100644
--- a/extmod/btstack/btstack_hci_uart.c
+++ b/extmod/btstack/btstack_hci_uart.c
@@ -50,6 +50,7 @@ STATIC uint8_t *recv_buf;
STATIC size_t recv_len;
STATIC size_t recv_idx;
STATIC void (*recv_handler)(void);
+STATIC bool init_success = false;
STATIC int btstack_uart_init(const btstack_uart_config_t *uart_config) {
(void)uart_config;
@@ -62,14 +63,21 @@ STATIC int btstack_uart_init(const btstack_uart_config_t *uart_config) {
// Set up the UART peripheral, attach IRQ and power up the HCI controller.
// We haven't been told the baud rate yet, so defer that until btstack_uart_set_baudrate.
- mp_bluetooth_hci_uart_init(MICROPY_HW_BLE_UART_ID, 0);
- mp_bluetooth_hci_controller_init();
+ if (mp_bluetooth_hci_uart_init(MICROPY_HW_BLE_UART_ID, 0)) {
+ init_success = false;
+ return -1;
+ }
+ if (mp_bluetooth_hci_controller_init()) {
+ init_success = false;
+ return -1;
+ }
+ init_success = true;
return 0;
}
STATIC int btstack_uart_open(void) {
- return 0;
+ return init_success ? 0 : 1;
}
STATIC int btstack_uart_close(void) {