File tree 2 files changed +10
-6
lines changed
2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -106,14 +106,20 @@ static void autodetectProtocol(uint8_t c)
106
106
{
107
107
static tmr10ms_t time ;
108
108
static uint8_t state = 0 ;
109
+ static tmr10ms_t firstPacketNMEA = 0 ;
109
110
110
111
switch (state) {
111
112
case 0 : // Init
112
113
time = get_tmr10ms ();
113
114
state = 1 ;
114
115
case 1 : // Wait for a valid packet
115
116
if (gpsNewFrameNMEA (c)) {
116
- gpsProtocol = GPS_PROTOCOL_NMEA;
117
+ if (!firstPacketNMEA) {
118
+ firstPacketNMEA = time ;
119
+ } else if (time - firstPacketNMEA > 200 ) {
120
+ // continuous stream of NMEA packets for 2 seconds, but no UBX packets
121
+ gpsProtocol = GPS_PROTOCOL_NMEA;
122
+ }
117
123
state = 0 ;
118
124
return ;
119
125
}
@@ -125,8 +131,9 @@ static void autodetectProtocol(uint8_t c)
125
131
}
126
132
127
133
uint32_t new_time = get_tmr10ms ();
128
- if (new_time - time > 20 ) {
134
+ if (new_time - time > 50 ) {
129
135
// No message received
136
+ firstPacketNMEA = 0 ;
130
137
changeBaudrate ();
131
138
time = new_time;
132
139
}
Original file line number Diff line number Diff line change @@ -129,10 +129,7 @@ static void configureGps(bool detect)
129
129
{
130
130
static int state = 0 ;
131
131
132
- if (detect) {
133
- state = 0 ;
134
- return ;
135
- }
132
+ if (detect) state = 0 ;
136
133
137
134
auto txCompleted = gpsSerialDrv->txCompleted ;
138
135
if (txCompleted && !txCompleted (gpsSerialCtx)) return ;
You can’t perform that action at this time.
0 commit comments