Merge branch 'testable' of https://github.com/Genaker/LoraSA into testable

This commit is contained in:
Egor
2024-12-24 14:23:49 -08:00
9 changed files with 87 additions and 60 deletions
+19 -9
View File
@@ -43,28 +43,38 @@ void _onReceive1()
Comms1->_onReceive();
}
#if ARDUINO_USB_MODE
#define IF_CDC_EVENT(e, data) \
arduino_hw_cdc_event_data_t *data = (arduino_hw_cdc_event_data_t *)event_data; \
if (event_base == ARDUINO_HW_CDC_EVENTS && event_id == ARDUINO_HW_CDC_##e)
#else
#define IF_CDC_EVENT(e, data) \
arduino_usb_cdc_event_data_t *data = (arduino_usb_cdc_event_data_t *)event_data; \
if (event_base == ARDUINO_USB_CDC_EVENTS && event_id == ARDUINO_USB_CDC_##e)
#endif
void _onUsbEvent0(void *arg, esp_event_base_t event_base, int32_t event_id,
void *event_data)
{
if (event_base == ARDUINO_HW_CDC_EVENTS)
{
arduino_hw_cdc_event_data_t *data = (arduino_hw_cdc_event_data_t *)event_data;
if (event_id == ARDUINO_HW_CDC_RX_EVENT)
{
_onReceiveUsb(data->rx.len);
}
}
IF_CDC_EVENT(RX_EVENT, data) { _onReceiveUsb(data->rx.len); }
}
bool Comms::initComms(Config &c)
{
bool fine = false;
#ifndef HELTEC
#ifdef ARDUINO_USB_CDC_ON_BOOT
if (c.listen_on_usb.equalsIgnoreCase("readline"))
{
// comms using readline plaintext protocol
HostComms = new ReadlineComms("Host", Serial);
#if ARDUINO_USB_MODE
// if Serial is HWCDC...
Serial.onEvent(ARDUINO_HW_CDC_RX_EVENT, _onUsbEvent0);
#else
// if Serial is USBCDC...
Serial.onEvent(ARDUINO_USB_CDC_RX_EVENT, _onUsbEvent0);
#endif
Serial.begin();
Serial.println("Initialized communications on Serial using readline protocol");
+1 -1
View File
@@ -7,7 +7,7 @@
#include <LiLyGo.h>
#include <config.h>
#ifdef HELTEC
#ifndef ARDUINO_USB_CDC_ON_BOOT
#define SERIAL0 Serial
#else
#define SERIAL0 Serial0
+5 -4
View File
@@ -384,21 +384,22 @@ LoRaConfig *configureLora(String cfg)
}
String k = param.substring(0, j);
param = param.substring(j + 1);
if (k.equalsIgnoreCase("sync_word"))
{
lora->sync_word = (uint8_t)fromHex(param.substring(j + 1));
lora->sync_word = (uint8_t)fromHex(param);
continue;
}
int v = param.substring(j + 1).toInt();
if (k.equalsIgnoreCase("freq"))
{
lora->freq = (uint16_t)v;
lora->freq = param.toFloat();
continue;
}
int v = param.toInt();
if (k.equalsIgnoreCase("bw"))
{
lora->bw = (uint16_t)v;
+3 -1
View File
@@ -12,7 +12,7 @@ struct ScanRange
struct LoRaConfig
{
uint16_t freq;
float freq;
uint16_t bw;
uint8_t sf;
uint8_t cr;
@@ -49,6 +49,8 @@ struct Config
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(NULL), tx_lora(NULL),
// Enable Lora Send:
// rx_lora(configureLora("freq:920")),tx_lora(configureLora("freq:916"))
is_host(false) {};
bool write_config(const char *path);
+5 -2
View File
@@ -1,4 +1,7 @@
#include "models.h"
#include <algorithm>
using namespace std;
#include <cstring>
WaterfallModel::WaterfallModel(size_t w, uint64_t base_dt, size_t m_sz,
@@ -67,13 +70,13 @@ void WaterfallModel::reset(uint64_t t0, size_t w)
* and it gets added to incomplete minute. This gets repeated for incomplete
* minutes, etc.
*/
size_t WaterfallModel::updateModel(uint16_t t, size_t x, uint16_t y)
size_t WaterfallModel::updateModel(uint64_t t, size_t x, uint16_t y)
{
size_t changed = 1;
while (t > times[0])
{
changed = push();
changed = max(changed, push());
}
counts[0][x]++;
+1 -1
View File
@@ -18,7 +18,7 @@ struct WaterfallModel
WaterfallModel(size_t w, uint64_t base_dt, size_t m_sz, const size_t *multiples);
void reset(uint64_t t0, size_t width);
size_t updateModel(uint16_t t, size_t x, uint16_t y);
size_t updateModel(uint64_t t, size_t x, uint16_t y);
size_t push();
char *toString();