Fix for problems with reboots by using GPS modul (was not correct implemented)

This commit is contained in:
norbert-walter 2022-03-16 12:02:31 +01:00
parent 8b49db33f2
commit e025ce0cdb
2 changed files with 60 additions and 1 deletions

View File

@ -0,0 +1,54 @@
#pragma once
#include "NMEA0183.h"
#include "GwNmea0183Msg.h"
class ObpNmea0183 : public tNMEA0183
{
public:
bool GetMessageCor(SNMEA0183Msg &NMEA0183Msg)
{
if (!IsOpen())
return false;
bool result = false;
while (port->available() > 0 && !result)
{
int NewByte = port->read();
if (NewByte == '$' || NewByte == '!')
{ // Message start
MsgInStarted = true;
MsgInPos = 0;
MsgInBuf[MsgInPos] = NewByte;
MsgInPos++;
}
else if (MsgInStarted)
{
MsgInBuf[MsgInPos] = NewByte;
if (NewByte == '*')
MsgCheckSumStartPos = MsgInPos;
MsgInPos++;
if (MsgCheckSumStartPos != SIZE_MAX and MsgCheckSumStartPos + 3 == MsgInPos)
{ // We have full checksum and so full message
MsgInBuf[MsgInPos] = 0; // add null termination
if (NMEA0183Msg.SetMessageCor(MsgInBuf))
{
NMEA0183Msg.SourceID = SourceID;
result = true;
}
MsgInStarted = false;
MsgInPos = 0;
MsgCheckSumStartPos = SIZE_MAX;
}
if (MsgInPos >= MAX_NMEA0183_MSG_BUF_LEN)
{ // Too may chars in message. Start from beginning
MsgInStarted = false;
MsgInPos = 0;
MsgCheckSumStartPos = SIZE_MAX;
}
}
}
return result;
}
};

View File

@ -28,8 +28,12 @@
#include "Logo_OBP_400x300_sw.h" // OBP Logo
#include "OBP60QRWiFi.h" // Functions lib for WiFi QR code
#include "ObpNmea0183.h"
#include "GwNmea0183Msg.h"
tNMEA0183Msg NMEA0183Msg;
tNMEA0183 NMEA0183;
ObpNmea0183 NMEA0183; // Fixed Lib for NMEA0183
// tNMEA0183 NMEA0183; // Old lib with problems for NMEA0183
Adafruit_BME280 bme280; // Evironment sensor BME280
Adafruit_BMP280 bmp280; // Evironment sensor BMEP280
@ -520,6 +524,7 @@ void OBP60Task(GwApi *api){
long starttime6 = millis(); // Environment sensor update all 1s
while (true){
delay(10); // Fixed the problem with NMEA0183 and GPS sentences
Timer1.update(); // Update for Timer1
Timer2.update(); // Update for Timer2
if(millis() > starttime0 + 100){