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
ESP32 Bluetooth Classic (BT) support #428
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add possibility to define the device name of the ESP32 BLE device
When running Blynk in direct mode (using Bluetooth/BLE), the connection can stop working after "Packet too big" or "Invalid header type". The cause is the loss of one or more bytes, which makes the Blynk protocol get out of sync, resulting in a connection being closed. However, it is not necessary to stop the connection, it just needs to resync. Because the Blynk protocol misses sync bytes, it should be done in another way. In this solution, it makes use of the fact that Blynk on BT/BLE is sending its bytes in block, starting with the header. So, in case the systen is no longer synced, we just need to flush the buffer to get it in sync again. Using this fix, the stability of BLE in Blynk increases a lot. Because conn.flush() doesn't exist, we make use of the fact that conn.connect() is basically executing a buffer flush.
flush in direct mode instead of reconnecting
Flushing buffer in direct mode (BLE)
User defined ESP32 BLE Device name
Update with blynkkk master
Use of old values ESP_PWR_LVL_N2, ESP_PWR_LVL_P7 for backward compatibility, they are also available in new IDF code
teejaydub
pushed a commit
to teejaydub/blynk-library
that referenced
this pull request
Jan 26, 2023
* User defined ESP32 BLE Device name Add possibility to define the device name of the ESP32 BLE device * name BLE_DEVICE_NAME to be consistent with other BLE's * Flushing buffer in direct mode When running Blynk in direct mode (using Bluetooth/BLE), the connection can stop working after "Packet too big" or "Invalid header type". The cause is the loss of one or more bytes, which makes the Blynk protocol get out of sync, resulting in a connection being closed. However, it is not necessary to stop the connection, it just needs to resync. Because the Blynk protocol misses sync bytes, it should be done in another way. In this solution, it makes use of the fact that Blynk on BT/BLE is sending its bytes in block, starting with the header. So, in case the systen is no longer synced, we just need to flush the buffer to get it in sync again. Using this fix, the stability of BLE in Blynk increases a lot. Because conn.flush() doesn't exist, we make use of the fact that conn.connect() is basically executing a buffer flush. * Update BlynkProtocol.h flush in direct mode instead of reconnecting * update naar blynk lib * Initial ESP32 BT classic support * ESP32 BT classic example * Update BlynkProtocol.h * use old values ESP_PWR_LVL_N2, ESP_PWR_LVL_P7 Use of old values ESP_PWR_LVL_N2, ESP_PWR_LVL_P7 for backward compatibility, they are also available in new IDF code
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Add support for Bluetooth (classic, BT) on ESP32 (Android only).
This need an up-to-date ESP32 library, if not it will not compile.
I did not make use of BluetoothSerial, due to the lack of onConnect, onDisconnect and Txpower functionality. By handling connect/disconnect nicely, Blynk always keeps working perfectly without sync-problems when going out-of-range and coming back. Remark that this needs Android app 2.26.7, as in 2.26.6 there is a bug in the Bluetooth implementation (I checked with a development version, in which Bluetooth issues are solved).