更新 'src/Network/fgcom.cxx'

next
zhongjin 2 years ago
parent f8a6003b68
commit e3f2781b1d

@ -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<FGCom> registrantFGCom;

Loading…
Cancel
Save