Skip to content

Add native SPI LoRa APRS channel (LCHANNEL) for SX1276/SX1262 hats - #638

Open
radiohound wants to merge 48 commits into
wb2osz:devfrom
radiohound:feature/lora-spi
Open

radiohound wants to merge 48 commits into
wb2osz:devfrom
radiohound:feature/lora-spi

Conversation

@radiohound

Copy link
Copy Markdown

Overview

This PR adds LoRa APRS support to Dire Wolf, targeting Raspberry Pi with a LoRa hat wired to the SPI bus. Two receive paths are provided:

  1. Native SPI driver (LCHANNEL) — new channel type compiled directly into Dire Wolf. Talks to SX1276/SX1278/SX1262 chips via Linux SPI and libgpiod. Full TX and RX. No Python or extra processes required.

  2. SDR bridge (lora_sdr_bridge.py) — Python script using RTL-SDR + GNU Radio + gr-lora_sdr for receive, connected to Dire Wolf over KISS TCP (NCHANNEL). RX only; TX falls through to the native driver if both are configured.

Both paths support iGate, digipeating, and beaconing through the normal Dire Wolf configuration.

Configuration

Native SPI driver:

LCHANNEL 10
MYCALL N0CALL-2
LORAHW meshadv
LORAFREQ 433.775
LORASF 12
LORABW 125
LORACR 5
LORASW 0x12
LORATXPOWER 17
SDR bridge (optional, RX-only second channel):

NCHANNEL 11 127.0.0.1 8002
Run alongside: python3 lora_sdr_bridge.py -c lora.conf

Hardware profiles

Profiles are selected with LORAHW in direwolf.conf. New profiles can be added by inserting a row in the s_profiles[] array in src/loraspi.c.

lorapi_rfm98w — Digital Concepts LoRa-Pi RFM98W, SX1278, 433 MHz — TX and RX tested
lorapi_rfm95w — Digital Concepts LoRa-Pi RFM95W, SX1276, 868/915 MHz
meshadv — MeshAdv Pi Hat (E22-400M30S, 1W PA), SX1262, 433 MHz — TX and RX tested
e22_900m30s — Ebyte E22-900M30S, SX1262, 868/915 MHz
e22_400m30s — Ebyte E22-400M30S, SX1262, 433 MHz
Notable bugs fixed during development
SX1262 GET_RX_BUFFER_STATUS byte offset
The SX1262 echoes the status byte twice in the GET_RX_BUFFER_STATUS response. RxPayloadLength and RxStartBufferPointer are at response bytes [2] and [3], not [1] and [2] as implied by some versions of the datasheet. Without this fix nb receives the status byte value (e.g. 0xD4 = 212) instead of the actual packet length (~47 bytes), causing every received frame to be padded with ~165 bytes of garbage from the chip buffer.

Pi 4 kernel 6.12 GPIO base offset
On Pi 4 with kernel 6.12, the BCM GPIO chip is registered as gpiochip512 (base=512) rather than gpiochip0 (base=0). Writing raw BCM pin numbers to /sys/class/gpio/export silently failed, leaving CS, BUSY, RST, TXEN, and RXEN as no-ops. Added gpio_sysfs_num() which scans /sys/class/gpio/gpiochip*/base at startup and applies the correct offset automatically.

SX1262 sync word encoding
The SX1262 uses a 16-bit sync word at registers 0x0740/0x0741. The SX1276-style single byte (e.g. 0x12) must be expanded by nibble: 0x12 becomes 0x1424. The expansion is sw_hi = (sw >> 4) << 4 | 0x04, sw_lo = (sw & 0x0F) << 4 | 0x04.

Test results

Tested on Raspberry Pi 4, kernel 6.12:

✓ TX beacon from MeshAdv hat (SX1262, 433 MHz) confirmed received by K6ATV-31 and uploaded to APRS-IS
✓ RX on MeshAdv hat decoding K6ATV-1 T-Echo beacons cleanly (RSSI=-106 dBm, SNR=20.5 dB)
✓ TX and RX on Digital Concepts LoRa-Pi hat (SX1278/RFM98W, 433 MHz)
✓ LCHANNEL and NCHANNEL coexisting in the same direwolf.conf

radiohound and others added 7 commits March 27, 2026 16:22
Introduces loraspi.c — a native Linux SPI/GPIO driver for SX1276 and
SX1262 LoRa chips — as a new channel medium alongside MEDIUM_RADIO,
MEDIUM_NETTNC, and MEDIUM_SERTNC.

