diff --git a/arch/portduino/portduino.ini b/arch/portduino/portduino.ini
index 98bb309b9..ac7ba13ba 100644
--- a/arch/portduino/portduino.ini
+++ b/arch/portduino/portduino.ini
@@ -1,6 +1,6 @@
; The Portduino based sim environment on top of any host OS, all hardware will be simulated
[portduino_base]
-platform = https://github.com/meshtastic/platform-native.git#8a66ef82cf38a4135d85cbb5043d0e8ebbb8ba17
+platform = https://github.com/meshtastic/platform-native.git#04435d06e39916a6c019d511518d8e95c659dfbd
framework = arduino
build_src_filter =
@@ -28,4 +28,8 @@ build_flags =
${arduino_base.build_flags}
-fPIC
-Isrc/platform/portduino
- -DRADIOLIB_EEPROM_UNSUPPORTED
\ No newline at end of file
+ -DRADIOLIB_EEPROM_UNSUPPORTED
+ -DPORTDUINO_LINUX_HARDWARE
+ -lbluetooth
+ -lgpiod
+ -lyaml-cpp
\ No newline at end of file
diff --git a/bin/config-dist.yaml b/bin/config-dist.yaml
index 4079e7676..99a08ad87 100644
--- a/bin/config-dist.yaml
+++ b/bin/config-dist.yaml
@@ -14,6 +14,12 @@ Lora:
# IRQ: 17
# Reset: 22
+# Module: sx1262 # pinedio
+# CS: 0
+# IRQ: 10
+# Busy: 11
+# spidev: spidev0.1
+
# Module: RF95 # Adafruit RFM9x
# Reset: 25
# CS: 7
@@ -31,10 +37,19 @@ Lora:
# Busy: 20
# Reset: 18
+# DIO3_TCXO_VOLTAGE: true # the Waveshare Core1262 and others are known to need this setting
+
+# TXen: x # TX and RX enable pins
+# RXen: x
+
### Set gpio chip to use in /dev/. Defaults to 0.
### Notably the Raspberry Pi 5 puts the GPIO header on gpiochip4
# gpiochip: 4
+### Specify the SPI device to use in /dev/. Defaults to spidev0.0
+### Some devices, like the pinedio, may require spidev0.1 as a workaround.
+# spidev: spidev0.0
+
### Define GPIO buttons here:
GPIO:
@@ -58,6 +73,18 @@ Display:
# Height: 320
# Reset: 27
# Rotate: true
+# Invert: true
+
+### Waveshare 1.44inch LCD HAT
+# Panel: ST7735S
+# CS: 8 #Chip Select
+# DC: 25 # Data/Command pin
+# Backlight: 24
+# Width: 128
+# Height: 128
+# Reset: 27
+# OffsetX: 0
+# OffsetY: 0
Touchscreen:
# Module: XPT2046
diff --git a/src/ButtonThread.h b/src/ButtonThread.h
index 7138d3b6a..3301df097 100644
--- a/src/ButtonThread.h
+++ b/src/ButtonThread.h
@@ -38,7 +38,7 @@ class ButtonThread : public concurrency::OSThread
#ifdef BUTTON_PIN_TOUCH
OneButton userButtonTouch;
#endif
-#if defined(ARCH_RASPBERRY_PI)
+#if defined(ARCH_PORTDUINO)
OneButton userButton;
#endif
static bool shutdown_on_long_stop;
@@ -49,8 +49,8 @@ class ButtonThread : public concurrency::OSThread
// callback returns the period for the next callback invocation (or 0 if we should no longer be called)
ButtonThread() : OSThread("Button")
{
-#if defined(ARCH_RASPBERRY_PI) || defined(BUTTON_PIN)
-#if defined(ARCH_RASPBERRY_PI)
+#if defined(ARCH_PORTDUINO) || defined(BUTTON_PIN)
+#if defined(ARCH_PORTDUINO)
if (settingsMap.count(user) != 0 && settingsMap[user] != RADIOLIB_NC)
userButton = OneButton(settingsMap[user], true, true);
#elif defined(BUTTON_PIN)
@@ -68,7 +68,7 @@ class ButtonThread : public concurrency::OSThread
userButton.attachMultiClick(userButtonMultiPressed);
userButton.attachLongPressStart(userButtonPressedLongStart);
userButton.attachLongPressStop(userButtonPressedLongStop);
-#if defined(ARCH_RASPBERRY_PI)
+#if defined(ARCH_PORTDUINO)
if (settingsMap.count(user) != 0 && settingsMap[user] != RADIOLIB_NC)
wakeOnIrq(settingsMap[user], FALLING);
#else
@@ -105,7 +105,7 @@ class ButtonThread : public concurrency::OSThread
#if defined(BUTTON_PIN)
userButton.tick();
canSleep &= userButton.isIdle();
-#elif defined(ARCH_RASPBERRY_PI)
+#elif defined(ARCH_PORTDUINO)
if (settingsMap.count(user) != 0 && settingsMap[user] != RADIOLIB_NC) {
userButton.tick();
canSleep &= userButton.isIdle();
@@ -143,7 +143,7 @@ class ButtonThread : public concurrency::OSThread
powerFSM.trigger(EVENT_PRESS);
}
#endif
-#if defined(ARCH_RASPBERRY_PI)
+#if defined(ARCH_PORTDUINO)
if ((settingsMap.count(user) != 0 && settingsMap[user] != RADIOLIB_NC) &&
(settingsMap[user] != moduleConfig.canned_message.inputbroker_pin_press) ||
!moduleConfig.canned_message.enabled) {
diff --git a/src/RedirectablePrint.cpp b/src/RedirectablePrint.cpp
index 2d73c7c9b..dfb3af17e 100644
--- a/src/RedirectablePrint.cpp
+++ b/src/RedirectablePrint.cpp
@@ -100,9 +100,9 @@ size_t RedirectablePrint::log(const char *logLevel, const char *format, ...)
int min = (hms % SEC_PER_HOUR) / SEC_PER_MIN;
int sec = (hms % SEC_PER_HOUR) % SEC_PER_MIN; // or hms % SEC_PER_MIN
- r += printf("%s | %02d:%02d:%02d %u ", logLevel, hour, min, sec, millis() / 1000);
+ r += ::printf("%s | %02d:%02d:%02d %u ", logLevel, hour, min, sec, millis() / 1000);
} else
- r += printf("%s | ??:??:?? %u ", logLevel, millis() / 1000);
+ r += ::printf("%s | ??:??:?? %u ", logLevel, millis() / 1000);
auto thread = concurrency::OSThread::currentThread;
if (thread) {
diff --git a/src/detect/ScanI2CTwoWire.cpp b/src/detect/ScanI2CTwoWire.cpp
index a5c932f1f..990fb36ea 100644
--- a/src/detect/ScanI2CTwoWire.cpp
+++ b/src/detect/ScanI2CTwoWire.cpp
@@ -2,7 +2,7 @@
#include "concurrency/LockGuard.h"
#include "configuration.h"
-#if defined(ARCH_RASPBERRY_PI)
+#if defined(ARCH_PORTDUINO)
#include "linux/LinuxHardwareI2C.h"
#endif
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp
index fee9393b0..0e0b5f8b6 100644
--- a/src/gps/GPS.cpp
+++ b/src/gps/GPS.cpp
@@ -16,7 +16,7 @@
#define GPS_RESET_MODE HIGH
#endif
-#if defined(NRF52840_XXAA) || defined(NRF52833_XXAA) || defined(ARCH_ESP32) || defined(ARCH_RASPBERRY_PI)
+#if defined(NRF52840_XXAA) || defined(NRF52833_XXAA) || defined(ARCH_ESP32) || defined(aLinuxInputImpl)
HardwareSerial *GPS::_serial_gps = &Serial1;
#else
HardwareSerial *GPS::_serial_gps = NULL;
@@ -924,7 +924,7 @@ GPS *GPS::createGps()
if (!_en_gpio)
_en_gpio = PIN_GPS_EN;
#endif
-#ifdef ARCH_RASPBERRY_PI
+#ifdef ARCH_PORTDUINO
if (!settingsMap[has_gps])
return nullptr;
#endif
@@ -1286,4 +1286,4 @@ int32_t GPS::disable()
setAwake(false);
return INT32_MAX;
-}
+}
\ No newline at end of file
diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp
index a7fcd0c34..00880ad05 100644
--- a/src/graphics/Screen.cpp
+++ b/src/graphics/Screen.cpp
@@ -43,7 +43,7 @@ along with this program. If not, see .
#include "sleep.h"
#include "target_specific.h"
-#if HAS_WIFI && !defined(ARCH_RASPBERRY_PI)
+#if HAS_WIFI && !defined(ARCH_PORTDUINO)
#include "mesh/wifi/WiFiAPClient.h"
#endif
@@ -52,7 +52,7 @@ along with this program. If not, see .
#include "modules/esp32/StoreForwardModule.h"
#endif
-#if ARCH_RASPBERRY_PI
+#if ARCH_PORTDUINO
#include "platform/portduino/PortduinoGlue.h"
#endif
@@ -930,8 +930,8 @@ Screen::Screen(ScanI2C::DeviceAddress address, meshtastic_Config_DisplayConfig_O
#elif defined(USE_ST7567)
dispdev = new ST7567Wire(address.address, -1, -1, geometry,
(address.port == ScanI2C::I2CPort::WIRE1) ? HW_I2C::I2C_TWO : HW_I2C::I2C_ONE);
-#elif ARCH_RASPBERRY_PI
- if (settingsMap[displayPanel] == st7789) {
+#elif ARCH_PORTDUINO
+ if (settingsMap[displayPanel] != no_screen) {
LOG_DEBUG("Making TFTDisplay!\n");
dispdev = new TFTDisplay(address.address, -1, -1, geometry,
(address.port == ScanI2C::I2CPort::WIRE1) ? HW_I2C::I2C_TWO : HW_I2C::I2C_ONE);
@@ -976,7 +976,7 @@ void Screen::handleSetOn(bool on)
#ifdef T_WATCH_S3
PMU->enablePowerOutput(XPOWERS_ALDO2);
#endif
-#if !ARCH_RASPBERRY_PI
+#if !ARCH_PORTDUINO
dispdev->displayOn();
#endif
dispdev->displayOn();
@@ -1060,7 +1060,7 @@ void Screen::setup()
uint8_t dmac[6];
getMacAddr(dmac);
snprintf(ourId, sizeof(ourId), "%02x%02x", dmac[4], dmac[5]);
-#if ARCH_RASPBERRY_PI
+#if ARCH_PORTDUINO
handleSetOn(false); // force clean init
#endif
@@ -1075,7 +1075,7 @@ void Screen::setup()
#endif
serialSinceMsec = millis();
-#if ARCH_RASPBERRY_PI
+#if ARCH_PORTDUINO
if (settingsMap[touchscreenModule]) {
touchScreenImpl1 =
new TouchScreenImpl1(dispdev->getWidth(), dispdev->getHeight(), static_cast(dispdev)->getTouch);
@@ -1344,7 +1344,7 @@ void Screen::setFrames()
// call a method on debugInfoScreen object (for more details)
normalFrames[numframes++] = &Screen::drawDebugInfoSettingsTrampoline;
-#if HAS_WIFI && !defined(ARCH_RASPBERRY_PI)
+#if HAS_WIFI && !defined(ARCH_PORTDUINO)
if (isWifiAvailable()) {
// call a method on debugInfoScreen object (for more details)
normalFrames[numframes++] = &Screen::drawDebugInfoWiFiTrampoline;
@@ -1588,7 +1588,7 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
#endif
} else {
// TODO: Raspberry Pi supports more than just the one screen size
-#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(ST7789_CS) || ARCH_RASPBERRY_PI) && \
+#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(ST7789_CS) || ARCH_PORTDUINO) && \
!defined(DISPLAY_FORCE_SMALL_FONTS)
display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 3 + FONT_HEIGHT_SMALL, 12, 8,
imgInfoL1);
@@ -1615,7 +1615,7 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
// Jm
void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
{
-#if HAS_WIFI && !defined(ARCH_RASPBERRY_PI)
+#if HAS_WIFI && !defined(ARCH_PORTDUINO)
const char *wifiName = config.network.wifi_ssid;
display->setFont(FONT_SMALL);
diff --git a/src/graphics/TFTDisplay.cpp b/src/graphics/TFTDisplay.cpp
index df1aefb3d..9b107ba52 100644
--- a/src/graphics/TFTDisplay.cpp
+++ b/src/graphics/TFTDisplay.cpp
@@ -1,6 +1,6 @@
#include "configuration.h"
#include "main.h"
-#if ARCH_RASPBERRY_PI
+#if ARCH_PORTDUINO
#include "platform/portduino/PortduinoGlue.h"
#endif
@@ -331,7 +331,7 @@ static LGFX *tft = nullptr;
#include // Graphics and font library for ILI9341 driver chip
static TFT_eSPI *tft = nullptr; // Invoke library, pins defined in User_Setup.h
-#elif ARCH_RASPBERRY_PI
+#elif ARCH_PORTDUINO
#include // Graphics and font library for ST7735 driver chip
class LGFX : public lgfx::LGFX_Device
@@ -344,8 +344,12 @@ class LGFX : public lgfx::LGFX_Device
public:
LGFX(void)
{
-
- _panel_instance = new lgfx::Panel_ST7789;
+ if (settingsMap[displayPanel] == st7789)
+ _panel_instance = new lgfx::Panel_ST7789;
+ else if (settingsMap[displayPanel] == st7735)
+ _panel_instance = new lgfx::Panel_ST7735;
+ else if (settingsMap[displayPanel] == st7735s)
+ _panel_instance = new lgfx::Panel_ST7735S;
auto buscfg = _bus_instance.config();
buscfg.spi_mode = 0;
@@ -356,19 +360,14 @@ class LGFX : public lgfx::LGFX_Device
auto cfg = _panel_instance->config(); // Gets a structure for display panel settings.
LOG_DEBUG("Height: %d, Width: %d \n", settingsMap[displayHeight], settingsMap[displayWidth]);
- cfg.pin_cs = settingsMap[displayCS]; // Pin number where CS is connected (-1 = disable)
+ cfg.pin_cs = settingsMap[displayCS]; // Pin number where CS is connected (-1 = disable)
+ cfg.pin_rst = settingsMap[displayReset];
cfg.panel_width = settingsMap[displayWidth]; // actual displayable width
cfg.panel_height = settingsMap[displayHeight]; // actual displayable height
- cfg.offset_x = 0; // Panel offset amount in X direction
- cfg.offset_y = 0; // Panel offset amount in Y direction
+ cfg.offset_x = settingsMap[displayOffsetX]; // Panel offset amount in X direction
+ cfg.offset_y = settingsMap[displayOffsetY]; // Panel offset amount in Y direction
cfg.offset_rotation = 0; // Rotation direction value offset 0~7 (4~7 is mirrored)
- cfg.dummy_read_pixel = 9; // Number of bits for dummy read before pixel readout
- cfg.dummy_read_bits = 1; // Number of bits for dummy read before non-pixel data read
- cfg.readable = true; // Set to true if data can be read
- cfg.invert = true; // Set to true if the light/darkness of the panel is reversed
- cfg.rgb_order = false; // Set to true if the panel's red and blue are swapped
- cfg.dlen_16bit = false; // Set to true for panels that transmit data length in 16-bit units with 16-bit parallel or SPI
- cfg.bus_shared = true; // If the bus is shared with the SD card, set to true (bus control with drawJpgFile etc.)
+ cfg.invert = settingsMap[displayInvert]; // Set to true if the light/darkness of the panel is reversed
_panel_instance->config(cfg);
@@ -399,7 +398,7 @@ class LGFX : public lgfx::LGFX_Device
static LGFX *tft = nullptr;
#endif
-#if defined(ST7735_CS) || defined(ST7789_CS) || defined(ILI9341_DRIVER) || defined(RAK14014) || ARCH_RASPBERRY_PI
+#if defined(ST7735_CS) || defined(ST7789_CS) || defined(ILI9341_DRIVER) || defined(RAK14014) || ARCH_PORTDUINO
#include "SPILock.h"
#include "TFTDisplay.h"
#include
@@ -407,7 +406,7 @@ static LGFX *tft = nullptr;
TFTDisplay::TFTDisplay(uint8_t address, int sda, int scl, OLEDDISPLAY_GEOMETRY geometry, HW_I2C i2cBus)
{
LOG_DEBUG("TFTDisplay!\n");
-#if ARCH_RASPBERRY_PI
+#if ARCH_PORTDUINO
if (settingsMap[displayRotate]) {
setGeometry(GEOMETRY_RAWMODE, settingsMap[configNames::displayHeight], settingsMap[configNames::displayWidth]);
} else {
@@ -460,7 +459,7 @@ void TFTDisplay::sendCommand(uint8_t com)
// handle display on/off directly
switch (com) {
case DISPLAYON: {
-#if ARCH_RASPBERRY_PI
+#if ARCH_PORTDUINO
display(true);
if (settingsMap[displayBacklight] > 0)
digitalWrite(settingsMap[displayBacklight], TFT_BACKLIGHT_ON);
@@ -492,7 +491,7 @@ void TFTDisplay::sendCommand(uint8_t com)
break;
}
case DISPLAYOFF: {
-#if ARCH_RASPBERRY_PI
+#if ARCH_PORTDUINO
tft->clear();
if (settingsMap[displayBacklight] > 0)
digitalWrite(settingsMap[displayBacklight], !TFT_BACKLIGHT_ON);
diff --git a/src/graphics/images.h b/src/graphics/images.h
index 7f3cd46fc..207fc3a86 100644
--- a/src/graphics/images.h
+++ b/src/graphics/images.h
@@ -14,7 +14,7 @@ const uint8_t imgUser[] PROGMEM = {0x3C, 0x42, 0x99, 0xA5, 0xA5, 0x99, 0x42, 0x3
const uint8_t imgPositionEmpty[] PROGMEM = {0x20, 0x30, 0x28, 0x24, 0x42, 0xFF};
const uint8_t imgPositionSolid[] PROGMEM = {0x20, 0x30, 0x38, 0x3C, 0x7E, 0xFF};
-#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(ST7789_CS) || ARCH_RASPBERRY_PI) && \
+#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS) || defined(ST7789_CS) || ARCH_PORTDUINO) && \
!defined(DISPLAY_FORCE_SMALL_FONTS)
const uint8_t imgQuestionL1[] PROGMEM = {0xff, 0x01, 0x01, 0x32, 0x7b, 0x49, 0x49, 0x6f, 0x26, 0x01, 0x01, 0xff};
const uint8_t imgQuestionL2[] PROGMEM = {0x0f, 0x08, 0x08, 0x08, 0x06, 0x0f, 0x0f, 0x06, 0x08, 0x08, 0x08, 0x0f};
diff --git a/src/input/LinuxInput.cpp b/src/input/LinuxInput.cpp
index ea588c4bf..d2a94e94e 100644
--- a/src/input/LinuxInput.cpp
+++ b/src/input/LinuxInput.cpp
@@ -1,7 +1,6 @@
-#if ARCH_RASPBERRY_PI
-#include "LinuxInput.h"
#include "configuration.h"
-
+#if ARCH_PORTDUINO
+#include "LinuxInput.h"
#include "platform/portduino/PortduinoGlue.h"
#include
#include
diff --git a/src/input/LinuxInput.h b/src/input/LinuxInput.h
index c7f011379..aa1e8e340 100644
--- a/src/input/LinuxInput.h
+++ b/src/input/LinuxInput.h
@@ -1,5 +1,5 @@
#pragma once
-#if ARCH_RASPBERRY_PI
+#if ARCH_PORTDUINO
#include "InputBroker.h"
#include "concurrency/OSThread.h"
#include
diff --git a/src/input/LinuxInputImpl.cpp b/src/input/LinuxInputImpl.cpp
index d12f457ec..4ddda1923 100644
--- a/src/input/LinuxInputImpl.cpp
+++ b/src/input/LinuxInputImpl.cpp
@@ -1,6 +1,7 @@
-#if ARCH_RASPBERRY_PI
-#include "LinuxInputImpl.h"
+#include "configuration.h"
+#if ARCH_PORTDUINO
#include "InputBroker.h"
+#include "LinuxInputImpl.h"
LinuxInputImpl *aLinuxInputImpl;
diff --git a/src/input/LinuxInputImpl.h b/src/input/LinuxInputImpl.h
index b5bfdc4c2..e734b0294 100644
--- a/src/input/LinuxInputImpl.h
+++ b/src/input/LinuxInputImpl.h
@@ -1,4 +1,4 @@
-#ifdef ARCH_RASPBERRY_PI
+#ifdef ARCH_PORTDUINO
#pragma once
#include "LinuxInput.h"
#include "main.h"
diff --git a/src/input/TouchScreenImpl1.cpp b/src/input/TouchScreenImpl1.cpp
index 145033c95..3e4ed4163 100644
--- a/src/input/TouchScreenImpl1.cpp
+++ b/src/input/TouchScreenImpl1.cpp
@@ -4,7 +4,7 @@
#include "configuration.h"
#include "modules/ExternalNotificationModule.h"
-#ifdef ARCH_RASPBERRY_PI
+#ifdef ARCH_PORTDUINO
#include "platform/portduino/PortduinoGlue.h"
#endif
@@ -17,7 +17,7 @@ TouchScreenImpl1::TouchScreenImpl1(uint16_t width, uint16_t height, bool (*getTo
void TouchScreenImpl1::init()
{
-#if ARCH_RASPBERRY_PI
+#if ARCH_PORTDUINO
if (settingsMap[touchscreenModule]) {
TouchScreenBase::init(true);
inputBroker->registerSource(this);
diff --git a/src/input/kbI2cBase.cpp b/src/input/kbI2cBase.cpp
index 366e7fbb1..1dba4e34d 100644
--- a/src/input/kbI2cBase.cpp
+++ b/src/input/kbI2cBase.cpp
@@ -187,7 +187,7 @@ int32_t KbI2cBase::runOnce()
i2cBus->requestFrom((int)cardkb_found.address, 1);
- while (i2cBus->available()) {
+ if (i2cBus->available()) {
char c = i2cBus->read();
InputEvent e;
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
@@ -222,7 +222,11 @@ int32_t KbI2cBase::runOnce()
case 0x00: // nopress
e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
break;
- default: // all other keys
+ default: // all other keys
+ if (c > 127) { // bogus key value
+ e.inputEvent = meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
+ break;
+ }
e.inputEvent = ANYKEY;
e.kbchar = c;
break;
@@ -238,4 +242,4 @@ int32_t KbI2cBase::runOnce()
LOG_WARN("Unknown kb_model 0x%02x\n", kb_model);
}
return 300;
-}
+}
\ No newline at end of file
diff --git a/src/main.cpp b/src/main.cpp
index 38c35cf15..a0246afe0 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -66,7 +66,7 @@ NRF52Bluetooth *nrf52Bluetooth;
#include "platform/portduino/SimRadio.h"
#endif
-#ifdef ARCH_RASPBERRY_PI
+#ifdef ARCH_PORTDUINO
#include "linux/LinuxHardwareI2C.h"
#include "platform/portduino/PortduinoGlue.h"
#include
@@ -74,7 +74,7 @@ NRF52Bluetooth *nrf52Bluetooth;
#include
#endif
-#if HAS_BUTTON || defined(ARCH_RASPBERRY_PI)
+#if HAS_BUTTON || defined(ARCH_PORTDUINO)
#include "ButtonThread.h"
#endif
#include "PowerFSMThread.h"
@@ -141,32 +141,12 @@ std::pair nodeTelemetrySensorsMap[_meshtastic_TelemetrySenso
Router *router = NULL; // Users of router don't care what sort of subclass implements that API
-#ifdef ARCH_RASPBERRY_PI
-void getPiMacAddr(uint8_t *dmac)
-{
- std::fstream macIdentity;
- macIdentity.open("/sys/kernel/debug/bluetooth/hci0/identity", std::ios::in);
- std::string macLine;
- getline(macIdentity, macLine);
- macIdentity.close();
-
- dmac[0] = strtol(macLine.substr(0, 2).c_str(), NULL, 16);
- dmac[1] = strtol(macLine.substr(3, 2).c_str(), NULL, 16);
- dmac[2] = strtol(macLine.substr(6, 2).c_str(), NULL, 16);
- dmac[3] = strtol(macLine.substr(9, 2).c_str(), NULL, 16);
- dmac[4] = strtol(macLine.substr(12, 2).c_str(), NULL, 16);
- dmac[5] = strtol(macLine.substr(15, 2).c_str(), NULL, 16);
-}
-#endif
-
const char *getDeviceName()
{
uint8_t dmac[6];
-#ifdef ARCH_RASPBERRY_PI
- getPiMacAddr(dmac);
-#else
+
getMacAddr(dmac);
-#endif
+
// Meshtastic_ab3c or Shortname_abcd
static char name[20];
snprintf(name, sizeof(name), "%02x%02x", dmac[4], dmac[5]);
@@ -211,13 +191,13 @@ static int32_t ledBlinker()
uint32_t timeLastPowered = 0;
-#if HAS_BUTTON || defined(ARCH_RASPBERRY_PI)
+#if HAS_BUTTON || defined(ARCH_PORTDUINO)
bool ButtonThread::shutdown_on_long_stop = false;
#endif
static Periodic *ledPeriodic;
static OSThread *powerFSMthread;
-#if HAS_BUTTON || defined(ARCH_RASPBERRY_PI)
+#if HAS_BUTTON || defined(ARCH_PORTDUINO)
static OSThread *buttonThread;
uint32_t ButtonThread::longPressTime = 0;
#endif
@@ -613,7 +593,7 @@ void setup()
} else
router = new ReliableRouter();
-#if HAS_BUTTON || defined(ARCH_RASPBERRY_PI)
+#if HAS_BUTTON || defined(ARCH_PORTDUINO)
// Buttons. Moved here cause we need NodeDB to be initialized
buttonThread = new ButtonThread();
#endif
@@ -664,12 +644,14 @@ void setup()
pinMode(LORA_CS, OUTPUT);
digitalWrite(LORA_CS, HIGH);
SPI1.begin(false);
-#else // HW_SPI1_DEVICE
+#else // HW_SPI1_DEVICE
SPI.setSCK(LORA_SCK);
SPI.setTX(LORA_MOSI);
SPI.setRX(LORA_MISO);
SPI.begin(false);
-#endif // HW_SPI1_DEVICE
+#endif // HW_SPI1_DEVICE
+#elif ARCH_PORTDUINO
+ SPI.begin(settingsStrings[spidev].c_str());
#elif !defined(ARCH_ESP32) // ARCH_RP2040
SPI.begin();
#else
@@ -715,7 +697,7 @@ void setup()
// the current region name)
#if defined(ST7735_CS) || defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7789_CS)
screen->setup();
-#elif ARCH_RASPBERRY_PI
+#elif defined(ARCH_PORTDUINO)
if (screen_found.port != ScanI2C::I2CPort::NO_I2C || settingsMap[displayPanel]) {
screen->setup();
}
@@ -732,7 +714,7 @@ void setup()
digitalWrite(SX126X_ANT_SW, 1);
#endif
-#ifdef ARCH_RASPBERRY_PI
+#ifdef ARCH_PORTDUINO
if (settingsMap[use_sx1262]) {
if (!rIf) {
LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings);
@@ -822,7 +804,7 @@ void setup()
}
#endif
-#if defined(USE_SX1262) && !defined(ARCH_RASPBERRY_PI)
+#if defined(USE_SX1262) && !defined(ARCH_PORTDUINO)
if (!rIf) {
rIf = new SX1262Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY);
if (!rIf->init()) {
@@ -997,4 +979,4 @@ void loop()
mainDelay.delay(delayMsec);
}
// if (didWake) LOG_DEBUG("wake!\n");
-}
+}
\ No newline at end of file
diff --git a/src/main.h b/src/main.h
index 8a646c80b..1a93298aa 100644
--- a/src/main.h
+++ b/src/main.h
@@ -62,7 +62,6 @@ extern graphics::Screen *screen;
// Return a human readable string of the form "Meshtastic_ab13"
const char *getDeviceName();
-void getPiMacAddr(uint8_t *dmac);
extern uint32_t timeLastPowered;
diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp
index 4de79de0b..1a619f34e 100644
--- a/src/mesh/NodeDB.cpp
+++ b/src/mesh/NodeDB.cpp
@@ -27,7 +27,7 @@
#include
#endif
-#ifdef ARCH_RASPBERRY_PI
+#ifdef ARCH_PORTDUINO
#include "platform/portduino/PortduinoGlue.h"
#endif
@@ -195,7 +195,7 @@ void NodeDB::installDefaultConfig()
config.bluetooth.fixed_pin = defaultBLEPin;
#if defined(ST7735_CS) || defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7789_CS)
bool hasScreen = true;
-#elif ARCH_RASPBERRY_PI
+#elif ARCH_PORTDUINO
bool hasScreen = false;
if (settingsMap[displayPanel])
hasScreen = true;
@@ -464,11 +464,8 @@ void NodeDB::init()
*/
void NodeDB::pickNewNodeNum()
{
-#ifdef ARCH_RASPBERRY_PI
- getPiMacAddr(ourMacAddr); // Make sure ourMacAddr is set
-#else
+
getMacAddr(ourMacAddr); // Make sure ourMacAddr is set
-#endif
// Pick an initial nodenum based on the macaddr
NodeNum nodeNum = (ourMacAddr[2] << 24) | (ourMacAddr[3] << 16) | (ourMacAddr[4] << 8) | ourMacAddr[5];
diff --git a/src/mesh/RF95Interface.cpp b/src/mesh/RF95Interface.cpp
index d7f319f8e..72e0f823f 100644
--- a/src/mesh/RF95Interface.cpp
+++ b/src/mesh/RF95Interface.cpp
@@ -4,6 +4,10 @@
#include "configuration.h"
#include "error.h"
+#if ARCH_PORTDUINO
+#include "PortduinoGlue.h"
+#endif
+
#define MAX_POWER 20
// if we use 20 we are limited to 1% duty cycle or hw might overheat. For continuous operation set a limit of 17
// In theory up to 27 dBm is possible, but the modules installed in most radios can cope with a max of 20. So BIG WARNING
@@ -23,10 +27,18 @@ void RF95Interface::setTransmitEnable(bool txon)
{
#ifdef RF95_TXEN
digitalWrite(RF95_TXEN, txon ? 1 : 0);
+#elif ARCH_PORTDUINO
+ if (settingsMap[txen] != RADIOLIB_NC) {
+ digitalWrite(settingsMap[txen], txon ? 1 : 0);
+ }
#endif
#ifdef RF95_RXEN
digitalWrite(RF95_RXEN, txon ? 0 : 1);
+#elif ARCH_PORTDUINO
+ if (settingsMap[rxen] != RADIOLIB_NC) {
+ digitalWrite(settingsMap[rxen], txon ? 0 : 1);
+ }
#endif
}
@@ -62,6 +74,16 @@ bool RF95Interface::init()
#ifdef RF95_RXEN
pinMode(RF95_RXEN, OUTPUT);
digitalWrite(RF95_RXEN, 1);
+#endif
+#if ARCH_PORTDUINO
+ if (settingsMap[txen] != RADIOLIB_NC) {
+ pinMode(settingsMap[txen], OUTPUT);
+ digitalWrite(settingsMap[txen], 0);
+ }
+ if (settingsMap[rxen] != RADIOLIB_NC) {
+ pinMode(settingsMap[rxen], OUTPUT);
+ digitalWrite(settingsMap[rxen], 0);
+ }
#endif
setTransmitEnable(false);
@@ -202,4 +224,4 @@ bool RF95Interface::sleep()
lora->sleep();
return true;
-}
+}
\ No newline at end of file
diff --git a/src/mesh/SX126xInterface.cpp b/src/mesh/SX126xInterface.cpp
index 45519ff87..7220dd3e5 100644
--- a/src/mesh/SX126xInterface.cpp
+++ b/src/mesh/SX126xInterface.cpp
@@ -2,7 +2,7 @@
#include "configuration.h"
#include "error.h"
#include "mesh/NodeDB.h"
-#ifdef ARCH_RASPBERRY_PI
+#ifdef ARCH_PORTDUINO
#include "PortduinoGlue.h"
#endif
@@ -30,18 +30,25 @@ template bool SX126xInterface::init()
digitalWrite(SX126X_POWER_EN, HIGH);
#endif
+#if ARCH_PORTDUINO
+ float tcxoVoltage = 0;
+ if (settingsMap[dio3_tcxo_voltage])
+ tcxoVoltage = 1.8;
// FIXME: correct logic to default to not using TCXO if no voltage is specified for SX126X_DIO3_TCXO_VOLTAGE
-#if !defined(SX126X_DIO3_TCXO_VOLTAGE)
+#elif !defined(SX126X_DIO3_TCXO_VOLTAGE)
float tcxoVoltage =
0; // "TCXO reference voltage to be set on DIO3. Defaults to 1.6 V, set to 0 to skip." per
// https://github.com/jgromes/RadioLib/blob/690a050ebb46e6097c5d00c371e961c1caa3b52e/src/modules/SX126x/SX126x.h#L471C26-L471C104
// (DIO3 is free to be used as an IRQ)
- LOG_DEBUG("SX126X_DIO3_TCXO_VOLTAGE not defined, not using DIO3 as TCXO reference voltage\n");
#else
float tcxoVoltage = SX126X_DIO3_TCXO_VOLTAGE;
- LOG_DEBUG("SX126X_DIO3_TCXO_VOLTAGE defined, using DIO3 as TCXO reference voltage at %f V\n", SX126X_DIO3_TCXO_VOLTAGE);
// (DIO3 is not free to be used as an IRQ)
#endif
+ if (tcxoVoltage == 0)
+ LOG_DEBUG("SX126X_DIO3_TCXO_VOLTAGE not defined, not using DIO3 as TCXO reference voltage\n");
+ else
+ LOG_DEBUG("SX126X_DIO3_TCXO_VOLTAGE defined, using DIO3 as TCXO reference voltage at %f V\n", tcxoVoltage);
+
// FIXME: May want to set depending on a definition, currently all SX126x variant files use the DC-DC regulator option
bool useRegulatorLDO = false; // Seems to depend on the connection to pin 9/DCC_SW - if an inductor DCDC?
@@ -77,7 +84,7 @@ template bool SX126xInterface::init()
#ifdef SX126X_DIO2_AS_RF_SWITCH
LOG_DEBUG("Setting DIO2 as RF switch\n");
bool dio2AsRfSwitch = true;
-#elif defined(ARCH_RASPBERRY_PI)
+#elif defined(ARCH_PORTDUINO)
bool dio2AsRfSwitch = false;
if (settingsMap[dio2_as_rf_switch]) {
LOG_DEBUG("Setting DIO2 as RF switch\n");
@@ -93,6 +100,12 @@ template bool SX126xInterface::init()
// If a pin isn't defined, we set it to RADIOLIB_NC, it is safe to always do external RF switching with RADIOLIB_NC as it has
// no effect
+#if ARCH_PORTDUINO
+ if (res == RADIOLIB_ERR_NONE) {
+ LOG_DEBUG("Using MCU pin %i as RXEN and pin %i as TXEN to control RF switching\n", settingsMap[rxen], settingsMap[txen]);
+ lora.setRfSwitchPins(settingsMap[rxen], settingsMap[txen]);
+ }
+#else
#ifndef SX126X_RXEN
#define SX126X_RXEN RADIOLIB_NC
LOG_DEBUG("SX126X_RXEN not defined, defaulting to RADIOLIB_NC\n");
@@ -105,7 +118,7 @@ template bool SX126xInterface::init()
LOG_DEBUG("Using MCU pin %i as RXEN and pin %i as TXEN to control RF switching\n", SX126X_RXEN, SX126X_TXEN);
lora.setRfSwitchPins(SX126X_RXEN, SX126X_TXEN);
}
-
+#endif
if (config.lora.sx126x_rx_boosted_gain) {
uint16_t result = lora.setRxBoostedGainMode(true);
LOG_INFO("Set RX gain to boosted mode; result: %d\n", result);
@@ -322,4 +335,4 @@ template bool SX126xInterface::sleep()
#endif
return true;
-}
+}
\ No newline at end of file
diff --git a/src/mesh/SX128xInterface.cpp b/src/mesh/SX128xInterface.cpp
index 6b7b0f438..47a79ea52 100644
--- a/src/mesh/SX128xInterface.cpp
+++ b/src/mesh/SX128xInterface.cpp
@@ -3,6 +3,10 @@
#include "error.h"
#include "mesh/NodeDB.h"
+#if ARCH_PORTDUINO
+#include "PortduinoGlue.h"
+#endif
+
// Particular boards might define a different max power based on what their hardware can do
#ifndef SX128X_MAX_POWER
#define SX128X_MAX_POWER 13
@@ -31,6 +35,16 @@ template bool SX128xInterface::init()
digitalWrite(RF95_FAN_EN, 1);
#endif
+#if ARCH_PORTDUINO
+ if (settingsMap[rxen] != RADIOLIB_NC) {
+ pinMode(settingsMap[rxen], OUTPUT);
+ digitalWrite(settingsMap[rxen], LOW); // Set low before becoming an output
+ }
+ if (settingsMap[txen] != RADIOLIB_NC) {
+ pinMode(settingsMap[txen], OUTPUT);
+ digitalWrite(settingsMap[txen], LOW); // Set low before becoming an output
+ }
+#else
#if defined(SX128X_RXEN) && (SX128X_RXEN != RADIOLIB_NC) // set not rx or tx mode
pinMode(SX128X_RXEN, OUTPUT);
digitalWrite(SX128X_RXEN, LOW); // Set low before becoming an output
@@ -38,6 +52,7 @@ template bool SX128xInterface::init()
#if defined(SX128X_TXEN) && (SX128X_TXEN != RADIOLIB_NC)
pinMode(SX128X_TXEN, OUTPUT);
digitalWrite(SX128X_TXEN, LOW);
+#endif
#endif
RadioLibInterface::init();
@@ -75,6 +90,10 @@ template bool SX128xInterface::init()
if (res == RADIOLIB_ERR_NONE) {
lora.setRfSwitchPins(SX128X_RXEN, SX128X_TXEN);
}
+#elif ARCH_PORTDUINO
+ if (res == RADIOLIB_ERR_NONE && settingsMap[rxen] != RADIOLIB_NC && settingsMap[txen] != RADIOLIB_NC) {
+ lora.setRfSwitchPins(settingsMap[rxen], settingsMap[txen]);
+ }
#endif
if (res == RADIOLIB_ERR_NONE)
@@ -148,14 +167,21 @@ template void SX128xInterface::setStandby()
}
assert(err == RADIOLIB_ERR_NONE);
-
+#if ARCH_PORTDUINO
+ if (settingsMap[rxen] != RADIOLIB_NC) {
+ digitalWrite(settingsMap[rxen], LOW);
+ }
+ if (settingsMap[txen] != RADIOLIB_NC) {
+ digitalWrite(settingsMap[txen], LOW);
+ }
+#else
#if defined(SX128X_RXEN) && (SX128X_RXEN != RADIOLIB_NC) // we have RXEN/TXEN control - turn off RX and TX power
digitalWrite(SX128X_RXEN, LOW);
#endif
#if defined(SX128X_TXEN) && (SX128X_TXEN != RADIOLIB_NC)
digitalWrite(SX128X_TXEN, LOW);
#endif
-
+#endif
isReceiving = false; // If we were receiving, not any more
activeReceiveStart = 0;
disableInterrupt();
@@ -176,11 +202,21 @@ template void SX128xInterface::addReceiveMetadata(meshtastic_Mes
*/
template void SX128xInterface::configHardwareForSend()
{
+#if ARCH_PORTDUINO
+ if (settingsMap[txen] != RADIOLIB_NC) {
+ digitalWrite(settingsMap[txen], HIGH);
+ }
+ if (settingsMap[rxen] != RADIOLIB_NC) {
+ digitalWrite(settingsMap[rxen], LOW);
+ }
+
+#else
#if defined(SX128X_TXEN) && (SX128X_TXEN != RADIOLIB_NC) // we have RXEN/TXEN control - turn on TX power / off RX power
digitalWrite(SX128X_TXEN, HIGH);
#endif
#if defined(SX128X_RXEN) && (SX128X_RXEN != RADIOLIB_NC)
digitalWrite(SX128X_RXEN, LOW);
+#endif
#endif
RadioLibInterface::configHardwareForSend();
@@ -197,11 +233,21 @@ template void SX128xInterface::startReceive()
setStandby();
+#if ARCH_PORTDUINO
+ if (settingsMap[rxen] != RADIOLIB_NC) {
+ digitalWrite(settingsMap[rxen], HIGH);
+ }
+ if (settingsMap[txen] != RADIOLIB_NC) {
+ digitalWrite(settingsMap[txen], LOW);
+ }
+
+#else
#if defined(SX128X_RXEN) && (SX128X_RXEN != RADIOLIB_NC) // we have RXEN/TXEN control - turn on RX power / off TX power
digitalWrite(SX128X_RXEN, HIGH);
#endif
#if defined(SX128X_TXEN) && (SX128X_TXEN != RADIOLIB_NC)
digitalWrite(SX128X_TXEN, LOW);
+#endif
#endif
// We use the PREAMBLE_DETECTED and HEADER_VALID IRQ flag to detect whether we are actively receiving
@@ -281,4 +327,4 @@ template bool SX128xInterface::sleep()
#endif
return true;
-}
+}
\ No newline at end of file
diff --git a/src/meshUtils.h b/src/meshUtils.h
index a6436a8d5..e32ef230a 100644
--- a/src/meshUtils.h
+++ b/src/meshUtils.h
@@ -8,5 +8,6 @@ template constexpr const T &clamp(const T &v, const T &lo, const T &hi
#if (defined(ARCH_PORTDUINO) && !defined(STRNSTR))
#define STRNSTR
+#include
char *strnstr(const char *s, const char *find, size_t slen);
#endif
\ No newline at end of file
diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp
index cc6d8e39d..3127b0986 100644
--- a/src/modules/CannedMessageModule.cpp
+++ b/src/modules/CannedMessageModule.cpp
@@ -1,5 +1,5 @@
#include "configuration.h"
-#if ARCH_RASPBERRY_PI
+#if ARCH_PORTDUINO
#include "PortduinoGlue.h"
#endif
#if HAS_SCREEN
diff --git a/src/modules/Modules.cpp b/src/modules/Modules.cpp
index 5ed49a4d8..37c7576f6 100644
--- a/src/modules/Modules.cpp
+++ b/src/modules/Modules.cpp
@@ -17,7 +17,7 @@
#include "modules/TextMessageModule.h"
#include "modules/TraceRouteModule.h"
#include "modules/WaypointModule.h"
-#if ARCH_RASPBERRY_PI
+#if ARCH_PORTDUINO
#include "input/LinuxInputImpl.h"
#endif
#if HAS_TELEMETRY
@@ -50,7 +50,7 @@
void setupModules()
{
if (config.device.role != meshtastic_Config_DeviceConfig_Role_REPEATER) {
-#if HAS_BUTTON || ARCH_RASPBERRY_PI
+#if HAS_BUTTON || ARCH_PORTDUINO
inputBroker = new InputBroker();
#endif
adminModule = new AdminModule();
@@ -67,7 +67,7 @@ void setupModules()
new RemoteHardwareModule();
new ReplyModule();
-#if HAS_BUTTON || ARCH_RASPBERRY_PI
+#if HAS_BUTTON || ARCH_PORTDUINO
rotaryEncoderInterruptImpl1 = new RotaryEncoderInterruptImpl1();
if (!rotaryEncoderInterruptImpl1->init()) {
delete rotaryEncoderInterruptImpl1;
@@ -85,7 +85,7 @@ void setupModules()
kbMatrixImpl->init();
#endif // INPUTBROKER_MATRIX_TYPE
#endif // HAS_BUTTON
-#if ARCH_RASPBERRY_PI
+#if ARCH_PORTDUINO
aLinuxInputImpl = new LinuxInputImpl();
aLinuxInputImpl->init();
#endif
diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp
index 5464c6c49..a13e7eba2 100644
--- a/src/platform/portduino/PortduinoGlue.cpp
+++ b/src/platform/portduino/PortduinoGlue.cpp
@@ -8,10 +8,8 @@
#include
#include
-#ifdef ARCH_RASPBERRY_PI
#include "PortduinoGlue.h"
#include "linux/gpio/LinuxGPIOPin.h"
-#include "pigpio.h"
#include "yaml-cpp/yaml.h"
#include
#include