diff --git a/default_4MB.csv b/default_4MB.csv new file mode 100644 index 00000000..8fb2b093 --- /dev/null +++ b/default_4MB.csv @@ -0,0 +1,5 @@ +# Name, Type, SubType, Offset, Size, Flags +nvs, data, nvs, 0x9000, 0x5000, +otadata, data, ota, 0xe000, 0x2000, +app0, app, ota_0, 0x10000, 0x300000, +spiffs, data, spiffs, 0x310000,0xF0000, \ No newline at end of file diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index f81b9ffc..d93276e4 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -68,10 +68,22 @@ #include #include static XiaoC3Board board; -#elif defined(SEEED_XIAO_S3) || defined(LILYGO_T3S3) +#elif defined(SEEED_XIAO_S3) #include #include static ESP32Board board; +#elif defined(LILYGO_T3) + #include + #include + static ESP32Board board; +#elif defined(LILYGO_T3S3) + #include + #if defined(P_LORA_DIO_0) // If P_LORA_DIO_0 is defined, we're using SX1276 + #include + #else + #include + #endif + static LilyGoT3S3Board board; #elif defined(RAK_4631) #include #include @@ -1108,6 +1120,9 @@ public: #if defined(NRF52_PLATFORM) RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI); +#elif defined(LILYGO_T3) || defined(HELTEC_LORA_V2) // ESP32 with SX1276 +SPIClass spi; +RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi); #elif defined(P_LORA_SCLK) SPIClass spi; RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi); @@ -1126,19 +1141,24 @@ void setup() { Serial.begin(115200); board.begin(); -#ifdef SX126X_DIO3_TCXO_VOLTAGE - float tcxo = SX126X_DIO3_TCXO_VOLTAGE; -#else - float tcxo = 1.6f; -#endif - #if defined(NRF52_PLATFORM) SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI); SPI.begin(); #elif defined(P_LORA_SCLK) spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI); #endif + +#if defined(LILYGO_T3) || defined(HELTEC_LORA_V2) // ESP32 with SX1276 + int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX127X_SYNC_WORD, LORA_TX_POWER); +#else // SX126X module + #ifdef SX126X_DIO3_TCXO_VOLTAGE + float tcxo = SX126X_DIO3_TCXO_VOLTAGE; + #else + float tcxo = 1.6f; + #endif int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo); +#endif + if (status != RADIOLIB_ERR_NONE) { Serial.print("ERROR: radio init failed: "); Serial.println(status); @@ -1147,12 +1167,14 @@ void setup() { radio.setCRC(0); -#ifdef SX126X_CURRENT_LIMIT - radio.setCurrentLimit(SX126X_CURRENT_LIMIT); -#endif +#if !defined(LILYGO_T3) && !defined(HELTEC_LORA_V2) // SX126X specific settings + #ifdef SX126X_CURRENT_LIMIT + radio.setCurrentLimit(SX126X_CURRENT_LIMIT); + #endif -#ifdef SX126X_DIO2_AS_RF_SWITCH - radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); + #ifdef SX126X_DIO2_AS_RF_SWITCH + radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); + #endif #endif fast_rng.begin(radio.random(0x7FFFFFFF)); diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 2c35106c..1d197749 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -72,10 +72,22 @@ #include #include static XiaoC3Board board; -#elif defined(SEEED_XIAO_S3) || defined(LILYGO_T3S3) +#elif defined(SEEED_XIAO_S3) #include #include static ESP32Board board; +#elif defined(LILYGO_T3) + #include + #include + static ESP32Board board; +#elif defined(LILYGO_T3S3) + #include + #if defined(P_LORA_DIO_0) // If P_LORA_DIO_0 is defined, we're using SX1276 + #include + #else + #include + #endif + static LilyGoT3S3Board board; #elif defined(RAK_4631) #include #include @@ -604,6 +616,9 @@ public: #if defined(NRF52_PLATFORM) RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI); +#elif defined(LILYGO_T3) || defined(HELTEC_LORA_V2) // ESP32 with SX1276 +SPIClass spi; +RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi); #elif defined(P_LORA_SCLK) SPIClass spi; RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi); @@ -638,19 +653,24 @@ void setup() { #endif rtc_clock.begin(Wire); -#ifdef SX126X_DIO3_TCXO_VOLTAGE - float tcxo = SX126X_DIO3_TCXO_VOLTAGE; -#else - float tcxo = 1.6f; -#endif - #if defined(NRF52_PLATFORM) SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI); SPI.begin(); #elif defined(P_LORA_SCLK) spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI); #endif + +#if defined(LILYGO_T3) || defined(HELTEC_LORA_V2) // ESP32 with SX1276 + int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX127X_SYNC_WORD, LORA_TX_POWER); +#else // SX126X module + #ifdef SX126X_DIO3_TCXO_VOLTAGE + float tcxo = SX126X_DIO3_TCXO_VOLTAGE; + #else + float tcxo = 1.6f; + #endif int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo); +#endif + if (status != RADIOLIB_ERR_NONE) { delay(5000); Serial.print("ERROR: radio init failed: "); @@ -660,12 +680,14 @@ void setup() { radio.setCRC(0); -#ifdef SX126X_CURRENT_LIMIT - radio.setCurrentLimit(SX126X_CURRENT_LIMIT); -#endif +#if !defined(LILYGO_T3) && !defined(HELTEC_LORA_V2) // SX126X specific settings + #ifdef SX126X_CURRENT_LIMIT + radio.setCurrentLimit(SX126X_CURRENT_LIMIT); + #endif -#ifdef SX126X_DIO2_AS_RF_SWITCH - radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); + #ifdef SX126X_DIO2_AS_RF_SWITCH + radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); + #endif #endif fast_rng.begin(radio.random(0x7FFFFFFF)); diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 4ef72e16..93870af9 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -76,10 +76,22 @@ #include #include static XiaoC3Board board; -#elif defined(SEEED_XIAO_S3) +#elif defined(SEEED_XIAO_S3) #include #include static ESP32Board board; +#elif defined(LILYGO_T3) + #include + #include + static ESP32Board board; +#elif defined(LILYGO_T3S3) + #include + #if defined(P_LORA_DIO_0) // If P_LORA_DIO_0 is defined, we're using SX1276 + #include + #else + #include + #endif + static LilyGoT3S3Board board; #elif defined(RAK_4631) #include #include @@ -659,6 +671,9 @@ public: #if defined(NRF52_PLATFORM) RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI); +#elif defined(LILYGO_T3) || defined(HELTEC_LORA_V2) // ESP32 with SX1276 +SPIClass spi; +RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi); #elif defined(P_LORA_SCLK) SPIClass spi; RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi); @@ -693,19 +708,24 @@ void setup() { #endif rtc_clock.begin(Wire); -#ifdef SX126X_DIO3_TCXO_VOLTAGE - float tcxo = SX126X_DIO3_TCXO_VOLTAGE; -#else - float tcxo = 1.6f; -#endif - #if defined(NRF52_PLATFORM) SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI); SPI.begin(); #elif defined(P_LORA_SCLK) spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI); #endif + +#if defined(LILYGO_T3) || defined(HELTEC_LORA_V2) // ESP32 with SX1276 + int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX127X_SYNC_WORD, LORA_TX_POWER); +#else // SX126X module + #ifdef SX126X_DIO3_TCXO_VOLTAGE + float tcxo = SX126X_DIO3_TCXO_VOLTAGE; + #else + float tcxo = 1.6f; + #endif int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo); +#endif + if (status != RADIOLIB_ERR_NONE) { delay(5000); Serial.print("ERROR: radio init failed: "); @@ -715,12 +735,14 @@ void setup() { radio.setCRC(0); -#ifdef SX126X_CURRENT_LIMIT - radio.setCurrentLimit(SX126X_CURRENT_LIMIT); -#endif +#if !defined(LILYGO_T3) && !defined(HELTEC_LORA_V2) // SX126X specific settings + #ifdef SX126X_CURRENT_LIMIT + radio.setCurrentLimit(SX126X_CURRENT_LIMIT); + #endif -#ifdef SX126X_DIO2_AS_RF_SWITCH - radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); + #ifdef SX126X_DIO2_AS_RF_SWITCH + radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); + #endif #endif fast_rng.begin(radio.random(0x7FFFFFFF)); diff --git a/examples/simple_secure_chat/main.cpp b/examples/simple_secure_chat/main.cpp index 9ab8bfa2..fb7fd986 100644 --- a/examples/simple_secure_chat/main.cpp +++ b/examples/simple_secure_chat/main.cpp @@ -62,10 +62,22 @@ #include #include static XiaoC3Board board; -#elif defined(SEEED_XIAO_S3) || defined(LILYGO_T3S3) +#elif defined(SEEED_XIAO_S3) #include #include static ESP32Board board; +#elif defined(LILYGO_T3) + #include + #include + static ESP32Board board; +#elif defined(LILYGO_T3S3) + #include + #if defined(P_LORA_DIO_0) // If P_LORA_DIO_0 is defined, we're using SX1276 + #include + #else + #include + #endif + static LilyGoT3S3Board board; #elif defined(RAK_4631) #include #include @@ -541,6 +553,9 @@ public: #if defined(NRF52_PLATFORM) RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI); +#elif defined(LILYGO_T3) || defined(HELTEC_LORA_V2) // ESP32 with SX1276 +SPIClass spi; +RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi); #elif defined(P_LORA_SCLK) SPIClass spi; RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi); @@ -559,19 +574,24 @@ void setup() { Serial.begin(115200); board.begin(); -#ifdef SX126X_DIO3_TCXO_VOLTAGE - float tcxo = SX126X_DIO3_TCXO_VOLTAGE; -#else - float tcxo = 1.6f; -#endif - #if defined(NRF52_PLATFORM) SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI); SPI.begin(); #elif defined(P_LORA_SCLK) spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI); #endif + +#if defined(LILYGO_T3) || defined(HELTEC_LORA_V2) // ESP32 with SX1276 + int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX127X_SYNC_WORD, LORA_TX_POWER); +#else // SX126X module + #ifdef SX126X_DIO3_TCXO_VOLTAGE + float tcxo = SX126X_DIO3_TCXO_VOLTAGE; + #else + float tcxo = 1.6f; + #endif int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo); +#endif + if (status != RADIOLIB_ERR_NONE) { Serial.print("ERROR: radio init failed: "); Serial.println(status); @@ -580,12 +600,14 @@ void setup() { radio.setCRC(0); -#ifdef SX126X_CURRENT_LIMIT - radio.setCurrentLimit(SX126X_CURRENT_LIMIT); -#endif +#if !defined(LILYGO_T3) && !defined(HELTEC_LORA_V2) // SX126X specific settings + #ifdef SX126X_CURRENT_LIMIT + radio.setCurrentLimit(SX126X_CURRENT_LIMIT); + #endif -#ifdef SX126X_DIO2_AS_RF_SWITCH - radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); + #ifdef SX126X_DIO2_AS_RF_SWITCH + radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); + #endif #endif fast_rng.begin(radio.random(0x7FFFFFFF)); diff --git a/platformio.ini b/platformio.ini index df6d2093..06526126 100644 --- a/platformio.ini +++ b/platformio.ini @@ -320,6 +320,48 @@ lib_deps = densaugeo/base64 @ ~1.4.0 ; ============= +[LilyGo_T3_sx1276] +extends = esp32_base +board = ttgo-lora32-v1 ; TTGO/LilyGo T3 V1 ESP32 with SX1276 +board_build.partitions = default_4MB.csv ; Use the 4MB partition to allocate more space for firmware +build_unflags = -Os +build_type = release ; Set build type to release +build_flags = + ${esp32_base.build_flags} + -Os -ffunction-sections -fdata-sections ; Optimize for size + -D LILYGO_T3 + -D HELTEC_LORA_V2 ; Needed for CustomSX1276 support + -D P_LORA_DIO_0=26 ; SX1276 DIO0 interrupt pin + -D P_LORA_DIO_1=33 ; SX1276 DIO1 interrupt pin + -D P_LORA_NSS=18 ; Chip select - SS pin + -D P_LORA_RESET=14 ; Reset pin + -D P_LORA_SCLK=5 ; SPI clock + -D P_LORA_MISO=19 ; SPI MISO + -D P_LORA_MOSI=27 ; SPI MOSI + -D P_LORA_TX_LED=2 ; LED pin for TX indication + -D PIN_VBAT_READ=35 ; Battery voltage reading (analog pin) + -D RADIO_CLASS=CustomSX1276 + -D WRAPPER_CLASS=CustomSX1276Wrapper + -D LORA_TX_POWER=20 + +[LilyGo_T3S3_sx1276] +extends = esp32_base +board = t3_s3_v1_x ; ESP32-S3 specific board +build_flags = ${esp32_base.build_flags} + -D LILYGO_T3S3 + -D P_LORA_DIO_1=33 ; DIO1 interrupt pin + -D P_LORA_DIO_0=34 ; DIO0 interrupt pin (replaces BUSY which is for SX126x) + -D P_LORA_NSS=7 ; Chip select + -D P_LORA_RESET=8 ; Reset pin + -D P_LORA_SCLK=5 ; SPI clock + -D P_LORA_MISO=3 ; SPI MISO + -D P_LORA_MOSI=6 ; SPI MOSI + -D P_LORA_TX_LED=37 ; TX LED + -D PIN_VBAT_READ=1 ; Battery voltage reading + -D RADIO_CLASS=CustomSX1276 + -D WRAPPER_CLASS=CustomSX1276Wrapper + -D LORA_TX_POWER=20 + [LilyGo_T3S3_sx1262] extends = esp32_base board = t3_s3_v1_x @@ -398,6 +440,147 @@ lib_deps = ${LilyGo_T3S3_sx1262.lib_deps} densaugeo/base64 @ ~1.4.0 +; === LilyGo T3S3 with SX1276 environments === +[env:LilyGo_T3_sx1276_Repeater] +extends = LilyGo_T3_sx1276 +build_src_filter = ${LilyGo_T3_sx1276.build_src_filter} +<../examples/simple_repeater/main.cpp> +build_flags = + ${LilyGo_T3_sx1276.build_flags} + -D ADVERT_NAME="\"T3-1276 Repeater\"" + -D ADVERT_LAT=-37.0 + -D ADVERT_LON=145.0 + -D ADMIN_PASSWORD="\"password\"" +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 + +[env:LilyGo_T3S3_sx1276_Repeater] +extends = LilyGo_T3S3_sx1276 +build_src_filter = ${LilyGo_T3S3_sx1276.build_src_filter} +<../examples/simple_repeater/main.cpp> +build_flags = + ${LilyGo_T3S3_sx1276.build_flags} + -D ADVERT_NAME="\"T3S3-1276 Repeater\"" + -D ADVERT_LAT=-37.0 + -D ADVERT_LON=145.0 + -D ADMIN_PASSWORD="\"password\"" +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 + +[env:LilyGo_T3_sx1276_terminal_chat] +extends = LilyGo_T3_sx1276 +build_flags = + ${LilyGo_T3_sx1276.build_flags} + -D MAX_CONTACTS=100 + -D MAX_GROUP_CHANNELS=1 +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +build_src_filter = ${LilyGo_T3_sx1276.build_src_filter} +<../examples/simple_secure_chat/main.cpp> +lib_deps = + ${LilyGo_T3_sx1276.lib_deps} + densaugeo/base64 @ ~1.4.0 + +[env:LilyGo_T3S3_sx1276_terminal_chat] +extends = LilyGo_T3S3_sx1276 +build_flags = + ${LilyGo_T3S3_sx1276.build_flags} + -D MAX_CONTACTS=100 + -D MAX_GROUP_CHANNELS=1 +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +build_src_filter = ${LilyGo_T3S3_sx1276.build_src_filter} +<../examples/simple_secure_chat/main.cpp> +lib_deps = + ${LilyGo_T3S3_sx1276.lib_deps} + densaugeo/base64 @ ~1.4.0 + +[env:LilyGo_T3_sx1276_companion_radio_usb] +extends = LilyGo_T3_sx1276 +build_flags = + ${LilyGo_T3_sx1276.build_flags} + -D MAX_CONTACTS=100 + -D MAX_GROUP_CHANNELS=1 +; -D ENABLE_PRIVATE_KEY_IMPORT=1 +; -D ENABLE_PRIVATE_KEY_EXPORT=1 +; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 +; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 +build_src_filter = ${LilyGo_T3_sx1276.build_src_filter} +<../examples/companion_radio/main.cpp> +lib_deps = + ${LilyGo_T3_sx1276.lib_deps} + densaugeo/base64 @ ~1.4.0 + +[env:LilyGo_T3S3_sx1276_companion_radio_usb] +extends = LilyGo_T3S3_sx1276 +build_flags = + ${LilyGo_T3S3_sx1276.build_flags} + -D MAX_CONTACTS=100 + -D MAX_GROUP_CHANNELS=1 +; -D ENABLE_PRIVATE_KEY_IMPORT=1 +; -D ENABLE_PRIVATE_KEY_EXPORT=1 +; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 +; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 +build_src_filter = ${LilyGo_T3S3_sx1276.build_src_filter} +<../examples/companion_radio/main.cpp> +lib_deps = + ${LilyGo_T3S3_sx1276.lib_deps} + densaugeo/base64 @ ~1.4.0 + +[env:LilyGo_T3_sx1276_companion_radio_ble] +extends = LilyGo_T3_sx1276 +build_flags = + ${LilyGo_T3_sx1276.build_flags} + -D MAX_CONTACTS=100 + -D MAX_GROUP_CHANNELS=1 + -D BLE_PIN_CODE=123456 + -D BLE_DEBUG_LOGGING=1 +; -D ENABLE_PRIVATE_KEY_IMPORT=1 +; -D ENABLE_PRIVATE_KEY_EXPORT=1 +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +build_src_filter = ${LilyGo_T3_sx1276.build_src_filter} + +<../examples/companion_radio/main.cpp> +lib_deps = + ${LilyGo_T3_sx1276.lib_deps} + densaugeo/base64 @ ~1.4.0 + +[env:LilyGo_T3_sx1276_room_server] +extends = LilyGo_T3_sx1276 +build_src_filter = ${LilyGo_T3_sx1276.build_src_filter} +<../examples/simple_room_server/main.cpp> +build_flags = + ${LilyGo_T3_sx1276.build_flags} + -D ADVERT_NAME="\"T3-1276 Room\"" + -D ADVERT_LAT=-37.0 + -D ADVERT_LON=145.0 + -D ADMIN_PASSWORD="\"password\"" + -D ROOM_PASSWORD="\"hello\"" +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 + +[env:LilyGo_T3S3_sx1276_companion_radio_ble] +extends = LilyGo_T3S3_sx1276 +build_flags = + ${LilyGo_T3S3_sx1276.build_flags} + -D MAX_CONTACTS=100 + -D MAX_GROUP_CHANNELS=1 + -D BLE_PIN_CODE=123456 + -D BLE_DEBUG_LOGGING=1 +; -D ENABLE_PRIVATE_KEY_IMPORT=1 +; -D ENABLE_PRIVATE_KEY_EXPORT=1 +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +build_src_filter = ${LilyGo_T3S3_sx1276.build_src_filter} + +<../examples/companion_radio/main.cpp> +lib_deps = + ${LilyGo_T3S3_sx1276.lib_deps} + densaugeo/base64 @ ~1.4.0 + +[env:LilyGo_T3S3_sx1276_room_server] +extends = LilyGo_T3S3_sx1276 +build_src_filter = ${LilyGo_T3S3_sx1276.build_src_filter} +<../examples/simple_room_server/main.cpp> +build_flags = + ${LilyGo_T3S3_sx1276.build_flags} + -D ADVERT_NAME="\"T3S3-1276 Room\"" + -D ADVERT_LAT=-37.0 + -D ADVERT_LON=145.0 + -D ADMIN_PASSWORD="\"password\"" + -D ROOM_PASSWORD="\"hello\"" +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 + ; ----------------- NRF52 --------------------- [nrf52_base] extends = arduino_base diff --git a/src/helpers/LilyGoT3S3Board.h b/src/helpers/LilyGoT3S3Board.h new file mode 100644 index 00000000..f7287d21 --- /dev/null +++ b/src/helpers/LilyGoT3S3Board.h @@ -0,0 +1,88 @@ +#pragma once + +#include +#include "ESP32Board.h" +#include + +// LoRa radio module pins for LilyGo T3S3 +// These need to be defined here for the SX1276 version +#if defined(RADIO_CLASS) && defined(CustomSX1276) + // SX1276 pin definitions specific to LilyGo T3S3 + #define P_LORA_DIO_0 34 // DIO0 interrupt pin (SX1276 uses DIO0) + #define P_LORA_DIO_1 33 // DIO1 interrupt pin + #define P_LORA_NSS 7 // Chip select + #define P_LORA_RESET 8 // Reset pin + #define P_LORA_SCLK 5 // SPI clock + #define P_LORA_MISO 3 // SPI MISO + #define P_LORA_MOSI 6 // SPI MOSI +#endif + +// Base class for LilyGo T-series boards +class LilyGoTBoard : public ESP32Board { +public: + void begin() { + ESP32Board::begin(); + + esp_reset_reason_t reason = esp_reset_reason(); + if (reason == ESP_RST_DEEPSLEEP) { + long wakeup_source = esp_sleep_get_ext1_wakeup_status(); + if (wakeup_source & (1 << P_LORA_DIO_1)) { // received a LoRa packet (while in deep sleep) + startup_reason = BD_STARTUP_RX_PACKET; + } + + rtc_gpio_hold_dis((gpio_num_t)P_LORA_NSS); + rtc_gpio_deinit((gpio_num_t)P_LORA_DIO_1); + } + } + + void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) { + esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON); + + // Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep + rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY); + rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1); + + rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS); + + if (pin_wake_btn < 0) { + esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet + } else { + esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn + } + + if (secs > 0) { + esp_sleep_enable_timer_wakeup(secs * 1000000); + } + + // Finally set ESP32 into sleep + esp_deep_sleep_start(); // CPU halts here and never returns! + } + + uint16_t getBattMilliVolts() override { + analogReadResolution(12); + + uint32_t raw = 0; + for (int i = 0; i < 8; i++) { + raw += analogReadMilliVolts(PIN_VBAT_READ); + } + raw = raw / 8; + + return (2 * raw); + } +}; + +// Standard ESP32 version (for T3 board) +class LilyGoT3Board : public LilyGoTBoard { +public: + const char* getManufacturerName() const override { + return "LilyGo T3"; + } +}; + +// For S3 variant +class LilyGoT3S3Board : public LilyGoTBoard { +public: + const char* getManufacturerName() const override { + return "LilyGo T3S3"; + } +}; \ No newline at end of file