New source files:
  src/loraspi.c  — driver: chip init, rx_thread (dlq_rec_frame injection),
                   tx_thread (AX.25 → TNC2 → LoRa preamble → SPI TX),
                   hardware profile table (loraspi_apply_profile)
  src/loraspi.h  — public API: loraspi_init, loraspi_send_packet,
                   loraspi_apply_profile

Modified source files:
  src/audio.h      — MEDIUM_LORA added to enum medium_e; ~18 lora_*[]
                     config fields added to struct audio_s
  src/config.c     — LCHANNEL, LORAHW, LORAFREQ, LORASF, LORABW, LORACR,
                     LORASW, LORATXPOWER directives parsed; all
                     chan_medium validity checks extended for MEDIUM_LORA
  src/direwolf.c   — loraspi_init() called at startup after sertnc_init()
  src/tq.c         — transmit queue routes MEDIUM_LORA packets to
                     loraspi_send_packet()
  src/beacon.c     — MEDIUM_LORA accepted for PBEACON/OBEACON channels
  src/digipeater.c — MEDIUM_LORA accepted as valid receive channel
  src/cdigipeater.c — MEDIUM_LORA accepted; bounds check widened from
                     MAX_RADIO_CHANS to MAX_TOTAL_CHANS for virtual channels
  src/CMakeLists.txt — loraspi.c added to direwolf source list

The driver is Linux-only; non-Linux platforms get empty stubs so the build
is unconditional.  A per-channel pthread_mutex_t serialises SPI access
between the rx and tx threads.  The chip is re-armed to continuous RX mode
after each transmission (SX1276 drops to STDBY on TX_DONE).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Bridge scripts (scripts/):
  lora_kiss_bridge.py   — hardware bridge: LoRaRF Python library over SPI,
                          connects to Dire Wolf LORAPORT as TNC2 TCP client,
                          RX + TX; reads hardware_profiles.yaml + lora.conf
  lora_sdr_bridge.py    — SDR bridge: KISS TCP server; Dire Wolf connects
                          via NCHANNEL; GNU Radio passes decoded LoRa frames
                          via lora_sdr_flowgraph.py; RX only
  lora_sdr_flowgraph.py — GNU Radio flowgraph: RTL-SDR IQ → gr-lora_sdr
                          demodulation → PDU messages to lora_sdr_bridge.py

Documentation (doc/):
  LoRa-APRS.md          — end-user setup for both LCHANNEL (native SPI,
                          recommended) and lora_kiss_bridge.py (Python)
  LoRa-SDR.md           — end-user setup for RTL-SDR receive path
  LoRa-Implementation.md — developer notes: architecture, modified/new
                          files, design decisions, upstream PR guidance

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The Digital Concepts LoRa-Pi hat ships in two variants: RFM95W (SX1276,
868/915 MHz) and RFM98W (SX1278, 433 MHz).  SX1276 and SX1278 are
register-identical; add a lorapi_rfm98w alias with the same pin
assignments so users can select the correct name for their module.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
SX1262 uses a 2-byte sync word at registers 0x0740/0x0741 with a
different encoding than SX1276's single-byte value.  The correct
mapping is: each nibble of the SX1276 byte becomes a nibble with
0x4 appended — e.g. 0x12 (LoRa APRS) becomes 0x1424, 0x34
(Meshtastic/private) becomes 0x3444.

Previously the code split lc->sw (0x0012) directly as 0x00/0x12,
which would leave the SX1262 with the wrong sync word and unable
to communicate with any LoRa APRS device.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Two bugs prevented TX on the MeshAdv Pi Hat with kernel 6.12:

1. GPIO sysfs base offset: on Pi 4 with kernel 6.12 the main BCM GPIO
   chip is registered as gpiochip512 (base=512, not 0).  Writing BCM pin
   numbers directly to /sys/class/gpio/export silently failed, leaving CS,
   BUSY, RESET, TXEN, and RXEN as no-ops.  Add gpio_sysfs_num() which
   scans /sys/class/gpio/gpiochip*/base at startup, picks the chip with
   the lowest base that has >=28 GPIOs, and applies that offset to every
   BCM pin number.

