Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gps research #3816

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
66 changes: 55 additions & 11 deletions src/gps/GPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ bool GPS::setup()
gnssModel = GNSS_MODEL_UNKNOWN;
}
#else
gnssModel = GNSS_MODEL_UC6580;
gnssModel = GNSS_MODEL_UC6580;
#endif

if (gnssModel == GNSS_MODEL_MTK) {
Expand Down Expand Up @@ -483,7 +483,14 @@ bool GPS::setup()
// Also we need SBAS for better accuracy and extra features
// ToDo: Dynamic configure GNSS systems depending of LoRa region

if (strncmp(info.hwVersion, "000A0000", 8) != 0) {
// M10: "000A0000"
// M9: "00190000"
// M8: "00080000"
// M7: "00070000"
// M6: "00040007"

// Not M9 or M10
if (strncmp(info.hwVersion, "000A0000", 8) != 0 && strncmp(info.hwVersion, "00190000", 8) != 0) {
if (strncmp(info.hwVersion, "00040007", 8) != 0) {
// The original ublox Neo-6 is GPS only and doesn't support the UBX-CFG-GNSS message
// Max7 seems to only support GPS *or* GLONASS
Expand Down Expand Up @@ -522,7 +529,7 @@ bool GPS::setup()
if (getACK(0x06, 0x02, 500) != GNSS_RESPONSE_OK) {
LOG_WARN("Unable to disable text info messages.\n");
}
// ToDo add M10 tests for below

if (strncmp(info.hwVersion, "00080000", 8) == 0) {
msglen = makeUBXPacket(0x06, 0x39, sizeof(_message_JAM_8), _message_JAM_8);
clearBuffer();
Expand Down Expand Up @@ -551,7 +558,6 @@ bool GPS::setup()
}
}
// Turn off unwanted NMEA messages, set update rate

msglen = makeUBXPacket(0x06, 0x08, sizeof(_message_1HZ), _message_1HZ);
_serial_gps->write(UBXscratch, msglen);
if (getACK(0x06, 0x08, 500) != GNSS_RESPONSE_OK) {
Expand Down Expand Up @@ -646,7 +652,33 @@ bool GPS::setup()
}
}
}
} else {
}

// M9
if (strncmp(info.hwVersion, "00190000", 8) == 0) {
LOG_INFO("Using defaults for config for UBLOX M9\n");
// reset, 0x00, 0x00, 0x00, // byte length
// manually reset in development
// TODO: add to python CLI
// msglen = makeUBXPacket(0xb5, 0x62, sizeof(_message_CFG_RST), _message_CFG_RST);
// _serial_gps->write(UBXscratch, msglen);

// Turn off unwanted NMEA messages, set update rate
// --> THIS IS FAILING CURRENTLY
// --> NEEDS TRANSLATION TO 32.01
msglen = makeUBXPacket(0xb5, 0x62, sizeof(_message_1HZ), _message_1HZ);
_serial_gps->write(UBXscratch, msglen);

if (getACK(0x06, 0x08, 500) != GNSS_RESPONSE_OK) {
LOG_WARN("Unable to set GPS update rate.\n");
} else {
LOG_INFO("Successfully set GPS update rate.!\n");
}
delay(1000);
}
Copy link
Contributor Author

@hdngr hdngr May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What other messages should go here? Not super familiar with all of these protocols. A dump of the hex code for M9 would be helpful BUT, a pointer directly to config. Would be cool too.

For instance, what does _message_VALSET_DISABLE_NMEA_RAM correspond to? Would it be 3.10.13 UBX-CFG-NMEA (0x06 0x17)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GPSFan ^^... cc: @lolsborn

@GPSFan if you made comments in here with what configs our commands you think we absolutely need, we can grind them out. We'd appreciate it! 🙏


