diff --git a/APRSCode.c b/APRSCode.c index 6734ff2..e48fea7 100644 --- a/APRSCode.c +++ b/APRSCode.c @@ -102,6 +102,7 @@ VOID sendandcheck(SOCKET sock, const char * Buffer, int Len); void SaveAPRSMessage(struct APRSMESSAGE * ptr); void ClearSavedMessages(); void GetSavedAPRSMessages(); +static VOID GPSDConnect(void * unused); extern int SemHeldByAPI; extern int APRSMONDECODE(); @@ -178,12 +179,20 @@ char LON[] = "00000.00W"; //in standard APRS Format char HostName[80]; // for BlueNMEA int HostPort = 4352; +char GPSDHost[80]; // for BlueNMEA +int GPSDPort = 2947; + + extern int ADSBPort; extern char ADSBHost[]; BOOL BlueNMEAOK = FALSE; int BlueNMEATimer = 0; +BOOL GPSDOK = FALSE; +int GPSDTimer = 0; + + BOOL GPSSetsLocator = 0; // Update Map Location from GPS double SOG, COG; // From GPS @@ -2326,6 +2335,21 @@ static int APRSProcessLine(char * buf) 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 (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) { @@ -3894,6 +3930,7 @@ void DecodeRMC(char * msg, size_t len) { #ifdef LINBPQ Debugprintf("GPS OK"); + printf("GPS OK\n"); #else SetDlgItemText(hConsWnd, IDC_GPS, "GPS OK"); #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, ¶m); + + // 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 // @@ -7849,7 +8021,7 @@ VOID APRSCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, CMDX * if (memcmp(CmdTail, "? ", 2) == 0) { 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"); SendCommandReply(Session, REPLYBUFFER, (int)(Bufferptr - (char *)REPLYBUFFER)); @@ -7908,7 +8080,16 @@ VOID APRSCMD(TRANSPORTENTRY * Session, char * Bufferptr, char * CmdTail, CMDX * else 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)); return; } diff --git a/Bpq32.c b/Bpq32.c index 8d94722..5c01509 100644 --- a/Bpq32.c +++ b/Bpq32.c @@ -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) // Add Node Help command (28) // 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 diff --git a/SCSTracker.c b/SCSTracker.c index a36d29f..3f53000 100644 --- a/SCSTracker.c +++ b/SCSTracker.c @@ -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 - if (TNC->HostMode == 0 || TNC->ReinitState == 10) // 10 is Recovery Mode - { - DoTermModeTimeout(TNC); - return; - } +// if (TNC->HostMode == 0 || TNC->ReinitState == 10) // 10 is Recovery Mode +// { +// DoTermModeTimeout(TNC); +// return; +// } // Timed out in host mode - Clear any connection and reinit the TNC diff --git a/Versions.h b/Versions.h index 00b0edd..10640c7 100644 --- a/Versions.h +++ b/Versions.h @@ -10,8 +10,8 @@ #endif -#define KVers 6,0,23,29 -#define KVerstring "6.0.23.29\0" +#define KVers 6,0,23,30 +#define KVerstring "6.0.23.30\0" #ifdef CKernel