2. GetIrqStatus byte offset: SX1262 GetIrqStatus returns four bytes:
   [status, echoed_status, IRQ[15:8], IRQ[7:0]].  The poll loops were
   computing irq = (rx[1]<<8)|rx[2] and missing TxDone (bit 0 of rx[3]).
   Fix to irq = (rx[2]<<8)|rx[3] in both sx1262_transmit and sx1262_receive.

Also remove TX diagnostic code that was added during debugging.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
install-lora.sh automates full LoRa APRS setup on Raspberry Pi 3/4/5:
- Pi 3: direwolf + native SPI hat (LCHANNEL) + Python bridge (LORAPORT)
- Pi 4/5: full install including GNU Radio and gr-lora_sdr SDR path

Steps performed:
- detects Pi model, installs build dependencies
- blacklists dvb_usb_rtl28xxu kernel driver for RTL-SDR
- builds gr-lora_sdr and Dire Wolf from source
- prompts for callsign, passcode, frequency, hardware profile
- writes /etc/direwolf/direwolf.conf and lora.conf
- installs and enables systemd services as the login user

Also adds systemd/lora-sdr-bridge.service for the SDR bridge path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The SX1262 echoes the status byte twice in the GET_RX_BUFFER_STATUS
response (bytes [0] and [1] are both status), so RxPayloadLength and
RxStartBufferPointer are at bytes [2] and [3], not [1] and [2].
Using the wrong offsets caused nb=212 (status byte value) instead of
the actual packet length (~47 bytes), resulting in garbage-padded RX.

Also separate TX/RX buffer base addresses (TX=0x00, RX=0x80) to
prevent any overlap between transmitted and received data.

Tested on MeshAdv-Pi Hat (E22-400M30S, SX1262, 433 MHz):
- TX confirmed via APRS-IS (heard by K6ATV-31)
- RX confirmed decoding DL5TKL T-Echo beacons cleanly

Updated LoRa-APRS.md: corrected MeshAdv frequency, added TX/RX
tested status to hardware table, added note on SX1262 status byte
echo quirk for future porters.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Pandapip1

Copy link
Copy Markdown

Out of curiosity, I haven't seen an actual spec for APRS over LoRA. How is this done, is it just transmitting the raw AX.25 frames?

@radiohound

Copy link
Copy Markdown
Author

Out of curiosity, I haven't seen an actual spec for APRS over LoRA. How is this done, is it just transmitting the raw AX.25 frames?

APRS over LoRa follows the same APRS specifications as traditional APRS. However, the characters are sent to the LoRa modules in a TNC2-style header (source, dest, path as plain text).

@wb2osz

wb2osz commented Apr 1, 2026

Copy link
Copy Markdown
Owner

Walter: Thank you for this very significant and interesting submission.
I will have to buy an RPi LoRa HAT and try it.
73,
John WB2OSZ

@radiohound

Copy link
Copy Markdown
Author

Walter: Thank you for this very significant and interesting submission. I will have to buy an RPi LoRa HAT and try it. 73, John WB2OSZ

You are welcome John,

Walter K6ATV

@wb2osz

wb2osz commented Apr 9, 2026

Copy link
Copy Markdown
Owner

I got this on start up when SPI was not enabled. It is easy to miss.
loraspi: cannot open /dev/spidev0.0: No such file or directory

In this case it would be good to add an explanation that SPI is not enabled and that raspi-config should be used to enable it.
This should be a fatal error and cause the application to exit.

@wb2osz

wb2osz commented Apr 9, 2026

Copy link
Copy Markdown
Owner

FCC Part 97 limits 70cm bandwidth to 100kHz for US hams.
I tried 62.5 and at start up time it says:
LoRa channel 10: 433.775 MHz SF12 BW62 kHz SX1262

BW was truncated to an integer for the display. I see that the internal variable is float. It would be good to add CR here for troubleshooting.

@radiohound

Copy link
Copy Markdown
Author

I got this on start up when SPI was not enabled. It is easy to miss. loraspi: cannot open /dev/spidev0.0: No such file or directory

In this case it would be good to add an explanation that SPI is not enabled and that raspi-config should be used to enable it. This should be a fatal error and cause the application to exit.

Thank you John, It is mentioned in the doc https://github.com/radiohound/direwolf/blob/feature/lora-spi/doc/LoRa-APRS.md

…12, remove lora_kiss_bridge, fix frequency docs, remove Meshtastic references
Update LoRa-Implementation.md and LoRa-SDR.md to reflect
the current state of the native SPI driver implementation:

