6.0.23.30

This commit is contained in:
g8bpq 2022-11-23 18:08:29 +00:00
parent be0f2b8576
commit e95c1f37c3
4 changed files with 192 additions and 10 deletions

View File

@ -102,6 +102,7 @@ VOID sendandcheck(SOCKET sock, const char * Buffer, int Len);
void SaveAPRSMessage(struct APRSMESSAGE * ptr); void SaveAPRSMessage(struct APRSMESSAGE * ptr);
void ClearSavedMessages(); void ClearSavedMessages();
void GetSavedAPRSMessages(); void GetSavedAPRSMessages();
static VOID GPSDConnect(void * unused);
extern int SemHeldByAPI; extern int SemHeldByAPI;
extern int APRSMONDECODE(); extern int APRSMONDECODE();
@ -178,12 +179,20 @@ char LON[] = "00000.00W"; //in standard APRS Format
char HostName[80]; // for BlueNMEA char HostName[80]; // for BlueNMEA
int HostPort = 4352; int HostPort = 4352;
char GPSDHost[80]; // for BlueNMEA
int GPSDPort = 2947;
extern int ADSBPort; extern int ADSBPort;
extern char ADSBHost[]; extern char ADSBHost[];
BOOL BlueNMEAOK = FALSE; BOOL BlueNMEAOK = FALSE;
int BlueNMEATimer = 0; int BlueNMEATimer = 0;
BOOL GPSDOK = FALSE;
int GPSDTimer = 0;
BOOL GPSSetsLocator = 0; // Update Map Location from GPS BOOL GPSSetsLocator = 0; // Update Map Location from GPS
double SOG, COG; // From GPS double SOG, COG; // From GPS
@ -2326,6 +2335,21 @@ static int APRSProcessLine(char * buf)
return TRUE; return TRUE;
} }
if (_stricmp(ptr, "GPSDHost") == 0)
{
if (strlen(p_value) > 70)
return FALSE;
strcpy(GPSDHost, p_value);
return TRUE;
}
if (_stricmp(ptr, "GPSDPort") == 0)
{
GPSDPort = atoi(p_value);
return TRUE;
}
if (_stricmp(ptr, "ADSBHost") == 0) if (_stricmp(ptr, "ADSBHost") == 0)
{ {
if (strlen(p_value) > 70) if (strlen(p_value) > 70)
@ -2912,6 +2936,18 @@ VOID DoSecTimer()
} }
} }
if (GPSDHost[0])
{
if (GPSDOK == 0)
{
GPSDTimer++;
if (GPSDTimer > 15)
{
GPSDTimer = 0;
_beginthread(GPSDConnect, 0, 0);
}
}
}
if (BeaconCounter) if (BeaconCounter)
{ {
@ -3894,6 +3930,7 @@ void DecodeRMC(char * msg, size_t len)
{ {
#ifdef LINBPQ #ifdef LINBPQ
Debugprintf("GPS OK"); Debugprintf("GPS OK");
printf("GPS OK\n");
#else #else
SetDlgItemText(hConsWnd, IDC_GPS, "GPS OK"); SetDlgItemText(hConsWnd, IDC_GPS, "GPS OK");
#endif #endif
@ -4315,6 +4352,141 @@ Lost:
} }
} }
} }
static VOID GPSDConnect(void * unused)
{
int err, ret;
u_long param=1;
BOOL bcopt=TRUE;
fd_set readfs;
fd_set errorfs;
struct timeval timeout;
struct sockaddr_in destaddr;
SOCKET TCPSock;
if (GPSDHost[0] == 0)
return;
destaddr.sin_addr.s_addr = inet_addr(GPSDHost);
destaddr.sin_family = AF_INET;
destaddr.sin_port = htons(GPSDPort);
TCPSock = socket(AF_INET,SOCK_STREAM,0);
if (TCPSock == INVALID_SOCKET)
{
return;
}
setsockopt (TCPSock, SOL_SOCKET, SO_REUSEADDR, (const char FAR *)&bcopt, 4);
GPSDOK = TRUE; // So we don't try to reconnect while waiting
if (connect(TCPSock,(LPSOCKADDR) &destaddr, sizeof(destaddr)) == 0)
{
//
// Connected successful
//
#ifdef LINBPQ
printf("GPSD Connected\n");
#else
Debugprintf("GPSD Connected");
#endif
ioctl(TCPSock, FIONBIO, &param);
// Request data
send(TCPSock, "?WATCH={\"enable\":true,\"nmea\":true}", 34, 0);
}
else
{
err=WSAGetLastError();
#ifdef LINBPQ
printf("GPSD Connect Failed - error code = %d\n", err);
#else
Debugprintf("GPSD Connect Failed - error code = %d", err);
#endif
closesocket(TCPSock);
GPSDOK = FALSE;
return;
}
while (TRUE)
{
FD_ZERO(&readfs);
FD_ZERO(&errorfs);
FD_SET(TCPSock,&readfs);
FD_SET(TCPSock,&errorfs);
timeout.tv_sec = 900;
timeout.tv_usec = 0; // We should get messages more frequently that this
ret = select((int)TCPSock + 1, &readfs, NULL, &errorfs, &timeout);
if (ret == SOCKET_ERROR)
{
goto Lost;
}
if (ret > 0)
{
// See what happened
if (FD_ISSET(TCPSock, &readfs))
{
char Buffer[65536];
int len = recv(TCPSock, Buffer, 65500, 0);
if (len == 0)
{
closesocket(TCPSock);
GPSDOK = FALSE;;
return;
}
if (len < 9000)
{
Buffer[len] = 0;
if (Buffer[0] == '$' && memcmp(&Buffer[3], "RMC", 3) == 0)
if (Check0183CheckSum(Buffer, len))
DecodeRMC(Buffer, len);
}
}
if (FD_ISSET(TCPSock, &errorfs))
{
Lost:
#ifdef LINBPQ
printf("GPSD Connection lost\n");
#endif
closesocket(TCPSock);
GPSDOK = FALSE;;
return;
}
}
else
{
// 15 mins without data. Shouldn't happen
shutdown(TCPSock, SD_BOTH);
Sleep(100);
closesocket(TCPSock);
GPSDOK = FALSE;
return;
}
}
}
// Code Moved from APRS Application // Code Moved from APRS Application
// //
@ -7849,7 +8021,7 @@ VOID APRSCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, CMDX *
if (memcmp(CmdTail, "? ", 2) == 0) if (memcmp(CmdTail, "? ", 2) == 0)
{ {
Bufferptr = Cmdprintf(Session, Bufferptr, "APRS Subcommmands:\r"); Bufferptr = Cmdprintf(Session, Bufferptr, "APRS Subcommmands:\r");
Bufferptr = Cmdprintf(Session, Bufferptr, "STATUS SEND MSGS SENT ENABLEIGATE DISABLEIGATE RECONFIG\r"); Bufferptr = Cmdprintf(Session, Bufferptr, "STATUS SEND MSGS SENT ENABLEIGATE DISABLEIGATE BEACON RECONFIG\r");
Bufferptr = Cmdprintf(Session, Bufferptr, "Default is Station list - Params [Port] [Pattern]\r"); Bufferptr = Cmdprintf(Session, Bufferptr, "Default is Station list - Params [Port] [Pattern]\r");
SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER)); SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER));
@ -7908,7 +8080,16 @@ VOID APRSCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, CMDX *
else else
Bufferptr = Cmdprintf(Session, Bufferptr, "but not connected\r"); Bufferptr = Cmdprintf(Session, Bufferptr, "but not connected\r");
} }
return;
}
if (memcmp(CmdTail, "BEACON ", 7) == 0)
{
if (isSYSOP(Session, Bufferptr) == FALSE)
return;
BeaconCounter = 2;
Bufferptr = Cmdprintf(Session, Bufferptr, "Beacons requested\r");
SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER)); SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER));
return; return;
} }

