From e535e161d8696bcaaf95e82955efa329c906ad1e Mon Sep 17 00:00:00 2001 From: Konrad Iturbe Date: Sat, 28 Dec 2024 15:28:44 +0100 Subject: [PATCH] Seek On Mavic (#93) * Start of seek on mavic: - Add build targets with LOG_DATA_JSON enabled - remove json lib * Switch between USB serial and HW serial * wip: test with lower bandwidth * use serial_out for seek on jam * serial out * change ports to lilygo port pin --- include/global_config.h | 1 - platformio.ini | 77 +++++++++++++++++++++++++++++++++++++---- src/main.cpp | 46 ++++++++++++------------ 3 files changed, 95 insertions(+), 29 deletions(-) diff --git a/include/global_config.h b/include/global_config.h index a2014f7..8297d73 100644 --- a/include/global_config.h +++ b/include/global_config.h @@ -17,7 +17,6 @@ // 4.8, 5.8, 7.3, 9.7, 11.7, 14.6, 19.5, 23.4, 29.3, 39.0, 46.9, 58.6, // 78.2, 93.8, 117.3, 156.2, 187.2, 234.3, 312.0, 373.6 and 467.0 #define BANDWIDTH 467.0 -#define BANDWIDTH_SX1280 406. // Detection level from the 33 levels. The higher number is more sensitive #define DEFAULT_DRONE_DETECTION_LEVEL 18 diff --git a/platformio.ini b/platformio.ini index 6696f87..7225048 100644 --- a/platformio.ini +++ b/platformio.ini @@ -29,7 +29,6 @@ board_build.f_cpu = 240000000 board_build.filesystem = littlefs lib_deps = ropg/Heltec_ESP32_LoRa_v3@^0.9.1 - bblanchon/ArduinoJson@^7.2.0 ESP Async WebServer build_flags = -DHELTEC_POWER_BUTTON @@ -65,7 +64,6 @@ board_build.f_cpu = 240000000 board_build.filesystem = littlefs lib_deps = ropg/Heltec_ESP32_LoRa_v3@^0.9.1 - bblanchon/ArduinoJson@^7.2.0 ESP Async WebServer build_flags = -DHELTEC_POWER_BUTTON @@ -84,7 +82,6 @@ board_build.f_cpu = 240000000 board_build.filesystem = littlefs lib_deps = ropg/Heltec_ESP32_LoRa_v3@^0.9.1 - bblanchon/ArduinoJson@^7.2.0 RadioLib U8g2 XPowersLib @@ -114,7 +111,6 @@ lib_deps = RadioLib U8g2 XPowersLib - bblanchon/ArduinoJson@^7.2.0 ESP Async WebServer build_flags = -DLILYGO @@ -142,7 +138,6 @@ board_build.f_cpu = 240000000 board_build.filesystem = littlefs lib_deps = ropg/Heltec_ESP32_LoRa_v3@^0.9.1 - bblanchon/ArduinoJson@^7.2.0 RadioLib U8g2 XPowersLib @@ -159,6 +154,7 @@ build_flags = -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_LILYGO_T3_S3_V1_X -DARDUINO_USB_MODE=1 + -DSERIAL_OUT [env:lilygo-T3-v1-6-xs1276] platform = espressif32 @@ -169,7 +165,6 @@ monitor_speed = 115200 board_build.filesystem = littlefs lib_deps = ropg/Heltec_ESP32_LoRa_v3@^0.9.1 - bblanchon/ArduinoJson@^7.2.0 RadioLib U8g2 XPowersLib @@ -271,5 +266,75 @@ lib_deps = ropg/Heltec_ESP32_LoRa_v3@^0.9.1 adafruit/Adafruit ST7735 and ST7789 Library@^1.10.4 +[env:seek-on-mavic-sx1280] +platform = espressif32 +board = t3_s3_v1_x +framework = arduino +upload_speed = 921600 +monitor_speed = 115200 +board_build.f_cpu = 240000000 +board_build.filesystem = littlefs +lib_deps = + ropg/Heltec_ESP32_LoRa_v3@^0.9.1 + RadioLib + U8g2 + XPowersLib + ESP Async WebServer +build_flags = + -DLILYGO + -DT3_S3_V1_2_SX1280_PA + -DARDUINO_LILYGO_T3S3_SX1280_PA + -DESP32 + -DUSING_SX1280PA + -DFREQ_BEGIN=2410 + -DFREQ_END=2452 + -DARDUINO_ARCH_ESP32 + -DARDUINO_USB_CDC_ON_BOOT=1 + -DARDUINO_LILYGO_T3_S3_V1_X + -DARDUINO_USB_MODE=1 + -DLOG_DATA_JSON=1 + -DSERIAL_OUT + -DTX_PIN=43 # TX pin on the Lora board, hook up to RX pin on Pi + -DRX_PIN=16 # not used but still need to be defined + -DSEEK_ON_X=1 # seek on X, so use HW serial port to log JSON + -DBANDWIDTH=4.8 + -DDISABLE_SDCARD + +[env:seek-on-mavic-lr1121] +platform = espressif32 +board = t3_s3_v1_x +framework = arduino +upload_speed = 921600 +monitor_speed = 115200 +board_build.f_cpu = 240000000 +board_build.filesystem = littlefs +lib_deps = + ropg/Heltec_ESP32_LoRa_v3@^0.9.1 + RadioLib + U8g2 + XPowersLib + ESP Async WebServer +build_flags = + -DLILYGO + -DT3_S3_V1_2_LR1121 + -DT3_V1_3_SX1262 + -DARDUINO_LILYGO_T3S3_LR1121 + -DESP32 + -DSAMPLES_RSSI=5 + -DUSING_LR1121 + -DFREQ_BEGIN=2410 + -DFREQ_END=2452 + -DARDUINO_ARCH_ESP32 + -DARDUINO_USB_CDC_ON_BOOT=1 + -DARDUINO_LILYGO_T3_S3_V1_X + -DARDUINO_USB_MODE=1 + -DLOG_DATA_JSON=1 + -DSERIAL_OUT + -DTX_PIN=43 # TX pin on the Lora board, hook up to RX pin on Pi + -DRX_PIN=16 # not used but still need to be defined + -DSEEK_ON_X=1 # seek on X, so use HW serial port to log JSON + -DBANDWIDTH=4.8 + -DDISABLE_SDCARD + [env:native] platform = native diff --git a/src/main.cpp b/src/main.cpp index 771d45d..aa63139 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,9 +25,6 @@ #include "FS.h" #include -#ifdef LOG_DATA_JSON -#include -#endif #include #include #include @@ -233,15 +230,16 @@ uint64_t scan_time = 0; uint64_t scan_start_time = 0; #endif -// Define which UART port to use (0, 1, or 2) +// log data via serial console, JSON format: +// Optionally it can be enabled via this flag, although its recommended to use +// platformio config flag -DLOG_DATA_JSON +// #define LOG_DATA_JSON true + +#ifdef SEEK_ON_X #define SERIAL_PORT 1 -// Define which pins to use -#define TX_PIN 12 -#define RX_PIN 16 // not used - -// Create HardwareSerial instance (UART 1 or 2) HardwareSerial SerialPort(SERIAL_PORT); +#endif // #define WEB_SERVER true @@ -778,8 +776,6 @@ void dumpToCommsTask(void *parameter) #ifdef LOG_DATA_JSON void logToSerialTask(void *parameter) { - JsonDocument doc; - char jsonOutput[200]; uint64_t last_epoch = frequency_scan_result.last_epoch; frequency_scan_result.rssi = -999; @@ -797,12 +793,19 @@ void logToSerialTask(void *parameter) continue; } - doc["low_range_freq"] = frequency_scan_result.begin; - doc["high_range_freq"] = frequency_scan_result.end; - doc["value"] = String(highest_value_scanned); - - serializeJson(doc, jsonOutput); - SerialPort.println(jsonOutput); +#ifdef SEEK_ON_X + SerialPort.printf("{\"low_range_freq\": %" PRIu64 + ", \"high_range_freq\": %" PRIu64 ", " + "\"value\": \"%" PRIi16 "\"}\n", + frequency_scan_result.begin, frequency_scan_result.end, + highest_value_scanned); +#else + Serial.printf("{\"low_range_freq\": %" PRIu64 + ", \"high_range_freq\": %" PRIu64 ", " + "\"value\": \"%" PRIi16 "\"}\n", + frequency_scan_result.begin, frequency_scan_result.end, + highest_value_scanned); +#endif } } } @@ -972,18 +975,17 @@ void setup(void) #ifdef LOG_DATA_JSON Serial.begin(115200); - // Initialize custom Serial port +#ifdef SEEK_ON_X + // Initialize custom Serial port on the hardware using pins // Parameters: baud rate, serial config, RX pin, TX pin SerialPort.begin(115200, SERIAL_8N1, RX_PIN, TX_PIN); #endif +#endif #ifdef LILYGO setupBoards(); // true for disable U8g2 display library delay(500); - Serial.println("Setup LiLybeginSDCardGO board is done"); -#else - // Serial0.begin(115200); // Initialize UART0 - // Serial0.println("Hello, Serial0 (UART0)!"); + Serial.println("Setup LiLyGO board is done"); #endif // LED brightness