- Remove references to lora_kiss_bridge.py (now obsolete)
- Remove LORAPORT and loratnc references (replaced by LCHANNEL)
- Update file listing (2 new C files: loraspi.c, lora_chan.h)
- Update architecture diagram to show direct SPI path
- Add note about hardware profiles requiring recompile (future: hardware_profiles.yaml)
- Update SDR comparison table to reference native SPI driver
- Add note that Pi 3 is not supported for SDR path (CPU intensive)
- Remove "Switching between hardware and SDR bridge" section (no longer applicable)
- Update sync word references: 0x34 (Meshtastic) → 0x12 (LoRa APRS standard)
Add Installation section covering:
- apt update && apt upgrade before building
- git clone and branch checkout
- sudo bash install-lora.sh
- enabling SPI and I2C via raspi-config
- SPI verification step

Move SPI/I2C enable commands from Requirements into the
Installation section where they fit more naturally in the
setup flow.
@radiohound

Copy link
Copy Markdown
Author

Testing and fixes — Pi 3 fresh install verified

I've done a full fresh install test on a Raspberry Pi 3 running Debian Trixie and resolved several issues found during testing. All changes are now on the feature/lora-spi branch.

Bugs fixed:

  • SX1262 BUSY timeout on Pi 3 — TCXO stabilization delay increased from 5ms to 100ms (usleep(5000) → usleep(100000) in loraspi.c). The SX1262 TCXO needs more time to stabilize on Pi 3 hardware.
  • LORABW float fix — bw_khz field changed from int to float in lora_chan_t struct (audio.h) so decimal bandwidth values (e.g. 125.0 kHz) are handled correctly.
  • Wrong sync word default — default sync word corrected from 0x34 (Meshtastic) to 0x12 (LoRa APRS standard) in config.c and audio.h. All Meshtastic references removed.
  • Missing hardware_profiles.yaml — removed from install-lora.sh (file did not exist, causing installer to fail)
  • Frequency prompt — installer prompt updated to "LoRa frequency MHz (433.775 MHz is standard worldwide)"
  • lora_kiss_bridge.py removed — obsolete now that LCHANNEL is the supported path

Documentation updated:

  • LoRa-APRS.md — full rewrite for the native SPI driver; added Installation section with step-by-step instructions verified on a fresh Pi 3
  • LoRa-Implementation.md — updated to reflect current file structure (2 new C files, not 4); removed LORAPORT/loratnc references; added future improvement note for hardware_profiles.yaml
  • LoRa-SDR.md — updated comparison table and architecture notes

Fresh install test results (Pi 3, Debian Trixie, MeshAdv hat, SX1262):

  • Install script runs end to end without errors or workarounds
  • LoRa hat initializes correctly at startup
  • TX confirmed over the air at 433.775 MHz
  • RX confirmed working
  • APRS-IS connection verified
  • systemd service starts automatically on boot

@radiohound

radiohound commented Apr 11, 2026 •

Copy link
Copy Markdown
Author

FCC Part 97 limits 70cm bandwidth to 100kHz for US hams. I tried 62.5 and at start up time it says: LoRa channel 10: 433.775 MHz SF12 BW62 kHz SX1262

BW was truncated to an integer for the display. I see that the internal variable is float. It would be good to add CR here for troubleshooting.

This has been changed to a float, which will allow you to select non standard bandwidths, such as 62.5 khz. However, every LoRa APRS system I can find in the US and abroad, uses 125 khz as the bandwidth setting. So you won't find many other users, unless you start your own network.

Coding rate was added to the channel output, so it is displayed with the rest of the LoRa settings.

@radiohound

Copy link
Copy Markdown
Author

Here is a recap of items changed since my last post:

LoRa SPI driver (loraspi.c)

  • Replaced legacy sysfs GPIO with libgpiod, which is already used in Dire Wolf — supports Pi Zero 2 W, Pi 3, Pi 4, and Pi 5 without pin offset calculations; releases pins cleanly on exit
  • Fixed silent GPIO failures that left TX_EN and RX_EN undriven, disabling the external PA and LNA on MeshAdv hats and causing severely degraded range
  • Increased SX1262 reset timing (5 ms pulse, 100 ms recovery) to prevent BUSY pin lockups after process restart
  • Added RX buffer overflow guard preventing packets >128 bytes from wrapping into the TX region of the SX1262 circular buffer
  • Improved GPIO error reporting with errno output to aid troubleshooting