View File

@ -1125,8 +1125,9 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses
// If BeacontoIS is zero don't Gate any of our messages received locally to APRS-IS (28) // If BeacontoIS is zero don't Gate any of our messages received locally to APRS-IS (28)
// Add Node Help command (28) // Add Node Help command (28)
// Add APRS Igate RXOnly option (29) // Add APRS Igate RXOnly option (29)
// Fix RMC message handling with prefixes other than GP // Fix RMC message handling with prefixes other than GP (29)
// Add GPSD support for APRS (30)
// Attempt to tix Tracker/WinRPR reconnect code (30)
#define CKernel #define CKernel

View File

@ -1052,11 +1052,11 @@ VOID DEDPoll(int Port)
// Can't use retries, as we have no way of detecting lost chars. Have to re-init on timeout // Can't use retries, as we have no way of detecting lost chars. Have to re-init on timeout
if (TNC->HostMode == 0 || TNC->ReinitState == 10) // 10 is Recovery Mode // if (TNC->HostMode == 0 || TNC->ReinitState == 10) // 10 is Recovery Mode
{ // {
DoTermModeTimeout(TNC); // DoTermModeTimeout(TNC);
return; // return;
} // }
// Timed out in host mode - Clear any connection and reinit the TNC // Timed out in host mode - Clear any connection and reinit the TNC

View File

@ -10,8 +10,8 @@
#endif #endif
#define KVers 6,0,23,29 #define KVers 6,0,23,30
#define KVerstring "6.0.23.29\0" #define KVerstring "6.0.23.30\0"
#ifdef CKernel #ifdef CKernel