From 6832ec031de2e29171fbb7d2c40b2b150a677b85 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Wed, 16 Nov 2016 16:59:53 +0000 Subject: [PATCH] Added Features to allow SatPC32 to act as a Radio interface with Cloudlog This required extra SQL so you'll need to run the SQL query. ALTER TABLE `cat` ADD `downlink_freq` INT(11) NOT NULL AFTER `mode`, ADD `uplink_freq` INT(11) NOT NULL AFTER `downlink_freq`, ADD `downlink_mode` VARCHAR(255) NOT NULL AFTER `uplink_freq`, ADD `uplink_mode` VARCHAR(255) NOT NULL AFTER `downlink_mode`, ADD `sat_name` VARCHAR(255) NOT NULL AFTER `uplink_mode`; --- application/config/config.sample.php | 2 +- application/controllers/radio.php | 81 ++++++++++++++++++++++++++-- application/models/cat.php | 64 ++++++++++++++++------ application/views/qso/index.php | 22 ++++++-- install/assets/install.sql | 2 + sql/tables/cat.sql | 4 +- 6 files changed, 150 insertions(+), 25 deletions(-) diff --git a/application/config/config.sample.php b/application/config/config.sample.php index 0452150c..1c501c2e 100644 --- a/application/config/config.sample.php +++ b/application/config/config.sample.php @@ -13,7 +13,7 @@ */ $config['app_name'] = "Cloudlog"; -$config['app_version'] = "1.1"; +$config['app_version'] = "1.5"; $config['directory'] = "logbook"; $config['callbook'] = "hamqth"; // Options are hamqth or qrz diff --git a/application/controllers/radio.php b/application/controllers/radio.php index 74ba5474..5e2acadf 100644 --- a/application/controllers/radio.php +++ b/application/controllers/radio.php @@ -66,7 +66,21 @@ { foreach ($query->result() as $row) { - echo $row->frequency; + if( $row->frequency == "0") { + $this->db->select('uplink_freq'); + $this->db->where('id', $id); + $query = $this->db->get('cat'); + + if ($query->num_rows() > 0) + { + foreach ($query->result() as $row) + { + echo strtoupper($row->uplink_freq); + } + } + } else { + echo $row->frequency; + } } } } @@ -78,7 +92,7 @@ if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } //$this->db->where('radio', $result['radio']); - $this->db->select('mode'); + $this->db->select('mode, radio, uplink_mode'); $this->db->where('id', $id); $query = $this->db->get('cat'); @@ -86,7 +100,68 @@ { foreach ($query->result() as $row) { - echo strtoupper($row->mode); + if($row->radio != "SatPC32") { + echo strtoupper($row->mode); + } else { + echo strtoupper($row->uplink_mode); + } + } + } + } + + function satname($id) { + + // Check Auth + $this->load->model('user_model'); + if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + + //$this->db->where('radio', $result['radio']); + $this->db->select('sat_name'); + $this->db->where('id', $id); + $query = $this->db->get('cat'); + + if ($query->num_rows() > 0) + { + foreach ($query->result() as $row) + { + echo strtoupper($row->sat_name); + } + } + } + + function satmode($id) { + + // Check Auth + $this->load->model('user_model'); + if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + + //$this->db->where('radio', $result['radio']); + $this->db->select('uplink_freq, downlink_freq'); + $this->db->where('id', $id); + $query = $this->db->get('cat'); + + if ($query->num_rows() > 0) + { + foreach ($query->result() as $row) + { + + if ($row->uplink_freq > 144000000 && $row->uplink_freq < 147000000) { + $uplink_mode = "V"; + } elseif ($row->uplink_freq > 432000000 && $row->uplink_freq < 438000000) { + $uplink_mode = "U"; + } elseif ($row->uplink_freq > 28000000 && $row->uplink_freq < 30000000) { + $uplink_mode = "A"; + } + + if ($row->downlink_freq > 144000000 && $row->downlink_freq < 147000000) { + $downlink_mode = "V"; + } elseif ($row->downlink_freq > 432000000 && $row->downlink_freq < 438000000) { + $downlink_mode = "U"; + } elseif ($row->downlink_freq > 28000000 && $row->downlink_freq < 30000000) { + $downlink_mode = "A"; + } + + echo $uplink_mode."/".$downlink_mode; } } } diff --git a/application/models/cat.php b/application/models/cat.php index 7c65aadc..1ec8f0c3 100644 --- a/application/models/cat.php +++ b/application/models/cat.php @@ -15,27 +15,59 @@ if ($query->num_rows() > 0) { - // Update the record - foreach ($query->result() as $row) - { - $radio_id = $row->id; - - $data = array( - 'frequency' => $result['frequency'], - 'mode' => $result['mode'] - ); + if($result['radio'] == "SatPC32") { + // Update the record + foreach ($query->result() as $row) + { + $radio_id = $row->id; + + $data = array( + 'sat_name' => $result['sat_name'], + 'downlink_freq' => $result['downlink_freq'], + 'uplink_freq' => $result['uplink_freq'], + 'downlink_mode' => $result['downlink_mode'], + 'uplink_mode' => $result['uplink_mode'], + ); - $this->db->where('id', $radio_id); - $this->db->update('cat', $data); + $this->db->where('id', $radio_id); + $this->db->update('cat', $data); + } + } else { + // Update the record + foreach ($query->result() as $row) + { + $radio_id = $row->id; + + $data = array( + 'frequency' => $result['frequency'], + 'mode' => $result['mode'], + ); + + $this->db->where('id', $radio_id); + $this->db->update('cat', $data); + } } } else { // Add a new record - $data = array( - 'radio' => $result['radio'], - 'frequency' => $result['frequency'], - 'mode' => $result['mode'] - ); + if($result['radio'] == "SatPC32") { + $data = array( + 'radio' => $result['radio'], + 'frequency' => $result['frequency'], + 'mode' => $result['mode'], + 'sat_name' => $result['sat_name'], + 'downlink_freq' => $result['downlink_freq'], + 'uplink_freq' => $result['uplink_freq'], + 'downlink_mode' => $result['downlink_mode'], + 'uplink_mode' => $result['uplink_mode'], + ); + } else { + $data = array( + 'radio' => $result['radio'], + 'frequency' => $result['frequency'], + 'mode' => $result['mode'] + ); + } $this->db->insert('cat', $data); diff --git a/application/views/qso/index.php b/application/views/qso/index.php index ce9253bf..a1240da7 100644 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -209,12 +209,12 @@ - + - +
Sat Name
Sat Mode
@@ -303,8 +303,12 @@ if($('select.radios option:selected').val() != '0') { // Get frequency $.get('radio/frequency/' + $('select.radios option:selected').val(), function(result) { - $('#frequency').val(result); - $(".band").val(frequencyToBand(result)); + + if(result == "0") { + } else { + $('#frequency').val(result); + $(".band").val(frequencyToBand(result)); + } }); // Get Mode @@ -315,6 +319,16 @@ $(".mode").val(result); } }); + + // Get SAT_Name + $.get('radio/satname/' + $('select.radios option:selected').val(), function(result) { + $(".sat_name").val(result); + }); + + // Get SAT_Name + $.get('radio/satmode/' + $('select.radios option:selected').val(), function(result) { + $(".sat_mode").val(result); + }); } }; diff --git a/install/assets/install.sql b/install/assets/install.sql index b5e605a3..f827cdea 100755 --- a/install/assets/install.sql +++ b/install/assets/install.sql @@ -3806,3 +3806,5 @@ CREATE TABLE IF NOT EXISTS `config` ( INSERT INTO `config` (`id`, `lotw_download_url`, `lotw_upload_url`, `lotw_rcvd_mark`, `lotw_login_url`, `eqsl_download_url`, `eqsl_rcvd_mark`) VALUES (1, 'https://p1k.arrl.org/lotwuser/lotwreport.adi', 'https://p1k.arrl.org/lotwuser/upload', 'Y', 'https://p1k.arrl.org/lotwuser/default', 'http://www.eqsl.cc/qslcard/DownloadInBox.cfm', 'Y'); + +ALTER TABLE `cat` ADD `downlink_freq` INT(11) NOT NULL AFTER `mode`, ADD `uplink_freq` INT(11) NOT NULL AFTER `downlink_freq`, ADD `downlink_mode` VARCHAR(255) NOT NULL AFTER `uplink_freq`, ADD `uplink_mode` VARCHAR(255) NOT NULL AFTER `downlink_mode`, ADD `sat_name` VARCHAR(255) NOT NULL AFTER `uplink_mode`; diff --git a/sql/tables/cat.sql b/sql/tables/cat.sql index b83684d2..55b64e49 100644 --- a/sql/tables/cat.sql +++ b/sql/tables/cat.sql @@ -5,4 +5,6 @@ CREATE TABLE IF NOT EXISTS `cat` ( `mode` varchar(10) NOT NULL, `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 ; \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=latin1 ; + +ALTER TABLE `cat` ADD `downlink_freq` INT(11) NOT NULL AFTER `mode`, ADD `uplink_freq` INT(11) NOT NULL AFTER `downlink_freq`, ADD `downlink_mode` VARCHAR(255) NOT NULL AFTER `uplink_freq`, ADD `uplink_mode` VARCHAR(255) NOT NULL AFTER `downlink_mode`, ADD `sat_name` VARCHAR(255) NOT NULL AFTER `uplink_mode`; \ No newline at end of file