Installer (install-lora.sh)

  • Config now writes to ~/direwolf.conf instead of /etc/direwolf/, matching standard direwolf convention
  • VHF APRS via RTL-SDR (rtl_fm piped to direwolf) now included on all Pi models — previously incorrectly limited to Pi 4/5
  • GNU Radio and gr-lora_sdr remain Pi 4/5 only (too CPU-intensive for Pi 3)
  • Fixed --upgrade mode to detect the active service name instead of hardcoding direwolf
  • Generated systemd service now includes the RTL-SDR pipe for VHF APRS on all models

Documentation

  • Updated architecture diagram and troubleshooting sections to reflect libgpiod GPIO
  • Added gpio group setup step and sysfs pin cleanup instructions to troubleshooting
  • Fixed clone command to specify the correct branch used in this pull request.

radiohound and others added 8 commits October 16, 2026 16:55
Packets ax25_from_text rejects (e.g. source or digipeater SSID above 15) were logged without signal data. Printing RSSI/SNR there lets external loggers (link9 bridge in balloon-chase-station) still record them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HwBpgjKYngbcEkSRMG3VzY
GetPacketStatus returns opcode echo, status, then RssiPkt, SnrPkt, SignalRssiPkt. The read used 4 bytes and took RSSI from the status byte (0xD4 -> constant -106 dBm) and SNR from RssiPkt. Read 5 bytes and use indices 2 and 3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ap7Evx5JLXaS46dGbUQKub
Sample instantaneous channel RSSI (SX1262 GetRssiInst / SX1276 RegRssiValue) about once a second while idle and print avg (power-averaged), min and max each minute. Also fix SX1276_REG_RSSI_VALUE (0x1B, not 0x1A; previously unused).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ap7Evx5JLXaS46dGbUQKub
The RTL-SDR + GNU Radio LoRa receive path is independent of the native SPI
driver and will be submitted as its own PR. Removes the bridge, flowgraph,
SDR installer, SDR guide and service unit; strips GNU Radio / gr-lora_sdr
and lora.conf from install-lora.sh (RTL-SDR for VHF APRS stays), merges the
Pi 3 and Pi 4/5 direwolf.conf templates, and explains the LCHANNEL block in
the generated config.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Default LORAFREQ was 915 MHz and there was no default hardware profile.
Default to the worldwide LoRa APRS frequency (433.775 MHz) and the
meshadv_400m30s profile (1 W, 433 MHz); LORAHW/LORAFREQ still override.
Add a "Where the LoRa settings live" section to LoRa-APRS.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
unistd.h, sys/ioctl.h and linux/spi/spidev.h were included above the
#ifndef __linux__ stubs, so macOS and Windows/MinGW builds failed before
reaching them. Move the POSIX/Linux headers into the Linux branch so other
platforms compile the no-op stubs, as the docs describe.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…staller cleanup

- Drop the unreachable cdigipeater/CDIGIPEAT LORA changes (connected mode
  is radio-channel only).
- AGW port list now includes LoRa channels.
- Oversize TX packets are dropped with an error instead of sent without info.
- Default LORATXPOWER follows the profile limit quietly; only an explicit
  value above the limit is reported.
- LCHANNEL errors no longer leave later LORA* lines applied to the previous
  channel.
- Validate LORAFREQ, LORABW, LORASF (7-12), LORASW, LORATXPOWER.
- Non-Linux builds report that LCHANNEL is unsupported.
- Remove unused Python packages from install-lora.sh; fix stale comments.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Match the docs to the code: SF 7-12, value ranges, defaults, startup message,
  case-insensitive profile names, colors controlled by -t.
- Use an RFM98W (433 MHz) in the example; RFM95W is an 868/915 MHz part.
- Point systemd users at the installer-created service, not the generic unit.
- Add spi group, LCHANNEL vs NCHANNEL/SCHANNEL, RSSI/SNR output, and a
  what-works-over-LoRa section (no connected mode, no listen-before-talk).
- Move the new-hat instructions and 33S warning to one place.
- Installer: Enter accepts 433.775; clone note for the feature branch.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@radiohound radiohound changed the title Add native SPI LoRa APRS driver (SX1276/SX1262) for LoRa APRS tx and rx, and SDR LoRa APRS receive path Add native SPI LoRa APRS channel (LCHANNEL) for SX1276/SX1262 hats Oct 23, 2026
@radiohound

