RIG CONNECT... "; $rigcmd=$rigctl.' -m '.$rmodel.' -r '.$device.' -s '.$dspeed; $socket=popen($rigcmd,'r'); print "OK (".$device.")\n"; print "CMD[".$rigcmd."]\n"; $last_read=time(); while ( TRUE ) { # GET $get=file_get_contents('https://qrzcq.com/api/rig/get/'.$mycall.'|'.$apikey); $put=json_decode($get); if ( $put->status == 'OK' ) { if ( isset($put->rig) ) { if ( $put->rig->set->freq > 0 && $put->rig->set->freq <= 54000000 && strlen($put->rig->set->mode) > 0 ) { $freq=$put->rig->set->freq; $mode=$put->rig->set->mode; ################################################################ ## DO WHATEVER YOU NEED TO SET YOUR RIG TO THIS FREQ AND MODE ## ################################################################ // here for Icom IC-7600 // it needs to switch band before setting frequency and mode if ( $mode == 'CW' ) { $wid=$cw_wid; } else { $wid=$ssb_wid; }; $amode=array(); exec($rigcmd.' M '.$mode.' '.$wid,$amode,$mret); $afreq=array(); exec($rigcmd.' F '.$freq,$afreq,$fret); print "==> RIG SET TO ".number_format($freq,0,'','.')." ".$mode." ".$wid."\n"; ################################################################ ################################################################ } } usleep(1000); } else { print "ERROR: QRZCQ GET FAILED\n"; print "SLEEP(10)\n"; sleep(10); } # PUT if ( time() != $last_read ) { ############################################################# ## DO WHATEVER YOU NEED TO READ THE FREQ AND MODE FROM RIG ## ############################################################# // here for Icom IC-7600 $afreq=array(); $get_freq=$rigcmd.' f'; exec($get_freq,$afreq,$fret); $freq=trim($afreq[0]); $amode=array(); $get_mode=$rigcmd.' m'; exec($get_mode,$amode,$mret); $mode=trim($amode[0]); $asmet=array(); $get_smet=$rigcmd.' l STRENGTH'; exec($get_smet,$asmet,$sret); $smet=trim($asmet[0]); if ( count($amode) > 1 ) { $wid=trim($amode[1]); }; ############################################################# ############################################################# if ( $freq*1 > 0 && $mode == strtoupper($mode) ) { #print "RIG READ ".$freq." ".$mode." ".$wid."\n"; $smet=$smet+54; # dB S9 -> dB S0 $put=file_get_contents('https://qrzcq.com/api/rig/put/'.$mycall.'|'.$apikey.'/'.$mode.'|'.$freq.'|'.$smet); $get=json_decode($put); if ( $get->status != 'OK' ) { print "\nERROR: QRZCQ PUT FAILED\n"; }; } $last_read=time(); if ( preg_match("/0$/",time()) && $freq*1 > 0 && $mode == strtoupper($mode) ) { print "ALIVE[_".number_format($freq,0,'','.')."_/".$mode."/".$wid."/".$smet."]\n"; }; usleep(1000); } # SLEEP usleep(200*1000); # STAMP if ( mt_rand(1,1000) == 1000 ) { print "STAMP[".gmdate("Y-m-d H:i:s")."]\n"; } } function get_band_of_freq($freq) { if ( 1800000 <= $freq && $freq <= 2000000 ) { return 1; }; if ( 3500000 <= $freq && $freq <= 4000000 ) { return 2; }; if ( 5258500 <= $freq && $freq <= 5450000 ) { return 3; }; if ( 7000000 <= $freq && $freq <= 7300000 ) { return 4; }; if ( 10100000 <= $freq && $freq <= 10150000 ) { return 5; }; if ( 14000000 <= $freq && $freq <= 14350000 ) { return 6; }; if ( 18068000 <= $freq && $freq <= 18168000 ) { return 7; }; if ( 21000000 <= $freq && $freq <= 21450000 ) { return 8; }; if ( 24890000 <= $freq && $freq <= 24990000 ) { return 9; }; if ( 28000000 <= $freq && $freq <= 29700000 ) { return 10; }; if ( 50000000 <= $freq && $freq <= 54000000 ) { return 11; }; #print "## OUTER BAND ## ".$freq." ##\n"; return 0; }