mirror of
https://github.com/Genaker/LoraSA.git
synced 2026-03-28 17:42:59 +01:00
Support USB comms on Heltec
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -12,7 +12,7 @@ struct ScanRange
|
||||
|
||||
struct LoRaConfig
|
||||
{
|
||||
uint16_t freq;
|
||||
float freq;
|
||||
uint16_t bw;
|
||||
uint8_t sf;
|
||||
uint8_t cr;
|
||||
|
||||
@@ -34,6 +34,8 @@ lib_deps =
|
||||
build_flags =
|
||||
-DHELTEC_POWER_BUTTON
|
||||
-DHELTEC
|
||||
-DARDUINO_USB_CDC_ON_BOOT=1
|
||||
-DARDUINO_USB_MODE=1
|
||||
|
||||
[env:heltec_wifi_lora_32_V3-OSD]
|
||||
platform = espressif32
|
||||
|
||||
Reference in New Issue
Block a user