From 1235b35f148900db131bf946e54a383d2fca6460 Mon Sep 17 00:00:00 2001 From: NStrijbosch Date: Sun, 8 Aug 2021 16:59:35 +0200 Subject: [PATCH] drv/bluetooth: hard code char_handle for Mario hub characteristics handle of LEGO Mario are not properly found by GATT_DiscCharsByUUID() remote_lwp3_char_handle for mario is hard coded for now --- .../drv/bluetooth/bluetooth_stm32_bluenrg.c | 18 ++++++++++----- .../drv/bluetooth/bluetooth_stm32_cc2640.c | 22 ++++++++++++------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/lib/pbio/drv/bluetooth/bluetooth_stm32_bluenrg.c b/lib/pbio/drv/bluetooth/bluetooth_stm32_bluenrg.c index 1bae15650..57b5b0f46 100644 --- a/lib/pbio/drv/bluetooth/bluetooth_stm32_bluenrg.c +++ b/lib/pbio/drv/bluetooth/bluetooth_stm32_bluenrg.c @@ -470,12 +470,18 @@ static PT_THREAD(scan_and_connect_task(struct pt *pt, pbio_task_t *task)) { PT_WAIT_UNTIL(pt, hci_command_status); context->status = aci_gatt_disc_charac_by_uuid_end(); - PT_WAIT_UNTIL(pt, { - if (task->cancel) { - goto cancel_disconnect; - } - remote_lwp3_char_handle; - }); + // HACK: Characteristics of LEGO Mario are not properly found by aci_gatt_disc_charac_by_uuid_begin(). + // remote_lwp3_char_handle for mario is hard coded for now + if (context->hub_kind == LWP3_HUB_KIND_MARIO) { + remote_lwp3_char_handle = 0x0011; + } else { + PT_WAIT_UNTIL(pt, { + if (task->cancel) { + goto cancel_disconnect; + } + remote_lwp3_char_handle; + }); + } // enable notifications diff --git a/lib/pbio/drv/bluetooth/bluetooth_stm32_cc2640.c b/lib/pbio/drv/bluetooth/bluetooth_stm32_cc2640.c index d259a8f31..a8fde3cd1 100644 --- a/lib/pbio/drv/bluetooth/bluetooth_stm32_cc2640.c +++ b/lib/pbio/drv/bluetooth/bluetooth_stm32_cc2640.c @@ -494,14 +494,20 @@ static PT_THREAD(scan_and_connect_task(struct pt *pt, pbio_task_t *task)) { context->status = read_buf[8]; // debug - // Assuming that we only ever get successful ATT_ReadByTypeRsp and failed - // ATT_ReadByTypeRsp or ATT_ErrorRsp. - PT_WAIT_UNTIL(pt, { - if (task->cancel) { - goto cancel_disconnect; - } - remote_lwp3_char_handle != NO_CONNECTION; - }); + // HACK: Characteristics of LEGO Mario are not properly found by GATT_DiscCharsByUUID(). + // remote_lwp3_char_handle for mario is hard coded for now + if (context->hub_kind == LWP3_HUB_KIND_MARIO) { + remote_lwp3_char_handle = 0x0011; + } else { + // Assuming that we only ever get successful ATT_ReadByTypeRsp and failed + // ATT_ReadByTypeRsp or ATT_ErrorRsp. + PT_WAIT_UNTIL(pt, { + if (task->cancel) { + goto cancel_disconnect; + } + remote_lwp3_char_handle != NO_CONNECTION; + }); + } // enable notifications