Attempt to remove json library and use existing comms

This commit is contained in:
KonradIT
2025-01-21 00:06:09 +01:00
parent cbccc60906
commit 3f69b1820f
6 changed files with 18 additions and 87 deletions

View File

@@ -512,7 +512,6 @@ Use connector and solder to RPI or similar, I'm using a RPI Zero 2. The targets
- **Chip Used**: LilyGO T3 S3 V1.2 with SX1280
- **Frequency**: 2410 MHz to 2452 MHz (Mavic 3 frequency ranges)
- **Unique Features**:
- `-DLOG_DATA_JSON=1` for JSON logging
- `-DDISABLE_SDCARD` to disable SD card and make boot faster
- `-DSERIAL_OUT` to enable serial output
- `-DSEEK_ON_X` to enable seek on jam
@@ -522,7 +521,6 @@ Use connector and solder to RPI or similar, I'm using a RPI Zero 2. The targets
- **Chip Used**: LilyGO T3 S3 V1.2 with LR1121
- **Frequency**: 2410 MHz to 2452 MHz (Mavic 3 frequency ranges)
- **Unique Features**:
- `-DLOG_DATA_JSON=1` for JSON logging
- `-DDISABLE_SDCARD` to disable SD card and make boot faster
- `-DSERIAL_OUT` to enable serial output
- `-DSEEK_ON_X` to enable seek on jam

View File

@@ -75,6 +75,13 @@ bool Comms::initComms(Config &c)
// if Serial is USBCDC...
Serial.onEvent(ARDUINO_USB_CDC_RX_EVENT, _onUsbEvent0);
#endif
#if SEEK_ON_X
#define SERIAL_PORT 1
HardwareSerial SerialPort(SERIAL_PORT);
SerialPort.begin(115200, SERIAL_8N1, RX_PIN, TX_PIN);
Comms1 = new ReadlineComms("Host", SerialPort);
#endif
Serial.begin();
Serial.println("Initialized communications on Serial using readline protocol");

View File

