fix: air530 behaves a bit differently than described in the datasheet
This commit is contained in:
parent
cafc58e49f
commit
83015ff022
2 changed files with 36 additions and 29 deletions
|
@ -15,7 +15,7 @@ framework = arduino
|
|||
lib_deps =
|
||||
https://github.com/marcoschwartz/LiquidCrystal_I2C
|
||||
https://github.com/rocketscream/Low-Power
|
||||
build_flags = -DGPSM_UBLOX6
|
||||
build_flags = -DGPSM_AIR530
|
||||
upload_protocol = custom
|
||||
upload_flags =
|
||||
-C
|
||||
|
|
63
src/main.cpp
63
src/main.cpp
|
@ -541,9 +541,18 @@ uint8_t nmeaState = 0;
|
|||
char nmeaStr[256]; // NMEA-0183 messages should only be 82 characters, but the NEO-6M sends much longer messages
|
||||
char *sptr;
|
||||
void readNmeaRmc() {
|
||||
if (nmeaState == 3) {
|
||||
nmeaState = 0;
|
||||
}
|
||||
|
||||
while (Serial.available()) {
|
||||
if (!Serial.available()) {
|
||||
return;
|
||||
}
|
||||
while (nmeaState != 3) {
|
||||
int16_t byt = Serial.read();
|
||||
if (byt == -1) {
|
||||
continue;
|
||||
}
|
||||
if (byt == '$') {
|
||||
nmeaState = 1;
|
||||
sptr = nmeaStr;
|
||||
|
@ -551,14 +560,14 @@ void readNmeaRmc() {
|
|||
if (nmeaState == 1) {
|
||||
*(sptr++) = (char) byt;
|
||||
if (sptr >= nmeaStr + sizeof(nmeaStr)) {
|
||||
nmeaState = 0;
|
||||
nmeaState = 3;
|
||||
}
|
||||
if (byt == '*') {
|
||||
*sptr = 0;
|
||||
if (nmeaStr[3] == 'R' && nmeaStr[4] == 'M' && nmeaStr[5] == 'C') {
|
||||
nmeaState = 2;
|
||||
} else {
|
||||
nmeaState = 0;
|
||||
nmeaState = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -567,11 +576,6 @@ void readNmeaRmc() {
|
|||
// L80-R: Send GPS module into standby mode
|
||||
Serial.println("$PMTK161,0*28");
|
||||
Serial.flush();
|
||||
#endif
|
||||
#if defined(GPSM_AIR530)
|
||||
// AIR530: Send GPS module into low-power mode
|
||||
Serial.println("$PGKC051,1*36");
|
||||
Serial.flush();
|
||||
#endif
|
||||
char buf[16];
|
||||
char *bptr = buf;
|
||||
|
@ -635,7 +639,7 @@ void readNmeaRmc() {
|
|||
} else {
|
||||
*bptr++ = *ptr;
|
||||
if (bptr >= buf + 16) {
|
||||
nmeaState = 0;
|
||||
nmeaState = 3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -675,7 +679,6 @@ void readNmeaRmc() {
|
|||
}
|
||||
memcpy(aprs+34, config.comment, config.commentLen);
|
||||
aprs[34+config.commentLen] = 0;
|
||||
Serial.println(aprs);
|
||||
// AX.25 3.8 - FCS is sent MSB first
|
||||
uint16_t fcs = 0xffff;
|
||||
for (size_t i = 0; i < sizeof(frame); ++i) {
|
||||
|
@ -701,7 +704,7 @@ void readNmeaRmc() {
|
|||
digitalWrite(PTT_IND, LOW);
|
||||
|
||||
}
|
||||
nmeaState = 0;
|
||||
nmeaState = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -729,6 +732,15 @@ void setup() {
|
|||
// AIR530: Disable all NMEA sentences except for GPRMC
|
||||
Serial.println("$PGKC242,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*36");
|
||||
Serial.flush();
|
||||
// AIR530: Disable all NMEA sentences except for GPRMC
|
||||
Serial.println("$PGKC242,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*36");
|
||||
Serial.flush();
|
||||
// AIR530: Send NMEA sentences once every 10s
|
||||
Serial.println("$PGKC101,10000*32");
|
||||
Serial.flush();
|
||||
// AIR530: Send GPS module into low-power mode
|
||||
Serial.println("$PGKC105,8*3F");
|
||||
Serial.flush();
|
||||
#else
|
||||
// Assume NMEA-0183 default baud rate of 4800
|
||||
Serial.begin(4800);
|
||||
|
@ -754,7 +766,6 @@ void setup() {
|
|||
|
||||
|
||||
void loop() {
|
||||
readNmeaRmc();
|
||||
if (editingConfig) {
|
||||
editConfig();
|
||||
return;
|
||||
|
@ -801,22 +812,18 @@ void loop() {
|
|||
}
|
||||
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
|
||||
if (!abcPressed && !setPressed) {
|
||||
off = true;
|
||||
lcd.noDisplay();
|
||||
lcd.noBacklight();
|
||||
readNmeaRmc();
|
||||
off = true;
|
||||
lcd.noDisplay();
|
||||
lcd.noBacklight();
|
||||
} else if (off) {
|
||||
off = false;
|
||||
abcPressed = false;
|
||||
setPressed = false;
|
||||
if (editingConfig || editingComment) {
|
||||
lcd.blink();
|
||||
}
|
||||
lcd.backlight();
|
||||
lcd.display();
|
||||
off = false;
|
||||
abcPressed = false;
|
||||
setPressed = false;
|
||||
if (editingConfig || editingComment) {
|
||||
lcd.blink();
|
||||
}
|
||||
lcd.backlight();
|
||||
lcd.display();
|
||||
}
|
||||
#if defined(GPSM_AIR530)
|
||||
// Wake AIR530
|
||||
Serial.println();
|
||||
Serial.flush();
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue