mirror of
https://github.com/meshtastic/firmware.git
synced 2026-09-21 05:45:27 -04:00
Adds the standard Meshtastic BLE service (toRadio/fromRadio/fromNum/logRadio) to the Linux native target, so a Raspberry Pi running meshtasticd can be paired and used over BLE like any other Meshtastic device. Implementation: a new LinuxBluetooth backend registers a GATT application, LE advertisement and pairing agent with bluetoothd over the org.bluez D-Bus APIs, using sdbus-c++ (both the 1.x and 2.x major versions, via a small compat shim - Debian bookworm/Ubuntu 24.04 ship 1.x, trixie/Fedora ship 2.x). When the sdbus-c++ dev package is absent the whole backend compiles out via __has_include, the same optional-dependency idiom as the ulfius webserver. Threading follows the NimbleBluetooth model, simplified: the sdbus event loop runs its own thread, and all PhoneAPI calls happen on the main thread. Writes queue to the main loop; reads park the D-Bus reply and are completed from the main thread after queued writes, so write-then-read clients see their answer without any busy-waiting. Enablement is a double opt-in: a new `Bluetooth:` config.yaml section (Enabled, default false; AdapterId, default hci0) must turn BLE on for the host, and the regular device config bluetooth.enabled must be on. The config-check schema and fixtures cover the new section. Pairing honors config.bluetooth.mode: NO_PIN maps to a NoInputNoOutput just-works agent; RANDOM_PIN to DisplayOnly with the kernel-generated passkey shown on screen/log via the existing BluetoothStatus plumbing. FIXED_PIN falls back to random-passkey semantics with a warning - BlueZ does not support forcing a passkey. PIN modes enforce encrypt-authenticated-read/write on all mesh characteristics. Packaging: install a D-Bus system policy so the meshtasticd user may talk to org.bluez, add it to the bluetooth group, order the unit after bluetooth.service, and add libsdbus-c++-dev to debian/rpm/docker/CI deps. Verified in-container against a mock bluetoothd: registration flow, GATT tree enumeration, advertisement properties, and a full config download (ToRadio wantConfig -> 47 FromRadio packets) through the D-Bus bridge. Real-hardware pairing/notify testing on a Pi still pending. Known limitations (v1): meshtasticd must be restarted if bluetoothd restarts; FIXED_PIN degrades to a random passkey; getRssi() returns 0 (same as nRF52). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0184v7MyCLuJHW2ebZ9r8NmQ
82 lines
3.2 KiB
Docker
82 lines
3.2 KiB
Docker
# trunk-ignore-all(trivy/DS-0002): We must run as root for this container
|
|
# trunk-ignore-all(checkov/CKV_DOCKER_8): We must run as root for this container
|
|
# trunk-ignore-all(hadolint/DL3002): We must run as root for this container
|
|
# trunk-ignore-all(hadolint/DL3008): Do not pin apt package versions
|
|
# trunk-ignore-all(hadolint/DL3013): Do not pin pip package versions
|
|
|
|
FROM debian:trixie AS builder
|
|
ARG PIO_ENV=native
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
ENV TZ=Etc/UTC
|
|
|
|
# Install Dependencies
|
|
ENV PIP_ROOT_USER_ACTION=ignore
|
|
ENV PIP_BREAK_SYSTEM_PACKAGES=1
|
|
RUN apt-get update && apt-get install --no-install-recommends -y \
|
|
curl wget g++ zip git ca-certificates pkg-config \
|
|
python3-pip python3-grpc-tools \
|
|
libgpiod-dev libyaml-cpp-dev libjsoncpp-dev libbluetooth-dev libsdbus-c++-dev libi2c-dev libuv1-dev \
|
|
libcurl4-gnutls-dev libusb-1.0-0-dev libulfius-dev liborcania-dev libssl-dev \
|
|
libx11-dev libinput-dev libxkbcommon-x11-dev libsqlite3-dev libsdl2-dev \
|
|
&& apt-get clean && rm -rf /var/lib/apt/lists/* \
|
|
&& pip install --no-cache-dir -U platformio \
|
|
&& mkdir /tmp/firmware
|
|
|
|
# Copy source code
|
|
WORKDIR /tmp/firmware
|
|
COPY . /tmp/firmware
|
|
|
|
# Build
|
|
RUN bash ./bin/build-native.sh "$PIO_ENV" && \
|
|
cp "/tmp/firmware/release/meshtasticd_linux_$(uname -m)" "/tmp/firmware/release/meshtasticd"
|
|
|
|
# Fetch web assets
|
|
RUN curl -L "https://github.com/meshtastic/web/releases/download/v$(cat /tmp/firmware/bin/web.version)/build.tar" -o /tmp/web.tar \
|
|
&& mkdir -p /tmp/web \
|
|
&& tar -xf /tmp/web.tar -C /tmp/web/ \
|
|
&& gzip -dr /tmp/web \
|
|
&& rm /tmp/web.tar
|
|
|
|
##### PRODUCTION BUILD #############
|
|
|
|
FROM debian:trixie-slim
|
|
LABEL org.opencontainers.image.title="Meshtastic" \
|
|
org.opencontainers.image.description="Debian Meshtastic daemon and web interface" \
|
|
org.opencontainers.image.url="https://meshtastic.org" \
|
|
org.opencontainers.image.documentation="https://meshtastic.org/docs/" \
|
|
org.opencontainers.image.authors="Meshtastic" \
|
|
org.opencontainers.image.licenses="GPL-3.0-or-later" \
|
|
org.opencontainers.image.source="https://github.com/meshtastic/firmware/"
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
ENV TZ=Etc/UTC
|
|
|
|
# nosemgrep: dockerfile.security.last-user-is-root.last-user-is-root
|
|
USER root
|
|
|
|
RUN apt-get update && apt-get --no-install-recommends -y install \
|
|
libc-bin libc6 libgpiod3 libyaml-cpp0.8 libjsoncpp26 libsdbus-c++2 libi2c0 libuv1t64 libusb-1.0-0-dev \
|
|
libcurl4t64 liborcania2.3 libulfius2.7t64 libssl3t64 \
|
|
libx11-6 libinput10 libxkbcommon-x11-0 libsdl2-2.0-0 \
|
|
&& apt-get clean && rm -rf /var/lib/apt/lists/* \
|
|
&& mkdir -p /var/lib/meshtasticd \
|
|
&& mkdir -p /etc/meshtasticd/config.d \
|
|
&& mkdir -p /etc/meshtasticd/ssl
|
|
|
|
# Fetch compiled binary from the builder
|
|
COPY --from=builder /tmp/firmware/release/meshtasticd /usr/bin/
|
|
COPY --from=builder /tmp/web /usr/share/meshtasticd/web/
|
|
# Copy config templates
|
|
COPY ./bin/config.d /etc/meshtasticd/available.d
|
|
|
|
WORKDIR /var/lib/meshtasticd
|
|
VOLUME /var/lib/meshtasticd
|
|
|
|
# Expose Meshtastic TCP API port from the host
|
|
EXPOSE 4403
|
|
# Expose Meshtastic Web UI port from the host
|
|
EXPOSE 9443
|
|
|
|
CMD [ "sh", "-cx", "meshtasticd --fsdir=/var/lib/meshtasticd" ]
|
|
|
|
HEALTHCHECK NONE
|