mirror of https://github.com/meshcore-dev/MeshCore
3 changed files with 143 additions and 0 deletions
@ -0,0 +1,47 @@ |
|||||
|
[Heltec_ct62] |
||||
|
extends = esp32_base |
||||
|
board = esp32-c3-devkitm-1 |
||||
|
build_flags = |
||||
|
${esp32_base.build_flags} |
||||
|
-I variants/heltec_ct62 |
||||
|
-D HELTEC_HT_CT62=1 |
||||
|
-D RADIO_CLASS=CustomSX1262 |
||||
|
-D WRAPPER_CLASS=CustomSX1262Wrapper |
||||
|
-D ESP32_CPU_FREQ=80 |
||||
|
-D LORA_TX_POWER=22 |
||||
|
-D P_LORA_TX_LED=18 |
||||
|
-D PIN_BOARD_SDA=0 |
||||
|
-D PIN_BOARD_SCL=1 |
||||
|
-D PIN_USER_BTN=9 |
||||
|
-D PIN_VBAT_READ=2 |
||||
|
-D P_LORA_DIO_1=3 |
||||
|
-D P_LORA_NSS=8 |
||||
|
-D P_LORA_RESET=5 |
||||
|
-D P_LORA_RESET=RADIOLIB_NC |
||||
|
-D P_LORA_BUSY=4 |
||||
|
-D P_LORA_SCLK=10 |
||||
|
-D P_LORA_MISO=6 |
||||
|
-D P_LORA_MOSI=7 |
||||
|
-D SX126X_DIO2_AS_RF_SWITCH=true |
||||
|
-D SX126X_DIO3_TCXO_VOLTAGE=1.8 |
||||
|
-D SX126X_CURRENT_LIMIT=140 |
||||
|
-D SX126X_RX_BOOSTED_GAIN=1 |
||||
|
build_src_filter = ${esp32_base.build_src_filter} |
||||
|
+<../variants/heltec_ct62> |
||||
|
|
||||
|
[env:Heltec_ct62_repeater] |
||||
|
extends = Heltec_ct62 |
||||
|
build_flags = |
||||
|
${Heltec_ct62.build_flags} |
||||
|
-D ADVERT_NAME='"HT-CT62 Repeater"' |
||||
|
-D ADVERT_LAT=0.0 |
||||
|
-D ADVERT_LON=0.0 |
||||
|
-D ADMIN_PASSWORD='"password"' |
||||
|
-D MAX_NEIGHBOURS=8 |
||||
|
; -D MESH_PACKET_LOGGING=1 |
||||
|
; -D MESH_DEBUG=1 |
||||
|
build_src_filter = ${Heltec_ct62.build_src_filter} |
||||
|
+<../examples/simple_repeater> |
||||
|
lib_deps = |
||||
|
${Heltec_ct62.lib_deps} |
||||
|
${esp32_ota.lib_deps} |
||||
@ -0,0 +1,76 @@ |
|||||
|
#include <Arduino.h> |
||||
|
#include "target.h" |
||||
|
|
||||
|
ESP32Board board; |
||||
|
|
||||
|
#if defined(P_LORA_SCLK) |
||||
|
static SPIClass spi; |
||||
|
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi); |
||||
|
#else |
||||
|
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY); |
||||
|
#endif |
||||
|
|
||||
|
WRAPPER_CLASS radio_driver(radio, board); |
||||
|
|
||||
|
ESP32RTCClock fallback_clock; |
||||
|
AutoDiscoverRTCClock rtc_clock(fallback_clock); |
||||
|
SensorManager sensors; |
||||
|
|
||||
|
#ifndef LORA_CR |
||||
|
#define LORA_CR 5 |
||||
|
#endif |
||||
|
|
||||
|
bool radio_init() { |
||||
|
fallback_clock.begin(); |
||||
|
rtc_clock.begin(Wire); |
||||
|
|
||||
|
#ifdef SX126X_DIO3_TCXO_VOLTAGE |
||||
|
float tcxo = SX126X_DIO3_TCXO_VOLTAGE; |
||||
|
#else |
||||
|
float tcxo = 1.6f; |
||||
|
#endif |
||||
|
|
||||
|
#if defined(P_LORA_SCLK) |
||||
|
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI); |
||||
|
#endif |
||||
|
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo); |
||||
|
if (status != RADIOLIB_ERR_NONE) { |
||||
|
Serial.print("ERROR: radio init failed: "); |
||||
|
Serial.println(status); |
||||
|
return false; // fail
|
||||
|
} |
||||
|
|
||||
|
radio.setCRC(1); |
||||
|
|
||||
|
#ifdef SX126X_CURRENT_LIMIT |
||||
|
radio.setCurrentLimit(SX126X_CURRENT_LIMIT); |
||||
|
#endif |
||||
|
#ifdef SX126X_DIO2_AS_RF_SWITCH |
||||
|
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); |
||||
|
#endif |
||||
|
#ifdef SX126X_RX_BOOSTED_GAIN |
||||
|
radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN); |
||||
|
#endif |
||||
|
|
||||
|
return true; // success
|
||||
|
} |
||||
|
|
||||
|
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(uint8_t dbm) { |
||||
|
radio.setOutputPower(dbm); |
||||
|
} |
||||
|
|
||||
|
mesh::LocalIdentity radio_new_identity() { |
||||
|
RadioNoiseListener rng(radio); |
||||
|
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
#define RADIOLIB_STATIC_ONLY 1 |
||||
|
#include <RadioLib.h> |
||||
|
#include <helpers/RadioLibWrappers.h> |
||||
|
#include <helpers/ESP32Board.h> |
||||
|
#include <helpers/CustomSX1262Wrapper.h> |
||||
|
#include <helpers/AutoDiscoverRTCClock.h> |
||||
|
#include <helpers/SensorManager.h> |
||||
|
|
||||
|
extern ESP32Board board; |
||||
|
extern WRAPPER_CLASS radio_driver; |
||||
|
extern AutoDiscoverRTCClock rtc_clock; |
||||
|
extern SensorManager sensors; |
||||
|
|
||||
|
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(uint8_t dbm); |
||||
|
mesh::LocalIdentity radio_new_identity(); |
||||
Loading…
Reference in new issue