2013-09-27 14:05:45 +00:00
|
|
|
/*
|
|
|
|
* fgcom - VoIP-Client for the FlightGear-Radio-Infrastructure
|
|
|
|
*
|
2014-08-19 18:46:42 +00:00
|
|
|
* This program realizes the usage of the VoIP infractructure based
|
|
|
|
* on flight data which is send from FlightGear with an external
|
|
|
|
* protocol to this application.
|
|
|
|
*
|
|
|
|
* Clement de l'Hamaide - Jan 2014
|
|
|
|
* Re-writting of FGCom standalone
|
|
|
|
*
|
2013-09-27 14:05:45 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
* MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __FGCOM_H__
|
|
|
|
#define __FGCOM_H__
|
|
|
|
|
2014-08-19 18:46:42 +00:00
|
|
|
// avoid name clash with winerror.h
|
2013-09-27 14:05:45 +00:00
|
|
|
#define FGC_SUCCESS(__x__) (__x__ == 0)
|
|
|
|
#define FGC_FAILED(__x__) (__x__ < 0)
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define snprintf _snprintf
|
|
|
|
#ifdef WIN64
|
|
|
|
typedef __int64 ssize_t;
|
|
|
|
#else
|
|
|
|
typedef int ssize_t;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2014-08-19 18:46:42 +00:00
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <fstream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2013-09-27 14:05:45 +00:00
|
|
|
#ifndef FGCOM_VERSION
|
2014-08-19 18:46:42 +00:00
|
|
|
#ifdef FLIGHTGEAR_VERSION
|
2013-09-27 14:05:45 +00:00
|
|
|
#define FGCOM_VERSION FLIGHTGEAR_VERSION
|
|
|
|
#else
|
2014-08-19 18:46:42 +00:00
|
|
|
#define FGCOM_VERSION "unknown"
|
2013-09-27 14:05:45 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2014-08-19 18:46:42 +00:00
|
|
|
#define MAXBUFLEN 1024
|
|
|
|
|
|
|
|
enum Modes {
|
|
|
|
ATC,
|
|
|
|
PILOT,
|
|
|
|
OBS,
|
|
|
|
TEST
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ActiveComm {
|
|
|
|
COM1,
|
|
|
|
COM2
|
2013-09-27 14:05:45 +00:00
|
|
|
};
|
|
|
|
|
2014-08-19 18:46:42 +00:00
|
|
|
struct Data
|
2013-09-27 14:05:45 +00:00
|
|
|
{
|
2014-08-19 18:46:42 +00:00
|
|
|
int ptt;
|
|
|
|
float com1;
|
|
|
|
float com2;
|
|
|
|
double lon;
|
|
|
|
double lat;
|
|
|
|
double alt;
|
|
|
|
float outputVol;
|
|
|
|
float silenceThd;
|
|
|
|
std::string callsign;
|
2013-09-27 14:05:45 +00:00
|
|
|
};
|
|
|
|
|
2014-08-19 18:46:42 +00:00
|
|
|
struct Airport
|
2013-09-27 14:05:45 +00:00
|
|
|
{
|
2014-08-19 18:46:42 +00:00
|
|
|
double frequency;
|
|
|
|
double latitude;
|
|
|
|
double longitude;
|
|
|
|
double distanceNm;
|
|
|
|
std::string icao;
|
|
|
|
std::string type;
|
|
|
|
std::string name;
|
2013-09-27 14:05:45 +00:00
|
|
|
};
|
|
|
|
|
2014-08-19 18:46:42 +00:00
|
|
|
// Internal functions
|
|
|
|
int usage();
|
|
|
|
int version();
|
|
|
|
void quit(int state);
|
|
|
|
bool isInRange(std::string icao, double acftLat, double acftLon, double acftAlt);
|
|
|
|
std::string computePhoneNumber(double freq, std::string icao, bool atis = false);
|
|
|
|
std::string getClosestAirportForFreq(double freq, double acftLat, double acftLon, double acftAlt);
|
|
|
|
std::multimap<int, Airport> getAirportsData();
|
|
|
|
|
|
|
|
// Library functions
|
|
|
|
bool lib_init();
|
|
|
|
bool lib_hangup();
|
|
|
|
bool lib_shutdown();
|
|
|
|
bool lib_call(std::string icao, double freq);
|
|
|
|
bool lib_directCall(std::string icao, double freq, std::string num);
|
|
|
|
|
|
|
|
int lib_registration();
|
|
|
|
int iaxc_callback(iaxc_event e);
|
|
|
|
|
|
|
|
void lib_setSilenceThreshold(double thd);
|
|
|
|
void lib_setCallerId(std::string callsign);
|
|
|
|
void lib_setVolume(double input, double output);
|
|
|
|
|
2013-09-27 14:05:45 +00:00
|
|
|
#endif
|