Skip to content

Commit 31b3863

Browse files
authored
Merge branch 'develop' into t-watch-ultra
2 parents 2d37a58 + 06a6c3e commit 31b3863

15 files changed

Lines changed: 129 additions & 28 deletions

bin/build-native.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ basename=meshtasticd-$1-$VERSION
3131
pio pkg install --environment "$PIO_ENV" || platformioFailed
3232
pio run --environment "$PIO_ENV" || platformioFailed
3333

34-
cp "$BUILDDIR/meshtasticd" "$OUTDIR/meshtasticd_linux_$(uname -m)"
34+
os_name=$(uname -s | tr '[:upper:]' '[:lower:]')
35+
cp "$BUILDDIR/meshtasticd" "$OUTDIR/meshtasticd_${os_name}_$(uname -m)"
3536
cp bin/native-install.* $OUTDIR/

src/Power.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,10 @@ void Power::reboot()
781781
rp2040.reboot();
782782
#elif defined(ARCH_PORTDUINO)
783783
deInitApiServer();
784+
#ifdef __linux__
784785
if (aLinuxInputImpl)
785786
aLinuxInputImpl->deInit();
787+
#endif
786788
SPI.end();
787789
Wire.end();
788790
Serial1.end();

src/RedirectablePrint.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#pragma once
22

33
#include "../freertosinc.h"
4+
#include "Print.h"
45
#include "mesh/generated/meshtastic/mesh.pb.h"
5-
#include <Print.h>
66
#include <stdarg.h>
77
#include <string>
88

src/input/InputBroker.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,11 @@ void InputBroker::Init()
390390
seesawRotary = nullptr;
391391
}
392392
}
393+
#ifdef __linux__
394+
// Linux evdev keyboard input only — macOS has no <linux/input.h>.
393395
aLinuxInputImpl = new LinuxInputImpl();
394396
aLinuxInputImpl->init();
397+
#endif
395398
}
396399
#endif
397400
#if !MESHTASTIC_EXCLUDE_INPUTBROKER && HAS_TRACKBALL

src/input/LinuxInput.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#pragma once
2-
#if ARCH_PORTDUINO
2+
// Linux evdev keyboard input. Only compiled on Linux portduino targets;
3+
// macOS / non-Linux builds have no <linux/input.h> or epoll, and the
4+
// headless build doesn't need real keyboards anyway.
5+
#if ARCH_PORTDUINO && defined(__linux__)
36
#include "InputBroker.h"
47
#include "concurrency/OSThread.h"
58
#include <assert.h>

src/input/LinuxInputImpl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#ifdef ARCH_PORTDUINO
1+
// Linux evdev impl. Same Linux-only gating as LinuxInput.h.
2+
#if defined(ARCH_PORTDUINO) && defined(__linux__)
23
#pragma once
34
#include "LinuxInput.h"
45
#include "main.h"

src/mesh/HardwareRNG.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ extern Adafruit_nRFCrypto nRFCrypto;
1919
#include <Arduino.h>
2020
#elif defined(ARCH_PORTDUINO)
2121
#include <random>
22-
#include <sys/random.h>
2322
#include <unistd.h>
23+
#ifdef __linux__
24+
#include <sys/random.h> // getrandom()
25+
#else
26+
#include <stdlib.h> // arc4random_buf() on Darwin/BSD
27+
#endif
2428
#endif
2529

2630
namespace HardwareRNG
@@ -119,10 +123,16 @@ bool fill(uint8_t *buffer, size_t length, bool useRadioEntropy)
119123
filled = true;
120124
#elif defined(ARCH_PORTDUINO)
121125
// Prefer the host OS RNG first when running under Portduino.
126+
#ifdef __linux__
122127
ssize_t generated = ::getrandom(buffer, length, 0);
123128
if (generated == static_cast<ssize_t>(length)) {
124129
filled = true;
125130
}
131+
#else
132+
// arc4random_buf is available on Darwin/BSD and cannot fail.
133+
::arc4random_buf(buffer, length);
134+
filled = true;
135+
#endif
126136

127137
if (!filled) {
128138
fillWithRandomDevice(buffer, length);

src/mesh/MeshRadio.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
#include "configuration.h"
77
#include "detect/LoRaRadioType.h"
88

9-
// Sentinel marking the end of a modem preset array
10-
static constexpr meshtastic_Config_LoRaConfig_ModemPreset MODEM_PRESET_END =
9+
// Sentinel marking the end of a modem preset array. Declared `const` rather
10+
// than `constexpr` because the cast from 0xFF to the enum is out-of-range and
11+
// therefore not a valid constant expression on Clang 16+ (Apple Clang on
12+
// macOS). The value is only ever compared at runtime, so static-init is fine.
13+
static const meshtastic_Config_LoRaConfig_ModemPreset MODEM_PRESET_END =
1114
static_cast<meshtastic_Config_LoRaConfig_ModemPreset>(0xFF);
1215

1316
// Region profile: bundles the preset list with regulatory parameters shared across regions

src/mesh/RadioLibInterface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ bool RadioLibInterface::canSendImmediately()
119119
return true;
120120
}
121121

122-
bool RadioLibInterface::receiveDetected(uint16_t irq, ulong syncWordHeaderValidFlag, ulong preambleDetectedFlag)
122+
bool RadioLibInterface::receiveDetected(uint16_t irq, unsigned long syncWordHeaderValidFlag, unsigned long preambleDetectedFlag)
123123
{
124124
bool detected = (irq & (syncWordHeaderValidFlag | preambleDetectedFlag));
125125
// Handle false detections

src/mesh/RadioLibInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ class RadioLibInterface : public RadioInterface, protected concurrency::Notified
220220
protected:
221221
uint32_t activeReceiveStart = 0;
222222

223-
bool receiveDetected(uint16_t irq, ulong syncWordHeaderValidFlag, ulong preambleDetectedFlag);
223+
bool receiveDetected(uint16_t irq, unsigned long syncWordHeaderValidFlag, unsigned long preambleDetectedFlag);
224224

225225
/** Do any hardware setup needed on entry into send configuration for the radio.
226226
* Subclasses can customize, but must also call this base method */

0 commit comments

Comments
 (0)