Compare commits

...

10 Commits

Author SHA1 Message Date
Michael Smith
5f3c41ca3d Add .claude/settings.local.json to .gitignore
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 19:43:20 +00:00
Michael Smith
8c3b4d7e48 Add ssh_config to .gitignore
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 19:42:27 +00:00
Michael Smith
aac310b29e Add README and LICENSE
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 19:38:34 +00:00
Michael Smith
5f28a11aa4 Add CB channel 16 (27.155 MHz) to monitoring
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 22:18:35 +00:00
Michael Smith
94fdaf7644 Add recording cleanup container to remove noise files
Alpine-based sdr-cleanup container runs a find loop every 5 minutes,
deleting MP3 files under 3 KB (configurable via SIZE_THRESHOLD env var)
to keep the web browser and Samba share free of false-positive recordings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 18:32:17 +00:00
Michael Smith
d3effff7db Update rtl_airband configuration 2026-03-19 20:59:33 +01:00
Michael Smith
3aec32499b Update Dockerfile 2026-03-19 14:31:55 +01:00
Michael Smith
733fe76ed5 Tune FFT size and squelch to reduce false-positive recordings
Increase fft_size from 512 (default) to 2048 for better NFM channel
isolation, and add squelch_snr_threshold = 15.0 dB per channel to
reject noise-triggered recordings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 13:25:37 +00:00
Michael Smith
9ff0506cae Add Nginx web server for browsing recordings
Serves the recordings directory over HTTP with autoindex on port 8080.
Users can browse by date and play MP3 files natively in the browser.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 11:42:45 +00:00
Michael Smith
97879a9f59 Sync gain setting with live Pi config
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 08:40:58 +00:00
32 changed files with 695 additions and 3 deletions

2
.gitignore vendored
View File

@@ -1,2 +1,4 @@
/.env /.env
/ssh_config
.claude/settings.local.json

View File

@@ -17,7 +17,6 @@ RUN apt-get update -y && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
ENV COLORTERM=truecolor ENV COLORTERM=truecolor
ENV TERM=xterm-256color
# Install Openspec # Install Openspec
RUN npm i -g @fission-ai/openspec@latest RUN npm i -g @fission-ai/openspec@latest

85
LICENSE Normal file
View File

@@ -0,0 +1,85 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
<https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS

30
README.md Normal file
View File

