This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbm-rpt2aprs.php
executable file
·77 lines (67 loc) · 2.29 KB
/
bm-rpt2aprs.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/php
<?php
date_default_timezone_set('UTC'); //Set timezone for everything to UTC
ini_set('display_errors','On');
error_reporting(E_ALL);
chdir(dirname(__FILE__));
include('config.inc.php');
include('dbus.inc.php');
include('aprs.inc.php');
echo "connecting to aprs...\n";
$aprs_socket = aprs_connect();
if ($aprs_socket === false)
return 1;
$repeater_ids = dbus_get_repeater_ids_for_network();
if ($repeater_ids) {
foreach ($repeater_ids as $repeater_id) {
echo "getting info for repeater id $repeater_id...\n";
$ctx = stream_context_create(array(
'http' => array(
'timeout' => 5
)
));
$result = file_get_contents("https://api.brandmeister.network/v1.0/repeater/?action=GET&q=$repeater_id", 0, $ctx);
$result = json_decode($result);
if (!isset($result->callsign)) {
echo " no callsign, ignoring\n";
continue;
}
if ($result->lat == 0 || $result->lng == 0) {
echo " invalid coordinates, ignoring\n";
continue;
}
if (time()-strtotime($result->last_updated) > 600) {
echo " last update was too long ago, ignoring\n";
continue;
}
if ($result->priorityDescription != '')
$description = $result->priorityDescription;
else {
$description = explode('-', $result->hardware);
$description = $description[0];
$description = explode(' ', $description);
$description = $description[0];
$description = str_replace('_', ' ', $description);
if ($description == '')
$description = APRS_DEFAULT_TEXT;
}
// Parse SSID of an APRS object from the repeater id
if (strlen($repeater_id) == 9) {
echo " parse ssid from repeater id\n";
$ssid = ltrim(substr($repeater_id, 7, 2), '0');
$callsign = $result->callsign . '-' . $ssid;
} else
$callsign = $result->callsign;
// Skip APRS reporting if NOGATE or NOAPRS tag is set
if (strpos(strtoupper($description), 'NOGATE') === false &&
strpos(strtoupper($description), 'NOAPRS') === false)
{
aprs_send_location($callsign, ($result->tx == $result->rx), $result->lat,
$result->lng, $result->pep, $result->agl, $result->gain, $description . ' ' .
$result->tx . '/' . $result->rx . ' CC' . $result->colorcode);
} else
echo " NOGATE or NOAPRS tag found, skip reporting to APRS-IS\n";
}
}
socket_close($aprs_socket);
?>