adafruit / Adafruit_nRF52_Arduino

Adafruit code for the Nordic nRF52 BLE SoC on Arduino
Other
606 stars 492 forks source link

GATT notify blocks unnesessarily (same as #665) #691

Closed eugeneanikin closed 2 years ago

eugeneanikin commented 2 years ago

Operating System

MacOS

IDE version

Arduino 1.8.15

Board

Feather nrf52840

BSP version

github latest

Sketch

Bluefruit52/examples/Periferal/hid_mouse replace the loop with this:

void loop() { static uint32_t timestamp = 0; if ((millis() - timestamp) < 20) { return; }

timestamp = millis();

blehid.mouseMove(0, 0);

if ((millis() - timestamp) > 10) {
    ledOn(LED_RED);
} else {
    ledOff(LED_RED);
} 

}

What happened ?

Pair it with a computer or an iPad. Notice that red LED lights up - mouseMove() takes more than 10ms! Really? Now try changing hvn_qsize to 2 in bluefruit.cpp:163. mouseMove() is now instant. IMO some notify buffering should be no harm to anyone...

How to reproduce ?

see above

Debug Log

No response

Screenshots

No response

hathach commented 2 years ago

thank for raising the issue, however allocating more buffer for speed is application dependent and bluefruit stack shouldn't try to do it by its own. If you want you could use configPrphConn() to set the HVN size to any values that you see fit. 1 is default value that fit most of the user need.