@@ -0,0 +1,30 @@
# SDR Scanner & Recorder
Monitors and records EU CB radio transmissions using an RTL-SDR dongle on a Raspberry Pi 400, powered by [RTLSDR-Airband](https://github.com/charlie-foxtrot/RTLSDR-Airband).
## Monitored Channels
| Channel | Frequency |
|---------|-----------|
| CB 3 | 26.985 MHz |
| CB 7 | 27.035 MHz |
| CB 10 | 27.075 MHz |
| CB 16 | 27.155 MHz |
## Architecture
Three Docker containers via `docker-compose`:
- **rtlsdr-airband** — multichannel SDR receiver, splits recordings per-transmission into dated directories
- **nginx** — web UI for browsing recordings on port 8080
- **cleanup** — periodically removes short/noise recordings (< 3KB)
## Usage
```sh
ssh m@sdr-pi
cd /workspace
docker compose up -d
```
Recordings are saved to `~/recordings/` and browsable at `http://sdr-pi:8080`.

16
cleanup-recordings.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/sh
# Deletes small MP3 recordings that are likely noise/false positives.
# Runs in a loop, intended for use inside a Docker container.
#
# Environment variables:
# SIZE_THRESHOLD - find -size format, e.g. 3k, 5k, 10k (default: 3k)
# INTERVAL - seconds between runs (default: 300)
RECORDINGS_DIR="/recordings"
SIZE_THRESHOLD="${SIZE_THRESHOLD:-3k}"
INTERVAL="${INTERVAL:-300}"
while true; do
find "$RECORDINGS_DIR" -type f -name '*.mp3' -size "-${SIZE_THRESHOLD}" -mmin +1 -delete
sleep "$INTERVAL"
done

View File

@@ -8,3 +8,25 @@ services:
volumes: volumes:
- ./rtl_airband.conf:/app/rtl_airband.conf:ro - ./rtl_airband.conf:/app/rtl_airband.conf:ro
- /home/m/recordings:/recordings - /home/m/recordings:/recordings
web:
image: nginx:alpine
container_name: sdr-web
restart: unless-stopped
ports:
- "8080:80"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
- /home/m/recordings:/recordings:ro
cleanup:
image: alpine:latest
container_name: sdr-cleanup
restart: unless-stopped
environment:
- SIZE_THRESHOLD=3k
- INTERVAL=300
volumes:
- ./cleanup-recordings.sh:/cleanup-recordings.sh:ro
- /home/m/recordings:/recordings
command: ["/bin/sh", "/cleanup-recordings.sh"]

8
nginx.conf Normal file
View File

@@ -0,0 +1,8 @@
server {
listen 80;
location / {
alias /recordings/;
autoindex on;
}
}

View File

@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-03-19

View File

@@ -0,0 +1,46 @@
## Context
RTLSDR-Airband monitors 3 CB channels (26.985, 27.035, 27.075 MHz) via a single RTL-SDR dongle on a Pi 400. Recordings split per transmission produce many false positives — short noise-triggered files, often on multiple channels simultaneously.
Current config: `fft_size` commented out (defaults to 512), no `squelch_snr_threshold` set (defaults to 9.54 dB). Both contribute to over-sensitivity.
## Goals / Non-Goals
**Goals:**
- Reduce false-positive recordings caused by noise, static, and weak signals
- Achieve this through RTLSDR-Airband config tuning only — no post-processing
**Non-Goals:**
- Eliminating 100% of false positives (some noise will always slip through)
- Automated cleanup scripts or post-processing pipelines
- Changes to gain, bandwidth, or sample rate (these are working adequately)
## Decisions
### 1. Set `fft_size = 2048`
**Decision**: Uncomment and increase `fft_size` from the current default of 512 to 2048.
**Rationale**: With 3 NFM channels spaced 10 kHz apart using 8 kHz bandwidth, a 512-point FFT produces bins too wide for clean separation. This causes energy from one channel (or wideband noise) to bleed into adjacent channels, triggering simultaneous false recordings. The simultaneous cross-channel triggers observed in the recordings confirm this.
2048 provides 4x the spectral resolution. Going to 4096 would be even better but may stress the Pi 400's CPU; 2048 is a safe starting point.
**Alternatives considered**:
- **4096**: Best selectivity but higher CPU cost. Can try later if 2048 isn't sufficient.
- **1024** (the previously commented-out value): Moderate improvement but may not fully resolve cross-channel bleed.
### 2. Add `squelch_snr_threshold = 15.0` per channel
**Decision**: Set an explicit SNR threshold of 15 dB on each channel.
**Rationale**: The default 9.54 dB is calibrated for aviation AM monitoring where signals are cleaner. CB at 27 MHz has a higher noise floor and more atmospheric interference. 15 dB is a reasonable starting point that should reject most noise while still capturing normal-strength CB transmissions.
**Alternatives considered**:
- **20-25 dB**: More aggressive, but risks missing weaker legitimate transmissions. Can increase later if 15 isn't enough.
- **`squelch_threshold` (absolute dBFS)**: Harder to tune and doesn't adapt to changing noise floor conditions. The SNR-relative approach is more robust.
## Risks / Trade-offs
- **[Weak signals missed]** → Higher squelch threshold will drop marginal transmissions. Acceptable trade-off — false positives are currently more disruptive than missed weak signals.
- **[CPU increase from larger FFT]** → 2048 uses more CPU than 512. Pi 400 quad-core should handle this comfortably, but worth monitoring after deployment.
- **[Iterative tuning needed]** → These values are starting points. May need adjustment after observing results over a day or two.

View File

@@ -0,0 +1,24 @@
## Why
The recorder generates many short false-positive recordings (360 bytes to ~4KB) triggered by noise, static, or weak signals. Multiple channels often fire simultaneously, suggesting wideband interference or poor channel isolation. The current config uses the default FFT size (512) and default squelch SNR threshold (9.54 dB), both of which are too permissive for noisy CB monitoring at 27 MHz.
## What Changes
- Increase `fft_size` to improve channel selectivity and reduce adjacent-channel false triggers
- Add `squelch_snr_threshold` per channel to raise the signal-to-noise requirement for squelch opening
- Uncomment and update the `fft_size` setting (currently commented out at 1024, defaulting to 512)
## Capabilities
### New Capabilities
- `false-positive-reduction`: RTLSDR-Airband configuration tuning to minimize noise-triggered recordings via FFT size and squelch SNR threshold adjustments
### Modified Capabilities
_(none)_
## Impact
- **Configuration**: Changes to `rtl_airband.conf` only — no new services or code
- **Pi resources**: Higher `fft_size` increases CPU usage slightly; monitor after deployment
- **Recording behavior**: Fewer but higher-confidence recordings; very weak legitimate signals may be missed

View File

@@ -0,0 +1,19 @@
## ADDED Requirements
### Requirement: FFT size configured for NFM channel isolation
The system SHALL use an `fft_size` of 2048 or greater to provide sufficient spectral resolution for separating NFM channels spaced 10 kHz apart.
#### Scenario: FFT size set in config
- **WHEN** the RTLSDR-Airband configuration is loaded
- **THEN** the `fft_size` is set to 2048
### Requirement: Squelch SNR threshold configured per channel
Each monitored channel SHALL have a `squelch_snr_threshold` set to reduce false triggers from noise and weak signals.
#### Scenario: Squelch threshold applied
- **WHEN** a signal is detected on a monitored channel
- **THEN** the squelch only opens if the signal exceeds the configured SNR threshold (starting value: 15.0 dB)
#### Scenario: Noise below threshold is rejected
- **WHEN** noise or interference is present but below the SNR threshold
- **THEN** no recording is triggered

View File

@@ -0,0 +1,10 @@
## 1. Configuration Changes
- [x] 1.1 Set `fft_size = 2048` in `rtl_airband.conf` (uncomment and update from 1024)
- [x] 1.2 Add `squelch_snr_threshold = 15.0` to each of the 3 channel blocks
## 2. Deploy and Verify
- [x] 2.1 Copy updated config to Pi and restart the `sdr-recorder` container
- [x] 2.2 Clear existing false-positive recordings so results are easy to evaluate
- [x] 2.3 Observe recording behavior — confirm fewer/no short noise-triggered files appearing

View File

@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-03-19

View File

@@ -0,0 +1,34 @@
## Context
RTLSDR-Airband records CB transmissions as MP3 files into `/home/m/recordings/` on the Pi, organized by channel subdirectories with dated subdirectories inside. The recorder runs as a Docker container via `docker-compose.yml`.
## Goals / Non-Goals
**Goals:**
- Serve the recordings directory over HTTP with browsable directory listings
- Allow MP3 playback via the browser's native audio handling
- Deploy as a Docker container alongside the existing `sdr-recorder` service
**Non-Goals:**
- Custom web UI, styling, or JavaScript
- Authentication (local network only)
- Modifying, uploading, or deleting recordings
- Live streaming or transcription
## Decisions
### Use Nginx with HTML autoindex, no custom frontend
**Decision**: Use `nginx:alpine` with `autoindex on` to serve the recordings directory. No custom HTML, JS, or CSS.
**Rationale**: Nginx's built-in directory listing is fully functional for browsing channel/date directories. Modern browsers play MP3 files natively when clicked. This requires only an Nginx config file and a docker-compose service — zero application code.
**Alternatives considered**:
- **Custom SPA frontend**: Adds complexity (build tools, JS code) for marginal UX improvement over native directory listing.
- **Python http.server**: Simpler but less performant and no Alpine image parity.
## Risks / Trade-offs
- **[No search or filtering]** → Users browse by directory structure. Acceptable given the channel/date organization.
- **[Plain directory listing]** → No styled UI. Acceptable for a local utility tool.
- **[No auth]** → Anyone on the LAN can access. Acceptable per non-goals.

View File

@@ -0,0 +1,23 @@
## Why
Recordings from the RTLSDR-Airband CB scanner are stored as MP3 files on the Pi's filesystem (`/home/m/recordings/`), organized by channel and date. There's currently no way to browse or listen to them without SSH access. A web server with directory listing would make recordings browsable and playable from any device on the local network.
## What Changes
- Add an Nginx container to `docker-compose.yml` that serves the recordings directory with autoindex enabled
- Users browse directories and click MP3 files to play them natively in the browser
## Capabilities
### New Capabilities
- `recording-browser`: Nginx autoindex serving the recordings directory over HTTP, with browser-native MP3 playback
### Modified Capabilities
_(none)_
## Impact
- **Docker deployment**: New Nginx service added to `docker-compose.yml`, sharing the `/home/m/recordings` volume (read-only)
- **Pi resources**: Negligible — Nginx Alpine uses ~2MB RAM
- **Network**: Exposes HTTP port on the Pi's local network

View File

@@ -0,0 +1,34 @@
## ADDED Requirements
### Requirement: Serve recordings directory over HTTP
The system SHALL serve the contents of the recordings directory via an Nginx web server with directory listing enabled.
#### Scenario: Browse channel directories
- **WHEN** a user navigates to the root URL of the web server
- **THEN** the server displays a directory listing showing the channel subdirectories
#### Scenario: Browse date directories within a channel
- **WHEN** a user clicks a channel directory
- **THEN** the server displays a directory listing of date subdirectories for that channel
#### Scenario: Browse recording files within a date
- **WHEN** a user clicks a date directory
- **THEN** the server displays a listing of MP3 recording files
### Requirement: Browser-native MP3 playback
The system SHALL serve MP3 files with correct MIME type so browsers can play them natively.
#### Scenario: Play a recording
- **WHEN** a user clicks an MP3 file link in the directory listing
- **THEN** the browser opens and plays the MP3 file using its native audio player
### Requirement: Docker deployment
The web server SHALL run as a Docker container defined in `docker-compose.yml`, mounting the recordings directory read-only.
#### Scenario: Start alongside recorder
- **WHEN** a user runs `docker compose up` on the Pi
- **THEN** the Nginx service starts alongside the `sdr-recorder` service and is accessible via HTTP
#### Scenario: Read-only access to recordings
- **WHEN** the Nginx container accesses the recordings volume
- **THEN** the volume is mounted read-only, preventing modification of recording files

View File

@@ -0,0 +1,11 @@
## 1. Nginx Configuration
- [x] 1.1 Create `nginx.conf` with a server block that serves `/recordings` with `autoindex on` and correct MIME type for MP3 files
## 2. Docker Integration
- [x] 2.1 Add an `nginx` service to `docker-compose.yml` using `nginx:alpine`, mounting `/home/m/recordings` to `/recordings:ro` and `./nginx.conf` to the Nginx config path, exposing port 8080
## 3. Deploy and Verify
- [x] 3.1 Deploy to the Pi and verify directory browsing and MP3 playback work at `http://sdr-pi:8080`

View File

@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-03-21

View File

@@ -0,0 +1,28 @@
## Context
The system monitors CB radio channels using RTLSDR-Airband running in Docker on a Pi 400. The SDR is tuned to a center frequency of 27.035 MHz with a 2.4 MHz sample rate, covering approximately 25.83528.235 MHz. Three channels are currently monitored (3, 7, 10). CB channel 16 at 27.155 MHz falls well within this window.
## Goals / Non-Goals
**Goals:**
- Add CB channel 16 (27.155 MHz) to the monitored channel list
- Use identical recording and squelch settings as existing channels for consistency
**Non-Goals:**
- Changing center frequency, sample rate, or gain settings
- Adding any other channels beyond channel 16
- Modifying the cleanup, web, or Docker configuration
## Decisions
**Use identical channel parameters as existing channels.**
All current channels use 8 kHz bandwidth, NFM modulation, 9.0 dB squelch SNR threshold, and file output with split-on-transmission. Channel 16 will use the same settings. There's no reason to deviate — CB channels have uniform characteristics.
**Filename template follows existing convention: `CB_CH16_27155`.**
This matches the `CB_CH{nn}_{freq}` pattern used by channels 3, 7, and 10, keeping recordings consistent for the cleanup script and web browser.
## Risks / Trade-offs
**Additional CPU load from fourth channel** → Minimal risk. RTLSDR-Airband's multichannel mode handles many channels efficiently within a single FFT pass. One more channel adds negligible overhead on the Pi 400.
**More recordings consuming disk space** → Mitigated by the existing cleanup container which removes files under the 3k size threshold.

View File

@@ -0,0 +1,24 @@
## Why
CB channel 16 (27.155 MHz) is commonly used for regional traffic and is worth monitoring alongside the existing channels 3, 7, and 10. The frequency already falls within the current SDR sample window, so adding it requires only a configuration change.
## What Changes
- Add CB channel 16 (27.155 MHz) as a new monitored channel in `rtl_airband.conf`
- Uses the same NFM modulation, bandwidth, squelch, and file output settings as existing channels
- Recordings saved with `CB_CH16_27155` filename template
## Capabilities
### New Capabilities
- `cb-channel-16-monitoring`: Monitor and record transmissions on CB channel 16 (27.155 MHz)
### Modified Capabilities
_(none — existing channel monitoring is unchanged)_
## Impact
- `rtl_airband.conf`: New channel entry added to the existing device's channel list
- No changes to Docker, Nginx, or cleanup configuration needed
- No additional hardware or SDR tuning changes required (27.155 MHz is within the current 2.4 MHz sample window)

View File

@@ -0,0 +1,19 @@
## ADDED Requirements
### Requirement: Monitor CB channel 16
The system SHALL monitor CB channel 16 at 27.155 MHz using narrowband FM demodulation with an 8 kHz bandwidth and a squelch SNR threshold of 9.0 dB.
#### Scenario: Channel 16 transmission detected
- **WHEN** a transmission occurs on 27.155 MHz above the squelch threshold
- **THEN** the system records the transmission to a file in the `/recordings` directory using dated subdirectories and the filename template `CB_CH16_27155`
#### Scenario: Channel 16 transmission ends
- **WHEN** the signal on 27.155 MHz drops below the squelch threshold
- **THEN** the system splits the recording file at the transmission boundary
### Requirement: Channel 16 labeled in configuration
The channel entry SHALL use the label `CB-CH16` for identification in logs and status output.
#### Scenario: Channel label appears in config
- **WHEN** RTLSDR-Airband loads the configuration
- **THEN** channel 16 is identified with the label `CB-CH16`

View File

@@ -0,0 +1,8 @@
## 1. Configuration
- [x] 1.1 Add CB channel 16 entry to `rtl_airband.conf` with freq 27.155, 8 kHz bandwidth, NFM modulation, 9.0 dB squelch SNR threshold, label `CB-CH16`, and file output with template `CB_CH16_27155`
- [x] 1.2 Update the comment at the top of `rtl_airband.conf` to include channel 16
## 2. Deploy
- [x] 2.1 Rebuild and restart the `sdr-recorder` container on the Pi to pick up the new configuration

View File

@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-03-21

View File

@@ -0,0 +1,42 @@
## Context
The SDR recorder running in Docker on `sdr-pi` writes MP3 files to `/home/m/recordings/` (mounted from the host). Despite squelch tuning, many files are noise — today's data shows 91 files totaling 476 KB, with the majority under 2 KB. These clutter the Nginx web browser and Samba share, making it hard to find real transmissions.
The recorder container runs as root (required for USB/SDR hardware access) and writes files owned by root, so cleanup must also run as root.
## Goals / Non-Goals
**Goals:**
- Automatically remove recordings that are too small to contain real audio
- Make the size threshold easily adjustable via environment variable
- Keep everything version-controlled in docker-compose
- Run frequently enough that the web/Samba views stay clean
**Non-Goals:**
- Duration-based or content-based analysis (too complex, needs extra tools)
- Age-based retention policy (handled manually for now)
## Decisions
### Dedicated cleanup container in docker-compose
Add a lightweight Alpine container (`sdr-cleanup`) to docker-compose that shares the `/home/m/recordings` volume. This follows Docker's separation-of-concerns model — one container per responsibility. The container runs a simple `find -delete` loop with `sleep` instead of requiring a cron daemon. Since it runs as root (Alpine default), it can delete the root-owned files written by the recorder.
Alternatives considered:
- **Host crontab**: Simplest, but files are root-owned so needs `sudo crontab`, and isn't version-controlled in docker-compose
- **Cron inside recorder container**: Not our image, would need custom build
- **Systemd timer on host**: More ceremony than cron for the same result
### File size threshold as the filter heuristic
Use file size (default 3 KB) rather than MP3 duration. This avoids needing `ffprobe` or similar tools. From today's data, files under 3 KB are consistently noise — real transmissions start around 5 KB. Configurable via `SIZE_THRESHOLD` environment variable in docker-compose.
### 5-minute sleep loop
Run every 5 minutes via `sleep 300` in a loop. Lightweight and keeps the browsing experience clean.
### Only delete files older than 1 minute
Add a minimum age filter (`-mmin +1`) to avoid deleting files still being written by rtl_airband.
## Risks / Trade-offs
- **Threshold too aggressive** → Real short transmissions deleted. Mitigation: start conservative at 3 KB, tune via environment variable.
- **Race condition with active writes** → The `-mmin +1` guard ensures we never delete a file rtl_airband is still writing.
- **Container restart** → If the cleanup container crashes, `restart: unless-stopped` brings it back. No state to lose.

View File

@@ -0,0 +1,25 @@
## Why
Despite tuning squelch thresholds and FFT settings, the SDR recorder still produces many small files triggered by noise rather than real CB transmissions. These clutter the web browser and Samba share, making it tedious to find actual recordings. A periodic cleanup job will automatically remove files that are too small to contain meaningful audio.
## What Changes
- Add a cleanup shell script that deletes MP3 files below a configurable size threshold (default: 3 KB)
- Install a cron job on the Pi host that runs the script frequently (every 5 minutes)
- The script and cron entry are version-controlled in this repo for documentation and tunability
## Capabilities
### New Capabilities
- `recording-cleanup`: Automated periodic deletion of recordings below a configurable file-size threshold
### Modified Capabilities
None.
## Impact
- New file: cleanup script in the repo, deployed to the Pi host
- Host crontab on `sdr-pi` will be modified to schedule the job
- Recordings directory (`/home/m/recordings/`) will have small files automatically removed
- No container or docker-compose changes required — this runs directly on the host

View File

@@ -0,0 +1,37 @@
## ADDED Requirements
### Requirement: Cleanup script removes small recordings
The system SHALL provide a shell script that deletes MP3 files below a configurable size threshold from the recordings directory. The default threshold SHALL be 3 KB (3072 bytes).
#### Scenario: File below threshold is deleted
- **WHEN** a `.mp3` file in `/home/m/recordings/` is smaller than the configured size threshold and older than 1 minute
- **THEN** the file is deleted
#### Scenario: File above threshold is preserved
- **WHEN** a `.mp3` file in `/home/m/recordings/` is equal to or larger than the configured size threshold
- **THEN** the file is not deleted
#### Scenario: File currently being written is preserved
- **WHEN** a `.mp3` file in `/home/m/recordings/` was modified less than 1 minute ago
- **THEN** the file is not deleted, regardless of size
### Requirement: Cleanup runs on a schedule
The system SHALL execute the cleanup script via a cron job on the Pi host, running every 5 minutes.
#### Scenario: Periodic execution
- **WHEN** 5 minutes have elapsed since the last run
- **THEN** the cleanup script executes and removes qualifying files
### Requirement: Size threshold is configurable
The cleanup script SHALL accept the size threshold as a parameter, allowing adjustment without editing the script.
#### Scenario: Custom threshold
- **WHEN** the script is invoked with a size argument (e.g., `5k`)
- **THEN** only files below that size are deleted instead of the default 3 KB
### Requirement: Cleanup script is version-controlled
The cleanup script SHALL be stored in the project repository so that changes are tracked and deployable.
#### Scenario: Script lives in repo
- **WHEN** a developer checks the repository
- **THEN** the cleanup script is present at a well-known path with documentation of its purpose

View File

@@ -0,0 +1,18 @@
## 1. Cleanup Script
- [x] 1.1 Create `cleanup-recordings.sh` in the repo with configurable size threshold (default 3k), `-mmin +1` safety guard, targeting `/recordings`
- [x] 1.2 Make the script executable and add a usage comment at the top
## 2. Docker Compose
- [x] 2.1 Update `cleanup-recordings.sh` to run as a loop with sleep instead of one-shot, read threshold from `SIZE_THRESHOLD` env var
- [x] 2.2 Add `sdr-cleanup` service to `docker-compose.yml` using `alpine` image, mounting the recordings volume and running the script
## 3. Deployment Cleanup
- [x] 3.1 Remove the host crontab entry installed earlier on `sdr-pi`
- [x] 3.2 Remove the script copy from `/home/m/cleanup-recordings.sh` on `sdr-pi`
## 4. Verification
- [x] 4.1 Deploy updated docker-compose to `sdr-pi` and confirm the cleanup container starts and deletes small files

View File

@@ -0,0 +1,17 @@
### Requirement: Monitor CB channel 16
The system SHALL monitor CB channel 16 at 27.155 MHz using narrowband FM demodulation with an 8 kHz bandwidth and a squelch SNR threshold of 9.0 dB.
#### Scenario: Channel 16 transmission detected
- **WHEN** a transmission occurs on 27.155 MHz above the squelch threshold
- **THEN** the system records the transmission to a file in the `/recordings` directory using dated subdirectories and the filename template `CB_CH16_27155`
#### Scenario: Channel 16 transmission ends
- **WHEN** the signal on 27.155 MHz drops below the squelch threshold
- **THEN** the system splits the recording file at the transmission boundary
### Requirement: Channel 16 labeled in configuration
The channel entry SHALL use the label `CB-CH16` for identification in logs and status output.
#### Scenario: Channel label appears in config
- **WHEN** RTLSDR-Airband loads the configuration
- **THEN** channel 16 is identified with the label `CB-CH16`

View File

@@ -0,0 +1,17 @@
### Requirement: FFT size configured for NFM channel isolation
The system SHALL use an `fft_size` of 2048 or greater to provide sufficient spectral resolution for separating NFM channels spaced 10 kHz apart.
#### Scenario: FFT size set in config
- **WHEN** the RTLSDR-Airband configuration is loaded
- **THEN** the `fft_size` is set to 2048
### Requirement: Squelch SNR threshold configured per channel
Each monitored channel SHALL have a `squelch_snr_threshold` set to reduce false triggers from noise and weak signals.
#### Scenario: Squelch threshold applied
- **WHEN** a signal is detected on a monitored channel
- **THEN** the squelch only opens if the signal exceeds the configured SNR threshold (starting value: 15.0 dB)
#### Scenario: Noise below threshold is rejected
- **WHEN** noise or interference is present but below the SNR threshold
- **THEN** no recording is triggered

View File

@@ -0,0 +1,32 @@
### Requirement: Serve recordings directory over HTTP
The system SHALL serve the contents of the recordings directory via an Nginx web server with directory listing enabled.
#### Scenario: Browse channel directories
- **WHEN** a user navigates to the root URL of the web server
- **THEN** the server displays a directory listing showing the channel subdirectories
#### Scenario: Browse date directories within a channel
- **WHEN** a user clicks a channel directory
- **THEN** the server displays a directory listing of date subdirectories for that channel
#### Scenario: Browse recording files within a date
- **WHEN** a user clicks a date directory
- **THEN** the server displays a listing of MP3 recording files
### Requirement: Browser-native MP3 playback
The system SHALL serve MP3 files with correct MIME type so browsers can play them natively.
#### Scenario: Play a recording
- **WHEN** a user clicks an MP3 file link in the directory listing
- **THEN** the browser opens and plays the MP3 file using its native audio player
### Requirement: Docker deployment
The web server SHALL run as a Docker container defined in `docker-compose.yml`, mounting the recordings directory read-only.
#### Scenario: Start alongside recorder
- **WHEN** a user runs `docker compose up` on the Pi
- **THEN** the Nginx service starts alongside the `sdr-recorder` service and is accessible via HTTP
#### Scenario: Read-only access to recordings
- **WHEN** the Nginx container accesses the recordings volume
- **THEN** the volume is mounted read-only, preventing modification of recording files

View File

@@ -0,0 +1,35 @@
### Requirement: Cleanup script removes small recordings
The system SHALL provide a shell script that deletes MP3 files below a configurable size threshold from the recordings directory. The default threshold SHALL be 3 KB (3072 bytes).
#### Scenario: File below threshold is deleted
- **WHEN** a `.mp3` file in `/home/m/recordings/` is smaller than the configured size threshold and older than 1 minute
- **THEN** the file is deleted
#### Scenario: File above threshold is preserved
- **WHEN** a `.mp3` file in `/home/m/recordings/` is equal to or larger than the configured size threshold
- **THEN** the file is not deleted
#### Scenario: File currently being written is preserved
- **WHEN** a `.mp3` file in `/home/m/recordings/` was modified less than 1 minute ago
- **THEN** the file is not deleted, regardless of size
### Requirement: Cleanup runs on a schedule
The system SHALL execute the cleanup script via a cron job on the Pi host, running every 5 minutes.
#### Scenario: Periodic execution
- **WHEN** 5 minutes have elapsed since the last run
- **THEN** the cleanup script executes and removes qualifying files
### Requirement: Size threshold is configurable
The cleanup script SHALL accept the size threshold as a parameter, allowing adjustment without editing the script.
#### Scenario: Custom threshold
- **WHEN** the script is invoked with a size argument (e.g., `5k`)
- **THEN** only files below that size are deleted instead of the default 3 KB
### Requirement: Cleanup script is version-controlled
The cleanup script SHALL be stored in the project repository so that changes are tracked and deployable.
#### Scenario: Script lives in repo
- **WHEN** a developer checks the repository
- **THEN** the cleanup script is present at a well-known path with documentation of its purpose

View File

@@ -1,5 +1,5 @@
# RTLSDR-Airband configuration for EU CB radio monitoring # RTLSDR-Airband configuration for EU CB radio monitoring
# Channels: 3 (26.985 MHz), 7 (27.035 MHz), 10 (27.075 MHz) # Channels: 3 (26.985 MHz), 7 (27.035 MHz), 10 (27.075 MHz), 16 (27.155 MHz)
localtime = false; localtime = false;
fft_size = 1024; fft_size = 1024;
@@ -8,7 +8,7 @@ devices:
({ ({
type = "rtlsdr"; type = "rtlsdr";
index = 0; index = 0;
gain = 35.0; gain = 25.0;
centerfreq = 27.035; centerfreq = 27.035;
correction = -1; correction = -1;
mode = "multichannel"; mode = "multichannel";
@@ -20,6 +20,7 @@ devices:
freq = 26.985; freq = 26.985;
bandwidth = 8000; bandwidth = 8000;
modulation = "nfm"; modulation = "nfm";
squelch_snr_threshold = 9.0;
label = "CB-CH03"; label = "CB-CH03";
outputs: ( outputs: (
{ {
@@ -35,6 +36,7 @@ devices:
freq = 27.035; freq = 27.035;
bandwidth = 8000; bandwidth = 8000;
modulation = "nfm"; modulation = "nfm";
squelch_snr_threshold = 9.0;
label = "CB-CH07"; label = "CB-CH07";
outputs: ( outputs: (
{ {
@@ -50,6 +52,7 @@ devices:
freq = 27.075; freq = 27.075;
bandwidth = 8000; bandwidth = 8000;
modulation = "nfm"; modulation = "nfm";
squelch_snr_threshold = 9.0;
label = "CB-CH10"; label = "CB-CH10";
outputs: ( outputs: (
{ {
@@ -60,6 +63,22 @@ devices:
dated_subdirectories = true; dated_subdirectories = true;
} }
); );
},
{
freq = 27.155;
bandwidth = 8000;
modulation = "nfm";
squelch_snr_threshold = 9.0;
label = "CB-CH16";
outputs: (
{
type = "file";
directory = "/recordings";
filename_template = "CB_CH16_27155";
split_on_transmission = true;
dated_subdirectories = true;
}
);
} }
); );
}); });