Skip to content

Commit

Permalink
Bangle.js2: GPS now detects binary CASIC packets and splits them into…
Browse files Browse the repository at this point in the history
… their own GPS-raw event
  • Loading branch information
gfwilliams committed Oct 11, 2024
1 parent 484f00c commit 3788fbb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
X.on now always allocates an array - tidies up code (fix #2559)
Bangle.js: E.showMenu no longer sends the internal `l` menu object as argument when running the callback function.
Bangle.js2: GPS request RMC packet automatically (so GPS speed/time work even without AGPS) (fix #2354)
Bangle.js2: GPS now detects binary CASIC packets and splits them into their own GPS-raw event

2v24 : Bangle.js2: Add 'Bangle.touchRd()', 'Bangle.touchWr()'
Bangle.js2: After Bangle.showTestScreen, put Bangle.js into a hard off state (not soft off)
Expand Down
18 changes: 17 additions & 1 deletion libs/banglejs/jswrap_bangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ JshI2CInfo i2cHRM;
#define PRESSURE_I2C &i2cPressure
#define HRM_I2C &i2cHRM
#define GPS_UART EV_SERIAL1
#define GPS_CASIC 1 // handle decoding of 'CASIC' packets from the GPS
#define HEARTRATE 1

bool pressureBMP280Enabled = false;
Expand Down Expand Up @@ -4658,7 +4659,7 @@ bool jswrap_banglejs_idle() {
bool jswrap_banglejs_gps_character(char ch) {
#ifdef GPS_PIN_RX
// if too many chars, roll over since it's probably because we skipped a newline
// or messed the message length
// or messed up the message length
if (gpsLineLength >= sizeof(gpsLine)) {
#ifdef GPS_UBLOX
if (inComingUbloxProtocol == UBLOX_PROTOCOL_UBX &&
Expand Down Expand Up @@ -4689,6 +4690,21 @@ bool jswrap_banglejs_gps_character(char ch) {
}
#endif // GPS_UBLOX
gpsLine[gpsLineLength++] = ch;
#ifdef GPS_CASIC
if (gpsLineLength>2 && gpsLine[0]==0xBA && gpsLine[1]==0xCE) {
if (gpsLineLength<4) return true; // not enough data for length
int len = gpsLine[2] | (gpsLine[3] << 8);
// 4 class, 5 = msg
// 4 byte checksum on end
if (gpsLineLength>=len+10) { // packet end!
memcpy(gpsLastLine, gpsLine, gpsLineLength);
gpsLastLineLength = gpsLineLength;
bangleTasks |= JSBT_GPS_DATA_LINE;
gpsClearLine();
}
return true;
}
#endif
if (
#ifdef GPS_UBLOX
inComingUbloxProtocol == UBLOX_PROTOCOL_NMEA &&
Expand Down

0 comments on commit 3788fbb

Please sign in to comment.