@@ -12,6 +12,7 @@ This is a fork of [lorabasics/basicstation](https://github.com/lorabasics/basics
1212- Automatic Gateway EUI detection from SX1302/SX1303 chips
1313- Systemd service configuration
1414- Fine timestamp support for SX1302/SX1303 with GPS PPS
15+ - Docker support for containerized deployment
1516
1617For upstream Basic Station documentation: https://doc.sm.tc/station
1718
@@ -481,6 +482,96 @@ sudo systemctl start basicstation.service
481482sudo journalctl -u basicstation.service -f
482483```
483484
485+ ## Docker Support
486+
487+ Build and run the station as a Docker container on Raspberry Pi.
488+
489+ ### Build
490+
491+ ``` bash
492+ docker build -t basicstation .
493+ # Debug variant:
494+ docker build -t basicstation --build-arg VARIANT=debug .
495+ ```
496+
497+ ### Detect EUI (new board)
498+
499+ ``` bash
500+ docker run --rm --privileged -e BOARD=WM1302 -e EUI_ONLY=1 basicstation
501+ ```
502+
503+ Register the printed EUI on TTN Console, then start:
504+
505+ ### Run
506+
507+ ``` bash
508+ # Using docker-compose (recommended)
509+ CUPS_KEY=" NNSXS.xxx..." docker compose up -d
510+ docker logs -f basicstation
511+
512+ # Using docker run
513+ docker run -d --privileged --network host \
514+ --name basicstation --restart unless-stopped \
515+ -e BOARD=PG1302 -e REGION=eu1 \
516+ -e GATEWAY_EUI=auto \
517+ -e CUPS_KEY=" NNSXS.xxx..." \
518+ basicstation
519+ ```
520+
521+ ### Environment Variables
522+
523+ | Variable | Required | Default | Description |
524+ | ----------| ----------| ---------| -------------|
525+ | ` BOARD ` | Yes | -- | WM1302, PG1302, LR1302, SX1302_WS, SEMTECH, or ` custom ` |
526+ | ` REGION ` | Yes | -- | TTN region: eu1, nam1, au1 |
527+ | ` GATEWAY_EUI ` | Yes | -- | 16 hex chars or ` auto ` (chip detection) |
528+ | ` CUPS_KEY ` | Yes | -- | TTN CUPS API key (NNSXS.xxx...) |
529+ | ` EUI_ONLY ` | No | -- | Set to ` 1 ` to detect Gateway EUI and exit (only ` BOARD ` required) |
530+ | ` GPS_DEV ` | No | _ (disabled)_ | GPS device path (e.g. ` /dev/ttyS0 ` ) or ` none ` |
531+ | ` ANTENNA_GAIN ` | No | ` 0 ` | Antenna gain in dBi (0-15) |
532+ | ` SPI_DEV ` | No | ` /dev/spidev0.0 ` | SPI device path |
533+ | ` LOG_LEVEL ` | No | ` DEBUG ` | Station log level |
534+ | ` SX1302_RESET_GPIO ` | If custom | -- | BCM pin for SX1302 reset |
535+ | ` POWER_EN_GPIO ` | If custom | -- | BCM pin for power enable |
536+ | ` SX1261_RESET_GPIO ` | If custom | -- | BCM pin for SX1261 reset |
537+
538+ ### Docker Files
539+
540+ - ` Dockerfile ` - Multi-stage build (builder compiles station + chip_id, runner is minimal)
541+ - ` docker/entrypoint.sh ` - Validates env vars, generates config, starts station
542+ - ` docker-compose.yml ` - Example compose file with all env vars documented
543+ - ` .dockerignore ` - Excludes build artifacts, credentials, tests from context
544+
545+ ### Container Layout
546+
547+ ```
548+ /app/
549+ ├── bin/station # Station binary
550+ ├── bin/chip_id # EUI detection tool
551+ ├── scripts/
552+ │ ├── reset_lgw.sh # GPIO reset (SX1302 + SX1261 + Power EN)
553+ │ ├── rinit.sh # Radio init wrapper
554+ │ └── board.conf # Generated at runtime by entrypoint
555+ ├── templates/
556+ │ ├── station.conf.template
557+ │ └── board.conf.template
558+ ├── config/ # Station home dir (generated at runtime)
559+ │ ├── station.conf
560+ │ ├── cups.uri
561+ │ ├── cups.key
562+ │ └── cups.trust
563+ └── entrypoint.sh
564+ ```
565+
566+ ### Notes
567+
568+ - Requires ` privileged: true ` or sysfs GPIO access for concentrator reset
569+ - Requires ` network_mode: host ` for LoRaWAN packet reception
570+ - Logs go to stderr via station's built-in stderr mode (` log_file: "stderr" ` ) — visible via ` docker logs `
571+ - Uses the same ` station.conf.template ` and ` board.conf.template ` as ` setup-gateway.sh `
572+ - Builder stage requires ` python3 ` , ` python3-jsonschema ` , ` python3-jinja2 ` for mbedtls 3.6.0 PSA crypto wrapper generation
573+ - Stale PID files (` /var/tmp/station.pid ` , ` /tmp/station.pid ` ) are cleaned up before station start to prevent restart failures
574+
484575## Build System Notes
485576
486577Platform/variant configuration in ` setup.gmk ` :
@@ -578,7 +669,7 @@ Format: `2.0.6-cnbhl.X.Y` or `2.0.6-cnbhl.X.Ya`
578669- ** Tag** : No "v" prefix (e.g., ` 2.0.6-cnbhl.1.0 ` )
579670- ** Release title** : ` Release 2.0.6-cnbhl.X.Y ` (prefix with "Release ")
580671
581- ** Current version** : ` 2.0.6-cnbhl.1.5 `
672+ ** Current version** : ` 2.0.6-cnbhl.1.6 `
582673
583674** History** : Versions ` 2.0.6-cnbhl.1 ` through ` 2.0.6-cnbhl.5 ` used the old single-number scheme.
584675Starting with ` 2.0.6-cnbhl.1.0 ` , we use the new X.Y format.
0 commit comments