Copy link
Copy Markdown
Author

This adds a native SPI driver so Dire Wolf can use a LoRa hat directly, with no separate bridge process. It is limited to the hat driver. The SDR receive path that was in earlier revisions of this PR has been removed and will come as a separate PR.

What it does

  • New channel type MEDIUM_LORA, declared with LCHANNEL n. n is from MAX_RADIO_CHANS to MAX_TOTAL_CHANS-1, the same range as NCHANNEL/SCHANNEL.
  • New directives: LORAHW, LORAFREQ, LORASF, LORABW, LORACR, LORASW, LORATXPOWER. Values are range-checked.
  • Defaults: 433.775 MHz, SF12, BW125, CR4/5, sync word 0x12, and the 1 W 433 MHz meshadv_400m30s hat. Default power is 20 dBm, capped to the hat's limit.
  • Drives SX1276/SX1278 and SX1262 over Linux spidev, with GPIO through libgpiod (legacy sysfs as a fallback).
  • Built-in hardware profiles (MeshAdv-Pi, LoRa-Pi, generic SX1276). Each has a maximum TX power, and Dire Wolf clamps to it. This protects 33S modules with an external PA.
  • Received lines show RSSI and SNR, and the idle noise floor is logged every 60 s.
  • install-lora.sh is a Raspberry Pi installer and is independent of the C changes.

What works on a LoRa channel

Beacons, DIGIPEAT, the APRS-IS iGate in both directions, IGTXVIA, and KISS and AGW clients (AGW lists it as PortN LoRa). Connected-mode AX.25 is not supported. The driver does not listen before transmitting, and TXDELAY, PERSIST and SLOTTIME do not apply.

Changes to existing files

audio.h, config.c, direwolf.c, tq.c, beacon.c, digipeater.c, server.c and CMakeLists.txt. These only extend the existing channel-medium checks to accept MEDIUM_LORA. There is no behaviour change for existing channel types. loraspi.c is Linux only; other platforms compile a stub that reports that LCHANNEL is unsupported.

Testing

  • All 5 jobs in the repo's CI workflow (Windows MinGW with and without Hamlib, macOS, Ubuntu latest, Ubuntu 22.04) build with -Werror and pass ctest. This is on my fork, since the PR's own workflow run needs approval.
  • Hardware: TX and RX tested on the MeshAdv-Pi 400M30S, MeshAdv-Pi 400M33S and LoRa-Pi RFM98W. The 868/915 MHz profiles are untested, and the docs say so.

Docs

doc/LoRa-APRS.md is the user guide and doc/LoRa-Implementation.md is for developers. They are markdown, so they are not in the PDF doc set. I can fold them into the User Guide or direwolf-doc if you prefer, and I can add a CHANGES.md entry. The branch history includes the earlier SDR work that was split out, so squash-merge is fine with me.

radiohound and others added 11 commits October 24, 2026 16:49
The packet params had the CRC flag off, so frames went out with a header saying
"no CRC".  Receivers that check the CRC (RadioLib setCRC(true), e.g. the common
ESP32 iGate firmware) reject such frames as "LoRa header damaged" (RadioLib error
-24): on 24 Oct 2026 an ESP32 iGate received a beacon from this driver and dropped
it twice, while a T-Deck decoded the same beacon.  Receiving is unchanged: the
SX1262 follows the CRC flag in each received header.  The SX1276 path already had
CRC on.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The receive buffer started at 0x80, so a frame longer than 128 bytes would have wrapped into the transmit area, and the driver discarded
it with 'RX packet too large'.  LoRa APRS frames of 130 to 250 bytes are common (weather beacons, long comments, objects), so every one of
them was lost.  The radio is half duplex and the transmit buffer is written before every send, so receive and transmit can share the
whole buffer from 0x00; a LoRa payload is at most 255 bytes, so it never wraps.

Also: sx1262_start_rx puts the packet parameters back to a 255 byte maximum payload (sx1262_transmit had set it to the length of the last
frame sent, and in receive mode that field is the largest payload the receiver accepts), and the transmit length check is 255, since the
payload length register is one byte.  The SX1276 path already used base 0x00 for both.

Tested on an SX1262 hat: full 188 byte frames (compressed, expanding to 245 bytes) are received and decoded.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… word