@@ -116,12 +116,6 @@ bool Config::updateConfig(String key, String value)
{
UPDATE_BOOL(print_profile_time, key, value);
if (key.equalsIgnoreCase("log_data_json_interval"))
{
log_data_json_interval = value.toInt();
return true;
}
if (key.equalsIgnoreCase("listen_on_serial0"))
{
listen_on_serial0 = value;
@@ -622,7 +616,6 @@ bool Config::write_config(const char *path)
}
f.println("print_profile_time = " + getConfig("print_profile_time"));
f.println("log_data_json_interval = " + getConfig("log_data_json_interval"));
f.println("listen_on_serial0 = " + getConfig("listen_on_serial0"));
f.println("listen_on_serial1 = " + getConfig("listen_on_serial1"));
f.println("listen_on_usb = " + getConfig("listen_on_usb"));
@@ -652,11 +645,6 @@ String Config::getConfig(String key)
return String(print_profile_time ? "true" : "false");
}
if (key.equalsIgnoreCase("log_data_json_interval"))
{
return String(log_data_json_interval);
}
if (key.equalsIgnoreCase("listen_on_serial0"))
{
return listen_on_serial0;

View File

@@ -202,7 +202,6 @@ struct Config
int samples;
size_t scan_ranges_sz;
ScanRange *scan_ranges;
int log_data_json_interval;
String listen_on_serial0;
String listen_on_serial1;
String listen_on_usb;
@@ -221,11 +220,10 @@ struct Config
Config()
: create_missing_config(CREATE_MISSING_CONFIG), print_profile_time(false),
detection_strategy(String("RSSI")), samples(0), scan_ranges_sz(0),
scan_ranges(NULL), log_data_json_interval(1000),
listen_on_serial0(String("none")), listen_on_serial1(String("readline")),
listen_on_usb(String("readline")), rx_lora(configureLora(DEFAULT_RX)),
tx_lora(configureLora(DEFAULT_TX)), is_host(DEFAULT_IS_LORA_HOST),
uart0(BusConfig::configure(DEFAULT_UART0)),
scan_ranges(NULL), listen_on_serial0(String("none")),
listen_on_serial1(String("readline")), listen_on_usb(String("readline")),
rx_lora(configureLora(DEFAULT_RX)), tx_lora(configureLora(DEFAULT_TX)),
is_host(DEFAULT_IS_LORA_HOST), uart0(BusConfig::configure(DEFAULT_UART0)),
uart1(BusConfig::configure(DEFAULT_UART1)),
spi1(BusConfig::configure(DEFAULT_SPI1)),
wire1(BusConfig::configure(DEFAULT_WIRE1)), lora_enabled(DEFAULT_LORA_ENABLED),

View File

@@ -71,7 +71,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
@@ -97,7 +96,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
@@ -453,10 +451,9 @@ build_flags =
-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
-DRX_PIN=44 # 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
@@ -492,7 +489,7 @@ build_flags =
-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
-DRX_PIN=44 # 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

View File

@@ -383,17 +383,6 @@ uint64_t scan_time = 0;
uint64_t scan_start_time = 0;
#endif
// 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
HardwareSerial SerialPort(SERIAL_PORT);
#endif
// #define WEB_SERVER true
uint64_t x, y, w = WATERFALL_START, i = 0;
@@ -977,7 +966,6 @@ struct frequency_scan_result
size_t readings_sz;
} frequency_scan_result;
TaskHandle_t logToSerial = NULL;
TaskHandle_t dumpToComms = NULL;
void eventListenerForReport(void *arg, Event &e)
@@ -1040,11 +1028,6 @@ void eventListenerForReport(void *arg, Event &e)
if (e.type == EventType::SCAN_TASK_COMPLETE)
{
// notify async communication that the data is ready
if (logToSerial != NULL)
{
xTaskNotifyGive(logToSerial);
}
if (dumpToComms != NULL)
{
xTaskNotifyGive(dumpToComms);
@@ -1098,49 +1081,16 @@ void dumpToCommsTask(void *parameter)
Comms1->send(m);
}
#ifdef SEEK_ON_X
if (Comms1 != NULL)
Comms1->send(m);
#endif
m.payload.dump.sz =
0; // dump is shared, so should not delete arrays in destructor
}
}
#ifdef LOG_DATA_JSON
void logToSerialTask(void *parameter)
{
uint64_t last_epoch = frequency_scan_result.last_epoch;
frequency_scan_result.rssi = -999;
for (;;)
{
ulTaskNotifyTake(true, pdMS_TO_TICKS(config.log_data_json_interval));
if (frequency_scan_result.begin != frequency_scan_result.end ||
frequency_scan_result.last_epoch != last_epoch)
{
int16_t highest_value_scanned = frequency_scan_result.rssi;
frequency_scan_result.rssi = -999;
last_epoch = frequency_scan_result.last_epoch;
if (highest_value_scanned == -999)
{
continue;
}
#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
}
}
}
#endif
void drone_sound_alarm(void *arg, Event &e);
void draw360Scale(int start = 0, int end = 360, int width = 128, int height = 64)
@@ -1640,9 +1590,6 @@ void setup(void)
osd.clear();
#endif
#ifdef LOG_DATA_JSON
xTaskCreate(logToSerialTask, "LOG_DATA_JSON", 2048, NULL, 1, &logToSerial);
#endif
xTaskCreate(dumpToCommsTask, "DUMP_RESPONSE_PROCESS", 2048, NULL, 1, &dumpToComms);
r.trigger_level = TRIGGER_LEVEL;
@@ -2879,10 +2826,6 @@ void doScan()
// mark freq end ... will shift right to last detected range
drone_detected_frequency_end = r.current_frequency;
#ifdef LOG_DATA_JSON
frequency_scan_result.begin = drone_detected_frequency_start;
frequency_scan_result.end = drone_detected_frequency_end;
#endif
if (DRAW_DETECTION_TICKS == true)
{
// draw vertical line on top of display for "drone detected"