- Saved searches
- Use saved searches to filter your results more quickly
- License
- kind3r/esp32-ble-gateway
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- Arduino.ru
- Возможна ли одновременная работа WiFi и Bluetooch на ESP32
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
WiFi to BLE gateway on ESP32
License
kind3r/esp32-ble-gateway
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
WiFi to BLE (Bluetooth Low Energy) gateway on ESP32 using a modified version of Noble’s WebSocket protocol. The modifications consist in an added authentication layer upon connection and some extra payloads here and there. It’s designed to be used with ttlock-sdk-js at least until I will find the time to document the API and implement a separate Noble binding. Note that data flows is via standard unencrypted websocket as the ESP can barely handle the memory requirements for BLE, WiFi and WebSocket at the same time and besides gateway is supposed to be in your LAN and the BLE traffic can be easilly sniffed over the air so there isn’t really a point in encrypting all communication at this time.
Note: this has nothing to do with the TTLock G2 official gateway, it is basically just a GATT proxy over WiFi.
Feeling generous and want to support my work, here is my PayPal link.
- WiFi init with AP style configuration via HTTPS web page
- Websocket communication and AES 128 CBC auth
- Start/stop BLE scan
- Discover devices
- Read characteristics
- Write characteristics
- Subscribe to characteristic
This short guide explains how to install the gateway and configure the TTLock Home Assistant addon so that you can interface it with a TTLock lock. You need to compile and upload the binary yourself, there is no pre-compiled version but the process should be fairly easy even for beginers.
- Visual Studio Code (VSCode) and PlatformIO extension.
- A clone of this repository
- A working ESP32-WROVER board
- Some type of TTLock lock paired to a working Home Assistant installation with TTLock Home Assistant addon
Open the cloned repo in VSCode and PlatformIO should automatically install all the required dependencies (it will take a couple of minutes, depending on your computer and internet speed, be patient and let it settle). You need to modify sdkconfig.h located in .platformio/packages/framework-arduinoespressif32/tools/sdk/include/config and change CONFIG_ARDUINO_LOOP_STACK_SIZE to 10240 . This is because the HTTPS certificate generation takes more stack space.
At the moment, the project is only configured to work on ESP32-WROVER boards. If you have a different board, you need to edit the platformio.ini file and create your own env configuration. As of this writing the code takes about 1.5Mb so I’m using the min_spiffs.csv partition scheme in order to be able to hopefully do OTA in the future.
Connect your ESP32 to the PC, go to PlatformIO menu (the alien head on the VSCode’s left toolbar, where you have files, search, plugins etc.) then in Project Tasks choose env:esp-wrover -> Platform -> Upload Filesystem Imager. This will ‘format’ the storage and upload the web UI.
Next, you need to build and upload the main code. In Project Tasks choose env:esp-wrover -> General -> Upload and Monitor. This should start the build process and once it is finished the compiled result will be uploaded to the ESP32.
Once the upload finishes you should start seeing some debug output, including the status of the WiFi AP and HTTPS certificate generation status (it will take quite some time so be patient). After the startup is completed, you can connect to ESP’s AP named ESP32GW with password 87654321 and access https://esp32gw.local. The browser will complain about the self-signed certificate but you can ignore and continue. The default username and password are admin/admin. Configure your wifi credentials and copy the AES Key which you need to setup in the TTLock Home Assistant addon.
After saving the new configuration, the ESP will reboot, connect to your WiFi and output it’s IP address on the serial port (it will also generate a new HTTPS certificate if you changed it’s name). It will also be accessible via esp32gw.local (or the new name you gave it) via MDNS if this service is working in your network. You can still make configuration changes by accessing it’s IP address in the browser.
Once you have the ESP running the gateway software, go to the TTLock Home Assistant addon configuration options and add the following:
gateway: noble gateway_host: IP_ADDRESS_OF_YOUR_ESP gateway_port: 8080 gateway_key: AES_KEY_FROM_ESP_CONFIG gateway_user: admin gateway_pass: admin
The user and password are hardcoded to admin/admin for the moment and so is the port. You will only need to update the IP address of the ESP gateway and the AES key you generated.
For extra debug info, you can add the gateway_debug: true option to log all communication to and from the gateway in Home Assistant.
If everything was done correctly you should now be able to use the addon using the ESP32 device as a BLE gateway.
- check if multiple connections to multiple devices are possible ( BLEDevice::createClient seems to store only 1 BLEClient , but we could just create the client ourselves)
- Service UUID filtering for scan and allow/disallow duplicates
- Timeout for non-authenticated connections
- Investigate unstable wifi (sometimes it connects but there is no traffic; try to ping gw during setup)
- Optimize memory fragmentation
- device discovery is always sent to all authenticated clients
- give each device a unique ID (peripheralUuid) and store ID, address and address type in a Map as it is required for connection
- connection is done based on peripheralUuid translated to address and type in the noble_api
- always stop scanning before connecting to a device
- only one client can connect to a device at a time so associate websocket with connection and cleanup on disconnect
Arduino.ru
Возможна ли одновременная работа WiFi и Bluetooch на ESP32
Приветствую всех. Может кто то уже делал такой симбиоз? Задача стоит принять от BLE 16 байт и обработав отправить по Wifi в сеть. Или железяка не сможет этого? Так сказать котлеты отдельно, мухи отдельно.
Возможна, а форуме уже было, надо выбрать в arduino ide нужную плату, но места для скетча остаётся мало в любом случае. Воспользуйтесь поиском в интернете.
Только надо учитывать, что антенна для обоих интерфейсов используется одна и та же, поэтому возможны всякие неожиданные таймауты.
Да удалось спасибо вам за наводку. Вот сейчас и возник вопрос по одновременной работе. Andicat прав памяти не хватает. Перебор на 8%. Andicat, а не подскажете какую надо плату выбрать в IDE чтобы скомпилить и всё влезло?
Отключи OTA и файловую систему.
Приветствую всех форумчан. Респект нашим китайским друзьям. Всё получилось, даже сам не ожидал. Не пришлось ни чего отключать. В одном скетче одновременно работает
1. WiFi сеть, UDP протокол 2.BLE сканер (читает показания весов) 3.Обновление по воздуху(OTA) 4.Настройка устройства через WEB морду 5.Вывод показаний на дисплей (i2c) 6.RFID считыватель PN532 NFC 7.Купюрник и монетник (по прерыванию работают). 8. Подключение к роутеру через собственную точку доступа. И весь этот микс тянет ESP32, при этом без каких либо видимых тормозов. Нашел библиотеки, которые заняли очень мало места. Памяти остается ещё достаточно, чтобы ещё что то впихнуть. Так что благодарю всех, кто давал советы, и писал качественные и без глючные библы. Ну и конечно производителей железа.