From e3f2781b1d0cdb4f41792010fab92e821c4bdbc8 Mon Sep 17 00:00:00 2001 From: zhongjin Date: Wed, 30 Nov 2022 22:58:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20'src/Network/fgcom.cxx'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Network/fgcom.cxx | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/Network/fgcom.cxx b/src/Network/fgcom.cxx index b7a480c..ac369fa 100644 --- a/src/Network/fgcom.cxx +++ b/src/Network/fgcom.cxx @@ -368,7 +368,7 @@ void FGCom::postinit() // Do the first call at start - //setupCommFrequency(); + setupCommFrequency(); connectToCommFrequency(); @@ -486,14 +486,17 @@ void FGCom::connectToCommFrequency() { if (_currentCallFrequency != _currentCommFrequency || _currentCallIdent == -1) { if (_currentCallIdent != -1) { + iaxc_dump_call_number(_currentCallIdent); - SG_LOG(SG_SOUND, SG_ALERT, "FGCom: dump_call_number " << _currentCallIdent); + + SG_LOG(SG_SOUND, SG_ALERT, "FGCom:iaxc_dump_call_number:" << _currentCallIdent); _currentCallIdent = -1; } if (_currentCallIdent == -1) { - std::string num = computePhoneNumber(_currentCommFrequency, getAirportCode(_currentCommFrequency)); +// std::string num = computePhoneNumber(_currentCommFrequency, getAirportCode(_currentCommFrequency)); + std::string num = computePhoneNumber(_currentCommFrequency, "ZGHA"); _processingTimer.stamp(); @@ -511,6 +514,8 @@ void FGCom::connectToCommFrequency() { SG_LOG(SG_SOUND, SG_ALERT, "FGCom: connectToCommFrequency num=" << num); if (!num.empty()) { + + lib_hangup(); _currentCallIdent = iaxc_call(num.c_str()); SG_LOG(SG_SOUND, SG_ALERT, "FGCom: iaxc_call(" << num << ") _currentCallIdent=" << _currentCallIdent); @@ -520,6 +525,7 @@ void FGCom::connectToCommFrequency() { else { SG_LOG(SG_SOUND, SG_ALERT, "FGCom: call established " << num.c_str() << " Freq: " << _currentCommFrequency); _currentCallFrequency = _currentCommFrequency; + _connected = true; } } else @@ -561,6 +567,7 @@ void FGCom::shutdown() _initialized = false; _enabled = false; + _connected = false; iaxc_set_event_callback(NULL); iaxc_unregister(_regId); @@ -815,7 +822,7 @@ std::string FGCom::computePhoneNumber(const double& freq, const std::string& ica exten); - SG_LOG(SG_SOUND, SG_ALERT, "FGCom: computePhoneNumber:" << phoneNumber << "icao:" << icao); + SG_LOG(SG_SOUND, SG_ALERT, "FGCom: computePhoneNumber:" << phoneNumber << " icao:" << icao); return phoneNumber; } @@ -849,5 +856,17 @@ bool FGCom::isInRange(const double &freq) const } +bool FGCom::lib_hangup() +{ + if(!_connected) + return false; + SG_LOG(SG_GENERAL, SG_DEBUG, "Request hangup"); + iaxc_dump_all_calls(); + iaxc_millisleep(300); + + _currentCallIdent = -1; + return false; +} + // Register the subsystem. SGSubsystemMgr::Registrant registrantFGCom;