更新 'src/Network/fgcom.cxx'
This commit is contained in:
parent
f8a6003b68
commit
e3f2781b1d
@ -368,7 +368,7 @@ void FGCom::postinit()
|
|||||||
|
|
||||||
|
|
||||||
// Do the first call at start
|
// Do the first call at start
|
||||||
//setupCommFrequency();
|
setupCommFrequency();
|
||||||
|
|
||||||
connectToCommFrequency();
|
connectToCommFrequency();
|
||||||
|
|
||||||
@ -486,14 +486,17 @@ void FGCom::connectToCommFrequency() {
|
|||||||
if (_currentCallFrequency != _currentCommFrequency || _currentCallIdent == -1) {
|
if (_currentCallFrequency != _currentCommFrequency || _currentCallIdent == -1) {
|
||||||
|
|
||||||
if (_currentCallIdent != -1) {
|
if (_currentCallIdent != -1) {
|
||||||
|
|
||||||
iaxc_dump_call_number(_currentCallIdent);
|
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;
|
_currentCallIdent = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_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();
|
_processingTimer.stamp();
|
||||||
|
|
||||||
@ -511,6 +514,8 @@ void FGCom::connectToCommFrequency() {
|
|||||||
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: connectToCommFrequency num=" << num);
|
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: connectToCommFrequency num=" << num);
|
||||||
|
|
||||||
if (!num.empty()) {
|
if (!num.empty()) {
|
||||||
|
|
||||||
|
lib_hangup();
|
||||||
_currentCallIdent = iaxc_call(num.c_str());
|
_currentCallIdent = iaxc_call(num.c_str());
|
||||||
|
|
||||||
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: iaxc_call(" << num << ") _currentCallIdent=" << _currentCallIdent);
|
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: iaxc_call(" << num << ") _currentCallIdent=" << _currentCallIdent);
|
||||||
@ -520,6 +525,7 @@ void FGCom::connectToCommFrequency() {
|
|||||||
else {
|
else {
|
||||||
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: call established " << num.c_str() << " Freq: " << _currentCommFrequency);
|
SG_LOG(SG_SOUND, SG_ALERT, "FGCom: call established " << num.c_str() << " Freq: " << _currentCommFrequency);
|
||||||
_currentCallFrequency = _currentCommFrequency;
|
_currentCallFrequency = _currentCommFrequency;
|
||||||
|
_connected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -561,6 +567,7 @@ void FGCom::shutdown()
|
|||||||
|
|
||||||
_initialized = false;
|
_initialized = false;
|
||||||
_enabled = false;
|
_enabled = false;
|
||||||
|
_connected = false;
|
||||||
|
|
||||||
iaxc_set_event_callback(NULL);
|
iaxc_set_event_callback(NULL);
|
||||||
iaxc_unregister(_regId);
|
iaxc_unregister(_regId);
|
||||||
@ -815,7 +822,7 @@ std::string FGCom::computePhoneNumber(const double& freq, const std::string& ica
|
|||||||
exten);
|
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;
|
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.
|
// Register the subsystem.
|
||||||
SGSubsystemMgr::Registrant<FGCom> registrantFGCom;
|
SGSubsystemMgr::Registrant<FGCom> registrantFGCom;
|
||||||
|
Loading…
Reference in New Issue
Block a user