Просмотр исходного кода

Merge pull request #387 from awolden/awolden/T3S3-sx1276

Add support T3S3 v1.2 (SX1726)
ripplebiz 1 год назад
Родитель
Сommit
fab84925c3

+ 119 - 0
variants/lilygo_t3s3_sx1276/platformio.ini

@@ -0,0 +1,119 @@
+[LilyGo_T3S3_sx1276]
+extends = esp32_base
+board = t3_s3_v1_x
+build_flags =
+  ${esp32_base.build_flags}
+  -I variants/lilygo_t3s3_sx1276
+  -D LILYGO_T3S3
+  -D P_LORA_DIO_0=9
+  -D P_LORA_DIO_1=33
+  -D P_LORA_NSS=7
+  -D P_LORA_RESET=8
+  -D P_LORA_SCLK=5
+  -D P_LORA_MISO=3
+  -D P_LORA_MOSI=6
+  -D P_LORA_TX_LED=37
+  -D PIN_VBAT_READ=1
+  -D PIN_USER_BTN=0
+  -D PIN_BOARD_SDA=18
+  -D PIN_BOARD_SCL=17
+  -D PIN_OLED_RESET=21
+  -D RADIO_CLASS=CustomSX1276
+  -D WRAPPER_CLASS=CustomSX1276Wrapper
+  -D SX127X_CURRENT_LIMIT=120
+  -D LORA_TX_POWER=20
+build_src_filter = ${esp32_base.build_src_filter}
+  +<../variants/lilygo_t3s3_sx1276>
+lib_deps =
+  ${esp32_base.lib_deps}
+  adafruit/Adafruit SSD1306 @ ^2.5.13
+
+; === LilyGo T3S3 with SX1276 environments ===
+[env:LilyGo_T3S3_sx1276_Repeater]
+extends = LilyGo_T3S3_sx1276
+build_flags =
+  ${LilyGo_T3S3_sx1276.build_flags}
+  -D DISPLAY_CLASS=SSD1306Display
+  -D ADVERT_NAME='"T3S3-1276 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 = ${LilyGo_T3S3_sx1276.build_src_filter}
+  +<helpers/ui/SSD1306Display.cpp>
+  +<../examples/simple_repeater>
+lib_deps =
+  ${LilyGo_T3S3_sx1276.lib_deps}
+  ${esp32_ota.lib_deps}
+
+[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_T3S3_sx1276_room_server]
+extends = LilyGo_T3S3_sx1276
+build_flags =
+  ${LilyGo_T3S3_sx1276.build_flags}
+  -D DISPLAY_CLASS=SSD1306Display
+  -D ADVERT_NAME='"T3S3-1276 Room"'
+  -D ADVERT_LAT=0.0
+  -D ADVERT_LON=0.0
+  -D ADMIN_PASSWORD='"password"'
+  -D ROOM_PASSWORD='"hello"'
+;  -D MESH_PACKET_LOGGING=1
+;  -D MESH_DEBUG=1
+build_src_filter = ${LilyGo_T3S3_sx1276.build_src_filter}
+  +<helpers/ui/SSD1306Display.cpp>
+  +<../examples/simple_room_server>
+lib_deps =
+  ${LilyGo_T3S3_sx1276.lib_deps}
+  ${esp32_ota.lib_deps}
+
+[env:LilyGo_T3S3_sx1276_companion_radio_usb]
+extends = LilyGo_T3S3_sx1276
+upload_speed = 115200
+build_flags =
+  ${LilyGo_T3S3_sx1276.build_flags}
+  -D DISPLAY_CLASS=SSD1306Display
+  -D MAX_CONTACTS=100
+  -D MAX_GROUP_CHANNELS=8
+  -D MESH_PACKET_LOGGING=1
+  -D MESH_DEBUG=1
+build_src_filter = ${LilyGo_T3S3_sx1276.build_src_filter}
+  +<helpers/ui/SSD1306Display.cpp>
+  +<../examples/companion_radio>
+lib_deps =
+  ${LilyGo_T3S3_sx1276.lib_deps}
+  densaugeo/base64 @ ~1.4.0
+
+[env:LilyGo_T3S3_sx1276_companion_radio_ble]
+extends = LilyGo_T3S3_sx1276
+build_flags =
+  ${LilyGo_T3S3_sx1276.build_flags}
+  -D DISPLAY_CLASS=SSD1306Display
+  -D MAX_CONTACTS=100
+  -D MAX_GROUP_CHANNELS=8
+  -D BLE_PIN_CODE=123456
+  -D BLE_DEBUG_LOGGING=1
+  -D OFFLINE_QUEUE_SIZE=256
+;  -D MESH_PACKET_LOGGING=1
+;  -D MESH_DEBUG=1
+build_src_filter = ${LilyGo_T3S3_sx1276.build_src_filter}
+  +<helpers/esp32/*.cpp>
+  +<helpers/ui/SSD1306Display.cpp>
+  +<../examples/companion_radio>
+lib_deps =
+  ${LilyGo_T3S3_sx1276.lib_deps}
+  densaugeo/base64 @ ~1.4.0

+ 70 - 0
variants/lilygo_t3s3_sx1276/target.cpp

@@ -0,0 +1,70 @@
+#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_0, P_LORA_RESET, P_LORA_DIO_1, spi);
+#else
+  RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1);
+#endif
+
+WRAPPER_CLASS radio_driver(radio, board);
+
+ESP32RTCClock fallback_clock;
+AutoDiscoverRTCClock rtc_clock(fallback_clock);
+SensorManager sensors;
+
+#ifdef DISPLAY_CLASS
+  DISPLAY_CLASS display;
+#endif
+
+#ifndef LORA_CR
+  #define LORA_CR      5
+#endif
+
+bool radio_init() {
+  fallback_clock.begin();
+  rtc_clock.begin(Wire);
+
+#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);
+  if (status != RADIOLIB_ERR_NONE) {
+    Serial.print("ERROR: radio init failed: ");
+    Serial.println(status);
+    return false;  // fail
+  }
+
+#ifdef SX127X_CURRENT_LIMIT
+  radio.setCurrentLimit(SX127X_CURRENT_LIMIT);
+#endif
+
+  radio.setCRC(1);
+  
+  radio.setRfSwitchPins(21, 10);
+
+  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
+}

+ 27 - 0
variants/lilygo_t3s3_sx1276/target.h

@@ -0,0 +1,27 @@
+#pragma once
+
+#define RADIOLIB_STATIC_ONLY 1
+#include <RadioLib.h>
+#include <helpers/RadioLibWrappers.h>
+#include <helpers/ESP32Board.h>
+#include <helpers/CustomSX1276Wrapper.h>
+#include <helpers/AutoDiscoverRTCClock.h>
+#include <helpers/SensorManager.h>
+#ifdef DISPLAY_CLASS
+  #include <helpers/ui/SSD1306Display.h>
+#endif
+
+extern ESP32Board board;
+extern WRAPPER_CLASS radio_driver;
+extern AutoDiscoverRTCClock rtc_clock;
+extern SensorManager sensors;
+
+#ifdef DISPLAY_CLASS
+  extern DISPLAY_CLASS display;
+#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(uint8_t dbm);
+mesh::LocalIdentity radio_new_identity();