From 47567b003fd70a27a195b180c70caf1d93202e19 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Tue, 21 Jan 2025 21:36:44 +1100 Subject: [PATCH] * new targets: RAK_4631_chat_alice, and _bob --- examples/simple_repeater/main.cpp | 4 ++-- examples/simple_secure_chat/main.cpp | 30 ++++++++++++++++++++-------- platformio.ini | 30 ++++++++++++++++++++++------ 3 files changed, 48 insertions(+), 16 deletions(-) diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 83d738ca..65cc1523 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -9,7 +9,6 @@ #define RADIOLIB_STATIC_ONLY 1 #include -#include #include #include #include @@ -30,7 +29,7 @@ #define LORA_CR 5 #endif #ifndef LORA_TX_POWER - #defne LORA_TX_POWER 20 + #define LORA_TX_POWER 20 #endif #ifndef ADVERT_NAME @@ -49,6 +48,7 @@ #if defined(HELTEC_LORA_V3) #include + #include static HeltecV3Board board; #elif defined(ARDUINO_XIAO_ESP32C3) #include diff --git a/examples/simple_secure_chat/main.cpp b/examples/simple_secure_chat/main.cpp index 8316da1a..15189f47 100644 --- a/examples/simple_secure_chat/main.cpp +++ b/examples/simple_secure_chat/main.cpp @@ -1,6 +1,5 @@ #include // needed for PlatformIO #include -#include #define RADIOLIB_STATIC_ONLY 1 #include @@ -23,6 +22,9 @@ #ifndef LORA_CR #define LORA_CR 5 #endif +#ifndef LORA_TX_POWER + #define LORA_TX_POWER 20 +#endif //#define RUN_AS_ALICE true @@ -38,7 +40,12 @@ #ifdef HELTEC_LORA_V3 #include + #include static HeltecV3Board board; +#elif defined(RAK_4631) + #include + #include + static RAK4631Board board; #else #error "need to provide a 'board' object" #endif @@ -233,7 +240,7 @@ public: uint32_t expected_ack_crc; unsigned long last_msg_sent; - MyMesh(mesh::Radio& radio, mesh::RNG& rng, mesh::RTCClock& rtc, SimpleMeshTables& tables) + MyMesh(RadioLibWrapper& radio, mesh::RNG& rng, mesh::RTCClock& rtc, SimpleMeshTables& tables) : mesh::Mesh(radio, *new ArduinoMillis(), rng, rtc, *new StaticPoolPacketManager(16), tables) { num_contacts = 0; @@ -272,11 +279,17 @@ public: } }; +#if defined(NRF52_PLATFORM) +RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI); +#elif defined(P_LORA_SCLK) 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 StdRNG fast_rng; SimpleMeshTables tables; -SX1262 radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi); -MyMesh the_mesh(*new RadioLibWrapper(radio, board), fast_rng, *new VolatileRTCClock(), tables); +MyMesh the_mesh(*new WRAPPER_CLASS(radio, board), fast_rng, *new VolatileRTCClock(), tables); void halt() { while (1) ; @@ -294,12 +307,13 @@ void setup() { float tcxo = 1.6f; #endif -#if defined(P_LORA_SCLK) +#if defined(NRF52_PLATFORM) + SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI); + SPI.begin(); +#elif defined(P_LORA_SCLK) spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI); - int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, 22, 8, tcxo); -#else - int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, 22, 8, tcxo); #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); diff --git a/platformio.ini b/platformio.ini index 74d06970..b7821f9c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -43,6 +43,8 @@ board = esp32-s3-devkitc-1 build_flags = ${esp32_base.build_flags} -D HELTEC_LORA_V3 + -D RADIO_CLASS=CustomSX1262 + -D WRAPPER_CLASS=CustomSX1262Wrapper -D LORA_TX_POWER=22 -D SX126X_DIO2_AS_RF_SWITCH=true -D SX126X_DIO3_TCXO_VOLTAGE=1.8 @@ -61,8 +63,6 @@ build_src_filter = ${Heltec_lora32_v3.build_src_filter} +<../examples/ping_clien extends = Heltec_lora32_v3 build_flags = ${Heltec_lora32_v3.build_flags} - -D RADIO_CLASS=CustomSX1262 - -D WRAPPER_CLASS=CustomSX1262Wrapper -D ADVERT_NAME="\"Heltec Repeater\"" -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 @@ -197,19 +197,37 @@ board = wiscore_rak4631 board_check = true build_flags = ${nrf52840_base.build_flags} -D RAK_4631 + -D RADIO_CLASS=CustomSX1262 + -D WRAPPER_CLASS=CustomSX1262Wrapper + -D LORA_TX_POWER=22 + -D SX126X_CURRENT_LIMIT=130 [env:RAK_4631_Repeater] extends = rak4631 build_src_filter = ${rak4631.build_src_filter} +<../examples/simple_repeater/main.cpp> build_flags = ${rak4631.build_flags} - -D RADIO_CLASS=CustomSX1262 - -D WRAPPER_CLASS=CustomSX1262Wrapper - -D LORA_TX_POWER=22 - -D SX126X_CURRENT_LIMIT=130 -D ADVERT_NAME="\"RAK4631 Repeater\"" -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 -D ADMIN_PASSWORD="\"password\"" ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 + +[env:RAK_4631_chat_alice] +extends = rak4631 +build_flags = + ${rak4631.build_flags} + -D RUN_AS_ALICE=true + -D MESH_PACKET_LOGGING=1 + -D MESH_DEBUG=1 +build_src_filter = ${rak4631.build_src_filter} +<../examples/simple_secure_chat/main.cpp> + +[env:RAK_4631_chat_bob] +extends = rak4631 +build_flags = + ${rak4631.build_flags} + -D RUN_AS_ALICE=false + -D MESH_PACKET_LOGGING=1 + -D MESH_DEBUG=1 +build_src_filter = ${rak4631.build_src_filter} +<../examples/simple_secure_chat/main.cpp>