Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration with Hearham.live call sign listener #142

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions admin/configure.php
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,10 @@ function resizeIframe(obj) {
if (empty($_POST['dstarNetHangTime']) != TRUE ) {
$configmmdvm['D-Star Network']['ModeHang'] = preg_replace('/[^0-9]/', '', $_POST['dstarNetHangTime']);
}
if (empty($_POST['HearhamKey']) != TRUE ) {
$configmmdvm['Hearham']['Secret'] = $_POST['HearhamKey'];
}

// Set YSF Hang Timers
if (empty($_POST['ysfRfHangTime']) != TRUE ) {
$configmmdvm['System Fusion']['ModeHang'] = preg_replace('/[^0-9]/', '', $_POST['ysfRfHangTime']);
Expand Down Expand Up @@ -3684,6 +3688,18 @@ function resizeIframe(obj) {
<td align="left"><a class="tooltip2" href="#"><?php echo $lang['mode_hangtime'];?>:<span><b>Net Hang Time</b>Stay in the last mode for this many seconds</span></a></td>
<td align="left" colspan="2"><input type="text" name="hangTime" size="13" maxlength="3" value="<?php echo $configmmdvm['General']['RFModeHang']; ?>" /> in seconds (90 secs works well for Multi-Mode)</td>
</tr>-->
<tr>
<td align="left"><a class="tooltip2" href="#">Your Hearham key:<span><b>Hearham "Upload Secret" from hearham.live/setup:</b>Enter your station's secret key</span></a></td>
<?php
if ( isset($configmmdvm['Hearham']) ) {
echo "<td colspan=2 align=\"left\"><input type=\"text\" name=\"HearhamKey\" value=\"".$configmmdvm['Hearham']['Secret']."\" /></td>\n";
}
else {
echo "<td colspan=2 align=\"left\"><input type=\"text\" name=\"HearhamKey\" value=\"\" /></td>\n";
}
?>
</tr>

</table>
<div><input type="button" value="<?php echo $lang['apply'];?>" onclick="submitform()" /><br /><br /></div>
<?php } ?>
Expand Down
64 changes: 64 additions & 0 deletions mmdvmhost/reportheard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
$dir = dirname(__DIR__);
require_once $dir.'/config/config.php'; // MMDVMDash Config
include_once $dir.'/mmdvmhost/tools.php'; // MMDVMDash Tools
require_once $dir.'/mmdvmhost/functions.php'; // MMDVMDash Functions
include_once $dir.'/config/language.php'; // Translation Code

$mmdvmConfigFile = '/etc/mmdvmhost';
$configmmdvm = parse_ini_file($mmdvmConfigFile, true);
if( isset($configmmdvm['Hearham'] ) ) {
// THIS IS YOUR hearham.live station key:
$secret = $configmmdvm['Hearham']['Secret'];
//echo "\n";
//echo $secret;
$UPLOADKEY = $secret;
} else {
exit;
}

for($t=0; $t<60; $t+=5) {

// Check if the config file exists
if (file_exists('/etc/pistar-css.ini')) {
// Use the values from the file
$piStarCssFile = '/etc/pistar-css.ini';
if (fopen($piStarCssFile,'r')) { $piStarCss = parse_ini_file($piStarCssFile, true); }

// Set the Values from the config file
if (isset($piStarCss['Lookup']['Service'])) { $callsignLookupSvc = $piStarCss['Lookup']['Service']; } // Lookup Service "QRZ" or "RadioID"
else { $callsignLookupSvc = "RadioID"; } // Set the default if its missing // Set the default if its missing
} else {
// Default values
$callsignLookupSvc = "RadioID";
}

$nowUTC = strtotime(gmdate("Y-m-d H:i:s"));

$i = 0;
for ($i = 0; ($i <= 19); $i++) { //Last 20 calls
if (isset($lastHeard[$i])) {
$listElem = $lastHeard[$i];
if ($listElem[5] == "RF"){
$date = strtotime($listElem[0]);
$type = $listElem[1];
$call = $listElem[2];
echo $nowUTC - $date;
echo 'seconds ago heard '.$call."\n";
if( $nowUTC - $date < 6 ) {
system("curl -X POST -F 'key=$UPLOADKEY' -F 'hear=$call' https://hearham.com/api/audioDigitalLog");
}
}else{
//Not rf
}
}
}

sleep(5);
//Re grab as in functions.php:
$logLinesMMDVM = getMMDVMLog();
$reverseLogLinesMMDVM = $logLinesMMDVM;
array_multisort($reverseLogLinesMMDVM,SORT_DESC);
$lastHeard = getLastHeard($reverseLogLinesMMDVM);

}