194 Commits

Author SHA1 Message Date
5f388fd38d add dependency to soapysdr-tool to make SoapySDRUtil available 2020-02-19 20:06:27 +01:00
9bc161c140 split the manifest step into a separate skript 2020-02-18 22:47:51 +01:00
dbb7c0cde3 remove the "under construction" banner 2020-02-18 22:26:44 +01:00
52e517dfc3 make tags overridable from the outside 2020-02-18 21:52:52 +01:00
37ffb2a02c break lines at 80 chars 2020-02-18 21:19:00 +01:00
91b3713dad fix date 2020-02-18 21:09:22 +01:00
c53ac1aa4f pin the dependency release commits 2020-02-18 20:58:01 +01:00
c4166997be release version 0.18 2020-02-18 20:55:24 +01:00
f0f9455c6e add the changelog to the debian package 2020-02-18 20:53:53 +01:00
7bc78425cd add user to plugdev group, fix some lintian issues 2020-02-17 17:05:31 +01:00
d1dc14d9e5 don't put debian files in docker builds 2020-02-17 15:03:39 +01:00
521755b9f2 create and use custom user on debian install 2020-02-17 15:03:20 +01:00
ad565c5a2b re-wire the audio output to "null" - thanks to @dl9rdz 2020-02-17 12:06:13 +01:00
ebba6e1ada use more cpu cores 2020-02-16 12:19:49 +01:00
0b7b5d985f update copyright date 2020-02-16 11:49:20 +01:00
b948e06a4f use urllib to update sdr.hu, no wget dependency
ref: #52
2020-02-15 00:16:04 +01:00
eaa98b0d64 new status controller as json 2020-02-09 21:46:03 +01:00
16b3c11678 add soapy remote to docker build, too 2020-02-09 15:23:17 +01:00
c92929a32d add soapyremote source 2020-02-09 13:59:37 +01:00
46c3e5077d fix typo 2020-02-08 21:43:47 +01:00
dc12c54ae6 fix libiio installation 2020-02-08 21:05:12 +01:00
bdc43455a5 add dependencies 2020-02-08 19:53:23 +01:00
42eeb00a0f add limesdr build 2020-02-08 19:47:16 +01:00
5951d2a874 add docker build for pluto 2020-02-08 19:01:50 +01:00
9a5aba7313 disable config interface unless explicitly enables in the config 2020-02-08 18:29:48 +01:00
d94914629f update changelog to reflect new image 2020-02-08 17:55:59 +01:00
216ede189c style the input 2020-02-01 22:25:16 +01:00
0191ed7ad6 abort frequency input on ESC key 2020-02-01 21:48:46 +01:00
8036758857 improve error handling on band and bookmark loading 2020-02-01 21:37:43 +01:00
41bc168a38 Merge pull request #51 from ofadam/patch-1
Fixed typo
2020-01-29 21:44:31 +01:00
14ea326f43 Fixed typo
2019 reference should have been 2020.
2020-01-29 14:35:52 -06:00
fcc907d488 add to changelog 2020-01-29 20:14:03 +01:00
2869fc3642 Merge branch 'develop' into daylight-scheduler 2020-01-29 20:12:35 +01:00
dc1fb3b607 more readme updates 2020-01-29 20:11:26 +01:00
1258180805 update the readme 2020-01-29 20:05:06 +01:00
b35958c6eb update changelog, closes #47 2020-01-29 19:58:36 +01:00
152737e8f6 split out the changelog into a separate file 2020-01-29 19:19:57 +01:00
840f624b21 Merge branch 'develop' into daylight-scheduler 2020-01-25 23:53:10 +01:00
cd1f8a7cb1 update dependencies in docker 2020-01-25 23:52:20 +01:00
49c333b88a include digital demods in hash 2020-01-25 23:47:32 +01:00
8fc981c8a0 use static elements 2020-01-25 22:47:47 +01:00
4b60b7e046 frequency editor on click 2020-01-25 22:35:44 +01:00
92254c8c4d update hash when demodulator params change 2020-01-25 21:15:05 +01:00
34312dd402 fix url hash parsing 2020-01-25 20:53:55 +01:00
b63a991008 redo the scheduling so it works close to the dateline, too 2020-01-24 23:29:25 +01:00
05af69f7b2 Merge branch 'develop' into daylight-scheduler 2020-01-23 11:15:18 +01:00
641907893c Merge pull request #48 from dh5ym/develop
Fix PlutoSDR support
2020-01-22 22:23:12 +01:00
7e2c2ad323 Fix PlutoSDR support 2020-01-22 21:55:22 +01:00
4e3d6527dd Merge pull request #2 from jketterl/develop
update
2020-01-22 21:51:19 +01:00
5b9344dee9 fix evening greyline 2020-01-20 17:29:32 +01:00
6157aba1ec Merge branch 'develop' into daylight-scheduler 2020-01-19 19:08:59 +01:00
f06f1265d8 just calculate today's schedule, makes things much easiear 2020-01-19 18:54:53 +01:00
1f68ecd9f4 add greyline calculation 2020-01-19 18:34:37 +01:00
877f0e4c28 allow schedule entries with datetime 2020-01-19 17:04:14 +01:00
af7437ab04 switch to monospaced font for better mousewheel tuning 2020-01-19 16:09:56 +01:00
f1e5e9a765 Merge branch 'develop' into daylight-scheduler 2020-01-19 10:52:43 +01:00
136b668f8f fix bookmark tuning 2020-01-19 10:50:40 +01:00
24032f4f5a Merge branch 'develop' into daylight-scheduler 2020-01-19 01:01:26 +01:00
18a63a6e7b mousewheel tuning 2020-01-19 00:00:51 +01:00
ae98e6bc56 refactor frequency display 2020-01-18 21:33:10 +01:00
b142180f94 optimize 2020-01-18 17:35:33 +01:00
f826002ea8 enable solar calculations 2020-01-18 00:43:37 +01:00
12be082523 refactor service / schedule code in preparation for alternate schedulers 2020-01-17 22:46:01 +01:00
470fc43646 avoid using preexec_fn in the other places, too 2020-01-17 21:18:02 +01:00
c12a4ecb80 Merge pull request #1 from jketterl/develop
merge changes to my fork
2020-01-17 15:06:30 +01:00
ea5b5dc8fb avoid preexec_fn (something's leaky there) 2020-01-17 12:17:15 +00:00
79ab37e6a0 add rtlsdr via soapy to the docker builds; clean up 2020-01-17 12:58:26 +01:00
0f1d219002 Merge pull request #44 from dh5ym/develop
Adding PlutoSDR support via SoapySDR, closes #27
2020-01-17 12:43:19 +01:00
7bf4c48733 Adding support for PlutoSDR (Adalm Pluto) via SoapySDR 2020-01-15 22:44:11 +01:00
d7aaf0d00e Adding support for PlutoSDR (Adalm Pluto) via SoapySDR 2020-01-15 22:42:08 +01:00
758b15e887 set parameters for psk63 mode 2020-01-13 20:10:14 +01:00
c3d89bd4bf fix device mixup 2020-01-10 23:31:51 +01:00
ad5683279e allow wider filter for pocsag; fix filter display; 2020-01-10 23:26:29 +01:00
14198aaa17 fix table alignment for long messages 2020-01-10 23:25:49 +01:00
976c15d29a parse address as a numeric field 2020-01-10 22:11:57 +01:00
ba9a9096bf use the nice error overlay, closes #28 2020-01-10 21:43:21 +01:00
cbd87abc3d add automatic backoff when server is at capacity 2020-01-10 21:38:46 +01:00
5a57648eec add direct sampling option, ref #37 2020-01-10 20:50:56 +01:00
b7538dcdd0 add alternate soapy driver for rtl-sdr sticks 2020-01-10 20:43:28 +01:00
aee1642ef6 add limesdr soapy driver module 2020-01-10 19:54:53 +01:00
ac92df2149 close pocsag message window on profile change 2020-01-09 23:48:48 +01:00
44c1edb2dd update legal information
remove andras from contacts since he discontinued openwebrx
2020-01-09 22:24:39 +01:00
2ea8812fda remove 3d view aka mathbox since it consumes more than 1MB data per
visit
2020-01-09 21:52:47 +01:00
922a5ed607 fix gain introduced by filtering 2020-01-09 21:44:36 +01:00
98e227c102 update digiham dependency 2020-01-09 19:33:17 +01:00
5a0398ceb5 require new digiham version 2020-01-09 19:26:41 +01:00
ebb7398446 update to latest digiham 2020-01-09 19:23:40 +01:00
e0501cff0f add owrx message passing and frontend 2020-01-09 15:12:51 +01:00
0e528c9267 refactor parsers; introduce new pocsag parser 2020-01-09 15:11:53 +01:00
0f8c86a26c 20 was too wide 2020-01-09 14:00:32 +01:00
f05ac31dc4 don't choke on invalid characters 2020-01-09 13:49:38 +01:00
2bb877a84b let's go for 20kHz for now 2020-01-09 13:49:15 +01:00
887cc3a88a sample pocsag data in 48kHz, too, allowing for wider filters 2020-01-09 13:47:47 +01:00
52199dd800 some preliminary styles 2020-01-08 22:40:44 +01:00
94b486cf2e wider filter for pocsag (as wide as possible) 2020-01-08 22:36:22 +01:00
db508fc4f7 inversion mode 2020-01-07 07:30:19 +01:00
12e5d2f6f3 add scaffolding for pocsag decoding 2020-01-06 22:08:17 +01:00
4859cb5db8 update to latest 2020-01-06 21:02:04 +01:00
83ad9d616f remove sdr.js 2020-01-06 19:52:31 +01:00
2a0ee83c12 implement lowpass 2020-01-06 19:48:54 +01:00
5379d8cc3d step one: implement upsampling 2020-01-06 16:29:23 +01:00
9187bb4371 use local codec for fft, too 2020-01-05 23:33:07 +01:00
c8c5ce8105 use local implementation of ima adpcm instead of sdr.js 2020-01-05 23:26:27 +01:00
15d351258f implement fallback for older setuptools 2020-01-05 21:08:17 +01:00
5fdc5489a1 losen dependency to python 3.5 2020-01-05 20:49:29 +01:00
a30841cdf6 add some debugging here 2020-01-05 18:41:46 +01:00
aad904f1a1 add owrs.source to the list of includes 2020-01-05 00:19:20 +01:00
8eb067b810 update csdr 2020-01-04 21:12:51 +01:00
108402a281 let's try this trick 2020-01-04 01:57:14 +01:00
de958ca091 seems like this fixes the starvation of workers 2020-01-02 19:35:58 +01:00
42828dbf65 add always-on feature 2019-12-31 19:14:05 +01:00
036442aa69 allow services to be disabled on individual sdrs 2019-12-31 18:44:47 +01:00
e60c332c24 arm 2019-12-31 16:24:45 +01:00
406d06fef2 add rockprog interface 2019-12-31 16:20:36 +01:00
9aa6f72152 fix the resampler 2019-12-31 15:27:33 +01:00
70347d1ef9 use automatic ports unless explicitly configured 2019-12-31 15:24:11 +01:00
42789ed561 clean up obsolete files 2019-12-31 09:43:04 +01:00
092a2e5ca0 handle soapy not being installed at all, references #42 2019-12-30 16:38:16 +01:00
9c82a80273 update csdr links 2019-12-30 16:23:22 +01:00
57dab75832 re-enable build cache 2019-12-30 00:12:03 +01:00
6297b8f277 use explicit revisions so i can use the docker build cache 2019-12-30 00:11:27 +01:00
6bcdd4007a fix dh_python3, hopefully 2019-12-29 21:46:26 +01:00
d0d0ba6ba7 initialize dict in code to avoid wrong references 2019-12-29 17:34:58 +01:00
550637ddef update raspi url 2019-12-29 10:06:10 +01:00
2bb2f65776 fix ppm parameter 2019-12-28 23:05:59 +01:00
420e21b078 add a pull to be up to date locally 2019-12-28 17:26:54 +01:00
71b8d72da3 push first, ask questions later 2019-12-28 17:17:10 +01:00
86ceb7a274 use lists for all command stuff 2019-12-28 16:44:45 +01:00
489d2390c8 fix name 2019-12-28 15:56:36 +01:00
1a3a5b43a0 reformat with black 2019-12-28 01:24:07 +01:00
e5724620a8 pass the tag the right way 2019-12-28 01:14:27 +01:00
2c4c88e30d move this over so a normal soapy sdr source 2019-12-28 00:38:36 +01:00
f92c49cee6 fix overlooked bias tee in airspy 2019-12-28 00:33:27 +01:00
8371d3b67a refactor sources to be more flexible 2019-12-28 00:26:45 +01:00
ca4d9771cc soapy driver detection; clean up docs 2019-12-27 11:37:12 +01:00
15a2e63866 combine arch and latest 2019-12-27 11:36:45 +01:00
eec35f07c3 add error message to log panel, too 2019-12-23 21:21:45 +01:00
11cfca5211 send a log message to the client when a device fails 2019-12-23 21:18:40 +01:00
46b5e9034f attempt to select new sdr on failure 2019-12-23 21:18:40 +01:00
7793609fa4 alpine is available for all archs now, but 3.11 produces segfaults :( 2019-12-23 19:11:47 +00:00
6f9ba6c290 improve sdr failure message display, closes #19 2019-12-21 23:46:05 +01:00
4d0d316fdd improve sdr failure detection 2019-12-21 23:29:56 +01:00
b5c5bcb9f1 fix readline problem 2019-12-21 21:17:19 +01:00
8fe9bf6292 attempt better wsjt decoder handling 2019-12-21 21:08:44 +01:00
9923f5b18e checkout the right branch 2019-12-21 21:00:43 +01:00
292fe80acf break apart the ever-growing owrx/source.py 2019-12-21 20:58:28 +01:00
5b08dae28d rx_sdr is not needed any more 2019-12-21 19:43:21 +01:00
33dd6937b4 change default config 2019-12-21 19:31:54 +01:00
a34cb3db8a reflect changes in the config, too 2019-12-21 19:30:46 +01:00
10de50d251 remove old sources, make the connector-based ones default 2019-12-21 19:24:14 +01:00
3bbcaa1329 use shallow cloning everywhere to speed up the build 2019-12-19 22:14:32 +01:00
e1d2ed8867 add fifisdr support (no frequency tuning) 2019-12-19 21:37:19 +01:00
8ee0d7c0e8 add sdrplay patch 2019-12-15 17:31:23 +00:00
721ac5e2a3 additional files for docker 2019-12-15 18:28:35 +01:00
88a410a9c0 the cache is evil, it has betrayed us 2019-12-15 18:28:10 +01:00
0e8116b743 handle errors in json files 2019-12-15 17:44:31 +01:00
ef1435cef7 rtltcp_compat is now a flag; expose through config 2019-12-15 16:33:07 +01:00
f7ff798238 add aarch64 build 2019-12-15 02:18:30 +00:00
f012c1180c update wsjt-x to 2.1.2 2019-12-14 21:04:23 +01:00
5a2e8d8f80 move config to /etc/openwebrx 2019-12-14 19:05:22 +01:00
364d3473a2 add airspyhf sample config 2019-12-10 23:02:22 +01:00
1a092a1e24 remove debug message 2019-12-08 22:13:57 +01:00
8248c60aa0 add direwolf and wsjtx packages 2019-12-08 21:56:50 +01:00
f4106ee427 strip path from glob 2019-12-08 21:46:08 +01:00
4e99a3ad07 explicitly glob over the htdocs 2019-12-08 21:37:14 +01:00
57a61f0c40 close connection when queue overflows 2019-12-08 21:11:36 +01:00
61988e3297 add sox dependency 2019-12-08 21:06:16 +01:00
5c8da76d9a move bands and bookmarks to the config, too 2019-12-08 21:00:01 +01:00
3b32dc37c8 git pull everytime 2019-12-08 20:45:30 +01:00
7a6d021e18 switch file loading to pkg_resources 2019-12-08 20:27:58 +01:00
21cb0e8feb docker-based debian package build 2019-12-08 19:00:34 +01:00
527eccd3c6 add systemd; add dependencies 2019-12-08 17:35:37 +01:00
57ec4e09ad move to package location 2019-12-08 17:16:28 +01:00
9164a3ed3a restructure project for packaging 2019-12-08 17:15:48 +01:00
37086bc6c7 debian build (first take) 2019-12-08 14:02:09 +01:00
1d1851dc76 add airspyhf support 2019-12-06 11:39:23 +01:00
ac841221b6 always pull before building 2019-12-06 11:38:15 +01:00
c8ddb121d0 simplify command execution 2019-12-05 21:07:56 +01:00
ba5613cf62 fix quoting 2019-12-05 20:57:03 +01:00
af4acd5623 parse device queries manually, since they are not x-www-urlencoded 2019-12-05 20:53:27 +01:00
19eb5c73e7 pre-filter soapy devices by driver 2019-12-05 19:51:55 +01:00
94ff6cc800 switch to my csdr master branch 2019-12-05 18:30:40 +01:00
adf4f5a738 explicit favicon link 2019-12-04 00:47:50 +01:00
1e6088ca1d relative map urls 2019-12-03 19:06:00 +01:00
9d01b2306c improve https detection 2019-12-03 18:57:32 +01:00
fc8d3d8f11 improve websocket url determination 2019-12-03 18:53:57 +01:00
15b860af36 add soapy connectivity for airspy 2019-12-03 14:32:10 +01:00
90d990bdfb add depencency for sox 2019-12-01 15:42:50 +01:00
2cfeb6b6d6 more safari fixes 2019-11-26 22:06:13 +01:00
42f9fb52ed safari compatibility 2019-11-26 21:35:22 +01:00
11c2c8afe3 limit multiprocessing queue to avoid memory leak on failing connections 2019-11-26 20:13:04 +01:00
fe39c2712d keep the output_rate on sdr change 2019-11-26 20:13:04 +01:00
b774e75f2c fix urls for when we aren't running on the root 2019-11-25 20:17:11 +01:00
147c108570 update with latest image link 2019-11-24 21:47:16 +01:00
110 changed files with 3213 additions and 14314 deletions

View File

@ -3,3 +3,5 @@
.idea
**/*.pyc
**/*.swp
black-env
debian

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
**/*.swp
tags
.idea
packages

118
CHANGELOG.md Normal file
View File

@ -0,0 +1,118 @@
**unreleased**
- Support for SoapyRemote
**2020-02-08**
- Compression, resampling and filtering in the frontend have been rewritten in javascript, sdr.js has been removed
- Decoding of Pocsag modulation is now possible
- Removed the 3D waterfall since it had no real application and required ~1MB of javascript code to be downloaded
- Improved the frontend handling of the "too many users" scenario
- PSK63 digimode is now available (same decoding pipeline as PSK31, but with adopted parameters)
- The frequency can now be manipulated with the mousewheel, which should allow the user to tune more precise. The tuning
step size is determined by the digit the mouse cursor is hovering over.
- Clicking on the frequency now opens an input for direct frequency selection
- URL hashes have been fixed and improved: They are now updated automatically, so a shared URL will include frequency
and demodulator, which allows for improved sharing and linking.
- New daylight scheduler for background decoding, allows profiles to be selected by local sunrise / sunset times
- New devices supported:
- LimeSDR (`"type": "lime_sdr"`)
- PlutoSDR (`"type": "pluto_sdr"`)
- RTL_SDR via Soapy (`"type": "rtl_sdr_soapy"`) on special request to allow use of the direct sampling mode
**2020-01-04**
- The [owrx_connector](https://github.com/jketterl/owrx_connector) is now the default way of communicating with sdr
devices. The old sdr types have been replaced, all `_connector` suffixes on the type must be removed!
- The sources have been refactored, making it a lot easier to add support for other devices
- SDR device failure handling has been improved, including user feedback
- New devices supported:
- FiFiSDR (`"type": "fifi_sdr"`)
**2019-12-15**
- wsjt-x updated to 2.1.2
- The rtl_tcp compatibility mode of the owrx_connector is now configurable using the `rtltcp_compat` flag
**2019-12-10**
- added support for airspyhf devices (Airspy HF+ / Discovery)
**2019-12-05**
- explicit device filter for soapy devices for multi-device setups
**2019-12-03**
- compatibility fixes for safari browsers (ios and mac)
**2019-11-24**
- There is now a new way to interface with SDR hardware, .
They talk directly to the hardware (no rtl_sdr / rx_sdr necessary) and offer I/Q data on a socket, just like nmux
did before. They additionally offer a control socket that allows openwebrx to control the SDR parameters directly,
without the need for repeated restarts. This allows for quicker profile changes, and also reduces the risk of your
SDR hardware from failing during the switchover. See `config_webrx.py` for further information and instructions.
- Offset tuning using the `lfo_offset` has been reworked in a way that `center_freq` has to be set to the frequency you
actually want to listen to. If you're using an `lfo_offset` already, you will probably need to change its sign.
- `initial_squelch_level` can now be set on each profile.
- As usual, plenty of fixes and improvements.
**2019-10-27**
- Part of the frontend code has been reworked
- Audio buffer minimums have been completely stripped. As a result, you should get better latency. Unfortunately,
this also means there will be some skipping when audio starts.
- Now also supports AudioWorklets (for those browser that have it). The Raspberry Pi image has been updated to include
https due to the SecureContext requirement.
- Mousewheel controls for the receiver sliders
- Error handling for failed SDR devices
**2019-09-29**
- One of the most-requested features is finally coming to OpenWebRX: Bookmarks (sometimes also referred to as labels).
There's two kinds of bookmarks available:
- Serverside bookmarks that are set up by the receiver administrator. Check the file `bookmarks.json` for examples!
- Clientside bookmarks which every user can store for themselves. They are stored in the browser's localStorage.
- Some more bugs in the websocket handling have been fixed.
**2019-09-25**
- Automatic reporting of spots to [pskreporter](https://pskreporter.info/) is now possible. Please have a look at the
configuration on how to set it up.
- Websocket communication has been overhauled in large parts. It should now be more reliable, and failing connections
should now have no impact on other users.
- Profile scheduling allows to set up band-hopping if you are running background services.
- APRS now has the ability to show symbols on the map, if a corresponding symbol set has been installed. Check the
config!
- Debug logging has been disabled in a handful of modules, expect vastly reduced output on the shell.
**2019-09-13**
- New set of APRS-related features
- Decode Packet transmissions using [direwolf](https://github.com/wb2osz/direwolf) (1k2 only for now)
- APRS packets are mostly decoded and shown both in a new panel and on the map
- APRS is also available as a background service
- direwolfs I-gate functionality can be enabled, which allows your receiver to work as a receive-only I-gate for the
APRS network in the background
- Demodulation for background services has been optimized to use less total bandwidth, saving CPU
- More metrics have been added; they can be used together with collectd and its curl_json plugin for now, with some
limitations.
**2019-07-21**
- Latest Features:
- More WSJT-X modes have been added, including the new FT4 mode
- I started adding a bandplan feature, the first thing visible is the "dial" indicator that brings you right to the
dial frequency for digital modes
- fixed some bugs in the websocket communication which broke the map
**2019-07-13**
- Latest Features:
- FT8 Integration (using wsjt-x demodulators)
- New Map Feature that shows both decoded grid squares from FT8 and Locations decoded from YSF digital voice
- New Feature report that will show what functionality is available
- There's a new Raspbian SD Card image available (see below)
**2019-06-30**
- I have done some major rework on the openwebrx core, and I am planning to continue adding more features in the near
future. Please check this place for updates.
- My work has not been accepted into the upstream repository, so you will need to chose between my fork and the official
version.
- I have enabled the issue tracker on this project, so feel free to file bugs or suggest enhancements there!
- This version sports the following new and amazing features:
- Support of multiple SDR devices simultaneously
- Support for multiple profiles per SDR that allow the user to listen to different frequencies
- Support for digital voice decoding
- Feature detection that will disable functionality when dependencies are not available (if you're missing the digital
buttons, this is probably why)
- Raspbian SD Card Images and Docker builds available (see below)
- I am currently working on the feature set for a stable release, but you are more than welcome to test development
versions!

View File

@ -1,15 +0,0 @@
First of all, thank you for taking the time to contribute to this project!
Before I can accept your contributions, I need a signed copy of the Individual Contributor License Agreement (ICLA) from you, which is available <a href="ICLA.txt">here</a>.
The ICLA is needed because it will allow me to dual license the OpenWebRX project under AGPL and a commercial license.
I will also apply dual licensing to csdr, but only those parts that are original work (e.g. without the parts enabled by `-DUSE_IMA_ADPCM`; code taken from other projects is clearly separable).
However, even if there is commercial interest in the projects, I promise to keep them as open as possible, keeping my original intention to provide an open-source web-based SDR receiver software to the amateur radio operators and SDR enthusiasts.
This contributor agreement is based on the one of Apache Software Foundation, with some modifications. (You can review differences <a href="https://gist.github.com/ha7ilm/9e981006d24659e336c7/revisions">here</a>).
When you contribute for the first time, I will send you the ICLA. Replying with only the information requested and the text "I Agree" is sufficient.
Thanks,
Andras, HA7ILM

View File

@ -1,5 +0,0 @@
This is a list of the great people who contributed code to the OpenWebRX repository. (Names are sorted alphabetically.)
Gnoxter <gnoxter@linuxlounge.net>
John Seamons, ZL/KF6VO <jks@jks.com>

128
ICLA.txt
View File

@ -1,128 +0,0 @@
Individual Contributor License Agreement ("Agreement")
In order to clarify the intellectual property license granted
with Contributions from any person or entity, Retzler András
(hereinafter referred to as "Project Owner") must have a
Contributor License Agreement ("CLA") on file that has
been signed by each Contributor, indicating agreement to the license
terms below. This license is for your protection as a Contributor as
well as the protection of the Project Owner; it does not change your
rights to use your own Contributions for any other purpose.
Please read this document carefully before signing and keep a copy
for your records.
Full name: ______________________________________________________
(optional) Public name: _________________________________________
Mailing Address: ________________________________________________
________________________________________________
Country: ______________________________________________________
(optional) Telephone: ___________________________________________
E-Mail: ______________________________________________________
You accept and agree to the following terms and conditions for Your
present and future Contributions submitted to the Project Owner.
Except for the license granted herein to the Project Owner and recipients
of software distributed by the Project Owner, You reserve all right, title,
and interest in and to Your Contributions.
1. Definitions.
"You" (or "Your") shall mean the copyright owner or legal entity
authorized by the copyright owner that is making this Agreement
with the Project Owner. For legal entities, the entity making a
Contribution and all other entities that control, are controlled
by, or are under common control with that entity are considered to
be a single Contributor. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"Contribution" shall mean any original work of authorship,
including any modifications or additions to an existing work, that
is intentionally submitted by You to the Project Owner for inclusion
in, or documentation of, any of the products owned or managed by
the Project Owner (the "Work"). For the purposes of this definition,
"submitted" means any form of electronic, verbal, or written
communication sent to the Project Owner or its representatives,
including but not limited to communication on electronic mailing
lists, source code control systems, and issue tracking systems that
are managed by, or on behalf of, the Project Owner for the purpose of
discussing and improving the Work, but excluding communication that
is conspicuously marked or otherwise designated in writing by You
as "Not a Contribution."
2. Grant of Copyright License. Subject to the terms and conditions of
this Agreement, You hereby grant to the Project Owner and to
recipients of software distributed by the Project Owner a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare derivative works of,
publicly display, publicly perform, sublicense, and distribute Your
Contributions and such derivative works.
3. Grant of Patent License. Subject to the terms and conditions of
this Agreement, You hereby grant to the Project Owner and to
recipients of software distributed by the Project Owner a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have
made, use, offer to sell, sell, import, and otherwise transfer the
Work, where such license applies only to those patent claims
licensable by You that are necessarily infringed by Your
Contribution(s) alone or by combination of Your Contribution(s)
with the Work to which such Contribution(s) was submitted. If any
entity institutes patent litigation against You or any other entity
(including a cross-claim or counterclaim in a lawsuit) alleging
that your Contribution, or the Work to which you have contributed,
constitutes direct or contributory patent infringement, then any
patent licenses granted to that entity under this Agreement for
that Contribution or Work shall terminate as of the date such
litigation is filed.
4. You represent that you are legally entitled to grant the above
license. If your employer(s) has rights to intellectual property
that you create that includes your Contributions, you represent
that you have received permission to make Contributions on behalf
of that employer, that your employer has waived such rights for
your Contributions to the Project Owner, or that your employer has
executed a separate Corporate CLA with the Project Owner.
5. You represent that each of Your Contributions is Your original
creation (see section 7 for submissions on behalf of others). You
represent that Your Contribution submissions include complete
details of any third-party license or other restriction (including,
but not limited to, related patents and trademarks) of which you
are personally aware and which are associated with any part of Your
Contributions.
6. You are not expected to provide support for Your Contributions,
except to the extent You desire to provide support. You may provide
support for free, for a fee, or not at all. Unless required by
applicable law or agreed to in writing, You provide Your
Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied, including, without
limitation, any warranties or conditions of TITLE, NON-
INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
7. Should You wish to submit work that is not Your original creation,
You may submit it to the Project Owner separately from any
Contribution, identifying the complete details of its source and of
any license or other restriction (including, but not limited to,
related patents, trademarks, and license agreements) of which you
are personally aware, and conspicuously marking the work as
"Submitted on behalf of a third-party: [named here]".
8. You agree to notify the Project Owner of any facts or circumstances of
which you become aware that would make these representations
inaccurate in any respect.
Please sign: __________________________________ Date: ________________
Text derived from the Apache Individual Contributor License Agreement
("Agreement") V2.0, available at http://apache.org/licenses/icla.txt

125
README.md
View File

@ -1,114 +1,44 @@
OpenWebRX
=========
[:floppy_disk: Setup guide for Ubuntu](http://blog.sdr.hu/2015/06/30/quick-setup-openwebrx.html) | [:blue_book: Knowledge base on the Wiki](https://github.com/simonyiszk/openwebrx/wiki/) | [:earth_americas: Receivers on SDR.hu](http://sdr.hu/)
OpenWebRX is a multi-user SDR receiver software with a web interface.
![OpenWebRX](http://blog.sdr.hu/images/openwebrx/screenshot.png)
It has the following features:
- [csdr](https://github.com/simonyiszk/csdr) based demodulators (AM/FM/SSB/CW/BPSK31),
- filter passband can be set from GUI,
- [csdr](https://github.com/jketterl/csdr) based demodulators (AM/FM/SSB/CW/BPSK31/BPSK63)
- filter passband can be set from GUI
- it extensively uses HTML5 features like WebSocket, Web Audio API, and Canvas
- it works in Google Chrome, Chromium and Mozilla Firefox
- currently supports RTL-SDR, HackRF, SDRplay, AirSpy
- currently supports RTL-SDR, HackRF, SDRplay, AirSpy, LimeSDR, PlutoSDR
- Multiple SDR devices can be used simultaneously
- [digiham](https://github.com/jketterl/digiham) based demodularors (DMR, YSF)
- [digiham](https://github.com/jketterl/digiham) based demodularors (DMR, YSF, Pocsag)
- [dsd](https://github.com/f4exb/dsdcc) based demodulators (D-Star, NXDN)
- [wsjt-x](https://physics.princeton.edu/pulsar/k1jt/wsjtx.html) based demodulators (FT8, FT4, WSPR, JT65, JT9)
**News (2019-11-24 by DD5JFK)**
- There is now a new way to interface with SDR hardware, [owrx_connectors](https://github.com/jketterl/owrx_connector).
They talk directly to the hardware (no rtl_sdr / rx_sdr necessary) and offer I/Q data on a socket, just like nmux
did before. They additionally offer a control socket that allows openwebrx to control the SDR parameters directly,
without the need for repeated restarts. This allows for quicker profile changes, and also reduces the risk of your
SDR hardware from failing during the switchover. See `config_webrx.py` for further information and instructions.
- Offset tuning using the `lfo_offset` has been reworked in a way that `center_freq` has to be set to the frequency you
actually want to listen to. If you're using an `lfo_offset` already, you will probably need to change its sign.
- `initial_squelch_level` can now be set on each profile.
- As usual, plenty of fixes and improvements.
**News (2019-10-27 by DD5JFK)**
- Part of the frontend code has been reworked
- Audio buffer minimums have been completely stripped. As a result, you should get better latency. Unfortunately, this also means there will be some skipping when audio starts.
- Now also supports AudioWorklets (for those browser that have it). The Raspberry Pi image has been updated to include https due to the SecureContext requirement.
- Mousewheel controls for the receiver sliders
- Error handling for failed SDR devices
**News (2019-09-29 by DD5FJK)**
- One of the most-requested features is finally coming to OpenWebRX: Bookmarks (sometimes also referred to as labels). There's two kinds of bookmarks available:
- Serverside bookmarks that are set up by the receiver administrator. Check the file `bookmarks.json` for examples!
- Clientside bookmarks which every user can store for themselves. They are stored in the browser's localStorage.
- Some more bugs in the websocket handling have been fixed.
**News (2019-09-25 by DD5JFK)**
- Automatic reporting of spots to [pskreporter](https://pskreporter.info/) is now possible. Please have a look at the configuration on how to set it up.
- Websocket communication has been overhauled in large parts. It should now be more reliable, and failing connections should now have no impact on other users.
- Profile scheduling allows to set up band-hopping if you are running background services.
- APRS now has the ability to show symbols on the map, if a corresponding symbol set has been installed. Check the config!
- Debug logging has been disabled in a handful of modules, expect vastly reduced output on the shell.
**News (2019-09-13 by DD5JFK)**
- New set of APRS-related features
- Decode Packet transmissions using [direwolf](https://github.com/wb2osz/direwolf) (1k2 only for now)
- APRS packets are mostly decoded and shown both in a new panel and on the map
- APRS is also available as a background service
- direwolfs I-gate functionality can be enabled, which allows your receiver to work as a receive-only I-gate for the APRS network in the background
- Demodulation for background services has been optimized to use less total bandwidth, saving CPU
- More metrics have been added; they can be used together with collectd and its curl_json plugin for now, with some limitations.
**News (2019-07-21 by DD5JFK)**
- Latest Features:
- More WSJT-X modes have been added, including the new FT4 mode
- I started adding a bandplan feature, the first thing visible is the "dial" indicator that brings you right to the dial frequency for digital modes
- fixed some bugs in the websocket communication which broke the map
**News (2019-07-13 by DD5JFK)**
- Latest Features:
- FT8 Integration (using wsjt-x demodulators)
- New Map Feature that shows both decoded grid squares from FT8 and Locations decoded from YSF digital voice
- New Feature report that will show what functionality is available
- There's a new Raspbian SD Card image available (see below)
**News (2019-06-30 by DD5JFK)**
- I have done some major rework on the openwebrx core, and I am planning to continue adding more features in the near future. Please check this place for updates.
- My work has not been accepted into the upstream repository, so you will need to chose between my fork and the official version.
- I have enabled the issue tracker on this project, so feel free to file bugs or suggest enhancements there!
- This version sports the following new and amazing features:
- Support of multiple SDR devices simultaneously
- Support for multiple profiles per SDR that allow the user to listen to different frequencies
- Support for digital voice decoding
- Feature detection that will disable functionality when dependencies are not available (if you're missing the digital buttons, this is probably why)
- Raspbian SD Card Images and Docker builds available (see below)
- I am currently working on the feature set for a stable release, but you are more than welcome to test development versions!
> When upgrading OpenWebRX, please make sure that you also upgrade *csdr* and *digiham*!
## OpenWebRX servers on SDR.hu
[SDR.hu](http://sdr.hu) is a site which lists the active, public OpenWebRX servers. Your receiver [can also be part of it](http://sdr.hu/openwebrx), if you want.
![sdr.hu](http://blog.sdr.hu/images/openwebrx/screenshot-sdrhu.png)
## Setup
### Raspberry Pi SD Card Images
Probably the quickest way to get started is to download the [latest Raspberry Pi SD Card Image](https://s3.eu-central-1.amazonaws.com/de.dd5jfk.openwebrx/2019-10-27-OpenWebRX-full.zip). It contains all the depencencies out of the box, and should work on all Raspberries up to the 3B+.
Probably the quickest way to get started is to download the latest Raspberry Pi SD Card Image. It contains all the
depencencies out of the box, and should work on all Raspberry Pis. It is based off the Raspbian Lite distribution,
so [their installation instructions](https://www.raspberrypi.org/documentation/installation/installing-images/) apply.
This is based off the Raspbian Lite distribution, so [their installation instructions](https://www.raspberrypi.org/documentation/installation/installing-images/) apply.
You can find the latest images [here](https://s3.eu-central-1.amazonaws.com/de.dd5jfk.openwebrx/index.html). You can
also checkout the `nightly` folder, which has the most recent builds, albeit untested.
Please note: I have not updated this to include the Raspberry Pi 4 yet. (It seems to be impossible to build Rasbpian Buster images on x86 hardware right now. Stay tuned!)
Once you have booted a Raspberry with the SD Card, it will appear in your network with the hostname "openwebrx", which
should make it available as https://openwebrx/ on most networks. This may vary depending on your specific setup.
Once you have booted a Raspberry with the SD Card, it will appear in your network with the hostname "openwebrx", which should make it available as https://openwebrx:8073/ on most networks. This may vary depending on your specific setup.
For Digital voice, the minimum requirement right now seems to be a Rasbperry Pi 3B+. I would like to work on optimizing this for lower specs, but at this point I am not sure how much can be done.
For Digital voice, the minimum requirement right now seems to be a Rasbperry Pi 3B+. I would like to work on optimizing
this for lower specs, but at this point I am not sure how much can be done.
### Docker Images
For those familiar with docker, I am providing [recent builds and Releases for both x86 and arm processors on the Docker hub](https://hub.docker.com/r/jketterl/openwebrx). You can find a short introduction there.
For those familiar with docker, I am providing
[recent builds and Releases for both x86 and arm processors on the Docker hub](https://hub.docker.com/r/jketterl/openwebrx).
You can find a short introduction there.
### Manual Installation
@ -116,11 +46,8 @@ OpenWebRX currently requires Linux and python >= 3.6 to run.
First you will need to install the dependencies:
- [csdr](https://github.com/simonyiszk/csdr)
- [csdr](https://github.com/jketterl/csdr)
- [rtl-sdr](http://sdr.osmocom.org/trac/wiki/rtl-sdr)
Optional dependency for improved hardware access (to become mandatory at some point):
- [owrx_connector](https://github.com/jketterl/owrx_connector)
Optional dependencies if you want to be able to listen do digital voice:
@ -132,16 +59,14 @@ Optional dependency if you want to decode WSJT-X modes:
- [wsjt-x](https://physics.princeton.edu/pulsar/k1jt/wsjtx.html)
[Detailed installation instructions in the Wiki](https://github.com/jketterl/openwebrx/wiki/Manual-Package-installation-(including-digital-voice))
After cloning this repository and connecting an RTL-SDR dongle to your computer, you can run the server:
./openwebrx.py
You can now open the GUI at <a href="http://localhost:8073">http://localhost:8073</a>.
Please note that the server is also listening on the following ports (on localhost only):
- ports 4950 to 4960 for the multi-user I/Q servers.
Now the next step is to customize the parameters of your server in `config_webrx.py`.
Actually, if you do something cool with OpenWebRX, please drop me a mail:
@ -155,14 +80,10 @@ The filter envelope can be dragged at its ends and moved around to set the passb
However, if you hold down the shift key, you can drag the center line (BFO) or the whole passband (PBS).
## Setup tips
If you have any problems installing OpenWebRX, you should check out the <a href="https://github.com/simonyiszk/openwebrx/wiki">Wiki</a> about it, which has a page on the <a href="https://github.com/simonyiszk/openwebrx/wiki/Common-problems-and-their-solutions">common problems and their solutions</a>.
Sometimes the actual error message is not at the end of the terminal output, you may have to look at the whole output to find it.
## Licensing
OpenWebRX is available under Affero GPL v3 license (<a href="https://tldrlegal.com/license/gnu-affero-general-public-license-v3-(agpl-3.0)">summary</a>).
OpenWebRX is available under Affero GPL v3 license
([summary](https://tldrlegal.com/license/gnu-affero-general-public-license-v3-(agpl-3.0)).
OpenWebRX is also available under a commercial license on request. Please contact me at the address *&lt;randras@sdr.hu&gt;* for licensing options.
OpenWebRX is also available under a commercial license on request. Please contact me at the address
*&lt;randras@sdr.hu&gt;* for licensing options.

View File

@ -160,7 +160,10 @@
{
"name": "70cm",
"lower_bound": 430000000,
"upper_bound": 440000000
"upper_bound": 440000000,
"frequencies": {
"pocsag": 439987500
}
},
{
"name": "23cm",

View File

@ -129,11 +129,6 @@
"frequency": 439937500,
"modulation": "dmr"
},
{
"name": "Pocsag",
"frequency": 439987500,
"modulation": "nfm"
},
{
"name": "DB0ULR",
"frequency": 145575000,

View File

@ -1,22 +1,15 @@
#!/bin/bash
set -euxo pipefail
. docker/env
ARCH=$(uname -m)
case $ARCH in
x86_64)
BASE_IMAGE=alpine
;;
armv*)
BASE_IMAGE=arm32v6/alpine
esac
TAGS=$ARCH
docker build --build-arg BASE_IMAGE=$BASE_IMAGE -t openwebrx-base:$ARCH -f docker/Dockerfiles/Dockerfile-base .
docker build --build-arg ARCH=$ARCH -t jketterl/openwebrx-rtlsdr:$ARCH -f docker/Dockerfiles/Dockerfile-rtlsdr .
docker build --build-arg ARCH=$ARCH -t openwebrx-soapysdr-base:$ARCH -f docker/Dockerfiles/Dockerfile-soapysdr .
docker build --build-arg ARCH=$ARCH -t jketterl/openwebrx-sdrplay:$ARCH -f docker/Dockerfiles/Dockerfile-sdrplay .
docker build --build-arg ARCH=$ARCH -t jketterl/openwebrx-hackrf:$ARCH -f docker/Dockerfiles/Dockerfile-hackrf .
docker build --build-arg ARCH=$ARCH -t jketterl/openwebrx-airspy:$ARCH -f docker/Dockerfiles/Dockerfile-airspy .
docker build --build-arg ARCH=$ARCH -t jketterl/openwebrx-full:$ARCH -t jketterl/openwebrx:$ARCH -f docker/Dockerfiles/Dockerfile-full .
docker build --pull -t openwebrx-base:$ARCHTAG -f docker/Dockerfiles/Dockerfile-base .
docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-rtlsdr:$ARCHTAG -f docker/Dockerfiles/Dockerfile-rtlsdr .
docker build --build-arg ARCHTAG=$ARCHTAG -t openwebrx-soapysdr-base:$ARCHTAG -f docker/Dockerfiles/Dockerfile-soapysdr .
docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-sdrplay:$ARCHTAG -f docker/Dockerfiles/Dockerfile-sdrplay .
docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-hackrf:$ARCHTAG -f docker/Dockerfiles/Dockerfile-hackrf .
docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-airspy:$ARCHTAG -f docker/Dockerfiles/Dockerfile-airspy .
docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-rtlsdr-soapy:$ARCHTAG -f docker/Dockerfiles/Dockerfile-rtlsdr-soapy .
docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-plutosdr:$ARCHTAG -f docker/Dockerfiles/Dockerfile-plutosdr .
docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-limesdr:$ARCHTAG -f docker/Dockerfiles/Dockerfile-limesdr .
docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-soapyremote:$ARCHTAG -f docker/Dockerfiles/Dockerfile-soapyremote .
docker build --build-arg ARCHTAG=$ARCHTAG -t jketterl/openwebrx-full:$ARCHTAG -t jketterl/openwebrx:$ARCHTAG -f docker/Dockerfiles/Dockerfile-full .

View File

@ -6,7 +6,7 @@ config_webrx: configuration options for OpenWebRX
This file is part of OpenWebRX,
an open-source SDR receiver software with a web UI.
Copyright (c) 2013-2015 by Andras Retzler <randras@sdr.hu>
Copyright (c) 2019 by Jakob Ketterl <dd5jfk@darc.de>
Copyright (c) 2019-2020 by Jakob Ketterl <dd5jfk@darc.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
@ -98,25 +98,22 @@ Note: if you experience audio underruns while CPU usage is 100%, you can:
# Check here: https://github.com/simonyiszk/openwebrx/wiki#guides-for-receiver-hardware-support #
#################################################################################################
# Currently supported types of sdr receivers: "rtl_sdr", "sdrplay", "hackrf", "airspy"
# Currently supported types of sdr receivers:
# "rtl_sdr", "sdrplay", "hackrf", "airspy", "airspyhf", "fifi_sdr"
#
# NEW: There is now custom connector software available, that is tailored for the use with
# openwebrx. The connectors allow the SDR to be reprogrammed while running, which allows for
# quicker profile changes. It also reduces the risk of a USB disconnect that can happen when the
# SDR software is restarted, since the connector will run continuously.
# Check out the connector repository here: https://github.com/jketterl/owrx_connector
# In order to use rtl_sdr, you will need to install librtlsdr-dev and the connector.
# In order to use sdrplay, airspy or airspyhf, you will need to install soapysdr, the corresponding driver, and the
# connector.
#
# The following connectors are available (simply use them as the "type" in the config below):
# "rtl_sdr_connector", "sdrplay_connector", "airspy_connector"
# https://github.com/jketterl/owrx_connector
#
# NOTE: These connectors will become the default as soon as they have become mature; the existing
# receiver types will then automatically be migrated to connectors. At that point, the old "nmux"
# method will start to be phased out.
# NOTE: The connector sources have replaced the old piped nmux style of reading input. If you still have any sdrs
# configured that have type endin in "_connector", simply remove that suffix.
sdrs = {
"rtlsdr": {
"name": "RTL-SDR USB Stick",
"type": "rtl_sdr_connector",
"type": "rtl_sdr",
"ppm": 0,
# you can change this if you use an upconverter. formula is:
# center_freq + lfo_offset = actual frequency on the sdr
@ -140,9 +137,56 @@ sdrs = {
},
},
},
"airspy": {
"name": "Airspy HF+",
"type": "airspyhf",
"ppm": 0,
"profiles": {
"20m": {
"name": "20m",
"center_freq": 14150000,
"rf_gain": 10,
"samp_rate": 768000,
"start_freq": 14070000,
"start_mod": "usb",
},
"30m": {
"name": "30m",
"center_freq": 10125000,
"rf_gain": 10,
"samp_rate": 192000,
"start_freq": 10142000,
"start_mod": "usb",
},
"40m": {
"name": "40m",
"center_freq": 7100000,
"rf_gain": 10,
"samp_rate": 256000,
"start_freq": 7070000,
"start_mod": "usb",
},
"80m": {
"name": "80m",
"center_freq": 3650000,
"rf_gain": 10,
"samp_rate": 768000,
"start_freq": 3570000,
"start_mod": "usb",
},
"49m": {
"name": "49m Broadcast",
"center_freq": 6000000,
"rf_gain": 10,
"samp_rate": 768000,
"start_freq": 6070000,
"start_mod": "am",
},
},
},
"sdrplay": {
"name": "SDRPlay RSP2",
"type": "sdrplay_connector",
"type": "sdrplay",
"ppm": 0,
"profiles": {
"20m": {
@ -193,13 +237,6 @@ sdrs = {
},
}
# ==== Misc settings ====
iq_port_range = [
4950,
4960,
] # TCP port for range ncat to listen on. It will send I/Q data over its connections, for internal use in OpenWebRX. It is only accessible from the localhost by default.
# ==== Color themes ====
# A guide is available to help you set these values: https://github.com/simonyiszk/openwebrx/wiki/Calibrating-waterfall-display-levels
@ -224,20 +261,6 @@ waterfall_auto_level_margin = (5, 40)
# \_waterfall_auto_level_margin[0]_/ |__ current_min_power_level | \_waterfall_auto_level_margin[1]_/
# current_max_power_level __|
# 3D view settings
mathbox_waterfall_frequency_resolution = 128 # bins
mathbox_waterfall_history_length = 10 # seconds
mathbox_waterfall_colors = [
0x000000FF,
0x2E6893FF,
0x69A5D0FF,
0x214B69FF,
0x9DC4E0FF,
0xFFF775FF,
0xFF8A8AFF,
0xB20000FF,
]
# === Experimental settings ===
# Warning! The settings below are very experimental.
csdr_dynamic_bufsize = False # This allows you to change the buffering mode of csdr.

View File

@ -4,7 +4,7 @@ OpenWebRX csdr plugin: do the signal processing with csdr
This file is part of OpenWebRX,
an open-source SDR receiver software with a web UI.
Copyright (c) 2013-2015 by Andras Retzler <randras@sdr.hu>
Copyright (c) 2019 by Jakob Ketterl <dd5jfk@darc.de>
Copyright (c) 2019-2020 by Jakob Ketterl <dd5jfk@darc.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
@ -225,7 +225,7 @@ class dsp(object):
if self.fft_compression == "adpcm":
chain += ["csdr compress_fft_adpcm_f_u8 {secondary_fft_size}"]
return chain
elif which == "bpsk31":
elif which == "bpsk31" or which == "bpsk63":
return chain + [
"csdr shift_addition_cc --fifo {secondary_shift_pipe}",
"csdr bandpass_fir_fft_cc -{secondary_bpf_cutoff} {secondary_bpf_cutoff} {secondary_bpf_cutoff}",
@ -243,7 +243,12 @@ class dsp(object):
chain += ["csdr fmdemod_quadri_cf"]
if self.last_decimation != 1.0:
chain += ["csdr fractional_decimator_ff {last_decimation}"]
return chain + ["csdr convert_f_s16", "direwolf -c {direwolf_config} -r {audio_rate} -t 0 -q d -q h - 1>&2"]
return chain + ["csdr convert_f_s16", "direwolf -c {direwolf_config} -r {audio_rate} -t 0 -q d -q h 1>&2"]
elif which == "pocsag":
chain += ["csdr fmdemod_quadri_cf"]
if self.last_decimation != 1.0:
chain += ["csdr fractional_decimator_ff {last_decimation}"]
return chain + ["fsk_demodulator -i", "pocsag_decoder"]
def set_secondary_demodulator(self, what):
if self.get_secondary_demodulator() == what:
@ -263,21 +268,29 @@ class dsp(object):
def secondary_bpf_cutoff(self):
if self.secondary_demodulator == "bpsk31":
return 31.25 / self.if_samp_rate()
elif self.secondary_demodulator == "bpsk63":
return 62.5 / self.if_samp_rate()
return 0
def secondary_bpf_transition_bw(self):
if self.secondary_demodulator == "bpsk31":
return 31.25 / self.if_samp_rate()
elif self.secondary_demodulator == "bpsk63":
return 62.5 / self.if_samp_rate()
return 0
def secondary_samples_per_bits(self):
if self.secondary_demodulator == "bpsk31":
return int(round(self.if_samp_rate() / 31.25)) & ~3
elif self.secondary_demodulator == "bpsk63":
return int(round(self.if_samp_rate() / 62.5)) & ~3
return 0
def secondary_bw(self):
if self.secondary_demodulator == "bpsk31":
return 31.25
elif self.secondary_demodulator == "bpsk63":
return 62.5
def start_secondary_demodulator(self):
if not self.secondary_demodulator:
@ -316,7 +329,7 @@ class dsp(object):
logger.debug("secondary command (fft) = %s", secondary_command_fft)
self.secondary_process_fft = subprocess.Popen(
secondary_command_fft, stdout=subprocess.PIPE, shell=True, preexec_fn=os.setpgrp, env=my_env
secondary_command_fft, stdout=subprocess.PIPE, shell=True, start_new_session=True, env=my_env
)
self.output.send_output(
"secondary_fft",
@ -328,7 +341,7 @@ class dsp(object):
# it would block if not read. by piping it to devnull, we avoid a potential pitfall here.
secondary_output = subprocess.DEVNULL if self.isPacket() else subprocess.PIPE
self.secondary_process_demod = subprocess.Popen(
secondary_command_demod, stdout=secondary_output, shell=True, preexec_fn=os.setpgrp, env=my_env
secondary_command_demod, stdout=secondary_output, shell=True, start_new_session=True, env=my_env
)
self.secondary_processes_running = True
@ -350,6 +363,8 @@ class dsp(object):
# we best get the ax25 packets from the kiss socket
kiss = KissClient(self.direwolf_port)
self.output.send_output("packet_demod", kiss.read)
elif self.isPocsag():
self.output.send_output("pocsag_demod", self.secondary_process_demod.stdout.readline)
else:
self.output.send_output("secondary_demod", partial(self.secondary_process_demod.stdout.read, 1))
@ -444,7 +459,7 @@ class dsp(object):
return self.output_rate
def get_audio_rate(self):
if self.isDigitalVoice() or self.isPacket():
if self.isDigitalVoice() or self.isPacket() or self.isPocsag():
return 48000
elif self.isWsjtMode():
return 12000
@ -465,6 +480,11 @@ class dsp(object):
demodulator = self.get_secondary_demodulator()
return demodulator == "packet"
def isPocsag(self, demodulator=None):
if demodulator is None:
demodulator = self.get_secondary_demodulator()
return demodulator == "pocsag"
def set_output_rate(self, output_rate):
if self.output_rate == output_rate:
return
@ -528,7 +548,7 @@ class dsp(object):
def set_squelch_level(self, squelch_level):
self.squelch_level = squelch_level
# no squelch required on digital voice modes
actual_squelch = -150 if self.isDigitalVoice() or self.isPacket() else self.squelch_level
actual_squelch = -150 if self.isDigitalVoice() or self.isPacket() or self.isPocsag() else self.squelch_level
if self.running:
self.modification_lock.acquire()
self.squelch_pipe_file.write("%g\n" % (self.convertToLinear(actual_squelch)))
@ -649,7 +669,7 @@ class dsp(object):
my_env["CSDR_PRINT_BUFSIZES"] = "1"
out = subprocess.PIPE if self.output.supports_type("audio") else subprocess.DEVNULL
self.process = subprocess.Popen(command, stdout=out, shell=True, preexec_fn=os.setpgrp, env=my_env)
self.process = subprocess.Popen(command, stdout=out, shell=True, start_new_session=True, env=my_env)
def watch_thread():
rc = self.process.wait()

97
debian/changelog vendored Normal file
View File

@ -0,0 +1,97 @@
openwebrx (0.18.0) buster; urgency=low
* Compression, resampling and filtering in the frontend have been rewritten
in javascript, sdr.js has been removed
* Decoding of Pocsag modulation is now possible
* Removed the 3D waterfall since it had no real application and required ~1MB
of javascript code to be downloaded
* Improved the frontend handling of the "too many users" scenario
* PSK63 digimode is now available (same decoding pipeline as PSK31, but with
adopted parameters)
* The frequency can now be manipulated with the mousewheel, which should
allow the user to tune more precise. The tuning step size is determined by
the digit the mouse cursor is hovering over.
* Clicking on the frequency now opens an input for direct frequency selection
* URL hashes have been fixed and improved: They are now updated
automatically, so a shared URL will include frequency and demodulator,
which allows for improved sharing and linking.
* New daylight scheduler for background decoding, allows profiles to be
selected by local sunrise / sunset times
* The owrx_connector is now the default way of communicating with sdr
devices. The old sdr types have been replaced, all `_connector` suffixes on
the type must be removed!
* The sources have been refactored, making it a lot easier to add support for
other devices
* SDR device failure handling has been improved, including user feedback
* New devices supported:
* wsjt-x updated to 2.1.2
* The rtl_tcp compatibility mode of the owrx_connector is now configurable
using the `rtltcp_compat` flag
* explicit device filter for soapy devices for multi-device setups
* compatibility fixes for safari browsers (ios and mac)
* Offset tuning using the `lfo_offset` has been reworked in a way that
`center_freq` has to be set to the frequency you actually want to listen
to. If you're using an `lfo_offset` already, you will probably need to
change its sign.
* `initial_squelch_level` can now be set on each profile.
* Part of the frontend code has been reworked
- Audio buffer minimums have been completely stripped. As a result, you
should get better latency. Unfortunately, this also means there will be
some skipping when audio starts.
- Now also supports AudioWorklets (for those browser that have it).
- Mousewheel controls for the receiver sliders
* Error handling for failed SDR devices
* One of the most-requested features is finally coming to OpenWebRX:
Bookmarks (sometimes also referred to as labels).
There's two kinds of bookmarks available:
- Serverside bookmarks that are set up by the receiver administrator.
Check the file `bookmarks.json` for examples!
- Clientside bookmarks which every user can store for themselves. They are
stored in the browser's localStorage.
* Automatic reporting of spots to [pskreporter](https://pskreporter.info/) is
now possible. Please have a look at the configuration on how to set it up.
* Websocket communication has been overhauled in large parts. It should now
be more reliable, and failing connections should now have no impact on
other users.
* Profile scheduling allows to set up band-hopping if you are running
background services.
* APRS now has the ability to show symbols on the map, if a corresponding
symbol set has been installed. Check the config!
* Debug logging has been disabled in a handful of modules, expect vastly
reduced output on the shell.
* New set of APRS-related features
- Decode Packet transmissions using direwolf (1k2 only for now)
- APRS packets are mostly decoded and shown both in a new panel and on the
map
- APRS is also available as a background service
- direwolfs I-gate functionality can be enabled, which allows your receiver
to work as a receive-only I-gate for the APRS network in the background
* Demodulation for background services has been optimized to use less total
bandwidth, saving CPU
* More metrics have been added; they can be used together with collectd and
its curl_json plugin for now, with some limitations.
* New bandplan feature, the first thing visible is the "dial" indicator that
brings you right to the dial frequency for digital modes
* fixed some bugs in the websocket communication which broke the map
* WSJT-X integration (FT8, FT4, WSPR, JT65, JT9 using wsjt-x demodulators)
* New Map Feature that shows both decoded grid squares from FT8 and Locations
decoded from YSF digital voice
* New Feature report that will show what functionality is available
* major rework on the openwebrx core
* Support of multiple SDR devices simultaneously
* Support for multiple profiles per SDR that allow the user to listen to
different frequencies
* Support for digital voice decoding
* Feature detection that will disable functionality when dependencies are not
available (if you're missing the digital
buttons, this is probably why)
* Support added for the following SDR sources:
- LimeSDR (`"type": "lime_sdr"`)
- PlutoSDR (`"type": "pluto_sdr"`)
- RTL_SDR via Soapy (`"type": "rtl_sdr_soapy"`) on special request to allow
use of the direct sampling mode
- SoapyRemote (`"type": "soapy_remote"`)
- FiFiSDR (`"type": "fifi_sdr"`)
- airspyhf devices (Airspy HF+ / Discovery) (`"type": "airspyhf"`)
-- Jakob Ketterl <jakob.ketterl@gmx.de> Tue, 18 Feb 2020 20:09:00 +0000

1
debian/compat vendored Normal file
View File

@ -0,0 +1 @@
10

13
debian/control vendored Normal file
View File

@ -0,0 +1,13 @@
Source: openwebrx
Maintainer: Jakob Ketterl <jakob.ketterl@gmx.de>
Section: hamradio
Priority: optional
Standards-Version: 4.2.0
Build-Depends: debhelper (>= 10), dh-python, python3 (>= 3.5)
Package: openwebrx
Architecture: all
Depends: adduser, python3 (>= 3.5), python3-pkg-resources, csdr (>= 0.14), netcat, owrx-connector (>= 0.1), ${python3:Depends}, ${misc:Depends}
Recommends: digiham (>= 0.3), dsd (>= 1.7), sox, direwolf (>= 1.4), wsjtx, soapysdr-tools
Description: multi-user web sdr
Open source, multi-user SDR receiver with a web interface

4
debian/openwebrx.install vendored Normal file
View File

@ -0,0 +1,4 @@
config_webrx.py etc/openwebrx/
bands.json etc/openwebrx/
bookmarks.json etc/openwebrx/
systemd/openwebrx.service lib/systemd/system/

7
debian/postinst vendored Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
set -euxo pipefail
adduser --system --group --no-create-home --home /nonexistant openwebrx
usermod -aG plugdev openwebrx
#DEBHELPER#

5
debian/rules vendored Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/make -f
export PYBUILD_NAME=openwebrx
%:
dh $@ --with python3 --buildsystem=pybuild --with systemd

1
debian/source/format vendored Normal file
View File

@ -0,0 +1 @@
3.0 (native)

View File

@ -1,6 +1,10 @@
ARG ARCH
FROM openwebrx-base:$ARCH
ARG ARCHTAG
FROM openwebrx-soapysdr-base:$ARCHTAG
ADD docker/scripts/install-dependencies-airspy.sh /
RUN /install-dependencies-airspy.sh
RUN rm /install-dependencies-airspy.sh
ADD docker/scripts/install-connectors.sh /
RUN /install-connectors.sh
RUN rm /install-connectors.sh

View File

@ -1,5 +1,4 @@
ARG BASE_IMAGE
FROM $BASE_IMAGE
FROM alpine:3.10
RUN apk add --no-cache bash
@ -8,17 +7,13 @@ RUN ln -s /usr/local/lib /usr/local/lib64
ADD docker/scripts/direwolf-1.5.patch /
ADD docker/scripts/install-dependencies.sh /
RUN /install-dependencies.sh
RUN rm /install-dependencies.sh
ADD . /opt/openwebrx
WORKDIR /opt/openwebrx
RUN mkdir -p /tmp/openwebrx && \
mv "/opt/openwebrx/config_webrx.py" "/opt/openwebrx/config_webrx.py.orig" && \
sed 's/temporary_directory = "\/tmp"/temporary_directory = "\/tmp\/openwebrx"/' < "/opt/openwebrx/config_webrx.py.orig" > "/opt/openwebrx/config_webrx.py" && \
rm "/opt/openwebrx/config_webrx.py.orig"
VOLUME /config
VOLUME /etc/openwebrx
ENTRYPOINT [ "/opt/openwebrx/docker/scripts/run.sh" ]
EXPOSE 8073

View File

@ -1,5 +1,5 @@
ARG ARCH
FROM openwebrx-base:$ARCH
ARG ARCHTAG
FROM openwebrx-base:$ARCHTAG
ADD docker/scripts/install-dependencies-*.sh /
ADD docker/scripts/install-lib.*.patch /
@ -9,6 +9,12 @@ RUN /install-dependencies-hackrf.sh
RUN /install-dependencies-soapysdr.sh
RUN /install-dependencies-sdrplay.sh
RUN /install-dependencies-airspy.sh
RUN /install-dependencies-rtlsdr-soapy.sh
RUN /install-dependencies-plutosdr.sh
RUN /install-dependencies-limesdr.sh
RUN /install-dependencies-soapyremote.sh
RUN rm /install-dependencies-*.sh
ADD docker/scripts/install-connectors.sh /
RUN /install-connectors.sh
RUN rm /install-connectors.sh

View File

@ -1,6 +1,7 @@
ARG ARCH
FROM openwebrx-base:$ARCH
ARG ARCHTAG
FROM openwebrx-base:$ARCHTAG
ADD docker/scripts/install-dependencies-hackrf.sh /
RUN /install-dependencies-hackrf.sh
RUN rm /install-dependencies-hackrf.sh

View File

@ -0,0 +1,10 @@
ARG ARCHTAG
FROM openwebrx-soapysdr-base:$ARCHTAG
ADD docker/scripts/install-dependencies-limesdr.sh /
RUN /install-dependencies-limesdr.sh
RUN rm /install-dependencies-limesdr.sh
ADD docker/scripts/install-connectors.sh /
RUN /install-connectors.sh
RUN rm /install-connectors.sh

View File

@ -0,0 +1,10 @@
ARG ARCHTAG
FROM openwebrx-soapysdr-base:$ARCHTAG
ADD docker/scripts/install-dependencies-plutosdr.sh /
RUN /install-dependencies-plutosdr.sh
RUN rm /install-dependencies-plutosdr.sh
ADD docker/scripts/install-connectors.sh /
RUN /install-connectors.sh
RUN rm /install-connectors.sh

View File

@ -1,8 +1,10 @@
ARG ARCH
FROM openwebrx-base:$ARCH
ARG ARCHTAG
FROM openwebrx-base:$ARCHTAG
ADD docker/scripts/install-dependencies-rtlsdr.sh /
RUN /install-dependencies-rtlsdr.sh
RUN rm /install-dependencies-rtlsdr.sh
ADD docker/scripts/install-connectors.sh /
RUN /install-connectors.sh
RUN rm /install-connectors.sh

View File

@ -0,0 +1,10 @@
ARG ARCHTAG
FROM openwebrx-soapysdr-base:$ARCHTAG
ADD docker/scripts/install-dependencies-rtlsdr-soapy.sh /
RUN /install-dependencies-rtlsdr-soapy.sh
RUN rm /install-dependencies-rtlsdr-soapy.sh
ADD docker/scripts/install-connectors.sh /
RUN /install-connectors.sh
RUN rm /install-connectors.sh

View File

@ -1,9 +1,12 @@
ARG ARCH
FROM openwebrx-soapysdr-base:$ARCH
ARG ARCHTAG
FROM openwebrx-soapysdr-base:$ARCHTAG
ADD docker/scripts/install-dependencies-sdrplay.sh /
ADD docker/scripts/install-lib.*.patch /
RUN /install-dependencies-sdrplay.sh
RUN rm /install-dependencies-sdrplay.sh
RUN rm /install-lib.*.patch
ADD docker/scripts/install-connectors.sh /
RUN /install-connectors.sh
RUN rm /install-connectors.sh

View File

@ -0,0 +1,10 @@
ARG ARCHTAG
FROM openwebrx-soapysdr-base:$ARCHTAG
ADD docker/scripts/install-dependencies-soapyremote.sh /
RUN /install-dependencies-soapyremote.sh
RUN rm /install-dependencies-soapyremote.sh
ADD docker/scripts/install-connectors.sh /
RUN /install-connectors.sh
RUN rm /install-connectors.sh

View File

@ -1,6 +1,7 @@
ARG ARCH
FROM openwebrx-base:$ARCH
ARG ARCHTAG
FROM openwebrx-base:$ARCHTAG
ADD docker/scripts/install-dependencies-soapysdr.sh /
RUN /install-dependencies-soapysdr.sh
RUN rm /install-dependencies-soapysdr.sh

5
docker/env Normal file
View File

@ -0,0 +1,5 @@
ARCH=$(uname -m)
IMAGES="openwebrx-rtlsdr openwebrx-sdrplay openwebrx-hackrf openwebrx-airspy openwebrx-rtlsdr-soapy openwebrx-plutosdr openwebrx-limesdr openwebrx-soapyremote openwebrx-full openwebrx"
ALL_ARCHS="x86_64 armv7l aarch64"
TAG=${TAG:-"latest"}
ARCHTAG="$TAG-$ARCH"

View File

@ -1,8 +1,12 @@
#!/usr/bin/env bash
set -euxo pipefail
export MAKEFLAGS="-j4"
function cmakebuild() {
cd $1
if [[ ! -z "${2:-}" ]]; then
git checkout $2
fi
mkdir build
cd build
cmake ..
@ -20,6 +24,6 @@ apk add --no-cache --virtual .build-deps $BUILD_PACKAGES
git clone https://github.com/jketterl/owrx_connector.git
cmakebuild owrx_connector
cmakebuild owrx_connector 22a34fe649a0121a79262f54e99e9aa864b1536f
apk del .build-deps

View File

@ -1,8 +1,12 @@
#!/bin/bash
set -euxo pipefail
export MAKEFLAGS="-j4"
function cmakebuild() {
cd $1
if [[ ! -z "${2:-}" ]]; then
git checkout $2
fi
mkdir build
cd build
cmake ..
@ -21,6 +25,15 @@ apk add --no-cache $STATIC_PACKAGES
apk add --no-cache --virtual .build-deps $BUILD_PACKAGES
git clone https://github.com/airspy/airspyone_host.git
cmakebuild airspyone_host
cmakebuild airspyone_host bceca18f9e3a5f89cff78c4d949c71771d92dfd3
git clone https://github.com/pothosware/SoapyAirspy.git
cmakebuild SoapyAirspy 99756be5c3413a2d447baf70cb5a880662452655
git clone https://github.com/airspy/airspyhf.git
cmakebuild airspyhf 613852a2bb64af42690bf9be2201826af69a9475
git clone https://github.com/pothosware/SoapyAirspyHF.git
cmakebuild SoapyAirspyHF 54f5487dd96207540b2dd562ff9e718e0588770b
apk del .build-deps

View File

@ -1,8 +1,12 @@
#!/bin/bash
set -euxo pipefail
export MAKEFLAGS="-j4"
function cmakebuild() {
cd $1
if [[ ! -z "${2:-}" ]]; then
git checkout $2
fi
mkdir build
cd build
cmake ..
@ -22,6 +26,7 @@ apk add --no-cache --virtual .build-deps $BUILD_PACKAGES
git clone https://github.com/mossmann/hackrf.git
cd hackrf
git checkout 06eb9192cd348083f5f7de9c0da9ead276020011
cmakebuild host
cd ..
rm -rf hackrf

View File

@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -euo pipefail
export MAKEFLAGS="-j4"
cd /tmp
STATIC_PACKAGES="libusb"
BUILD_PACKAGES="git libusb-dev cmake make gcc musl-dev g++ linux-headers"
apk add --no-cache $STATIC_PACKAGES
apk add --no-cache --virtual .build-deps $BUILD_PACKAGES
git clone https://github.com/myriadrf/LimeSuite.git
cd LimeSuite
git checkout 1c1c202f9a6ae4bb34068b6f3f576f7f8e74c7f1
mkdir builddir
cd builddir
cmake .. -DENABLE_EXAMPLES=OFF -DENABLE_DESKTOP=OFF -DENABLE_LIME_UTIL=OFF -DENABLE_QUICKTEST=OFF -DENABLE_OCTAVE=OFF -DENABLE_GUI=OFF -DCMAKE_CXX_STANDARD_LIBRARIES="-latomic"
make
make install
cd ../..
rm -rf LimeSuite
apk del .build-deps

View File

@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -euo pipefail
export MAKEFLAGS="-j4"
function cmakebuild() {
cd $1
if [[ ! -z "${2:-}" ]]; then
git checkout $2
fi
mkdir build
cd build
cmake .. ${3:-}
make
make install
cd ../..
rm -rf $1
}
cd /tmp
STATIC_PACKAGES="libusb libxml2"
BUILD_PACKAGES="git libusb-dev cmake make gcc musl-dev g++ linux-headers libxml2-dev flex bison"
apk add --no-cache $STATIC_PACKAGES
apk add --no-cache --virtual .build-deps $BUILD_PACKAGES
git clone https://github.com/analogdevicesinc/libiio.git
cmakebuild libiio 4e22517c60f3c5e691320871956edede15459ae3 -DCMAKE_INSTALL_PREFIX=/usr/local
git clone https://github.com/analogdevicesinc/libad9361-iio.git
cmakebuild libad9361-iio 8ac95f3325c18c2e34cd9cfd49c7b63d69a0a9d2
git clone https://github.com/pothosware/SoapyPlutoSDR.git
cmakebuild SoapyPlutoSDR e28e4f5c68c16a38c0b50b9606035f3267a135c8
apk del .build-deps

View File

@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -euo pipefail
export MAKEFLAGS="-j4"
function cmakebuild() {
cd $1
if [[ ! -z "${2:-}" ]]; then
git checkout $2
fi
mkdir build
cd build
cmake ..
make
make install
cd ../..
rm -rf $1
}
cd /tmp
STATIC_PACKAGES="libusb"
BUILD_PACKAGES="git libusb-dev cmake make gcc musl-dev g++ linux-headers"
apk add --no-cache $STATIC_PACKAGES
apk add --no-cache --virtual .build-deps $BUILD_PACKAGES
git clone https://github.com/osmocom/rtl-sdr.git
cmakebuild rtl-sdr b5af355b1d833b3c898a61cf1e072b59b0ea3440
git clone https://github.com/pothosware/SoapyRTLSDR.git
cmakebuild SoapyRTLSDR 5c5d9503337c6d1c34b496dec6f908aab9478b0f
apk del .build-deps

View File

@ -1,8 +1,12 @@
#!/bin/bash
set -euxo pipefail
export MAKEFLAGS="-j4"
function cmakebuild() {
cd $1
if [[ ! -z "${2:-}" ]]; then
git checkout $2
fi
mkdir build
cd build
cmake ..
@ -21,6 +25,6 @@ apk add --no-cache $STATIC_PACKAGES
apk add --no-cache --virtual .build-deps $BUILD_PACKAGES
git clone https://github.com/osmocom/rtl-sdr.git
cmakebuild rtl-sdr
cmakebuild rtl-sdr b5af355b1d833b3c898a61cf1e072b59b0ea3440
apk del .build-deps

View File

@ -1,8 +1,12 @@
#!/bin/bash
set -euxo pipefail
export MAKEFLAGS="-j4"
function cmakebuild() {
cd $1
if [[ ! -z "${2:-}" ]]; then
git checkout $2
fi
mkdir build
cd build
cmake ..
@ -29,9 +33,12 @@ case $ARCH in
armv*)
BINARY=SDRplay_RSP_API-RPi-2.13.1.run
;;
aarch64)
BINARY=SDRplay_RSP_API-ARM64-2.13.1.run
;;
esac
wget http://www.sdrplay.com/software/$BINARY
wget https://www.sdrplay.com/software/$BINARY
sh $BINARY --noexec --target sdrplay
patch --verbose -Np0 < /install-lib.$ARCH.patch
@ -42,6 +49,6 @@ rm -rf sdrplay
rm $BINARY
git clone https://github.com/pothosware/SoapySDRPlay.git
cmakebuild SoapySDRPlay
cmakebuild SoapySDRPlay 14ec39e4ff0dab7ae7fdf1afbbd2d28b49b0ffae
apk del .build-deps

View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -euo pipefail
export MAKEFLAGS="-j4"
function cmakebuild() {
cd $1
if [[ ! -z "${2:-}" ]]; then
git checkout $2
fi
mkdir build
cd build
cmake ..
make
make install
cd ../..
rm -rf $1
}
cd /tmp
STATIC_PACKAGES="avahi"
BUILD_PACKAGES="git cmake make gcc musl-dev g++ linux-headers avahi-dev"
apk add --no-cache $STATIC_PACKAGES
apk add --no-cache --virtual .build-deps $BUILD_PACKAGES
git clone https://github.com/pothosware/SoapyRemote.git
cmakebuild SoapyRemote 6d9bd820da470cfe7b27b2e6946af93cfece448f
apk del .build-deps

View File

@ -1,8 +1,12 @@
#!/bin/bash
set -euxo pipefail
export MAKEFLAGS="-j4"
function cmakebuild() {
cd $1
if [[ ! -z "${2:-}" ]]; then
git checkout $2
fi
mkdir build
cd build
cmake ..
@ -21,9 +25,6 @@ apk add --no-cache $STATIC_PACKAGES
apk add --no-cache --virtual .build-deps $BUILD_PACKAGES
git clone https://github.com/pothosware/SoapySDR
cmakebuild SoapySDR
git clone https://github.com/rxseger/rx_tools
cmakebuild rx_tools
cmakebuild SoapySDR f722f9ce5b629c3c44401a9bf628b3f8e67a9695
apk del .build-deps

View File

@ -1,8 +1,12 @@
#!/bin/bash
set -euxo pipefail
export MAKEFLAGS="-j4"
function cmakebuild() {
cd $1
if [[ ! -z "${2:-}" ]]; then
git checkout $2
fi
mkdir build
cd build
cmake ..
@ -21,33 +25,33 @@ apk add --no-cache $STATIC_PACKAGES
apk add --no-cache --virtual .build-deps $BUILD_PACKAGES
git clone https://git.code.sf.net/p/itpp/git itpp
cmakebuild itpp
cmakebuild itpp bb5c7e95f40e8fdb5c3f3d01a84bcbaf76f3676d
git clone https://github.com/jketterl/csdr.git -b docker_fixes
git clone https://github.com/jketterl/csdr.git
cd csdr
git checkout fe0b042d9cdc2605a817ca7fdd3a23c48bf07563
make
make install
cd ..
rm -rf csdr
git clone https://github.com/szechyjs/mbelib.git
cmakebuild mbelib
cmakebuild mbelib 9a04ed5c78176a9965f3d43f7aa1b1f5330e771f
git clone https://github.com/jketterl/digiham.git
cmakebuild digiham
cmakebuild digiham 95206501be89b38d0267bf6c29a6898e7c65656f
git clone https://github.com/f4exb/dsd.git
cmakebuild dsd
cmakebuild dsd f6939f9edbbc6f66261833616391a4e59cb2b3d7
WSJT_DIR=wsjtx-2.1.0
WSJT_DIR=wsjtx-2.1.2
WSJT_TGZ=${WSJT_DIR}.tgz
wget http://physics.princeton.edu/pulsar/k1jt/$WSJT_TGZ
tar xvfz $WSJT_TGZ
cmakebuild $WSJT_DIR
git clone https://github.com/wb2osz/direwolf.git
git clone --depth 1 -b 1.5 https://github.com/wb2osz/direwolf.git
cd direwolf
git checkout 1.5
patch -Np1 < /direwolf-1.5.patch
make
make install
@ -55,5 +59,8 @@ cd ..
rm -rf direwolf
git clone https://github.com/hessu/aprs-symbols /opt/aprs-symbols
pushd /opt/aprs-symbols
git checkout 5c2abe2658ee4d2563f3c73b90c6f59124839802
popd
apk del .build-deps

View File

@ -0,0 +1,40 @@
--- sdrplay/install_lib.sh 2018-06-21 18:47:08.000000000 +0000
+++ sdrplay/install_lib_patched.sh 2019-12-15 01:49:49.477386963 +0000
@@ -3,19 +3,7 @@
echo "Installing SDRplay RSP API library 2.13..."
-more sdrplay_license.txt
-
-while true; do
- echo "Press y and RETURN to accept the license agreement and continue with"
- read -p "the installation, or press n and RETURN to exit the installer [y/n] " yn
- case $yn in
- [Yy]* ) break;;
- [Nn]* ) exit;;
- * ) echo "Please answer y or n";;
- esac
-done
-
-export ARCH=`arch`
+export ARCH=`uname -m`
export VERS="2.13"
echo "Architecture: ${ARCH}"
@@ -63,16 +51,6 @@
echo " "
exit 1
fi
-
-if /sbin/ldconfig -p | /bin/fgrep -q libusb-1.0; then
- echo "Libusb found, continuing..."
-else
- echo " "
- echo "ERROR: Libusb cannot be found. Please install libusb and then run"
- echo "the installer again. Libusb can be installed from http://libusb.info"
- echo " "
- exit 1
-fi
sudo ldconfig

View File

@ -1,12 +1,17 @@
#!/bin/bash
set -euo pipefail
if [[ ! -f /config/config_webrx.py ]] ; then
cp config_webrx.py /config
mkdir -p /etc/openwebrx/
mkdir -p /tmp/openwebrx/
if [[ ! -f /etc/openwebrx/config_webrx.py ]] ; then
sed 's/temporary_directory = "\/tmp"/temporary_directory = "\/tmp\/openwebrx"/' < "/opt/openwebrx/config_webrx.py" > "/etc/openwebrx/config_webrx.py"
fi
if [[ ! -f /etc/openwebrx/bands.json ]] ; then
cp bands.json /etc/openwebrx/
fi
if [[ ! -f /etc/openwebrx/bookmarks.json ]] ; then
cp bookmarks.json /etc/openwebrx/
fi
rm config_webrx.py
ln -s /config/config_webrx.py .
_term() {

0
htdocs/__init__.py Normal file
View File

View File

@ -3,7 +3,7 @@
This file is part of OpenWebRX,
an open-source SDR receiver software with a web UI.
Copyright (c) 2013-2015 by Andras Retzler <randras@sdr.hu>
Copyright (c) 2019 by Jakob Ketterl <dd5jfk@darc.de>
Copyright (c) 2019-2020 by Jakob Ketterl <dd5jfk@darc.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
@ -266,14 +266,16 @@ input[type=range]:focus::-ms-fill-upper
background-repeat: no-repeat;
background-color: #1e5f7f;
background-size: cover;
display: flex;
flex-direction: column;
}
#webrx-canvas-container
{
position: relative;
overflow: hidden;
overflow: visible;
cursor: crosshair;
height: 100%;
flex-grow: 1;
}
#webrx-canvas-container canvas
@ -286,13 +288,6 @@ input[type=range]:focus::-ms-fill-upper
height: 200px;
}
#openwebrx-mathbox-container
{
flex-grow: 1;
overflow: none;
display: none;
}
#openwebrx-log-scroll
{
/*overflow-y:auto;*/
@ -309,48 +304,40 @@ input[type=range]:focus::-ms-fill-upper
color: #ff6262;
}
/*#webrx-freq-show
{
visibility: hidden;
position: absolute;
top: 0px;
left: 0px;
padding: 5px;
font-weight: bold;
border-radius: 10px;
-moz-border-radius: 10px;
background-color: #999999;
color: White;
z-index:9999; /*should be higher?
}*/
/* removed non-free fonts like that: */
/*@font-face {
font-family: 'unibody_8_pro_regregular';
src: url('../gfx/unibody8pro-regular-webfont.eot');
src: url('../gfx/unibody8pro-regular-webfont.ttf');
font-weight: normal;
font-style: normal;
}*/
@font-face {
font-family: 'expletus-sans-medium';
src: url('../gfx/font-expletus-sans/ExpletusSans-Medium.ttf');
font-family: 'roboto-mono';
src: url('../fonts/RobotoMono-Regular.ttf');
font-weight: normal;
font-style: normal;
}
#webrx-actual-freq
{
#webrx-actual-freq {
width: 100%;
text-align: left;
font-size: 16pt;
font-family: 'expletus-sans-medium';
padding: 0;
margin: 0;
line-height:22px;
display: flex;
flex-direction: row;
}
#webrx-actual-freq > * {
flex: 1;
}
#webrx-actual-freq input {
font-family: 'roboto-mono';
width: 0;
box-sizing: border-box;
border: 0;
padding: 0;
background-color: inherit;
color: inherit;
}
#webrx-actual-freq, #webrx-actual-freq input {
font-size: 16pt;
font-family: 'roboto-mono';
line-height: 22px;
}
#webrx-mouse-freq
@ -359,7 +346,7 @@ input[type=range]:focus::-ms-fill-upper
text-align: left;
font-size: 10pt;
color: #AAA;
font-family: 'expletus-sans-medium';
font-family: 'roboto-mono';
margin-bottom: 5px;
}
@ -651,11 +638,10 @@ img.openwebrx-mirror-img
float: right;
margin-right: 5px;
margin-top: 24px;
font-family: 'expletus-sans-medium';
font-family: 'roboto-mono';
}
#openwebrx-autoplay-overlay
{
.openwebrx-overlay {
position: fixed;
width: 100%;
height: 100%;
@ -669,6 +655,10 @@ img.openwebrx-mirror-img
color: white;
font-weight: bold;
font-size: 20pt;
}
#openwebrx-autoplay-overlay
{
cursor: pointer;
transition: opacity 0.3s linear;
}
@ -678,7 +668,7 @@ img.openwebrx-mirror-img
width: 150px;
}
#openwebrx-autoplay-overlay .overlay-content {
.openwebrx-overlay .overlay-content {
position: absolute;
left: 50%;
top: 50%;
@ -686,6 +676,12 @@ img.openwebrx-mirror-img
text-align: center;
}
#openwebrx-error-overlay .overlay-content {
background-color: #000;
padding: 50px;
border-radius: 20px;
}
#openwebrx-digimode-canvas-container
{
/*margin: -10px -10px 10px -10px;*/
@ -928,13 +924,15 @@ img.openwebrx-mirror-img
}
#openwebrx-panel-wsjt-message,
#openwebrx-panel-packet-message
#openwebrx-panel-packet-message,
#openwebrx-panel-pocsag-message
{
height: 180px;
}
#openwebrx-panel-wsjt-message tbody,
#openwebrx-panel-packet-message tbody
#openwebrx-panel-packet-message tbody,
#openwebrx-panel-pocsag-message tbody
{
display: block;
overflow: auto;
@ -943,7 +941,8 @@ img.openwebrx-mirror-img
}
#openwebrx-panel-wsjt-message thead tr,
#openwebrx-panel-packet-message thead tr
#openwebrx-panel-packet-message thead tr,
#openwebrx-panel-pocsag-message thead tr
{
display: block;
}
@ -951,7 +950,9 @@ img.openwebrx-mirror-img
#openwebrx-panel-wsjt-message th,
#openwebrx-panel-wsjt-message td,
#openwebrx-panel-packet-message th,
#openwebrx-panel-packet-message td
#openwebrx-panel-packet-message td,
#openwebrx-panel-pocsag-message th,
#openwebrx-panel-pocsag-message td
{
width: 50px;
text-align: left;
@ -973,6 +974,7 @@ img.openwebrx-mirror-img
#openwebrx-panel-packet-message .message {
width: 410px;
max-width: 410px;
}
#openwebrx-panel-packet-message .callsign {
@ -984,6 +986,16 @@ img.openwebrx-mirror-img
text-align: center;
}
#openwebrx-panel-pocsag-message .address {
width: 100px;
}
#openwebrx-panel-pocsag-message .message {
width: 486px;
max-width: 486px;
white-space: pre;
}
.aprs-symbol {
display: inline-block;
width: 15px;
@ -1065,12 +1077,14 @@ img.openwebrx-mirror-img
#openwebrx-panel-digimodes[data-mode="jt9"] #openwebrx-digimode-content-container,
#openwebrx-panel-digimodes[data-mode="ft4"] #openwebrx-digimode-content-container,
#openwebrx-panel-digimodes[data-mode="packet"] #openwebrx-digimode-content-container,
#openwebrx-panel-digimodes[data-mode="pocsag"] #openwebrx-digimode-content-container,
#openwebrx-panel-digimodes[data-mode="ft8"] #openwebrx-digimode-select-channel,
#openwebrx-panel-digimodes[data-mode="wspr"] #openwebrx-digimode-select-channel,
#openwebrx-panel-digimodes[data-mode="jt65"] #openwebrx-digimode-select-channel,
#openwebrx-panel-digimodes[data-mode="jt9"] #openwebrx-digimode-select-channel,
#openwebrx-panel-digimodes[data-mode="ft4"] #openwebrx-digimode-select-channel,
#openwebrx-panel-digimodes[data-mode="packet"] #openwebrx-digimode-select-channel
#openwebrx-panel-digimodes[data-mode="packet"] #openwebrx-digimode-select-channel,
#openwebrx-panel-digimodes[data-mode="pocsag"] #openwebrx-digimode-select-channel
{
display: none;
}
@ -1080,8 +1094,10 @@ img.openwebrx-mirror-img
#openwebrx-panel-digimodes[data-mode="jt65"] #openwebrx-digimode-canvas-container,
#openwebrx-panel-digimodes[data-mode="jt9"] #openwebrx-digimode-canvas-container,
#openwebrx-panel-digimodes[data-mode="ft4"] #openwebrx-digimode-canvas-container,
#openwebrx-panel-digimodes[data-mode="packet"] #openwebrx-digimode-canvas-container
#openwebrx-panel-digimodes[data-mode="packet"] #openwebrx-digimode-canvas-container,
#openwebrx-panel-digimodes[data-mode="pocsag"] #openwebrx-digimode-canvas-container
{
height: 200px;
margin: -10px;
}

View File

@ -1,5 +1,6 @@
<HTML><HEAD>
<TITLE>OpenWebRX Feature report</TITLE>
<link rel="shortcut icon" type="image/x-icon" href="static/favicon.ico" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="static/css/features.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.9.0/showdown.min.js"></script>

View File

@ -1,6 +1,6 @@
$(function(){
var converter = new showdown.Converter();
$.ajax('/api/features').done(function(data){
$.ajax('api/features').done(function(data){
var $table = $('table.features');
$.each(data, function(name, details) {
var requirements = $.map(details.requirements, function(r, name){
@ -21,4 +21,4 @@ $(function(){
);
})
});
});
});

Binary file not shown.

View File

@ -1,93 +0,0 @@
Copyright (c) 2011, Jasper de Waard (jasper@designtown.nl),
with Reserved Font Name "Expletus Sans".
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

View File

@ -18,7 +18,7 @@
<li data-toggle-panel="openwebrx-panel-status"><img src="static/gfx/openwebrx-panel-status.png" /><br/>Status</li>
<li data-toggle-panel="openwebrx-panel-log"><img src="static/gfx/openwebrx-panel-log.png" /><br/>Log</li>
<li data-toggle-panel="openwebrx-panel-receiver"><img src="static/gfx/openwebrx-panel-receiver.png" /><br/>Receiver</li>
<li><a href="/map" target="_blank"><img src="static/gfx/openwebrx-panel-map.png" /><br/>Map</a></li>
<li><a href="map" target="_blank"><img src="static/gfx/openwebrx-panel-map.png" /><br/>Map</a></li>
</ul>
</section>
</div>

View File

@ -4,7 +4,7 @@
This file is part of OpenWebRX,
an open-source SDR receiver software with a web UI.
Copyright (c) 2013-2015 by Andras Retzler <randras@sdr.hu>
Copyright (c) 2019 by Jakob Ketterl <dd5jfk@darc.de>
Copyright (c) 2019-2020 by Jakob Ketterl <dd5jfk@darc.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
@ -23,8 +23,7 @@
<html>
<head>
<title>OpenWebRX | Open Source SDR Web App for Everyone!</title>
<script src="static/sdr.js"></script>
<script src="static/mathbox-bundle.min.js"></script>
<link rel="shortcut icon" type="image/x-icon" href="static/favicon.ico" />
<script src="static/openwebrx.js"></script>
<script src="static/lib/jquery-3.2.1.min.js"></script>
<script src="static/lib/jquery.nanoscroller.js"></script>
@ -32,6 +31,7 @@
<script src="static/lib/AudioEngine.js"></script>
<script src="static/lib/ProgressBar.js"></script>
<script src="static/lib/Measurement.js"></script>
<script src="static/lib/FrequencyDisplay.js"></script>
<link rel="stylesheet" type="text/css" href="static/lib/nanoscroller.css" />
<link rel="stylesheet" type="text/css" href="static/css/openwebrx.css" />
<meta charset="utf-8">
@ -45,7 +45,6 @@
<canvas id="openwebrx-scale-canvas" width="0" height="0"></canvas>
</div>
</div>
<div id="openwebrx-mathbox-container"> </div>
<div id="webrx-canvas-background">
<div id="webrx-canvas-container">
<!-- add canvas here by javascript -->
@ -53,10 +52,6 @@
</div>
<div id="openwebrx-panels-container">
<div id="openwebrx-panels-container-left">
<div class="openwebrx-panel" data-panel-name="client-under-devel" style="width: 245px; background-color: Red;">
<span style="font-size: 15pt; font-weight: bold;">Under construction</span>
<br />We're working on the code right now, so the application might fail.
</div>
<div class="openwebrx-panel" id="openwebrx-panel-digimodes" style="display: none; width: 619px;" data-panel-name="digimodes">
<div id="openwebrx-digimode-canvas-container">
<div id="openwebrx-digimode-select-channel"></div>
@ -87,6 +82,13 @@
</tr></thead>
<tbody></tbody>
</table>
<table class="openwebrx-panel" id="openwebrx-panel-pocsag-message" style="display: none; width: 619px;" data-panel-name="pocsag-message">
<thead><tr>
<th class="address">Address</th>
<th class="message">Message</th>
</tr></thead>
<tbody></tbody>
</table>
<div class="openwebrx-panel openwebrx-meta-panel" id="openwebrx-panel-metadata-ysf" style="display: none;" data-panel-name="metadata-ysf">
<div class="openwebrx-meta-frame">
<div class="openwebrx-meta-slot">
@ -120,7 +122,6 @@
<div class="openwebrx-panel-inner nano" id="openwebrx-log-scroll">
<div class="nano-content">
<div id="openwebrx-client-log-title">OpenWebRX client log</div>
<div>Author contact: <a href="http://blog.sdr.hu/about" target="_blank">András Retzler, HA7ILM</a></div>
<div>Author contact: <a href="http://www.justjakob.de/" target="_blank">Jakob Ketterl, DD5JFK</a></div>
<div id="openwebrx-debugdiv"></div>
</div>
@ -139,8 +140,8 @@
<div class="openwebrx-panel" id="openwebrx-panel-receiver" data-panel-name="client-params" style="width: 259px;">
<div class="openwebrx-panel-line frequencies-container">
<div class="frequencies">
<div id="webrx-actual-freq">---.--- MHz</div>
<div id="webrx-mouse-freq">---.--- MHz</div>
<div id="webrx-actual-freq"></div>
<div id="webrx-mouse-freq"></div>
</div>
<div class="openwebrx-button openwebrx-square-button openwebrx-bookmark-button" style="display:none;" title="Add bookmark...">
<img src="static/gfx/openwebrx-bookmark.png">
@ -181,12 +182,14 @@
<select id="openwebrx-secondary-demod-listbox" onchange="secondary_demod_listbox_changed();">
<option value="none"></option>
<option value="bpsk31">BPSK31</option>
<option value="bpsk63">BPSK63</option>
<option value="ft8" data-feature="wsjt-x">FT8</option>
<option value="wspr" data-feature="wsjt-x">WSPR</option>
<option value="jt65" data-feature="wsjt-x">JT65</option>
<option value="jt9" data-feature="wsjt-x">JT9</option>
<option value="ft4" data-feature="wsjt-x">FT4</option>
<option value="packet" data-feature="packet">Packet</option>
<option value="pocsag" data-feature="pocsag">Pocsag</option>
</select>
</div>
<div class="openwebrx-panel-line">
@ -206,7 +209,6 @@
<div class="openwebrx-button openwebrx-square-button" onclick="zoomOutOneStep();" title="Zoom out one step"> <img src="static/gfx/openwebrx-zoom-out.png" /></div>
<div class="openwebrx-button openwebrx-square-button" onclick="zoomInTotal();" title="Zoom in totally"><img src="static/gfx/openwebrx-zoom-in-total.png" /></div>
<div class="openwebrx-button openwebrx-square-button" onclick="zoomOutTotal();" title="Zoom out totally"><img src="static/gfx/openwebrx-zoom-out-total.png" /></div>
<div class="openwebrx-button openwebrx-square-button" onclick="mathbox_toggle();" title="Toggle 3D view"><img src="static/gfx/openwebrx-3d-spectrum.png" /></div>
<div id="openwebrx-smeter-db">0 dB</div>
</div>
<div class="openwebrx-panel-line">
@ -218,12 +220,19 @@
</div>
</div>
</div>
<div id="openwebrx-autoplay-overlay" style="display:none;">
<div id="openwebrx-autoplay-overlay" class="openwebrx-overlay" style="display:none;">
<div class="overlay-content">
<img id="openwebrx-play-button" src="static/gfx/openwebrx-play-button.png" />
<div>Start OpenWebRX</div>
</div>
</div>
<div id="openwebrx-error-overlay" class="openwebrx-overlay" style="display:none;">
<div class="overlay-content">
<div>This receiver is currently unavailable due to technical issues.</div>
<div>Error Message:</div>
<div class="errormessage"></div>
</div>
</div>
<div id="openwebrx-dialog-bookmark" class="openwebrx-dialog" style="display:none;">
<form>
<div class="form-field">

View File

@ -9,7 +9,7 @@ AprsMarker.prototype.draw = function() {
if (this.symbol) {
var tableId = this.symbol.table === '/' ? 0 : 1;
div.style.background = 'url(/aprs-symbols/aprs-symbols-24-' + tableId + '@2x.png)';
div.style.background = 'url(aprs-symbols/aprs-symbols-24-' + tableId + '@2x.png)';
div.style['background-size'] = '384px 144px';
div.style['background-position-x'] = -(this.symbol.index % 16) * 24 + 'px';
div.style['background-position-y'] = -Math.floor(this.symbol.index / 16) * 24 + 'px';
@ -63,7 +63,7 @@ AprsMarker.prototype.onAdd = function() {
var overlay = this.overlay = document.createElement('div');
overlay.style.width = '24px';
overlay.style.height = '24px';
overlay.style.background = 'url(/aprs-symbols/aprs-symbols-24-2@2x.png)';
overlay.style.background = 'url(aprs-symbols/aprs-symbols-24-2@2x.png)';
overlay.style['background-size'] = '384px 144px';
overlay.style.display = 'none';

View File

@ -14,11 +14,11 @@ function AudioEngine(maxBufferLength, audioReporter) {
this.allowed = this.audioContext.state === 'running';
this.started = false;
this.audioCodec = new sdrjs.ImaAdpcm();
this.audioCodec = new ImaAdpcmCodec();
this.compression = 'none';
this.setupResampling();
this.resampler = new sdrjs.RationalResamplerFF(this.resamplingFactor, 1);
this.resampler = new Interpolator(this.resamplingFactor);
this.maxBufferSize = maxBufferLength * this.getSampleRate();
}
@ -203,7 +203,7 @@ AudioEngine.prototype.pushAudio = function(data) {
} else {
buffer = new Int16Array(data);
}
buffer = this.resampler.process(sdrjs.ConvertI16_F(buffer));
buffer = this.resampler.process(buffer);
if (this.audioNode.port) {
// AudioWorklets supported
this.audioNode.port.postMessage(buffer);
@ -228,3 +228,129 @@ AudioEngine.prototype.getBuffersize = function() {
if (!this.audioBuffers) return 0;
return this.audioBuffers.map(function(b){ return b.length; }).reduce(function(a, b){ return a + b; }, 0);
};
function ImaAdpcmCodec() {
this.reset();
}
ImaAdpcmCodec.prototype.reset = function() {
this.stepIndex = 0;
this.predictor = 0;
this.step = 0;
};
ImaAdpcmCodec.imaIndexTable = [ -1, -1, -1, -1, 2, 4, 6, 8, -1, -1, -1, -1, 2, 4, 6, 8 ];
ImaAdpcmCodec.imaStepTable = [
7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
];
ImaAdpcmCodec.prototype.decode = function(data) {
var output = new Int16Array(data.length * 2);
for (var i = 0; i < data.length; i++) {
output[i * 2] = this.decodeNibble(data[i] & 0x0F);
output[i * 2 + 1] = this.decodeNibble((data[i] >> 4) & 0x0F);
}
return output;
};
ImaAdpcmCodec.prototype.decodeNibble = function(nibble) {
this.stepIndex += ImaAdpcmCodec.imaIndexTable[nibble];
this.stepIndex = Math.min(Math.max(this.stepIndex, 0), 88);
var diff = this.step >> 3;
if (nibble & 1) diff += this.step >> 2;
if (nibble & 2) diff += this.step >> 1;
if (nibble & 4) diff += this.step;
if (nibble & 8) diff = -diff;
this.predictor += diff;
this.predictor = Math.min(Math.max(this.predictor, -32768), 32767);
this.step = ImaAdpcmCodec.imaStepTable[this.stepIndex];
return this.predictor;
};
function Interpolator(factor) {
this.factor = factor;
this.lowpass = new Lowpass(factor)
}
Interpolator.prototype.process = function(data) {
var output = new Float32Array(data.length * this.factor);
for (var i = 0; i < data.length; i++) {
output[i * this.factor] = (data[i] + 0.5) / 32768;
}
return this.lowpass.process(output);
};
function Lowpass(interpolation) {
this.interpolation = interpolation;
var transitionBandwidth = 0.05;
this.numtaps = Math.round(4 / transitionBandwidth);
if (this.numtaps % 2 == 0) this.numtaps += 1;
var cutoff = 1 / interpolation;
this.coefficients = this.getCoefficients(cutoff / 2);
this.delay = new Float32Array(this.numtaps);
for (var i = 0; i < this.numtaps; i++){
this.delay[i] = 0;
}
this.delayIndex = 0;
}
Lowpass.prototype.getCoefficients = function(cutoffRate) {
var middle = Math.floor(this.numtaps / 2);
// hamming window
var window_function = function(r){
var rate = 0.5 + r / 2;
return 0.54 - 0.46 * Math.cos(2 * Math.PI * rate);
}
var output = [];
output[middle] = 2 * Math.PI * cutoffRate * window_function(0);
for (var i = 1; i <= middle; i++) {
output[middle - i] = output[middle + i] = (Math.sin(2 * Math.PI * cutoffRate * i) / i) * window_function(i / middle);
}
return this.normalizeCoefficients(output);
};
Lowpass.prototype.normalizeCoefficients = function(input) {
var sum = 0;
var output = [];
for (var i = 0; i < input.length; i++) {
sum += input[i];
}
for (var i = 0; i < input.length; i++) {
output[i] = input[i] / sum;
}
return output;
};
Lowpass.prototype.process = function(input) {
output = new Float32Array(input.length);
for (var oi = 0; oi < input.length; oi++) {
this.delay[this.delayIndex] = input[oi];
this.delayIndex = (this.delayIndex + 1) % this.numtaps;
var acc = 0;
var index = this.delayIndex;
for (var i = 0; i < this.numtaps; ++i) {
var index = index != 0 ? index - 1 : this.numtaps - 1;
acc += this.delay[index] * this.coefficients[i];
if (isNaN(acc)) debugger;
}
// gain by interpolation
output[oi] = this.interpolation * acc;
}
return output;
};

View File

@ -9,7 +9,7 @@ function BookmarkBar() {
me.$container.find('.bookmark').removeClass('selected');
var b = $bookmark.data();
if (!b || !b.frequency || (!b.modulation && !b.digital_modulation)) return;
demodulator_set_offset_frequency(0, b.frequency - center_freq);
demodulators[0].set_offset_frequency(b.frequency - center_freq);
if (b.modulation) {
demodulator_analog_replace(b.modulation);
} else if (b.digital_modulation) {

View File

@ -0,0 +1,101 @@
function FrequencyDisplay(element) {
this.element = $(element);
this.digits = [];
this.setupElements();
this.setFrequency(0);
}
FrequencyDisplay.prototype.setupElements = function() {
this.displayContainer = $('<div>');
this.digitContainer = $('<span>');
this.displayContainer.html([this.digitContainer, $('<span> MHz</span>')]);
this.element.html(this.displayContainer);
};
FrequencyDisplay.prototype.setFrequency = function(freq) {
this.frequency = freq;
var formatted = (freq / 1e6).toLocaleString(undefined, {maximumFractionDigits: 4, minimumFractionDigits: 4});
var children = this.digitContainer.children();
for (var i = 0; i < formatted.length; i++) {
if (!this.digits[i]) {
this.digits[i] = $('<span>');
var before = children[i];
if (before) {
$(before).after(this.digits[i]);
} else {
this.digitContainer.append(this.digits[i]);
}
}
this.digits[i][(isNaN(formatted[i]) ? 'remove' : 'add') + 'Class']('digit');
this.digits[i].html(formatted[i]);
}
while (this.digits.length > formatted.length) {
this.digits.pop().remove();
}
};
function TuneableFrequencyDisplay(element) {
FrequencyDisplay.call(this, element);
this.setupEvents();
}
TuneableFrequencyDisplay.prototype = new FrequencyDisplay();
TuneableFrequencyDisplay.prototype.setupElements = function() {
FrequencyDisplay.prototype.setupElements.call(this);
this.input = $('<input>');
this.input.hide();
this.element.append(this.input);
};
TuneableFrequencyDisplay.prototype.setupEvents = function() {
var me = this;
me.listeners = [];
me.element.on('wheel', function(e){
e.preventDefault();
e.stopPropagation();
var index = me.digitContainer.find('.digit').index(e.target);
if (index < 0) return;
var delta = 10 ** (Math.floor(Math.log10(me.frequency)) - index);
if (e.originalEvent.deltaY > 0) delta *= -1;
var newFrequency = me.frequency + delta;
me.listeners.forEach(function(l) {
l(newFrequency);
});
});
var submit = function(){
var freq = parseInt(me.input.val());
if (!isNaN(freq)) {
me.listeners.forEach(function(l) {
l(freq);
});
}
me.input.hide();
me.displayContainer.show();
};
me.input.on('blur', submit).on('keyup', function(e){
if (e.keyCode == 13) return submit();
if (e.keyCode == 27) {
me.input.hide();
me.displayContainer.show();
}
});
me.input.on('click', function(e){
e.stopPropagation();
});
me.element.on('click', function(){
me.input.val(me.frequency);
me.input.show();
me.displayContainer.hide();
me.input.focus();
});
};
TuneableFrequencyDisplay.prototype.onFrequencyChange = function(listener){
this.listeners.push(listener);
};

View File

@ -2,6 +2,7 @@
<html>
<head>
<title>OpenWebRX Map</title>
<link rel="shortcut icon" type="image/x-icon" href="static/favicon.ico" />
<script src="static/lib/jquery-3.2.1.min.js"></script>
<script src="static/lib/chroma.min.js"></script>
<script src="static/map.js"></script>

View File

@ -1,9 +1,4 @@
(function(){
var protocol = 'ws';
if (window.location.toString().startsWith('https://')) {
protocol = 'wss';
}
var query = window.location.search.replace(/^\?/, '').split('&').map(function(v){
var s = v.split('=');
var r = {};
@ -18,8 +13,19 @@
var expectedLocator;
if (query.locator) expectedLocator = query.locator;
var ws_url = protocol + "://" + (window.location.origin.split("://")[1]) + "/ws/";
if (!("WebSocket" in window)) return;
var protocol = window.location.protocol.match(/https/) ? 'wss' : 'ws';
var href = window.location.href;
var index = href.lastIndexOf('/');
if (index > 0) {
href = href.substr(0, index + 1);
}
href = href.split("://")[1];
href = protocol + "://" + href;
if (!href.endsWith('/')) {
href += '/';
}
var ws_url = href + "ws/";
var map;
var markers = {};
@ -216,11 +222,11 @@
},
zoom: 5
});
$.getScript("/static/lib/nite-overlay.js").done(function(){
$.getScript("static/lib/nite-overlay.js").done(function(){
nite.init(map);
setInterval(function() { nite.refresh() }, 10000); // every 10s
});
$.getScript('/static/lib/AprsMarker.js').done(function(){
$.getScript('static/lib/AprsMarker.js').done(function(){
processUpdates(updateQueue);
updateQueue = [];
});
@ -353,4 +359,4 @@
});
}, 1000);
})();
})();

File diff suppressed because one or more lines are too long

View File

@ -1,461 +0,0 @@
.shadergraph-graph {
font: 12px sans-serif;
line-height: 25px;
position: relative;
}
.shadergraph-graph:after {
content: ' ';
display: block;
height: 0;
font-size: 0;
clear: both;
}
.shadergraph-graph svg {
pointer-events: none;
}
.shadergraph-clear {
clear: both;
}
.shadergraph-graph svg {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: auto;
height: auto;
}
.shadergraph-column {
float: left;
}
.shadergraph-node .shadergraph-graph {
float: left;
clear: both;
overflow: visible;
}
.shadergraph-node .shadergraph-graph .shadergraph-node {
margin: 5px 15px 15px;
}
.shadergraph-node {
margin: 5px 15px 25px;
background: rgba(0, 0, 0, .1);
border-radius: 5px;
box-shadow: 0 1px 2px rgba(0, 0, 0, .2),
0 1px 10px rgba(0, 0, 0, .2);
min-height: 35px;
float: left;
clear: left;
position: relative;
}
.shadergraph-type {
font-weight: bold;
}
.shadergraph-header {
font-weight: bold;
text-align: center;
height: 25px;
background: rgba(0, 0, 0, .3);
text-shadow: 0 1px 2px rgba(0, 0, 0, .25);
color: #fff;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
margin-bottom: 5px;
padding: 0 10px;
}
.shadergraph-outlet div {
}
.shadergraph-outlet-in .shadergraph-name {
margin-right: 7px;
}
.shadergraph-outlet-out .shadergraph-name {
margin-left: 7px;
}
.shadergraph-name {
margin: 0 4px;
}
.shadergraph-point {
margin: 6px;
width: 11px;
height: 11px;
border-radius: 7.5px;
background: rgba(255, 255, 255, 1);
}
.shadergraph-outlet-in {
float: left;
clear: left;
}
.shadergraph-outlet-in div {
float: left;
}
.shadergraph-outlet-out {
float: right;
clear: right;
}
.shadergraph-outlet-out div {
float: right;
}
.shadergraph-node-callback {
background: rgba(205, 209, 221, .5);
box-shadow: 0 1px 2px rgba(0, 10, 40, .2),
0 1px 10px rgba(0, 10, 40, .2);
}
.shadergraph-node-callback > .shadergraph-header {
background: rgba(0, 20, 80, .3);
}
.shadergraph-graph .shadergraph-graph .shadergraph-node-callback {
background: rgba(0, 20, 80, .1);
}
.shadergraph-node-call {
background: rgba(209, 221, 205, .5);
box-shadow: 0 1px 2px rgba(10, 40, 0, .2),
0 1px 10px rgba(10, 40, 0, .2);
}
.shadergraph-node-call > .shadergraph-header {
background: rgba(20, 80, 0, .3);
}
.shadergraph-graph .shadergraph-graph .shadergraph-node-call {
background: rgba(20, 80, 0, .1);
}
.shadergraph-node-isolate {
background: rgba(221, 205, 209, .5);
box-shadow: 0 1px 2px rgba(40, 0, 10, .2),
0 1px 10px rgba(40, 0, 10, .2);
}
.shadergraph-node-isolate > .shadergraph-header {
background: rgba(80, 0, 20, .3);
}
.shadergraph-graph .shadergraph-graph .shadergraph-node-isolate {
background: rgba(80, 0, 20, .1);
}
.shadergraph-node.shadergraph-has-code {
cursor: pointer;
}
.shadergraph-node.shadergraph-has-code::before {
position: absolute;
content: ' ';
top: 0;
left: 0;
right: 0;
bottom: 0;
display: none;
border: 2px solid rgba(0, 0, 0, .25);
border-radius: 5px;
}
.shadergraph-node.shadergraph-has-code:hover::before {
display: block;
}
.shadergraph-code {
z-index: 10000;
display: none;
position: absolute;
background: #fff;
color: #000;
white-space: pre;
padding: 10px;
border-radius: 5px;
box-shadow: 0 1px 2px rgba(0, 0, 0, .2),
0 1px 10px rgba(0, 0, 0, .2);
font-family: monospace;
font-size: 10px;
line-height: 12px;
}
.shadergraph-overlay {
position: fixed;
top: 50%;
left: 0;
right: 0;
bottom: 0;
background: #fff;
border-top: 1px solid #CCC;
}
.shadergraph-overlay .shadergraph-view {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
overflow: auto;
}
.shadergraph-overlay .shadergraph-inside {
width: 4000px;
min-height: 100%;
box-sizing: border-box;
}
.shadergraph-overlay .shadergraph-close {
position: absolute;
top: 5px;
right: 5px;
padding: 4px;
border-radius: 16px;
background: rgba(255,255,255,.3);
color: rgba(0, 0, 0, .3);
cursor: pointer;
font-size: 24px;
line-height: 24px;
width: 24px;
text-align: center;
vertical-align: middle;
}
.shadergraph-overlay .shadergraph-close:hover {
background: rgba(255,255,255,1);
color: rgba(0, 0, 0, 1);
}
.shadergraph-overlay .shadergraph-graph {
padding-top: 10px;
overflow: visible;
min-height: 100%;
}
.shadergraph-overlay span {
display: block;
padding: 5px 15px;
margin: 0;
background: rgba(0, 0, 0, .1);
font-weight: bold;
font-family: sans-serif;
}
.mathbox-loader {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
padding: 10px;
border-radius: 50%;
background: #fff;
}
.mathbox-loader.mathbox-exit {
opacity: 0;
-webkit-transition:
opacity .15s ease-in-out;
transition:
opacity .15s ease-in-out;
}
.mathbox-progress {
height: 10px;
border-radius: 5px;
width: 80px;
margin: 0 auto 20px;
box-shadow:
1px 1px 1px rgba(255, 255, 255, .2),
1px -1px 1px rgba(255, 255, 255, .2),
-1px 1px 1px rgba(255, 255, 255, .2),
-1px -1px 1px rgba(255, 255, 255, .2);
background: #ccc;
overflow: hidden;
}
.mathbox-progress > div {
display: block;
width: 0px;
height: 10px;
background: #888;
}
.mathbox-logo {
position: relative;
width: 140px;
height: 100px;
margin: 0 auto 10px;
-webkit-perspective: 200px;
perspective: 200px;
}
.mathbox-logo > div {
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
}
.mathbox-logo > :nth-child(1) {
-webkit-transform: rotateZ(22deg) rotateX(24deg) rotateY(30deg);
transform: rotateZ(22deg) rotateX(24deg) rotateY(30deg);
}
.mathbox-logo > :nth-child(2) {
-webkit-transform: rotateZ(11deg) rotateX(12deg) rotateY(15deg) scale3d(.6, .6, .6);
transform: rotateZ(11deg) rotateX(12deg) rotateY(15deg) scale3d(.6, .6, .6);
}
.mathbox-logo > div > div {
position: absolute;
top: 50%;
left: 50%;
margin-left: -100px;
margin-top: -100px;
width: 200px;
height: 200px;
box-sizing: border-box;
border-radius: 50%;
}
.mathbox-logo > div > :nth-child(1) {
-webkit-transform: scale(0.5, 0.5);
transform: rotateX(30deg) scale(0.5, 0.5);
}
.mathbox-logo > div > :nth-child(2) {
-webkit-transform: rotateX(90deg) scale(0.42, 0.42);
transform: rotateX(90deg) scale(0.42, 0.42);
}
.mathbox-logo > div > :nth-child(3) {
-webkit-transform: rotateY(90deg) scale(0.35, 0.35);
transform: rotateY(90deg) scale(0.35, 0.35);
}
.mathbox-logo > :nth-child(1) > :nth-child(1) {
border: 16px solid #808080;
}
.mathbox-logo > :nth-child(1) > :nth-child(2) {
border: 19px solid #A0A0A0;
}
.mathbox-logo > :nth-child(1) > :nth-child(3) {
border: 23px solid #C0C0C0;
}
.mathbox-logo > :nth-child(2) > :nth-child(1) {
border: 27px solid #808080;
}
.mathbox-logo > :nth-child(2) > :nth-child(2) {
border: 32px solid #A0A0A0;
}
.mathbox-logo > :nth-child(2) > :nth-child(3) {
border: 38px solid #C0C0C0;
}
.mathbox-splash-blue .mathbox-progress {
background: #def;
}
.mathbox-splash-blue .mathbox-progress > div {
background: #1979e7;
}
.mathbox-splash-blue .mathbox-logo > :nth-child(1) > :nth-child(1) {
border-color: #1979e7;
}
.mathbox-splash-blue .mathbox-logo > :nth-child(1) > :nth-child(2) {
border-color: #33b0ff;
}
.mathbox-splash-blue .mathbox-logo > :nth-child(1) > :nth-child(3) {
border-color: #75eaff;
}
.mathbox-splash-blue .mathbox-logo > :nth-child(2) > :nth-child(1) {
border-color: #18487F;
}
.mathbox-splash-blue .mathbox-logo > :nth-child(2) > :nth-child(2) {
border-color: #33b0ff;
}
.mathbox-splash-blue .mathbox-logo > :nth-child(2) > :nth-child(3) {
border-color: #75eaff;
}
.mathbox-overlays {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
pointer-events: none;
transform-style: preserve-3d;
overflow: hidden;
}
.mathbox-overlays > div {
transform-style: preserve-3d;
}
.mathbox-overlay > div {
position: absolute;
will-change: transform, opacity;
}
.mathbox-label {
font-family: sans-serif;
}
.mathbox-outline-1 {
text-shadow:
-1px -1px 0px rgb(255, 255, 255),
1px 1px 0px rgb(255, 255, 255),
-1px 1px 0px rgb(255, 255, 255),
1px -1px 0px rgb(255, 255, 255),
1px 0px 1px rgb(255, 255, 255),
-1px 0px 1px rgb(255, 255, 255),
0px -1px 1px rgb(255, 255, 255),
0px 1px 1px rgb(255, 255, 255);
}
.mathbox-outline-2 {
text-shadow:
0px -2px 0px rgb(255, 255, 255),
0px 2px 0px rgb(255, 255, 255),
-2px 0px 0px rgb(255, 255, 255),
2px 0px 0px rgb(255, 255, 255),
-1px -2px 0px rgb(255, 255, 255),
-2px -1px 0px rgb(255, 255, 255),
-1px 2px 0px rgb(255, 255, 255),
-2px 1px 0px rgb(255, 255, 255),
1px 2px 0px rgb(255, 255, 255),
2px 1px 0px rgb(255, 255, 255),
1px -2px 0px rgb(255, 255, 255),
2px -1px 0px rgb(255, 255, 255);
}
.mathbox-outline-3 {
text-shadow:
3px 0px 0px rgb(255, 255, 255),
-3px 0px 0px rgb(255, 255, 255),
0px 3px 0px rgb(255, 255, 255),
0px -3px 0px rgb(255, 255, 255),
-2px -2px 0px rgb(255, 255, 255),
-2px 2px 0px rgb(255, 255, 255),
2px 2px 0px rgb(255, 255, 255),
2px -2px 0px rgb(255, 255, 255),
-1px -2px 1px rgb(255, 255, 255),
-2px -1px 1px rgb(255, 255, 255),
-1px 2px 1px rgb(255, 255, 255),
-2px 1px 1px rgb(255, 255, 255),
1px 2px 1px rgb(255, 255, 255),
2px 1px 1px rgb(255, 255, 255),
1px -2px 1px rgb(255, 255, 255),
2px -1px 1px rgb(255, 255, 255);
}
.mathbox-outline-4 {
text-shadow:
4px 0px 0px rgb(255, 255, 255),
-4px 0px 0px rgb(255, 255, 255),
0px 4px 0px rgb(255, 255, 255),
0px -4px 0px rgb(255, 255, 255),
-3px -2px 0px rgb(255, 255, 255),
-3px 2px 0px rgb(255, 255, 255),
3px 2px 0px rgb(255, 255, 255),
3px -2px 0px rgb(255, 255, 255),
-2px -3px 0px rgb(255, 255, 255),
-2px 3px 0px rgb(255, 255, 255),
2px 3px 0px rgb(255, 255, 255),
2px -3px 0px rgb(255, 255, 255),
-1px -2px 1px rgb(255, 255, 255),
-2px -1px 1px rgb(255, 255, 255),
-1px 2px 1px rgb(255, 255, 255),
-2px 1px 1px rgb(255, 255, 255),
1px 2px 1px rgb(255, 255, 255),
2px 1px 1px rgb(255, 255, 255),
1px -2px 1px rgb(255, 255, 255),
2px -1px 1px rgb(255, 255, 255);
}
.mathbox-outline-fill, .mathbox-outline-fill * {
color: #fff !important;
}

View File

@ -3,7 +3,7 @@
This file is part of OpenWebRX,
an open-source SDR receiver software with a web UI.
Copyright (c) 2013-2015 by Andras Retzler <randras@sdr.hu>
Copyright (c) 2019 by Jakob Ketterl <dd5jfk@darc.de>
Copyright (c) 2019-2020 by Jakob Ketterl <dd5jfk@darc.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
@ -29,7 +29,7 @@ var center_freq;
var fft_size;
var fft_fps;
var fft_compression = "none";
var fft_codec = new sdrjs.ImaAdpcm();
var fft_codec;
var waterfall_setup_done = 0;
var secondary_fft_size;
var rx_photo_state = 1;
@ -334,7 +334,6 @@ function demod_envelope_where_clicked(x, drag_ranges, key_modifiers) { // Check
//******* class Demodulator *******
// this can be used as a base class for ANY demodulator
Demodulator = function (offset_frequency) {
//console.log("this too");
this.offset_frequency = offset_frequency;
this.envelope = {};
this.color = demodulators_get_next_color();
@ -357,17 +356,23 @@ Demodulator.draggable_ranges = {
demodulator_response_time = 50;
//in ms; if we don't limit the number of SETs sent to the server, audio will underrun (possibly output buffer is cleared on SETs in GNU Radio
function Demodulator_default_analog(offset_frequency, subtype) {
//console.log("hopefully this happens");
//http://stackoverflow.com/questions/4152931/javascript-inheritance-call-super-constructor-or-use-prototype-chain
Demodulator.call(this, offset_frequency);
this.subtype = subtype;
this.filter = {
min_passband: 100,
high_cut_limit: (audioEngine.getOutputRate() / 2) - 1,
low_cut_limit: (-audioEngine.getOutputRate() / 2) + 1
getLimits: function() {
var max_bw;
if (secondary_demod === 'pocsag') {
max_bw = 12500;
} else {
max_bw = (audioEngine.getOutputRate() / 2) - 1;
}
return {
high: max_bw,
low: -max_bw
};
}
};
//Subtypes only define some filter parameters and the mod string sent to server,
//so you may set these parameters in your custom child class.
@ -417,8 +422,7 @@ function Demodulator_default_analog(offset_frequency, subtype) {
timeout_this.wait_for_timer = false;
if (timeout_this.set_after) timeout_this.set();
}, demodulator_response_time);
}
else {
} else {
this.set_after = true;
}
};
@ -431,6 +435,7 @@ function Demodulator_default_analog(offset_frequency, subtype) {
};
if (first_time) params.mod = this.server_mod;
ws.send(JSON.stringify({"type": "dspcontrol", "params": params}));
mkenvelopes(get_visible_freq_range());
};
this.doset(true); //we set parameters on object creation
@ -476,7 +481,7 @@ function Demodulator_default_analog(offset_frequency, subtype) {
//frequency.
if (this.dragged_range === dr.beginning || this.dragged_range === dr.bfo || this.dragged_range === dr.pbs) {
//we don't let low_cut go beyond its limits
if ((new_value = this.drag_origin.low_cut + minus * freq_change) < this.parent.filter.low_cut_limit) return true;
if ((new_value = this.drag_origin.low_cut + minus * freq_change) < this.parent.filter.getLimits().low) return true;
//nor the filter passband be too small
if (this.parent.high_cut - new_value < this.parent.filter.min_passband) return true;
//sanity check to prevent GNU Radio "firdes check failed: fa <= fb"
@ -485,7 +490,7 @@ function Demodulator_default_analog(offset_frequency, subtype) {
}
if (this.dragged_range === dr.ending || this.dragged_range === dr.bfo || this.dragged_range === dr.pbs) {
//we don't let high_cut go beyond its limits
if ((new_value = this.drag_origin.high_cut + minus * freq_change) > this.parent.filter.high_cut_limit) return true;
if ((new_value = this.drag_origin.high_cut + minus * freq_change) > this.parent.filter.getLimits().high) return true;
//nor the filter passband be too small
if (new_value - this.parent.low_cut < this.parent.filter.min_passband) return true;
//sanity check to prevent GNU Radio "firdes check failed: fa <= fb"
@ -502,7 +507,7 @@ function Demodulator_default_analog(offset_frequency, subtype) {
mkenvelopes(this.visible_range);
this.parent.set();
//will have to change this when changing to multi-demodulator mode:
e("webrx-actual-freq").innerHTML = format_frequency("{x} MHz", center_freq + this.parent.offset_frequency, 1e6, 4);
tunedFrequencyDisplay.setFrequency(center_freq + this.parent.offset_frequency);
return true;
};
@ -544,23 +549,31 @@ function demodulator_analog_replace(subtype, for_digital) { //this function shou
secondary_demod_close_window();
secondary_demod_listbox_update();
}
last_analog_demodulator_subtype = subtype;
var temp_offset = 0;
if (demodulators.length) {
temp_offset = demodulators[0].offset_frequency;
demodulator_remove(0);
if (!demodulators || !demodulators[0] || demodulators[0].subtype !== subtype) {
last_analog_demodulator_subtype = subtype;
var temp_offset = 0;
if (demodulators.length) {
temp_offset = demodulators[0].offset_frequency;
demodulator_remove(0);
}
demodulator_add(new Demodulator_default_analog(temp_offset, subtype));
}
demodulator_add(new Demodulator_default_analog(temp_offset, subtype));
demodulator_buttons_update();
update_digitalvoice_panels("openwebrx-panel-metadata-" + subtype);
updateHash();
}
function demodulator_set_offset_frequency(which, to_what) {
Demodulator.prototype.set_offset_frequency = function(to_what) {
if (to_what > bandwidth / 2 || to_what < -bandwidth / 2) return;
demodulators[0].offset_frequency = Math.round(to_what);
demodulators[0].set();
this.offset_frequency = Math.round(to_what);
this.set();
mkenvelopes(get_visible_freq_range());
$("#webrx-actual-freq").html(format_frequency("{x} MHz", center_freq + to_what, 1e6, 4));
tunedFrequencyDisplay.setFrequency(center_freq + to_what);
updateHash();
}
Demodulator.prototype.get_offset_frequency = function() {
return this.offset_frequency;
}
function waterfallWidth() {
@ -574,9 +587,11 @@ function waterfallWidth() {
var scale_ctx;
var scale_canvas;
var tunedFrequencyDisplay;
var mouseFrequencyDisplay;
function scale_setup() {
e("webrx-actual-freq").innerHTML = format_frequency("{x} MHz", canvas_get_frequency(window.innerWidth / 2), 1e6, 4);
tunedFrequencyDisplay.setFrequency(canvas_get_frequency(window.innerWidth / 2));
scale_canvas = e("openwebrx-scale-canvas");
scale_ctx = scale_canvas.getContext("2d");
scale_canvas.addEventListener("mousedown", scale_canvas_mousedown, false);
@ -623,14 +638,14 @@ function scale_canvas_mousemove(evt) {
else if (scale_canvas_drag_params.drag) {
//call the drag_move for all demodulators (and they will decide if they're dragged)
for (i = 0; i < demodulators.length; i++) event_handled |= demodulators[i].envelope.drag_move(evt.pageX);
if (!event_handled) demodulator_set_offset_frequency(0, scale_offset_freq_from_px(evt.pageX));
if (!event_handled) demodulators[0].set_offset_frequency(scale_offset_freq_from_px(evt.pageX));
}
}
function frequency_container_mousemove(evt) {
var frequency = center_freq + scale_offset_freq_from_px(evt.pageX);
e("webrx-mouse-freq").innerHTML = format_frequency("{x} MHz", frequency, 1e6, 4);
mouseFrequencyDisplay.setFrequency(frequency);
}
function scale_canvas_end_drag(x) {
@ -639,7 +654,7 @@ function scale_canvas_end_drag(x) {
scale_canvas_drag_params.mouse_down = false;
var event_handled = false;
for (var i = 0; i < demodulators.length; i++) event_handled |= demodulators[i].envelope.drag_end();
if (!event_handled) demodulator_set_offset_frequency(0, scale_offset_freq_from_px(x));
if (!event_handled) demodulators[0].set_offset_frequency(scale_offset_freq_from_px(x));
}
function scale_canvas_mouseup(evt) {
@ -906,8 +921,9 @@ function canvas_mousemove(evt) {
mkscale();
bookmarks.position();
}
} else {
mouseFrequencyDisplay.setFrequency(canvas_get_frequency(relativeX));
}
else e("webrx-mouse-freq").innerHTML = format_frequency("{x} MHz", canvas_get_frequency(relativeX), 1e6, 4);
}
function canvas_container_mouseleave() {
@ -919,7 +935,7 @@ function canvas_mouseup(evt) {
var relativeX = get_relative_x(evt);
if (!canvas_drag) {
demodulator_set_offset_frequency(0, canvas_get_freq_offset(relativeX));
demodulators[0].set_offset_frequency(canvas_get_freq_offset(relativeX));
}
else {
canvas_end_drag();
@ -1042,8 +1058,11 @@ function on_ws_recv(evt) {
waterfall_auto_level_margin = config['waterfall_auto_level_margin'];
waterfallColorsDefault();
starting_mod = config['start_mod'];
starting_offset_frequency = config['start_offset_freq'];
var initial_demodulator_params = {
mod: config['start_mod'],
offset_frequency: config['start_offset_freq']
};
bandwidth = config['samp_rate'];
center_freq = config['center_freq'];
fft_size = config['fft_size'];
@ -1054,15 +1073,12 @@ function on_ws_recv(evt) {
fft_compression = config['fft_compression'];
divlog("FFT stream is " + ((fft_compression === "adpcm") ? "compressed" : "uncompressed") + ".");
clientProgressBar.setMaxClients(config['max_clients']);
mathbox_waterfall_colors = config['mathbox_waterfall_colors'];
mathbox_waterfall_frequency_resolution = config['mathbox_waterfall_frequency_resolution'];
mathbox_waterfall_history_length = config['mathbox_waterfall_history_length'];
var sql = Number.isInteger(config['initial_squelch_level']) ? config['initial_squelch_level'] : -150;
$("#openwebrx-panel-squelch").val(sql);
updateSquelch();
waterfall_init();
initialize_demodulator();
initialize_demodulator(initial_demodulator_params);
bookmarks.loadLocalBookmarks();
waterfall_clear();
@ -1108,7 +1124,7 @@ function on_ws_recv(evt) {
var features = json['value'];
for (var feature in features) {
if (features.hasOwnProperty(feature)) {
$('[data-feature="' + feature + '"')[features[feature] ? "show" : "hide"]();
$('[data-feature="' + feature + '"]')[features[feature] ? "show" : "hide"]();
}
}
break;
@ -1136,10 +1152,27 @@ function on_ws_recv(evt) {
break;
case "sdr_error":
divlog(json['value'], true);
var $overlay = $('#openwebrx-error-overlay');
$overlay.find('.errormessage').text(json['value']);
$overlay.show();
break;
case 'secondary_demod':
secondary_demod_push_data(json['value']);
break;
case 'log_message':
divlog(json['value'], true);
break;
case 'pocsag_data':
update_pocsag_panel(json['value']);
break;
case 'backoff':
divlog("Server is currently busy: " + json['reason'], true);
var $overlay = $('#openwebrx-error-overlay');
$overlay.find('.errormessage').text(json['reason']);
$overlay.show();
// set a higher reconnection timeout right away to avoid additional load
reconnect_timeout = 16000;
break;
default:
console.warn('received message of unknown type: ' + json['type']);
}
@ -1239,7 +1272,7 @@ function update_metadata(meta) {
mode = "Mode: " + meta['mode'];
source = meta['source'] || "";
if (meta['lat'] && meta['lon'] && meta['source']) {
source = "<a class=\"openwebrx-maps-pin\" href=\"/map?callsign=" + meta['source'] + "\" target=\"_blank\"></a>" + source;
source = "<a class=\"openwebrx-maps-pin\" href=\"map?callsign=" + meta['source'] + "\" target=\"_blank\"></a>" + source;
}
up = meta['up'] ? "Up: " + meta['up'] : "";
down = meta['down'] ? "Down: " + meta['down'] : "";
@ -1274,14 +1307,14 @@ function update_wsjt_panel(msg) {
if (['FT8', 'JT65', 'JT9', 'FT4'].indexOf(msg['mode']) >= 0) {
matches = linkedmsg.match(/(.*\s[A-Z0-9]+\s)([A-R]{2}[0-9]{2})$/);
if (matches && matches[2] !== 'RR73') {
linkedmsg = html_escape(matches[1]) + '<a href="/map?locator=' + matches[2] + '" target="_blank">' + matches[2] + '</a>';
linkedmsg = html_escape(matches[1]) + '<a href="map?locator=' + matches[2] + '" target="_blank">' + matches[2] + '</a>';
} else {
linkedmsg = html_escape(linkedmsg);
}
} else if (msg['mode'] === 'WSPR') {
matches = linkedmsg.match(/([A-Z0-9]*\s)([A-R]{2}[0-9]{2})(\s[0-9]+)/);
if (matches) {
linkedmsg = html_escape(matches[1]) + '<a href="/map?locator=' + matches[2] + '" target="_blank">' + matches[2] + '</a>' + html_escape(matches[3]);
linkedmsg = html_escape(matches[1]) + '<a href="map?locator=' + matches[2] + '" target="_blank">' + matches[2] + '</a>' + html_escape(matches[3]);
} else {
linkedmsg = html_escape(linkedmsg);
}
@ -1367,7 +1400,7 @@ function update_packet_panel(msg) {
'style="' + stylesToString(styles) + '"'
].join(' ');
if (msg.lat && msg.lon) {
link = '<a ' + attrs + ' href="/map?callsign=' + source + '" target="_blank">' + overlay + '</a>';
link = '<a ' + attrs + ' href="map?callsign=' + source + '" target="_blank">' + overlay + '</a>';
} else {
link = '<div ' + attrs + '>' + overlay + '</div>'
}
@ -1383,6 +1416,17 @@ function update_packet_panel(msg) {
$b.scrollTop($b[0].scrollHeight);
}
function update_pocsag_panel(msg) {
var $b = $('#openwebrx-panel-pocsag-message').find('tbody');
$b.append($(
'<tr>' +
'<td class="address">' + msg.address + '</td>' +
'<td class="message">' + msg.message + '</td>' +
'</tr>'
));
$b.scrollTop($b[0].scrollHeight);
}
function update_digitalvoice_panels(showing) {
$(".openwebrx-meta-panel").each(function (_, p) {
toggle_panel(p.id, p.id === showing);
@ -1407,6 +1451,7 @@ function waterfall_measure_minmax_do(what) {
}
function on_ws_opened() {
$('#openwebrx-error-overlay').hide();
ws.send("SERVER DE CLIENT client=openwebrx.js type=receiver");
divlog("WebSocket opened to " + ws.url);
if (!networkSpeedMeasurement) {
@ -1419,10 +1464,13 @@ function on_ws_opened() {
}
reconnect_timeout = false;
ws.send(JSON.stringify({
"type": "dspcontrol",
"action": "start",
"type": "connectionproperties",
"params": {"output_rate": audioEngine.getOutputRate()}
}));
ws.send(JSON.stringify({
"type": "dspcontrol",
"action": "start"
}));
}
var was_error = 0;
@ -1452,28 +1500,52 @@ function webrx_set_param(what, value) {
ws.send(JSON.stringify({"type": "dspcontrol", "params": params}));
}
var starting_offset_frequency;
var starting_mod;
function parseHash() {
var h;
if (h = window.location.hash) {
h.substring(1).split(",").forEach(function (x) {
var harr = x.split("=");
if (harr[0] === "mute") toggleMute();
else if (harr[0] === "mod") starting_mod = harr[1];
else if (harr[0] === "sql") {
e("openwebrx-panel-squelch").value = harr[1];
updateSquelch();
}
else if (harr[0] === "freq") {
console.log(parseInt(harr[1]));
console.log(center_freq);
starting_offset_frequency = parseInt(harr[1]) - center_freq;
}
});
if (!window.location.hash) {
return {};
}
return window.location.hash.substring(1).split(",").map(function(x) {
var harr = x.split('=');
return [harr[0], harr.slice(1).join('=')];
}).reduce(function(params, p){
params[p[0]] = p[1];
return params;
}, {});
}
function validateHash() {
var params = parseHash();
params = Object.keys(params).filter(function(key) {
if (key == 'freq') {
return Math.abs(params[key] - center_freq) < bandwidth;
}
return true;
}).reduce(function(p, key) {
p[key] = params[key];
return p;
}, {});
if (params['freq']) {
params['offset_frequency'] = params['freq'] - center_freq;
delete params['freq'];
}
return params;
}
function updateHash() {
var demod = demodulators[0];
if (!demod) return;
window.location.hash = $.map({
freq: demod.get_offset_frequency() + center_freq,
mod: demod.subtype,
secondary_mod: secondary_demod
}, function(value, key){
if (!value) return undefined;
return key + '=' + value;
}).filter(function(v) {
return !!v;
}).join(',');
}
function onAudioStart(success, apiType){
@ -1491,13 +1563,16 @@ function onAudioStart(success, apiType){
updateVolume();
}
function initialize_demodulator() {
demodulator_analog_replace(starting_mod);
if (starting_offset_frequency) {
demodulators[0].offset_frequency = starting_offset_frequency;
e("webrx-actual-freq").innerHTML = format_frequency("{x} MHz", center_freq + starting_offset_frequency, 1e6, 4);
demodulators[0].set();
mkscale();
function initialize_demodulator(initialParams) {
mkscale();
var params = $.extend(initialParams || {}, validateHash());
if (params.secondary_mod) {
demodulator_digital_replace(params.secondary_mod);
} else if (params.mod) {
demodulator_analog_replace(params.mod);
}
if (params.offset_frequency) {
demodulators[0].set_offset_frequency(params.offset_frequency);
}
}
@ -1520,19 +1595,23 @@ function on_ws_error() {
divlog("WebSocket error.", 1);
}
String.prototype.startswith = function (str) {
return this.indexOf(str) === 0;
}; //http://stackoverflow.com/questions/646628/how-to-check-if-a-string-startswith-another-string
var ws;
function open_websocket() {
var protocol = 'ws';
if (window.location.toString().startsWith('https://')) {
protocol = 'wss';
}
var protocol = window.location.protocol.match(/https/) ? 'wss' : 'ws';
var href = window.location.href;
var index = href.lastIndexOf('/');
if (index > 0) {
href = href.substr(0, index + 1);
}
href = href.split("://")[1];
href = protocol + "://" + href;
if (!href.endsWith('/')) {
href += '/';
}
var ws_url = href + "ws/";
var ws_url = protocol + "://" + (window.location.origin.split("://")[1]) + "/ws/"; //guess automatically -> now default behaviour
if (!("WebSocket" in window))
divlog("Your browser does not support WebSocket, which is required for WebRX to run. Please upgrade to a HTML5 compatible browser.");
ws = new WebSocket(ws_url);
@ -1597,7 +1676,6 @@ function add_canvas() {
function init_canvas_container() {
canvas_container = e("webrx-canvas-container");
mathbox_container = e("openwebrx-mathbox-container");
canvas_container.addEventListener("mouseleave", canvas_container_mouseleave, false);
canvas_container.addEventListener("mousemove", canvas_mousemove, false);
canvas_container.addEventListener("mouseup", canvas_mouseup, false);
@ -1635,27 +1713,6 @@ function waterfall_init() {
waterfall_setup_done = 1;
}
var mathbox_shift = function () {
if (mathbox_data_current_depth < mathbox_data_max_depth) mathbox_data_current_depth++;
if (mathbox_data_index + 1 >= mathbox_data_max_depth) mathbox_data_index = 0;
else mathbox_data_index++;
mathbox_data_global_index++;
};
var mathbox_clear_data = function () {
mathbox_data_index = 50;
mathbox_data_current_depth = 0;
};
var mathbox_get_data_line = function (x) {
return (mathbox_data_max_depth + mathbox_data_index + x - 1) % mathbox_data_max_depth;
};
var mathbox_data_index_valid = function (x) {
return x > mathbox_data_max_depth - mathbox_data_current_depth;
};
function waterfall_add(data) {
if (!waterfall_setup_done) return;
var w = fft_size;
@ -1667,26 +1724,18 @@ function waterfall_add(data) {
waterfallColorsAuto();
}
if (mathbox_mode === MATHBOX_MODES.WATERFALL) {
//Handle mathbox
for (var i = 0; i < fft_size; i++) mathbox_data[i + mathbox_data_index * fft_size] = data[i];
mathbox_shift();
} else {
//Add line to waterfall image
var oneline_image = canvas_context.createImageData(w, 1);
for (var x = 0; x < w; x++) {
var color = waterfall_mkcolor(data[x]);
for (i = 0; i < 4; i++)
oneline_image.data[x * 4 + i] = ((color >>> 0) >> ((3 - i) * 8)) & 0xff;
}
//Draw image
canvas_context.putImageData(oneline_image, 0, canvas_actual_line--);
shift_canvases();
if (canvas_actual_line < 0) add_canvas();
//Add line to waterfall image
var oneline_image = canvas_context.createImageData(w, 1);
for (var x = 0; x < w; x++) {
var color = waterfall_mkcolor(data[x]);
for (i = 0; i < 4; i++)
oneline_image.data[x * 4 + i] = ((color >>> 0) >> ((3 - i) * 8)) & 0xff;
}
//Draw image
canvas_context.putImageData(oneline_image, 0, canvas_actual_line--);
shift_canvases();
if (canvas_actual_line < 0) add_canvas();
}
function check_top_bar_congestion() {
@ -1704,167 +1753,6 @@ function check_top_bar_congestion() {
}
var MATHBOX_MODES =
{
UNINITIALIZED: 0,
NONE: 1,
WATERFALL: 2,
CONSTELLATION: 3
};
var mathbox_mode = MATHBOX_MODES.UNINITIALIZED;
var mathbox;
var mathbox_element;
var mathbox_waterfall_colors;
var mathbox_waterfall_frequency_resolution;
var mathbox_waterfall_history_length;
var mathbox_correction_for_z;
var mathbox_data_max_depth;
var mathbox_data_current_depth;
var mathbox_data_index;
var mathbox_data;
var mathbox_data_global_index;
var mathbox_container;
function mathbox_init() {
//mathbox_waterfall_history_length is defined in the config
mathbox_data_max_depth = fft_fps * mathbox_waterfall_history_length; //how many lines can the buffer store
mathbox_data_current_depth = 0; //how many lines are in the buffer currently
mathbox_data_index = 0; //the index of the last empty line / the line to be overwritten
mathbox_data = new Float32Array(fft_size * mathbox_data_max_depth);
mathbox_data_global_index = 0;
mathbox_correction_for_z = 0;
mathbox = mathBox({
plugins: ['core', 'controls', 'cursor', 'stats'],
controls: {klass: THREE.OrbitControls}
});
var three = mathbox.three;
if (typeof three === "undefined") divlog("3D waterfall cannot be initialized because WebGL is not supported in your browser.", true);
three.renderer.setClearColor(new THREE.Color(0x808080), 1.0);
mathbox_container.appendChild((mathbox_element = three.renderer.domElement));
var view = mathbox
.set({
scale: 1080,
focus: 3
})
.camera({
proxy: true,
position: [-2, 1, 3]
})
.cartesian({
range: [[-1, 1], [0, 1], [0, 1]],
scale: [2, 2 / 3, 1]
});
view.axis({
axis: 1,
width: 3,
color: "#fff"
});
view.axis({
axis: 2,
width: 3,
color: "#fff"
//offset: [0, 0, 0],
});
view.axis({
axis: 3,
width: 3,
color: "#fff"
});
view.grid({
width: 2,
opacity: 0.5,
axes: [1, 3],
zOrder: 1,
color: "#fff"
});
var remap = function (x, z, t) {
var currentTimePos = mathbox_data_global_index / (fft_fps * 1.0);
var realZAdd = (-(t - currentTimePos) / mathbox_waterfall_history_length);
var zAdd = realZAdd - mathbox_correction_for_z;
if (zAdd < -0.2 || zAdd > 0.2) {
mathbox_correction_for_z = realZAdd;
}
var xIndex = Math.trunc(((x + 1) / 2.0) * fft_size); //x: frequency
var zIndex = Math.trunc(z * (mathbox_data_max_depth - 1)); //z: time
var realZIndex = mathbox_get_data_line(zIndex);
if (!mathbox_data_index_valid(zIndex)) return {y: undefined, dBValue: undefined, zAdd: 0};
var index = Math.trunc(xIndex + realZIndex * fft_size);
var dBValue = mathbox_data[index];
var y;
if (dBValue > waterfall_max_level) y = 1;
else if (dBValue < waterfall_min_level) y = 0;
else y = (dBValue - waterfall_min_level) / (waterfall_max_level - waterfall_min_level);
if (!y) y = 0;
return {y: y, dBValue: dBValue, zAdd: zAdd};
};
view.area({
expr: function (emit, x, z, i, j, t) {
var y;
var remapResult = remap(x, z, t);
if ((y = remapResult.y) === undefined) return;
emit(x, y, z + remapResult.zAdd);
},
width: mathbox_waterfall_frequency_resolution,
height: mathbox_data_max_depth - 1,
channels: 3,
axes: [1, 3]
});
view.area({
expr: function (emit, x, z, i, j, t) {
var dBValue;
if ((dBValue = remap(x, z, t).dBValue) === undefined) return;
var color = waterfall_mkcolor(dBValue, mathbox_waterfall_colors);
var b = (color & 0xff) / 255.0;
var g = ((color & 0xff00) >> 8) / 255.0;
var r = ((color & 0xff0000) >> 16) / 255.0;
emit(r, g, b, 1.0);
},
width: mathbox_waterfall_frequency_resolution,
height: mathbox_data_max_depth - 1,
channels: 4,
axes: [1, 3]
});
view.surface({
shaded: true,
points: '<<',
colors: '<',
color: 0xFFFFFF
});
view.surface({
fill: false,
lineX: false,
lineY: false,
points: '<<',
colors: '<',
color: 0xFFFFFF,
width: 2,
blending: 'add',
opacity: .25,
zBias: 5
});
mathbox_mode = MATHBOX_MODES.NONE;
}
function mathbox_toggle() {
if (mathbox_mode === MATHBOX_MODES.UNINITIALIZED) mathbox_init();
mathbox_mode = (mathbox_mode === MATHBOX_MODES.NONE) ? MATHBOX_MODES.WATERFALL : MATHBOX_MODES.NONE;
mathbox_container.style.display = (mathbox_mode === MATHBOX_MODES.WATERFALL) ? "block" : "none";
mathbox_clear_data();
waterfall_clear();
}
function waterfall_clear() {
while (canvases.length) //delete all canvases
{
@ -1928,18 +1816,26 @@ function openwebrx_init() {
} else {
audioEngine.start(onAudioStart);
}
fft_codec = new ImaAdpcmCodec();
initProgressBars();
init_rx_photo();
open_websocket();
secondary_demod_init();
digimodes_init();
initPanels();
tunedFrequencyDisplay = new TuneableFrequencyDisplay($('#webrx-actual-freq'));
tunedFrequencyDisplay.onFrequencyChange(function(f) {
demodulators[0].set_offset_frequency(f - center_freq);
});
mouseFrequencyDisplay = new FrequencyDisplay($('#webrx-mouse-freq'));
window.addEventListener("resize", openwebrx_resize);
check_top_bar_congestion();
init_header();
bookmarks = new BookmarkBar();
parseHash();
initSliders();
window.addEventListener('hashchange', function() {
initialize_demodulator();
});
}
function initSliders() {
@ -2064,6 +1960,7 @@ function initPanels() {
function demodulator_buttons_update() {
$(".openwebrx-demodulator-button").removeClass("highlighted");
if (!demodulators.length) return;
if (secondary_demod) {
$("#openwebrx-button-dig").addClass("highlighted");
$('#openwebrx-secondary-demod-listbox').val(secondary_demod);
@ -2126,8 +2023,10 @@ function demodulator_digital_replace_last() {
}
function demodulator_digital_replace(subtype) {
if (secondary_demod === subtype) return;
switch (subtype) {
case "bpsk31":
case "bpsk63":
case "rtty":
case "ft8":
case "jt65":
@ -2148,12 +2047,21 @@ function demodulator_digital_replace(subtype) {
secondary_demod_start(subtype);
demodulator_analog_replace('nfm', true);
break;
case "pocsag":
secondary_demod_start(subtype);
demodulator_analog_replace('nfm', true);
demodulators[0].low_cut = -6000;
demodulators[0].high_cut = 6000;
demodulators[0].set();
break;
}
demodulator_buttons_update();
$('#openwebrx-panel-digimodes').attr('data-mode', subtype);
toggle_panel("openwebrx-panel-digimodes", true);
toggle_panel("openwebrx-panel-wsjt-message", ['ft8', 'wspr', 'jt65', 'jt9', 'ft4'].indexOf(subtype) >= 0);
toggle_panel("openwebrx-panel-packet-message", subtype === "packet");
toggle_panel("openwebrx-panel-pocsag-message", subtype === "pocsag");
updateHash();
}
function secondary_demod_create_canvas() {
@ -2243,6 +2151,7 @@ function secondary_demod_close_window() {
toggle_panel("openwebrx-panel-digimodes", false);
toggle_panel("openwebrx-panel-wsjt-message", false);
toggle_panel("openwebrx-panel-packet-message", false);
toggle_panel("openwebrx-panel-pocsag-message", false);
}
function secondary_demod_waterfall_add(data) {

File diff suppressed because one or more lines are too long

15
manifest.sh Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -euxo pipefail
. docker/env
for image in ${IMAGES}; do
# there's no docker manifest rm command, and the create --amend does not work, so we have to clean up manually
rm -rf "${HOME}/.docker/manifests/docker.io_jketterl_${image}-${TAG}"
IMAGE_LIST=""
for a in $ALL_ARCHS; do
IMAGE_LIST="$IMAGE_LIST jketterl/$image:$TAG-$a"
done
docker manifest create jketterl/$image:$TAG $IMAGE_LIST
docker manifest push --purge jketterl/$image:$TAG
docker pull jketterl/$image:$TAG
done

View File

@ -1,66 +1,6 @@
#!/usr/bin/env python3
from http.server import HTTPServer
from owrx.http import RequestHandler
from owrx.config import PropertyManager
from owrx.feature import FeatureDetector
from owrx.source import SdrService
from socketserver import ThreadingMixIn
from owrx.sdrhu import SdrHuUpdater
from owrx.service import Services
from owrx.websocket import WebSocketConnection
from owrx.pskreporter import PskReporter
import logging
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
class ThreadedHttpServer(ThreadingMixIn, HTTPServer):
pass
def main():
print(
"""
OpenWebRX - Open Source SDR Web App for Everyone! | for license see LICENSE file in the package
_________________________________________________________________________________________________
Author contact info: Andras Retzler, HA7ILM <randras@sdr.hu>
Author contact info: Jakob Ketterl, DD5JFK <dd5jfk@darc.de>
"""
)
pm = PropertyManager.getSharedInstance().loadConfig("config_webrx")
featureDetector = FeatureDetector()
if not featureDetector.is_available("core"):
print(
"you are missing required dependencies to run openwebrx. "
"please check that the following core requirements are installed:"
)
print(", ".join(featureDetector.get_requirements("core")))
return
# Get error messages about unknown / unavailable features as soon as possible
SdrService.loadProps()
if "sdrhu_key" in pm and pm["sdrhu_public_listing"]:
updater = SdrHuUpdater()
updater.start()
Services.start()
server = ThreadedHttpServer(("0.0.0.0", pm.getPropertyValue("web_port")), RequestHandler)
server.serve_forever()
from owrx.__main__ import main
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
WebSocketConnection.closeAll()
Services.stop()
PskReporter.stop()
main()

59
owrx/__main__.py Normal file
View File

@ -0,0 +1,59 @@
from http.server import HTTPServer
from owrx.http import RequestHandler
from owrx.config import PropertyManager
from owrx.feature import FeatureDetector
from owrx.sdr import SdrService
from socketserver import ThreadingMixIn
from owrx.sdrhu import SdrHuUpdater
from owrx.service import Services
from owrx.websocket import WebSocketConnection
from owrx.pskreporter import PskReporter
import logging
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
class ThreadedHttpServer(ThreadingMixIn, HTTPServer):
pass
def main():
print(
"""
OpenWebRX - Open Source SDR Web App for Everyone! | for license see LICENSE file in the package
_________________________________________________________________________________________________
Author contact info: Jakob Ketterl, DD5JFK <dd5jfk@darc.de>
"""
)
pm = PropertyManager.getSharedInstance().loadConfig()
featureDetector = FeatureDetector()
if not featureDetector.is_available("core"):
print(
"you are missing required dependencies to run openwebrx. "
"please check that the following core requirements are installed:"
)
print(", ".join(featureDetector.get_requirements("core")))
return
# Get error messages about unknown / unavailable features as soon as possible
SdrService.loadProps()
if "sdrhu_key" in pm and pm["sdrhu_public_listing"]:
updater = SdrHuUpdater()
updater.start()
Services.start()
try:
server = ThreadedHttpServer(("0.0.0.0", pm.getPropertyValue("web_port")), RequestHandler)
server.serve_forever()
except KeyboardInterrupt:
WebSocketConnection.closeAll()
Services.stop()
PskReporter.stop()

View File

@ -2,6 +2,7 @@ from owrx.kiss import KissDeframer
from owrx.map import Map, LatLngLocation
from owrx.bands import Bandplan
from owrx.metrics import Metrics, CounterMetric
from owrx.parser import Parser
from datetime import datetime, timezone
import re
import logging
@ -148,18 +149,15 @@ class AprsLocation(LatLngLocation):
return res
class AprsParser(object):
class AprsParser(Parser):
def __init__(self, handler):
super().__init__(handler)
self.ax25parser = Ax25Parser()
self.deframer = KissDeframer()
self.dial_freq = None
self.band = None
self.handler = handler
self.metric = self.getMetric()
def setDialFrequency(self, freq):
self.dial_freq = freq
self.band = Bandplan.getSharedInstance().findBand(freq)
super().setDialFrequency(freq)
self.metric = self.getMetric()
def getMetric(self):

View File

@ -46,10 +46,24 @@ class Bandplan(object):
return Bandplan.sharedInstance
def __init__(self):
f = open("bands.json", "r")
bands_json = json.load(f)
f.close()
self.bands = [Band(d) for d in bands_json]
self.bands = self.loadBands()
def loadBands(self):
for file in ["/etc/openwebrx/bands.json", "bands.json"]:
try:
f = open(file, "r")
bands_json = json.load(f)
f.close()
return [Band(d) for d in bands_json]
except FileNotFoundError:
pass
except json.JSONDecodeError:
logger.exception("error while parsing bandplan file %s", file)
return []
except Exception:
logger.exception("error while processing bandplan from %s", file)
return []
return []
def findBands(self, freq):
return [band for band in self.bands if band.inBand(freq)]

View File

@ -1,5 +1,9 @@
import json
import logging
logger = logging.getLogger(__name__)
class Bookmark(object):
def __init__(self, j):
@ -34,10 +38,24 @@ class Bookmarks(object):
return Bookmarks.sharedInstance
def __init__(self):
f = open("bookmarks.json", "r")
bookmarks_json = json.load(f)
f.close()
self.bookmarks = [Bookmark(d) for d in bookmarks_json]
self.bookmarks = self.loadBookmarks()
def loadBookmarks(self):
for file in ["/etc/openwebrx/bookmarks.json", "bookmarks.json"]:
try:
f = open(file, "r")
bookmarks_json = json.load(f)
f.close()
return [Bookmark(d) for d in bookmarks_json]
except FileNotFoundError:
pass
except json.JSONDecodeError:
logger.exception("error while parsing bookmarks file %s", file)
return []
except Exception:
logger.exception("error while processing bookmarks from %s", file)
return []
return []
def getBookmarks(self, range):
(lo, hi) = range

50
owrx/client.py Normal file
View File

@ -0,0 +1,50 @@
from owrx.config import PropertyManager
from owrx.metrics import Metrics, DirectMetric
import threading
import logging
logger = logging.getLogger(__name__)
class TooManyClientsException(Exception):
pass
class ClientRegistry(object):
sharedInstance = None
creationLock = threading.Lock()
@staticmethod
def getSharedInstance():
with ClientRegistry.creationLock:
if ClientRegistry.sharedInstance is None:
ClientRegistry.sharedInstance = ClientRegistry()
return ClientRegistry.sharedInstance
def __init__(self):
self.clients = []
Metrics.getSharedInstance().addMetric("openwebrx.users", DirectMetric(self.clientCount))
super().__init__()
def broadcast(self):
n = self.clientCount()
for c in self.clients:
c.write_clients(n)
def addClient(self, client):
pm = PropertyManager.getSharedInstance()
if len(self.clients) >= pm["max_clients"]:
raise TooManyClientsException()
self.clients.append(client)
self.broadcast()
def clientCount(self):
return len(self.clients)
def removeClient(self, client):
try:
self.clients.remove(client)
except ValueError:
pass
self.broadcast()

71
owrx/command.py Normal file
View File

@ -0,0 +1,71 @@
from abc import ABC, abstractmethod
class CommandMapper(object):
def __init__(self, base=None, mappings=None, static=None):
self.base = base
self.mappings = {} if mappings is None else mappings
self.static = static
def map(self, values):
args = [self.mappings[k].map(v) for k, v in values.items() if k in self.mappings]
args = [a for a in args if a != ""]
options = " ".join(args)
command = "{0} {1}".format(self.base, options)
if self.static is not None:
command += " " + self.static
return command
def setMapping(self, key, mapping):
self.mappings[key] = mapping
return self
def setMappings(self, mappings):
for k, v in mappings.items():
self.setMapping(k, v)
return self
def setBase(self, base):
self.base = base
return self
def setStatic(self, static):
self.static = static
return self
class CommandMapping(ABC):
@abstractmethod
def map(self, value):
pass
class Flag(CommandMapping):
def __init__(self, flag):
self.flag = flag
def map(self, value):
if value is not None and value:
return self.flag
else:
return ""
class Option(CommandMapping):
def __init__(self, option):
self.option = option
self.spacer = " "
def map(self, value):
if value is not None:
if isinstance(value, str) and " " in value:
template = '{option}{spacer}"{value}"'
else:
template = "{option}{spacer}{value}"
return template.format(option=self.option, spacer=self.spacer, value=value)
else:
return ""
def setSpacer(self, spacer):
self.spacer = spacer
return self

View File

@ -1,3 +1,4 @@
import importlib.util
import logging
logger = logging.getLogger(__name__)
@ -50,6 +51,10 @@ class Property(object):
return self
class ConfigNotFoundException(Exception):
pass
class PropertyManager(object):
sharedInstance = None
@ -128,10 +133,17 @@ class PropertyManager(object):
p.setValue(other_pm[key])
return self
def loadConfig(self, filename):
cfg = __import__(filename)
for name, value in cfg.__dict__.items():
if name.startswith("__"):
continue
self[name] = value
return self
def loadConfig(self):
for file in ["/etc/openwebrx/config_webrx.py", "./config_webrx.py"]:
try:
spec = importlib.util.spec_from_file_location("config_webrx", file)
cfg = importlib.util.module_from_spec(spec)
spec.loader.exec_module(cfg)
for name, value in cfg.__dict__.items():
if name.startswith("__"):
continue
self[name] = value
return self
except FileNotFoundError:
pass
raise ConfigNotFoundException("no usable config found! please make sure you have a valid configuration file!")

View File

@ -1,5 +1,9 @@
from owrx.config import PropertyManager
from owrx.source import DspManager, CpuUsageThread, SdrService, ClientRegistry
from owrx.dsp import DspManager
from owrx.cpu import CpuUsageThread
from owrx.sdr import SdrService
from owrx.source import SdrSource
from owrx.client import ClientRegistry, TooManyClientsException
from owrx.feature import FeatureDetector
from owrx.version import openwebrx_version
from owrx.bands import Bandplan
@ -7,6 +11,7 @@ from owrx.bookmarks import Bookmarks
from owrx.map import Map
from owrx.locator import Locator
from multiprocessing import Queue
from queue import Full
import json
import threading
@ -18,7 +23,7 @@ logger = logging.getLogger(__name__)
class Client(object):
def __init__(self, conn):
self.conn = conn
self.multiprocessingPipe = Queue()
self.multiprocessingPipe = Queue(100)
def mp_passthru():
run = True
@ -39,7 +44,10 @@ class Client(object):
self.multiprocessingPipe.close()
def mp_send(self, data):
self.multiprocessingPipe.put(data, block=False)
try:
self.multiprocessingPipe.put(data, block=False)
except Full:
self.close()
def handleTextMessage(self, conn, message):
pass
@ -66,9 +74,6 @@ class OpenWebRxReceiverClient(Client):
"start_mod",
"start_freq",
"center_freq",
"mathbox_waterfall_colors",
"mathbox_waterfall_history_length",
"mathbox_waterfall_frequency_resolution",
"initial_squelch_level",
"profile_id",
]
@ -79,8 +84,14 @@ class OpenWebRxReceiverClient(Client):
self.dsp = None
self.sdr = None
self.configSub = None
self.connectionProperties = {}
ClientRegistry.getSharedInstance().addClient(self)
try:
ClientRegistry.getSharedInstance().addClient(self)
except TooManyClientsException:
self.write_backoff_message("Too many clients")
self.close()
raise
pm = PropertyManager.getSharedInstance()
@ -99,6 +110,14 @@ class OpenWebRxReceiverClient(Client):
receiver_details["locator"] = Locator.fromCoordinates(receiver_details["receiver_gps"])
self.write_receiver_details(receiver_details)
self.__sendProfiles()
features = FeatureDetector().feature_availability()
self.write_features(features)
CpuUsageThread.getSharedInstance().add_client(self)
def __sendProfiles(self):
profiles = [
{"name": s.getName() + " " + p["name"], "id": sid + "|" + pid}
for (sid, s) in SdrService.getSources().items()
@ -106,11 +125,6 @@ class OpenWebRxReceiverClient(Client):
]
self.write_profiles(profiles)
features = FeatureDetector().feature_availability()
self.write_features(features)
CpuUsageThread.getSharedInstance().add_client(self)
def handleTextMessage(self, conn, message):
try:
message = json.loads(message)
@ -123,17 +137,23 @@ class OpenWebRxReceiverClient(Client):
params = message["params"]
self.setDspProperties(params)
if message["type"] == "config":
elif message["type"] == "config":
if "params" in message:
self.setParams(message["params"])
if message["type"] == "setsdr":
elif message["type"] == "setsdr":
if "params" in message:
self.setSdr(message["params"]["sdr"])
if message["type"] == "selectprofile":
elif message["type"] == "selectprofile":
if "params" in message and "profile" in message["params"]:
profile = message["params"]["profile"].split("|")
self.setSdr(profile[0])
self.sdr.activateProfile(profile[1])
elif message["type"] == "connectionproperties":
if "params" in message:
self.connectionProperties = message["params"]
if self.dsp:
self.setDspProperties(self.connectionProperties)
else:
logger.warning("received message without type: {0}".format(message))
@ -141,26 +161,40 @@ class OpenWebRxReceiverClient(Client):
logger.warning("message is not json: {0}".format(message))
def setSdr(self, id=None):
next = SdrService.getSource(id)
while True:
next = None
if id is not None:
next = SdrService.getSource(id)
if next is None:
next = SdrService.getFirstSource()
if next is None:
# exit condition: no sdrs available
self.handleNoSdrsAvailable()
return
if next is None:
self.handleSdrFailure("sdr device failed")
return
# exit condition: no change
if next == self.sdr:
return
if next == self.sdr:
return
self.stopDsp()
self.stopDsp()
if self.configSub is not None:
self.configSub.cancel()
self.configSub = None
if self.configSub is not None:
self.configSub.cancel()
self.configSub = None
self.sdr = next
self.sdr = next
self.startDsp()
self.startDsp()
# keep trying until we find a suitable SDR
if self.sdr.getState() == SdrSource.STATE_FAILED:
self.write_log_message('SDR device "{0}" has failed, selecting new device'.format(self.sdr.getName()))
else:
break
# send initial config
self.setDspProperties(self.connectionProperties)
configProps = (
self.sdr.getProps()
.collect(*OpenWebRxReceiverClient.config_keys)
@ -184,14 +218,15 @@ class OpenWebRxReceiverClient(Client):
self.configSub = configProps.wire(sendConfig)
sendConfig(None, None)
self.__sendProfiles()
self.sdr.addSpectrumClient(self)
def handleSdrFailure(self, message):
self.write_sdr_error(message)
def handleNoSdrsAvailable(self):
self.write_sdr_error("No SDR Devices available")
def startDsp(self):
if self.dsp is None:
if self.dsp is None and self.sdr is not None:
self.dsp = DspManager(self, self.sdr)
self.dsp.start()
@ -212,10 +247,14 @@ class OpenWebRxReceiverClient(Client):
self.sdr.removeSpectrumClient(self)
def setParams(self, params):
# allow direct configuration only if enabled in the config
keys = PropertyManager.getSharedInstance()["configurable_keys"]
if not keys:
return
# only the keys in the protected property manager can be overridden from the web
protected = (
self.sdr.getProps()
.collect("samp_rate", "center_freq", "rf_gain", "type", "if_gain")
.collect(*keys)
.defaults(PropertyManager.getSharedInstance())
)
for key, value in params.items():
@ -244,7 +283,7 @@ class OpenWebRxReceiverClient(Client):
self.send(bytes([0x03]) + data)
def write_secondary_demod(self, data):
message = data.decode("ascii")
message = data.decode("ascii", "replace")
self.send({"type": "secondary_demod", "value": message})
def write_secondary_dsp_config(self, cfg):
@ -277,9 +316,18 @@ class OpenWebRxReceiverClient(Client):
def write_aprs_data(self, data):
self.send({"type": "aprs_data", "value": data})
def write_log_message(self, message):
self.send({"type": "log_message", "value": message})
def write_sdr_error(self, message):
self.send({"type": "sdr_error", "value": message})
def write_pocsag_data(self, data):
self.send({"type": "pocsag_data", "value": data})
def write_backoff_message(self, reason):
self.send({"type": "backoff", "reason": reason})
class MapConnection(Client):
def __init__(self, conn):

View File

@ -1,22 +1,25 @@
import os
import mimetypes
import json
import pkg_resources
from datetime import datetime
from string import Template
from owrx.websocket import WebSocketConnection
from owrx.config import PropertyManager
from owrx.source import ClientRegistry
from owrx.client import ClientRegistry
from owrx.connection import WebSocketMessageHandler
from owrx.version import openwebrx_version
from owrx.feature import FeatureDetector
from owrx.metrics import Metrics
from owrx.sdr import SdrService
from abc import ABC, abstractmethod
import logging
logger = logging.getLogger(__name__)
class Controller(object):
class Controller(ABC):
def __init__(self, handler, request):
self.handler = handler
self.request = request
@ -34,6 +37,10 @@ class Controller(object):
content = content.encode()
self.handler.wfile.write(content)
@abstractmethod
def handle_request(self):
pass
class StatusController(Controller):
def handle_request(self):
@ -54,18 +61,54 @@ class StatusController(Controller):
self.send_response("\n".join(["{key}={value}".format(key=key, value=value) for key, value in vars.items()]))
class StatusJsonController(Controller):
def getProfileStats(self, profile):
return {
"name": profile["name"],
"center_freq": profile["center_freq"],
"sample_rate": profile["samp_rate"],
}
def getReceiverStats(self, receiver):
stats = {
"name": receiver.getName(),
# TODO would be better to have types from the config here
"type": type(receiver).__name__,
"profiles": [self.getProfileStats(p) for p in receiver.getProfiles().values()]
}
return stats
def handle_request(self):
pm = PropertyManager.getSharedInstance()
gps = pm["receiver_gps"]
status = {
"receiver": {
"name": pm["receiver_name"],
"admin": pm["receiver_admin"],
"gps": {"lat": gps[0], "lon": gps[1]},
"asl": pm["receiver_asl"],
"location": pm["receiver_location"],
},
"max_clients": pm["max_clients"],
"version": openwebrx_version,
"sdrs": [self.getReceiverStats(r) for r in SdrService.getSources().values()]
}
self.send_response(json.dumps(status), content_type="application/json")
class AssetsController(Controller):
def __init__(self, handler, request, path):
if not path.endswith("/"):
path += "/"
self.path = path
super().__init__(handler, request)
def getModified(self, file):
return None
def openFile(self, file):
pass
def serve_file(self, file, content_type=None):
try:
modified = datetime.fromtimestamp(os.path.getmtime(self.path + file))
modified = self.getModified(file)
if "If-Modified-Since" in self.handler.headers:
if modified is not None and "If-Modified-Since" in self.handler.headers:
client_modified = datetime.strptime(
self.handler.headers["If-Modified-Since"], "%a, %d %b %Y %H:%M:%S %Z"
)
@ -73,7 +116,7 @@ class AssetsController(Controller):
self.send_response("", code=304)
return
f = open(self.path + file, "rb")
f = self.openFile(file)
data = f.read()
f.close()
@ -89,21 +132,33 @@ class AssetsController(Controller):
class OwrxAssetsController(AssetsController):
def __init__(self, handler, request):
super().__init__(handler, request, "htdocs/")
def openFile(self, file):
return pkg_resources.resource_stream("htdocs", file)
class AprsSymbolsController(AssetsController):
def __init__(self, handler, request):
pm = PropertyManager.getSharedInstance()
super().__init__(handler, request, pm["aprs_symbols_path"])
path = pm["aprs_symbols_path"]
if not path.endswith("/"):
path += "/"
self.path = path
super().__init__(handler, request)
def getFilePath(self, file):
return self.path + file
def getModified(self, file):
return datetime.fromtimestamp(os.path.getmtime(self.getFilePath(file)))
def openFile(self, file):
return open(self.getFilePath(file), "rb")
class TemplateController(Controller):
def render_template(self, file, **vars):
f = open("htdocs/" + file, "r", encoding="utf-8")
template = Template(f.read())
f.close()
file_content = pkg_resources.resource_string("htdocs", file).decode("utf-8")
template = Template(file_content)
return template.safe_substitute(**vars)

73
owrx/cpu.py Normal file
View File

@ -0,0 +1,73 @@
import threading
import logging
logger = logging.getLogger(__name__)
class CpuUsageThread(threading.Thread):
sharedInstance = None
@staticmethod
def getSharedInstance():
if CpuUsageThread.sharedInstance is None:
CpuUsageThread.sharedInstance = CpuUsageThread()
return CpuUsageThread.sharedInstance
def __init__(self):
self.clients = []
self.doRun = True
self.last_worktime = 0
self.last_idletime = 0
self.endEvent = threading.Event()
super().__init__()
def run(self):
while self.doRun:
try:
cpu_usage = self.get_cpu_usage()
except:
cpu_usage = 0
for c in self.clients:
c.write_cpu_usage(cpu_usage)
self.endEvent.wait(timeout=3)
logger.debug("cpu usage thread shut down")
def get_cpu_usage(self):
try:
f = open("/proc/stat", "r")
except:
return 0 # Workaround, possibly we're on a Mac
line = ""
while not "cpu " in line:
line = f.readline()
f.close()
spl = line.split(" ")
worktime = int(spl[2]) + int(spl[3]) + int(spl[4])
idletime = int(spl[5])
dworktime = worktime - self.last_worktime
didletime = idletime - self.last_idletime
rate = float(dworktime) / (didletime + dworktime)
self.last_worktime = worktime
self.last_idletime = idletime
if self.last_worktime == 0:
return 0
return rate
def add_client(self, c):
self.clients.append(c)
if not self.is_alive():
self.start()
def remove_client(self, c):
try:
self.clients.remove(c)
except ValueError:
pass
if not self.clients:
self.shutdown()
def shutdown(self):
CpuUsageThread.sharedInstance = None
self.doRun = False
self.endEvent.set()

154
owrx/dsp.py Normal file
View File

@ -0,0 +1,154 @@
from owrx.config import PropertyManager
from owrx.meta import MetaParser
from owrx.wsjt import WsjtParser
from owrx.aprs import AprsParser
from owrx.pocsag import PocsagParser
from owrx.source import SdrSource
from csdr import csdr
import threading
import logging
logger = logging.getLogger(__name__)
class DspManager(csdr.output):
def __init__(self, handler, sdrSource):
self.handler = handler
self.sdrSource = sdrSource
self.parsers = {
"meta": MetaParser(self.handler),
"wsjt_demod": WsjtParser(self.handler),
"packet_demod": AprsParser(self.handler),
"pocsag_demod": PocsagParser(self.handler),
}
self.localProps = (
self.sdrSource.getProps()
.collect(
"audio_compression",
"fft_compression",
"digimodes_fft_size",
"csdr_dynamic_bufsize",
"csdr_print_bufsizes",
"csdr_through",
"digimodes_enable",
"samp_rate",
"digital_voice_unvoiced_quality",
"dmr_filter",
"temporary_directory",
"center_freq",
)
.defaults(PropertyManager.getSharedInstance())
)
self.dsp = csdr.dsp(self)
self.dsp.nc_port = self.sdrSource.getPort()
def set_low_cut(cut):
bpf = self.dsp.get_bpf()
bpf[0] = cut
self.dsp.set_bpf(*bpf)
def set_high_cut(cut):
bpf = self.dsp.get_bpf()
bpf[1] = cut
self.dsp.set_bpf(*bpf)
def set_dial_freq(key, value):
freq = self.localProps["center_freq"] + self.localProps["offset_freq"]
for parser in self.parsers.values():
parser.setDialFrequency(freq)
self.subscriptions = [
self.localProps.getProperty("audio_compression").wire(self.dsp.set_audio_compression),
self.localProps.getProperty("fft_compression").wire(self.dsp.set_fft_compression),
self.localProps.getProperty("digimodes_fft_size").wire(self.dsp.set_secondary_fft_size),
self.localProps.getProperty("samp_rate").wire(self.dsp.set_samp_rate),
self.localProps.getProperty("output_rate").wire(self.dsp.set_output_rate),
self.localProps.getProperty("offset_freq").wire(self.dsp.set_offset_freq),
self.localProps.getProperty("squelch_level").wire(self.dsp.set_squelch_level),
self.localProps.getProperty("low_cut").wire(set_low_cut),
self.localProps.getProperty("high_cut").wire(set_high_cut),
self.localProps.getProperty("mod").wire(self.dsp.set_demodulator),
self.localProps.getProperty("digital_voice_unvoiced_quality").wire(self.dsp.set_unvoiced_quality),
self.localProps.getProperty("dmr_filter").wire(self.dsp.set_dmr_filter),
self.localProps.getProperty("temporary_directory").wire(self.dsp.set_temporary_directory),
self.localProps.collect("center_freq", "offset_freq").wire(set_dial_freq),
]
self.dsp.set_offset_freq(0)
self.dsp.set_bpf(-4000, 4000)
self.dsp.csdr_dynamic_bufsize = self.localProps["csdr_dynamic_bufsize"]
self.dsp.csdr_print_bufsizes = self.localProps["csdr_print_bufsizes"]
self.dsp.csdr_through = self.localProps["csdr_through"]
if self.localProps["digimodes_enable"]:
def set_secondary_mod(mod):
if mod == False:
mod = None
self.dsp.set_secondary_demodulator(mod)
if mod is not None:
self.handler.write_secondary_dsp_config(
{
"secondary_fft_size": self.localProps["digimodes_fft_size"],
"if_samp_rate": self.dsp.if_samp_rate(),
"secondary_bw": self.dsp.secondary_bw(),
}
)
self.subscriptions += [
self.localProps.getProperty("secondary_mod").wire(set_secondary_mod),
self.localProps.getProperty("secondary_offset_freq").wire(self.dsp.set_secondary_offset_freq),
]
self.sdrSource.addClient(self)
super().__init__()
def start(self):
if self.sdrSource.isAvailable():
self.dsp.start()
def receive_output(self, t, read_fn):
logger.debug("adding new output of type %s", t)
writers = {
"audio": self.handler.write_dsp_data,
"smeter": self.handler.write_s_meter_level,
"secondary_fft": self.handler.write_secondary_fft,
"secondary_demod": self.handler.write_secondary_demod,
}
for demod, parser in self.parsers.items():
writers[demod] = parser.parse
write = writers[t]
threading.Thread(target=self.pump(read_fn, write)).start()
def stop(self):
self.dsp.stop()
self.sdrSource.removeClient(self)
for sub in self.subscriptions:
sub.cancel()
self.subscriptions = []
def setProperty(self, prop, value):
self.localProps.getProperty(prop).setValue(value)
def getClientClass(self):
return SdrSource.CLIENT_USER
def onStateChange(self, state):
if state == SdrSource.STATE_RUNNING:
logger.debug("received STATE_RUNNING, attempting DspSource restart")
self.dsp.start()
elif state == SdrSource.STATE_STOPPING:
logger.debug("received STATE_STOPPING, shutting down DspSource")
self.dsp.stop()
elif state == SdrSource.STATE_FAILED:
logger.debug("received STATE_FAILED, shutting down DspSource")
self.dsp.stop()
def onBusyStateChange(self, state):
pass

View File

@ -1,6 +1,6 @@
import subprocess
from functools import reduce
from operator import and_
from operator import and_, or_
import re
from distutils.version import LooseVersion
import inspect
@ -18,18 +18,25 @@ class UnknownFeatureException(Exception):
class FeatureDetector(object):
features = {
# core features; we won't start without these
"core": ["csdr", "nmux", "nc"],
"rtl_sdr": ["rtl_sdr"],
"rtl_sdr_connector": ["rtl_connector"],
"sdrplay": ["rx_tools"],
"sdrplay_connector": ["soapy_connector"],
# different types of sdrs and their requirements
"rtl_sdr": ["rtl_connector"],
"rtl_sdr_soapy": ["soapy_connector", "soapy_rtl_sdr"],
"sdrplay": ["soapy_connector", "soapy_sdrplay"],
"hackrf": ["hackrf_transfer"],
"airspy": ["airspy_rx"],
"airspy_connector": ["soapy_connector"],
"airspy": ["soapy_connector", "soapy_airspy"],
"airspyhf": ["soapy_connector", "soapy_airspyhf"],
"lime_sdr": ["soapy_connector", "soapy_lime_sdr"],
"fifi_sdr": ["alsa"],
"pluto_sdr": ["soapy_connector", "soapy_pluto_sdr"],
"soapy_remote": ["soapy_connector", "soapy_remote"],
# optional features and their requirements
"digital_voice_digiham": ["digiham", "sox"],
"digital_voice_dsd": ["dsd", "sox", "digiham"],
"wsjt-x": ["wsjtx", "sox"],
"packet": ["direwolf"],
"packet": ["direwolf", "sox"],
"pocsag": ["digiham", "sox"],
}
def feature_availability(self):
@ -123,17 +130,6 @@ class FeatureDetector(object):
"""
return self.command_is_runnable("rtl_sdr --help")
def has_rx_tools(self):
"""
The rx_tools package can be used to interface with SDR devices compatible with SoapySDR. It is currently used
to connect to SDRPlay devices. Please check the following pages for more details:
* [rx_tools GitHub page](https://github.com/rxseger/rx_tools)
* [SoapySDR Project wiki](https://github.com/pothosware/SoapySDR/wiki)
* [SDRPlay homepage](https://www.sdrplay.com/)
"""
return self.command_is_runnable("rx_sdr --help")
def has_hackrf_transfer(self):
"""
To use a HackRF, compile the HackRF host tools from its "stdout" branch:
@ -161,9 +157,9 @@ class FeatureDetector(object):
Please note: there is close interaction between digiham and openwebrx, so older versions will probably not work.
If you have an older verison of digiham installed, please update it along with openwebrx.
As of now, we require version 0.2 of digiham.
As of now, we require version 0.3 of digiham.
"""
required_version = LooseVersion("0.2")
required_version = LooseVersion("0.3")
digiham_version_regex = re.compile("^digiham version (.*)$")
@ -190,6 +186,8 @@ class FeatureDetector(object):
"mbe_synthesizer",
"gfsk_demodulator",
"digitalvoice_filter",
"fsk_demodulator",
"pocsag_decoder",
],
),
True,
@ -216,7 +214,7 @@ class FeatureDetector(object):
The owrx_connector package offers direct interfacing between your hardware and openwebrx. It allows quicker
frequency switching, uses less CPU and can even provide more stability in some cases.
You can get it here: https://github.com/jketterl/owrx_connector
You can get it [here](https://github.com/jketterl/owrx_connector).
"""
return self._check_connector("rtl_connector")
@ -225,10 +223,82 @@ class FeatureDetector(object):
The owrx_connector package offers direct interfacing between your hardware and openwebrx. It allows quicker
frequency switching, uses less CPU and can even provide more stability in some cases.
You can get it here: https://github.com/jketterl/owrx_connector
You can get it [here](https://github.com/jketterl/owrx_connector).
"""
return self._check_connector("soapy_connector")
def _has_soapy_driver(self, driver):
try:
process = subprocess.Popen(["SoapySDRUtil", "--info"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
driverRegex = re.compile("^Module found: .*lib(.*)Support.so")
def matchLine(line):
matches = driverRegex.match(line.decode())
return matches is not None and matches.group(1) == driver
lines = [matchLine(line) for line in process.stdout]
return reduce(or_, lines, False)
except FileNotFoundError:
return False
def has_soapy_rtl_sdr(self):
"""
The SoapySDR module for rtl-sdr devices can be used as an alternative to the rtl_connector. It provides
additional support for the direct sampling mod.
You can get it [here](https://github.com/pothosware/SoapyRTLSDR/wiki).
"""
return self._has_soapy_driver("rtlsdr")
def has_soapy_sdrplay(self):
"""
The SoapySDR module for sdrplay devices is required for interfacing with SDRPlay devices (RSP1*, RSP2*, RSPDuo)
You can get it [here](https://github.com/pothosware/SoapySDRPlay/wiki).
"""
return self._has_soapy_driver("sdrPlay")
def has_soapy_airspy(self):
"""
The SoapySDR module for airspy devices is required for interfacing with Airspy devices (Airspy R2, Airspy Mini).
You can get it [here](https://github.com/pothosware/SoapyAirspy/wiki).
"""
return self._has_soapy_driver("airspy")
def has_soapy_airspyhf(self):
"""
The SoapySDR module for airspyhf devices is required for interfacing with Airspy HF devices (Airspy HF+,
Airspy HF discovery).
You can get it [here](https://github.com/pothosware/SoapyAirspyHF/wiki).
"""
return self._has_soapy_driver("airspyhf")
def has_soapy_lime_sdr(self):
"""
The Lime Suite installs - amongst others - a Soapy driver for the LimeSDR device series.
You can get it [here](https://github.com/myriadrf/LimeSuite).
"""
return self._has_soapy_driver("LMS7")
def has_soapy_pluto_sdr(self):
"""
The SoapySDR module for PlutoSDR devices is required for interfacing with PlutoSDR devices.
You can get it [here](https://github.com/photosware/SoapyPlutoSDR).
"""
return self._has_soapy_driver("PlutoSDR")
def has_soapy_remote(self):
"""
The SoapyRemote allows the usage of remote SDR devices using the SoapySDRServer.
You can get the code and find additional information [here](https://github.com/pothosware/SoapyRemote/wiki).
"""
return self._has_soapy_driver("remote")
def has_dsd(self):
"""
The digital voice modes NXDN and D-Star can be decoded by the dsd project. Please note that you need the version
@ -246,6 +316,11 @@ class FeatureDetector(object):
return self.command_is_runnable("sox")
def has_direwolf(self):
"""
OpenWebRX uses the [direwolf](https://github.com/wb2osz/direwolf) software modem to decode Packet Radio and
report data back to APRS-IS. Direwolf is available from the package manager on many distributions, or you can
compile it from source.
"""
return self.command_is_runnable("direwolf --help")
def has_airspy_rx(self):
@ -261,3 +336,10 @@ class FeatureDetector(object):
on how to build from source.
"""
return reduce(and_, map(self.command_is_runnable, ["jt9", "wsprd"]), True)
def has_alsa(self):
"""
Some SDR receivers are identifying themselves as a soundcard. In order to read their data, OpenWebRX relies
on the Alsa library. It is available as a package for most Linux distributions.
"""
return self.command_is_runnable("arecord --help")

92
owrx/fft.py Normal file
View File

@ -0,0 +1,92 @@
from owrx.config import PropertyManager
from csdr import csdr
import threading
from owrx.source import SdrSource
import logging
logger = logging.getLogger(__name__)
class SpectrumThread(csdr.output):
def __init__(self, sdrSource):
self.sdrSource = sdrSource
super().__init__()
self.props = props = self.sdrSource.props.collect(
"samp_rate",
"fft_size",
"fft_fps",
"fft_voverlap_factor",
"fft_compression",
"csdr_dynamic_bufsize",
"csdr_print_bufsizes",
"csdr_through",
"temporary_directory",
).defaults(PropertyManager.getSharedInstance())
self.dsp = dsp = csdr.dsp(self)
dsp.nc_port = self.sdrSource.getPort()
dsp.set_demodulator("fft")
def set_fft_averages(key, value):
samp_rate = props["samp_rate"]
fft_size = props["fft_size"]
fft_fps = props["fft_fps"]
fft_voverlap_factor = props["fft_voverlap_factor"]
dsp.set_fft_averages(
int(round(1.0 * samp_rate / fft_size / fft_fps / (1.0 - fft_voverlap_factor)))
if fft_voverlap_factor > 0
else 0
)
self.subscriptions = [
props.getProperty("samp_rate").wire(dsp.set_samp_rate),
props.getProperty("fft_size").wire(dsp.set_fft_size),
props.getProperty("fft_fps").wire(dsp.set_fft_fps),
props.getProperty("fft_compression").wire(dsp.set_fft_compression),
props.getProperty("temporary_directory").wire(dsp.set_temporary_directory),
props.collect("samp_rate", "fft_size", "fft_fps", "fft_voverlap_factor").wire(set_fft_averages),
]
set_fft_averages(None, None)
dsp.csdr_dynamic_bufsize = props["csdr_dynamic_bufsize"]
dsp.csdr_print_bufsizes = props["csdr_print_bufsizes"]
dsp.csdr_through = props["csdr_through"]
logger.debug("Spectrum thread initialized successfully.")
def start(self):
self.sdrSource.addClient(self)
if self.sdrSource.isAvailable():
self.dsp.start()
def supports_type(self, t):
return t == "audio"
def receive_output(self, type, read_fn):
if self.props["csdr_dynamic_bufsize"]:
read_fn(8) # dummy read to skip bufsize & preamble
logger.debug("Note: CSDR_DYNAMIC_BUFSIZE_ON = 1")
threading.Thread(target=self.pump(read_fn, self.sdrSource.writeSpectrumData)).start()
def stop(self):
self.dsp.stop()
self.sdrSource.removeClient(self)
for c in self.subscriptions:
c.cancel()
self.subscriptions = []
def getClientClass(self):
return SdrSource.CLIENT_USER
def onStateChange(self, state):
if state in [SdrSource.STATE_STOPPING, SdrSource.STATE_FAILED]:
self.dsp.stop()
elif state == SdrSource.STATE_RUNNING:
self.dsp.start()
def onBusyStateChange(self, state):
pass

View File

@ -1,5 +1,6 @@
from owrx.controllers import (
StatusController,
StatusJsonController,
IndexController,
OwrxAssetsController,
WebSocketController,
@ -41,6 +42,7 @@ class Router(object):
mappings = [
{"route": "/", "controller": IndexController},
{"route": "/status", "controller": StatusController},
{"route": "/status.json", "controller": StatusJsonController},
{"regex": "/static/(.+)", "controller": OwrxAssetsController},
{"regex": "/aprs-symbols/(.+)", "controller": AprsSymbolsController},
{"route": "/ws/", "controller": WebSocketController},

View File

@ -18,6 +18,7 @@ class DirewolfConfig(object):
config = """
ACHANNELS 1
ADEVICE stdin null
CHANNEL 0
MYCALL {callsign}

View File

@ -2,6 +2,7 @@ from datetime import datetime, timedelta
import threading, time
from owrx.config import PropertyManager
from owrx.bands import Band
import sys
import logging
@ -15,11 +16,13 @@ class Location(object):
class Map(object):
sharedInstance = None
creationLock = threading.Lock()
@staticmethod
def getSharedInstance():
if Map.sharedInstance is None:
Map.sharedInstance = Map()
with Map.creationLock:
if Map.sharedInstance is None:
Map.sharedInstance = Map()
return Map.sharedInstance
def __init__(self):
@ -111,9 +114,11 @@ class Map(object):
self.removeLocation(callsign)
def rebuildPositions(self):
logger.debug("rebuilding map storage; size before: %i", sys.getsizeof(self.positions))
with self.positionsLock:
p = {key: value for key, value in self.positions.items()}
self.positions = p
logger.debug("rebuild complete; size after: %i", sys.getsizeof(self.positions))
class LatLngLocation(Location):

View File

@ -5,7 +5,7 @@ from datetime import datetime, timedelta
import logging
import threading
from owrx.map import Map, LatLngLocation
from owrx.bands import Bandplan
from owrx.parser import Parser
logger = logging.getLogger(__name__)
@ -83,17 +83,10 @@ class YsfMetaEnricher(object):
return None
class MetaParser(object):
class MetaParser(Parser):
def __init__(self, handler):
self.handler = handler
super().__init__(handler)
self.enrichers = {"DMR": DmrMetaEnricher(), "YSF": YsfMetaEnricher(self)}
self.band = None
def setDialFrequency(self, freq):
self.band = Bandplan.getSharedInstance().findBand(freq)
def getBand(self):
return self.band
def parse(self, meta):
fields = meta.split(";")

20
owrx/parser.py Normal file
View File

@ -0,0 +1,20 @@
from abc import ABC, abstractmethod
from owrx.bands import Bandplan
class Parser(ABC):
def __init__(self, handler):
self.handler = handler
self.dial_freq = None
self.band = None
@abstractmethod
def parse(self, raw):
pass
def setDialFrequency(self, freq):
self.dial_freq = freq
self.band = Bandplan.getSharedInstance().findBand(freq)
def getBand(self):
return self.band

10
owrx/pocsag.py Normal file
View File

@ -0,0 +1,10 @@
from owrx.parser import Parser
class PocsagParser(Parser):
def parse(self, raw):
fields = raw.decode("ascii", "replace").rstrip("\n").split(";")
meta = {v[0]: "".join(v[1:]) for v in map(lambda x: x.split(":"), fields) if v[0] != ""}
if "address" in meta:
meta["address"] = int(meta["address"])
self.handler.write_pocsag_data(meta)

81
owrx/sdr.py Normal file
View File

@ -0,0 +1,81 @@
from owrx.config import PropertyManager
from owrx.feature import FeatureDetector, UnknownFeatureException
import logging
logger = logging.getLogger(__name__)
class SdrService(object):
sdrProps = None
sources = {}
lastPort = None
@staticmethod
def loadProps():
if SdrService.sdrProps is None:
pm = PropertyManager.getSharedInstance()
featureDetector = FeatureDetector()
def loadIntoPropertyManager(dict: dict):
propertyManager = PropertyManager()
for (name, value) in dict.items():
propertyManager[name] = value
return propertyManager
def sdrTypeAvailable(value):
try:
if not featureDetector.is_available(value["type"]):
logger.error(
'The RTL source type "{0}" is not available. please check requirements.'.format(
value["type"]
)
)
return False
return True
except UnknownFeatureException:
logger.error(
'The RTL source type "{0}" is invalid. Please check your configuration'.format(value["type"])
)
return False
# transform all dictionary items into PropertyManager object, filtering out unavailable ones
SdrService.sdrProps = {
name: loadIntoPropertyManager(value) for (name, value) in pm["sdrs"].items() if sdrTypeAvailable(value)
}
logger.info(
"SDR sources loaded. Available SDRs: {0}".format(
", ".join(map(lambda x: x["name"], SdrService.sdrProps.values()))
)
)
@staticmethod
def getFirstSource():
sources = SdrService.getSources()
if not sources:
return None
# TODO: configure default sdr in config? right now it will pick the first one off the list.
return sources[list(sources.keys())[0]]
@staticmethod
def getSource(id):
SdrService.loadProps()
sources = SdrService.getSources()
if not sources:
return None
if not id in sources:
return None
return sources[id]
@staticmethod
def getSources():
SdrService.loadProps()
for id in SdrService.sdrProps.keys():
if not id in SdrService.sources:
props = SdrService.sdrProps[id]
sdrType = props["type"]
className = "".join(x for x in sdrType.title() if x.isalnum()) + "Source"
module = __import__("owrx.source.{0}".format(sdrType), fromlist=[className])
cls = getattr(module, className)
SdrService.sources[id] = cls(id, props)
return {key: s for key, s in SdrService.sources.items() if not s.isFailed()}

View File

@ -1,7 +1,7 @@
import threading
import subprocess
import time
from owrx.config import PropertyManager
from urllib import request, parse
import logging
@ -14,24 +14,28 @@ class SdrHuUpdater(threading.Thread):
super().__init__(daemon=True)
def update(self):
pm = PropertyManager.getSharedInstance()
cmd = 'wget --timeout=15 -4qO- https://sdr.hu/update --post-data "url=http://{server_hostname}:{web_port}&apikey={sdrhu_key}" 2>&1'.format(
**pm.__dict__()
)
logger.debug(cmd)
returned = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).communicate()
returned = returned[0].decode("utf-8")
if "UPDATE:" in returned:
retrytime_mins = 20
value = returned.split("UPDATE:")[1].split("\n", 1)[0]
if value.startswith("SUCCESS"):
logger.info("Update succeeded!")
else:
logger.warning("Update failed, your receiver cannot be listed on sdr.hu! Reason: %s", value)
pm = PropertyManager.getSharedInstance().collect("server_hostname", "web_port", "sdrhu_key")
data = parse.urlencode({
"url": "http://{server_hostname}:{web_port}".format(**pm.__dict__()),
"apikey": pm["sdrhu_key"]
}).encode()
res = request.urlopen("https://sdr.hu/update", data=data)
if res.getcode() < 200 or res.getcode() >= 300:
logger.warning('sdr.hu update failed with error code %i', res.getcode())
return 2
returned = res.read().decode("utf-8")
if "UPDATE:" not in returned:
logger.warning("Update failed, your receiver cannot be listed on sdr.hu!")
return 2
value = returned.split("UPDATE:")[1].split("\n", 1)[0]
if value.startswith("SUCCESS"):
logger.info("Update succeeded!")
else:
retrytime_mins = 2
logger.warning("wget failed while updating, your receiver cannot be listed on sdr.hu!")
return retrytime_mins
logger.warning("Update failed, your receiver cannot be listed on sdr.hu! Reason: %s", value)
return 20
def run(self):
while self.doRun:

View File

@ -1,24 +1,26 @@
import threading
from owrx.socket import getAvailablePort
from datetime import datetime, timezone, timedelta
from owrx.source import SdrService, SdrSource
from owrx.source import SdrSource
from owrx.sdr import SdrService
from owrx.bands import Bandplan
from csdr import dsp, output
from csdr.csdr import dsp, output
from owrx.wsjt import WsjtParser
from owrx.aprs import AprsParser
from owrx.config import PropertyManager
from owrx.source import Resampler
from owrx.source.resampler import Resampler
from owrx.feature import FeatureDetector
from abc import ABCMeta, abstractmethod
from .schedule import ServiceScheduler
import logging
logger = logging.getLogger(__name__)
class ServiceOutput(output):
class ServiceOutput(output, metaclass=ABCMeta):
def __init__(self, frequency):
self.frequency = frequency
@abstractmethod
def getParser(self):
# abstract method; implement in subclasses
pass
@ -46,132 +48,6 @@ class AprsServiceOutput(ServiceOutput):
return t == "packet_demod"
class ScheduleEntry(object):
def __init__(self, startTime, endTime, profile):
self.startTime = startTime
self.endTime = endTime
self.profile = profile
def isCurrent(self, time):
if self.startTime < self.endTime:
return self.startTime <= time < self.endTime
else:
return self.startTime <= time or time < self.endTime
def getProfile(self):
return self.profile
def getScheduledEnd(self):
now = datetime.utcnow()
end = now.combine(date=now.date(), time=self.endTime)
while end < now:
end += timedelta(days=1)
return end
def getNextActivation(self):
now = datetime.utcnow()
start = now.combine(date=now.date(), time=self.startTime)
while start < now:
start += timedelta(days=1)
return start
class Schedule(object):
@staticmethod
def parse(scheduleDict):
entries = []
for time, profile in scheduleDict.items():
if len(time) != 9:
logger.warning("invalid schedule spec: %s", time)
continue
startTime = datetime.strptime(time[0:4], "%H%M").replace(tzinfo=timezone.utc).time()
endTime = datetime.strptime(time[5:9], "%H%M").replace(tzinfo=timezone.utc).time()
entries.append(ScheduleEntry(startTime, endTime, profile))
return Schedule(entries)
def __init__(self, entries):
self.entries = entries
def getCurrentEntry(self):
current = [p for p in self.entries if p.isCurrent(datetime.utcnow().time())]
if current:
return current[0]
return None
def getNextEntry(self):
s = sorted(self.entries, key=lambda e: e.getNextActivation())
if s:
return s[0]
return None
class ServiceScheduler(object):
def __init__(self, source, schedule):
self.source = source
self.schedule = Schedule.parse(schedule)
self.source.addClient(self)
self.selectionTimer = None
self.source.getProps().collect("center_freq", "samp_rate").wire(self.onFrequencyChange)
self.scheduleSelection()
def shutdown(self):
self.cancelTimer()
self.source.removeClient(self)
def scheduleSelection(self, time=None):
seconds = 10
if time is not None:
delta = time - datetime.utcnow()
seconds = delta.total_seconds()
self.cancelTimer()
self.selectionTimer = threading.Timer(seconds, self.selectProfile)
self.selectionTimer.start()
def cancelTimer(self):
if self.selectionTimer:
self.selectionTimer.cancel()
def getClientClass(self):
return SdrSource.CLIENT_BACKGROUND
def onStateChange(self, state):
if state == SdrSource.STATE_STOPPING:
self.scheduleSelection()
elif state == SdrSource.STATE_FAILED:
self.cancelTimer()
def onBusyStateChange(self, state):
if state == SdrSource.BUSYSTATE_IDLE:
self.scheduleSelection()
def onFrequencyChange(self, name, value):
self.scheduleSelection()
def selectProfile(self):
if self.source.hasClients(SdrSource.CLIENT_USER):
logger.debug("source has active users; not touching")
return
logger.debug("source seems to be idle, selecting profile for background services")
entry = self.schedule.getCurrentEntry()
if entry is None:
logger.debug("schedule did not return a profile. checking next entry...")
nextEntry = self.schedule.getNextEntry()
if nextEntry is not None:
self.scheduleSelection(nextEntry.getNextActivation())
return
logger.debug("scheduling end for current profile: %s", entry.getScheduledEnd())
self.scheduleSelection(entry.getScheduledEnd())
try:
self.source.activateProfile(entry.getProfile())
self.source.start()
except KeyError:
pass
class ServiceHandler(object):
def __init__(self, source):
self.lock = threading.Lock()
@ -184,8 +60,8 @@ class ServiceHandler(object):
if self.source.isAvailable():
self.scheduleServiceStartup()
self.scheduler = None
if "schedule" in props:
self.scheduler = ServiceScheduler(self.source, props["schedule"])
if "schedule" in props or "scheduler" in props:
self.scheduler = ServiceScheduler(self.source)
def getClientClass(self):
return SdrSource.CLIENT_INACTIVE
@ -199,6 +75,8 @@ class ServiceHandler(object):
elif state == SdrSource.STATE_FAILED:
logger.debug("sdr source failed; stopping services.")
self.stopServices()
if self.scheduler:
self.scheduler.shutdown()
def onBusyStateChange(self, state):
pass
@ -289,7 +167,7 @@ class ServiceHandler(object):
resampler_props["center_freq"] = cf
# TODO the + 24000 is a temporary fix since the resampling optimizer does not account for required bandwidths
resampler_props["samp_rate"] = bw + 24000
resampler = Resampler(resampler_props, getAvailablePort(), self.source)
resampler = Resampler(resampler_props, self.source)
resampler.start()
for dial in group:
@ -385,18 +263,12 @@ class Services(object):
if not PropertyManager.getSharedInstance()["services_enabled"]:
return
for source in SdrService.getSources().values():
Services.handlers.append(ServiceHandler(source))
props = source.getProps()
if "services" not in props or props["services"] is not False:
Services.handlers.append(ServiceHandler(source))
@staticmethod
def stop():
for handler in Services.handlers:
handler.shutdown()
Services.handlers = []
class Service(object):
pass
class WsjtService(Service):
pass

272
owrx/service/schedule.py Normal file
View File

@ -0,0 +1,272 @@
from datetime import datetime, timezone, timedelta
from owrx.source import SdrSource
from owrx.config import PropertyManager
import threading
import math
from abc import ABC, ABCMeta, abstractmethod
import logging
logger = logging.getLogger(__name__)
class ScheduleEntry(ABC):
def __init__(self, startTime, endTime, profile):
self.startTime = startTime
self.endTime = endTime
self.profile = profile
def getProfile(self):
return self.profile
def __str__(self):
return "{0} - {1}: {2}".format(self.startTime, self.endTime, self.profile)
@abstractmethod
def isCurrent(self, dt):
pass
@abstractmethod
def getScheduledEnd(self):
pass
@abstractmethod
def getNextActivation(self):
pass
class TimeScheduleEntry(ScheduleEntry):
def isCurrent(self, dt):
time = dt.time()
if self.startTime < self.endTime:
return self.startTime <= time < self.endTime
else:
return self.startTime <= time or time < self.endTime
def getScheduledEnd(self):
now = datetime.utcnow()
end = now.combine(date=now.date(), time=self.endTime)
while end < now:
end += timedelta(days=1)
return end
def getNextActivation(self):
now = datetime.utcnow()
start = now.combine(date=now.date(), time=self.startTime)
while start < now:
start += timedelta(days=1)
return start
class DatetimeScheduleEntry(ScheduleEntry):
def isCurrent(self, dt):
return self.startTime <= dt < self.endTime
def getScheduledEnd(self):
return self.endTime
def getNextActivation(self):
return self.startTime
class Schedule(ABC):
@staticmethod
def parse(props):
# downwards compatibility
if "schedule" in props:
return StaticSchedule(props["schedule"])
elif "scheduler" in props:
sc = props["scheduler"]
t = sc["type"] if "type" in sc else "static"
if t == "static":
return StaticSchedule(sc["schedule"])
elif t == "daylight":
return DaylightSchedule(sc["schedule"])
else:
logger.warning("Invalid scheduler type: %s", t)
@abstractmethod
def getCurrentEntry(self):
pass
@abstractmethod
def getNextEntry(self):
pass
class TimerangeSchedule(Schedule, metaclass=ABCMeta):
@abstractmethod
def getEntries(self):
pass
def getCurrentEntry(self):
current = [p for p in self.getEntries() if p.isCurrent(datetime.utcnow())]
if current:
return current[0]
return None
def getNextEntry(self):
s = sorted(self.getEntries(), key=lambda e: e.getNextActivation())
if s:
return s[0]
return None
class StaticSchedule(TimerangeSchedule):
def __init__(self, scheduleDict):
self.entries = []
for time, profile in scheduleDict.items():
if len(time) != 9:
logger.warning("invalid schedule spec: %s", time)
continue
startTime = datetime.strptime(time[0:4], "%H%M").replace(tzinfo=timezone.utc).time()
endTime = datetime.strptime(time[5:9], "%H%M").replace(tzinfo=timezone.utc).time()
self.entries.append(TimeScheduleEntry(startTime, endTime, profile))
def getEntries(self):
return self.entries
class DaylightSchedule(TimerangeSchedule):
greyLineTime = timedelta(hours=1)
def __init__(self, scheduleDict):
self.schedule = scheduleDict
def getSunTimes(self, date):
pm = PropertyManager.getSharedInstance()
lat, lng = pm["receiver_gps"]
degtorad = math.pi / 180
radtodeg = 180 / math.pi
#Number of days since 01/01
days = date.timetuple().tm_yday
# Longitudinal correction
longCorr = 4 * lng
# calibrate for solstice
b = 2 * math.pi * (days - 81) / 365
# Equation of Time Correction
eoTCorr = 9.87 * math.sin(2 * b) - 7.53 * math.cos(b) - 1.5 * math.sin(b)
# Solar correction
solarCorr = longCorr + eoTCorr
# Solar declination
declination = math.asin(math.sin(23.45 * degtorad) * math.sin(b))
sunrise = 12 - math.acos(-math.tan(lat * degtorad) * math.tan(declination)) * radtodeg / 15 - solarCorr / 60
sunset = 12 + math.acos(-math.tan(lat * degtorad) * math.tan(declination)) * radtodeg / 15 - solarCorr / 60
midnight = datetime.combine(date, datetime.min.time())
sunrise = midnight + timedelta(hours=sunrise)
sunset = midnight + timedelta(hours=sunset)
logger.debug("for {date} sunrise: {sunrise} sunset {sunset}".format(date=date, sunrise=sunrise, sunset=sunset))
return sunrise, sunset
def getEntries(self):
now = datetime.utcnow()
date = now.date()
# greyline is optional, it its set it will shorten the other profiles
useGreyline = "greyline" in self.schedule
entries = []
delta = DaylightSchedule.greyLineTime if useGreyline else timedelta()
events = []
# we need to start yesterday for longitudes close to the date line
offset = -1
while len(events) < 1:
sunrise, sunset = self.getSunTimes(date + timedelta(days=offset))
offset += 1
events += [{"type": "sunrise", "time": sunrise}, {"type": "sunset", "time": sunset}]
# keep only events in the future
events = [v for v in events if v["time"] + delta > now]
events.sort(key=lambda e: e["time"])
previousEvent = None
for event in events:
# night profile _until_ sunrise, day profile _until_ sunset
stype = "night" if event["type"] == "sunrise" else "day"
if previousEvent is not None or event["time"] - delta > now:
start = now if previousEvent is None else previousEvent
entries.append(DatetimeScheduleEntry(start, event["time"] - delta, self.schedule[stype]))
if useGreyline:
entries.append(
DatetimeScheduleEntry(event["time"] - delta, event["time"] + delta, self.schedule["greyline"])
)
previousEvent = event["time"] + delta
logger.debug([str(e) for e in entries])
return entries
class ServiceScheduler(object):
def __init__(self, source):
self.source = source
self.selectionTimer = None
self.source.addClient(self)
props = self.source.getProps()
self.schedule = Schedule.parse(props)
props.collect("center_freq", "samp_rate").wire(self.onFrequencyChange)
self.scheduleSelection()
def shutdown(self):
self.cancelTimer()
self.source.removeClient(self)
def scheduleSelection(self, time=None):
if self.source.getState() == SdrSource.STATE_FAILED:
return
seconds = 10
if time is not None:
delta = time - datetime.utcnow()
seconds = delta.total_seconds()
self.cancelTimer()
self.selectionTimer = threading.Timer(seconds, self.selectProfile)
self.selectionTimer.start()
def cancelTimer(self):
if self.selectionTimer:
self.selectionTimer.cancel()
def getClientClass(self):
return SdrSource.CLIENT_BACKGROUND
def onStateChange(self, state):
if state == SdrSource.STATE_STOPPING:
self.scheduleSelection()
elif state == SdrSource.STATE_FAILED:
self.cancelTimer()
def onBusyStateChange(self, state):
if state == SdrSource.BUSYSTATE_IDLE:
self.scheduleSelection()
def onFrequencyChange(self, name, value):
self.scheduleSelection()
def selectProfile(self):
if self.source.hasClients(SdrSource.CLIENT_USER):
logger.debug("source has active users; not touching")
return
logger.debug("source seems to be idle, selecting profile for background services")
entry = self.schedule.getCurrentEntry()
if entry is None:
logger.debug("schedule did not return a profile. checking next entry...")
nextEntry = self.schedule.getNextEntry()
if nextEntry is not None:
self.scheduleSelection(nextEntry.getNextActivation())
return
logger.debug("selected profile %s until %s", entry.getProfile(), entry.getScheduledEnd())
self.scheduleSelection(entry.getScheduledEnd())
try:
self.source.activateProfile(entry.getProfile())
self.source.start()
except KeyError:
pass

View File

@ -1,957 +0,0 @@
import subprocess
from owrx.config import PropertyManager
from owrx.feature import FeatureDetector, UnknownFeatureException
from owrx.meta import MetaParser
from owrx.wsjt import WsjtParser
from owrx.aprs import AprsParser
from owrx.metrics import Metrics, DirectMetric
from owrx.socket import getAvailablePort
import threading
import csdr
import time
import os
import signal
import sys
import socket
import logging
logger = logging.getLogger(__name__)
class SdrService(object):
sdrProps = None
sources = {}
lastPort = None
@staticmethod
def getNextPort():
pm = PropertyManager.getSharedInstance()
(start, end) = pm["iq_port_range"]
if SdrService.lastPort is None:
SdrService.lastPort = start
else:
SdrService.lastPort += 1
if SdrService.lastPort > end:
raise IndexError("no more available ports to start more sdrs")
return SdrService.lastPort
@staticmethod
def loadProps():
if SdrService.sdrProps is None:
pm = PropertyManager.getSharedInstance()
featureDetector = FeatureDetector()
def loadIntoPropertyManager(dict: dict):
propertyManager = PropertyManager()
for (name, value) in dict.items():
propertyManager[name] = value
return propertyManager
def sdrTypeAvailable(value):
try:
if not featureDetector.is_available(value["type"]):
logger.error(
'The RTL source type "{0}" is not available. please check requirements.'.format(
value["type"]
)
)
return False
return True
except UnknownFeatureException:
logger.error(
'The RTL source type "{0}" is invalid. Please check your configuration'.format(value["type"])
)
return False
# transform all dictionary items into PropertyManager object, filtering out unavailable ones
SdrService.sdrProps = {
name: loadIntoPropertyManager(value) for (name, value) in pm["sdrs"].items() if sdrTypeAvailable(value)
}
logger.info(
"SDR sources loaded. Availables SDRs: {0}".format(
", ".join(map(lambda x: x["name"], SdrService.sdrProps.values()))
)
)
@staticmethod
def getSource(id=None):
SdrService.loadProps()
sources = SdrService.getSources()
if not sources:
return None
if id is None:
# TODO: configure default sdr in config? right now it will pick the first one off the list.
id = list(sources.keys())[0]
if not id in sources:
return None
return sources[id]
@staticmethod
def getSources():
SdrService.loadProps()
for id in SdrService.sdrProps.keys():
if not id in SdrService.sources:
props = SdrService.sdrProps[id]
className = "".join(x for x in props["type"].title() if x.isalnum()) + "Source"
cls = getattr(sys.modules[__name__], className)
SdrService.sources[id] = cls(id, props, SdrService.getNextPort())
return {key: s for key, s in SdrService.sources.items() if not s.isFailed()}
class SdrSource(object):
STATE_STOPPED = 0
STATE_STARTING = 1
STATE_RUNNING = 2
STATE_STOPPING = 3
STATE_TUNING = 4
STATE_FAILED = 5
BUSYSTATE_IDLE = 0
BUSYSTATE_BUSY = 1
CLIENT_INACTIVE = 0
CLIENT_BACKGROUND = 1
CLIENT_USER = 2
def __init__(self, id, props, port):
self.id = id
self.props = props
self.profile_id = None
self.activateProfile()
self.rtlProps = self.props.collect(*self.getEventNames()).defaults(PropertyManager.getSharedInstance())
self.wireEvents()
self.port = port
self.monitor = None
self.clients = []
self.spectrumClients = []
self.spectrumThread = None
self.process = None
self.modificationLock = threading.Lock()
self.failed = False
self.state = SdrSource.STATE_STOPPED
self.busyState = SdrSource.BUSYSTATE_IDLE
def getEventNames(self):
return [
"samp_rate",
"nmux_memory",
"center_freq",
"ppm",
"rf_gain",
"lna_gain",
"rf_amp",
"antenna",
"if_gain",
"lfo_offset",
]
def wireEvents(self):
def restart(name, value):
logger.debug("restarting sdr source due to property change: {0} changed to {1}".format(name, value))
self.stop()
self.start()
self.rtlProps.wire(restart)
# override this in subclasses
def getCommand(self):
pass
# override this in subclasses, if necessary
def getFormatConversion(self):
return None
def activateProfile(self, profile_id=None):
profiles = self.props["profiles"]
if profile_id is None:
profile_id = list(profiles.keys())[0]
if profile_id == self.profile_id:
return
logger.debug("activating profile {0}".format(profile_id))
self.profile_id = profile_id
profile = profiles[profile_id]
self.props["profile_id"] = profile_id
for (key, value) in profile.items():
# skip the name, that would overwrite the source name.
if key == "name":
continue
self.props[key] = value
def getId(self):
return self.id
def getProfileId(self):
return self.profile_id
def getProfiles(self):
return self.props["profiles"]
def getName(self):
return self.props["name"]
def getProps(self):
return self.props
def getPort(self):
return self.port
def useNmux(self):
return True
def getCommandValues(self):
dict = self.rtlProps.collect(*self.getEventNames()).__dict__()
if "lfo_offset" in dict and dict["lfo_offset"] is not None:
dict["tuner_freq"] = dict["center_freq"] + dict["lfo_offset"]
else:
dict["tuner_freq"] = dict["center_freq"]
return dict
def start(self):
self.modificationLock.acquire()
if self.monitor:
self.modificationLock.release()
return
props = self.rtlProps
cmd = self.getCommand().format(**self.getCommandValues())
format_conversion = self.getFormatConversion()
if format_conversion is not None:
cmd += " | " + format_conversion
if self.useNmux():
nmux_bufcnt = nmux_bufsize = 0
while nmux_bufsize < props["samp_rate"] / 4:
nmux_bufsize += 4096
while nmux_bufsize * nmux_bufcnt < props["nmux_memory"] * 1e6:
nmux_bufcnt += 1
if nmux_bufcnt == 0 or nmux_bufsize == 0:
logger.error(
"Error: nmux_bufsize or nmux_bufcnt is zero. These depend on nmux_memory and samp_rate options in config_webrx.py"
)
self.modificationLock.release()
return
logger.debug("nmux_bufsize = %d, nmux_bufcnt = %d" % (nmux_bufsize, nmux_bufcnt))
cmd = cmd + " | nmux --bufsize %d --bufcnt %d --port %d --address 127.0.0.1" % (
nmux_bufsize,
nmux_bufcnt,
self.port,
)
self.process = subprocess.Popen(cmd, shell=True, preexec_fn=os.setpgrp)
logger.info("Started rtl source: " + cmd)
available = False
def wait_for_process_to_end():
rc = self.process.wait()
logger.debug("shut down with RC={0}".format(rc))
self.monitor = None
self.monitor = threading.Thread(target=wait_for_process_to_end)
self.monitor.start()
retries = 1000
while retries > 0:
retries -= 1
if self.monitor is None:
break
testsock = socket.socket()
try:
testsock.connect(("127.0.0.1", self.getPort()))
testsock.close()
available = True
break
except:
time.sleep(0.1)
if not available:
self.failed = True
self.postStart()
self.modificationLock.release()
self.setState(SdrSource.STATE_FAILED if self.failed else SdrSource.STATE_RUNNING)
def postStart(self):
pass
def isAvailable(self):
return self.monitor is not None
def isFailed(self):
return self.failed
def stop(self):
self.setState(SdrSource.STATE_STOPPING)
self.modificationLock.acquire()
if self.process is not None:
try:
os.killpg(os.getpgid(self.process.pid), signal.SIGTERM)
except ProcessLookupError:
# been killed by something else, ignore
pass
if self.monitor:
self.monitor.join()
self.sleepOnRestart()
self.modificationLock.release()
self.setState(SdrSource.STATE_STOPPED)
def sleepOnRestart(self):
pass
def hasClients(self, *args):
clients = [c for c in self.clients if c.getClientClass() in args]
return len(clients) > 0
def addClient(self, c):
self.clients.append(c)
hasUsers = self.hasClients(SdrSource.CLIENT_USER)
hasBackgroundTasks = self.hasClients(SdrSource.CLIENT_BACKGROUND)
if hasUsers or hasBackgroundTasks:
self.start()
self.setBusyState(SdrSource.BUSYSTATE_BUSY if hasUsers else SdrSource.BUSYSTATE_IDLE)
def removeClient(self, c):
try:
self.clients.remove(c)
except ValueError:
pass
hasUsers = self.hasClients(SdrSource.CLIENT_USER)
hasBackgroundTasks = self.hasClients(SdrSource.CLIENT_BACKGROUND)
self.setBusyState(SdrSource.BUSYSTATE_BUSY if hasUsers else SdrSource.BUSYSTATE_IDLE)
if not hasUsers and not hasBackgroundTasks:
self.stop()
def addSpectrumClient(self, c):
self.spectrumClients.append(c)
if self.spectrumThread is None:
self.spectrumThread = SpectrumThread(self)
self.spectrumThread.start()
def removeSpectrumClient(self, c):
try:
self.spectrumClients.remove(c)
except ValueError:
pass
if not self.spectrumClients and self.spectrumThread is not None:
self.spectrumThread.stop()
self.spectrumThread = None
def writeSpectrumData(self, data):
for c in self.spectrumClients:
c.write_spectrum_data(data)
def setState(self, state):
if state == self.state:
return
self.state = state
for c in self.clients:
c.onStateChange(state)
def setBusyState(self, state):
if state == self.busyState:
return
self.busyState = state
for c in self.clients:
c.onBusyStateChange(state)
class Resampler(SdrSource):
def __init__(self, props, port, sdr):
sdrProps = sdr.getProps()
self.shift = (sdrProps["center_freq"] - props["center_freq"]) / sdrProps["samp_rate"]
self.decimation = int(float(sdrProps["samp_rate"]) / props["samp_rate"])
if_samp_rate = sdrProps["samp_rate"] / self.decimation
self.transition_bw = 0.15 * (if_samp_rate / float(sdrProps["samp_rate"]))
props["samp_rate"] = if_samp_rate
self.sdr = sdr
super().__init__(None, props, port)
def start(self):
if self.isFailed():
return
self.modificationLock.acquire()
if self.monitor:
self.modificationLock.release()
return
self.setState(SdrSource.STATE_STARTING)
props = self.rtlProps
resampler_command = [
"nc -v 127.0.0.1 {nc_port}".format(nc_port=self.sdr.getPort()),
"csdr shift_addition_cc {shift}".format(shift=self.shift),
"csdr fir_decimate_cc {decimation} {ddc_transition_bw} HAMMING".format(
decimation=self.decimation, ddc_transition_bw=self.transition_bw
),
]
nmux_bufcnt = nmux_bufsize = 0
while nmux_bufsize < props["samp_rate"] / 4:
nmux_bufsize += 4096
while nmux_bufsize * nmux_bufcnt < props["nmux_memory"] * 1e6:
nmux_bufcnt += 1
if nmux_bufcnt == 0 or nmux_bufsize == 0:
logger.error(
"Error: nmux_bufsize or nmux_bufcnt is zero. These depend on nmux_memory and samp_rate options in config_webrx.py"
)
self.modificationLock.release()
return
logger.debug("nmux_bufsize = %d, nmux_bufcnt = %d" % (nmux_bufsize, nmux_bufcnt))
resampler_command += [
"nmux --bufsize %d --bufcnt %d --port %d --address 127.0.0.1" % (nmux_bufsize, nmux_bufcnt, self.port)
]
cmd = " | ".join(resampler_command)
logger.debug("resampler command: %s", cmd)
self.process = subprocess.Popen(cmd, shell=True, preexec_fn=os.setpgrp)
logger.info("Started resampler source: " + cmd)
available = False
def wait_for_process_to_end():
rc = self.process.wait()
logger.debug("shut down with RC={0}".format(rc))
self.monitor = None
self.monitor = threading.Thread(target=wait_for_process_to_end)
self.monitor.start()
retries = 1000
while retries > 0:
retries -= 1
if self.monitor is None:
break
testsock = socket.socket()
try:
testsock.connect(("127.0.0.1", self.getPort()))
testsock.close()
available = True
break
except:
time.sleep(0.1)
if not available:
self.failed = True
self.modificationLock.release()
self.setState(SdrSource.STATE_FAILED if self.failed else SdrSource.STATE_RUNNING)
def activateProfile(self, profile_id=None):
pass
class ConnectorSource(SdrSource):
def __init__(self, id, props, port):
super().__init__(id, props, port)
self.controlSocket = None
self.controlPort = getAvailablePort()
def sendControlMessage(self, prop, value):
logger.debug("sending property change over control socket: {0} changed to {1}".format(prop, value))
self.controlSocket.sendall("{prop}:{value}\n".format(prop=prop, value=value).encode())
def wireEvents(self):
def reconfigure(prop, value):
if self.monitor is None:
return
if (
(prop == "center_freq" or prop == "lfo_offset")
and "lfo_offset" in self.rtlProps
and self.rtlProps["lfo_offset"] is not None
):
freq = self.rtlProps["center_freq"] + self.rtlProps["lfo_offset"]
self.sendControlMessage("center_freq", freq)
else:
self.sendControlMessage(prop, value)
self.rtlProps.wire(reconfigure)
def postStart(self):
logger.debug("opening control socket...")
self.controlSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.controlSocket.connect(("localhost", self.controlPort))
def stop(self):
super().stop()
if self.controlSocket:
self.controlSocket.close()
self.controlSocket = None
def getFormatConversion(self):
return None
def useNmux(self):
return False
class RtlSdrConnectorSource(ConnectorSource):
def getEventNames(self):
return [
"samp_rate",
"center_freq",
"ppm",
"rf_gain",
"device",
"iqswap",
"lfo_offset",
]
def getCommand(self):
cmd = (
"rtl_connector -p {port} -c {controlPort}".format(port=self.port, controlPort=self.controlPort)
+ " -s {samp_rate} -f {tuner_freq} -g {rf_gain} -P {ppm}"
)
if "device" in self.rtlProps and self.rtlProps["device"] is not None:
cmd += ' -d "{device}"'
if self.rtlProps["iqswap"]:
cmd += " -i"
return cmd
class SdrplayConnectorSource(ConnectorSource):
def getEventNames(self):
return [
"samp_rate",
"center_freq",
"ppm",
"rf_gain",
"antenna",
"device",
"iqswap",
"lfo_offset",
]
def getCommand(self):
cmd = (
"soapy_connector -p {port} -c {controlPort}".format(port=self.port, controlPort=self.controlPort)
+ ' -s {samp_rate} -f {tuner_freq} -g "{rf_gain}" -P {ppm} -a "{antenna}"'
)
if "device" in self.rtlProps and self.rtlProps["device"] is not None:
cmd += ' -d "{device}"'
if self.rtlProps["iqswap"]:
cmd += " -i"
return cmd
class AirspyConnectorSource(ConnectorSource):
def getEventNames(self):
return [
"samp_rate",
"center_freq",
"ppm",
"rf_gain",
"device",
"iqswap",
"lfo_offset",
"bias_tee",
]
def getCommand(self):
cmd = (
"soapy_connector -p {port} -c {controlPort}".format(port=self.port, controlPort=self.controlPort)
+ ' -s {samp_rate} -f {tuner_freq} -g "{rf_gain}" -P {ppm}'
)
if "device" in self.rtlProps and self.rtlProps["device"] is not None:
cmd += ' -d "{device}"'
if self.rtlProps["iqswap"]:
cmd += " -i"
if self.rtlProps["bias_tee"]:
cmd += " -t biastee=true"
return cmd
class RtlSdrSource(SdrSource):
def getCommand(self):
return "rtl_sdr -s {samp_rate} -f {tuner_freq} -p {ppm} -g {rf_gain} -"
def getFormatConversion(self):
return "csdr convert_u8_f"
class HackrfSource(SdrSource):
def getCommand(self):
return "hackrf_transfer -s {samp_rate} -f {tuner_freq} -g {rf_gain} -l{lna_gain} -a{rf_amp} -r-"
def getFormatConversion(self):
return "csdr convert_s8_f"
class SdrplaySource(SdrSource):
def getCommand(self):
command = "rx_sdr -F CF32 -s {samp_rate} -f {tuner_freq} -p {ppm}"
gainMap = {"rf_gain": "RFGR", "if_gain": "IFGR"}
gains = [
"{0}={{{1}}}".format(gainMap[name], name)
for (name, value) in self.rtlProps.collect("rf_gain", "if_gain").__dict__().items()
if value is not None
]
if gains:
command += " -g {gains}".format(gains=",".join(gains))
if self.rtlProps["antenna"] is not None:
command += ' -a "{antenna}"'
command += " -"
return command
def sleepOnRestart(self):
time.sleep(1)
class AirspySource(SdrSource):
def getCommand(self):
frequency = self.props["tuner_freq"] / 1e6
command = "airspy_rx"
command += " -f{0}".format(frequency)
command += " -r /dev/stdout -a{samp_rate} -g {rf_gain}"
return command
def getFormatConversion(self):
return "csdr convert_s16_f"
class SpectrumThread(csdr.output):
def __init__(self, sdrSource):
self.sdrSource = sdrSource
super().__init__()
self.props = props = self.sdrSource.props.collect(
"samp_rate",
"fft_size",
"fft_fps",
"fft_voverlap_factor",
"fft_compression",
"csdr_dynamic_bufsize",
"csdr_print_bufsizes",
"csdr_through",
"temporary_directory",
).defaults(PropertyManager.getSharedInstance())
self.dsp = dsp = csdr.dsp(self)
dsp.nc_port = self.sdrSource.getPort()
dsp.set_demodulator("fft")
def set_fft_averages(key, value):
samp_rate = props["samp_rate"]
fft_size = props["fft_size"]
fft_fps = props["fft_fps"]
fft_voverlap_factor = props["fft_voverlap_factor"]
dsp.set_fft_averages(
int(round(1.0 * samp_rate / fft_size / fft_fps / (1.0 - fft_voverlap_factor)))
if fft_voverlap_factor > 0
else 0
)
self.subscriptions = [
props.getProperty("samp_rate").wire(dsp.set_samp_rate),
props.getProperty("fft_size").wire(dsp.set_fft_size),
props.getProperty("fft_fps").wire(dsp.set_fft_fps),
props.getProperty("fft_compression").wire(dsp.set_fft_compression),
props.getProperty("temporary_directory").wire(dsp.set_temporary_directory),
props.collect("samp_rate", "fft_size", "fft_fps", "fft_voverlap_factor").wire(set_fft_averages),
]
set_fft_averages(None, None)
dsp.csdr_dynamic_bufsize = props["csdr_dynamic_bufsize"]
dsp.csdr_print_bufsizes = props["csdr_print_bufsizes"]
dsp.csdr_through = props["csdr_through"]
logger.debug("Spectrum thread initialized successfully.")
def start(self):
self.sdrSource.addClient(self)
if self.sdrSource.isAvailable():
self.dsp.start()
def supports_type(self, t):
return t == "audio"
def receive_output(self, type, read_fn):
if self.props["csdr_dynamic_bufsize"]:
read_fn(8) # dummy read to skip bufsize & preamble
logger.debug("Note: CSDR_DYNAMIC_BUFSIZE_ON = 1")
threading.Thread(target=self.pump(read_fn, self.sdrSource.writeSpectrumData)).start()
def stop(self):
self.dsp.stop()
self.sdrSource.removeClient(self)
for c in self.subscriptions:
c.cancel()
self.subscriptions = []
def getClientClass(self):
return SdrSource.CLIENT_USER
def onStateChange(self, state):
if state in [SdrSource.STATE_STOPPING, SdrSource.STATE_FAILED]:
self.dsp.stop()
elif state == SdrSource.STATE_RUNNING:
self.dsp.start()
def onBusyStateChange(self, state):
pass
class DspManager(csdr.output):
def __init__(self, handler, sdrSource):
self.handler = handler
self.sdrSource = sdrSource
self.metaParser = MetaParser(self.handler)
self.wsjtParser = WsjtParser(self.handler)
self.aprsParser = AprsParser(self.handler)
self.localProps = (
self.sdrSource.getProps()
.collect(
"audio_compression",
"fft_compression",
"digimodes_fft_size",
"csdr_dynamic_bufsize",
"csdr_print_bufsizes",
"csdr_through",
"digimodes_enable",
"samp_rate",
"digital_voice_unvoiced_quality",
"dmr_filter",
"temporary_directory",
"center_freq",
)
.defaults(PropertyManager.getSharedInstance())
)
self.dsp = csdr.dsp(self)
self.dsp.nc_port = self.sdrSource.getPort()
def set_low_cut(cut):
bpf = self.dsp.get_bpf()
bpf[0] = cut
self.dsp.set_bpf(*bpf)
def set_high_cut(cut):
bpf = self.dsp.get_bpf()
bpf[1] = cut
self.dsp.set_bpf(*bpf)
def set_dial_freq(key, value):
freq = self.localProps["center_freq"] + self.localProps["offset_freq"]
self.wsjtParser.setDialFrequency(freq)
self.aprsParser.setDialFrequency(freq)
self.metaParser.setDialFrequency(freq)
self.subscriptions = [
self.localProps.getProperty("audio_compression").wire(self.dsp.set_audio_compression),
self.localProps.getProperty("fft_compression").wire(self.dsp.set_fft_compression),
self.localProps.getProperty("digimodes_fft_size").wire(self.dsp.set_secondary_fft_size),
self.localProps.getProperty("samp_rate").wire(self.dsp.set_samp_rate),
self.localProps.getProperty("output_rate").wire(self.dsp.set_output_rate),
self.localProps.getProperty("offset_freq").wire(self.dsp.set_offset_freq),
self.localProps.getProperty("squelch_level").wire(self.dsp.set_squelch_level),
self.localProps.getProperty("low_cut").wire(set_low_cut),
self.localProps.getProperty("high_cut").wire(set_high_cut),
self.localProps.getProperty("mod").wire(self.dsp.set_demodulator),
self.localProps.getProperty("digital_voice_unvoiced_quality").wire(self.dsp.set_unvoiced_quality),
self.localProps.getProperty("dmr_filter").wire(self.dsp.set_dmr_filter),
self.localProps.getProperty("temporary_directory").wire(self.dsp.set_temporary_directory),
self.localProps.collect("center_freq", "offset_freq").wire(set_dial_freq),
]
self.dsp.set_offset_freq(0)
self.dsp.set_bpf(-4000, 4000)
self.dsp.csdr_dynamic_bufsize = self.localProps["csdr_dynamic_bufsize"]
self.dsp.csdr_print_bufsizes = self.localProps["csdr_print_bufsizes"]
self.dsp.csdr_through = self.localProps["csdr_through"]
if self.localProps["digimodes_enable"]:
def set_secondary_mod(mod):
if mod == False:
mod = None
self.dsp.set_secondary_demodulator(mod)
if mod is not None:
self.handler.write_secondary_dsp_config(
{
"secondary_fft_size": self.localProps["digimodes_fft_size"],
"if_samp_rate": self.dsp.if_samp_rate(),
"secondary_bw": self.dsp.secondary_bw(),
}
)
self.subscriptions += [
self.localProps.getProperty("secondary_mod").wire(set_secondary_mod),
self.localProps.getProperty("secondary_offset_freq").wire(self.dsp.set_secondary_offset_freq),
]
self.sdrSource.addClient(self)
super().__init__()
def start(self):
if self.sdrSource.isAvailable():
self.dsp.start()
def receive_output(self, t, read_fn):
logger.debug("adding new output of type %s", t)
writers = {
"audio": self.handler.write_dsp_data,
"smeter": self.handler.write_s_meter_level,
"secondary_fft": self.handler.write_secondary_fft,
"secondary_demod": self.handler.write_secondary_demod,
"meta": self.metaParser.parse,
"wsjt_demod": self.wsjtParser.parse,
"packet_demod": self.aprsParser.parse,
}
write = writers[t]
threading.Thread(target=self.pump(read_fn, write)).start()
def stop(self):
self.dsp.stop()
self.sdrSource.removeClient(self)
for sub in self.subscriptions:
sub.cancel()
self.subscriptions = []
def setProperty(self, prop, value):
self.localProps.getProperty(prop).setValue(value)
def getClientClass(self):
return SdrSource.CLIENT_USER
def onStateChange(self, state):
if state == SdrSource.STATE_RUNNING:
logger.debug("received STATE_RUNNING, attempting DspSource restart")
self.dsp.start()
elif state == SdrSource.STATE_STOPPING:
logger.debug("received STATE_STOPPING, shutting down DspSource")
self.dsp.stop()
elif state == SdrSource.STATE_FAILED:
logger.debug("received STATE_FAILED, shutting down DspSource")
self.dsp.stop()
self.handler.handleSdrFailure("sdr device failed")
def onBusyStateChange(self, state):
pass
class CpuUsageThread(threading.Thread):
sharedInstance = None
@staticmethod
def getSharedInstance():
if CpuUsageThread.sharedInstance is None:
CpuUsageThread.sharedInstance = CpuUsageThread()
return CpuUsageThread.sharedInstance
def __init__(self):
self.clients = []
self.doRun = True
self.last_worktime = 0
self.last_idletime = 0
self.endEvent = threading.Event()
super().__init__()
def run(self):
while self.doRun:
try:
cpu_usage = self.get_cpu_usage()
except:
cpu_usage = 0
for c in self.clients:
c.write_cpu_usage(cpu_usage)
self.endEvent.wait(timeout=3)
logger.debug("cpu usage thread shut down")
def get_cpu_usage(self):
try:
f = open("/proc/stat", "r")
except:
return 0 # Workaround, possibly we're on a Mac
line = ""
while not "cpu " in line:
line = f.readline()
f.close()
spl = line.split(" ")
worktime = int(spl[2]) + int(spl[3]) + int(spl[4])
idletime = int(spl[5])
dworktime = worktime - self.last_worktime
didletime = idletime - self.last_idletime
rate = float(dworktime) / (didletime + dworktime)
self.last_worktime = worktime
self.last_idletime = idletime
if self.last_worktime == 0:
return 0
return rate
def add_client(self, c):
self.clients.append(c)
if not self.is_alive():
self.start()
def remove_client(self, c):
try:
self.clients.remove(c)
except ValueError:
pass
if not self.clients:
self.shutdown()
def shutdown(self):
CpuUsageThread.sharedInstance = None
self.doRun = False
self.endEvent.set()
class TooManyClientsException(Exception):
pass
class ClientRegistry(object):
sharedInstance = None
creationLock = threading.Lock()
@staticmethod
def getSharedInstance():
with ClientRegistry.creationLock:
if ClientRegistry.sharedInstance is None:
ClientRegistry.sharedInstance = ClientRegistry()
return ClientRegistry.sharedInstance
def __init__(self):
self.clients = []
Metrics.getSharedInstance().addMetric("openwebrx.users", DirectMetric(self.clientCount))
super().__init__()
def broadcast(self):
n = self.clientCount()
for c in self.clients:
c.write_clients(n)
def addClient(self, client):
pm = PropertyManager.getSharedInstance()
if len(self.clients) >= pm["max_clients"]:
raise TooManyClientsException()
self.clients.append(client)
self.broadcast()
def clientCount(self):
return len(self.clients)
def removeClient(self, client):
try:
self.clients.remove(client)
except ValueError:
pass
self.broadcast()

291
owrx/source/__init__.py Normal file
View File

@ -0,0 +1,291 @@
from owrx.config import PropertyManager
import threading
import subprocess
import os
import socket
import shlex
import time
import signal
from abc import ABC, abstractmethod
from owrx.command import CommandMapper
from owrx.socket import getAvailablePort
import logging
logger = logging.getLogger(__name__)
class SdrSource(ABC):
STATE_STOPPED = 0
STATE_STARTING = 1
STATE_RUNNING = 2
STATE_STOPPING = 3
STATE_TUNING = 4
STATE_FAILED = 5
BUSYSTATE_IDLE = 0
BUSYSTATE_BUSY = 1
CLIENT_INACTIVE = 0
CLIENT_BACKGROUND = 1
CLIENT_USER = 2
def __init__(self, id, props):
self.id = id
self.props = props
self.profile_id = None
self.activateProfile()
self.rtlProps = self.props.collect(*self.getEventNames()).defaults(PropertyManager.getSharedInstance())
self.wireEvents()
self.commandMapper = None
if "port" in props and props["port"] is not None:
self.port = props["port"]
else:
self.port = getAvailablePort()
self.monitor = None
self.clients = []
self.spectrumClients = []
self.spectrumThread = None
self.process = None
self.modificationLock = threading.Lock()
self.failed = False
self.state = SdrSource.STATE_STOPPED
self.busyState = SdrSource.BUSYSTATE_IDLE
if self.isAlwaysOn():
self.start()
def isAlwaysOn(self):
return "always-on" in self.props and self.props["always-on"]
def getEventNames(self):
return [
"samp_rate",
"center_freq",
"ppm",
"rf_gain",
"lfo_offset",
]
def getCommandMapper(self):
if self.commandMapper is None:
self.commandMapper = CommandMapper()
return self.commandMapper
@abstractmethod
def onPropertyChange(self, name, value):
pass
def wireEvents(self):
self.rtlProps.wire(self.onPropertyChange)
def getCommand(self):
return [self.getCommandMapper().map(self.getCommandValues())]
def activateProfile(self, profile_id=None):
profiles = self.props["profiles"]
if profile_id is None:
profile_id = list(profiles.keys())[0]
if profile_id not in profiles:
logger.warning("invalid profile %s for sdr %s. ignoring", profile_id, self.id)
return
if profile_id == self.profile_id:
return
logger.debug("activating profile {0}".format(profile_id))
self.profile_id = profile_id
profile = profiles[profile_id]
self.props["profile_id"] = profile_id
for (key, value) in profile.items():
# skip the name, that would overwrite the source name.
if key == "name":
continue
self.props[key] = value
def getId(self):
return self.id
def getProfileId(self):
return self.profile_id
def getProfiles(self):
return self.props["profiles"]
def getName(self):
return self.props["name"]
def getProps(self):
return self.props
def getPort(self):
return self.port
def getCommandValues(self):
dict = self.rtlProps.collect(*self.getEventNames()).__dict__()
if "lfo_offset" in dict and dict["lfo_offset"] is not None:
dict["tuner_freq"] = dict["center_freq"] + dict["lfo_offset"]
else:
dict["tuner_freq"] = dict["center_freq"]
return dict
def start(self):
with self.modificationLock:
if self.monitor:
return
try:
self.preStart()
except Exception:
logger.exception("Exception during preStart()")
cmd = self.getCommand()
cmd = [c for c in cmd if c is not None]
# don't use shell mode for commands without piping
if len(cmd) > 1:
# multiple commands with pipes
cmd = "|".join(cmd)
self.process = subprocess.Popen(cmd, shell=True, start_new_session=True)
else:
# single command
cmd = cmd[0]
# start_new_session can go as soon as there's no piped commands left
# the os.killpg call must be replaced with something more reasonable at the same time
self.process = subprocess.Popen(shlex.split(cmd), start_new_session=True)
logger.info("Started sdr source: " + cmd)
available = False
def wait_for_process_to_end():
rc = self.process.wait()
logger.debug("shut down with RC={0}".format(rc))
self.monitor = None
self.monitor = threading.Thread(target=wait_for_process_to_end)
self.monitor.start()
retries = 1000
while retries > 0:
retries -= 1
if self.monitor is None:
break
testsock = socket.socket()
try:
testsock.connect(("127.0.0.1", self.getPort()))
testsock.close()
available = True
break
except:
time.sleep(0.1)
if not available:
self.failed = True
try:
self.postStart()
except Exception:
logger.exception("Exception during postStart()")
self.failed = True
self.setState(SdrSource.STATE_FAILED if self.failed else SdrSource.STATE_RUNNING)
def preStart(self):
"""
override this method in subclasses if there's anything to be done before starting up the actual SDR
"""
pass
def postStart(self):
"""
override this method in subclasses if there's things to do after the actual SDR has started up
"""
pass
def isAvailable(self):
return self.monitor is not None
def isFailed(self):
return self.failed
def stop(self):
self.setState(SdrSource.STATE_STOPPING)
with self.modificationLock:
if self.process is not None:
try:
os.killpg(os.getpgid(self.process.pid), signal.SIGTERM)
except ProcessLookupError:
# been killed by something else, ignore
pass
if self.monitor:
self.monitor.join()
self.setState(SdrSource.STATE_STOPPED)
def hasClients(self, *args):
clients = [c for c in self.clients if c.getClientClass() in args]
return len(clients) > 0
def addClient(self, c):
self.clients.append(c)
hasUsers = self.hasClients(SdrSource.CLIENT_USER)
hasBackgroundTasks = self.hasClients(SdrSource.CLIENT_BACKGROUND)
if hasUsers or hasBackgroundTasks:
self.start()
self.setBusyState(SdrSource.BUSYSTATE_BUSY if hasUsers else SdrSource.BUSYSTATE_IDLE)
def removeClient(self, c):
try:
self.clients.remove(c)
except ValueError:
pass
# no need to check for users if we are always-on
if self.isAlwaysOn():
return
hasUsers = self.hasClients(SdrSource.CLIENT_USER)
hasBackgroundTasks = self.hasClients(SdrSource.CLIENT_BACKGROUND)
self.setBusyState(SdrSource.BUSYSTATE_BUSY if hasUsers else SdrSource.BUSYSTATE_IDLE)
if not hasUsers and not hasBackgroundTasks:
self.stop()
def addSpectrumClient(self, c):
self.spectrumClients.append(c)
if self.spectrumThread is None:
# local import due to circular depencency
from owrx.fft import SpectrumThread
self.spectrumThread = SpectrumThread(self)
self.spectrumThread.start()
def removeSpectrumClient(self, c):
try:
self.spectrumClients.remove(c)
except ValueError:
pass
if not self.spectrumClients and self.spectrumThread is not None:
self.spectrumThread.stop()
self.spectrumThread = None
def writeSpectrumData(self, data):
for c in self.spectrumClients:
c.write_spectrum_data(data)
def getState(self):
return self.state
def setState(self, state):
if state == self.state:
return
self.state = state
for c in self.clients:
c.onStateChange(state)
def setBusyState(self, state):
if state == self.busyState:
return
self.busyState = state
for c in self.clients:
c.onBusyStateChange(state)

13
owrx/source/airspy.py Normal file
View File

@ -0,0 +1,13 @@
from owrx.command import Flag
from .soapy import SoapyConnectorSource
class AirspySource(SoapyConnectorSource):
def getCommandMapper(self):
return super().getCommandMapper().setMappings({"bias_tee": Flag("-t biastee=true")})
def getDriver(self):
return "airspy"
def getEventNames(self):
return super().getEventNames() + ["bias_tee"]

6
owrx/source/airspyhf.py Normal file
View File

@ -0,0 +1,6 @@
from .soapy import SoapyConnectorSource
class AirspyhfSource(SoapyConnectorSource):
def getDriver(self):
return "airspyhf"

74
owrx/source/connector.py Normal file
View File

@ -0,0 +1,74 @@
from . import SdrSource
from owrx.socket import getAvailablePort
import socket
from owrx.command import CommandMapper, Flag, Option
import logging
logger = logging.getLogger(__name__)
class ConnectorSource(SdrSource):
def __init__(self, id, props):
self.controlSocket = None
self.controlPort = getAvailablePort()
super().__init__(id, props)
def getCommandMapper(self):
return super().getCommandMapper().setMappings(
{
"samp_rate": Option("-s"),
"tuner_freq": Option("-f"),
"port": Option("-p"),
"controlPort": Option("-c"),
"device": Option("-d"),
"iqswap": Flag("-i"),
"rtltcp_compat": Flag("-r"),
"ppm": Option("-P"),
"rf_gain": Option("-g"),
}
)
def getEventNames(self):
return super().getEventNames() + [
"device",
"iqswap",
"rtltcp_compat",
]
def sendControlMessage(self, prop, value):
logger.debug("sending property change over control socket: {0} changed to {1}".format(prop, value))
self.controlSocket.sendall("{prop}:{value}\n".format(prop=prop, value=value).encode())
def onPropertyChange(self, prop, value):
if self.monitor is None:
return
if (
(prop == "center_freq" or prop == "lfo_offset")
and "lfo_offset" in self.rtlProps
and self.rtlProps["lfo_offset"] is not None
):
freq = self.rtlProps["center_freq"] + self.rtlProps["lfo_offset"]
self.sendControlMessage("center_freq", freq)
else:
self.sendControlMessage(prop, value)
def postStart(self):
logger.debug("opening control socket...")
self.controlSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.controlSocket.connect(("localhost", self.controlPort))
def stop(self):
super().stop()
if self.controlSocket:
self.controlSocket.close()
self.controlSocket = None
def getControlPort(self):
return self.controlPort
def getCommandValues(self):
values = super().getCommandValues()
values["port"] = self.getPort()
values["controlPort"] = self.getControlPort()
return values

54
owrx/source/direct.py Normal file
View File

@ -0,0 +1,54 @@
from abc import ABCMeta
from . import SdrSource
import logging
logger = logging.getLogger(__name__)
class DirectSource(SdrSource, metaclass=ABCMeta):
def onPropertyChange(self, name, value):
logger.debug(
"restarting sdr source due to property change: {0} changed to {1}".format(
name, value
)
)
self.stop()
self.sleepOnRestart()
self.start()
def getEventNames(self):
return super().getEventNames() + [
"nmux_memory",
]
def getNmuxCommand(self):
props = self.rtlProps
nmux_bufcnt = nmux_bufsize = 0
while nmux_bufsize < props["samp_rate"] / 4:
nmux_bufsize += 4096
while nmux_bufsize * nmux_bufcnt < props["nmux_memory"] * 1e6:
nmux_bufcnt += 1
if nmux_bufcnt == 0 or nmux_bufsize == 0:
raise ValueError(
"Error: nmux_bufsize or nmux_bufcnt is zero. "
"These depend on nmux_memory and samp_rate options in config_webrx.py"
)
return ["nmux --bufsize %d --bufcnt %d --port %d --address 127.0.0.1" % (
nmux_bufsize,
nmux_bufcnt,
self.port,
)]
def getCommand(self):
return super().getCommand() + self.getFormatConversion() + self.getNmuxCommand()
# override this in subclasses, if necessary
def getFormatConversion(self):
return []
# override this in subclasses, if necessary
def sleepOnRestart(self):
pass

36
owrx/source/fifi_sdr.py Normal file
View File

@ -0,0 +1,36 @@
from owrx.command import Option
from .direct import DirectSource
from subprocess import Popen
import logging
logger = logging.getLogger(__name__)
class FifiSdrSource(DirectSource):
def getCommandMapper(self):
return super().getCommandMapper().setBase("arecord").setMappings(
{"device": Option("-D"), "samp_rate": Option("-r")}
).setStatic("-f S16_LE -c2 -")
def getEventNames(self):
return super().getEventNames() + ["device"]
def getFormatConversion(self):
return ["csdr convert_s16_f", "csdr gain_ff 30"]
def sendRockProgFrequency(self, frequency):
process = Popen(["rockprog", "--vco", "-w", "--", "freq={}".format(frequency / 1E6)])
process.communicate()
rc = process.wait()
if rc != 0:
logger.warning("rockprog failed to set frequency; rc=%i", rc)
def preStart(self):
values = self.getCommandValues()
self.sendRockProgFrequency(values["tuner_freq"])
def onPropertyChange(self, name, value):
if name != "center_freq":
return
self.sendRockProgFrequency(value)

24
owrx/source/hackrf.py Normal file
View File

@ -0,0 +1,24 @@
from .direct import DirectSource
from owrx.command import Flag, Option
class HackrfSource(DirectSource):
def getCommandMapper(self):
return super().getCommandMapper().setBase("hackrf_transfer").setMappings(
{
"samp_rate": Option("-s"),
"tuner_freq": Option("-f"),
"rf_gain": Option("-g"),
"lna_gain": Option("-l"),
"rf_amp": Option("-a"),
}
).setStatic("-r-")
def getEventNames(self):
return super().getEventNames() + [
"lna_gain",
"rf_amp",
]
def getFormatConversion(self):
return ["csdr convert_s8_f"]

6
owrx/source/lime_sdr.py Normal file
View File

@ -0,0 +1,6 @@
from .soapy import SoapyConnectorSource
class LimeSdrSource(SoapyConnectorSource):
def getDriver(self):
return "lime"

6
owrx/source/pluto_sdr.py Normal file
View File

@ -0,0 +1,6 @@
from .soapy import SoapyConnectorSource
class PlutoSdrSource(SoapyConnectorSource):
def getDriver(self):
return "plutosdr"

40
owrx/source/resampler.py Normal file
View File

@ -0,0 +1,40 @@
from .direct import DirectSource
from . import SdrSource
import subprocess
import threading
import os
import socket
import time
import logging
logger = logging.getLogger(__name__)
class Resampler(DirectSource):
def onPropertyChange(self, name, value):
logger.warning("Resampler is unable to handle property change ({0} changed to {1})".format(name, value))
def __init__(self, props, sdr):
sdrProps = sdr.getProps()
self.shift = (sdrProps["center_freq"] - props["center_freq"]) / sdrProps["samp_rate"]
self.decimation = int(float(sdrProps["samp_rate"]) / props["samp_rate"])
if_samp_rate = sdrProps["samp_rate"] / self.decimation
self.transition_bw = 0.15 * (if_samp_rate / float(sdrProps["samp_rate"]))
props["samp_rate"] = if_samp_rate
self.sdr = sdr
super().__init__(None, props)
def getCommand(self):
return [
"nc -v 127.0.0.1 {nc_port}".format(nc_port=self.sdr.getPort()),
"csdr shift_addition_cc {shift}".format(shift=self.shift),
"csdr fir_decimate_cc {decimation} {ddc_transition_bw} HAMMING".format(
decimation=self.decimation, ddc_transition_bw=self.transition_bw
),
] + self.getNmuxCommand()
def activateProfile(self, profile_id=None):
logger.warning("Resampler does not support setting profiles")
pass

6
owrx/source/rtl_sdr.py Normal file
View File

@ -0,0 +1,6 @@
from .connector import ConnectorSource
class RtlSdrSource(ConnectorSource):
def getCommandMapper(self):
return super().getCommandMapper().setBase("rtl_connector")

Some files were not shown because too many files have changed in this diff Show More