diff --git a/rconfig b/rconfig index 0f799bb..e024545 100755 --- a/rconfig +++ b/rconfig @@ -196,8 +196,8 @@ USE ${ysfdbname}; CREATE TABLE IF NOT EXISTS ysfnodes ( callsign VARCHAR(7) PRIMARY KEY, password VARCHAR(255) NOT NULL, - txfreq INT NOT NULL DEFAULT 446500000, - rxfreq INT NOT NULL DEFAULT 446500000, + txfreq INT NOT NULL DEFAULT 445500000, + rxfreq INT NOT NULL DEFAULT 445500000, created_at DATETIME DEFAULT CURRENT_TIMESTAMP ); CREATE USER IF NOT EXISTS '${ysfdbuser}'@'localhost' IDENTIFIED BY '${ysfdbpw}'; diff --git a/src/cysfnodedir.cpp b/src/cysfnodedir.cpp index 1cb4288..78e9488 100644 --- a/src/cysfnodedir.cpp +++ b/src/cysfnodedir.cpp @@ -78,11 +78,18 @@ void CYsfNodeDir::Thread() while (keep_running) { // Wait YSFNODEDB_REFRESH_RATE minutes - for (int i=0; i<30*YSFNODEDB_REFRESH_RATE && keep_running; i++) + for (int i=0; keep_running && (i < 30*YSFNODEDB_REFRESH_RATE); i++) + { CTimePoint::TaskSleepFor(2000); - +#if YSF_DB_SUPPORT==true + if (keep_running && (0 == i % 450)) + { + ReadDb(); // update from the db every 15 minutes + } +#endif + } // have lists files changed ? - if ( NeedReload() ) + if (keep_running && NeedReload()) { Reload(); } @@ -100,7 +107,7 @@ bool CYsfNodeDir::Reload(void) if ( LoadContent(&buffer) ) { Lock(); - ok = RefreshContent(buffer) && ReadDb(); + ok = RefreshContent(buffer); Unlock(); } return ok; @@ -126,10 +133,9 @@ bool CYsfNodeDir::FindFrequencies(const CCallsign &callsign, uint32 *txfreq, uin } } -bool CYsfNodeDir::ReadDb() -{ #if YSF_DB_SUPPORT==true - bool rval = false; +void CYsfNodeDir::ReadDb() +{ MYSQL *con = mysql_init(NULL); if (con) { @@ -140,7 +146,6 @@ bool CYsfNodeDir::ReadDb() MYSQL_RES *result = mysql_store_result(con); if (result) { - rval = true; std::cout << "Adding " << mysql_num_rows(result) << " registered YSF stations from table " << YSF_DB_NAME << std::endl; MYSQL_ROW row; @@ -148,8 +153,7 @@ bool CYsfNodeDir::ReadDb() { CCallsign cs(row[0]); CYsfNode node(atoi(row[1]), atoi(row[2])); - std::pair pair(cs, node); - insert(pair); + m_map[cs] = node; } mysql_free_result(result); @@ -172,11 +176,7 @@ bool CYsfNodeDir::ReadDb() } else { - std::cerr << "Could not init mysql." << std::endl; - return false; + std::cerr << "Could not init mysql." << std::endl;; } - return rval; -#else - return true; -#endif } +#endif diff --git a/src/cysfnodedir.h b/src/cysfnodedir.h index e23cb20..c21562d 100644 --- a/src/cysfnodedir.h +++ b/src/cysfnodedir.h @@ -84,7 +84,9 @@ protected: // reload helpers bool Reload(void); virtual bool NeedReload(void) { return false; } - bool ReadDb(void); +#if YSF_DB_SUPPORT==true; + void ReadDb(void); +#endif //bool IsValidDmrid(const char *); diff --git a/src/main.h b/src/main.h index be9054d..dd3140d 100644 --- a/src/main.h +++ b/src/main.h @@ -137,8 +137,8 @@ #define YSF_PORT 42000 // UDP port #define YSF_KEEPALIVE_PERIOD 3 // in seconds #define YSF_KEEPALIVE_TIMEOUT (YSF_KEEPALIVE_PERIOD*10) // in seconds -#define YSF_DEFAULT_NODE_TX_FREQ 446500000 // in Hz -#define YSF_DEFAULT_NODE_RX_FREQ 446500000 // in Hz +#define YSF_DEFAULT_NODE_TX_FREQ 445500000 // in Hz +#define YSF_DEFAULT_NODE_RX_FREQ 445500000 // in Hz // the following two defines are now in configure.h // #define YSF_AUTOLINK_ENABLE 0 // 1 = enable, 0 = disable auto-link // #define YSF_AUTOLINK_MODULE 'B' // module for client to auto-link to diff --git a/wiresx/finish.php b/wiresx/finish.php index f099786..261cdc7 100644 --- a/wiresx/finish.php +++ b/wiresx/finish.php @@ -59,9 +59,10 @@ if ($stmt = mysqli_prepare($link, $sql)) {

Hot-Spot Frequencies Summary

-

Hot-spot Callsign:

+

Hot-spot Callsign:

Transmit Frequency: MHz

Receive Frequency: MHz

+

It can take up to 15 minutes for the frequency data to be available to the reflector. Please be patient.

Reset Frequencies diff --git a/wiresx/frequency.php b/wiresx/frequency.php index 63256f0..8ca9258 100644 --- a/wiresx/frequency.php +++ b/wiresx/frequency.php @@ -57,7 +57,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { // Check input errors before updating the database if (empty($txfreq_err) && empty($rxfreq_err)) { // Prepare an update statement - $sql = "UPDATE users SET txfreq = ?, rxfreq = ? WHERE callsign = ?"; + $sql = "UPDATE ysfnodes SET txfreq = ?, rxfreq = ? WHERE callsign = ?"; if($stmt = mysqli_prepare($link, $sql)){ // Bind variables to the prepared statement as parameters diff --git a/wiresx/register.php b/wiresx/register.php index d3e053f..b92bba5 100644 --- a/wiresx/register.php +++ b/wiresx/register.php @@ -78,7 +78,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($callsign_err) && empty($password_err) && empty($confirm_password_err)) { // Prepare an insert statement - $sql = "INSERT INTO users (callsign, password) VALUES (?, ?)"; + $sql = "INSERT INTO ysfnodes (callsign, password) VALUES (?, ?)"; if ($stmt = mysqli_prepare($link, $sql)) { // Bind variables to the prepared statement as parameters diff --git a/wiresx/reset-password.php b/wiresx/reset-password.php index fc64a07..94f5569 100644 --- a/wiresx/reset-password.php +++ b/wiresx/reset-password.php @@ -40,7 +40,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { // Check input errors before updating the database if (empty($new_password_err) && empty($confirm_password_err)) { // Prepare an update statement - $sql = "UPDATE users SET password = ? WHERE callsign = ?"; + $sql = "UPDATE ysfnodes SET password = ? WHERE callsign = ?"; if($stmt = mysqli_prepare($link, $sql)){ // Bind variables to the prepared statement as parameters