Skip to content

Commit 3788fbb

Browse files
committed
Bangle.js2: GPS now detects binary CASIC packets and splits them into their own GPS-raw event
1 parent 484f00c commit 3788fbb

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
X.on now always allocates an array - tidies up code (fix #2559)
4141
Bangle.js: E.showMenu no longer sends the internal `l` menu object as argument when running the callback function.
4242
Bangle.js2: GPS request RMC packet automatically (so GPS speed/time work even without AGPS) (fix #2354)
43+
Bangle.js2: GPS now detects binary CASIC packets and splits them into their own GPS-raw event
4344

4445
2v24 : Bangle.js2: Add 'Bangle.touchRd()', 'Bangle.touchWr()'
4546
Bangle.js2: After Bangle.showTestScreen, put Bangle.js into a hard off state (not soft off)

libs/banglejs/jswrap_bangle.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ JshI2CInfo i2cHRM;
587587
#define PRESSURE_I2C &i2cPressure
588588
#define HRM_I2C &i2cHRM
589589
#define GPS_UART EV_SERIAL1
590+
#define GPS_CASIC 1 // handle decoding of 'CASIC' packets from the GPS
590591
#define HEARTRATE 1
591592

592593
bool pressureBMP280Enabled = false;
@@ -4658,7 +4659,7 @@ bool jswrap_banglejs_idle() {
46584659
bool jswrap_banglejs_gps_character(char ch) {
46594660
#ifdef GPS_PIN_RX
46604661
// if too many chars, roll over since it's probably because we skipped a newline
4661-
// or messed the message length
4662+
// or messed up the message length
46624663
if (gpsLineLength >= sizeof(gpsLine)) {
46634664
#ifdef GPS_UBLOX
46644665
if (inComingUbloxProtocol == UBLOX_PROTOCOL_UBX &&
@@ -4689,6 +4690,21 @@ bool jswrap_banglejs_gps_character(char ch) {
46894690
}
46904691
#endif // GPS_UBLOX
46914692
gpsLine[gpsLineLength++] = ch;
4693+
#ifdef GPS_CASIC
4694+
if (gpsLineLength>2 && gpsLine[0]==0xBA && gpsLine[1]==0xCE) {
4695+
if (gpsLineLength<4) return true; // not enough data for length
4696+
int len = gpsLine[2] | (gpsLine[3] << 8);
4697+
// 4 class, 5 = msg
4698+
// 4 byte checksum on end
4699+
if (gpsLineLength>=len+10) { // packet end!
4700+
memcpy(gpsLastLine, gpsLine, gpsLineLength);
4701+
gpsLastLineLength = gpsLineLength;
4702+
bangleTasks |= JSBT_GPS_DATA_LINE;
4703+
gpsClearLine();
4704+
}
4705+
return true;
4706+
}
4707+
#endif
46924708
if (
46934709
#ifdef GPS_UBLOX
46944710
inComingUbloxProtocol == UBLOX_PROTOCOL_NMEA &&

0 commit comments

Comments
 (0)