Skip to content

Commit 49e7516

Browse files
Add KISS UART support
1 parent f445b5a commit 49e7516

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

examples/kiss_modem/main.cpp

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#elif defined(ESP32)
1212
#include <SPIFFS.h>
1313
#endif
14+
#if defined(KISS_UART_RX) && defined(KISS_UART_TX)
15+
#include <HardwareSerial.h>
16+
#endif
1417

1518
#define NOISE_FLOOR_CALIB_INTERVAL_MS 2000
1619
#define AGC_RESET_INTERVAL_MS 30000
@@ -91,14 +94,35 @@ void setup() {
9194
rng.begin(radio_get_rng_seed());
9295
loadOrCreateIdentity();
9396

97+
sensors.begin();
98+
99+
#if defined(KISS_UART_RX) && defined(KISS_UART_TX)
100+
#if defined(ESP32)
101+
Serial1.setPins(KISS_UART_RX, KISS_UART_TX);
102+
Serial1.begin(115200);
103+
#elif defined(NRF52_PLATFORM)
104+
((Uart *)&Serial1)->setPins(KISS_UART_RX, KISS_UART_TX);
105+
Serial1.begin(115200);
106+
#elif defined(RP2040_PLATFORM)
107+
((SerialUART *)&Serial1)->setRX(KISS_UART_RX);
108+
((SerialUART *)&Serial1)->setTX(KISS_UART_TX);
109+
Serial1.begin(115200);
110+
#elif defined(STM32_PLATFORM)
111+
((HardwareSerial *)&Serial1)->setRx(KISS_UART_RX);
112+
((HardwareSerial *)&Serial1)->setTx(KISS_UART_TX);
113+
Serial1.begin(115200);
114+
#else
115+
#error "KISS UART not supported on this platform"
116+
#endif
117+
modem = new KissModem(Serial1, identity, rng, radio_driver, board, sensors);
118+
#else
94119
Serial.begin(115200);
95120
uint32_t start = millis();
96121
while (!Serial && millis() - start < 3000) delay(10);
97122
delay(100);
98-
99-
sensors.begin();
100-
101123
modem = new KissModem(Serial, identity, rng, radio_driver, board, sensors);
124+
#endif
125+
102126
modem->setRadioCallback(onSetRadio);
103127
modem->setTxPowerCallback(onSetTxPower);
104128
modem->setGetCurrentRssiCallback(onGetCurrentRssi);

0 commit comments

Comments
 (0)