From 65857966417a24a9109e2b9b73499d70c6d2d6df Mon Sep 17 00:00:00 2001 From: radmir <39234121+mrrdmr@users.noreply.github.com> Date: Mon, 18 May 2026 12:16:52 +0300 Subject: [PATCH] add Ebyte EoRa hub (LR1121) --- variants/ebyte_eora_hub/platformio.ini | 201 +++++++++++++++++++++++++ variants/ebyte_eora_hub/target.cpp | 107 +++++++++++++ variants/ebyte_eora_hub/target.h | 30 ++++ 3 files changed, 338 insertions(+) create mode 100644 variants/ebyte_eora_hub/platformio.ini create mode 100644 variants/ebyte_eora_hub/target.cpp create mode 100644 variants/ebyte_eora_hub/target.h diff --git a/variants/ebyte_eora_hub/platformio.ini b/variants/ebyte_eora_hub/platformio.ini new file mode 100644 index 000000000..da185fb31 --- /dev/null +++ b/variants/ebyte_eora_hub/platformio.ini @@ -0,0 +1,201 @@ +[Ebyte_EoRa-hub] +extends = esp32_base +board = esp32-s3-devkitc-1 + +build_flags = + ${esp32_base.build_flags} + -I variants/ebyte_eora_hub + -D RADIO_CLASS=CustomLR1121 + -D WRAPPER_CLASS=CustomLR1121Wrapper + -D P_LORA_NSS=8 + -D P_LORA_SCLK=9 + -D P_LORA_MOSI=10 + -D P_LORA_MISO=11 + -D P_LORA_RESET=12 + -D P_LORA_DIO_9=13 + -D P_LORA_BUSY=13 + -D LR1121_IRQ_PIN=14 + -D LR11X0_DIO3_TCXO_VOLTAGE=1.8 + -D RF_SWITCH_TABLE + -D LORA_TX_POWER=22 + -D DISPLAY_CLASS=SSD1306Display + -D PIN_BOARD_SDA=18 + -D PIN_BOARD_SCL=17 + -D PIN_VBAT_READ=1 + -D ADC_CTRL=37 + -D PIN_SERIAL_TX=43 + -D PIN_SERIAL_RX=44 + -D PIN_USER_BTN=0 + -D LED_POWER=35 + +build_src_filter = + ${esp32_base.build_src_filter} + +<../variants/ebyte_eora_hub> + +lib_deps = + ${esp32_base.lib_deps} + adafruit/Adafruit SSD1306 @ ^2.5.13 + + +; === Repeater role === +[env:Ebyte_EoRa_repeater] +extends = Ebyte_EoRa-hub +build_flags = + ${Ebyte_EoRa-hub.build_flags} + -D ADVERT_NAME='"EORA_HUB-1121 Repeater"' + -D ADVERT_LAT=0.0 + -D ADVERT_LON=0.0 + -D ADMIN_PASSWORD='"password"' + -D MAX_NEIGHBOURS=50 +build_src_filter = + ${Ebyte_EoRa-hub.build_src_filter} + + + +<../examples/simple_repeater> +lib_deps = + ${Ebyte_EoRa-hub.lib_deps} + ${esp32_ota.lib_deps} + + +; === ESP-NOW Bridge role === +[env:Ebyte_EoRa-hub_repeater_bridge_espnow] +extends = Ebyte_EoRa-hub +build_flags = + ${Ebyte_EoRa-hub.build_flags} + -D DISPLAY_CLASS=SSD1306Display + -D ADVERT_NAME='"ESPNow Bridge"' + -D ADVERT_LAT=0.0 + -D ADVERT_LON=0.0 + -D ADMIN_PASSWORD='"password"' + -D MAX_NEIGHBOURS=50 + -D WITH_ESPNOW_BRIDGE=1 +build_src_filter = + ${Ebyte_EoRa-hub.build_src_filter} + + + + + +<../examples/simple_repeater> +lib_deps = + ${Ebyte_EoRa-hub.lib_deps} + ${esp32_ota.lib_deps} + + +; === Terminal chat role === +[env:Ebyte_EoRa-hub_terminal_chat] +extends = Ebyte_EoRa-hub +build_flags = + ${Ebyte_EoRa-hub.build_flags} + -D MAX_CONTACTS=300 + -D MAX_GROUP_CHANNELS=1 +build_src_filter = + ${Ebyte_EoRa-hub.build_src_filter} + +<../examples/simple_secure_chat/main.cpp> +lib_deps = + ${Ebyte_EoRa-hub.lib_deps} + densaugeo/base64 @ ~1.4.0 + + +; === Room server role === +[env:Ebyte_EoRa_room_server] +extends = Ebyte_EoRa-hub +build_flags = + ${Ebyte_EoRa-hub.build_flags} + -D ADVERT_NAME='"EORA_HUB-1121 Room"' + -D ADVERT_LAT=0.0 + -D ADVERT_LON=0.0 + -D ADMIN_PASSWORD='"password"' + -D ROOM_PASSWORD='"hello"' +build_src_filter = + ${Ebyte_EoRa-hub.build_src_filter} + + + +<../examples/simple_room_server> +lib_deps = + ${Ebyte_EoRa-hub.lib_deps} + ${esp32_ota.lib_deps} + + +; === Companion radio (USB) === +[env:Ebyte_EoRa_companion_radio_usb] +extends = Ebyte_EoRa-hub +upload_speed = 115200 +build_flags = + ${Ebyte_EoRa-hub.build_flags} + -I examples/companion_radio/ui-new + -D MAX_CONTACTS=300 + -D MAX_GROUP_CHANNELS=8 +build_src_filter = + ${Ebyte_EoRa-hub.build_src_filter} + + + + + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-new/*.cpp> +lib_deps = + ${Ebyte_EoRa-hub.lib_deps} + densaugeo/base64 @ ~1.4.0 + + +; === Companion radio (BLE) === +[env:Ebyte_EoRa_companion_radio_ble] +extends = Ebyte_EoRa-hub +build_flags = + ${Ebyte_EoRa-hub.build_flags} + -I examples/companion_radio/ui-new + -D MAX_CONTACTS=300 + -D MAX_GROUP_CHANNELS=8 + -D BLE_PIN_CODE=123456 + -D BLE_DEBUG_LOGGING=1 + -D OFFLINE_QUEUE_SIZE=256 +build_src_filter = + ${Ebyte_EoRa-hub.build_src_filter} + + + + + + + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-new/*.cpp> +lib_deps = + ${Ebyte_EoRa-hub.lib_deps} + densaugeo/base64 @ ~1.4.0 + + +; === Companion radio (WiFi) === +[env:Ebyte_EoRa-hub_companion_radio_wifi] +extends = Ebyte_EoRa-hub +build_flags = + ${Ebyte_EoRa-hub.build_flags} + -I examples/companion_radio/ui-new + -D MAX_CONTACTS=300 + -D MAX_GROUP_CHANNELS=8 + -D OFFLINE_QUEUE_SIZE=256 + -D DISPLAY_CLASS=SSD1306Display + -D WIFI_DEBUG_LOGGING=1 + -D WIFI_SSID='"myssid"' + -D WIFI_PWD='"mypwd"' +build_src_filter = + ${Ebyte_EoRa-hub.build_src_filter} + + + + + + + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-new/*.cpp> +lib_deps = + ${Ebyte_EoRa-hub.lib_deps} + densaugeo/base64 @ ~1.4.0 + + +; === Sensor role === +[env:Ebyte_EoRa-hub_sensor] +extends = Ebyte_EoRa-hub +build_flags = + ${Ebyte_EoRa-hub.build_flags} + -D ADVERT_NAME='"EoRaHub Sensor"' + -D ADVERT_LAT=0.0 + -D ADVERT_LON=0.0 + -D ADMIN_PASSWORD='"password"' + -D ENV_PIN_SDA=3 + -D ENV_PIN_SCL=4 + -D DISPLAY_CLASS=SSD1306Display +build_src_filter = + ${Ebyte_EoRa-hub.build_src_filter} + + + +<../examples/simple_sensor> +lib_deps = + ${Ebyte_EoRa-hub.lib_deps} + ${esp32_ota.lib_deps} \ No newline at end of file diff --git a/variants/ebyte_eora_hub/target.cpp b/variants/ebyte_eora_hub/target.cpp new file mode 100644 index 000000000..2884fb29f --- /dev/null +++ b/variants/ebyte_eora_hub/target.cpp @@ -0,0 +1,107 @@ +#include +#include "target.h" + +ESP32Board board; + +static SPIClass spi; +RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_9, P_LORA_RESET, P_LORA_BUSY, spi); + +WRAPPER_CLASS radio_driver(radio, board); + +ESP32RTCClock fallback_clock; +AutoDiscoverRTCClock rtc_clock(fallback_clock); +SensorManager sensors; + +#ifdef DISPLAY_CLASS + DISPLAY_CLASS display; + MomentaryButton user_btn(PIN_USER_BTN, 1000, true); +#endif + +#ifndef LORA_CR + #define LORA_CR 5 +#endif + +#ifdef RF_SWITCH_TABLE +// EoRa-Hub 900TB RF switch (E80-900M2213S) +static const uint32_t rfswitch_dios[Module::RFSWITCH_MAX_PINS] = { + RADIOLIB_LR11X0_DIO5, + RADIOLIB_LR11X0_DIO6, + RADIOLIB_LR11X0_DIO7, + RADIOLIB_NC, + RADIOLIB_NC +}; + +static const Module::RfSwitchMode_t rfswitch_table[] = { + { LR11x0::MODE_STBY, {LOW, LOW, LOW} }, + { LR11x0::MODE_RX, {LOW, HIGH, LOW} }, + { LR11x0::MODE_TX, {HIGH, HIGH, LOW} }, + { LR11x0::MODE_TX_HP, {HIGH, LOW, LOW} }, + { LR11x0::MODE_TX_HF, {LOW, LOW, LOW} }, + { LR11x0::MODE_GNSS, {LOW, LOW, HIGH} }, + { LR11x0::MODE_WIFI, {LOW, LOW, LOW} }, + END_OF_MODE_TABLE, +}; +#endif + +bool radio_init() { + fallback_clock.begin(); + rtc_clock.begin(Wire); + +#ifdef LR11X0_DIO3_TCXO_VOLTAGE + float tcxo = LR11X0_DIO3_TCXO_VOLTAGE; +#else + float tcxo = 1.6f; +#endif + + spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI, P_LORA_NSS); + + int status = radio.begin( + LORA_FREQ, + LORA_BW, + LORA_SF, + LORA_CR, + RADIOLIB_LR11X0_LORA_SYNC_WORD_PRIVATE, + LORA_TX_POWER, + 16, + tcxo + ); + + if (status != RADIOLIB_ERR_NONE) { + Serial.print("ERROR: radio init failed: "); + Serial.println(status); + return false; + } + + radio.setCRC(2); + radio.explicitHeader(); + +#ifdef RF_SWITCH_TABLE + radio.setRfSwitchTable(rfswitch_dios, rfswitch_table); +#endif + +#ifdef RX_BOOSTED_GAIN + radio.setRxBoostedGainMode(RX_BOOSTED_GAIN); +#endif + + return true; +} + +uint32_t radio_get_rng_seed() { + return radio.random(0x7FFFFFFF); +} + +void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) { + radio.setFrequency(freq); + radio.setSpreadingFactor(sf); + radio.setBandwidth(bw); + radio.setCodingRate(cr); +} + +void radio_set_tx_power(int8_t dbm) { + radio.setOutputPower(dbm); +} + +mesh::LocalIdentity radio_new_identity() { + RadioNoiseListener rng(radio); + return mesh::LocalIdentity(&rng); +} diff --git a/variants/ebyte_eora_hub/target.h b/variants/ebyte_eora_hub/target.h new file mode 100644 index 000000000..ba9b0abec --- /dev/null +++ b/variants/ebyte_eora_hub/target.h @@ -0,0 +1,30 @@ +#pragma once + +#define RADIOLIB_STATIC_ONLY 1 +#include +#include +#include +#include +#include +#include + +#ifdef DISPLAY_CLASS + #include + #include +#endif + +extern ESP32Board board; +extern WRAPPER_CLASS radio_driver; +extern AutoDiscoverRTCClock rtc_clock; +extern SensorManager sensors; + +#ifdef DISPLAY_CLASS + extern DISPLAY_CLASS display; + extern MomentaryButton user_btn; +#endif + +bool radio_init(); +uint32_t radio_get_rng_seed(); +void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr); +void radio_set_tx_power(int8_t dbm); +mesh::LocalIdentity radio_new_identity();