-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Remote.name() doesn't work on Technic hub #432
Comments
Sending messages to LWP3 devices is currently very buggy. Also see #417. As a workaround, you can try adding SPIKE Prime works since it is using write with response instead of write without response. But I haven't had any luck yet making the same change to the City/Technic hubs. |
Thanks for the insight! That explains some of my other observations too. Adding delays up to 2000 ms didn't fix it though.. |
This modifies the pbdrv_bluetooth_write_remote() function in the CC2640 driver to use write with response instead of write without response. This ensures that the remote device received the message before the task ends. This fixes issues like messages at the end of a MicroPython program not being sent before the remote device is disconnected when the program ends. After this commit, connecting to a Handset fails with RuntimeError. This is expected due to a separate bug where remote_lwp3_char_handle is being overwritten (and actually shows that one of the error paths is working correctly). Issue: pybricks/support#432
This should be fixed on the City and Technic hubs now. I still need to make similar changes on Move hub. @NStrijbosch could you test and see if the Mario hack is still needed? The fixes for this may have fixed that too. That is, delete this and see what happens: // 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 = 0x0012;
} |
Yes, this specific bug is fixed now! On the other hand mario does have issues connecting with this update. I will investigate further! |
If Mario is raising a RutimeError during connection, it could be that we are getting a diff --git a/lib/pbio/drv/bluetooth/bluetooth_stm32_cc2640.c b/lib/pbio/drv/bluetooth/bluetooth_stm32_cc2640.c
index 92095995..6f94603a 100644
--- a/lib/pbio/drv/bluetooth/bluetooth_stm32_cc2640.c
+++ b/lib/pbio/drv/bluetooth/bluetooth_stm32_cc2640.c
@@ -554,6 +554,13 @@ try_again:
HCI_StatusCodes_t status;
(payload = get_vendor_event(remote_handle, &event, &status)) && ({
if (event == ATT_EVENT_ERROR_RSP && payload[0] == ATT_READ_BY_TYPE_REQ) {
+ // 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 = 0x0012;
+ goto retry;
+ }
+
task->status = PBIO_ERROR_FAILED;
goto disconnect;
}
@@ -577,12 +584,6 @@ try_again:
});
});
- // 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 = 0x0012;
- }
-
// enable notifications
retry: |
Fix for Move hub has been committed. We can start a new issue for the Mario regression. |
Describe the bug
When running the sample script: https://docs.pybricks.com/en/latest/pupdevices/remote.html#changing-the-name-of-the-remote using the Technic hub the remote name is not printed (line 7) and the internal name in the remote is not changed.
To reproduce
Steps to reproduce the behavior:
Expected behavior
I expected the name to be printed and the internal name in the remote to be changed. On the PrimeHub this expected behaviour was obtained.
The text was updated successfully, but these errors were encountered: