Compare commits

...

186 Commits

Author SHA1 Message Date
KF7EEL be1c306af8
Update README.md 2021-09-05 19:24:34 -07:00
KF7EEL 421a0ddc49
Update README.md 2021-04-29 11:55:38 -07:00
KF7EEL e97e5cff32 fix dashboard logging bug 2021-03-11 17:54:38 -08:00
KF7EEL 7f46a19749 improve PIN write to user_settings 2021-03-11 08:40:55 -08:00
KF7EEL e6ace9e72d fix missing code from bridge_gps_data.py 2021-03-11 08:02:24 -08:00
KF7EEL 1fb22d01c6 Merge branch 'gps' of https://github.com/kf7eel/hblink3 into gps 2021-03-11 07:52:43 -08:00
KF7EEL 4e0c87dac9 fix config.py, add editing of user settings to dashboard, limit number of stored locations per user 2021-03-11 07:52:06 -08:00
KF7EEL ef850596d1
cap positions on map at 15 for station view 2021-03-05 08:15:42 -08:00
KF7EEL 247168d567
fix typo 2021-03-05 07:27:25 -08:00
KF7EEL 6a6fdf367a
correct condition 2021-03-05 07:20:07 -08:00
KF7EEL b860dc75ba
pass on blank addrersse messages 2021-03-05 07:15:58 -08:00
KF7EEL 6cc6f7fc81
fix exception 2021-03-04 17:15:37 -08:00
KF7EEL 873bbb6ce7
fix bug again 2021-03-04 16:55:17 -08:00
KF7EEL 2e5dec5cac fix bugs 2021-03-04 16:31:54 -08:00
KF7EEL 239c0730c0 fix incorrect config 2021-03-04 15:17:51 -08:00
KF7EEL fcff610fd3 fix bugs, add user settings to config 2021-03-04 15:16:03 -08:00
KF7EEL 6a1476af51
Update gps_data-SAMPLE.cfg 2021-03-04 13:57:10 -08:00
KF7EEL 295dfbda1f rewrite dahboard config, update APRS receive 2021-03-04 12:36:45 -08:00
KF7EEL e61f90fcfd initial untested receive script 2021-03-03 16:42:01 -08:00
KF7EEL 599f549ab9 add dashboard APRS message hook 2021-03-03 16:36:25 -08:00
KF7EEL 65ab256b7f fix dashboard SOS bug 2021-03-02 14:04:42 -08:00
KF7EEL 104cab1c29 fix typo 2021-03-02 13:46:12 -08:00
KF7EEL eded346f91 fix typo 2021-03-02 13:41:40 -08:00
KF7EEL a91eb65273 make mailbox file persistent 2021-03-02 13:40:03 -08:00
KF7EEL 5b1e250d57 fix exception in map view 2021-03-02 12:56:24 -08:00
KF7EEL d332604f26 add comment to map plots 2021-03-02 12:41:03 -08:00
KF7EEL 888d8c19b7 fix typos 2021-03-01 20:24:37 -08:00
KF7EEL cb47556205 switch to UNIX time 2021-03-01 20:11:32 -08:00
KF7EEL f8cdf8fead minor improvement, remove user_settings.html 2021-03-01 18:16:49 -08:00
KF7EEL d0e90531c6 fix mailbox parsing 2021-03-01 16:50:55 -08:00
KF7EEL dccf561e3d add generic template 2021-03-01 16:41:36 -08:00
KF7EEL 751af20357 update help 2021-03-01 16:39:48 -08:00
KF7EEL 12dc612c2e add mailbox feature 2021-03-01 15:58:09 -08:00
KF7EEL dfedf9eade add generic template to dashboard 2021-03-01 14:18:51 -08:00
KF7EEL ee7c7eccf1 add user setting query, improve dashboard 2021-03-01 13:52:22 -08:00
KF7EEL f4010939dc increase number of BB entries in RSS 2021-02-28 20:01:29 -08:00
KF7EEL 9b19a09eac limit map size on track screen 2021-02-28 19:48:42 -08:00
KF7EEL 89176e922c add option for map theme 2021-02-28 17:27:08 -08:00
KF7EEL 7febe66a76 add notice function as an alternative to emergency 2021-02-28 17:01:32 -08:00
KF7EEL ce36850621 use internal map rather than aprs.fi 2021-02-28 16:17:58 -08:00
KF7EEL 3368683a1f update emergency function 2021-02-28 14:37:23 -08:00
KF7EEL d84e937c1f add emergency feature 2021-02-28 13:47:02 -08:00
KF7EEL ec82ce8b24 add bulletin board rss, correct spelling of bulletin 2021-02-28 12:25:19 -08:00
KF7EEL 40a3030694 update map look and feel 2021-02-28 10:51:39 -08:00
KF7EEL f68c5d0691 improve map 2021-02-27 15:44:14 -08:00
KF7EEL bf9b45d44f fix map template 2021-02-27 15:11:09 -08:00
KF7EEL fb9226e04f add tracking to map 2021-02-27 14:57:48 -08:00
KF7EEL b00ba9ea62 improve map plotting 2021-02-27 06:55:48 -08:00
KF7EEL 9b14982abe improve map and dashboard 2021-02-26 23:30:49 -08:00
KF7EEL 61fd13514b increase positions logged 2021-02-26 21:51:42 -08:00
KF7EEL 77309d5ca6 Merge branch 'gps' of https://github.com/kf7eel/hblink3 into gps 2021-02-26 21:17:33 -08:00
KF7EEL db77a165b4 add map to dashboard 2021-02-26 21:17:06 -08:00
KF7EEL 83274856a3
Update README.md 2021-02-26 18:50:02 -08:00
KF7EEL 72ed9f2d2b
remove aprs_upload calls
Accidentally added aprs calls from aprs_features branch
2021-02-26 13:45:06 -08:00
KF7EEL 1b904e9af7 improve regexp for APRS messages 2021-02-26 13:40:44 -08:00
KF7EEL db068d859e add exception logging 2021-02-26 10:49:54 -08:00
KF7EEL 74ca23af73 add example config for combined application 2021-02-08 12:38:45 -08:00
KF7EEL 76cadf01a4 fix typo 2021-02-07 15:02:52 -08:00
KF7EEL ccd197a8c1 add combined bridge/D-APRS 2021-02-07 13:52:03 -08:00
KF7EEL 1a96434c78 fix typo 2021-02-04 12:58:16 -08:00
KF7EEL 3047b55bcc add 14FRS2013 contributions, add both option for call type 2021-02-04 12:45:14 -08:00
KF7EEL 21a0c95ad3 add option to disable APRS upload 2021-02-04 10:06:09 -08:00
Roby 08f53ee1a4
Update help.html (#22)
Add new commands
2021-02-03 13:37:54 -08:00
KF7EEL 82ce4995ae Merge branch 'gps' of https://github.com/kf7eel/hblink3 into gps 2021-02-02 12:04:19 -08:00
KF7EEL dc5dbc0f7f fix typo for GNRMC 2021-02-02 12:04:03 -08:00
KF7EEL 85d085d563
Update README.md 2021-02-02 11:57:24 -08:00
KF7EEL 5e349a9705 Merge branch 'gps' of https://github.com/kf7eel/hblink3 into gps 2021-02-02 11:36:17 -08:00
KF7EEL 664cc46b63 potential fix for RT73 2021-02-02 11:35:56 -08:00
KF7EEL 45dca64490
Update README.md 2021-02-01 17:31:19 -08:00
KF7EEL bc8bb8b298
Update README.md 2021-02-01 17:29:35 -08:00
KF7EEL 40fa5372ce
change email syntax, bug fix 2021-02-01 17:28:11 -08:00
KF7EEL 586533ac4c
Update README.md 2021-02-01 07:32:55 -08:00
KF7EEL f99451b0a4
Update gps_data-SAMPLE.cfg 2021-01-31 12:56:48 -08:00
KF7EEL afb249c418 fix bugs 2021-01-31 12:45:43 -08:00
KF7EEL a750dedab0 Merge branch 'gps' of https://github.com/kf7eel/hblink3 into gps 2021-01-31 12:36:35 -08:00
KF7EEL 84f7baf9b4
Update requirements.txt 2021-01-31 12:35:22 -08:00
KF7EEL fccbdc908c
Update README.md 2021-01-31 12:34:58 -08:00
KF7EEL 2affa319d4
Update README.md 2021-01-31 12:33:57 -08:00
KF7EEL 54f4ad799e imrove email template 2021-01-31 11:55:09 -08:00
KF7EEL 372bb845b2 add email sending 2021-01-31 11:42:15 -08:00
KF7EEL fcb0f1bd05 fix manual positions 2021-01-31 09:17:45 -08:00
KF7EEL 14f4eafa6e
Update footer.html 2021-01-30 11:22:53 -08:00
KF7EEL bebf487936
Update help.html 2021-01-30 11:18:28 -08:00
KF7EEL 9def4fbfec
Update help.html 2021-01-30 09:58:10 -08:00
KF7EEL 33f499a32a
Update gps_data.py 2021-01-30 09:15:18 -08:00
KF7EEL 2d94dbe045 fix MD-380 and SMS positions 2021-01-26 08:54:48 -08:00
KF7EEL 0b5ecaa04f
Update README.md 2021-01-21 15:50:47 -08:00
KF7EEL becbffed8e
Update README.md 2021-01-12 14:23:54 -08:00
KF7EEL 24e5329ac7 add sending messages to APRS 2021-01-12 13:54:53 -08:00
KF7EEL e7b76acaff fix typo 2021-01-12 10:00:38 -08:00
KF7EEL c9b9c307d6 add GNRMC to filter to allow RT73 compatability 2021-01-12 09:56:17 -08:00
M0GLJ 22d371a8f6
Update README.md (#19)
Model Correction
2021-01-10 10:01:49 -08:00
KF7EEL f81e5dae78
Update README.md 2021-01-08 10:19:28 -08:00
KF7EEL bd4bb0b611
Change example to allow D-APRS out of the box 2021-01-07 15:10:34 -08:00
KF7EEL d76a808e4a
Update gps_data.py 2021-01-06 11:31:22 -08:00
KF7EEL e6e9600e73 fix grammar 2021-01-02 18:13:35 -08:00
KF7EEL 22e04f6ff3 fix dash width 2021-01-02 18:02:55 -08:00
KF7EEL a943748c94 fix missing templates 2021-01-02 16:17:34 -08:00
KF7EEL 674f9102d1 improve dash 2021-01-02 15:58:45 -08:00
KF7EEL 3dde015e5d Merge branch 'gps' of https://github.com/kf7eel/hblink3 into gps 2021-01-02 14:58:58 -08:00
KF7EEL 3b36b44c5d add page, split header and footer 2021-01-02 14:58:38 -08:00
KF7EEL e4ef4383fe
Update gps_data-SAMPLE.cfg 2021-01-02 08:46:56 -08:00
KF7EEL f2675d885c clean up pages 2021-01-01 15:10:12 -08:00
KF7EEL 105f4bdc7a fix html 2021-01-01 14:46:05 -08:00
KF7EEL 1df3026a59 update dashboard theme 2021-01-01 14:44:08 -08:00
KF7EEL 79fe60fc3f add about page 2021-01-01 14:35:15 -08:00
KF7EEL 3a3f4719a0 fix description yet again 2021-01-01 14:16:57 -08:00
KF7EEL dcc1b4ff40 fix description again 2021-01-01 14:15:43 -08:00
KF7EEL e753f4f56b fix description location 2021-01-01 14:12:38 -08:00
KF7EEL 215af2ea6c add description to dashboard 2021-01-01 14:09:14 -08:00
KF7EEL 944e3bf1af
Update requirements.txt 2021-01-01 13:51:45 -08:00
M0GLJ ecba8f75bd
Added install.sh and appended requirements.txt (#16)
* Create install.sh

* Update requirements.txt

Add additional for gps operation
2021-01-01 13:51:20 -08:00
M0GLJ 1af61d184a
Update README.md (#17) 2021-01-01 13:50:21 -08:00
KF7EEL f411531bd0 Merge branch 'gps' of https://github.com/kf7eel/hblink3 into gps 2021-01-01 09:58:33 -08:00
KF7EEL 15111563ed fix bug, improve index template 2021-01-01 09:58:13 -08:00
KF7EEL b6adc461c6
Update README.md 2021-01-01 09:43:19 -08:00
KF7EEL 6fc4dcfe27
Update README.md 2021-01-01 09:37:22 -08:00
KF7EEL 8cb40cbe2c add host to dashboard 2020-12-30 16:41:51 -08:00
KF7EEL 7cd73740b4 add port settings 2020-12-30 09:35:25 -08:00
KF7EEL 6da1c4de0d update web dashboard, add template 2020-12-30 09:10:23 -08:00
KF7EEL e4b55b05fe basic functioning web dashboard 2020-12-29 20:36:07 -08:00
KF7EEL 54bdbd72e8 Merge branch 'gps' of https://github.com/kf7eel/hblink3 into gps
add backend code for upcoming web dashboard
2020-12-27 20:39:42 -08:00
KF7EEL 3a8e111443 add backend code for upcoming web dashboard 2020-12-27 20:39:17 -08:00
KF7EEL a04f8e8cc3
Update README.md 2020-12-27 08:33:02 -08:00
KF7EEL 350b366ffd
Update README.md 2020-12-26 15:30:58 -08:00
KF7EEL 636246c664
Update README.md 2020-12-26 14:47:52 -08:00
KF7EEL 2a752487d0 add UDT SAP requirement to reduce fake packets 2020-12-26 14:31:11 -08:00
KF7EEL c6ebf86b0f add UDT UAB criteria to reduce inaccurate packets 2020-12-26 13:43:19 -08:00
KF7EEL 4900f859f8 fix parse bug, md-380 working again 2020-12-26 12:53:50 -08:00
KF7EEL 17999eb3f4 fix typo 2020-12-26 10:38:03 -08:00
KF7EEL c09d2ea734 fix hdr_type error for non MD-380 radios 2020-12-26 09:59:08 -08:00
KF7EEL 84eaaf70f7 remove code from accidental commit 2020-12-24 13:53:44 -08:00
KF7EEL a0d49b5175
Update README.md 2020-12-23 22:59:52 -08:00
KF7EEL 423d269e78
Update README.md 2020-12-23 22:53:23 -08:00
KF7EEL 9c73c70d71 fix typo in gps_data.py 2020-12-23 16:09:45 -08:00
KF7EEL 11e5aba3fc fix typo 2020-12-23 15:27:59 -08:00
KF7EEL f6a501a42e initial commit for MD-380 type radios 2020-12-23 15:19:10 -08:00
KF7EEL 6902b3bd4c fix beacon time to minutes 2020-12-11 13:05:59 -08:00
KF7EEL fe1daeb406 add APRS beacon script for gps_data 2020-12-11 12:49:34 -08:00
KF7EEL 76ad6adea4 add APRS beacon script for gps_data 2020-12-11 12:47:43 -08:00
KF7EEL 542e7496ca fix import time 2020-12-06 16:39:05 -08:00
KF7EEL 05a90944e2 add official tocall, add timestamp, and hook for MD-380 GPS 2020-12-06 12:30:20 -08:00
KF7EEL 804cb1c025
Update README.md 2020-12-01 13:35:32 -08:00
KF7EEL b2fda94746
Update README.md 2020-12-01 13:34:39 -08:00
KF7EEL 6d934096aa
Update README.md 2020-12-01 13:21:26 -08:00
KF7EEL a583ff92d2 parse all SMS for command string instead of header 2020-12-01 12:15:17 -08:00
KF7EEL 43e6e6d6b1 change handling of unknown SMS 2020-12-01 09:15:57 -08:00
KF7EEL 579ba3d282 add ETSI like SMS 2020-11-30 17:25:33 -08:00
KF7EEL 5c8be7c177 add debug statements 2020-11-30 14:08:33 -08:00
KF7EEL 28a2e7ba70 APRS position via SMS for grid square 2020-11-30 12:38:50 -08:00
KF7EEL b47d70142d
Update README.md 2020-11-30 10:03:59 -08:00
KF7EEL 896ba4fbae change file read, move global declaration 2020-11-30 09:59:15 -08:00
KF7EEL d202f4d0ce fix group SMS for Motorola, fix typo 2020-11-29 15:36:44 -08:00
KF7EEL 4beaf3000d added blank variables to attempt to fix bug 2020-11-29 15:08:53 -08:00
KF7EEL 7e19e705ef
Update README.md 2020-11-28 23:53:53 -08:00
KF7EEL 821c57b381
Update README.md 2020-11-28 19:57:37 -08:00
KF7EEL ffdfe55cb8 Merge branch 'gps' of https://github.com/kf7eel/hblink3 into gps 2020-11-28 09:15:26 -08:00
KF7EEL 9e40195161 attempt to fix bug with assembled packets 2020-11-28 09:14:26 -08:00
KF7EEL 7fd8500105
Update README.md 2020-11-27 23:53:22 -08:00
KF7EEL d9e5085765
Update README.md 2020-11-27 09:39:18 -08:00
KF7EEL d7afa94a5a added user settings, added speed and course 2020-11-27 09:31:38 -08:00
KF7EEL 00e3ea840c update readme, sample, and functions 2020-11-26 19:40:43 -08:00
KF7EEL 9dc7ce12e1 fix another bug 2020-11-26 17:44:19 -08:00
KF7EEL a21393313f revert change, remove UNIT_MAP changes 2020-11-26 15:23:33 -08:00
KF7EEL e736893543 time for static unit now generated at start 2020-11-26 11:50:28 -08:00
KF7EEL e88d545955 add hooks in code for shell commands 2020-11-25 15:53:42 -08:00
KF7EEL eca8619153 Merge branch 'gps' of https://github.com/kf7eel/hblink3 into gps 2020-11-25 14:52:41 -08:00
KF7EEL 8e8836057b fix typo for unit calls 2020-11-25 14:50:49 -08:00
KF7EEL 471feee9c3 implement static routes for unit calls 2020-11-25 14:39:28 -08:00
KF7EEL d4e1ebd4ec
Update README.md 2020-11-25 12:35:06 -08:00
KF7EEL ee40ad1e34
Update README.md 2020-11-25 12:17:51 -08:00
KF7EEL 37521fc7f1 implement custom UNIT time 2020-11-25 12:02:58 -08:00
KF7EEL 64ee23788a
Update README.md 2020-11-24 11:56:40 -08:00
KF7EEL c07edcdc91 ensure lat and lon are float 2020-11-23 13:43:54 -08:00
KF7EEL 29fb602fcb
Update README.md 2020-11-23 13:19:04 -08:00
KF7EEL 6b9ae44256 add info to README 2020-11-23 13:15:22 -08:00
KF7EEL 72a9bd015b fix typo again 2020-11-23 12:54:44 -08:00
KF7EEL 0ffd119994 implement basic SMS processing 2020-11-23 12:52:40 -08:00
KF7EEL 0056e1e09e moved config to file 2020-11-23 10:08:31 -08:00
KF7EEL 84dee59b37 fix typo 2020-11-22 22:03:02 -08:00
KF7EEL 696e0bc128 fix typo 2020-11-22 21:58:45 -08:00
KF7EEL f233e50516 fix old data bug 2020-11-22 20:39:45 -08:00
KF7EEL 6293497b61 decode motorola type sms 2020-11-22 18:51:46 -08:00
KF7EEL 6c3cab0827 added debug stuff 2020-11-22 13:55:06 -08:00
KF7EEL 0c6912c55f fix typo 2020-11-22 12:44:52 -08:00
KF7EEL e838fc3423 now using NMEA parser 2020-11-22 12:43:38 -08:00
27 changed files with 5030 additions and 79 deletions

175
README.md
View File

@ -1,3 +1,178 @@
### This project has morphed into HBNet. It is still under heavy development and not ready for production. You can see it [here](https://github.com/kf7eel/hblink3/tree/hbnet). The example/development server can be found at [https://demo.hbnet.xyz](https://demo.hbnet.xyz).
# GPS/Data Application
This repository contains everything needed to decode DMR GPS packets and SMS for HBLink3. This application can act as a master or peer and receive data as a group call or private call. It is designed to work in a multi system/user network.
Files modified from original master branch of HBLink3:
* bridge.py
* config.py
#### Required modules
* pynmea2
* aprslib
* maidenhead
#### Optional Modules
* Flask - Required for dashboard
* smtplib - Required for sending email. If pip fails to install module, it may already be installed as most Linux distributions have this module by default.
* traceback - If pip fails to install module, it may already be installed as most Linux distrobutions have this module by default.
* slixmpp - Required for upcoming XMPP gateway.
* folium - Required for mapping on dashboard.
This should work for DMR radios that send location data as a UTF-8 NMEA sentence. I am hopping to add support for more radios in the future.
### Differences in branches
* **GPS**: Contains the GPS/Data Application.
* **aprs_features**: Contains the GPS/Data Application and a modified version of the APRS implementation for repeaters and hotspots by **IU7IGU**. (See [https://github.com/iu7igu/hblink3-aprs](https://github.com/iu7igu/hblink3-aprs) for his work). I combined these for convenience.
## Confirmed working:
Actually tested
| Radio | GPS | SMS |
|-------|:---:|:---:|
| Anytone D878| YES | YES |
| Anytone D578| YES | YES |
| BTech DMR-6x2 | YES | Most likely |
| MD-380 (MD380tools, no GPS) | - | YES |
| MD-380 (stock firmware, GPS) | YES | Most likely |
| MD-390 (stock firmware) | YES | YES |
| Retevis RT73* | YES | YES |
| Ailunce HD1 | YES | YES |
*RT73 must have unconfirmed data setting enabled.
## Highly suspected to work:
Not tested yet, but will most likely work.
| Radio | GPS | SMS |
|-------|:---:|:---:|
| Anytone D868 | Most likely | Most likely |
| TYT MD-2017 | Most likely | Likely |
| TYT MD-9600 | Most likely | Likely |
| Retevis RT8 | Most likely | Likely |
## Tested, but with issues.
Tested, but with bugs present.
| Radio | GPS | SMS |
|-------|:---:|:---:|
| Alinco DJ-MD5TGP | WIP | Most likely |
| Motorola DP3601| WIP | WIP |
## Would like to test:
Connect Systems GPS enabled radios
## Features
* Decode GPS locations and upload APRS position packets
* Each user/DMR ID can customize APRS position
* Ability to receive data as a private call or group call
* Trigger a command or script via DMR SMS
* Optional web dashboard to show APRS packets uploaded
* Display bulletins sent via SMS on web dashboard
## How it works
A user should configure their radio for the DMR ID of the application and private or group call. When a position is received by the application, it will extract the coordinates and create an APRS position packet. The application will find the callsign of the user based on the sending radio's DMR ID. It is essential to have an up to date subscriber_ids file for this to work. A predefined APRS SSID is appended to the callsign. The APRS location packet is then uploaded to APRS-IS. No setup is required beforehand on the part of the user. This is pretty much "plug and play."
For example, N0CALL has a DMR ID of 1234567. N0CALL's radio sends a position to the application. The application will query the subscriber_ids file for DMR ID 1234567. The result will be N0CALL. An APRS location pack is created and uploaded to APRS-IS.
## Individual user/DMR ID APRS settings
By default, all APRS positions will have an SSID of 15, a default comment, and the callsign of the DMR user. These default settings can be changed.
The comment, SSID, and icon can be set for each individual user/DMR ID the application sees. The application stores all the setting in a file. You may have different SSIDs, icons, and comments for different DMR IDs. This is done via DMR SMS using the following commands:
| Command | Description | Example |
|-------|:---:|:---:|
|**@SSID**|Change SSID of user callsign.|`@SSID 7`|
|**@ICON**|Change the icon of the APRS position. *See [http://aprs.net/vm/DOS/SYMBOLS.HTM](http://aprs.net/vm/DOS/SYMBOLS.HTM) for icon list.|`@icon /p`|
|**@COM**|Change the comment of the APRS.|`@COM This is a test comment.`|
|**@MH**|Set you location by maidenhead grid square. Designed for radios with no GPS or that are not compatable yet.|`@MH DN97uk`|
|**@BB**|Post a bulliten to the web dashboard.|`@BB This is a test bulletin.`|
|**@[CALLSIGN W/ SSID] A-[MESSAGE]**|Send a message to another station via APRS.|`@N0CALL-15 A-This is a test.`|
|**[EMAIL ADDRESS] E-[MESSAGE]**|Send an email to an email address.|`test@example.org E-This is a test.`|
Send a DMR SMS to the configured dmr_data_id in the application with the desired command followed by the value. For example, to change your icon to a dog, the command would be `@ICON /p` (see the icon table for values). Changing your SSID is as simple as `@SSID 7`, and `@COM Testing 123` will change the comment.
Sending `@BB Test` will result in a post to the bulletin board with the messaage of "Test".
**To remove any of the stored values, just send the appropriate command without any input.** `@COM` will remove the stored comment, `@ICON` will remove the stored icon, and `@COM` will remove the strored comment. Any position now reports sent will have the default settings.
## Web Dashboard
The web dashboard is completely optional. Python module flask is required for this to work. The web dashboard will display the last 15 positions of radios sent to APRS-IS. The dashboard will also sh user bulletin. A bulletin is a message sent via SMS that will display on the web dashboard. There are several uses for this, including: testing SMS functionality of radio, announcements, and moire. It is a novel feature. The page will automatically reload every 2 minutes. Setup is rather simple. Just modify the example config in the dashboard directory and rename it to dashboard_settings.py. Then start dashboard.py.
## APRS messaging
**At this time, only sending of messages from DMR SMS to APRS-IS is supported.** I find this feature very pointless because it will only go one way, but someone else may find it important. **Messages from sent from APRS-IS to DMR SMS will not work.** I have not written the code for this yet. It will likley be a long time before this is a possibility.
## APRS TOCALL
The project was granted a [tocall](http://www.aprs.org/aprs11/tocalls.txt) of **APHBLx** by Bob Bruniga, WB4APR. This will identify that your APRS position came from HBLink. The x on the end can be any letter/number. Here are the current designations of APHBLx:
* **APHBL3** - HBlink3 D-APRS gateway
* **APHBLD** - DMRlink D-APRS gateway (the IPSC version of the project)
* **_APHBLS_** - Planned, but not in use: HBLink3 via KISS TNC
## Configuration
See hblink_SAMPLE.cfg, rules_SAMPLE.py, and gps_data_SAMPLE.cfg for examples.
## Special thanks to:
**N0MJS** - For creating HBLink and dmr_utils. This project not possible without him.
**IU7IGU** - For creating APRS position beaconing for PEER connections.
**IV3JDV** - For helping debug SMS in Anytone radios.
**KD7LMN** - For pointing out a critical bug.
**KB5PBM** - For helping implement support for MD-380 type radios.
**EI7IG** - For writing the page explaining MD-380 type GPS packets.
**M0GLJ** - For assisting with Motorola testing.
## Resources for DMR data
I spent many hours looking at the following for this project. You may find these links useful.
https://github.com/travisgoodspeed/md380tools/issues/160
https://jpronans.github.io/ei7ig/dmr.html
http://cloud.dstar.su/files/G4KLX/MMDVM/MMDVM%20Specification%2020150922.pdf
https://wiki.brandmeister.network/index.php/NMEA_Location_Reporting
https://forums.radioreference.com/threads/motorola-lrrp-protocol.370081/
https://forums.radioreference.com/threads/lrrp-decoding.359575/
https://github.com/polkabana/go-dmr
https://github.com/nonoo/dmrshark
https://wiki.brandmeister.network/index.php/Compressed_Location_Reporting
All of the ETSI DMR documents (ETSI 102 361-1 through 361-4).
The Shark RF forums.
---
### FOR SUPPORT, DISCUSSION, GETTING INVOLVED ###

View File

@ -56,6 +56,9 @@ import pickle
import logging
logger = logging.getLogger(__name__)
# Import UNIT time from rules.py
from rules import UNIT_TIME, STATIC_UNIT
# Does anybody read this stuff? There's a PEP somewhere that says I should do this.
__author__ = 'Cortney T. Buffington, N0MJS'
@ -73,6 +76,14 @@ __email__ = 'n0mjs@me.com'
# format 'unit_id': ('SYSTEM', time)
UNIT_MAP = {}
# UNIX time for end of year 2060. This is used to keep subscribers in UNIT_MAP indefinitely to accomplish static routes for unit calls
#time_2060 = 2871763199.0000000
# 20 years in seconds. added to current at time of start to keep static units from being trimmed.
time_20 = 630720000
# Build a UNIT_MAP based on values in STATIC_MAP.
for i in STATIC_UNIT:
UNIT_MAP[bytes_3(i[0])] = i[1], time() + time_20
# Timed loop used for reporting HBP status
#
@ -152,11 +163,12 @@ def rule_timer_loop():
else:
logger.debug('(ROUTER) Conference Bridge NO ACTION: System: %s, Bridge: %s, TS: %s, TGID: %s', _system['SYSTEM'], _bridge, _system['TS'], int_id(_system['TGID']))
_then = _now - 60
_then = _now - 60 * UNIT_TIME
remove_list = []
#logger.info(UNIT_MAP)
for unit in UNIT_MAP:
if UNIT_MAP[unit][1] < (_then):
remove_list.append(unit)
if UNIT_MAP[unit][1] < (_then):
remove_list.append(unit)
for unit in remove_list:
del UNIT_MAP[unit]
@ -427,9 +439,18 @@ class routerOBP(OPENBRIDGE):
pkt_time = time()
dmrpkt = _data[20:53]
_bits = _data[15]
# Check if subscriber is in STATIC_UNIT
for i in STATIC_UNIT:
# Subscriber is static. Add 20 years of time.
if i[0] == int_id(_rf_src):
map_time = pkt_time + time_20
logger.debug('Static Unit, update time.')
# Proceed as normal
else:
map_time = pkt_time
# Make/update this unit in the UNIT_MAP cache
UNIT_MAP[_rf_src] = (self.name, pkt_time)
UNIT_MAP[_rf_src] = (self.name, map_time)
# Is this a new call stream?
@ -575,8 +596,11 @@ class routerOBP(OPENBRIDGE):
self.group_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _frame_type, _dtype_vseq, _stream_id, _data)
elif _call_type == 'unit':
self.unit_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _frame_type, _dtype_vseq, _stream_id, _data)
elif _call_type == 'vscsbk':
logger.debug('CSBK recieved, but HBlink does not process them currently')
elif _call_type == 'vcsbk':
# Route CSBK packets to destination TG. Necessary for group data to work with GPS/Data decoder.
self.group_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _frame_type, _dtype_vseq, _stream_id, _data)
logger.debug('CSBK recieved, but HBlink does not process them currently. Packets routed to talkgroup.')
else:
logger.error('Unknown call type recieved -- not processed')
@ -906,9 +930,20 @@ class routerHBP(HBSYSTEM):
pkt_time = time()
dmrpkt = _data[20:53]
_bits = _data[15]
# Check if subscriber is in STATIC_UNIT
for i in STATIC_UNIT:
# Subscriber is static. Add 20 years of time.
if i[0] == int_id(_rf_src):
map_time = pkt_time + time_20
logger.debug('Static Unit, update time.')
# Proceed as normal
else:
map_time = pkt_time
# Make/update this unit in the UNIT_MAP cache
UNIT_MAP[_rf_src] = (self.name, pkt_time)
UNIT_MAP[_rf_src] = (self.name, map_time)
# Is this a new call stream?

398
bridge_gps_data-SAMPLE.cfg Normal file
View File

@ -0,0 +1,398 @@
# PROGRAM-WIDE PARAMETERS GO HERE
# PATH - working path for files, leave it alone unless you NEED to change it
# PING_TIME - the interval that peers will ping the master, and re-try registraion
# - how often the Master maintenance loop runs
# MAX_MISSED - how many pings are missed before we give up and re-register
# - number of times the master maintenance loop runs before de-registering a peer
#
# ACLs:
#
# Access Control Lists are a very powerful tool for administering your system.
# But they consume packet processing time. Disable them if you are not using them.
# But be aware that, as of now, the configuration stanzas still need the ACL
# sections configured even if you're not using them.
#
# REGISTRATION ACLS ARE ALWAYS USED, ONLY SUBSCRIBER AND TGID MAY BE DISABLED!!!
#
# The 'action' May be PERMIT|DENY
# Each entry may be a single radio id, or a hypenated range (e.g. 1-2999)
# Format:
# ACL = 'action:id|start-end|,id|start-end,....'
# --for example--
# SUB_ACL: DENY:1,1000-2000,4500-60000,17
#
# ACL Types:
# REG_ACL: peer radio IDs for registration (only used on HBP master systems)
# SUB_ACL: subscriber IDs for end-users
# TGID_TS1_ACL: destination talkgroup IDs on Timeslot 1
# TGID_TS2_ACL: destination talkgroup IDs on Timeslot 2
#
# ACLs may be repeated for individual systems if needed for granularity
# Global ACLs will be processed BEFORE the system level ACLs
# Packets will be matched against all ACLs, GLOBAL first. If a packet 'passes'
# All elements, processing continues. Packets are discarded at the first
# negative match, or 'reject' from an ACL element.
#
# If you do not wish to use ACLs, set them to 'PERMIT:ALL'
# TGID_TS1_ACL in the global stanza is used for OPENBRIDGE systems, since all
# traffic is passed as TS 1 between OpenBridges
[GLOBAL]
PATH: ./
PING_TIME: 5
MAX_MISSED: 3
USE_ACL: True
REG_ACL: PERMIT:ALL
SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL
# APRS - BY IU7IGU
# Enabling "APRS" will configure APRS-Beaconing of Master's connection
# like repeater and hotspots.
# REPORT_INTERVAL in Minute (ALLOW only > 3 Minutes)
# CALLSIGN: Callsign that will pubblish data on aprs server
# MESSAGE: This message will print on APRS description together RX and TX Frequency
[APRS]
ENABLED: False
REPORT_INTERVAL: 15
CALLSIGN:HB1LNK-11
SERVER:euro.aprs2.net
MESSAGE:Connesso ad HBLINK
# NOT YET WORKING: NETWORK REPORTING CONFIGURATION
# Enabling "REPORT" will configure a socket-based reporting
# system that will send the configuration and other items
# to a another process (local or remote) that may process
# the information for some useful purpose, like a web dashboard.
#
# REPORT - True to enable, False to disable
# REPORT_INTERVAL - Seconds between reports
# REPORT_PORT - TCP port to listen on if "REPORT_NETWORKS" = NETWORK
# REPORT_CLIENTS - comma separated list of IPs you will allow clients
# to connect on. Entering a * will allow all.
#
# ****FOR NOW MUST BE TRUE - USE THE LOOPBACK IF YOU DON'T USE THIS!!!****
[REPORTS]
REPORT: True
REPORT_INTERVAL: 60
REPORT_PORT: 4321
REPORT_CLIENTS: 127.0.0.1
# SYSTEM LOGGER CONFIGURAITON
# This allows the logger to be configured without chaning the individual
# python logger stuff. LOG_FILE should be a complete path/filename for *your*
# system -- use /dev/null for non-file handlers.
# LOG_HANDLERS may be any of the following, please, no spaces in the
# list if you use several:
# null
# console
# console-timed
# file
# file-timed
# syslog
# LOG_LEVEL may be any of the standard syslog logging levels, though
# as of now, DEBUG, INFO, WARNING and CRITICAL are the only ones
# used.
#
[LOGGER]
LOG_FILE: /tmp/hblink.log
LOG_HANDLERS: console-timed
LOG_LEVEL: DEBUG
LOG_NAME: HBlink
# DOWNLOAD AND IMPORT SUBSCRIBER, PEER and TGID ALIASES
# Ok, not the TGID, there's no master list I know of to download
# This is intended as a facility for other applcations built on top of
# HBlink to use, and will NOT be used in HBlink directly.
# STALE_DAYS is the number of days since the last download before we
# download again. Don't be an ass and change this to less than a few days.
[ALIASES]
TRY_DOWNLOAD: True
PATH: ./
PEER_FILE: peer_ids.json
SUBSCRIBER_FILE: subscriber_ids.json
TGID_FILE: talkgroup_ids.json
PEER_URL: https://www.radioid.net/static/rptrs.json
SUBSCRIBER_URL: https://www.radioid.net/static/users.json
STALE_DAYS: 1
# GPS/Data Application - by KF7EEL
# Configure the settings for the DMR GPS to APRS position application here.
#
# DATA_DMR_ID - This is the DMR ID that users send DMR GPS data.
# CALL_TYPE - group, unit, or both. Group if you want users to send data to a talkgroup,
# unit if you want users to send data as a private call, or both if you want both options.
# USER_APRS_SSID - Default APRS SSID assigned to user APRS positions.
# USER_APRS_COMMENT - Default Comment attached to user APRS positions.
# APRS_LOGIN_CALL, PASSCODE, SERVER, and PORT - Login settings for APRS-IS.
[GPS_DATA]
DATA_DMR_ID: 9099
CALL_TYPE: both
USER_APRS_SSID: 15
USER_APRS_COMMENT: HBLink3 D-APRS -
# Setting APRS_LOGIN_CALL to N0CALL will cause the gateway to not upload packets to APRS server.
APRS_LOGIN_CALL: N0CALL
APRS_LOGIN_PASSCODE: 12345
APRS_SERVER: rotate.aprs2.net
APRS_PORT: 14580
# The following settings are only applicable if you are using the gps_data_beacon_igate script.
# They do not affect the operation gps_data itself.
# Time in minutes.
IGATE_BEACON_TIME = 45
IGATE_BEACON_COMMENT = HBLink3 D-APRS Gateway
IGATE_BEACON_ICON = /I
IGATE_LATITUDE = 0000.00N
IGATE_LONGITUDE = 00000.00W
# User settings file, MUST configure using absolute path.
USER_SETTINGS_FILE: /path/to/user_settings.txt
# The APRS filter below is used for the message received script. See http://www.aprs-is.net/javAPRSFilter.aspx for details
# about APRS filters.
APRS_RECEIVE_LOGIN_CALL: N0CALL-1
APRS_FILTER: r/47/-120/500 t/m
# The email gateway settingns below are OPTIONAL. They are NOT REQUIRED if you don't want
# to enable the email gateway. Leave as is to disable.
EMAIL_SENDER:
EMAIL_PASSWORD:
SMTP_SERVER: smtp.gmail.com
SMTP_PORT: 465
# The options below are required for operation of the dashboard and will cause errors in gps_data.py
# if configured wrong. Leave them as default unless you know what you are doing.
# If you do change, you must use absolute paths.
LOCATION_FILE: /tmp/gps_data_user_loc.txt
BULLETIN_BOARD_FILE: /tmp/gps_data_user_bb.txt
MAILBOX_FILE: /tmp/gps_data_user_mailbox.txt
EMERGENCY_SOS_FILE: /tmp/gps_data_user_sos.txt
# The following options are used for the dashboard. The dashboard is optional.
# Title of the Dashboard
DASHBOARD_TITLE: HBLink3 D-APRS Dashboard
# Logo used on dashboard page
LOGO: https://raw.githubusercontent.com/kf7eel/hblink3/gps/HBlink.png
# Port to run server
DASH_PORT: 8092
# IP to run server on
DASH_HOST: 127.0.0.1
#Description of dashboard to show on main page
DESCRIPTION: Welcome to the dashboard.
# Gateway contact info displayed on about page.
CONTACT_NAME: your name
CONTACT_CALL: N0CALL
CONTACT_EMAIL: email@example.org
CONTACT_WEBSITE: https://hbl.ink
# Time format for display
TIME_FORMAT: %%H:%%M:%%S - %%m/%%d/%%y
# Center dashboard map over these coordinates
MAP_CENTER_LAT: 47.00
MAP_CENTER_LON: -120.00
ZOOM_LEVEL: 7
# List and preview of some map themes at http://leaflet-extras.github.io/leaflet-providers/preview/
# The following are options for map themes and just work, you should use one of these: “OpenStreetMap”, “Stamen” (Terrain, Toner, and Watercolor),
MAP_THEME: Stamen Toner
# RSS feed link, shows in the link section of each RSS item.
RSS_LINK: http://localhost:8092
# OPENBRIDGE INSTANCES - DUPLICATE SECTION FOR MULTIPLE CONNECTIONS
# OpenBridge is a protocol originall created by DMR+ for connection between an
# IPSC2 server and Brandmeister. It has been implemented here at the suggestion
# of the Brandmeister team as a way to legitimately connect HBlink to the
# Brandemiester network.
# It is recommended to name the system the ID of the Brandmeister server that
# it connects to, but is not necessary. TARGET_IP and TARGET_PORT are of the
# Brandmeister or IPSC2 server you are connecting to. PASSPHRASE is the password
# that must be agreed upon between you and the operator of the server you are
# connecting to. NETWORK_ID is a number in the format of a DMR Radio ID that
# will be sent to the other server to identify this connection.
# other parameters follow the other system types.
#
# ACLs:
# OpenBridge does not 'register', so registration ACL is meaningless.
# Proper OpenBridge passes all traffic on TS1.
# HBlink can extend OPB to use both slots for unit calls only.
# Setting "BOTH_SLOTS" True ONLY affects unit traffic!
# Otherwise ACLs work as described in the global stanza
[OBP-1]
MODE: OPENBRIDGE
ENABLED: False
IP:
PORT: 62035
NETWORK_ID: 3129100
PASSPHRASE: password
TARGET_IP: 1.2.3.4
TARGET_PORT: 62035
BOTH_SLOTS: True
USE_ACL: True
SUB_ACL: DENY:1
TGID_ACL: PERMIT:ALL
# MASTER INSTANCES - DUPLICATE SECTION FOR MULTIPLE MASTERS
# HomeBrew Protocol Master instances go here.
# IP may be left blank if there's one interface on your system.
# Port should be the port you want this master to listen on. It must be unique
# and unused by anything else.
# Repeat - if True, the master repeats traffic to peers, False, it does nothing.
#
# MAX_PEERS -- maximun number of peers that may be connect to this master
# at any given time. This is very handy if you're allowing hotspots to
# connect, or using a limited computer like a Raspberry Pi.
#
# ACLs:
# See comments in the GLOBAL stanza
[MASTER-1]
MODE: MASTER
ENABLED: True
# The APRS setting below has to do with the beaconing of PEER conections, and not GPS positions
# from radios. This setting will not affect gps_data.py
APRS: False
REPEAT: True
MAX_PEERS: 10
EXPORT_AMBE: False
IP:
PORT: 54000
PASSPHRASE: s3cr37w0rd
GROUP_HANGTIME: 5
USE_ACL: True
REG_ACL: DENY:1
SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL
[D-APRS]
MODE: MASTER
ENABLED: True
REPEAT: True
MAX_PEERS: 2
EXPORT_AMBE: False
IP:
PORT: 54070
PASSPHRASE: passw0rd
GROUP_HANGTIME: 5
USE_ACL: True
REG_ACL: DENY:1
SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL
# PEER INSTANCES - DUPLICATE SECTION FOR MULTIPLE PEERS
# There are a LOT of errors in the HB Protocol specifications on this one!
# MOST of these items are just strings and will be properly dealt with by the program
# The TX & RX Frequencies are 9-digit numbers, and are the frequency in Hz.
# Latitude is an 8-digit unsigned floating point number.
# Longitude is a 9-digit signed floating point number.
# Height is in meters
# Setting Loose to True relaxes the validation on packets received from the master.
# This will allow HBlink to connect to a non-compliant system such as XLXD, DMR+ etc.
#
# ACLs:
# See comments in the GLOBAL stanza
[REPEATER-1]
MODE: PEER
ENABLED: False
LOOSE: False
EXPORT_AMBE: False
IP:
PORT: 54001
MASTER_IP: 172.16.1.1
MASTER_PORT: 54000
PASSPHRASE: homebrew
CALLSIGN: W1ABC
RADIO_ID: 312000
RX_FREQ: 449000000
TX_FREQ: 444000000
TX_POWER: 25
COLORCODE: 1
SLOTS: 1
LATITUDE: 38.0000
LONGITUDE: -095.0000
HEIGHT: 75
LOCATION: Anywhere, USA
DESCRIPTION: This is a cool repeater
URL: www.w1abc.org
SOFTWARE_ID: 20170620
PACKAGE_ID: MMDVM_HBlink
GROUP_HANGTIME: 5
OPTIONS:
USE_ACL: True
SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL
[ECHO]
MODE: PEER
ENABLED: True
LOOSE: False
EXPORT_AMBE: False
IP:
PORT: 54073
MASTER_IP: localhost
MASTER_PORT: 54072
passphrase: passw0rd
CALLSIGN: ECHO
RADIO_ID: 9999
RX_FREQ: 000000000
TX_FREQ: 000000000
TX_POWER: 0
COLORCODE: 1
SLOTS: 1
LATITUDE: 00.0000
LONGITUDE: 000.0000
HEIGHT: 0
LOCATION: This Server
DESCRIPTION: Echo Server
URL: www.github.com/kf7eel/hblink3
SOFTWARE_ID: 20170620
PACKAGE_ID: MMDVM_HBlink
GROUP_HANGTIME: 5
OPTIONS:
USE_ACL: True
SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL
[XLX-1]
MODE: XLXPEER
ENABLED: False
LOOSE: True
EXPORT_AMBE: False
IP:
PORT: 54002
MASTER_IP: 172.16.1.1
MASTER_PORT: 62030
PASSPHRASE: passw0rd
CALLSIGN: W1ABC
RADIO_ID: 312000
RX_FREQ: 449000000
TX_FREQ: 444000000
TX_POWER: 25
COLORCODE: 1
SLOTS: 1
LATITUDE: 38.0000
LONGITUDE: -095.0000
HEIGHT: 75
LOCATION: Anywhere, USA
DESCRIPTION: This is a cool repeater
URL: www.w1abc.org
SOFTWARE_ID: 20170620
PACKAGE_ID: MMDVM_HBlink
GROUP_HANGTIME: 5
XLXMODULE: 4004
USE_ACL: True
SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL

1935
bridge_gps_data.py Executable file

File diff suppressed because it is too large Load Diff

View File

@ -106,6 +106,7 @@ def build_config(_config_file):
CONFIG['GLOBAL'] = {}
CONFIG['REPORTS'] = {}
CONFIG['LOGGER'] = {}
CONFIG['GPS_DATA'] = {}
CONFIG['ALIASES'] = {}
CONFIG['SYSTEMS'] = {}
@ -141,6 +142,35 @@ def build_config(_config_file):
if not CONFIG['LOGGER']['LOG_FILE']:
CONFIG['LOGGER']['LOG_FILE'] = '/dev/null'
elif section == 'GPS_DATA':
CONFIG['GPS_DATA'].update({
'DATA_DMR_ID': config.get(section, 'DATA_DMR_ID'),
'USER_APRS_SSID': config.get(section, 'USER_APRS_SSID'),
'CALL_TYPE': config.get(section, 'CALL_TYPE'),
'USER_APRS_COMMENT': config.get(section, 'USER_APRS_COMMENT'),
'APRS_LOGIN_CALL': config.get(section, 'APRS_LOGIN_CALL'),
'APRS_LOGIN_PASSCODE': config.get(section, 'APRS_LOGIN_PASSCODE'),
'APRS_SERVER': config.get(section, 'APRS_SERVER'),
'APRS_PORT': config.get(section, 'APRS_PORT'),
'IGATE_BEACON_TIME': config.get(section, 'IGATE_BEACON_TIME'),
'IGATE_BEACON_ICON': config.get(section, 'IGATE_BEACON_ICON'),
'IGATE_BEACON_COMMENT': config.get(section, 'IGATE_BEACON_COMMENT'),
'IGATE_LATITUDE': config.get(section, 'IGATE_LATITUDE'),
'IGATE_LONGITUDE': config.get(section, 'IGATE_LONGITUDE'),
'EMAIL_SENDER': config.get(section, 'EMAIL_SENDER'),
'EMAIL_PASSWORD': config.get(section, 'EMAIL_PASSWORD'),
'SMTP_SERVER': config.get(section, 'SMTP_SERVER'),
'SMTP_PORT': config.get(section, 'SMTP_PORT'),
'LOCATION_FILE': config.get(section, 'LOCATION_FILE'),
'BULLETIN_BOARD_FILE': config.get(section, 'BULLETIN_BOARD_FILE'),
'MAILBOX_FILE': config.get(section, 'MAILBOX_FILE'),
'EMERGENCY_SOS_FILE': config.get(section, 'EMERGENCY_SOS_FILE'),
'USER_SETTINGS_FILE': config.get(section, 'USER_SETTINGS_FILE'),
})
if not CONFIG['LOGGER']['LOG_FILE']:
CONFIG['LOGGER']['LOG_FILE'] = '/dev/null'
elif section == 'ALIASES':
CONFIG['ALIASES'].update({
'TRY_DOWNLOAD': config.getboolean(section, 'TRY_DOWNLOAD'),
@ -182,7 +212,7 @@ def build_config(_config_file):
'SOFTWARE_ID': bytes(config.get(section, 'SOFTWARE_ID').ljust(40)[:40], 'utf-8'),
'PACKAGE_ID': bytes(config.get(section, 'PACKAGE_ID').ljust(40)[:40], 'utf-8'),
'GROUP_HANGTIME': config.getint(section, 'GROUP_HANGTIME'),
'OPTIONS': b''.join([b'Type=HBlink;', bytes(config.get(section, 'OPTIONS'), 'utf-8')]),
'OPTIONS': bytes(config.get(section, 'OPTIONS'), 'utf-8'),
'USE_ACL': config.getboolean(section, 'USE_ACL'),
'SUB_ACL': config.get(section, 'SUB_ACL'),
'TG1_ACL': config.get(section, 'TGID_TS1_ACL'),

307
gps_data-SAMPLE.cfg Normal file
View File

@ -0,0 +1,307 @@
# PROGRAM-WIDE PARAMETERS GO HERE
# PATH - working path for files, leave it alone unless you NEED to change it
# PING_TIME - the interval that peers will ping the master, and re-try registraion
# - how often the Master maintenance loop runs
# MAX_MISSED - how many pings are missed before we give up and re-register
# - number of times the master maintenance loop runs before de-registering a peer
#
# ACLs:
#
# Access Control Lists are a very powerful tool for administering your system.
# But they consume packet processing time. Disable them if you are not using them.
# But be aware that, as of now, the configuration stanzas still need the ACL
# sections configured even if you're not using them.
#
# REGISTRATION ACLS ARE ALWAYS USED, ONLY SUBSCRIBER AND TGID MAY BE DISABLED!!!
#
# The 'action' May be PERMIT|DENY
# Each entry may be a single radio id, or a hypenated range (e.g. 1-2999)
# Format:
# ACL = 'action:id|start-end|,id|start-end,....'
# --for example--
# SUB_ACL: DENY:1,1000-2000,4500-60000,17
#
# ACL Types:
# REG_ACL: peer radio IDs for registration (only used on HBP master systems)
# SUB_ACL: subscriber IDs for end-users
# TGID_TS1_ACL: destination talkgroup IDs on Timeslot 1
# TGID_TS2_ACL: destination talkgroup IDs on Timeslot 2
#
# ACLs may be repeated for individual systems if needed for granularity
# Global ACLs will be processed BEFORE the system level ACLs
# Packets will be matched against all ACLs, GLOBAL first. If a packet 'passes'
# All elements, processing continues. Packets are discarded at the first
# negative match, or 'reject' from an ACL element.
#
# If you do not wish to use ACLs, set them to 'PERMIT:ALL'
# TGID_TS1_ACL in the global stanza is used for OPENBRIDGE systems, since all
# traffic is passed as TS 1 between OpenBridges
[GLOBAL]
PATH: ./
PING_TIME: 5
MAX_MISSED: 3
USE_ACL: True
REG_ACL: PERMIT:ALL
SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL
# NOT YET WORKING: NETWORK REPORTING CONFIGURATION
# Enabling "REPORT" will configure a socket-based reporting
# system that will send the configuration and other items
# to a another process (local or remote) that may process
# the information for some useful purpose, like a web dashboard.
#
# REPORT - True to enable, False to disable
# REPORT_INTERVAL - Seconds between reports
# REPORT_PORT - TCP port to listen on if "REPORT_NETWORKS" = NETWORK
# REPORT_CLIENTS - comma separated list of IPs you will allow clients
# to connect on. Entering a * will allow all.
#
# ****FOR NOW MUST BE TRUE - USE THE LOOPBACK IF YOU DON'T USE THIS!!!****
[REPORTS]
REPORT: True
REPORT_INTERVAL: 60
REPORT_PORT: 4323
REPORT_CLIENTS: 127.0.0.1
# SYSTEM LOGGER CONFIGURAITON
# This allows the logger to be configured without chaning the individual
# python logger stuff. LOG_FILE should be a complete path/filename for *your*
# system -- use /dev/null for non-file handlers.
# LOG_HANDLERS may be any of the following, please, no spaces in the
# list if you use several:
# null
# console
# console-timed
# file
# file-timed
# syslog
# LOG_LEVEL may be any of the standard syslog logging levels, though
# as of now, DEBUG, INFO, WARNING and CRITICAL are the only ones
# used.
#
[LOGGER]
LOG_FILE: /tmp/gps_data.log
LOG_HANDLERS: console-timed
LOG_LEVEL: DEBUG
LOG_NAME: HBlink3 GPS/Data
# DOWNLOAD AND IMPORT SUBSCRIBER, PEER and TGID ALIASES
# Ok, not the TGID, there's no master list I know of to download
# This is intended as a facility for other applcations built on top of
# HBlink to use, and will NOT be used in HBlink directly.
# STALE_DAYS is the number of days since the last download before we
# download again. Don't be an ass and change this to less than a few days.
[ALIASES]
TRY_DOWNLOAD: True
PATH: ./
PEER_FILE: peer_ids.json
SUBSCRIBER_FILE: subscriber_ids.json
TGID_FILE: talkgroup_ids.json
PEER_URL: https://www.radioid.net/static/rptrs.json
SUBSCRIBER_URL: https://www.radioid.net/static/users.json
STALE_DAYS: 1
#####################################################################
# GPS/Data Application - by KF7EEL
# Configure the settings for the DMR GPS to APRS position application here.
#
# DATA_DMR_ID - This is the DMR ID that users send DMR GPS data.
# CALL_TYPE - group, unit, or both. Group if you want users to send data to a talkgroup,
# unit if you want users to send data as a private call, or both if you want both options.
# USER_APRS_SSID - Default APRS SSID assigned to user APRS positions.
# USER_APRS_COMMENT - Default Comment attached to user APRS positions.
# APRS_LOGIN_CALL, PASSCODE, SERVER, and PORT - Login settings for APRS-IS.
[GPS_DATA]
DATA_DMR_ID: 9099
CALL_TYPE: unit
USER_APRS_SSID: 15
USER_APRS_COMMENT: HBLink3 D-APRS -
# Setting APRS_LOGIN_CALL to N0CALL will cause the gateway to not upload packets to APRS server.
APRS_LOGIN_CALL: N0CALL
APRS_LOGIN_PASSCODE: 12345
APRS_SERVER: rotate.aprs2.net
APRS_PORT: 14580
# The APRS filter below is used for the message received script. See http://www.aprs-is.net/javAPRSFilter.aspx for details
# about APRS filters.
APRS_RECEIVE_LOGIN_CALL: N0CALL-1
APRS_FILTER: r/47/-120/500 t/m
# The following settings are only applicable if you are using the gps_data_beacon_igate script.
# They do not affect the operation gps_data itself.
# Time in minutes.
IGATE_BEACON_TIME = 45
IGATE_BEACON_COMMENT = HBLink3 D-APRS Gateway
IGATE_BEACON_ICON = /I
IGATE_LATITUDE = 0000.00N
IGATE_LONGITUDE = 00000.00W
# User settings file, MUST configure using absolute path.
USER_SETTINGS_FILE: /path/to/user_settings.txt
# The email gateway settingns below are OPTIONAL. They are NOT REQUIRED if you don't want
http://www.aprs-is.net/javAPRSFilter.aspx# to enable the email gateway. Leave as is to disable.
EMAIL_SENDER: test@example.org
EMAIL_PASSWORD: letmein
SMTP_SERVER: smtp.gmail.com
SMTP_PORT: 465
# The options below are required for operation of the dashboard and will cause errors in gps_data.py
# if configured wrong. Leave them as default unless you know what you are doing.
# If you do change, you must use absolute paths.
LOCATION_FILE: /tmp/gps_data_user_loc.txt
BULLETIN_BOARD_FILE: /tmp/gps_data_user_bb.txt
MAILBOX_FILE: /tmp/gps_data_user_mailbox.txt
EMERGENCY_SOS_FILE: /tmp/gps_data_user_sos.txt
# The following options are used for the dashboard. The dashboard is optional.
# Title of the Dashboard
DASHBOARD_TITLE: HBLink3 D-APRS Dashboard
# Logo used on dashboard page
LOGO: https://raw.githubusercontent.com/kf7eel/hblink3/gps/HBlink.png
# Port to run server
DASH_PORT: 8092
# IP to run server on
DASH_HOST: 127.0.0.1
#Description of dashboard to show on main page
DESCRIPTION: Welcome to the dashboard.
# Gateway contact info displayed on about page.
CONTACT_NAME: your name
CONTACT_CALL: N0CALL
CONTACT_EMAIL: email@example.org
CONTACT_WEBSITE: https://hbl.ink
# Time format for display
TIME_FORMAT: %%H:%%M:%%S - %%m/%%d/%%y
# Center dashboard map over these coordinates
MAP_CENTER_LAT: 47.00
MAP_CENTER_LON: -120.00
ZOOM_LEVEL: 7
# List and preview of some map themes at http://leaflet-extras.github.io/leaflet-providers/preview/
# The following are options for map themes and just work, you should use one of these: “OpenStreetMap”, “Stamen” (Terrain, Toner, and Watercolor),
MAP_THEME: Stamen Toner
# RSS feed link, shows in the link section of each RSS item.
RSS_LINK: http://localhost:8092
#####################################################################
# OPENBRIDGE INSTANCES - DUPLICATE SECTION FOR MULTIPLE CONNECTIONS
# OpenBridge is a protocol originall created by DMR+ for connection between an
# IPSC2 server and Brandmeister. It has been implemented here at the suggestion
# of the Brandmeister team as a way to legitimately connect HBlink to the
# Brandemiester network.
# It is recommended to name the system the ID of the Brandmeister server that
# it connects to, but is not necessary. TARGET_IP and TARGET_PORT are of the
# Brandmeister or IPSC2 server you are connecting to. PASSPHRASE is the password
# that must be agreed upon between you and the operator of the server you are
# connecting to. NETWORK_ID is a number in the format of a DMR Radio ID that
# will be sent to the other server to identify this connection.
# other parameters follow the other system types.
#
# ACLs:
# OpenBridge does not 'register', so registration ACL is meaningless.
# Proper OpenBridge passes all traffic on TS1.
# HBlink can extend OPB to use both slots for unit calls only.
# Setting "BOTH_SLOTS" True ONLY affects unit traffic!
# Otherwise ACLs work as described in the global stanza
##[OBP-1]
##MODE: OPENBRIDGE
##ENABLED: True
##IP:
##PORT: 62035
##NETWORK_ID: 3129100
##PASSPHRASE: password
##TARGET_IP: 1.2.3.4
##TARGET_PORT: 62035
##BOTH_SLOTS: True
##USE_ACL: True
##SUB_ACL: DENY:1
##TGID_ACL: PERMIT:ALL
# MASTER INSTANCES - DUPLICATE SECTION FOR MULTIPLE MASTERS
# HomeBrew Protocol Master instances go here.
# IP may be left blank if there's one interface on your system.
# Port should be the port you want this master to listen on. It must be unique
# and unused by anything else.
# Repeat - if True, the master repeats traffic to peers, False, it does nothing.
#
# MAX_PEERS -- maximun number of peers that may be connect to this master
# at any given time. This is very handy if you're allowing hotspots to
# connect, or using a limited computer like a Raspberry Pi.
#
# ACLs:
# See comments in the GLOBAL stanza
[MASTER-1]
MODE: MASTER
ENABLED: False
REPEAT: True
MAX_PEERS: 10
EXPORT_AMBE: False
IP:
PORT: 54000
PASSPHRASE: password
GROUP_HANGTIME: 5
USE_ACL: True
REG_ACL: DENY:1
SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL
# PEER INSTANCES - DUPLICATE SECTION FOR MULTIPLE PEERS
# There are a LOT of errors in the HB Protocol specifications on this one!
# MOST of these items are just strings and will be properly dealt with by the program
# The TX & RX Frequencies are 9-digit numbers, and are the frequency in Hz.
# Latitude is an 8-digit unsigned floating point number.
# Longitude is a 9-digit signed floating point number.
# Height is in meters
# Setting Loose to True relaxes the validation on packets received from the master.
# This will allow HBlink to connect to a non-compliant system such as XLXD, DMR+ etc.
#
# ACLs:
# See comments in the GLOBAL stanza
[D-APRS]
MODE: PEER
ENABLED: True
LOOSE: True
EXPORT_AMBE: False
IP:
PORT: 54071
MASTER_IP: localhost
MASTER_PORT: 54070
PASSPHRASE: passw0rd
CALLSIGN: D-APRS
RADIO_ID: 9099
RX_FREQ: 000000000
TX_FREQ: 000000000
TX_POWER: 0
COLORCODE: 1
SLOTS: 1
LATITUDE: 00.0000
LONGITUDE: 000.0000
HEIGHT: 0
LOCATION: This Server
DESCRIPTION: GPS to APRS
URL: www.github.com/kf7eel/hblink3
SOFTWARE_ID: 20170620
PACKAGE_ID: MMDVM_HBlink
GROUP_HANGTIME: 5
OPTIONS:
USE_ACL: True
SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL

View File

@ -1,7 +1,9 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
###############################################################################
# Copyright (C) 2020 Cortney T. Buffington, N0MJS <n0mjs@me.com>
# HBLink - Copyright (C) 2020 Cortney T. Buffington, N0MJS <n0mjs@me.com>
# GPS/Data - Copyright (C) 2020 Eric Craw, KF7EEL <kf7eel@qsl.net>
# Annotated modifications Copyright (C) 2021 Xavier FRS2013
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -46,6 +48,7 @@ import const
# The module needs logging logging, but handlers, etc. are controlled by the parent
import logging
logger = logging.getLogger(__name__)
import traceback
# Other modules we need for data and GPS
from bitarray import bitarray
@ -55,6 +58,31 @@ import re
import aprslib
import datetime
from bitarray.util import ba2int as ba2num
from bitarray.util import ba2hex as ba2hx
import codecs
import time
#Needed for working with NMEA
import pynmea2
# Modules for executing commands/scripts
import os
from gps_functions import cmd_list
# Module for maidenhead grids
try:
import maidenhead as mh
except Exception as error_exception:
logger.info('Error importing maidenhead module, make sure it is installed.')
# Module for sending email
try:
import smtplib
except Exception as error_exception:
logger.info('Error importing smtplib module, make sure it is installed.')
#Modules for APRS settings
import ast
from pathlib import Path
# Does anybody read this stuff? There's a PEP somewhere that says I should do this.
__author__ = 'Cortney T. Buffington, N0MJS; Eric Craw, KF7EEL'
@ -70,27 +98,14 @@ __status__ = 'pre-alpha'
# Must have the following at line 1054 in bridge.py to forward group vcsbk, also there is a typo there:
# self.group_received(_peer_id, _rf_src, _dst_id, _seq, _slot, _frame_type, _dtype_vseq, _stream_id, _data)
############################# Configuration Variables - Change these #############################
# DMR ID for GPS and data
data_id = 9099
# Group call or Unit (private) call
call_type = 'unit'
# APRS-IS login information
aprs_callsign = 'N0CALL'
aprs_passcode = 12345
aprs_server = 'rotate.aprs2.net'
aprs_port = 14580
user_ssid = '15'
aprs_comment = 'HBLink3 GPS decode - '
##################################################################################################
# Headers for GPS by model of radio:
# AT-D878 - Compressed UDP
# MD-380 - Unified Data Transport
hdr_type = ''
btf = -1
ssid = ''
# From dmr_utils3, modified to decode entire packet. Works for 1/2 rate coded data.
def decode_full(_data):
@ -103,6 +118,7 @@ def decode_full(_data):
binlc.extend([_data[36], _data[21], _data[6], _data[187],_data[172],_data[157],_data[142],_data[127],_data[112],_data[97], _data[82] ])
binlc.extend([_data[7], _data[188],_data[173],_data[158],_data[143],_data[128],_data[113],_data[98], _data[83]])
#This is the rest of the Full LC data -- the RS1293 FEC that we don't need
# This is extremely important for SMS and GPS though.
binlc.extend([_data[68],_data[53],_data[174],_data[159],_data[144],_data[129],_data[114],_data[99],_data[84],_data[69],_data[54],_data[39]])
binlc.extend([_data[24],_data[145],_data[130],_data[115],_data[100],_data[85],_data[70],_data[55],_data[40],_data[25],_data[10],_data[191]])
return binlc
@ -112,16 +128,306 @@ n_packet_assembly = 0
packet_assembly = ''
final_packet = ''
#Convert DMR packet to binary from MMDVM packet and remove Slot Type and EMB Sync stuff to allow for BPTC 196,96 decoding
def bptc_decode(_data):
binary_packet = bitarray(decode.to_bits(_data[20:]))
del binary_packet[98:166]
return decode_full(binary_packet)
def header_info(_data):
bptc_decode(_data)
# Placeholder for future header id
def header_ID(_data):
hex_hdr = str(ahex(bptc_decode(_data)))
return hex_hdr[2:6]
# Work in progress, used to determine data format
pass
## pass
def aprs_send(packet):
if aprs_callsign == 'N0CALL':
logger.info('APRS callsighn set to N0CALL, packet not sent.')
pass
else:
AIS = aprslib.IS(aprs_callsign, passwd=aprs_passcode,host=aprs_server, port=aprs_port)
AIS.connect()
AIS.sendall(packet)
AIS.close()
logger.info('Packet sent to APRS-IS.')
# For future use
##def position_timer(aprs_call):
## dash_entries = ast.literal_eval(os.popen('cat ' + loc_file).read())
## for i in dash_entries:
## if aprs_call == i['call']:
## if time.time()
def dashboard_loc_write(call, lat, lon, time, comment):
dash_entries = ast.literal_eval(os.popen('cat /tmp/gps_data_user_loc.txt').read())
dash_entries.insert(0, {'call': call, 'lat': lat, 'lon': lon, 'time':time, 'comment':comment})
# Clear old entries
list_index = 0
call_count = 0
new_dash_entries = []
for i in dash_entries:
if i['call'] == call:
if call_count >= 25:
pass
else:
new_dash_entries.append(i)
call_count = call_count + 1
if call != i['call']:
new_dash_entries.append(i)
pass
list_index = list_index + 1
with open(loc_file, 'w') as user_loc_file:
user_loc_file.write(str(new_dash_entries[:500]))
user_loc_file.close()
logger.info('User location saved for dashboard')
#logger.info(dash_entries)
def dashboard_bb_write(call, dmr_id, time, bulletin):
#try:
dash_bb = ast.literal_eval(os.popen('cat ' + bb_file).read())
# except:
# dash_entries = []
dash_bb.insert(0, {'call': call, 'dmr_id': dmr_id, 'time': time, 'bulletin':bulletin})
with open(bb_file, 'w') as user_bb_file:
user_bb_file.write(str(dash_bb[:20]))
user_bb_file.close()
logger.info('User bulletin entry saved.')
#logger.info(dash_bb)
def mailbox_write(call, dmr_id, time, message, recipient):
#try:
mail_file = ast.literal_eval(os.popen('cat ' + the_mailbox_file).read())
mail_file.insert(0, {'call': call, 'dmr_id': dmr_id, 'time': time, 'message':message, 'recipient': recipient})
with open(the_mailbox_file, 'w') as mailbox_file:
mailbox_file.write(str(mail_file[:100]))
mailbox_file.close()
logger.info('User mail saved.')
def mailbox_delete(dmr_id):
mail_file = ast.literal_eval(os.popen('cat ' + the_mailbox_file).read())
call = str(get_alias((dmr_id), subscriber_ids))
new_data = []
for message in mail_file:
if message['recipient'] != call:
new_data.append(message)
with open(the_mailbox_file, 'w') as mailbox_file:
mailbox_file.write(str(new_data[:100]))
mailbox_file.close()
logger.info('Mailbox updated. Delete occurred.')
def sos_write(dmr_id, time, message):
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
try:
if user_settings[dmr_id][1]['ssid'] == '':
sos_call = user_settings[dmr_id][0]['call'] + '-' + user_ssid
else:
sos_call = user_settings[dmr_id][0]['call'] + '-' + user_settings[dmr_id][1]['ssid']
except:
sos_call = str(get_alias((dmr_id), subscriber_ids))
sos_info = {'call': sos_call, 'dmr_id': dmr_id, 'time': time, 'message':message}
with open(emergency_sos_file, 'w') as sos_file:
sos_file.write(str(sos_info))
sos_file.close()
logger.info('Saved SOS.')
# Send email via SMTP function
def send_email(to_email, email_subject, email_message):
global smtp_server
sender_address = email_sender
account_password = email_password
smtp_server = smtplib.SMTP_SSL(smtp_server, int(smtp_port))
smtp_server.login(sender_address, account_password)
message = "From: " + aprs_callsign + " D-APRS Gateway\nTo: " + to_email + "\nContent-type: text/html\nSubject: " + email_subject + "\n\n" + '<strong>' + email_subject + '</strong><p>&nbsp;</p><h3>' + email_message + '</h3><p>&nbsp;</p><p>This message was sent to you from a D-APRS gateway operated by <strong>' + aprs_callsign + '</strong>. Do not reply as this gateway is only one way at this time.</p>'
smtp_server.sendmail(sender_address, to_email, message)
smtp_server.close()
# Thanks for this forum post for this - https://stackoverflow.com/questions/2579535/convert-dd-decimal-degrees-to-dms-degrees-minutes-seconds-in-python
def decdeg2dms(dd):
is_positive = dd >= 0
dd = abs(dd)
minutes,seconds = divmod(dd*3600,60)
degrees,minutes = divmod(minutes,60)
degrees = degrees if is_positive else -degrees
return (degrees,minutes,seconds)
def user_setting_write(dmr_id, setting, value):
## try:
# Open file and load as dict for modification
with open(user_settings_file, 'r') as f:
## if f.read() == '{}':
## user_dict = {}
user_dict = ast.literal_eval(f.read())
logger.info('Current settings: ' + str(user_dict))
if dmr_id not in user_dict:
user_dict[dmr_id] = [{'call': str(get_alias((dmr_id), subscriber_ids))}, {'ssid': ''}, {'icon': ''}, {'comment': ''}]
if setting.upper() == 'ICON':
user_dict[dmr_id][2]['icon'] = value
if setting.upper() == 'SSID':
user_dict[dmr_id][1]['ssid'] = value
if setting.upper() == 'COM':
user_comment = user_dict[dmr_id][3]['comment'] = value[0:35]
if setting.upper() == 'APRS':
user_dict[dmr_id] = [{'call': str(get_alias((dmr_id), subscriber_ids))}, {'ssid': ''}, {'icon': ''}, {'comment': ''}]
if setting.upper() == 'PIN':
try:
if user_dict[dmr_id]:
user_dict[dmr_id][4]['pin'] = value
if not user_dict[dmr_id]:
user_dict[dmr_id] = [{'call': str(get_alias((dmr_id), subscriber_ids))}, {'ssid': ''}, {'icon': ''}, {'comment': ''}, {'pin': pin}]
except:
user_dict[dmr_id].append({'pin': value})
f.close()
logger.info('Loaded user settings. Preparing to write...')
# Write modified dict to file
with open(user_settings_file, 'w') as user_dict_file:
user_dict_file.write(str(user_dict))
user_dict_file.close()
logger.info('User setting saved')
f.close()
packet_assembly = ''
# Process SMS, do something bases on message
def process_sms(_rf_src, sms):
if sms == 'ID':
logger.info(str(get_alias(int_id(_rf_src), subscriber_ids)) + ' - ' + str(int_id(_rf_src)))
elif sms == 'TEST':
logger.info('It works!')
elif '@ICON' in sms:
user_setting_write(int_id(_rf_src), re.sub(' .*|@','',sms), re.sub('@ICON| ','',sms))
elif '@SSID' in sms:
user_setting_write(int_id(_rf_src), re.sub(' .*|@','',sms), re.sub('@SSID| ','',sms))
elif '@COM' in sms:
user_setting_write(int_id(_rf_src), re.sub(' .*|@','',sms), re.sub('@COM |@COM','',sms))
elif '@PIN' in sms:
user_setting_write(int_id(_rf_src), re.sub(' .*|@','',sms), int(re.sub('@PIN |@PIN','',sms)))
# Write blank entry to cause APRS receive to look for packets for this station.
elif '@APRS' in sms:
user_setting_write(int_id(_rf_src), 'APRS', '')
elif '@BB' in sms:
dashboard_bb_write(get_alias(int_id(_rf_src), subscriber_ids), int_id(_rf_src), time.time(), re.sub('@BB|@BB ','',sms))
elif '@' and ' E-' in sms:
email_message = str(re.sub('.*@|.* E-', '', sms))
to_email = str(re.sub(' E-.*', '', sms))
email_subject = 'New message from ' + str(get_alias(int_id(_rf_src), subscriber_ids))
logger.info('Email to: ' + to_email)
logger.info('Message: ' + email_message)
try:
send_email(to_email, email_subject, email_message)
logger.info('Email sent.')
except Exception as error_exception:
logger.info('Failed to send email.')
logger.info(error_exception)
logger.info(str(traceback.extract_tb(error_exception.__traceback__)))
elif '@SOS' in sms or '@NOTICE' in sms:
sos_write(int_id(_rf_src), time.time(), sms)
elif '@REM SOS' == sms:
os.remove(emergency_sos_file)
logger.info('Removing SOS or Notice')
elif '@' and 'M-' in sms:
message = re.sub('^@|.* M-|','',sms)
recipient = re.sub('@| M-.*','',sms)
mailbox_write(get_alias(int_id(_rf_src), subscriber_ids), int_id(_rf_src), time.time(), message, str(recipient).upper())
elif '@REM MAIL' == sms:
mailbox_delete(_rf_src)
elif '@MH' in sms:
grid_square = re.sub('@MH ', '', sms)
if len(grid_square) < 6:
pass
else:
lat = decdeg2dms(mh.to_location(grid_square)[0])
lon = decdeg2dms(mh.to_location(grid_square)[1])
if lon[0] < 0:
lon_dir = 'W'
if lon[0] > 0:
lon_dir = 'E'
if lat[0] < 0:
lat_dir = 'S'
if lat[0] > 0:
lat_dir = 'N'
#logger.info(lat)
#logger.info(lat_dir)
aprs_lat = str(str(re.sub('\..*|-', '', str(lat[0]))) + str(re.sub('\..*', '', str(lat[1])) + '.')).zfill(5) + ' ' + lat_dir
aprs_lon = str(str(re.sub('\..*|-', '', str(lon[0]))) + str(re.sub('\..*', '', str(lon[1])) + '.')).zfill(6) + ' ' + lon_dir
logger.info('Latitude: ' + str(aprs_lat))
logger.info('Longitude: ' + str(aprs_lon))
# 14FRS2013 simplified and moved settings retrieval
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
if int_id(_rf_src) not in user_settings:
ssid = str(user_ssid)
icon_table = '/'
icon_icon = '['
comment = aprs_comment + ' DMR ID: ' + str(int_id(_rf_src))
else:
if user_settings[int_id(_rf_src)][1]['ssid'] == '':
ssid = user_ssid
if user_settings[int_id(_rf_src)][3]['comment'] == '':
comment = aprs_comment + ' DMR ID: ' + str(int_id(_rf_src))
if user_settings[int_id(_rf_src)][2]['icon'] == '':
icon_table = '/'
icon_icon = '['
if user_settings[int_id(_rf_src)][2]['icon'] != '':
icon_table = user_settings[int_id(_rf_src)][2]['icon'][0]
icon_icon = user_settings[int_id(_rf_src)][2]['icon'][1]
if user_settings[int_id(_rf_src)][1]['ssid'] != '':
ssid = user_settings[int_id(_rf_src)][1]['ssid']
if user_settings[int_id(_rf_src)][3]['comment'] != '':
comment = user_settings[int_id(_rf_src)][3]['comment']
aprs_loc_packet = str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid + '>APHBL3,TCPIP*:@' + str(datetime.datetime.utcnow().strftime("%H%M%Sh")) + str(aprs_lat) + icon_table + str(aprs_lon) + icon_icon + '/' + str(comment)
logger.info(aprs_loc_packet)
logger.info('User comment: ' + comment)
logger.info('User SSID: ' + ssid)
logger.info('User icon: ' + icon_table + icon_icon)
try:
aprslib.parse(aprs_loc_packet)
aprs_send(aprs_loc_packet)
dashboard_loc_write(str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid, aprs_lat, aprs_lon, time.time(), comment)
#logger.info('Sent manual position to APRS')
except Exception as error_exception:
logger.info('Exception. Not uploaded')
logger.info(error_exception)
logger.info(str(traceback.extract_tb(error_exception.__traceback__)))
packet_assembly = ''
elif 'A-' in sms and '@' in sms:
#Example SMS text: @ARMDS A-This is a test.
aprs_dest = re.sub('@| A-.*','',sms)
aprs_msg = re.sub('^@|.* A-|','',sms)
logger.info('APRS message to ' + aprs_dest.upper() + '. Message: ' + aprs_msg)
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
if int_id(_rf_src) in user_settings and user_settings[int_id(_rf_src)][1]['ssid'] != '':
ssid = user_settings[int_id(_rf_src)][1]['ssid']
else:
ssid = user_ssid
aprs_msg_pkt = str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + str(ssid) + '>APHBL3,TCPIP*::' + str(aprs_dest).ljust(9).upper() + ':' + aprs_msg[0:73]
logger.info(aprs_msg_pkt)
try:
aprslib.parse(aprs_msg_pkt)
aprs_send(aprs_msg_pkt)
#logger.info('Packet sent.')
except Exception as error_exception:
logger.info('Error uploading MSG packet.')
logger.info(error_exception)
logger.info(str(traceback.extract_tb(error_exception.__traceback__)))
try:
if sms in cmd_list:
logger.info('Executing command/script.')
os.popen(cmd_list[sms]).read()
packet_assembly = ''
except Exception as error_exception:
logger.info('Exception. Command possibly not in list, or other error.')
packet_assembly = ''
logger.info(error_exception)
logger.info(str(traceback.extract_tb(error_exception.__traceback__)))
else:
pass
###########
@ -134,64 +440,246 @@ class DATA_SYSTEM(HBSYSTEM):
def dmrd_received(self, _peer_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
# Capture data headers
global n_packet_assembly
global n_packet_assembly, hdr_type
#logger.info(_dtype_vseq)
logger.info(time.strftime('%H:%M:%S - %m/%d/%y'))
#logger.info('Special debug for developement:')
#logger.info(ahex(bptc_decode(_data)))
#logger.info(hdr_type)
#logger.info((ba2num(bptc_decode(_data)[8:12])))
if int_id(_dst_id) == data_id:
#logger.info(type(_seq))
if type(_seq) is bytes:
pckt_seq = int.from_bytes(_seq, 'big')
else:
pckt_seq = _seq
if _call_type == call_type or (_call_type == 'vcsbk' and pckt_seq > 3): #int.from_bytes(_seq, 'big') > 3 ):
# Try to classify header
# UDT header has DPF of 0101, which is 5.
# If 5 is at position 3, then this should be a UDT header for MD-380 type radios.
# Coordinates are usually in the very next block after the header, we will discard the rest.
#logger.info(ahex(bptc_decode(_data)[0:10]))
if _call_type == call_type and header_ID(_data)[3] == '5' and ba2num(bptc_decode(_data)[69:72]) == 0 and ba2num(bptc_decode(_data)[8:12]) == 0 or (_call_type == 'vcsbk' and header_ID(_data)[3] == '5' and ba2num(bptc_decode(_data)[69:72]) == 0 and ba2num(bptc_decode(_data)[8:12]) == 0):
global udt_block
logger.info('MD-380 type UDT header detected. Very next packet should be location.')
hdr_type = '380'
if _dtype_vseq == 6 and hdr_type == '380' or _dtype_vseq == 'group' and hdr_type == '380':
udt_block = 1
if _dtype_vseq == 7 and hdr_type == '380':
udt_block = udt_block - 1
if udt_block == 0:
logger.info('MD-380 type packet. This should contain the GPS location.')
logger.info('Packet: ' + str(ahex(bptc_decode(_data))))
if ba2num(bptc_decode(_data)[1:2]) == 1:
lat_dir = 'N'
if ba2num(bptc_decode(_data)[1:2]) == 0:
lat_dir = 'S'
if ba2num(bptc_decode(_data)[2:3]) == 1:
lon_dir = 'E'
if ba2num(bptc_decode(_data)[2:3]) == 0:
lon_dir = 'W'
lat_deg = ba2num(bptc_decode(_data)[11:18])
lon_deg = ba2num(bptc_decode(_data)[38:46])
lat_min = ba2num(bptc_decode(_data)[18:24])
lon_min = ba2num(bptc_decode(_data)[46:52])
lat_min_dec = str(ba2num(bptc_decode(_data)[24:38])).zfill(4)
lon_min_dec = str(ba2num(bptc_decode(_data)[52:66])).zfill(4)
# Old MD-380 coordinate format, keep here until new is confirmed working.
#aprs_lat = str(str(lat_deg) + str(lat_min) + '.' + str(lat_min_dec)[0:2]).zfill(7) + lat_dir
#aprs_lon = str(str(lon_deg) + str(lon_min) + '.' + str(lon_min_dec)[0:2]).zfill(8) + lon_dir
# Fix for MD-380 by G7HIF
aprs_lat = str(str(lat_deg) + str(lat_min).zfill(2) + '.' + str(lat_min_dec)[0:2]).zfill(7) + lat_dir
aprs_lon = str(str(lon_deg) + str(lon_min).zfill(2) + '.' + str(lon_min_dec)[0:2]).zfill(8) + lon_dir
# Form APRS packet
#logger.info(aprs_loc_packet)
logger.info('Lat: ' + str(aprs_lat) + ' Lon: ' + str(aprs_lon))
# 14FRS2013 simplified and moved settings retrieval
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
if int_id(_rf_src) not in user_settings:
ssid = str(user_ssid)
icon_table = '/'
icon_icon = '['
comment = aprs_comment + ' DMR ID: ' + str(int_id(_rf_src))
else:
if user_settings[int_id(_rf_src)][1]['ssid'] == '':
ssid = user_ssid
if user_settings[int_id(_rf_src)][3]['comment'] == '':
comment = aprs_comment + ' DMR ID: ' + str(int_id(_rf_src))
if user_settings[int_id(_rf_src)][2]['icon'] == '':
icon_table = '/'
icon_icon = '['
if user_settings[int_id(_rf_src)][2]['icon'] != '':
icon_table = user_settings[int_id(_rf_src)][2]['icon'][0]
icon_icon = user_settings[int_id(_rf_src)][2]['icon'][1]
if user_settings[int_id(_rf_src)][1]['ssid'] != '':
ssid = user_settings[int_id(_rf_src)][1]['ssid']
if user_settings[int_id(_rf_src)][3]['comment'] != '':
comment = user_settings[int_id(_rf_src)][3]['comment']
aprs_loc_packet = str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid + '>APHBL3,TCPIP*:@' + str(datetime.datetime.utcnow().strftime("%H%M%Sh")) + str(aprs_lat) + icon_table + str(aprs_lon) + icon_icon + '/' + str(comment)
logger.info(aprs_loc_packet)
logger.info('User comment: ' + comment)
logger.info('User SSID: ' + ssid)
logger.info('User icon: ' + icon_table + icon_icon)
# Attempt to prevent malformed packets from being uploaded.
try:
aprslib.parse(aprs_loc_packet)
float(lat_deg) < 91
float(lon_deg) < 121
aprs_send(aprs_loc_packet)
dashboard_loc_write(str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid, aprs_lat, aprs_lon, time.time(), comment)
#logger.info('Sent APRS packet')
except Exception as error_exception:
logger.info('Error. Failed to send packet. Packet may be malformed.')
logger.info(error_exception)
logger.info(str(traceback.extract_tb(error_exception.__traceback__)))
udt_block = 1
hdr_type = ''
else:
pass
#NMEA type packets for Anytone like radios.
#if _call_type == call_type or (_call_type == 'vcsbk' and pckt_seq > 3): #int.from_bytes(_seq, 'big') > 3 ):
# 14FRS2013 contributed improved header filtering, KF7EEL added conditions to allow both call types at the same time
if _call_type == call_type or (_call_type == 'vcsbk' and pckt_seq > 3 and call_type != 'unit') or (_call_type == 'group' and pckt_seq > 3 and call_type != 'unit') or (_call_type == 'group' and pckt_seq > 3 and call_type == 'both') or (_call_type == 'vcsbk' and pckt_seq > 3 and call_type == 'both') or (_call_type == 'unit' and pckt_seq > 3 and call_type == 'both'): #int.from_bytes(_seq, 'big') > 3 ):
global packet_assembly, btf
if _dtype_vseq == 6 or _dtype_vseq == 'group':
global btf
logger.info('Header from ' + str(int_id(_rf_src)))
global btf, hdr_start
hdr_start = str(header_ID(_data))
logger.info('Header from ' + str(get_alias(int_id(_rf_src), subscriber_ids)) + '. DMR ID: ' + str(int_id(_rf_src)))
logger.info(ahex(bptc_decode(_data)))
logger.info('Blocks to follow: ' + str(ba2num(bptc_decode(_data)[65:72])))
btf = ba2num(bptc_decode(_data)[65:72])
# Try resetting packet_assembly
packet_assembly = ''
# Data blocks at 1/2 rate, see https://github.com/g4klx/MMDVM/blob/master/DMRDefines.h for data types. _dtype_seq defined here also
if _dtype_vseq == 7:
btf = btf - 1
logger.info('Block #: ' + str(btf))
#logger.info(_seq)
global packet_assembly
logger.info('Data block from ' + str(int_id(_rf_src)))
logger.info('Data block from ' + str(get_alias(int_id(_rf_src), subscriber_ids)) + '. DMR ID: ' + str(int_id(_rf_src)))
logger.info(ahex(bptc_decode(_data)))
if _seq == 0:
n_packet_assembly = 0
packet_assembly = ''
if btf < btf + 1:
n_packet_assembly = n_packet_assembly + 1
packet_assembly = packet_assembly + str(bptc_decode(_data)) #str((decode_full_lc(b_packet)).strip('bitarray('))
#if btf < btf + 1:
# 14FRS2013 removed condition, works great!
n_packet_assembly = n_packet_assembly + 1
packet_assembly = packet_assembly + str(bptc_decode(_data)) #str((decode_full_lc(b_packet)).strip('bitarray('))
# Use block 0 as trigger. $GPRMC must also be in string to indicate NMEA.
# This triggers the APRS upload
if btf == 0: #_seq == 12:
final_packet = bitarray(re.sub("\)|\(|bitarray|'", '', packet_assembly)).tobytes().decode('utf-8', 'ignore')
if '$GPRMC' in final_packet:
if btf == 0:
final_packet = str(bitarray(re.sub("\)|\(|bitarray|'", '', packet_assembly)).tobytes().decode('utf-8', 'ignore'))
sms_hex = str(ba2hx(bitarray(re.sub("\)|\(|bitarray|'", '', packet_assembly))))
sms_hex_string = re.sub("b'|'", '', str(sms_hex))
#NMEA GPS sentence
if '$GPRMC' in final_packet or '$GNRMC' in final_packet:
logger.info(final_packet + '\n')
logger.info('Latitude: ' + re.sub(',', '', final_packet[29:40]) + ' Longitude: ' + re.sub(',', '', final_packet[41:53]) + ' Direction: ' + re.sub(',', '', final_packet[58:62]) + ' Speed: ' + re.sub(',', '', final_packet[53:58]))
# Begin APRS format and upload
aprs_loc_packet = str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + str(user_ssid) + '>APRS,TCPIP*:/' + str(datetime.datetime.utcnow().strftime("%H%M%Sh")) + str(final_packet[29:36]) + str(final_packet[39]) + '/' + str(re.sub(',', '', final_packet[41:49])) + str(final_packet[52]) + '[/' + aprs_comment + ' DMR ID: ' + str(int_id(_rf_src))
logger.info(aprs_loc_packet)
# Eliminate excess bytes based on NMEA type
# GPRMC
if 'GPRMC' in final_packet:
logger.info('GPRMC location')
#nmea_parse = re.sub('A\*.*|.*\$', '', str(final_packet))
nmea_parse = re.sub('A\*.*|.*\$|\n.*', '', str(final_packet))
# GNRMC
if 'GNRMC' in final_packet:
logger.info('GNRMC location')
nmea_parse = re.sub('.*\$|\n.*|V\*.*', '', final_packet)
loc = pynmea2.parse(nmea_parse, check=False)
logger.info('Latitude: ' + str(loc.lat) + str(loc.lat_dir) + ' Longitude: ' + str(loc.lon) + str(loc.lon_dir) + ' Direction: ' + str(loc.true_course) + ' Speed: ' + str(loc.spd_over_grnd) + '\n')
try:
# Try parse of APRS packet. If it fails, it will not upload to APRS-IS
# Begin APRS format and upload
# Disable opening file for reading to reduce "collision" or reading and writing at same time.
# 14FRS2013 simplified and moved settings retrieval
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
if int_id(_rf_src) not in user_settings:
ssid = str(user_ssid)
icon_table = '/'
icon_icon = '['
comment = aprs_comment + ' DMR ID: ' + str(int_id(_rf_src))
else:
if user_settings[int_id(_rf_src)][1]['ssid'] == '':
ssid = user_ssid
if user_settings[int_id(_rf_src)][3]['comment'] == '':
comment = aprs_comment + ' DMR ID: ' + str(int_id(_rf_src))
if user_settings[int_id(_rf_src)][2]['icon'] == '':
icon_table = '/'
icon_icon = '['
if user_settings[int_id(_rf_src)][2]['icon'] != '':
icon_table = user_settings[int_id(_rf_src)][2]['icon'][0]
icon_icon = user_settings[int_id(_rf_src)][2]['icon'][1]
if user_settings[int_id(_rf_src)][1]['ssid'] != '':
ssid = user_settings[int_id(_rf_src)][1]['ssid']
if user_settings[int_id(_rf_src)][3]['comment'] != '':
comment = user_settings[int_id(_rf_src)][3]['comment']
aprs_loc_packet = str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid + '>APHBL3,TCPIP*:@' + str(datetime.datetime.utcnow().strftime("%H%M%Sh")) + str(loc.lat[0:7]) + str(loc.lat_dir) + icon_table + str(loc.lon[0:8]) + str(loc.lon_dir) + icon_icon + str(round(loc.true_course)).zfill(3) + '/' + str(round(loc.spd_over_grnd)).zfill(3) + '/' + str(comment)
logger.info(aprs_loc_packet)
logger.info('User comment: ' + comment)
logger.info('User SSID: ' + ssid)
logger.info('User icon: ' + icon_table + icon_icon)
except Exception as error_exception:
logger.info('Error or user settings file not found, proceeding with default settings.')
aprs_loc_packet = str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + str(user_ssid) + '>APHBL3,TCPIP*:@' + str(datetime.datetime.utcnow().strftime("%H%M%Sh")) + str(loc.lat[0:7]) + str(loc.lat_dir) + '/' + str(loc.lon[0:8]) + str(loc.lon_dir) + '[' + str(round(loc.true_course)).zfill(3) + '/' + str(round(loc.spd_over_grnd)).zfill(3) + '/' + aprs_comment + ' DMR ID: ' + str(int_id(_rf_src))
logger.info(error_exception)
logger.info(str(traceback.extract_tb(error_exception.__traceback__)))
try:
# Try parse of APRS packet. If it fails, it will not upload to APRS-IS
aprslib.parse(aprs_loc_packet)
AIS = aprslib.IS(aprs_callsign, passwd=aprs_passcode,host=aprs_server, port=aprs_port)
AIS.connect()
AIS.sendall(aprs_loc_packet)
AIS.close()
except:
# Float values of lat and lon. Anything that is not a number will cause it to fail.
float(loc.lat)
float(loc.lon)
aprs_send(aprs_loc_packet)
dashboard_loc_write(str(get_alias(int_id(_rf_src), subscriber_ids)) + '-' + ssid, str(loc.lat[0:7]) + str(loc.lat_dir), str(loc.lon[0:8]) + str(loc.lon_dir), time.time(), comment)
except Exception as error_exception:
logger.info('Failed to parse packet. Packet may be deformed. Not uploaded.')
logger.info(error_exception)
logger.info(str(traceback.extract_tb(error_exception.__traceback__)))
#final_packet = ''
# Get callsign based on DMR ID
#logger.info(get_alias(int_id(_rf_src), subscriber_ids))
# End APRS-IS upload
else:
logger.info(final_packet)
packet_assembly = ''
logger.info(_seq)
#logger.info(_dtype_vseq)
logger.info(ahex(bptc_decode(_data)).decode('utf-8', 'ignore'))
# Assume this is an SMS message
elif '$GPRMC' not in final_packet or '$GNRMC' not in final_packet:
#### # Motorola type SMS header
## if '824a' in hdr_start or '024a' in hdr_start:
## logger.info('\nMotorola type SMS')
## sms = codecs.decode(bytes.fromhex(''.join(sms_hex[74:-8].split('00'))), 'utf-8')
## logger.info('\n\n' + 'Received SMS from ' + str(get_alias(int_id(_rf_src), subscriber_ids)) + ', DMR ID: ' + str(int_id(_rf_src)) + ': ' + str(sms) + '\n')
## process_sms(_rf_src, sms)
## packet_assembly = ''
## # ETSI? type SMS header
## elif '0244' in hdr_start or '8244' in hdr_start:
## logger.info('ETSI? type SMS')
## sms = codecs.decode(bytes.fromhex(''.join(sms_hex[64:-8].split('00'))), 'utf-8')
## logger.info('\n\n' + 'Received SMS from ' + str(get_alias(int_id(_rf_src), subscriber_ids)) + ', DMR ID: ' + str(int_id(_rf_src)) + ': ' + str(sms) + '\n')
## #logger.info(final_packet)
## #logger.info(sms_hex[64:-8])
## process_sms(_rf_src, sms)
## packet_assembly = ''
####
## else:
logger.info('\nSMS detected. Attempting to parse.')
#logger.info(final_packet)
logger.info(sms_hex)
## logger.info(type(sms_hex))
logger.info('Attempting to find command...')
## sms = codecs.decode(bytes.fromhex(''.join(sms_hex[:-8].split('00'))), 'utf-8', 'ignore')
sms = codecs.decode(bytes.fromhex(''.join(sms_hex_string[:-8].split('00'))), 'utf-8', 'ignore')
msg_found = re.sub('.*\n', '', sms)
logger.info('\n\n' + 'Received SMS from ' + str(get_alias(int_id(_rf_src), subscriber_ids)) + ', DMR ID: ' + str(int_id(_rf_src)) + ': ' + str(msg_found) + '\n')
process_sms(_rf_src, msg_found)
#packet_assembly = ''
pass
#logger.info(bitarray(re.sub("\)|\(|bitarray|'", '', str(bptc_decode(_data)).tobytes().decode('utf-8', 'ignore'))))
#logger.info('\n\n' + 'Received SMS from ' + str(get_alias(int_id(_rf_src), subscriber_ids)) + ', DMR ID: ' + str(int_id(_rf_src)) + ': ' + str(sms) + '\n')
# Reset the packet assembly to prevent old data from returning.
# 14FRS2013 moved variable reset
hdr_start = ''
n_packet_assembly = 0
packet_assembly = ''
btf = 0
#logger.info(_seq)
#packet_assembly = '' #logger.info(_dtype_vseq)
#logger.info(ahex(bptc_decode(_data)).decode('utf-8', 'ignore'))
#logger.info(bitarray(re.sub("\)|\(|bitarray|'", '', str(bptc_decode(_data)).tobytes().decode('utf-8', 'ignore'))))
else:
@ -203,6 +691,7 @@ class DATA_SYSTEM(HBSYSTEM):
#************************************************
if __name__ == '__main__':
#global aprs_callsign, aprs_passcode, aprs_server, aprs_port, user_ssid, aprs_comment, call_type, data_id
import argparse
import sys
import os
@ -212,19 +701,77 @@ if __name__ == '__main__':
# Change the current directory to the location of the application
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])))
# CLI argument parser - handles picking up the config file from the command line, and sending a "help" message
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually hblink.cfg)')
parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually gps_data.cfg)')
parser.add_argument('-l', '--logging', action='store', dest='LOG_LEVEL', help='Override config file logging level.')
cli_args = parser.parse_args()
# Ensure we have a path for the config file, if one wasn't specified, then use the default (top of file)
if not cli_args.CONFIG_FILE:
cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/hblink.cfg'
cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/gps_data.cfg'
# Call the external routine to build the configuration dictionary
CONFIG = config.build_config(cli_args.CONFIG_FILE)
data_id = int(CONFIG['GPS_DATA']['DATA_DMR_ID'])
# Group call or Unit (private) call
call_type = CONFIG['GPS_DATA']['CALL_TYPE']
# APRS-IS login information
aprs_callsign = CONFIG['GPS_DATA']['APRS_LOGIN_CALL']
aprs_passcode = int(CONFIG['GPS_DATA']['APRS_LOGIN_PASSCODE'])
aprs_server = CONFIG['GPS_DATA']['APRS_SERVER']
aprs_port = int(CONFIG['GPS_DATA']['APRS_PORT'])
user_ssid = CONFIG['GPS_DATA']['USER_APRS_SSID']
aprs_comment = CONFIG['GPS_DATA']['USER_APRS_COMMENT']
# EMAIL variables
email_sender = CONFIG['GPS_DATA']['EMAIL_SENDER']
email_password = CONFIG['GPS_DATA']['EMAIL_PASSWORD']
smtp_server = CONFIG['GPS_DATA']['SMTP_SERVER']
smtp_port = CONFIG['GPS_DATA']['SMTP_PORT']
# Dashboard files
bb_file = CONFIG['GPS_DATA']['BULLETIN_BOARD_FILE']
loc_file = CONFIG['GPS_DATA']['LOCATION_FILE']
the_mailbox_file = CONFIG['GPS_DATA']['MAILBOX_FILE']
emergency_sos_file = CONFIG['GPS_DATA']['EMERGENCY_SOS_FILE']
# User APRS settings
user_settings_file = CONFIG['GPS_DATA']['USER_SETTINGS_FILE']
# Check if user_settings (for APRS settings of users) exists. Creat it if not.
if Path(user_settings_file).is_file():
pass
else:
Path(user_settings_file).touch()
with open(user_settings_file, 'w') as user_dict_file:
user_dict_file.write("{1: [{'call': 'N0CALL'}, {'ssid': ''}, {'icon': ''}, {'comment': ''}]}")
user_dict_file.close()
# Check to see if dashboard files exist
if Path(loc_file).is_file():
pass
else:
Path(loc_file).touch()
with open(loc_file, 'w') as user_loc_file:
user_loc_file.write("[]")
user_loc_file.close()
if Path(bb_file).is_file():
pass
else:
Path(bb_file).touch()
with open(bb_file, 'w') as user_bb_file:
user_bb_file.write("[]")
user_bb_file.close()
if Path(the_mailbox_file).is_file():
pass
else:
Path(the_mailbox_file).touch()
with open(the_mailbox_file, 'w') as user_mail_file:
user_mail_file.write("[]")
user_mail_file.close()
# Start the system logger
if cli_args.LOG_LEVEL:
CONFIG['LOGGER']['LOG_LEVEL'] = cli_args.LOG_LEVEL

60
gps_data_igate_beacon.py Normal file
View File

@ -0,0 +1,60 @@
#!/usr/bin/env python
#
###############################################################################
# HBLink - Copyright (C) 2020 Cortney T. Buffington, N0MJS <n0mjs@me.com>
# GPS/Data - Copyright (C) 2020 Eric Craw, KF7EEL <kf7eel@qsl.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
###############################################################################
'''
This script uploads a beacon to APRS-IS for the GPS/Data Application itself, cuasing it to appear as an igate
an aprs.fi.
'''
import aprslib
import argparse
import os
import config
import time
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually gps_data.cfg)')
cli_args = parser.parse_args()
if not cli_args.CONFIG_FILE:
cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/gps_data.cfg'
CONFIG = config.build_config(cli_args.CONFIG_FILE)
print('''
GPS/Data Application Beacon Script by Eric, KF7EEL. https://github.com/kf7eel/hblink3 \n
This script will upload an APRS position for the GPS/Data Application. This usually causes most APRS-IS clients to see the GPS/Data Application
as an i-gate. \n
Using the following setting to upload beacon.\n
Callsign: ''' + CONFIG['GPS_DATA']['APRS_LOGIN_CALL'] + ''' - Position comment: ''' + CONFIG['GPS_DATA']['IGATE_BEACON_COMMENT'] + '''
Beacon time: ''' + CONFIG['GPS_DATA']['IGATE_BEACON_TIME'] + '''
''')
beacon_packet = CONFIG['GPS_DATA']['APRS_LOGIN_CALL'] + '>APHBL3,TCPIP*:!' + CONFIG['GPS_DATA']['IGATE_LATITUDE'] + str(CONFIG['GPS_DATA']['IGATE_BEACON_ICON'][0]) + CONFIG['GPS_DATA']['IGATE_LONGITUDE'] + str(CONFIG['GPS_DATA']['IGATE_BEACON_ICON'][1]) + '/' + CONFIG['GPS_DATA']['IGATE_BEACON_COMMENT']
#print(beacon_packet)
AIS = aprslib.IS(CONFIG['GPS_DATA']['APRS_LOGIN_CALL'], passwd=CONFIG['GPS_DATA']['APRS_LOGIN_PASSCODE'],host=CONFIG['GPS_DATA']['APRS_SERVER'], port=CONFIG['GPS_DATA']['APRS_PORT'])
while int(CONFIG['GPS_DATA']['IGATE_BEACON_TIME']) > 15:
AIS.connect()
AIS.sendall(beacon_packet)
print(beacon_packet)
AIS.close()
time.sleep(int(CONFIG['GPS_DATA']['IGATE_BEACON_TIME'])*60)

11
gps_functions.py Normal file
View File

@ -0,0 +1,11 @@
# Various configurable options used in the GPS/Data application.
# SMS message that triggers command
cmd_list = {
'COMMAND' : 'echo "command to execute"',
'UPTIME' : 'uptime'
}

View File

@ -126,7 +126,7 @@ STALE_DAYS: 7
# Otherwise ACLs work as described in the global stanza
[OBP-1]
MODE: OPENBRIDGE
ENABLED: True
ENABLED: False
IP:
PORT: 62035
NETWORK_ID: 3129100
@ -167,6 +167,22 @@ SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL
[D-APRS]
MODE: MASTER
ENABLED: True
REPEAT: True
MAX_PEERS: 2
EXPORT_AMBE: False
IP:
PORT: 54070
PASSPHRASE: passw0rd
GROUP_HANGTIME: 5
USE_ACL: True
REG_ACL: DENY:1
SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL
# PEER INSTANCES - DUPLICATE SECTION FOR MULTIPLE PEERS
# There are a LOT of errors in the HB Protocol specifications on this one!
# MOST of these items are just strings and will be properly dealt with by the program
@ -181,7 +197,7 @@ TGID_TS2_ACL: PERMIT:ALL
# See comments in the GLOBAL stanza
[REPEATER-1]
MODE: PEER
ENABLED: True
ENABLED: False
LOOSE: False
EXPORT_AMBE: False
IP:
@ -211,9 +227,41 @@ SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL
[ECHO]
MODE: PEER
ENABLED: True
LOOSE: False
EXPORT_AMBE: False
IP:
PORT: 54073
MASTER_IP: localhost
MASTER_PORT: 54072
passphrase: passw0rd
CALLSIGN: ECHO
RADIO_ID: 9999
RX_FREQ: 000000000
TX_FREQ: 000000000
TX_POWER: 0
COLORCODE: 1
SLOTS: 1
LATITUDE: 00.0000
LONGITUDE: 000.0000
HEIGHT: 0
LOCATION: This Server
DESCRIPTION: Echo Server
URL: www.github.com/kf7eel/hblink3
SOFTWARE_ID: 20170620
PACKAGE_ID: MMDVM_HBlink
GROUP_HANGTIME: 5
OPTIONS:
USE_ACL: True
SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL
[XLX-1]
MODE: XLXPEER
ENABLED: True
ENABLED: False
LOOSE: True
EXPORT_AMBE: False
IP:

0
hblink.py Executable file → Normal file
View File

5
install.sh Normal file
View File

@ -0,0 +1,5 @@
#! /bin/bash
# Install the required support programs
apt-get install python3 python3-pip -y
pip3 install -r requirements.txt

209
playback.cfg Normal file
View File

@ -0,0 +1,209 @@
# PROGRAM-WIDE PARAMETERS GO HERE
# PATH - working path for files, leave it alone unless you NEED to change it
# PING_TIME - the interval that peers will ping the master, and re-try registraion
# - how often the Master maintenance loop runs
# MAX_MISSED - how many pings are missed before we give up and re-register
# - number of times the master maintenance loop runs before de-registering a peer
#
# ACLs:
#
# Access Control Lists are a very powerful tool for administering your system.
# But they consume packet processing time. Disable them if you are not using them.
# But be aware that, as of now, the configuration stanzas still need the ACL
# sections configured even if you're not using them.
#
# REGISTRATION ACLS ARE ALWAYS USED, ONLY SUBSCRIBER AND TGID MAY BE DISABLED!!!
#
# The 'action' May be PERMIT|DENY
# Each entry may be a single radio id, or a hypenated range (e.g. 1-2999)
# Format:
# ACL = 'action:id|start-end|,id|start-end,....'
# --for example--
# SUB_ACL: DENY:1,1000-2000,4500-60000,17
#
# ACL Types:
# REG_ACL: peer radio IDs for registration (only used on HBP master systems)
# SUB_ACL: subscriber IDs for end-users
# TGID_TS1_ACL: destination talkgroup IDs on Timeslot 1
# TGID_TS2_ACL: destination talkgroup IDs on Timeslot 2
#
# ACLs may be repeated for individual systems if needed for granularity
# Global ACLs will be processed BEFORE the system level ACLs
# Packets will be matched against all ACLs, GLOBAL first. If a packet 'passes'
# All elements, processing continues. Packets are discarded at the first
# negative match, or 'reject' from an ACL element.
#
# If you do not wish to use ACLs, set them to 'PERMIT:ALL'
# TGID_TS1_ACL in the global stanza is used for OPENBRIDGE systems, since all
# traffic is passed as TS 1 between OpenBridges
[GLOBAL]
PATH: ./
PING_TIME: 5
MAX_MISSED: 3
USE_ACL: True
REG_ACL: PERMIT:ALL
SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL
# NOT YET WORKING: NETWORK REPORTING CONFIGURATION
# Enabling "REPORT" will configure a socket-based reporting
# system that will send the configuration and other items
# to a another process (local or remote) that may process
# the information for some useful purpose, like a web dashboard.
#
# REPORT - True to enable, False to disable
# REPORT_INTERVAL - Seconds between reports
# REPORT_PORT - TCP port to listen on if "REPORT_NETWORKS" = NETWORK
# REPORT_CLIENTS - comma separated list of IPs you will allow clients
# to connect on. Entering a * will allow all.
#
# ****FOR NOW MUST BE TRUE - USE THE LOOPBACK IF YOU DON'T USE THIS!!!****
[REPORTS]
REPORT: True
REPORT_INTERVAL: 60
REPORT_PORT: 4322
REPORT_CLIENTS: 127.0.0.1
# SYSTEM LOGGER CONFIGURAITON
# This allows the logger to be configured without chaning the individual
# python logger stuff. LOG_FILE should be a complete path/filename for *your*
# system -- use /dev/null for non-file handlers.
# LOG_HANDLERS may be any of the following, please, no spaces in the
# list if you use several:
# null
# console
# console-timed
# file
# file-timed
# syslog
# LOG_LEVEL may be any of the standard syslog logging levels, though
# as of now, DEBUG, INFO, WARNING and CRITICAL are the only ones
# used.
#
[LOGGER]
LOG_FILE: /tmp/hb-playback.log
LOG_HANDLERS: console
LOG_LEVEL: DEBUG
LOG_NAME: HBlink3 Playback
# DOWNLOAD AND IMPORT SUBSCRIBER, PEER and TGID ALIASES
# Ok, not the TGID, there's no master list I know of to download
# This is intended as a facility for other applcations built on top of
# HBlink to use, and will NOT be used in HBlink directly.
# STALE_DAYS is the number of days since the last download before we
# download again. Don't be an ass and change this to less than a few days.
[ALIASES]
TRY_DOWNLOAD: False
PATH: ./
PEER_FILE: peer_ids.json
SUBSCRIBER_FILE: subscriber_ids.json
TGID_FILE: talkgroup_ids.json
PEER_URL: https://www.radioid.net/static/rptrs.json
SUBSCRIBER_URL: https://www.radioid.net/static/users.json
STALE_DAYS: 7
# OPENBRIDGE INSTANCES - DUPLICATE SECTION FOR MULTIPLE CONNECTIONS
# OpenBridge is a protocol originall created by DMR+ for connection between an
# IPSC2 server and Brandmeister. It has been implemented here at the suggestion
# of the Brandmeister team as a way to legitimately connect HBlink to the
# Brandemiester network.
# It is recommended to name the system the ID of the Brandmeister server that
# it connects to, but is not necessary. TARGET_IP and TARGET_PORT are of the
# Brandmeister or IPSC2 server you are connecting to. PASSPHRASE is the password
# that must be agreed upon between you and the operator of the server you are
# connecting to. NETWORK_ID is a number in the format of a DMR Radio ID that
# will be sent to the other server to identify this connection.
# other parameters follow the other system types.
#
# ACLs:
# OpenBridge does not 'register', so registration ACL is meaningless.
# OpenBridge passes all traffic on TS1, so there is only 1 TGID ACL.
# Otherwise ACLs work as described in the global stanza
#[OBP-1]
#MODE: OPENBRIDGE
#ENABLED: True
#IP:
#PORT: 62035
#NETWORK_ID: 3129100
#PASSPHRASE: password
#TARGET_IP: 1.2.3.4
#TARGET_PORT: 62035
#USE_ACL: True
#SUB_ACL: DENY:1
#TGID_ACL: PERMIT:ALL
# MASTER INSTANCES - DUPLICATE SECTION FOR MULTIPLE MASTERS
# HomeBrew Protocol Master instances go here.
# IP may be left blank if there's one interface on your system.
# Port should be the port you want this master to listen on. It must be unique
# and unused by anything else.
# Repeat - if True, the master repeats traffic to peers, False, it does nothing.
#
# MAX_PEERS -- maximun number of peers that may be connect to this master
# at any given time. This is very handy if you're allowing hotspots to
# connect, or using a limited computer like a Raspberry Pi.
#
# ACLs:
# See comments in the GLOBAL stanza
[MASTER]
MODE: MASTER
ENABLED: True
REPEAT: True
MAX_PEERS: 1
EXPORT_AMBE: False
IP:
PORT: 54072
PASSPHRASE: passw0rd
GROUP_HANGTIME: 5
USE_ACL: True
REG_ACL: DENY:1
SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL
# PEER INSTANCES - DUPLICATE SECTION FOR MULTIPLE PEERS
# There are a LOT of errors in the HB Protocol specifications on this one!
# MOST of these items are just strings and will be properly dealt with by the program
# The TX & RX Frequencies are 9-digit numbers, and are the frequency in Hz.
# Latitude is an 8-digit unsigned floating point number.
# Longitude is a 9-digit signed floating point number.
# Height is in meters
# Setting Loose to True relaxes the validation on packets received from the master.
# This will allow HBlink to connect to a non-compliant system such as XLXD, DMR+ etc.
#
# ACLs:
# See comments in the GLOBAL stanza
#[REPEATER-1]
#MODE: PEER
#ENABLED: True
#LOOSE: False
#EXPORT_AMBE: False
#IP:
#PORT: 54001
#MASTER_IP: 172.16.1.1
#MASTER_PORT: 54000
#PASSPHRASE: homebrew
#CALLSIGN: W1ABC
#RADIO_ID: 312000
#RX_FREQ: 449000000
#TX_FREQ: 444000000
#TX_POWER: 25
#COLORCODE: 1
#SLOTS: 1
#LATITUDE: 38.0000
#LONGITUDE: -095.0000
#HEIGHT: 75
#LOCATION: Anywhere, USA
#DESCRIPTION: This is a cool repeater
#URL: www.w1abc.org
#SOFTWARE_ID: 20170620
#PACKAGE_ID: MMDVM_HBlink
#GROUP_HANGTIME: 5
#OPTIONS:
#USE_ACL: True
#SUB_ACL: DENY:1
#TGID_TS1_ACL: PERMIT:ALL
#TGID_TS2_ACL: PERMIT:ALL

View File

@ -169,13 +169,13 @@ if __name__ == '__main__':
# CLI argument parser - handles picking up the config file from the command line, and sending a "help" message
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually hblink.cfg)')
parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually playback.cfg)')
parser.add_argument('-l', '--logging', action='store', dest='LOG_LEVEL', help='Override config file logging level.')
cli_args = parser.parse_args()
# Ensure we have a path for the config file, if one wasn't specified, then use the default (top of file)
if not cli_args.CONFIG_FILE:
cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/hblink.cfg'
cli_args.CONFIG_FILE = os.path.dirname(os.path.abspath(__file__))+'/playback.cfg'
# Call the external routine to build the configuration dictionary
CONFIG = config.build_config(cli_args.CONFIG_FILE)

View File

@ -3,3 +3,8 @@ bitarray>=0.8.1
Twisted>=16.3.0
dmr_utils3>=0.1.19
configparser>=3.0.0
aprslib>=0.6.42
pynmea2
maidenhead
flask
folium

View File

@ -33,17 +33,17 @@ configuration file.
'''
BRIDGES = {
'WORLDWIDE': [
{'SYSTEM': 'MASTER-1', 'TS': 1, 'TGID': 1, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'ON', 'ON': [2,], 'OFF': [9,10], 'RESET': []},
{'SYSTEM': 'CLIENT-1', 'TS': 1, 'TGID': 3100, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'ON', 'ON': [2,], 'OFF': [9,10], 'RESET': []},
],
'ENGLISH': [
{'SYSTEM': 'MASTER-1', 'TS': 1, 'TGID': 13, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [3,], 'OFF': [8,10], 'RESET': []},
{'SYSTEM': 'CLIENT-2', 'TS': 1, 'TGID': 13, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [3,], 'OFF': [8,10], 'RESET': []},
],
'STATEWIDE': [
{'SYSTEM': 'MASTER-1', 'TS': 2, 'TGID': 3129, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [4,], 'OFF': [7,10], 'RESET': []},
{'SYSTEM': 'CLIENT-2', 'TS': 2, 'TGID': 3129, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [4,], 'OFF': [7,10], 'RESET': []},
## 'ENGLISH': [
## {'SYSTEM': 'CHANGE_ME-1', 'TS': 1, 'TGID': 13, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [3,], 'OFF': [8,10], 'RESET': []},
## {'SYSTEM': 'CHANGE_ME-2', 'TS': 1, 'TGID': 13, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [3,], 'OFF': [8,10], 'RESET': []},
## ],
## 'STATEWIDE': [
## {'SYSTEM': 'CHANGE_ME-1', 'TS': 2, 'TGID': 3129, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [4,], 'OFF': [7,10], 'RESET': []},
## {'SYSTEM': 'CHANGE_ME-2', 'TS': 2, 'TGID': 3129, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [4,], 'OFF': [7,10], 'RESET': []},
## ],
'ECHO': [
{'SYSTEM': 'MASTER-1', 'TS': 2, 'TGID': 9999, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'ON', 'ON': [9999,], 'OFF': [9,10], 'RESET': []},
{'SYSTEM': 'ECHO', 'TS': 2, 'TGID': 9999, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'ON', 'ON': [9999,], 'OFF': [9,10], 'RESET': []},
]
}
@ -51,7 +51,29 @@ BRIDGES = {
list the names of each system that should bridge unit to unit (individual) calls.
'''
UNIT = ['ONE', 'TWO']
UNIT = ['MASTER-1', 'CHANGE_ME']
'''
Unit Call flood timeout:
The amount of time to keep sending private calls to a single system before
flooding all systems with the call. A higher value should be set for systems where subscribers
are not moving between systems often. A lower value should be set for systems that have subscribers
moving between systems often.
Time is in minutes.
'''
UNIT_TIME = 1
'''
Input the DMR ID and SYSTEM of a subscriber that you would like to have always have private calls routed.
This will not flood all systems.
'''
STATIC_UNIT = [
# [ 456, 'CLIENT-1'],
# [ 123, 'MASTER-1'],
[ 9099, 'D-APRS']
]
'''
This is for testing the syntax of the file. It won't eliminate all errors, but running this file
@ -62,3 +84,4 @@ if __name__ == '__main__':
from pprint import pprint
pprint(BRIDGES)
print(UNIT)
print(STATIC_UNIT)

View File

@ -0,0 +1,85 @@
###############################################################################
# GPS/Data - Copyright (C) 2020 Eric Craw, KF7EEL <kf7eel@qsl.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
###############################################################################
import aprslib
import ast, os
import re
from configparser import ConfigParser
import time
import argparse
def mailbox_write(call, dmr_id, time, message, recipient):
global mailbox_file
mail_file = ast.literal_eval(os.popen('cat ' + parser.get('GPS_DATA', 'MAILBOX_FILE')).read())
mail_file.insert(0, {'call': call, 'dmr_id': dmr_id, 'time': time, 'message':message, 'recipient': recipient})
with open(parser.get('GPS_DATA', 'MAILBOX_FILE'), 'w') as mailbox_file:
mailbox_file.write(str(mail_file[:100]))
mailbox_file.close()
print('User mail saved.')
def aprs_filter(packet):
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
if 'addresse' in aprslib.parse(packet):
#print(aprslib.parse(packet))
recipient = re.sub('-.*','', aprslib.parse(packet)['addresse'])
recipient_ssid = re.sub('.*-','', aprslib.parse(packet)['addresse'])
if recipient == '':
pass
else:
for i in user_settings.items():
ssid = i[1][1]['ssid']
if i[1][1]['ssid'] == '':
ssid = user_aprs_ssid
if recipient in i[1][0]['call'] and recipient_ssid in ssid:
mailbox_write(re.sub('-.*','', aprslib.parse(packet)['addresse']), aprslib.parse(packet)['from'], time.time(), aprslib.parse(packet)['message_text'], recipient)
if 'msgNo' in aprslib.parse(packet):
time.sleep(1)
AIS.sendall(aprslib.parse(packet)['addresse'] + '>APHBL3,TCPIP*:' + ':' + aprslib.parse(packet)['from'].ljust(9) +':ack'+aprslib.parse(packet)['msgNo'])
print('Send ACK')
print(aprslib.parse(packet)['addresse'] + '>APHBL3,TCPIP*:' + ':' + aprslib.parse(packet)['from'].ljust(9) +':ack'+aprslib.parse(packet)['msgNo'])
## else:
## print(aprslib.parse(packet)['from'])
if __name__ == '__main__':
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually gps_data.cfg)')
cli_args = arg_parser.parse_args()
parser = ConfigParser()
if not cli_args.CONFIG_FILE:
print('\n\nMust specify a config file with -c argument.\n\n')
parser.read(cli_args.CONFIG_FILE)
aprs_server = parser.get('GPS_DATA', 'APRS_SERVER')
aprs_port = parser.get('GPS_DATA', 'APRS_PORT')
aprs_login = parser.get('GPS_DATA', 'APRS_RECEIVE_LOGIN_CALL')
aprs_passcode = parser.get('GPS_DATA', 'APRS_LOGIN_PASSCODE')
mailbox_file = parser.get('GPS_DATA', 'MAILBOX_FILE')
user_settings_file = parser.get('GPS_DATA', 'USER_SETTINGS_FILE')
user_aprs_ssid = parser.get('GPS_DATA', 'USER_APRS_SSID')
AIS = aprslib.IS(aprs_login, passwd=int(aprs_passcode), host=aprs_server, port=int(aprs_port))
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
print('APRS message receive script for GPS/Data Application.\nAuthor: Eric, KF7EEL - kf7eel@qsl.net')
AIS.set_filter(parser.get('GPS_DATA', 'APRS_FILTER'))
AIS.connect()
print('Connecting to APRS-IS')
AIS.consumer(aprs_filter, raw=True)

View File

@ -0,0 +1,764 @@
###############################################################################
# HBLink - Copyright (C) 2020 Cortney T. Buffington, N0MJS <n0mjs@me.com>
# GPS/Data - Copyright (C) 2020 Eric Craw, KF7EEL <kf7eel@qsl.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
###############################################################################
'''
This is a web dashboard for the GPS/Data application.
'''
from flask import Flask, render_template, request, Response, Markup
import ast, os
#from dashboard_settings import *
import folium
from folium.plugins import MarkerCluster
import re
from datetime import datetime
import argparse
from configparser import ConfigParser
app = Flask(__name__)
tbl_hdr = '''
<table style="border-color: black; margin-left: auto; margin-right: auto;" border="2" cellspacing="6" cellpadding="2"><tbody>
'''
tbl_ftr = '''
</tbody>
</table>
'''
def get_loc_data():
try:
dash_loc = ast.literal_eval(os.popen('cat ' + loc_file).read())
tmp_loc = ''
loc_hdr = '''
<tr>
<td style="text-align: center;">
<h2><strong>&nbsp;Callsign&nbsp;</strong></h2>
</td>
<td style="text-align: center;">
<h2>&nbsp;<strong>Latitude</strong>&nbsp; </h2>
</td>
<td style="text-align: center;">
<h2>&nbsp;<strong>Longitude</strong>&nbsp;</h2>
</td>
<td style="text-align: center;">
<h2>&nbsp;<strong>Time</strong>&nbsp;</h2>
</td>
</tr>
'''
last_known_loc_list = []
display_number = 15
for e in dash_loc:
if display_number == 0:
break
else:
if e['call'] in last_known_loc_list:
pass
if e['call'] not in last_known_loc_list:
if type(e['time']) == str:
loc_time = str(e['time'])
if type(e['time']) == int or type(e['time']) == float:
loc_time = datetime.fromtimestamp(e['time']).strftime(time_format)
last_known_loc_list.append(e['call'])
display_number = display_number - 1
tmp_loc = tmp_loc + '''<tr>
<td style="text-align: center;"><a href="view_map?track=''' + e['call'] + '''"target="_blank"><strong>''' + e['call'] + '''</strong></a></td>
<td style="text-align: center;"><strong>&nbsp;''' + str(e['lat']) + '''&nbsp;</strong></td>
<td style="text-align: center;"><strong>&nbsp;''' + str(e['lon']) + '''&nbsp;</strong></td>
<td style="text-align: center;">&nbsp;''' + loc_time + '''&nbsp;</td>
</tr>'''
return str(str('<h1 style="text-align: center;">Last Known Location</h1>') + tbl_hdr + loc_hdr + tmp_loc + tbl_ftr)
except:
return str('<h1 style="text-align: center;">No data</h1>')
def get_bb_data():
try:
dash_bb = ast.literal_eval(os.popen('cat ' + bb_file).read())
tmp_bb = ''
bb_hdr = '''
<tr>
<td style="text-align: center;">
<h2><strong>&nbsp;Callsign&nbsp;</strong></h2>
</td>
<td style="text-align: center;">
<h2>&nbsp;<strong>ID</strong>&nbsp; </h2>
</td>
<td style="text-align: center;">
<h2>&nbsp;<strong>Bulletin</strong>&nbsp;</h2>
</td>
<td style="text-align: center;">
<h2>&nbsp;<strong>Time</strong>&nbsp;</h2>
</td>
</tr>
'''
display_number = 10
for e in dash_bb:
if display_number == 0:
break
else:
if type(e['time']) == str:
loc_time = str(e['time'])
if type(e['time']) == int or type(e['time']) == float:
loc_time = datetime.fromtimestamp(e['time']).strftime(time_format)
display_number = display_number - 1
tmp_bb = tmp_bb + '''<tr>
<td style="text-align: center;"><strong>&nbsp;''' + e['call'] + '''&nbsp;</strong></td>
<td style="text-align: center;">''' + str(e['dmr_id']) + '''</td>
<td style="text-align: center;"><strong>&nbsp;''' + e['bulletin'] + '''&nbsp;</strong></td>
<td style="text-align: center;">&nbsp;''' + loc_time + '''&nbsp;</td>
</tr>'''
return str('<h1 style="text-align: center;">Bulletin Board</h1>' + tbl_hdr + bb_hdr + tmp_bb + tbl_ftr)
except:
return str('<h1 style="text-align: center;">No data</h1>')
def check_emergency():
# open emergency txt
try:
sos_file = ast.literal_eval(os.popen('cat ' + emergency_sos_file).read())
if type(sos_file['time']) == str:
loc_time = str(sos_file['time'])
if type(sos_file['time']) == int or type(sos_file['time']) == float:
loc_time = datetime.fromtimestamp(sos_file['time']).strftime(time_format)
if '@NOTICE' in sos_file['message'] and '@SOS' not in sos_file['message']:
notice_header = '<span style="background-color: #ffffff; color: #008000;">NOTICE:</span>'
else:
notice_header = '<span style="background-color: #ff0000; color: #ffffff;">EMERGENCY ACTIVATION</span>'
value = Markup("""
<h1 style="text-align: center;">""" + notice_header + """</h1>
<table style="width: 441px; margin-left: auto; margin-right: auto;" border="3">
<tbody>
<tr>
<td style="width: 78.3667px;"><span style="text-decoration: underline;"><strong>From:</strong></span></td>
<td style="width: 345.633px; text-align: center;"><strong>""" + sos_file['call'] + """</strong> - """ + str(sos_file['dmr_id']) + """</td>
</tr>
<tr>
<td style="width: 78.3667px;"><span style="text-decoration: underline;"><strong>Message:</strong></span></td>
<td style="width: 345.633px; text-align: center;">""" + sos_file['message'] + """</td>
</tr>
<tr>
<td style="width: 78.3667px;"><span style="text-decoration: underline;"><strong>Time:</strong></span></td>
<td style="width: 345.633px; text-align: center;">""" + loc_time + """</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<button onclick="window.open('view_map?track=""" + sos_file['call'] + """&reload=30','_blank' );" type="button" class="emergency_button"><h1>View Station on Map</h1></button>
<p style="text-align: center;"><a href="https://aprs.fi/""" + sos_file['call'] + """"><strong>View on aprs.fi</strong></a></p>
<hr />
""")
return value
except Exception as e:
return ''
def aprs_to_latlon(x):
degrees = int(x) // 100
minutes = x - 100*degrees
return degrees + minutes/60
def user_setting_write(dmr_id, input_ssid, input_icon, input_comment):
dmr_id = int(dmr_id)
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
new_dict = user_settings
new_dict[dmr_id][1]['ssid'] = input_ssid
new_dict[dmr_id][2]['icon'] = input_icon
new_dict[dmr_id][3]['comment'] = input_comment
print(input_comment)
print(new_dict[dmr_id])
# Write modified dict to file
with open(user_settings_file, 'w') as user_dict_file:
user_dict_file.write(str(new_dict))
user_dict_file.close()
@app.route('/')
def index():
value = Markup('<strong>The HTML String</strong>')
#return get_data()
return render_template('index.html', title = dashboard_title, logo = logo, emergency = check_emergency())
@app.route('/bulletin_board')
def dash_bb():
return get_bb_data()
#return render_template('index.html', data = str(get_data()))
@app.route('/positions')
def dash_loc():
return get_loc_data()
@app.route('/help/')
def help():
#return get_data()
return render_template('help.html', title = dashboard_title, logo = logo, description = description, data_call_type = data_call_type, data_call_id = data_call_id, aprs_ssid = aprs_ssid)
@app.route('/about/')
def about():
#return get_data()
return render_template('about.html', title = dashboard_title, logo = logo, contact_name = contact_name, contact_call = contact_call, contact_email = contact_email, contact_website = contact_website)
@app.route('/view_map')
def view_map():
reload_time = request.args.get('reload')
track_call = request.args.get('track')
map_size = request.args.get('map_size')
user_loc = ast.literal_eval(os.popen('cat ' + loc_file).read())
last_known_list = []
coord_list = []
try:
if track_call:
#folium_map = folium.Map(location=map_center, zoom_start=int(zoom_level))
#marker_cluster = MarkerCluster().add_to(folium_map)
for user_coord in user_loc:
user_lat = aprs_to_latlon(float(re.sub('[A-Za-z]','', user_coord['lat'])))
user_lon = aprs_to_latlon(float(re.sub('[A-Za-z]','', user_coord['lon'])))
if type(user_coord['time']) == str:
loc_time = str(user_coord['time'])
if type(user_coord['time']) == int or type(user_coord['time']) == float:
loc_time = datetime.fromtimestamp(user_coord['time']).strftime(time_format)
if 'S' in user_coord['lat']:
user_lat = -user_lat
if 'W' in user_coord['lon']:
user_lon = -user_lon
loc_comment = ''
if 'comment' in user_coord:
loc_comment = """
<tr>
<td style="text-align: center;">Comment:</td>
</tr>
<tr>
<td style="text-align: center;"><strong>"""+ str(user_coord['comment']) +"""</strong></td>
</tr>"""
if user_coord['call'] not in last_known_list and user_coord['call'] == track_call:
folium_map = folium.Map(location=[user_lat, user_lon], tiles=map_theme, zoom_start=15)
marker_cluster = MarkerCluster().add_to(folium_map)
folium.Marker([user_lat, user_lon], popup="""<i>
<table style="width: 150px;">
<tbody>
<tr>
<td style="text-align: center;">Last Location:</td>
</tr>
<tr>
<td style="text-align: center;"><strong>"""+ str(user_coord['call']) +"""</strong></td>
</tr>
<tr>
<td style="text-align: center;"><em>"""+ loc_time +"""</em></td>
""" + loc_comment + """
</tr>
</tbody>
</table>
</i>
""", icon=folium.Icon(color="red", icon="record"), tooltip=str(user_coord['call'])).add_to(folium_map)
last_known_list.append(user_coord['call'])
if user_coord['call'] in last_known_list and user_coord['call'] == track_call:
folium.CircleMarker([user_lat, user_lon], popup="""
<table style="width: 150px;">
<tbody>
<tr>
<td style="text-align: center;"><strong>""" + user_coord['call'] + """</strong></td>
</tr>
<tr>
<td style="text-align: center;"><em>""" + loc_time + """</em></td>
</tr>
</tbody>
</table>
""", tooltip=str(user_coord['call']), fill=True, fill_color="#3186cc", radius=4).add_to(marker_cluster)
#return folium_map._repr_html_()
if not reload_time:
reload_time = 120
if not map_size:
map_view = '''<table style="width: 1000px; height: 600px; margin-left: auto; margin-right: auto;" border="1">
<tbody>
<tr>
<td>
''' + folium_map._repr_html_() + '''</td>
</tr>
</tbody>
</table>'''
if map_size == 'full':
map_view = folium_map._repr_html_()
content = '''
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="''' + str(reload_time) + """" >
<title>""" + dashboard_title + """ - Tracking """+ track_call + """</title>
</head>
<p style="text-align: center;"><strong>""" + dashboard_title + """ - Tracking """ + track_call + """</strong></p>
<p style="text-align: center;"><em>Page automatically reloads every """ + str(reload_time) + """ seconds.</em></p>
<p style="text-align: center;">
<select name="sample" onchange="location = this.value;">
<option value="view_map?track=""" + track_call + """&reload=120">2 Minutes</option>
<option value="view_map?track=""" + track_call + """&reload=">Don't Reload</option>
<option value="view_map?track=""" + track_call + """&reload=30">30 Seconds</option>
<option value="view_map?track=""" + track_call + """&reload=5">5 Minutes</option>
<option value="view_map?track=""" + track_call + """&reload=600">10 Minutes</option>
</select>
<p style="text-align: center;"><button onclick="self.close()">Close</button><!--<button onclick="history.back()">Back</button>-->
</p>
""" + map_view
return render_template('generic.html', title = dashboard_title, logo = logo, content = Markup(content))
except Exception as e:
content = """<h1 style="text-align: center;">Station not found.</h1>
#<p style="text-align: center;"><button onclick="self.close()">Close Window</button>
#</p>"""
return render_template('generic.html', title = dashboard_title, logo = logo, content = Markup(content))
if not track_call:
folium_map = folium.Map(location=(map_center_lat, map_center_lon), tiles=map_theme, zoom_start=int(zoom_level))
marker_cluster = MarkerCluster().add_to(folium_map)
for user_coord in user_loc:
user_lat = aprs_to_latlon(float(re.sub('[A-Za-z]','', user_coord['lat'])))
user_lon = aprs_to_latlon(float(re.sub('[A-Za-z]','', user_coord['lon'])))
if type(user_coord['time']) == str:
loc_time = str(user_coord['time'])
if type(user_coord['time']) == int or type(user_coord['time']) == float:
loc_time = datetime.fromtimestamp(user_coord['time']).strftime(time_format)
if 'S' in user_coord['lat']:
user_lat = -user_lat
if 'W' in user_coord['lon']:
user_lon = -user_lon
loc_comment = ''
coord_list.append([user_lat, user_lon])
if 'comment' in user_coord:
loc_comment = """
<tr>
<td style="text-align: center;">Comment:</td>
</tr>
<tr>
<td style="text-align: center;"><strong>"""+ str(user_coord['comment']) +"""</strong></td>
</tr>"""
if user_coord['call'] not in last_known_list:
folium.Marker([user_lat, user_lon], popup="""<i>
<table style="width: 150px;">
<tbody>
<tr>
<td style="text-align: center;">Last Location:</td>
</tr>
<tr>
<td style="text-align: center;"><strong>""" + user_coord['call'] + """</strong></td>
</tr>
<tr>
<td style="text-align: center;"><em>""" + loc_time + """</em></td>
</tr>
""" + loc_comment + """
<tr>
<td style="text-align: center;"><strong><A href="view_map?track=""" + user_coord['call'] + """" target="_blank">Track Station</A></strong></td>
</tr>
</tbody>
</table>
</i>""", icon=folium.Icon(color="red", icon="record"), tooltip=str(user_coord['call'])).add_to(folium_map)
last_known_list.append(user_coord['call'])
if user_coord['call'] in last_known_list:
if coord_list.count([user_lat, user_lon]) > 15:
pass
else:
folium.CircleMarker([user_lat, user_lon], popup="""
<table style="width: 150px;">
<tbody>
<tr>
<td style="text-align: center;"><strong>""" + user_coord['call'] + """</strong></td>
</tr>
<tr>
<td style="text-align: center;"><em>""" + loc_time + """</em></td>
</tr>
</tbody>
</table>
""", tooltip=str(user_coord['call']), fill=True, fill_color="#3186cc", radius=4).add_to(marker_cluster)
return folium_map._repr_html_()
@app.route('/map/')
def map():
return render_template('map.html', title = dashboard_title, logo = logo)
@app.route('/user', methods = ['GET', 'POST'])
def user_settings():
user_settings = ast.literal_eval(os.popen('cat ' + user_settings_file).read())
user_id = request.args.get('user_id')
if request.method == 'POST' and request.form.get('dmr_id'):
if int(request.form.get('dmr_id')) in user_settings:
user_id = request.form.get('dmr_id')
ssid = user_settings[int(request.form.get('dmr_id'))][1]['ssid']
icon = user_settings[int(request.form.get('dmr_id'))][2]['icon']
comment = user_settings[int(request.form.get('dmr_id'))][3]['comment']
try:
pin = user_settings[int(request.form.get('dmr_id'))][4]['pin']
if ssid == '':
ssid = aprs_ssid
if icon == '':
icon = '\['
if comment == '':
comment = default_comment + ' ' + user_id
user_result = """
Use this tool to change the stored APRS settings for your DMR ID. When a position is sent, the stored settings will be used to format the APRS packet. Leave field(s) blank for default value.
<h2 style="text-align: center;">&nbsp;Modify Settings for ID: """ + user_id + """</h2>
<form action="user" method="post">
<table style="margin-left: auto; margin-right: auto; width: 419.367px;" border="1">
<tbody>
<tr>
<td style="width: 82px;"><strong>Callsign:</strong></td>
<td style="width: 319.367px; text-align: center;"><strong>""" + str(user_settings[int(user_id)][0]['call']) + """</strong></td>
</tr>
<tr>
<td style="width: 82px;"><strong>SSID:</strong></td>
<td style="width: 319.367px; text-align: center;"><input id="ssid" name="ssid" type="text" placeholder='""" + ssid + """' /></td>
</tr>
<tr>
<td style="width: 82px;"><strong>Icon:</strong></td>
<td style="width: 319.367px; text-align: center;"><input id="icon" name="icon" type="text" placeholder='""" + icon + """' /></td>
</tr>
<tr>
<td style="width: 82px;"><strong>Comment:</strong></td>
<td style="width: 319.367px; text-align: center;"><input id="comment" name="comment" type="text" placeholder='""" + comment + """'/></td>
</tr>
<tr>
<td style="width: 82px;"><strong>DMR ID:</strong></td>
<td style="width: 319.367px; text-align: center;"><input id="dmr_id" name="dmr_id" type="text" value='""" + user_id + """'/></td>
</tr>
<tr>
<td style="width: 82px;"><strong>PIN:</strong></td>
<td style="width: 319.367px; text-align: center;"><input id="pin" name="pin" type="password" /></td>
</tr>
</tbody>
</table>
<p style="text-align: center;"><input type="submit" value="Submit" /></p>
</form>
<p>&nbsp;</p>
"""
except:
user_result = """<h2 style="text-align: center;">No PIN set for """ + str(user_settings[int(user_id)][0]['call']) + """ - """ + request.form.get('dmr_id') + """</h2>
<p style="text-align: center;"><button onclick="history.back()">Back</button>
</p>"""
if int(request.form.get('dmr_id')) not in user_settings:
user_result = """<h2 style="text-align: center;">DMR ID not found.</h2>
<p style="text-align: center;"><button onclick="history.back()">Back</button>
</p>"""
#if edit_user:
if request.method == 'POST' and request.form.get('dmr_id') and request.form.get('pin'):
if int(request.form.get('pin')) == pin:
ssid = request.form.get('ssid')
icon = request.form.get('icon')
comment = request.form.get('comment')
user_setting_write(request.form.get('dmr_id'), request.form.get('ssid'), request.form.get('icon'), request.form.get('comment'))
user_result = """<h2 style="text-align: center;">Changed settings for """ + str(user_settings[int(user_id)][0]['call']) + """ - """ + request.form.get('dmr_id') + """</h2>
<p style="text-align: center;"><button onclick="history.back()">Back</button>
</p>"""
if int(request.form.get('pin')) != pin:
user_result = """<h2 style="text-align: center;">Incorrect PIN.</h2>
<p style="text-align: center;"><button onclick="history.back()">Back</button>
</p>"""
if request.method == 'GET' and not request.args.get('user_id'):
user_result = """
Use this tool to find, check, and change the stored APRS settings for your DMR ID. When a position is sent, the stored settings will be used to format the APRS packet.
<table style="width: 600px; margin-left: auto; margin-right: auto;" border="3">
<tbody>
<tr>
<td><form action="user" method="get">
<table style="margin-left: auto; margin-right: auto;">
<tbody>
<tr style="height: 62px;">
<td style="text-align: center; height: 62px;">
<h2><strong><label for="user_id">Look up DMR ID:</label></strong></h2>
</td>
</tr>
<tr style="height: 51.1667px;">
<td style="height: 51.1667px;"><input id="user_id" name="user_id" type="text" /></td>
</tr>
<tr style="height: 27px;">
<td style="text-align: center; height: 27px;"><input type="submit" value="Submit" /></td>
</tr>
</tbody>
</table>
</form></td>
<td><form action="user" method="post">
<table style="margin-left: auto; margin-right: auto;">
<tbody>
<tr style="height: 62px;">
<td style="text-align: center; height: 62px;">
<h2><strong><label for="dmr_id">Edit DMR ID:</label></strong></h2>
</td>
</tr>
<tr style="height: 51.1667px;">
<td style="height: 51.1667px;"><input id="dmr_id" name="dmr_id" type="text" /></td>
</tr>
<tr style="height: 27px;">
<td style="text-align: center; height: 27px;"><input type="submit" value="Submit" /></td>
</tr>
</tbody>
</table>
</form></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
"""
#else:
if request.method == 'GET' and request.args.get('user_id'):
try:
call = user_settings[int(user_id)][0]['call']
ssid = user_settings[int(user_id)][1]['ssid']
icon = user_settings[int(user_id)][2]['icon']
comment = user_settings[int(user_id)][3]['comment']
if ssid == '':
ssid = aprs_ssid
if icon == '':
icon = '\['
if comment == '':
comment = default_comment + ' ' + user_id
#for result in user_settings:
#return user_settings[int(user_id)][0]
#return user_id
#return user_settings
user_result = """<h2 style="text-align: center;">&nbsp;Settings for ID: """ + user_id + """</h2>
<table style="margin-left: auto; margin-right: auto; width: 419.367px;" border="1">
<tbody>
<tr>
<td style="width: 82px;"><strong>Callsign:</strong></td>
<td style="width: 319.367px; text-align: center;">""" + user_settings[int(user_id)][0]['call'] + """</td>
</tr>
<tr>
<td style="width: 82px;"><strong>SSID:</strong></td>
<td style="width: 319.367px; text-align: center;">""" + ssid + """</td>
</tr>
<tr>
<td style="width: 82px;"><strong>Icon:</strong></td>
<td style="width: 319.367px; text-align: center;">""" + icon + """</td>
</tr>
<tr>
<td style="width: 82px;"><strong>Comment:</strong></td>
<td style="width: 319.367px; text-align: center;">""" + comment + """</td>
</tr>
</tbody>
</table>
<p style="text-align: center;"><button onclick="history.back()">Back</button>
</p>
"""
except:
user_result = '''<h2 style="text-align: center;">User ID not found.</h2>
<p style="text-align: center;"><button onclick="history.back()">Back</button>
</p>'''
return render_template('generic.html', title = dashboard_title, logo = logo, content = Markup(user_result))
@app.route('/mailbox')
def mailbox():
recipient = request.args.get('recipient')
if not recipient:
mail_content = """
<p>The Mailbox is a place where users can leave messages via DMR SMS. A user can leave a message for someone else by sending a specially formatted SMS to <strong>""" + data_call_id + """</strong>.
The message recipient can then use the mailbox to check for messages. You can also check for APRS mesages addressed to your DMR radio. Enter your call sign (without APRS SSID) below to check for messages. See the <a href="help">help</a> page for more information.</p>
<form action="mailbox" method="get">
<table style="margin-left: auto; margin-right: auto;">
<tbody>
<tr style="height: 62px;">
<td style="text-align: center; height: 62px;">
<h2><strong><label for="recipient">Callsign:</label></strong></h2>
</td>
</tr>
<tr style="height: 51.1667px;">
<td style="height: 51.1667px;"><input id="recipient" name="recipient" type="text" /></td>
</tr>
<tr style="height: 27px;">
<td style="text-align: center; height: 27px;"><input type="submit" value="Submit" /></td>
</tr>
</tbody>
</table>
</form>
<p>&nbsp;</p>
"""
else:
mailbox_file = ast.literal_eval(os.popen('cat ' + the_mailbox_file).read())
mail_content = '<h2 style="text-align: center;">Messages for: ' + recipient.upper() + '''
</h2>\n<p style="text-align: center;"><button onclick="history.back()">Back</button></p>\n
<h4 style="text-align: center;"><a href="mailbox_rss?recipient=''' + recipient.upper() + '''"><em>Mailbox RSS Feed for ''' + recipient.upper() + '''</em></a><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH5QIcFBAOXAevLAAAAZZJREFUSMftlbtKA0EUhj8jWhi8gaIEC29oxEoRFESLgIXYiWVSKoj6CCrBBwj6CBHNE1hEWy21ETQqiIW1wXhPo81ZOBw2apbdVPvDsDPnP8M/5zKzECJEQKivYO8DFoAYEAGKtTpQEvhW4w3IA+tAVy2F9fgEskA8COHUL8LOKAMZoMmLQF0FewcwImmNAzPANBB18b0BFoGroNLfBiyLgI2+BMwF3XgNwCrwYsQ//BBPSRPdAoeybjE+A8ClS+Sjfnf1E5A2dW4FzoxfwWvD/XWd7oAxI24jz3gVnpS7eiEpt+KvQEL5D5qal/245zFgU+pnXzMd+Zrh9/3q5l7g3CXtTs0bgWvFffn5vDa7iKcVv2K4DS8i3cAOsAuMm8h12ovqqrVL/R3upFrRKPBgHgctvm0iSynuWNnf5bf6byy5dPKe4nukhg6XU9yW2TfsJlDpNCUX27OaP8pD4WBCzQtmX381EUeAI3Xqe6m5xoHpYAezJuJkNb9Fh0tI4+SlXhpTwJBaZ+XbCcwr+6kcPESI2uAHmAijFaMnEmYAAAAASUVORK5CYII=" /></h4>
'''
for messages in mailbox_file:
if messages['recipient'] == recipient.upper():
sender = """
<tr>
<td style="width: 63px;"><strong>DMR ID:</strong></td>
<td style="width: 292.55px; text-align: center;">""" + str(messages['dmr_id']) + """</td>
</tr>
"""
if type(messages['time']) == str:
loc_time = str(messages['time'])
if type(messages['time']) == int or type(messages['time']) == float:
loc_time = datetime.fromtimestamp(messages['time']).strftime(time_format)
if type(messages['dmr_id']) == str:
sender = """
<tr>
<td style="width: 63px;"><strong>APRS Call:</strong></td>
<td style="width: 292.55px; text-align: center;">""" + str(messages['dmr_id']) + """</td>
</tr>
"""
mail_content = mail_content + """
<table style="margin-left: auto; margin-right: auto; width: 372.55px;" border="1">
<tbody>
<tr>
<td style="width: 63px;"><strong>From:</strong></td>
<td style="text-align: center; width: 292.55px;"><strong>""" + messages['call'] + """</strong></td>
</tr>
""" + sender + """
<tr>
<td style="width: 63px;"><strong>Time:</strong></td>
<td style="width: 292.55px; text-align: center;">""" + loc_time + """</td>
</tr>
<tr>
<td style="width: 63px;"><strong>Message:</strong></td>
<td style="width: 292.55px; text-align: center;"><strong>""" + messages['message'] + """</strong></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
"""
return render_template('generic.html', title = dashboard_title, logo = logo, content = Markup(mail_content))
@app.route('/bulletin_rss.xml')
def bb_rss():
try:
dash_bb = ast.literal_eval(os.popen('cat ' + bb_file).read())
post_data = ''
rss_header = """<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>""" + dashboard_title + """ - Bulletin Board Feed</title>
<link>""" + rss_link + """</link>
<description>This is the Bulletin Board feed from """ + dashboard_title + """</description>"""
for entry in dash_bb:
if type(entry['time']) == str:
loc_time = str(entry['time'])
if type(entry['time']) == int or type(entry['time']) == float:
loc_time = datetime.fromtimestamp(entry['time']).strftime(time_format)
post_data = post_data + """
<item>
<title>""" + entry['call'] + ' - ' + str(entry['dmr_id']) + """</title>
<link>""" + rss_link + """</link>
<description>""" + entry['bulletin'] + """ - """ + loc_time + """</description>
<pubDate>""" + datetime.fromtimestamp(entry['time']).strftime('%a, %d %b %y') +"""</pubDate>
</item>
"""
return Response(rss_header + post_data + "\n</channel>\n</rss>", mimetype='text/xml')
except Exception as e:
#return str('<h1 style="text-align: center;">No data</h1>')
return str(e)
@app.route('/mailbox_rss')
def mail_rss():
mailbox_file = ast.literal_eval(os.popen('cat ' + the_mailbox_file).read())
post_data = ''
recipient = request.args.get('recipient').upper()
rss_header = """<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>""" + dashboard_title + """ - Mailbox Feed for """ + recipient + """</title>
<link>""" + rss_link + """</link>
<description>This is a Mailbox feed from """ + dashboard_title + """ for """ + recipient + """.</description>"""
for entry in mailbox_file:
if type(entry['time']) == str:
loc_time = str(entry['time'])
if type(entry['time']) == int or type(entry['time']) == float:
loc_time = datetime.fromtimestamp(entry['time']).strftime(time_format)
if entry['recipient'] == recipient:
post_data = post_data + """
<item>
<title>""" + entry['call'] + ' - ' + str(entry['dmr_id']) + """</title>
<link>""" + rss_link + """</link>
<description>""" + entry['message'] + """ - """ + loc_time + """</description>
<pubDate>""" + datetime.fromtimestamp(entry['time']).strftime('%a, %d %b %y') +"""</pubDate>
</item>
"""
return Response(rss_header + post_data + "\n</channel>\n</rss>", mimetype='text/xml')
if __name__ == '__main__':
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually gps_data.cfg)')
cli_args = arg_parser.parse_args()
parser = ConfigParser()
if not cli_args.CONFIG_FILE:
print('\n\nMust specify a config file with -c argument.\n\n')
parser.read(cli_args.CONFIG_FILE)
###### Definitions #####
# Title of the Dashboard
dashboard_title = parser.get('GPS_DATA', 'DASHBOARD_TITLE')
# Logo used on dashboard page
logo = parser.get('GPS_DATA', 'LOGO')
dash_port = int(parser.get('GPS_DATA', 'DASH_PORT'))
# IP to run server on
dash_host = parser.get('GPS_DATA', 'DASH_HOST')
#Description of dashboard to show on main page
description = parser.get('GPS_DATA', 'DESCRIPTION')
# The following will generate a help page for your users.
# Data call type
if parser.get('GPS_DATA', 'CALL_TYPE') == 'unit':
data_call_type = 'Private Call'
if parser.get('GPS_DATA', 'CALL_TYPE') == 'group':
data_call_type = 'Group Call'
if parser.get('GPS_DATA', 'CALL_TYPE') == 'both':
data_call_type = 'Private or Group Call'
# DMR ID of GPS/Data application
data_call_id = parser.get('GPS_DATA', 'DATA_DMR_ID')
# Default APRS ssid
aprs_ssid = parser.get('GPS_DATA', 'USER_APRS_SSID')
# Gateway contact info displayed on about page.
contact_name = parser.get('GPS_DATA', 'CONTACT_NAME')
contact_call = parser.get('GPS_DATA', 'CONTACT_CALL')
contact_email = parser.get('GPS_DATA', 'CONTACT_EMAIL')
contact_website = parser.get('GPS_DATA', 'CONTACT_WEBSITE')
# Center dashboard map over these coordinates
map_center_lat = float(parser.get('GPS_DATA', 'MAP_CENTER_LAT'))
map_center_lon = float(parser.get('GPS_DATA', 'MAP_CENTER_LON'))
zoom_level = int(parser.get('GPS_DATA', 'ZOOM_LEVEL'))
map_theme = parser.get('GPS_DATA', 'MAP_THEME')
# Time format for display
time_format = parser.get('GPS_DATA', 'TIME_FORMAT')
# RSS feed link, shows in the link section of each RSS item.
rss_link = parser.get('GPS_DATA', 'RSS_LINK')
# Default APRS comment for users.
default_comment = parser.get('GPS_DATA', 'USER_APRS_COMMENT')
# DO NOT MODIFY BELOW HERE.
bb_file = parser.get('GPS_DATA', 'BULLETIN_BOARD_FILE')
loc_file = parser.get('GPS_DATA', 'LOCATION_FILE')
emergency_sos_file = parser.get('GPS_DATA', 'EMERGENCY_SOS_FILE')
the_mailbox_file = parser.get('GPS_DATA', 'MAILBOX_FILE')
user_settings_file = parser.get('GPS_DATA', 'USER_SETTINGS_FILE')
########################
app.run(debug = True, port=dash_port, host=dash_host)

View File

@ -0,0 +1,63 @@
###############################################################################
# HBLink - Copyright (C) 2020 Cortney T. Buffington, N0MJS <n0mjs@me.com>
# GPS/Data - Copyright (C) 2020 Eric Craw, KF7EEL <kf7eel@qsl.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
###############################################################################
'''
Settings for web dashboard.
'''
# Title of the Dashboard
dashboard_title = 'HBLink3 D-APRS Dashboard'
# Logo used on dashboard page
logo = 'https://raw.githubusercontent.com/kf7eel/hblink3/gps/HBlink.png'
# Port to run server
dash_port = 8092
# IP to run server on
dash_host = '127.0.0.1'
#Description of dashboard to show on main page
description = '''
Welcome to the ''' + dashboard_title + '''.
'''
# The following will generate a help page for your users.
# Data call type
data_call_type = 'Private Call'
# DMR ID of GPS/Data application
data_call_id = '9099'
# Default APRS ssid
aprs_ssid = '15'
# Gateway contact info displayed on about page.
contact_name = 'your name'
contact_call = 'N0CALL'
contact_email = 'email@example.org'
contact_website = 'https://hbl.ink'
# Time format for display
time_format = '%H:%M:%S - %m/%d/%y'
# Center dashboard map over these coordinates
map_center = (47.00, -120.00)
zoom_level = 7
# List and preview of some map themes at http://leaflet-extras.github.io/leaflet-providers/preview/
# The following are options for map themes and just work, you should use one of these: “OpenStreetMap”, “Stamen” (Terrain, Toner, and Watercolor),
map_theme = 'Stamen Toner'
# RSS feed link, shows in the link section of each RSS item.
rss_link = 'http://localhost:8092'

View File

@ -0,0 +1,28 @@
{% include 'page.html' %}
{% include 'header.html' %}
{{description}}
<p>&nbsp;</p>
<p>Contact information for this gateway.</p>
<table style="margin-left: auto; margin-right: auto;" border="black">
<tbody>
<tr>
<td><strong>Name</strong></td>
<td>{{contact_name}} </td>
</tr>
<tr>
<td><strong>Callsign</strong></td>
<td>&nbsp;{{contact_call}}</td>
</tr>
<tr>
<td><strong>E-Mail</strong></td>
<td>&nbsp;{{contact_email}}</td>
</tr>
<tr>
<td><strong>Website</strong></td>
<td>&nbsp;{{contact_website}}</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
{% include 'footer.html' %}

View File

@ -0,0 +1,5 @@
<div>
<hr />
<div style="text-align: center;">Dashboard created by KF7EEL - <a href="https://kf7eel.github.io/hblink3/">https://github.com/kf7eel/hblink3</a><br />HBLink created by N0MJS.<br /><a href="https://github.com/HBLink-org">HBLink GitHub page</a><br />This is branch: <strong>gps<strong></div>
</body>
</html>

View File

@ -0,0 +1,5 @@
{% include 'page.html' %}
{% include 'header.html' %}
{{content}}
{% include 'footer.html' %}

