mirror of https://github.com/meshcore-dev/MeshCore
committed by
GitHub
5 changed files with 410 additions and 0 deletions
@ -0,0 +1,26 @@ |
|||
#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(); |
|||
bool detected = ((irq & RADIOLIB_LR11X0_IRQ_SYNC_WORD_HEADER_VALID) || (irq & RADIOLIB_LR11X0_IRQ_PREAMBLE_DETECTED)); |
|||
return detected; |
|||
} |
|||
uint8_t getSpreadingFactor() const { return spreadingFactor; } |
|||
}; |
|||
@ -0,0 +1,59 @@ |
|||
#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->setFrequency(freq); |
|||
r->setSpreadingFactor(sf); |
|||
r->setBandwidth(bw); |
|||
r->setCodingRate(cr); |
|||
updatePreamble(sf); |
|||
} |
|||
|
|||
uint8_t getSpreadingFactor() const override { |
|||
return ((CustomLR1121*)_radio)->getSpreadingFactor(); |
|||
} |
|||
|
|||
void doResetAGC() override { |
|||
lr11x0ResetAGC((LR11x0*)_radio, ((CustomLR1121*)_radio)->getFreqMHz()); |
|||
} |
|||
|
|||
bool isReceivingPacket() override { |
|||
return ((CustomLR1121*)_radio)->isReceiving(); |
|||
} |
|||
|
|||
float getCurrentRSSI() override { |
|||
float rssi = -110; |
|||
((CustomLR1121*)_radio)->getRssiInst(&rssi); |
|||
return rssi; |
|||
} |
|||
|
|||
void onSendFinished() override { |
|||
RadioLibWrapper::onSendFinished(); |
|||
_radio->setPreambleLength(preambleLengthForSF(getSpreadingFactor())); |
|||
} |
|||
|
|||
float getLastRSSI() const override { |
|||
return ((CustomLR1121*)_radio)->getRSSI(); |
|||
} |
|||
|
|||
float getLastSNR() const override { |
|||
return ((CustomLR1121*)_radio)->getSNR(); |
|||
} |
|||
|
|||
void setRxBoostedGainMode(bool en) override { |
|||
((CustomLR1121*)_radio)->setRxBoostedGainMode(en); |
|||
} |
|||
|
|||
bool getRxBoostedGainMode() const override { |
|||
return ((CustomLR1121*)_radio)->getRxBoostedGainMode(); |
|||
} |
|||
}; |
|||
@ -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} |
|||
@ -0,0 +1,93 @@ |
|||
#include <Arduino.h> |
|||
#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; |
|||
} |
|||
|
|||
|
|||
mesh::LocalIdentity radio_new_identity() { |
|||
RadioNoiseListener rng(radio); |
|||
return mesh::LocalIdentity(&rng); |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
#pragma once |
|||
|
|||
#define RADIOLIB_STATIC_ONLY 1 |
|||
#include <RadioLib.h> |
|||
#include <helpers/radiolib/RadioLibWrappers.h> |
|||
#include <helpers/ESP32Board.h> |
|||
#include <helpers/radiolib/CustomLR1121Wrapper.h> |
|||
#include <helpers/AutoDiscoverRTCClock.h> |
|||
#include <helpers/SensorManager.h> |
|||
|
|||
#ifdef DISPLAY_CLASS |
|||
#include <helpers/ui/SSD1306Display.h> |
|||
#include <helpers/ui/MomentaryButton.h> |
|||
#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(); |
|||
mesh::LocalIdentity radio_new_identity(); |
|||
Loading…
Reference in new issue