Update BleKeyboard.cpp
Edited BleKeyboard::begin and BleKeyboard::end to be able to delete the Task when stopping BleKeyboard. I had the need for this to so I could stop ESP32-BLE-Keyboard and start AsyncWebServer.
If you create a task like this:
TaskHandle_t xHandle = NULL;
void BleKeyboard::begin(void) { xTaskCreate(this->taskServer, "server", 20000, (void *)this, 5, &xHandle); }
You will be able to delete the task using BleKeyboard.end();
void BleKeyboard::end(void) { vTaskDelete(xHandle); }
Thanks for your contribution. However, I would like to get #53 merged first and from what I recall it removes the xTaskCreate. I think with #53 merged the memory footprint will be greatly reduced and thus you should be able to run a webserver in parallel without having to end the BleKeyboard instance. The only reason I haven't merged #53 yet is that I would like startAdvertising to be called by the library internally rather than forcing the user deal with this. Maybe you can help with that? Because rousir hasn't replied.
I can at least test it for you on Mac. I reduced the STACK_SIZE to about 2500 but is still wasn't good enough. That is why I create the vTaskDelete. In my case in doesn't matter because when the AsyncWebServer is started, I do not need BLE until I restart.
I have changed the task size to 4096. 20000 was quite big. Haven't had issues since.
I also included BLE_KEYBOARD_VERSION "1.1" (Which off course can be any version number) for debugging purposes.
Thanks for the efforts and I have tested without issues on PC, Android. However, can someone suggest how to convert this to classic BT instead of BLE environment please? I am a volunteer worker teaching remote region juniors to make fun projects, To cut the story short, the facility only equipped with outdated computers (BT2.0) , no BLE.
No it can't be converted. Maybe if you work at espressif.
To Dustin Watts, thanks for posting this - it solved a problem I have been working on for a few days now.
T-vk - I would like to second Dustin Watts' request to have this change accepted.