View File

@ -0,0 +1,17 @@
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="{{logo}}" alt="Logo" width="300" height="144" /></p>
<h1 style="text-align: center;">{{title}}</h1>
<hr />
<table style="width: 500px; margin-left: auto; margin-right: auto;" border="black" cellspacing="3" cellpadding="3">
<tbody>
<tr>
<td style="text-align: center;"><button onclick="window.location.href='/';"> Dashboard Home </button></td>
<td style="text-align: center;"><button onclick="window.location.href='/map';"> Station Map </button></td>
<td style="text-align: center;"><button onclick="window.location.href='/mailbox';"> The Mailbox </button></td>
<td style="text-align: center;"><button onclick="window.location.href='/user';"> User Settings </button></td>
<td style="text-align: center;"><button onclick="window.location.href='/help';"> Dashboard Help </button></td>
<td style="text-align: center;"><button onclick="window.location.href='/about';"> Gateway Contact </button></td>
</tr>
</tbody>
</table>
<hr />

View File

@ -0,0 +1,117 @@
{% include 'page.html' %}
{% include 'header.html' %}
<h2 style="text-align: center;">Attention:</h2>
<p><span style="color: #ff0000;"><strong>Please be aware that many (if not all) DMR radios DO NOT transmit your callsign when sending a GPS position. It is your responsibility to identify your station per the regulations of your country.</strong></span></p>
<p>&nbsp;</p>
<p>{{description}}</p>
<p>Configure your radio to send GPS positions with the following settings:</p>
<table style="margin-left: auto; margin-right: auto;" border="black">
<tbody>
<tr>
<td style="text-align: center;"><strong>Data Call Type</strong></td>
<td style="text-align: center;"><strong>DMR ID</strong></td>
</tr>
<tr>
<td style="text-align: center;">&nbsp;{{data_call_type}}</td>
<td style="text-align: center;">&nbsp;{{data_call_id}}</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>When a position is received by this gateway, it will extract the coordinates and create an APRS position packet. This gateway will find your callsign based your radio's DMR ID. It is essential to have your information up to date with <a href="https://radioid.net/">RadioID.net</a>. A predefined APRS SSID of <strong>{{aprs_ssid}}</strong> is appended your callsign. The APRS location packet is then uploaded to APRS-IS. No setup or account creation is required beforehand. This is pretty much "plug and play."</p>
<p>For example, N0CALL has a DMR ID of 1234567. N0CALL's radio sends a position to this gateway with the call type settings above. This gateway will query the <a href="https://radioid.net/">RadioID.net</a> database for DMR ID 1234567. The result will be an APRS location packet with APRS SSID&nbsp;{{aprs_ssid}}. </p>
<p>You can change the default APRS settings for your radio via SMS.</p>
<h2 style="text-align: center;">Commands</h2>
<table style="margin-left: auto; margin-right: auto;" border="black">
<tbody>
<tr>
<td style="text-align: center;">
<h4><strong>Command</strong></h4>
</td>
<td style="text-align: center;">
<h4><strong>Description</strong></h4>
</td>
<td style="text-align: center;">
<h4><strong>Example</strong></h4>
</td>
</tr>
<tr>
<td><strong>@COM</strong></td>
<td>Change the comment of the APRS.</td>
<td><em><code>@COM This is a test comment.</code></em></td>
</tr>
<tr>
<td><strong>@ICON</strong></td>
<td>Change the icon of the APRS position. *See <a href="http://aprs.net/vm/DOS/SYMBOLS.HTM" rel="nofollow">http://aprs.net/vm/DOS/SYMBOLS.HTM</a> for icon list.</td>
<td><em><code>@ICON /p</code></em></td>
</tr>
<tr>
<td><strong>@SSID</strong></td>
<td>Change SSID of your callsign.</td>
<td><em><code>@SSID 7</code></em></td>
</tr>
<tr>
<td><strong>@PIN</strong></td>
<td>Set a PIN. This is used for changing your APRS settings ia the dashboard. You must set this for each DMR ID you wish to change via the dashboard.</td>
<td><em><code>@PIN 1234</code></em></td>
</tr>
<tr>
<td><strong>@MH</strong></td>
<td>Set you location by maidenhead grid square. Designed for radios with no GPS or that are not compatable yet.</td>
<td><em><code>@MH DN97uk</code></em></td>
</tr>
<tr>
<td><strong>@BB</strong></td>
<td>Post a bulliten to the web dashboard.</td>
<td><em><code>@BB This is a test bulletin.</code></em></td>
</tr>
<tr>
<td><strong>@[CALLSIGN W/ SSID] A-[MESSAGE]</strong></td>
<td>Send a message to another station via APRS.</td>
<td><em><code>@N0CALL-15 A-This is a test.</code></em></td>
</tr>
<tr>
<td><strong>[EMAIL ADDRESS] E-[MESSAGE]</strong></td>
<td>Send an email to an email address.</td>
<td><em><code>test@example.org E-This is a test.</code></em></td>
</tr>
<tr>
<td><strong>@[RECIPIENT CALLSIGN] M-[MESSAGE]</strong></td>
<td>Post a message to the Mailbox.</td>
<td><em>@N0CALL M-This is a test.</em></td>
</tr>
<tr>
<td><strong>@REM MAIL</strong></td>
<td>Remove all mail addressed to you.</td>
<td><em>@REM MAIL</em></td>
</tr>
<tr>
<td><strong>@SOS</strong></td>
<td>EMERGENCY activation displays a banner on the main dashboard page.</td>
<td><em>THIS IS AN EMERGENCY. @SOS</em></td>
</tr>
<tr>
<td><strong>@NOTICE</strong></td>
<td>Used to prominantly display a notice, similar to EMERGENCY activation.</td>
<td><em>@NOTICE Server going down at 1800</em></td>
</tr>
<tr>
<td><strong>@REM SOS</strong></td>
<td>Removes an EMERGENCY or notice.</td>
<td><em>@REM SOS</em></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p><strong>Commands should be in upper case.</strong> Send an SMS to <strong>{{data_call_id}}</strong> as a <strong>{{data_call_type}}</strong> with the desired command followed by the value. For example, to change your icon to a dog, the command would be <code>@ICON /p</code> (see the icon table for values). Changing your SSID is as simple as <code>@SSID 7</code>, and <code>@COM Testing 123</code> will change the comment.</p>
<p>Sending <code>@BB Test</code> will result in a post to the bulletin board with the messaage of "Test".</p>
<p><strong>To remove any of the stored values, just send the appropriate command without any input.</strong> <code>@COM</code> will remove the stored comment, <code>@ICON</code> will remove the stored icon, and <code>@ICON</code> will remove the strored icon. Any position reports sent will have the default settings.</p>
<h3 style="text-align: center;">EMERGENCY Activation</h3>
<p>The EMERGENCY Activation function will display a prominant banner accross the main dashboard page. The banner contains a message, time, callsign of station, and a link to the last known location of the station. This feature is intended to be used in situations where a user is in distress. To trigger an EMERGENCY activation, simply send an SMS to <strong>{{data_call_id}}</strong> with <strong>@SOS</strong> in the message. The <strong>@SOS</strong> command can be anywhere in the message. A less intimidating banner can be displayed for testing, or other purposes, by using <strong>@NOTICE</strong>. To remove the EMERGENCY activation, simply send the <strong>@REM SOS</strong> command.</p>
<h3 style="text-align: center;">The Map</h3>
<p>This dashboard now has a built in map. The map will display the last know location of stations and some previous plots from them. You can track a station by clicking on the red pin, and selecting the <strong>Track Station</strong> link. When tracking a station, you have a few options for a refresh rate, located in a drop down menu.</p>
<h3 style="text-align: center;">The Mailbox</h3>
<p>The Mailbox is a place where users can leave messages via DMR SMS. A user can leave a message for someone else by sending a formatted SMS to <strong>{{data_call_id}}</strong>. See the table above for a syntax example of posting a message to the Mailbox. The message recipient can then use the mailbox to check for messages. Message recipients can delete all of their messages by sending the command <strong>@REM MAIL</strong>. There is no way to remove a single message, it's all or none.</p>
{% include 'footer.html' %}