LORAFREQ was stored as a float, which holds 433.775 as 433.774994.  The radio was tuned 6 Hz low on an SX1262 (a constant error added to every
frequency-error reading, which matters for anything measuring offsets or Doppler), and the frequency word was cut off instead of rounded.
lora_freq_mhz (audio.h, config.c) and freq_mhz (loraspi.c) are now doubles, and both chips round the frequency word to the nearest step.

Tuning error at 433.775 MHz:  SX1262 (0.95 Hz step): -6.10 Hz before, -0.38 Hz after.  SX1276 (61 Hz step): -36.6 Hz before, +24.4 Hz after.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…rial TNC channel

SCHANNEL never set 'channel', so a MYCALL after it landed on the previous
LCHANNEL.  Set channel on success and reset it to -1 on every error path
(as LCHANNEL does); the error paths now also stop instead of writing the
device name into an out-of-range or already-used channel.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…once

The 'TX poll: chipMode' line printed on every SX1262 transmit.  It now prints
only with -d L (new loraspi_set_debug(), same pattern as ptt_set_debug).

The RX path printed its own packet text before Dire Wolf's normal decode
line, so every packet appeared twice.  Remove that line; RSSI and SNR now
ride in the spectrum string the normal decode line already shows.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…00M30S

LORATXPOWER is the chip output, before the module's external PA.  Document
that, and fix the sample-config comments.

Add an optional per-profile table of chip setting vs. power at the antenna
connector, interpolated and printed at startup.  Only meshadv_400m30s has
data (module manual); it is capped at 18 dBm, the manual's maximum
(29.96 dBm out).  The profile name is now kept in audio_s (lora_hw).

No official power table was found for the E22-400M33S, so the 33S profiles
stay capped at 8 dBm with no estimate, until official information or
documented testing is available.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…imit, SX1276 power floor

- FILTER accepted only radio/NET/serial channels; accept LoRa too.
- LORASW was parsed with base 0, so 'LORASW 34' meant 0x22.  Parse as hex.
- loraspi_send_packet allowed a 256-byte frame; a LoRa payload is at most
  255.  Reject it there, and guard sx1276_transmit as the SX1262 path does.
- sx1276_init: LORATXPOWER 0 or 1 wrapped the PA_CONFIG byte to about
  16-17 dBm.  Floor the register value (2 dBm output is the minimum).
- Docs: the context rule lists every channel directive; the iGate sends
  APRS-IS to LoRa only with IGTXVIA; field count, -d L and the SCHANNEL
  and FILTER changes are in LoRa-Implementation.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
meshadv_900m30s and meshadv_900m33s have no TX/RX testing and no power
table; leave them for a later addition by someone with the hardware.
Removed from s_profiles[], the profile table and the installer menu.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…te config

- Ask whether there is an RTL-SDR dongle.  Without one (default) write
  ADEVICE null null and a service that runs direwolf alone, instead of
  piping rtl_fm into it and exiting at once.
- Accept only known hardware profile names (a typo kept the MeshAdv pins).
- Keep a timestamped .bak of an existing direwolf.conf / direwolf.service
  before overwriting; chmod 600 direwolf.conf and backups (APRS-IS passcode).
- Run the service with -t 0 so the journal has no color codes.
- Docs: Pi 5 is untested, not 'any model'; a bad LORAHW name is not fatal
  and what it looks like; describe the installer behavior.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
On a 33S hat, 17 is above the 8 dBm cap, so every start printed a clamping
error.  Leave it out (default 20, capped quietly to the profile limit) and
keep a commented example.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…mation field

Transmit:
- A frame that is not UI with PID F0 (a connected-mode SABM, I frame, RR,
  or a UI frame with another PID) is not sent on the LoRa channel. The TNC2
  text used by LoRa APRS has no place for the control field or PID, so such
  a frame used to go out looking like an APRS packet.
- The information field is copied by length, not with strncat, so a NUL
  byte no longer cuts the packet short.

Receive:
- Only the address part goes through ax25_from_text; the information field
  is set by length with ax25_set_info. A NUL no longer cuts the packet short,
  and text such as "<0x0d>" in a received packet is no longer turned into a
  byte.
- Only a trailing CR/LF is removed; trailing spaces are part of the packet.
- A packet that can't be parsed is printed with ax25_safe_print.

LoRa-APRS.md says that only APRS frames go out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants