Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/helpers/radiolib/CustomLR1121.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#pragma once

#include <RadioLib.h>
#include "MeshCore.h"

class CustomLR1121 : public LR1121 {
bool _rx_boosted = false;

public:
CustomLR1121(Module *mod) : LR1121(mod) { }

float getFreqMHz() const { return freqMHz; }

int16_t setRxBoostedGainMode(bool en) {
_rx_boosted = en;
return LR1121::setRxBoostedGainMode(en);
}

bool getRxBoostedGainMode() const { return _rx_boosted; }

bool isReceiving() {
uint16_t irq = getIrqStatus();
return irq & (
RADIOLIB_LR11X0_IRQ_SYNC_WORD_HEADER_VALID |
RADIOLIB_LR11X0_IRQ_PREAMBLE_DETECTED |
RADIOLIB_LR11X0_IRQ_CRC_ERR
);
}

uint8_t getSpreadingFactor() const {
return spreadingFactor;
}

size_t getPacketLength(bool update) override {
size_t len = LR1121::getPacketLength(update);
uint16_t irq = getIrqStatus();
if (len == 0 && irq == 0) {
return 0;
}
if (len == 0 && (irq & RADIOLIB_LR11X0_IRQ_HEADER_ERR)) {
MESH_DEBUG_PRINTLN("LR1121: header err, calling standby()");
standby();
clearIrqState(RADIOLIB_LR11X0_IRQ_HEADER_ERR);
}
return len;
}
};
65 changes: 65 additions & 0 deletions src/helpers/radiolib/CustomLR1121Wrapper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#pragma once

#include "CustomLR1121.h"
#include "RadioLibWrappers.h"
#include "LR11x0Reset.h"

class CustomLR1121Wrapper : public RadioLibWrapper {
public:
CustomLR1121Wrapper(CustomLR1121& radio, mesh::MainBoard& board)
: RadioLibWrapper(radio, board) { }

void setParams(float freq, float bw, uint8_t sf, uint8_t cr) override {
auto* r = (CustomLR1121*)_radio;
r->standby();
r->setFrequency(freq);
uint8_t ldro = (sf >= 11 || bw <= 125) ? 1 : 0;
r->setModulationParamsLoRa(sf, bw, cr, ldro);
updatePreamble(sf);
}

uint8_t getSpreadingFactor() const override {
return ((CustomLR1121*)_radio)->getSpreadingFactor();
}

bool isReceivingPacket() override {
return ((CustomLR1121*)_radio)->isReceiving();
}

float getCurrentRSSI() override {
float rssi = -110;
((CustomLR1121*)_radio)->getRssiInst(&rssi);
return rssi;
}

float getLastRSSI() const override {
return ((CustomLR1121*)_radio)->getRSSI();
}

float getLastSNR() const override {
return ((CustomLR1121*)_radio)->getSNR();
}

void onSendFinished() override {
RadioLibWrapper::onSendFinished();
_radio->setPreambleLength(
preambleLengthForSF(getSpreadingFactor()));
}

void doResetAGC() override {
auto* r = (CustomLR1121*)_radio;
float freqHz = r->getFreqMHz() * 1e6;
r->standby();
r->calibrate(RADIOLIB_LR11X0_CALIBRATE_ALL);
r->setFs();
lr11x0ResetAGC((LR11x0*)_radio, freqHz);
}

void setRxBoostedGainMode(bool en) override {
((CustomLR1121*)_radio)->setRxBoostedGainMode(en);
}

bool getRxBoostedGainMode() const override {
return ((CustomLR1121*)_radio)->getRxBoostedGainMode();
}
};
205 changes: 205 additions & 0 deletions variants/ebyte_eora_hub/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
[Ebyte_EoRa_hub]
extends = esp32_base
board = esp32-s3-devkitc-1
board_build.partitions = min_spiffs.csv

build_flags =
${esp32_base.build_flags}
-I variants/ebyte_eora_hub
-D BOARD_HAS_PSRAM=1
-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_BUSY=13
-D P_LORA_DIO_9=14
-D P_LORA_DIO_1=-1
-D LR11X0_DIO3_TCXO_VOLTAGE=1.8
-D RF_SWITCH_TABLE
-D LORA_TX_POWER=22
-D DISPLAY_CLASS=SSD1306Display
-D PIN_OLED_RESET=21
-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_hub_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}
+<helpers/ui/SSD1306Display.cpp>
+<../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}
+<helpers/bridges/ESPNowBridge.cpp>
+<helpers/ui/SSD1306Display.cpp>
+<../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}
+<helpers/ui/SSD1306Display.cpp>
+<../examples/simple_secure_chat/main.cpp>
lib_deps =
${Ebyte_EoRa_hub.lib_deps}
densaugeo/base64 @ ~1.4.0


; === Room server role ===
[env:Ebyte_EoRa_hub_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}
+<helpers/ui/SSD1306Display.cpp>
+<../examples/simple_room_server>
lib_deps =
${Ebyte_EoRa_hub.lib_deps}
${esp32_ota.lib_deps}


; === Companion radio (USB) ===
[env:Ebyte_EoRa_hub_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}
+<helpers/ui/SSD1306Display.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<../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_hub_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}
+<helpers/esp32/*.cpp>
+<helpers/ui/SSD1306Display.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<../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}
+<helpers/ui/SSD1306Display.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/esp32/*.cpp>
+<../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}
+<helpers/ui/SSD1306Display.cpp>
+<../examples/simple_sensor>
lib_deps =
${Ebyte_EoRa_hub.lib_deps}
${esp32_ota.lib_deps}
Loading