fix: air530 behaves a bit differently than described in the datasheet

This commit is contained in:
s3lph 2023-05-29 02:35:07 +02:00
parent cafc58e49f
commit 83015ff022
Signed by: s3lph
GPG key ID: 0AA29A52FB33CFB5
2 changed files with 36 additions and 29 deletions

View file

@ -15,7 +15,7 @@ framework = arduino
lib_deps = lib_deps =
https://github.com/marcoschwartz/LiquidCrystal_I2C https://github.com/marcoschwartz/LiquidCrystal_I2C
https://github.com/rocketscream/Low-Power https://github.com/rocketscream/Low-Power
build_flags = -DGPSM_UBLOX6 build_flags = -DGPSM_AIR530
upload_protocol = custom upload_protocol = custom
upload_flags = upload_flags =
-C -C

View file

@ -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 nmeaStr[256]; // NMEA-0183 messages should only be 82 characters, but the NEO-6M sends much longer messages
char *sptr; char *sptr;
void readNmeaRmc() { void readNmeaRmc() {
if (nmeaState == 3) {
nmeaState = 0;
}
while (Serial.available()) { if (!Serial.available()) {
return;
}
while (nmeaState != 3) {
int16_t byt = Serial.read(); int16_t byt = Serial.read();
if (byt == -1) {
continue;
}
if (byt == '$') { if (byt == '$') {
nmeaState = 1; nmeaState = 1;
sptr = nmeaStr; sptr = nmeaStr;
@ -551,14 +560,14 @@ void readNmeaRmc() {
if (nmeaState == 1) { if (nmeaState == 1) {
*(sptr++) = (char) byt; *(sptr++) = (char) byt;
if (sptr >= nmeaStr + sizeof(nmeaStr)) { if (sptr >= nmeaStr + sizeof(nmeaStr)) {
nmeaState = 0; nmeaState = 3;
} }
if (byt == '*') { if (byt == '*') {
*sptr = 0; *sptr = 0;
if (nmeaStr[3] == 'R' && nmeaStr[4] == 'M' && nmeaStr[5] == 'C') { if (nmeaStr[3] == 'R' && nmeaStr[4] == 'M' && nmeaStr[5] == 'C') {
nmeaState = 2; nmeaState = 2;
} else { } else {
nmeaState = 0; nmeaState = 3;
} }
} }
} }
@ -567,11 +576,6 @@ void readNmeaRmc() {
// L80-R: Send GPS module into standby mode // L80-R: Send GPS module into standby mode
Serial.println("$PMTK161,0*28"); Serial.println("$PMTK161,0*28");
Serial.flush(); Serial.flush();
#endif
#if defined(GPSM_AIR530)
// AIR530: Send GPS module into low-power mode
Serial.println("$PGKC051,1*36");
Serial.flush();
#endif #endif
char buf[16]; char buf[16];
char *bptr = buf; char *bptr = buf;
@ -635,7 +639,7 @@ void readNmeaRmc() {
} else { } else {
*bptr++ = *ptr; *bptr++ = *ptr;
if (bptr >= buf + 16) { if (bptr >= buf + 16) {
nmeaState = 0; nmeaState = 3;
break; break;
} }
} }
@ -675,7 +679,6 @@ void readNmeaRmc() {
} }
memcpy(aprs+34, config.comment, config.commentLen); memcpy(aprs+34, config.comment, config.commentLen);
aprs[34+config.commentLen] = 0; aprs[34+config.commentLen] = 0;
Serial.println(aprs);
// AX.25 3.8 - FCS is sent MSB first // AX.25 3.8 - FCS is sent MSB first
uint16_t fcs = 0xffff; uint16_t fcs = 0xffff;
for (size_t i = 0; i < sizeof(frame); ++i) { for (size_t i = 0; i < sizeof(frame); ++i) {
@ -701,7 +704,7 @@ void readNmeaRmc() {
digitalWrite(PTT_IND, LOW); digitalWrite(PTT_IND, LOW);
} }
nmeaState = 0; nmeaState = 3;
} }
} }
} }
@ -729,6 +732,15 @@ void setup() {
// AIR530: Disable all NMEA sentences except for GPRMC // 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.println("$PGKC242,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*36");
Serial.flush(); 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 #else
// Assume NMEA-0183 default baud rate of 4800 // Assume NMEA-0183 default baud rate of 4800
Serial.begin(4800); Serial.begin(4800);
@ -754,7 +766,6 @@ void setup() {
void loop() { void loop() {
readNmeaRmc();
if (editingConfig) { if (editingConfig) {
editConfig(); editConfig();
return; return;
@ -801,6 +812,7 @@ void loop() {
} }
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
if (!abcPressed && !setPressed) { if (!abcPressed && !setPressed) {
readNmeaRmc();
off = true; off = true;
lcd.noDisplay(); lcd.noDisplay();
lcd.noBacklight(); lcd.noBacklight();
@ -814,9 +826,4 @@ void loop() {
lcd.backlight(); lcd.backlight();
lcd.display(); lcd.display();
} }
#if defined(GPSM_AIR530)
// Wake AIR530
Serial.println();
Serial.flush();
#endif
} }