From 995fbc838a9ecd0265a5ec3d193940bb907e5321 Mon Sep 17 00:00:00 2001 From: Jason2866 Date: Thu, 11 Feb 2021 13:53:21 +0000 Subject: [PATCH] Tasmota variant ESP32 bluetooth --- .github/workflows/CI_github_ESP32.yml | 20 ++++++++ .github/workflows/Tasmota_build.yml | 20 ++++++++ .github/workflows/Tasmota_build_master.yml | 20 ++++++++ platformio_override_sample.ini | 1 + platformio_tasmota_env32.ini | 6 +-- tasmota/tasmota_configurations_ESP32.h | 24 ++++++++++ tasmota/tasmota_template.h | 53 ++++++++++++++++++++++ tasmota/xdrv_85_esp32_bluetooth.ino | 28 ++++++++++++ 8 files changed, 169 insertions(+), 3 deletions(-) create mode 100644 tasmota/xdrv_85_esp32_bluetooth.ino diff --git a/.github/workflows/CI_github_ESP32.yml b/.github/workflows/CI_github_ESP32.yml index 0c2b75709..e3d26ef19 100644 --- a/.github/workflows/CI_github_ESP32.yml +++ b/.github/workflows/CI_github_ESP32.yml @@ -84,6 +84,26 @@ jobs: name: firmware path: ./build_output + tasmota32-bluetooth: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -U platformio + platformio upgrade --dev + platformio update + - name: Run PlatformIO + run: | + platformio run -e tasmota32-bluetooth + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output + tasmota32-minimal: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/Tasmota_build.yml b/.github/workflows/Tasmota_build.yml index 368c9e767..b707b68a3 100644 --- a/.github/workflows/Tasmota_build.yml +++ b/.github/workflows/Tasmota_build.yml @@ -824,6 +824,26 @@ jobs: path: ./build_output + tasmota32-bluetooth: + needs: tasmota_pull + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + pip install -U platformio + - name: Run PlatformIO + run: | + platformio run -e tasmota32-bluetooth + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output + + tasmota32-knx: needs: tasmota_pull runs-on: ubuntu-latest diff --git a/.github/workflows/Tasmota_build_master.yml b/.github/workflows/Tasmota_build_master.yml index a9b958f53..a6a1b668c 100644 --- a/.github/workflows/Tasmota_build_master.yml +++ b/.github/workflows/Tasmota_build_master.yml @@ -824,6 +824,26 @@ jobs: path: ./build_output + tasmota32-bluetooth: + needs: tasmota_pull + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/checkout@v1 + - name: Set up Python + uses: actions/setup-python@v1 + - name: Install dependencies + run: | + pip install -U platformio + - name: Run PlatformIO + run: | + platformio run -e tasmota32-bluetooth + - uses: actions/upload-artifact@v2 + with: + name: firmware + path: ./build_output + + tasmota32-knx: needs: tasmota_pull runs-on: ubuntu-latest diff --git a/platformio_override_sample.ini b/platformio_override_sample.ini index 32a57fbdf..9b7ddfa53 100644 --- a/platformio_override_sample.ini +++ b/platformio_override_sample.ini @@ -27,6 +27,7 @@ default_envs = ; tasmota-zbbridge ; tasmota-ir ; tasmota32 +; tasmota32-bluetooth ; tasmota32-webcam ; tasmota32-minimal ; tasmota32-lite diff --git a/platformio_tasmota_env32.ini b/platformio_tasmota_env32.ini index b99accdef..d0b4e97c3 100644 --- a/platformio_tasmota_env32.ini +++ b/platformio_tasmota_env32.ini @@ -58,10 +58,10 @@ board_build.partitions = esp32_partition_app1984k_spiffs12M.csv build_flags = ${common32.build_flags} -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue -DFIRMWARE_M5STACK_CORE2 lib_extra_dirs = lib/libesp32, lib/lib_basic, lib/lib_i2c, lib/lib_rf, lib/lib_div, lib/lib_ssl, lib/lib_display, lib/lib_audio -[env:tasmota32-ble] +[env:tasmota32-bluetooth] extends = env:tasmota32 -build_flags = ${common32.build_flags} -DFIRMWARE_BLE -lib_extra_dirs = lib/libesp32 +build_flags = ${common32.build_flags} -DFIRMWARE_BLUETOOTH +lib_extra_dirs = lib/libesp32, lib/lib_basic, lib/lib_i2c, lib/lib_ssl [env:tasmota32-minimal] extends = env:tasmota32 diff --git a/tasmota/tasmota_configurations_ESP32.h b/tasmota/tasmota_configurations_ESP32.h index 431b3381f..d3641e862 100644 --- a/tasmota/tasmota_configurations_ESP32.h +++ b/tasmota/tasmota_configurations_ESP32.h @@ -117,6 +117,30 @@ #endif // USE_SCRIPT #endif // FIRMWARE_M5STACK_CORE2 +/*********************************************************************************************\ + * [tasmota32-bluetooth.bin] + * Provide an image with BLE support +\*********************************************************************************************/ + +#ifdef FIRMWARE_BLUETOOTH + +#undef CODE_IMAGE_STR +#define CODE_IMAGE_STR "bluetooth" + +#undef MODULE +#define MODULE BLUETOOTH // [Module] Select default module from tasmota_template.h +#undef FALLBACK_MODULE +#define FALLBACK_MODULE BLUETOOTH // [Module2] Select default module on fast reboot where USER_MODULE is user template + +#define USE_BLUETOOTH // Add support for BLUETOOTH +#define USE_UFILESYS +#define USE_SDCARD + #define GUI_TRASH_FILE +#define USE_ADC +#define USE_BLE_ESP32 // Enable new BLE driver +#define USE_MI_ESP32 // (ESP32 only) Add support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash) +#endif // FFIRMWARE_BLE + #endif // ESP32 #endif // _TASMOTA_CONFIGURATIONS_ESP32_H_ diff --git a/tasmota/tasmota_template.h b/tasmota/tasmota_template.h index 98567ca42..c7325188a 100644 --- a/tasmota/tasmota_template.h +++ b/tasmota/tasmota_template.h @@ -2354,6 +2354,7 @@ enum SupportedModules { WT32_ETH01, TTGO_WATCH, M5STACK_CORE2, + BLUETOOTH, MAXMODULE }; // Default module settings @@ -2377,6 +2378,9 @@ const uint8_t kModuleNiceList[] PROGMEM = { #ifdef USE_M5STACK_CORE2 M5STACK_CORE2, #endif // USE_M5STACK_CORE2 +#ifdef USE_BLUETOOTH + BLUETOOTH, +#endif // USE_BLUETOOTH }; const char kModuleNames[] PROGMEM = @@ -2399,6 +2403,9 @@ const char kModuleNames[] PROGMEM = #ifdef USE_M5STACK_CORE2 "M5Stack Core2|" #endif // USE_M5STACK_CORE2 +#ifdef USE_BLUETOOTH + "ESP32-BLE|" +#endif // USE_BLUETOOTH ; const mytmplt kModules[] PROGMEM = { @@ -2543,6 +2550,52 @@ const mytmplt kModules[] PROGMEM = { // }, #endif // USE_ESP32_SOLO +#ifdef USE_BLUETOOTH + { // WEMOS - Espressif ESP32-DevKitC - Any ESP32 device like WeMos and NodeMCU hardware (ESP32) + AGPIO(GPIO_USER), // 0 (I)O GPIO0, ADC2_CH1, TOUCH1, RTC_GPIO11, CLK_OUT1, EMAC_TX_CLK + AGPIO(GPIO_USER), // 1 IO TXD0 GPIO1, U0TXD, CLK_OUT3, EMAC_RXD2 + AGPIO(GPIO_USER), // 2 IO GPIO2, ADC2_CH2, TOUCH2, RTC_GPIO12, HSPIWP, HS2_DATA0, SD_DATA0 + AGPIO(GPIO_USER), // 3 IO RXD0 GPIO3, U0RXD, CLK_OUT2 + AGPIO(GPIO_USER), // 4 IO GPIO4, ADC2_CH0, TOUCH0, RTC_GPIO10, HSPIHD, HS2_DATA1, SD_DATA1, EMAC_TX_ER + AGPIO(GPIO_USER), // 5 IO GPIO5, VSPICS0, HS1_DATA6, EMAC_RX_CLK + // 6 IO GPIO6, Flash CLK + // 7 IO GPIO7, Flash D0 + // 8 IO GPIO8, Flash D1 + AGPIO(GPIO_USER), // 9 IO GPIO9, Flash D2, U1RXD + AGPIO(GPIO_USER), // 10 IO GPIO10, Flash D3, U1TXD + // 11 IO GPIO11, Flash CMD + AGPIO(GPIO_USER), // 12 (I)O GPIO12, ADC2_CH5, TOUCH5, RTC_GPIO15, MTDI, HSPIQ, HS2_DATA2, SD_DATA2, EMAC_TXD3 (If driven High, flash voltage (VDD_SDIO) is 1.8V not default 3.3V. Has internal pull-down, so unconnected = Low = 3.3V. May prevent flashing and/or booting if 3.3V flash is connected and pulled high. See ESP32 datasheet for more details.) + AGPIO(GPIO_USER), // 13 IO GPIO13, ADC2_CH4, TOUCH4, RTC_GPIO14, MTCK, HSPID, HS2_DATA3, SD_DATA3, EMAC_RX_ER + AGPIO(GPIO_USER), // 14 IO GPIO14, ADC2_CH6, TOUCH6, RTC_GPIO16, MTMS, HSPICLK, HS2_CLK, SD_CLK, EMAC_TXD2 + AGPIO(GPIO_USER), // 15 (I)O GPIO15, ADC2_CH3, TOUCH3, MTDO, HSPICS0, RTC_GPIO13, HS2_CMD, SD_CMD, EMAC_RXD3 (If driven Low, silences boot messages from normal boot. Has internal pull-up, so unconnected = High = normal output.) + AGPIO(GPIO_USER), // 16 IO GPIO16, HS1_DATA4, U2RXD, EMAC_CLK_OUT + AGPIO(GPIO_USER), // 17 IO GPIO17, HS1_DATA5, U2TXD, EMAC_CLK_OUT_180 + AGPIO(GPIO_USER), // 18 IO GPIO18, VSPICLK, HS1_DATA7 + AGPIO(GPIO_USER), // 19 IO GPIO19, VSPIQ, U0CTS, EMAC_TXD0 + 0, // 20 + AGPIO(GPIO_USER), // 21 IO GPIO21, VSPIHD, EMAC_TX_EN + AGPIO(GPIO_USER), // 22 IO LED GPIO22, VSPIWP, U0RTS, EMAC_TXD1 + AGPIO(GPIO_USER), // 23 IO GPIO23, VSPID, HS1_STROBE + 0, // 24 + AGPIO(GPIO_USER), // 25 IO GPIO25, DAC_1, ADC2_CH8, RTC_GPIO6, EMAC_RXD0 + AGPIO(GPIO_USER), // 26 IO GPIO26, DAC_2, ADC2_CH9, RTC_GPIO7, EMAC_RXD1 + AGPIO(GPIO_USER), // 27 IO GPIO27, ADC2_CH7, TOUCH7, RTC_GPIO17, EMAC_RX_DV + 0, // 28 + 0, // 29 + 0, // 30 + 0, // 31 + AGPIO(GPIO_USER), // 32 IO GPIO32, XTAL_32K_P (32.768 kHz crystal oscillator input), ADC1_CH4, TOUCH9, RTC_GPIO9 + AGPIO(GPIO_USER), // 33 IO GPIO33, XTAL_32K_N (32.768 kHz crystal oscillator output), ADC1_CH5, TOUCH8, RTC_GPIO8 + AGPIO(GPIO_USER), // 34 I NO PULLUP GPIO34, ADC1_CH6, RTC_GPIO4 + AGPIO(GPIO_USER), // 35 I NO PULLUP GPIO35, ADC1_CH7, RTC_GPIO5 + AGPIO(GPIO_USER), // 36 I NO PULLUP GPIO36, SENSOR_VP, ADC_H, ADC1_CH0, RTC_GPIO0 + 0, // 37 NO PULLUP + 0, // 38 NO PULLUP + AGPIO(GPIO_USER), // 39 I NO PULLUP GPIO39, SENSOR_VN, ADC1_CH3, ADC_H, RTC_GPIO3 + 0 // Flag + }, +#endif // USE_BLUETOOTH + #ifdef USE_WT32_ETH01 { // WT32_ETH01 - (ESP32) 0, // 0 (I)O GPIO0, Ethernet EMAC_REF_CLK diff --git a/tasmota/xdrv_85_esp32_bluetooth.ino b/tasmota/xdrv_85_esp32_bluetooth.ino new file mode 100644 index 000000000..b68ae6bd9 --- /dev/null +++ b/tasmota/xdrv_85_esp32_bluetooth.ino @@ -0,0 +1,28 @@ +/* + xdrv_81_esp32_bluetooth.ino - ESP32 Blueetooth support for Tasmota + + Copyright (C) 2021 Theo Arends + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifdef ESP32 +#ifdef USE_BLUETOOTH +/*********************************************************************************************\ + * every ESP32 board + * +/*********************************************************************************************/ + +#endif // USE_BLUETOOTH +#endif // ESP32