// M10
if(strncmp(info.hwVersion, "000A0000", 8) == 0) {
// LOG_INFO("u-blox M10 hardware found.\n");
delay(1000);
// First disable all NMEA messages in RAM layer
Expand Down Expand Up @@ -738,11 +770,11 @@ bool GPS::setup()
// BBR will survive a restart, and power off for a while, but modules with small backup
// batteries or super caps will not retain the config for a long power off time.
}
msglen = makeUBXPacket(0x06, 0x09, sizeof(_message_SAVE), _message_SAVE);
_serial_gps->write(UBXscratch, msglen);
if (getACK(0x06, 0x09, 2000) != GNSS_RESPONSE_OK) {
msglen = makeUBXPacket(0x06, 0x09, sizeof(_message_SAVE), _message_SAVE);
_serial_gps->write(UBXscratch, msglen);
if (getACK(0x06, 0x09, 2000) != GNSS_RESPONSE_OK) {
LOG_WARN("Unable to save GNSS module configuration.\n");
} else {
} else {
LOG_INFO("GNSS module configuration saved!\n");
}
}
Expand Down Expand Up @@ -1153,6 +1185,7 @@ GnssModel_t GPS::probe(int serialSpeed)
_serial_gps->write(_message_prt, sizeof(_message_prt));
delay(500);
serialSpeed = 9600;

#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO) || defined(ARCH_RP2040)
_serial_gps->end();
_serial_gps->begin(serialSpeed);
Expand Down Expand Up @@ -1384,9 +1417,20 @@ bool GPS::factoryReset()
delay(100);
// send the UBLOX Factory Reset Command regardless of detect state, something is very wrong, just assume it's UBLOX.
// Factory Reset
byte _message_reset[] = {0xB5, 0x62, 0x06, 0x09, 0x0D, 0x00, 0xFF, 0xFB, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x17, 0x2B, 0x7E};
// byte _message_reset[] = {0xB5, 0x62, 0x06, 0x09, 0x0D, 0x00, 0xFF, 0xFB, 0x00, 0x00, 0x00,
// 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x17, 0x2B, 0x7E};
byte _message_reset[] = {
0xB5, 0x62, // header
0x06, 0x04, // class, id
0x0D, 0x00, 0xFF, 0xFB, // length
0x00, 0x00, // hotstart M8
0x00, // hardware reset
0x00, // reserved
0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x17,
0x2B, 0x7E // checksum
};
_serial_gps->write(_message_reset, sizeof(_message_reset));
LOG_DEBUG("Sent Factory Reset\n");
}
delay(1000);
return true;
Expand Down
5 changes: 5 additions & 0 deletions src/gps/GPS.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ class GPS : private concurrency::OSThread
static const uint8_t _message_PMS[];
static const uint8_t _message_SAVE[];

// RST Commands for M9
static const uint8_t _message_CFG_RST[];
// VALSET Commands for M9
// static const uint8_t _message_VALSET_SIGNAL[];

// VALSET Commands for M10
static const uint8_t _message_VALSET_PM[];
static const uint8_t _message_VALSET_PM_RAM[];
Expand Down
12 changes: 11 additions & 1 deletion src/gps/ubx.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,15 @@ const uint8_t GPS::_message_SAVE[] = {
0x17 // deviceMask: BBR, Flash, EEPROM, and SPI Flash
};

// M9 Commands
const uint8_t GPS::_message_CFG_RST[] = {
0x06, 0x04, // class, id
0x00, 0x00, 0x00, 0x00, // length 4 bytes
0xFF, 0xFF, 0x00, 0x00 // payload: restart type - 0xFFFF Cold start , reset mode - 0x00 hardware reset, reserved

};


// As the M10 has no flash, the best we can do to preserve the config is to set it in RAM and BBR.
// BBR will survive a restart, and power off for a while, but modules with small backup
// batteries or super caps will not retain the config for a long power off time.
Expand Down Expand Up @@ -450,4 +459,5 @@ b5 62 06 8a 0e 00 00 01 00 00 20 00 31 10 00 05 00 31 10 00 46 87

BBR layer config message:
b5 62 06 8a 0e 00 00 02 00 00 20 00 31 10 00 05 00 31 10 00 47 94
*/
*/

3 changes: 1 addition & 2 deletions variants/canaryone/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ static const uint8_t A0 = PIN_A0;
*/
#define HAS_GPS 1
#define GPS_UBLOX
#define GPS_BAUDRATE 38400

#define GPS_DEBUG 1
// #define PIN_GPS_WAKE (GPIO_PORT1 + 2) // An output to wake GPS, low means allow sleep, high means force wake
// Seems to be missing on this new board
#define PIN_GPS_PPS (GPIO_PORT1 + 4) // Pulse per second input from the GPS
Expand Down