Merge branch 'master' into dockerfile-nogit
17
.travis.yml
@ -17,17 +17,6 @@ env:
|
||||
- ARTEFACT_BASE=$TRAVIS_BUILD_DIR/artefacts/
|
||||
- ARTEFACT_PATH=$ARTEFACT_BASE/$BUILD_NAME
|
||||
|
||||
notifications:
|
||||
irc:
|
||||
channels:
|
||||
- "chat.freenode.net#portapack"
|
||||
template:
|
||||
- "%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}"
|
||||
- "Change view : %{compare_url}"
|
||||
- "Build details : %{build_url}"
|
||||
# TODO: The "build_number.1" in this URL is almost certainly wrong, but correct value not available from Travis?
|
||||
- "Firmware download : https://jboone.github.io/portapack-havoc-nightly/"
|
||||
|
||||
before_install:
|
||||
- sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa -y
|
||||
- sudo apt-get update -q
|
||||
@ -65,9 +54,3 @@ addons:
|
||||
- cmake
|
||||
- dfu-util
|
||||
|
||||
deploy:
|
||||
provider: script
|
||||
skip-cleanup: true
|
||||
script: bash $TRAVIS_BUILD_DIR/tools/deploy-nightly.sh
|
||||
on:
|
||||
branch: master
|
||||
|
148
README.md
@ -1,135 +1,25 @@
|
||||
![HAVOC banner](doc/banner.png)
|
||||
## Fork of the unofficial HAVOC
|
||||
|
||||
HAVOC is an **unofficial** fork of the PortaPack H1 firmware, a portability add-on for the [HackRF One software-defined radio](http://greatscottgadgets.com/hackrf/).
|
||||
Keeping the latest release files and all features I found, and possible my own features in the future, around here. Check Releases
|
||||
|
||||
Hardware is available at [ShareBrained Technology](http://sharebrained.com/portapack).
|
||||
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CBPQA4HRRPJQ6&source=url)
|
||||
|
||||
It is build on top of [ShareBrained's firmware](https://github.com/sharebrained/portapack-hackrf/), meaning most of the original functionality remains the same.
|
||||
I only have this [Portapack H2+HackRF+battery](https://s.click.aliexpress.com/e/_dSMPvNo), so that's the version I'll be using for testing the releases before I post them here. BTW, if you have the same H2 (I know... I know it is a *dirty* clone) you could print my case:
|
||||
[![Case](docs/images/h2_front.jpg)](https://www.thingiverse.com/thing:4260973)
|
||||
|
||||
# Documentation & finding help
|
||||
<details>
|
||||
<summary>More details about the H2 case</summary>
|
||||
|
||||
[STL files](https://www.thingiverse.com/thing:4260973)
|
||||
|
||||
![Helpful note](doc/helpful.png)
|
||||
|
||||
</details>
|
||||
|
||||
Please RTFM before asking for help:
|
||||
* [Havoc wiki](https://github.com/furrtek/portapack-havoc/wiki)
|
||||
* [PortaPack wiki](https://github.com/sharebrained/portapack-hackrf/wiki)
|
||||
* [Some questions and answers](https://github.com/furrtek/portapack-havoc/issues)
|
||||
* [Facebook group](https://www.facebook.com/groups/177623356165819/) if that's your thing
|
||||
* And probably a bunch of posts on a variety of forums...
|
||||
|
||||
If you want to submit a bug report, use this page: https://github.com/furrtek/portapack-havoc/issues. Check if it hasn't been already posted, there's a search function. Also check the progress list below. Tickets which aren't related to the firmware itself, or the original HackRF and Portapack H1 will be closed.
|
||||
|
||||
# Summary
|
||||
|
||||
As its name implies, HAVOC's functions can be fun, mean or even useful sometimes. You probably shouldn't use them. No ! Bad ! Put it down.
|
||||
|
||||
**In most countries, radio transmissions are tightly regulated. Transmitting outside of free/public bands without a licence or authorization, even at very low power, is certainly forbidden where you live. Always bear that in mind. You're the ONLY ONE responsible for what you do with this software.**
|
||||
|
||||
# Fork features
|
||||
|
||||
* IQ file replay
|
||||
* Microphone FM transmit with CTCSS
|
||||
* CTCSS decoder
|
||||
* Frequency manager (save & load from SD card, with categories and notes)
|
||||
* File manager
|
||||
* "Soundboard" wave file player (put 8-bit mono files in SD card /wav directory)
|
||||
* ADS-B receiver with map view
|
||||
* ADS-B transmitter (aircraft spoof)
|
||||
* SSTV transmitter
|
||||
* Fully configurable jammer
|
||||
* POCSAG transmitter
|
||||
* POCSAG receiver/decoder
|
||||
* Morse transmitter (FM tone and CW)
|
||||
* OOK transmitter for common remote encoders (PT2262, doorbells, remote outlets, some garage doors, ...)
|
||||
* RDS (Radio Data System) PSN, RadioText and Time groups transmitter
|
||||
* Meteorological radiosonde receiver (M10, M2K2, ...)
|
||||
* AFSK receiver
|
||||
* AFSK transmitter (Bell202, ...)
|
||||
* Nuoptix DTMF sync transmitter (quite specific but can be useful in some theme parks :) )
|
||||
* TouchTunes jukebox universal remote (by Notpike)
|
||||
* LCR (Language de Commande Routier) message generator
|
||||
* Street lighting control transmitter (CCIR tones)
|
||||
* "Play Dead" in case of emergency
|
||||
* Fully configurable RF signal generator
|
||||
* RSSI audio output as pitch (for direction finding)
|
||||
|
||||
# Progress
|
||||
|
||||
Feature | Progress | Notes
|
||||
------- | -------- | -----
|
||||
POCSAG RX | 95% | Needs support for numeric messages
|
||||
Morse TX | 95% | Needs fox hunt scheduler and live keying mode
|
||||
Mic. TX | 95% | Carrier leak bug, need to find guard tones for various brands of wireless mics
|
||||
ADS-B RX | 90% | Needs angle and speed decoding
|
||||
Close-Call™ | 85% | Needs adjustments and optimization for wider frequency range
|
||||
ADS-B TX | 85% | Works but baseband module needs cleaning
|
||||
SSTV TX | 80% | Needs better bitmap file handling, support for other modes (ROBOT ?) and callsign FSK ID
|
||||
Radiosondes | 75% | Needs support for other models
|
||||
Wave visualizer | 70% | Needs cleaning and handling of other sample formats, high priority
|
||||
AFSK RX | 70% | Needs work regarding flexibility
|
||||
Sigfox RX | 40% | Tuning basics done, needs decoding code and testing
|
||||
Generic TXs | 30% | Raw AX.25, AFSK, FSK, CCIR, DTMF... Tonesets are ready
|
||||
CC1101 TRX | 10% | And other sub-GHz transceiver chips like SI4032...
|
||||
SSTV RX | 0% |
|
||||
Scanner | 0% | Easy, could be used with POCSAG RX to catch jumping channels
|
||||
SSB TX | 0% | Requested but math is hard :(
|
||||
OOK RX | 0% | See if rtl_433's author is fine with using protocol defs
|
||||
Analog TV TX| 0% | Enough CPU ? B&W and no sound ?
|
||||
LoJack RX | 0% | Basically AFSK RX
|
||||
DMR info RX | 0% | Retrieve DMR channel info. **No voice** because of vocoder complexity and possible legal issue
|
||||
Tetra info? | 0% | Same
|
||||
|
||||
# Screenshots
|
||||
|
||||
![HAVOC screenshots](doc/screenshots.png)
|
||||
|
||||
# Thanks
|
||||
|
||||
* Sig and cLx for research on AFSK LCR, Xylos, and for lending remote-controlled outlets
|
||||
* Pyr3x, Rainer Matla and DC1RDB for the donations :)
|
||||
* Keld Norman and Giorgio Campiotti for ideas and suggestions
|
||||
* In general, people who help making it better instead of asking already answered questions
|
||||
|
||||
# License
|
||||
|
||||
Except where specified in subdirectories of this project, all work is offered under the following license:
|
||||
|
||||
Copyright (C) 2013-2019 Jared Boone, ShareBrained Technology, Inc.
|
||||
|
||||
Copyright (C) 2015-2016 Furrtek
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301, USA.
|
||||
|
||||
# Contact
|
||||
|
||||
## Original firmware and hardware
|
||||
|
||||
Jared Boone <jared@sharebrained.com>
|
||||
|
||||
ShareBrained Technology, Inc.
|
||||
|
||||
<http://www.sharebrained.com/>
|
||||
|
||||
The latest version of this repository can be found at
|
||||
https://github.com/sharebrained/portapack-hackrf/
|
||||
|
||||
## HAVOC specific things
|
||||
|
||||
Warning: won't reply to questions about flashing and compiling. See links above.
|
||||
|
||||
Furrtek <furrtek@gmail.com>
|
||||
|
||||
<http://www.furrtek.org>
|
||||
<details>
|
||||
<summary>Printed magnetic cover for the H2 case</summary>
|
||||
|
||||
[![Cover](docs/images/h2_cover.jpg)](https://www.thingiverse.com/thing:4278961)
|
||||
|
||||
[STL files](https://www.thingiverse.com/thing:4278961)
|
||||
|
||||
</details>
|
||||
|
BIN
doc/banner.png
Before Width: | Height: | Size: 59 KiB |
BIN
doc/helpful.png
Before Width: | Height: | Size: 191 KiB |
Before Width: | Height: | Size: 114 KiB |
Before Width: | Height: | Size: 137 KiB |
BIN
doc/mainmenu.png
Before Width: | Height: | Size: 14 KiB |
BIN
doc/pj1.jpg
Before Width: | Height: | Size: 47 KiB |
BIN
doc/pj2.jpg
Before Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 12 KiB |
BIN
doc/pwmrssi.png
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 261 KiB |
BIN
doc/stealth.png
Before Width: | Height: | Size: 245 B |
Before Width: | Height: | Size: 20 KiB |
171
doc/widgets.txt
@ -1,171 +0,0 @@
|
||||
~ Pretty ugly PortaPack H1 (+HAVOC) UI widget documentation ~
|
||||
by @furrtek - v0.1 - 2017/02/02
|
||||
Not approved at all by @Sharebrained
|
||||
|
||||
The display is 240 x 320 pixels.
|
||||
|
||||
A View is basically a rectangular zone on the screen.
|
||||
Widgets (aka controls, UI elements...) go into Views.
|
||||
|
||||
Views can be pushed to/popped from a stack.
|
||||
The main menu view is at the bottom of the stack and can't be popped.
|
||||
The title bar view is a special case, it (normally) can't be hidden by pushed Views.
|
||||
Since the title bar is 16 pixel high, a regular full-screen view is 240 x 304 pixels.
|
||||
|
||||
If the current View can be popped (removed), an arrow shows on the left of the title bar.
|
||||
|
||||
Kind of widgets:
|
||||
|
||||
==== Rectangle ====
|
||||
|
||||
A simple filled or outlined rectangle. No interactivity.
|
||||
|
||||
Constructors:
|
||||
- Empty
|
||||
- Rectangle(Rect, Color)
|
||||
|
||||
Methods:
|
||||
- set_color(Color)
|
||||
- set_outline(bool): Default is filled, set to true for outline only
|
||||
|
||||
==== Text ====
|
||||
|
||||
A simple text label. No interactivity.
|
||||
|
||||
Constructors:
|
||||
- Empty
|
||||
- Text(Rect)
|
||||
- Text(Rect, std::string)
|
||||
|
||||
Methods:
|
||||
- set(std::string): Updates text
|
||||
|
||||
==== BigFrequency (HAVOC) ====
|
||||
|
||||
Displays a big 7-segment style frequency value in the XXXX.xxxMHz format.
|
||||
If the value is 0, ----.--- is displayed. No leading zeros. No interactivity.
|
||||
|
||||
Constructors:
|
||||
- BigFrequency(Rect, rf::Frequency)
|
||||
|
||||
Methods:
|
||||
- set(rf::Frequency): Updates value
|
||||
|
||||
==== ProgressBar (HAVOC) ====
|
||||
|
||||
Displays progress as an horizontal progress bar with value and maximum value.
|
||||
No interactivity.
|
||||
|
||||
Constructors:
|
||||
- ProgressBar(Rect)
|
||||
|
||||
Methods:
|
||||
- set_max(uint32_t): Updates maximum value
|
||||
- set_value(uint32_t): Updates current value
|
||||
|
||||
The maximum value is set by default to 100.
|
||||
|
||||
==== Console ====
|
||||
|
||||
Displays a scrolling text console. No interactivity.
|
||||
|
||||
Constructors:
|
||||
- Console(Rect)
|
||||
|
||||
Methods:
|
||||
- clear(): Clears text and resets cursor to top-left
|
||||
- write(std::string): Adds text
|
||||
- writeln(std::string): Adds text and CR + LF
|
||||
|
||||
==== Checkbox (HAVOC) ====
|
||||
|
||||
A toggle option shown as a tickable box with a text label.
|
||||
Interactive: select and touch.
|
||||
|
||||
Constructors:
|
||||
- Empty
|
||||
- Checkbox(Point, size_t, std::string)
|
||||
- Checkbox(Point, size_t, std::string, bool)
|
||||
|
||||
(Position, length of text label, text, regular size/small)
|
||||
|
||||
Methods:
|
||||
- bool value(): Returns state
|
||||
- set_text(std::string): Updates text label
|
||||
- set_value(bool): Sets state
|
||||
|
||||
Callbacks:
|
||||
- on_select: Select key press or touch. Returns state
|
||||
|
||||
==== Button ====
|
||||
|
||||
A momentary push-button. Interactive: select and touch.
|
||||
|
||||
Constructors:
|
||||
- Empty
|
||||
- Button(Rect, std::string)
|
||||
|
||||
Methods:
|
||||
- std::string text(): Returns text
|
||||
- set_text(std::string): Updates text
|
||||
|
||||
Callbacks:
|
||||
- on_select: Select key press or touch
|
||||
- on_dir: Direction keys press
|
||||
- on_highlight: Focus get
|
||||
|
||||
==== Image ====
|
||||
|
||||
Shows a 1-bit bitmap. No interactivity.
|
||||
|
||||
Constructors:
|
||||
- Empty
|
||||
- Image(Rect, Bitmap*, Color, Color)
|
||||
|
||||
(Rect, pointer to bitmap (see bitmap.hpp), foreground, background)
|
||||
|
||||
Methods:
|
||||
- set_bitmap(Bitmap*): Updates bitmap
|
||||
- set_foreground(Color): Changes foreground color
|
||||
- set_background(Color): Changes background color
|
||||
- invert_colors(): Flip foreground color with background
|
||||
|
||||
==== ImageButton ====
|
||||
|
||||
Same as the Image widget, except interactive (select and touch). No methods.
|
||||
|
||||
Constructors:
|
||||
- Empty
|
||||
- ImageButton(Rect, Bitmap*, Color, Color)
|
||||
|
||||
(Rect, pointer to bitmap (see bitmap.hpp), foreground, background)
|
||||
|
||||
Callbacks:
|
||||
- on_select: Select key press or touch
|
||||
|
||||
==== ImageOptionsField (HAVOC) ====
|
||||
|
||||
Options list displayed as images.
|
||||
Interactive: change (jog wheel) and focus.
|
||||
|
||||
Constructors:
|
||||
- Empty
|
||||
- ImageOptionsField(Rect, options_t)
|
||||
|
||||
options_t is a std::vector of std::pair of unsigned char pointers to color bitmap data and an int32_t
|
||||
|
||||
Methods:
|
||||
- set_options(options_t)
|
||||
- size_t selected_index()
|
||||
- size_t selected_index_value()
|
||||
- set_selected_index(size_t)
|
||||
- set_by_value(value_t)
|
||||
|
||||
Callbacks:
|
||||
- on_change: Option was changed
|
||||
- on_show_options: Focus get
|
||||
|
||||
==== OptionsField ====
|
||||
==== NumberField ====
|
||||
==== SymField (HAVOC) ====
|
||||
==== Waveform (HAVOC) ====
|
@ -1,31 +1,31 @@
|
||||
FROM ubuntu:xenial
|
||||
|
||||
# Set location to download ARM toolkit from.
|
||||
# This will need to be changed over time or replaced with a static link to the latest release.
|
||||
ENV ARMBINURL=https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2?revision=108bd959-44bd-4619-9c19-26187abf5225&la=en&hash=E788CE92E5DFD64B2A8C246BBA91A249CB8E2D2D \
|
||||
PATH=$HOME/bin:$PATH:/opt/build/armbin/bin
|
||||
|
||||
#Create volume /havoc/bin for compiled firmware binaries
|
||||
VOLUME /havoc
|
||||
WORKDIR /havoc/firmware
|
||||
|
||||
# Fetch dependencies from APT
|
||||
RUN apt-get update && \
|
||||
apt-get install -y git tar wget dfu-util cmake python3 python-pip ccache && \
|
||||
apt-get -qy autoremove
|
||||
|
||||
RUN pip install pyyaml
|
||||
|
||||
# Grab the GNU ARM toolchain from arm.com
|
||||
# Then extract contents to /opt/build/armbin/
|
||||
RUN mkdir /opt/build && cd /opt/build && \
|
||||
wget -O gcc-arm-none-eabi $ARMBINURL && \
|
||||
mkdir armbin && \
|
||||
tar --strip=1 -xjvf gcc-arm-none-eabi -C armbin
|
||||
|
||||
# Configure CCACHE
|
||||
RUN mkdir ~/bin && cd ~/bin && \
|
||||
for tool in gcc g++ cpp c++;do ln -s $(which ccache) arm-none-eabi-$tool;done
|
||||
|
||||
CMD cd .. && cd build && \
|
||||
FROM ubuntu:xenial
|
||||
|
||||
# Set location to download ARM toolkit from.
|
||||
# This will need to be changed over time or replaced with a static link to the latest release.
|
||||
ENV ARMBINURL=https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2?revision=108bd959-44bd-4619-9c19-26187abf5225&la=en&hash=E788CE92E5DFD64B2A8C246BBA91A249CB8E2D2D \
|
||||
PATH=$HOME/bin:$PATH:/opt/build/armbin/bin
|
||||
|
||||
#Create volume /havoc/bin for compiled firmware binaries
|
||||
VOLUME /havoc
|
||||
WORKDIR /havoc/firmware
|
||||
|
||||
# Fetch dependencies from APT
|
||||
RUN apt-get update && \
|
||||
apt-get install -y git tar wget dfu-util cmake python3 python-pip ccache && \
|
||||
apt-get -qy autoremove
|
||||
|
||||
RUN pip install pyyaml
|
||||
|
||||
# Grab the GNU ARM toolchain from arm.com
|
||||
# Then extract contents to /opt/build/armbin/
|
||||
RUN mkdir /opt/build && cd /opt/build && \
|
||||
wget -O gcc-arm-none-eabi $ARMBINURL && \
|
||||
mkdir armbin && \
|
||||
tar --strip=1 -xjvf gcc-arm-none-eabi -C armbin
|
||||
|
||||
# Configure CCACHE
|
||||
RUN mkdir ~/bin && cd ~/bin && \
|
||||
for tool in gcc g++ cpp c++;do ln -s $(which ccache) arm-none-eabi-$tool;done
|
||||
|
||||
CMD cd .. && cd build && \
|
||||
cmake .. && make firmware
|
1
docs/CNAME
Normal file
@ -0,0 +1 @@
|
||||
portapack.ried.cl
|
BIN
docs/favicon.ico
Normal file
After Width: | Height: | Size: 34 KiB |
BIN
docs/images/h2_cover.jpg
Normal file
After Width: | Height: | Size: 43 KiB |
BIN
docs/images/h2_front.jpg
Normal file
After Width: | Height: | Size: 150 KiB |
4
docs/index.html
Normal file
@ -0,0 +1,4 @@
|
||||
<h1>Portapack Havoc</h1>
|
||||
<h2>Nightly builds</h2>
|
||||
<p><a href="/fake.bin">fake.bin</a></p>
|
||||
<p><a href="/fake.bin">fake.bin</a></p>
|
@ -223,7 +223,7 @@ set(CPPSRC
|
||||
apps/ui_aprs_tx.cpp
|
||||
apps/ui_bht_tx.cpp
|
||||
apps/ui_coasterp.cpp
|
||||
# apps/ui_debug.cpp
|
||||
apps/ui_debug.cpp
|
||||
apps/ui_encoders.cpp
|
||||
apps/ui_fileman.cpp
|
||||
apps/ui_freqman.cpp
|
||||
@ -260,6 +260,7 @@ set(CPPSRC
|
||||
apps/lge_app.cpp
|
||||
apps/pocsag_app.cpp
|
||||
apps/replay_app.cpp
|
||||
apps/gps_sim_app.cpp
|
||||
apps/soundboard_app.cpp
|
||||
apps/tpms_app.cpp
|
||||
protocols/aprs.cpp
|
||||
@ -275,7 +276,7 @@ set(CPPSRC
|
||||
# ui_numbers.cpp
|
||||
# ui_replay_view.cpp
|
||||
# ui_script.cpp
|
||||
# ui_sd_card_debug.cpp
|
||||
ui_sd_card_debug.cpp
|
||||
${CPLD_20150901_DATA_CPP}
|
||||
${CPLD_20170522_DATA_CPP}
|
||||
${HACKRF_CPLD_DATA_CPP}
|
||||
|
260
firmware/application/apps/gps_sim_app.cpp
Normal file
@ -0,0 +1,260 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2016 Furrtek
|
||||
* Copyright (C) 2020 Shao
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "gps_sim_app.hpp"
|
||||
#include "string_format.hpp"
|
||||
|
||||
#include "ui_fileman.hpp"
|
||||
#include "io_file.hpp"
|
||||
|
||||
#include "baseband_api.hpp"
|
||||
#include "portapack.hpp"
|
||||
#include "portapack_persistent_memory.hpp"
|
||||
|
||||
using namespace portapack;
|
||||
|
||||
namespace ui {
|
||||
|
||||
void GpsSimAppView::set_ready() {
|
||||
ready_signal = true;
|
||||
}
|
||||
|
||||
void GpsSimAppView::on_file_changed(std::filesystem::path new_file_path) {
|
||||
File data_file, info_file;
|
||||
char file_data[257];
|
||||
|
||||
// Get file size
|
||||
auto data_open_error = data_file.open("/" + new_file_path.string());
|
||||
if (data_open_error.is_valid()) {
|
||||
file_error();
|
||||
return;
|
||||
}
|
||||
|
||||
file_path = new_file_path;
|
||||
|
||||
// Get original record frequency if available
|
||||
std::filesystem::path info_file_path = file_path;
|
||||
info_file_path.replace_extension(u".TXT");
|
||||
|
||||
sample_rate = 500000;
|
||||
|
||||
auto info_open_error = info_file.open("/" + info_file_path.string());
|
||||
if (!info_open_error.is_valid()) {
|
||||
memset(file_data, 0, 257);
|
||||
auto read_size = info_file.read(file_data, 256);
|
||||
if (!read_size.is_error()) {
|
||||
auto pos1 = strstr(file_data, "center_frequency=");
|
||||
if (pos1) {
|
||||
pos1 += 17;
|
||||
field_frequency.set_value(strtoll(pos1, nullptr, 10));
|
||||
}
|
||||
|
||||
auto pos2 = strstr(file_data, "sample_rate=");
|
||||
if (pos2) {
|
||||
pos2 += 12;
|
||||
sample_rate = strtoll(pos2, nullptr, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
text_sample_rate.set(unit_auto_scale(sample_rate, 3, 1) + "Hz");
|
||||
|
||||
auto file_size = data_file.size();
|
||||
auto duration = (file_size * 1000) / (1 * 2 * sample_rate);
|
||||
|
||||
progressbar.set_max(file_size);
|
||||
text_filename.set(file_path.filename().string().substr(0, 12));
|
||||
text_duration.set(to_string_time_ms(duration));
|
||||
|
||||
button_play.focus();
|
||||
}
|
||||
|
||||
void GpsSimAppView::on_tx_progress(const uint32_t progress) {
|
||||
progressbar.set_value(progress);
|
||||
}
|
||||
|
||||
void GpsSimAppView::focus() {
|
||||
button_open.focus();
|
||||
}
|
||||
|
||||
void GpsSimAppView::file_error() {
|
||||
nav_.display_modal("Error", "File read error.");
|
||||
}
|
||||
|
||||
bool GpsSimAppView::is_active() const {
|
||||
return (bool)replay_thread;
|
||||
}
|
||||
|
||||
void GpsSimAppView::toggle() {
|
||||
if( is_active() ) {
|
||||
stop(false);
|
||||
} else {
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
void GpsSimAppView::start() {
|
||||
stop(false);
|
||||
|
||||
std::unique_ptr<stream::Reader> reader;
|
||||
|
||||
auto p = std::make_unique<FileReader>();
|
||||
auto open_error = p->open(file_path);
|
||||
if( open_error.is_valid() ) {
|
||||
file_error();
|
||||
} else {
|
||||
reader = std::move(p);
|
||||
}
|
||||
|
||||
if( reader ) {
|
||||
button_play.set_bitmap(&bitmap_stop);
|
||||
baseband::set_sample_rate(sample_rate );
|
||||
|
||||
replay_thread = std::make_unique<ReplayThread>(
|
||||
std::move(reader),
|
||||
read_size, buffer_count,
|
||||
&ready_signal,
|
||||
[](uint32_t return_code) {
|
||||
ReplayThreadDoneMessage message { return_code };
|
||||
EventDispatcher::send_message(message);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
radio::enable({
|
||||
receiver_model.tuning_frequency(),
|
||||
sample_rate ,
|
||||
baseband_bandwidth,
|
||||
rf::Direction::Transmit,
|
||||
receiver_model.rf_amp(),
|
||||
static_cast<int8_t>(receiver_model.lna()),
|
||||
static_cast<int8_t>(receiver_model.vga())
|
||||
});
|
||||
}
|
||||
|
||||
void GpsSimAppView::stop(const bool do_loop) {
|
||||
if( is_active() )
|
||||
replay_thread.reset();
|
||||
|
||||
if (do_loop && check_loop.value()) {
|
||||
start();
|
||||
} else {
|
||||
radio::disable();
|
||||
button_play.set_bitmap(&bitmap_play);
|
||||
}
|
||||
|
||||
ready_signal = false;
|
||||
}
|
||||
|
||||
void GpsSimAppView::handle_replay_thread_done(const uint32_t return_code) {
|
||||
if (return_code == ReplayThread::END_OF_FILE) {
|
||||
stop(true);
|
||||
} else if (return_code == ReplayThread::READ_ERROR) {
|
||||
stop(false);
|
||||
file_error();
|
||||
}
|
||||
|
||||
progressbar.set_value(0);
|
||||
}
|
||||
|
||||
GpsSimAppView::GpsSimAppView(
|
||||
NavigationView& nav
|
||||
) : nav_ (nav)
|
||||
{
|
||||
baseband::run_image(portapack::spi_flash::image_tag_gps);
|
||||
|
||||
add_children({
|
||||
&labels,
|
||||
&button_open,
|
||||
&text_filename,
|
||||
&text_sample_rate,
|
||||
&text_duration,
|
||||
&progressbar,
|
||||
&field_frequency,
|
||||
&field_lna,
|
||||
&field_rf_amp,
|
||||
&check_loop,
|
||||
&button_play,
|
||||
&waterfall,
|
||||
});
|
||||
|
||||
field_frequency.set_value(target_frequency());
|
||||
field_frequency.set_step(receiver_model.frequency_step());
|
||||
field_frequency.on_change = [this](rf::Frequency f) {
|
||||
this->on_target_frequency_changed(f);
|
||||
};
|
||||
field_frequency.on_edit = [this, &nav]() {
|
||||
// TODO: Provide separate modal method/scheme?
|
||||
auto new_view = nav.push<FrequencyKeypadView>(this->target_frequency());
|
||||
new_view->on_changed = [this](rf::Frequency f) {
|
||||
this->on_target_frequency_changed(f);
|
||||
this->field_frequency.set_value(f);
|
||||
};
|
||||
};
|
||||
|
||||
field_frequency.set_step(5000);
|
||||
|
||||
button_play.on_select = [this](ImageButton&) {
|
||||
this->toggle();
|
||||
};
|
||||
|
||||
button_open.on_select = [this, &nav](Button&) {
|
||||
auto open_view = nav.push<FileLoadView>(".C8");
|
||||
open_view->on_changed = [this](std::filesystem::path new_file_path) {
|
||||
on_file_changed(new_file_path);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
GpsSimAppView::~GpsSimAppView() {
|
||||
radio::disable();
|
||||
baseband::shutdown();
|
||||
}
|
||||
|
||||
void GpsSimAppView::on_hide() {
|
||||
// TODO: Terrible kludge because widget system doesn't notify Waterfall that
|
||||
// it's being shown or hidden.
|
||||
waterfall.on_hide();
|
||||
View::on_hide();
|
||||
}
|
||||
|
||||
void GpsSimAppView::set_parent_rect(const Rect new_parent_rect) {
|
||||
View::set_parent_rect(new_parent_rect);
|
||||
|
||||
const ui::Rect waterfall_rect { 0, header_height, new_parent_rect.width(), new_parent_rect.height() - header_height };
|
||||
waterfall.set_parent_rect(waterfall_rect);
|
||||
}
|
||||
|
||||
void GpsSimAppView::on_target_frequency_changed(rf::Frequency f) {
|
||||
set_target_frequency(f);
|
||||
}
|
||||
|
||||
void GpsSimAppView::set_target_frequency(const rf::Frequency new_value) {
|
||||
persistent_memory::set_tuned_frequency(new_value);;
|
||||
}
|
||||
|
||||
rf::Frequency GpsSimAppView::target_frequency() const {
|
||||
return persistent_memory::tuned_frequency();
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
157
firmware/application/apps/gps_sim_app.hpp
Normal file
@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2016 Furrtek
|
||||
* Copyright (C) 2020 Shao
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GPS_SIM_APP_HPP__
|
||||
#define __GPS_SIM_APP_HPP__
|
||||
|
||||
#include "ui_widget.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "ui_receiver.hpp"
|
||||
#include "replay_thread.hpp"
|
||||
#include "ui_spectrum.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
namespace ui {
|
||||
|
||||
class GpsSimAppView : public View {
|
||||
public:
|
||||
GpsSimAppView(NavigationView& nav);
|
||||
~GpsSimAppView();
|
||||
|
||||
void on_hide() override;
|
||||
void set_parent_rect(const Rect new_parent_rect) override;
|
||||
void focus() override;
|
||||
|
||||
std::string title() const override { return "GPS Simulator"; };
|
||||
|
||||
private:
|
||||
NavigationView& nav_;
|
||||
|
||||
static constexpr ui::Dim header_height = 3 * 16;
|
||||
|
||||
uint32_t sample_rate = 0;
|
||||
static constexpr uint32_t baseband_bandwidth = 3000000; //filter bandwidth
|
||||
const size_t read_size { 16384 };
|
||||
const size_t buffer_count { 3 };
|
||||
|
||||
void on_file_changed(std::filesystem::path new_file_path);
|
||||
void on_target_frequency_changed(rf::Frequency f);
|
||||
void on_tx_progress(const uint32_t progress);
|
||||
|
||||
void set_target_frequency(const rf::Frequency new_value);
|
||||
rf::Frequency target_frequency() const;
|
||||
|
||||
void toggle();
|
||||
void start();
|
||||
void stop(const bool do_loop);
|
||||
bool is_active() const;
|
||||
void set_ready();
|
||||
void handle_replay_thread_done(const uint32_t return_code);
|
||||
void file_error();
|
||||
|
||||
std::filesystem::path file_path { };
|
||||
std::unique_ptr<ReplayThread> replay_thread { };
|
||||
bool ready_signal { false };
|
||||
|
||||
Labels labels {
|
||||
{ { 10 * 8, 2 * 16 }, "LNA: A:", Color::light_grey() }
|
||||
};
|
||||
|
||||
Button button_open {
|
||||
{ 0 * 8, 0 * 16, 10 * 8, 2 * 16 },
|
||||
"Open file"
|
||||
};
|
||||
|
||||
Text text_filename {
|
||||
{ 11 * 8, 0 * 16, 12 * 8, 16 },
|
||||
"-"
|
||||
};
|
||||
Text text_sample_rate {
|
||||
{ 24 * 8, 0 * 16, 6 * 8, 16 },
|
||||
"-"
|
||||
};
|
||||
|
||||
Text text_duration {
|
||||
{ 11 * 8, 1 * 16, 6 * 8, 16 },
|
||||
"-"
|
||||
};
|
||||
ProgressBar progressbar {
|
||||
{ 18 * 8, 1 * 16, 12 * 8, 16 }
|
||||
};
|
||||
|
||||
FrequencyField field_frequency {
|
||||
{ 0 * 8, 2 * 16 },
|
||||
};
|
||||
LNAGainField field_lna {
|
||||
{ 14 * 8, 2 * 16 }
|
||||
};
|
||||
RFAmpField field_rf_amp {
|
||||
{ 19 * 8, 2 * 16 }
|
||||
};
|
||||
Checkbox check_loop {
|
||||
{ 21 * 8, 2 * 16 },
|
||||
4,
|
||||
"Loop",
|
||||
true
|
||||
};
|
||||
ImageButton button_play {
|
||||
{ 28 * 8, 2 * 16, 2 * 8, 1 * 16 },
|
||||
&bitmap_play,
|
||||
Color::green(),
|
||||
Color::black()
|
||||
};
|
||||
|
||||
spectrum::WaterfallWidget waterfall { };
|
||||
|
||||
MessageHandlerRegistration message_handler_replay_thread_error {
|
||||
Message::ID::ReplayThreadDone,
|
||||
[this](const Message* const p) {
|
||||
const auto message = *reinterpret_cast<const ReplayThreadDoneMessage*>(p);
|
||||
this->handle_replay_thread_done(message.return_code);
|
||||
}
|
||||
};
|
||||
|
||||
MessageHandlerRegistration message_handler_fifo_signal {
|
||||
Message::ID::RequestSignal,
|
||||
[this](const Message* const p) {
|
||||
const auto message = static_cast<const RequestSignalMessage*>(p);
|
||||
if (message->signal == RequestSignalMessage::Signal::FillRequest) {
|
||||
this->set_ready();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MessageHandlerRegistration message_handler_tx_progress {
|
||||
Message::ID::TXProgress,
|
||||
[this](const Message* const p) {
|
||||
const auto message = *reinterpret_cast<const TXProgressMessage*>(p);
|
||||
this->on_tx_progress(message.progress);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
#endif/*__GPS_SIM_APP_HPP__*/
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include "audio.hpp"
|
||||
|
||||
// #include "ui_sd_card_debug.hpp"
|
||||
#include "ui_sd_card_debug.hpp"
|
||||
|
||||
#include "portapack.hpp"
|
||||
using namespace portapack;
|
||||
@ -347,7 +347,7 @@ DebugMenuView::DebugMenuView(NavigationView& nav) {
|
||||
add_items({
|
||||
{ "Memory", ui::Color::white(), nullptr, [&nav](){ nav.push<DebugMemoryView>(); } },
|
||||
{ "Radio State", ui::Color::white(), nullptr, [&nav](){ nav.push<NotImplementedView>(); } },
|
||||
//{ "SD Card", ui::Color::white(), nullptr, [&nav](){ nav.push<SDCardDebugView>(); } },
|
||||
{ "SD Card", ui::Color::white(), nullptr, [&nav](){ nav.push<SDCardDebugView>(); } },
|
||||
{ "Peripherals", ui::Color::white(), nullptr, [&nav](){ nav.push<DebugPeripheralsMenuView>(); } },
|
||||
{ "Temperature", ui::Color::white(), nullptr, [&nav](){ nav.push<TemperatureView>(); } },
|
||||
{ "Controls", ui::Color::white(), nullptr, [&nav](){ nav.push<DebugControlsView>(); } }, });
|
||||
|
@ -1503,6 +1503,28 @@ static constexpr Bitmap bitmap_icon_replay {
|
||||
{ 16, 16 }, bitmap_icon_replay_data
|
||||
};
|
||||
|
||||
static constexpr uint8_t bitmap_gps_sim_data[] = {
|
||||
0x00, 0x00,
|
||||
0x00, 0x00,
|
||||
0x00, 0x00,
|
||||
0xF0, 0x0F,
|
||||
0x4C, 0x32,
|
||||
0xFE, 0x7F,
|
||||
0x25, 0xA4,
|
||||
0x25, 0xA4,
|
||||
0xFF, 0xFF,
|
||||
0x25, 0xA4,
|
||||
0x25, 0xA4,
|
||||
0xFE, 0x7F,
|
||||
0x4C, 0x32,
|
||||
0xF0, 0x0F,
|
||||
0x00, 0x00,
|
||||
0x00, 0x00,
|
||||
};
|
||||
static constexpr Bitmap bitmap_gps_sim {
|
||||
{ 16, 16 }, bitmap_gps_sim_data
|
||||
};
|
||||
|
||||
static constexpr uint8_t bitmap_icon_btle_data[] = {
|
||||
0x00, 0x00,
|
||||
0x80, 0x00,
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include "ui_aprs_tx.hpp"
|
||||
#include "ui_bht_tx.hpp"
|
||||
#include "ui_coasterp.hpp"
|
||||
//#include "ui_debug.hpp"
|
||||
#include "ui_debug.hpp"
|
||||
#include "ui_encoders.hpp"
|
||||
#include "ui_fileman.hpp"
|
||||
#include "ui_freqman.hpp"
|
||||
@ -76,6 +76,7 @@
|
||||
#include "lge_app.hpp"
|
||||
#include "pocsag_app.hpp"
|
||||
#include "replay_app.hpp"
|
||||
#include "gps_sim_app.hpp"
|
||||
#include "soundboard_app.hpp"
|
||||
#include "tpms_app.hpp"
|
||||
|
||||
@ -377,6 +378,7 @@ TransmittersMenuView::TransmittersMenuView(NavigationView& nav) {
|
||||
{ "ADS-B [S]", ui::Color::yellow(), &bitmap_icon_adsb, [&nav](){ nav.push<ADSBTxView>(); } },
|
||||
{ "APRS", ui::Color::orange(), &bitmap_icon_aprs, [&nav](){ nav.push<APRSTXView>(); } },
|
||||
{ "BHT Xy/EP", ui::Color::green(), &bitmap_icon_bht, [&nav](){ nav.push<BHTView>(); } },
|
||||
{ "GPS Sim", ui::Color::yellow(), &bitmap_gps_sim, [&nav](){ nav.push<GpsSimAppView>(); } },
|
||||
{ "Jammer", ui::Color::yellow(), &bitmap_icon_jammer, [&nav](){ nav.push<JammerView>(); } },
|
||||
{ "Key fob", ui::Color::orange(), &bitmap_icon_keyfob, [&nav](){ nav.push<KeyfobView>(); } },
|
||||
{ "LGE tool", ui::Color::yellow(), &bitmap_icon_lge, [&nav](){ nav.push<LGEView>(); } },
|
||||
@ -436,7 +438,7 @@ SystemMenuView::SystemMenuView(NavigationView& nav) {
|
||||
{ "Scanner", ui::Color::orange(), &bitmap_icon_scanner, [&nav](){ nav.push<ScannerView>(); } },
|
||||
{ "Utilities", ui::Color::light_grey(), &bitmap_icon_utilities, [&nav](){ nav.push<UtilitiesMenuView>(); } },
|
||||
{ "Settings", ui::Color::cyan(), &bitmap_icon_setup, [&nav](){ nav.push<SettingsMenuView>(); } },
|
||||
//{ "Debug", ui::Color::cyan(), nullptr, [&nav](){ nav.push<DebugMenuView>(); } },
|
||||
{ "Debug", ui::Color::cyan(), nullptr, [&nav](){ nav.push<DebugMenuView>(); } },
|
||||
{ "HackRF", ui::Color::cyan(), &bitmap_icon_hackrf, [this, &nav](){ hackrf_mode(nav); } },
|
||||
{ "About", ui::Color::cyan(), nullptr, [&nav](){ nav.push<AboutView>(); } }
|
||||
});
|
||||
|
@ -437,6 +437,13 @@ set(MODE_CPPSRC
|
||||
)
|
||||
DeclareTargets(PREP replay)
|
||||
|
||||
### GPS Simulator
|
||||
|
||||
set(MODE_CPPSRC
|
||||
proc_gps_sim.cpp
|
||||
)
|
||||
DeclareTargets(PGPS gps_sim)
|
||||
|
||||
### Signal generator
|
||||
|
||||
set(MODE_CPPSRC
|
||||
|
143
firmware/baseband/proc_gps_sim.cpp
Normal file
@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2016 Furrtek
|
||||
* Copyright (C) 2020 Shao
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "proc_gps_sim.hpp"
|
||||
#include "sine_table_int8.hpp"
|
||||
#include "portapack_shared_memory.hpp"
|
||||
|
||||
#include "event_m4.hpp"
|
||||
|
||||
#include "utility.hpp"
|
||||
|
||||
ReplayProcessor::ReplayProcessor() {
|
||||
channel_filter_pass_f = taps_200k_decim_1.pass_frequency_normalized * 1000000; // 162760.416666667
|
||||
channel_filter_stop_f = taps_200k_decim_1.stop_frequency_normalized * 1000000; // 337239.583333333
|
||||
|
||||
spectrum_samples = 0;
|
||||
|
||||
channel_spectrum.set_decimation_factor(1);
|
||||
|
||||
configured = false;
|
||||
}
|
||||
|
||||
void ReplayProcessor::execute(const buffer_c8_t& buffer) {
|
||||
/* 4MHz, 2048 samples */
|
||||
|
||||
if (!configured) return;
|
||||
|
||||
// File data is in C16 format, we need C8
|
||||
// File samplerate is 500kHz, we're at 4MHz
|
||||
// iq_buffer can only be 512 C16 samples (RAM limitation)
|
||||
// To fill up the 2048-sample C8 buffer, we need:
|
||||
// 2048 samples * 2 bytes per sample = 4096 bytes
|
||||
// Since we're oversampling by 4M/500k = 8, we only need 2048/8 = 256 samples from the file and duplicate them 8 times each
|
||||
// So 256 * 4 bytes per sample (C16) = 1024 bytes from the file
|
||||
if( stream ) { //sizeof(*buffer.p) = sizeof(C8) = 2*int8 = 2 bytes //buffer.count = 2048
|
||||
const size_t bytes_to_read = sizeof(*buffer.p) * 1 * (buffer.count ); // *2 (C16), /8 (oversampling) should be == 1024
|
||||
bytes_read += stream->read(iq_buffer.p, bytes_to_read);
|
||||
}
|
||||
|
||||
// Fill and "stretch"
|
||||
for (size_t i = 0; i < buffer.count; i++) {
|
||||
/*if (i & 3) {
|
||||
buffer.p[i] = buffer.p[i - 1];
|
||||
} else {
|
||||
auto re_out = iq_buffer.p[i >> 3].real() ;
|
||||
auto im_out = iq_buffer.p[i >> 3].imag() ;
|
||||
buffer.p[i] = { (int8_t)re_out, (int8_t)im_out };
|
||||
}*/
|
||||
/*
|
||||
if (i % 8 != 0) {
|
||||
buffer.p[i] = buffer.p[i - 1];
|
||||
} else {
|
||||
auto re_out = iq_buffer.p[i/8].real() ;
|
||||
auto im_out = iq_buffer.p[i/8].imag() ;
|
||||
buffer.p[i] = { (int8_t)re_out, (int8_t)im_out };
|
||||
}*/
|
||||
|
||||
auto re_out = iq_buffer.p[i].real() ;
|
||||
auto im_out = iq_buffer.p[i].imag() ;
|
||||
buffer.p[i] = { (int8_t)re_out, (int8_t)im_out };
|
||||
}
|
||||
|
||||
spectrum_samples += buffer.count;
|
||||
if( spectrum_samples >= spectrum_interval_samples ) {
|
||||
spectrum_samples -= spectrum_interval_samples;
|
||||
//channel_spectrum.feed(iq_buffer, channel_filter_pass_f, channel_filter_stop_f);
|
||||
|
||||
txprogress_message.progress = bytes_read; // Inform UI about progress
|
||||
txprogress_message.done = false;
|
||||
shared_memory.application_queue.push(txprogress_message);
|
||||
}
|
||||
}
|
||||
|
||||
void ReplayProcessor::on_message(const Message* const message) {
|
||||
switch(message->id) {
|
||||
case Message::ID::UpdateSpectrum:
|
||||
case Message::ID::SpectrumStreamingConfig:
|
||||
channel_spectrum.on_message(message);
|
||||
break;
|
||||
|
||||
case Message::ID::SamplerateConfig:
|
||||
samplerate_config(*reinterpret_cast<const SamplerateConfigMessage*>(message));
|
||||
break;
|
||||
|
||||
case Message::ID::ReplayConfig:
|
||||
configured = false;
|
||||
bytes_read = 0;
|
||||
replay_config(*reinterpret_cast<const ReplayConfigMessage*>(message));
|
||||
break;
|
||||
|
||||
// App has prefilled the buffers, we're ready to go now
|
||||
case Message::ID::FIFOData:
|
||||
configured = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ReplayProcessor::samplerate_config(const SamplerateConfigMessage& message) {
|
||||
baseband_fs = message.sample_rate;
|
||||
baseband_thread.set_sampling_rate(baseband_fs);
|
||||
spectrum_interval_samples = baseband_fs / spectrum_rate_hz;
|
||||
}
|
||||
|
||||
void ReplayProcessor::replay_config(const ReplayConfigMessage& message) {
|
||||
if( message.config ) {
|
||||
|
||||
stream = std::make_unique<StreamOutput>(message.config);
|
||||
|
||||
// Tell application that the buffers and FIFO pointers are ready, prefill
|
||||
shared_memory.application_queue.push(sig_message);
|
||||
} else {
|
||||
stream.reset();
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
EventDispatcher event_dispatcher { std::make_unique<ReplayProcessor>() };
|
||||
event_dispatcher.run();
|
||||
return 0;
|
||||
}
|
77
firmware/baseband/proc_gps_sim.hpp
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2016 Furrtek
|
||||
* Copyright (C) 2020 Shao
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __PROC_GPS_SIM_HPP__
|
||||
#define __PROC_GPS_SIM_HPP__
|
||||
|
||||
#include "baseband_processor.hpp"
|
||||
#include "baseband_thread.hpp"
|
||||
|
||||
#include "spectrum_collector.hpp"
|
||||
|
||||
#include "stream_output.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
|
||||
class ReplayProcessor : public BasebandProcessor {
|
||||
public:
|
||||
ReplayProcessor();
|
||||
|
||||
void execute(const buffer_c8_t& buffer) override;
|
||||
|
||||
void on_message(const Message* const message) override;
|
||||
|
||||
private:
|
||||
size_t baseband_fs = 0;
|
||||
static constexpr auto spectrum_rate_hz = 50.0f;
|
||||
|
||||
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Transmit };
|
||||
|
||||
std::array<complex8_t, 2048> iq { };
|
||||
const buffer_c8_t iq_buffer {
|
||||
iq.data(),
|
||||
iq.size(),
|
||||
baseband_fs
|
||||
};
|
||||
|
||||
uint32_t channel_filter_pass_f = 0;
|
||||
uint32_t channel_filter_stop_f = 0;
|
||||
|
||||
std::unique_ptr<StreamOutput> stream { };
|
||||
|
||||
SpectrumCollector channel_spectrum { };
|
||||
size_t spectrum_interval_samples = 0;
|
||||
size_t spectrum_samples = 0;
|
||||
|
||||
bool configured { false };
|
||||
uint32_t bytes_read { 0 };
|
||||
|
||||
void samplerate_config(const SamplerateConfigMessage& message);
|
||||
void replay_config(const ReplayConfigMessage& message);
|
||||
|
||||
TXProgressMessage txprogress_message { };
|
||||
RequestSignalMessage sig_message { RequestSignalMessage::Signal::FillRequest };
|
||||
};
|
||||
|
||||
#endif/*__PROC_GPS_SIM_HPP__*/
|
@ -92,6 +92,7 @@ constexpr image_tag_t image_tag_mic_tx { 'P', 'M', 'T', 'X' };
|
||||
constexpr image_tag_t image_tag_ook { 'P', 'O', 'O', 'K' };
|
||||
constexpr image_tag_t image_tag_rds { 'P', 'R', 'D', 'S' };
|
||||
constexpr image_tag_t image_tag_replay { 'P', 'R', 'E', 'P' };
|
||||
constexpr image_tag_t image_tag_gps { 'P', 'G', 'P', 'S' };
|
||||
constexpr image_tag_t image_tag_siggen { 'P', 'S', 'I', 'G' };
|
||||
constexpr image_tag_t image_tag_sstv_tx { 'P', 'S', 'T', 'X' };
|
||||
constexpr image_tag_t image_tag_tones { 'P', 'T', 'O', 'N' };
|
||||
|
@ -1,43 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
printf "Hold down the HackRF's DFU button (the button closest to the antenna jack)\n"
|
||||
printf "then plug the HackRF into a USB port on your computer.\n\n"
|
||||
printf "After the HackRF is plugged in, you may release the DFU button.\n"
|
||||
printf "Press any key to continue or ^c to abort\n"
|
||||
read
|
||||
|
||||
for i in /usr/share/hackrf/hackrf_one_usb.dfu /usr/share/hackrf/hackrf_one_usb_ram.dfu hackrf_one_usb.dfu; do
|
||||
if [ -r "${i}" ]; then
|
||||
ram_firmware="${i}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "${ram_firmware}" ]; then
|
||||
printf "\nFound firmware: ${ram_firmware}\n"
|
||||
printf "Flashing...\n"
|
||||
else
|
||||
printf "Unable to find firmware to flash, please have hackrf_one_usb.dfu\n"
|
||||
printf "in current directory or /usr/share/hackrf/\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for i in /usr/share/hackrf/hackrf_one_usb.bin /usr/share/hackrf/hackrf_one_usb_rom_to_ram.bin hackrf_one_usb.bin; do
|
||||
if [ -r "${i}" ]; then
|
||||
rom_firmware="${i}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "${rom_firmware}" ]; then
|
||||
printf "\nFound firmware: ${rom_firmware}\n"
|
||||
printf "Flashing...\n"
|
||||
else
|
||||
printf "Unable to find firmware to flash, please have hackrf_one_usb.bin\n"
|
||||
printf "in current directory or /usr/share/hackrf/\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dfu-util --device 1fc9:000c --download "${ram_firmware}" --reset
|
||||
sleep 2s
|
||||
hackrf_spiflash -w "${rom_firmware}"
|
@ -1,43 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
printf "Hold down the HackRF's DFU button (the button closest to the antenna jack)\n"
|
||||
printf "then plug the HackRF into a USB port on your computer.\n\n"
|
||||
printf "After the HackRF is plugged in, you may release the DFU button.\n"
|
||||
printf "Press any key to continue or ^c to abort\n"
|
||||
read
|
||||
|
||||
for i in /usr/share/hackrf/hackrf_one_usb.dfu /usr/share/hackrf/hackrf_one_usb_ram.dfu hackrf_one_usb.dfu; do
|
||||
if [ -r "${i}" ]; then
|
||||
ram_firmware="${i}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "${ram_firmware}" ]; then
|
||||
printf "\nFound firmware: ${ram_firmware}\n"
|
||||
printf "Flashing...\n"
|
||||
else
|
||||
printf "Unable to find firmware to flash, please have hackrf_one_usb.dfu\n"
|
||||
printf "in current directory or /usr/share/hackrf/\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for i in /usr/share/hackrf/portapack-h1-firmware.bin portapack-h1-firmware.bin; do
|
||||
if [ -r "${i}" ]; then
|
||||
rom_firmware="${i}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "${rom_firmware}" ]; then
|
||||
printf "\nFound firmware: ${rom_firmware}\n"
|
||||
printf "Flashing...\n"
|
||||
else
|
||||
printf "Unable to find firmware to flash, please have portapack-h1-firmware.bin\n"
|
||||
printf "in current directory or /usr/share/hackrf/\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dfu-util --device 1fc9:000c --download "${ram_firmware}" --reset
|
||||
sleep 2s
|
||||
hackrf_spiflash -w "${rom_firmware}"
|
@ -1,57 +0,0 @@
|
||||
#!/bin/bash
|
||||
PUBLICATION_BRANCH=master
|
||||
# set -x
|
||||
cd $HOME
|
||||
# Checkout the branch
|
||||
git clone --branch=$PUBLICATION_BRANCH https://${GITHUB_TOKEN}@github.com/${ARTEFACT_REPO}.git publish
|
||||
cd publish
|
||||
# Update pages
|
||||
BUILD_PATH=$BUILD_DATE-$SHORT_COMMIT_HASH
|
||||
mkdir $BUILD_PATH
|
||||
cp $ARTEFACT_BASE/$BUILD_NAME.tar.xz $BUILD_PATH/
|
||||
cp $ARTEFACT_BASE/MD5SUMS $BUILD_PATH/
|
||||
cp $ARTEFACT_BASE/SHA256SUMS $BUILD_PATH/
|
||||
# Write index page
|
||||
cd $TRAVIS_BUILD_DIR
|
||||
COMMITS=`git log --oneline | awk '{print $1}'`
|
||||
cd $HOME/publish
|
||||
echo "
|
||||
<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
|
||||
<html><head>
|
||||
<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">
|
||||
<title>$PROJECT_NAME Builds</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>$PROJECT_NAME Builds</h2>
|
||||
<table>
|
||||
" > index.html
|
||||
|
||||
for commit in $COMMITS; do
|
||||
FILEPATH=`find . -maxdepth 2 -name "*-$commit.tar.xz"`
|
||||
if [ "$FILEPATH" != "" ]; then
|
||||
FILEDIR=`dirname "${FILEPATH}"`
|
||||
FILENAME=`basename "${FILEPATH}"`
|
||||
FILEPATH=${FILEPATH:2}
|
||||
# pushd "${FILEDIR}"
|
||||
# HASH_MD5=`md5sum --binary ${FILENAME}`
|
||||
# HASH_SHA256=`sha256sum --binary ${FILENAME}`
|
||||
# popd
|
||||
echo "<tr><td><a href=\"$FILEPATH\">$FILENAME</a></td><td><a href=\"$FILEDIR/MD5SUMS\">MD5SUMS</a></td><td><a href=\"$FILEDIR/SHA256SUMS\">SHA256SUMS</a></td></tr>" >> index.html
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
echo "
|
||||
</table>
|
||||
</body></html>
|
||||
" >> index.html
|
||||
|
||||
# Commit and push latest version
|
||||
git add $BUILD_PATH/$BUILD_NAME.tar.xz $BUILD_PATH/MD5SUMS $BUILD_PATH/SHA256SUMS index.html
|
||||
git config user.name "Travis"
|
||||
git config user.email "travis@travis-ci.org"
|
||||
git commit -m "Build products for $SHORT_COMMIT_HASH, built on $TRAVIS_OS_NAME, log: $TRAVIS_BUILD_WEB_URL"
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "Looks like the commit failed"
|
||||
fi
|
||||
git push -fq origin $PUBLICATION_BRANCH
|