raspberrypi / pico-sdk

BSD 3-Clause "New" or "Revised" License
3.78k stars 950 forks source link

Bluetooth LE connectable unidirected advertisements' long intervals unreliable #1674

Open matsobdev opened 8 months ago

matsobdev commented 8 months ago

Values greater than approx. 100 ms are unreliable for connectable unidirected advertisements, ex. 150 ms equals more likely to 800 ms, 1280 ms - 6500 ms (with high variations). Non-connectable unidirected advertisements' intervals are reliable. BTstack it is not the root of the problem. It is the same with or without it - just HCI commands written by cyw43 driver. To reproduce, just use some BTstack example, like hog_mouse_demo.c:

// setup advertisements
uint16_t adv_int_min = 0x0030;
uint16_t adv_int_max = 0x0030;
uint8_t adv_type = 0;

adv_int_min and adv_int_max are values of intervals in number of time slots (0,625 ms). Min value is 32 (0x20), max 16384 (0x4000). adv_type of 3 will switch it to non-connectable unidirected. It seems to be more likely firmware or CYW43439 ROM for Bluetooth.

peterharperuk commented 1 month ago

What exactly is unreliable? Is it the connection to the device? I do see problems pairing to a hog mouse device when these values are high (10000). But I see the same problem when using the libusb port and a USB dongle. So I guess I need convincing that this is a specific issue with cyw43 that doesn't affect other controllers. Are you wanting to modify these values to save power?

matsobdev commented 1 week ago

What is unreliable, is interval value between advertisements, when the value is set to "high" number of milliseconds. To be honest, it won't be a real world issue, maybe there is something wrong with Bluetooth firmware, I don't know. Spec allows broad range of values and just high ones doesn't seem to do what they are told to do. I see it a problem, when Pico W would be told specifically to advertise in wide intervals for whatever reason. So very edge case. Since radio is on for a short amount of time to TX and comparing to Pico W current draw, there won't be great power savings.