View File

@ -0,0 +1,49 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="120" >
<title>{{title}}</title>
<style>
body {background-color: D3D3D3;}
h1 {color: green;}
p {
padding: 10px;
margin: 20px;
}
.content {
max-width: 1200px;
min-width: 1200px;
margin: auto;
}
.emergency_button {
display: block;
width: 100%;
border: none;
background-color: ##ff0000;
padding: 14px 28px;
font-size: 16px;
cursor: pointer;
text-align: center;
}
</style>
</head>
<div class="content">
<body>
{% include 'header.html' %}
{{emergency}}
<p style="text-align: center;"><em>Page automatically reloads every 2 minutes.</em></p>
<h4 style="text-align: center;"><a href="bulletin_rss.xml"><em>Bulletin Board RSS Feed</em></a><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH5QIcFBAOXAevLAAAAZZJREFUSMftlbtKA0EUhj8jWhi8gaIEC29oxEoRFESLgIXYiWVSKoj6CCrBBwj6CBHNE1hEWy21ETQqiIW1wXhPo81ZOBw2apbdVPvDsDPnP8M/5zKzECJEQKivYO8DFoAYEAGKtTpQEvhW4w3IA+tAVy2F9fgEskA8COHUL8LOKAMZoMmLQF0FewcwImmNAzPANBB18b0BFoGroNLfBiyLgI2+BMwF3XgNwCrwYsQ//BBPSRPdAoeybjE+A8ClS+Sjfnf1E5A2dW4FzoxfwWvD/XWd7oAxI24jz3gVnpS7eiEpt+KvQEL5D5qal/245zFgU+pnXzMd+Zrh9/3q5l7g3CXtTs0bgWvFffn5vDa7iKcVv2K4DS8i3cAOsAuMm8h12ovqqrVL/R3upFrRKPBgHgctvm0iSynuWNnf5bf6byy5dPKe4nukhg6XU9yW2TfsJlDpNCUX27OaP8pD4WBCzQtmX381EUeAI3Xqe6m5xoHpYAezJuJkNb9Fh0tI4+SlXhpTwJBaZ+XbCcwr+6kcPESI2uAHmAijFaMnEmYAAAAASUVORK5CYII=" /></h4>
<table>
<tbody>
<tr>
<td><div><p align="center"><iframe style="border: none;" title="Bulletin Board" src="bulletin_board" width="480" height="950"></iframe></p></div></td>
<td><div>
<p align="center"><iframe style="border: none;" title="Positions Received" src="positions" width="620" height="950"></iframe></p>
</div></td>
</tr>
</tbody>
</table>
{% include 'footer.html' %}

View File

@ -0,0 +1,8 @@
{% include 'page.html' %}
{% include 'header.html' %}
<p style="text-align: center;"><span style="color: #ff0000;"><strong>Red</strong></span>: Last location received. <span style="color: #0000ff;"><strong>Blue</strong></span>: Location history.</p>
<p style="text-align: center;">&nbsp;</p>
<div><p align="center"><iframe style="border: none;" title="Map" src="/view_map?track=" width="1100" height="700"></iframe></p></div>
<p>&nbsp;</p>
{% include 'footer.html' %}

View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{title}}</title>
<style>
body {background-color: D3D3D3;}
h1 {color: green;}
p {
padding: 10px;
margin: 20px;
}
.content {
max-width: 1200px;
min-width: 1200px;
margin: auto;
}
</style>
</head>
<div class="content">
<body>