mirror of
https://github.com/meshtastic/firmware.git
synced 2025-05-01 03:39:18 +00:00
Cleanup in prep for commiting
Fix some compilation warnings gate debug code behind GPS_DEBUG minor fix in u-blox protocol detection Begin to gate GPS messages based on protover
This commit is contained in:
parent
b21368ecfa
commit
7c98445ca3
@ -47,7 +47,7 @@ void GPS::UBXChecksum(byte *message, size_t length)
|
|||||||
message[length - 1] = CK_B;
|
message[length - 1] = CK_B;
|
||||||
}
|
}
|
||||||
|
|
||||||
GPS_RESPONSE GPS::getACK(const char *message, int waitMillis)
|
GPS_RESPONSE GPS::getACK(const char *message, uint32_t waitMillis)
|
||||||
{
|
{
|
||||||
uint8_t buffer[768] = {0};
|
uint8_t buffer[768] = {0};
|
||||||
uint8_t b;
|
uint8_t b;
|
||||||
@ -62,27 +62,31 @@ GPS_RESPONSE GPS::getACK(const char *message, int waitMillis)
|
|||||||
if (strnstr((char *)buffer, message, bytesRead) != nullptr) {
|
if (strnstr((char *)buffer, message, bytesRead) != nullptr) {
|
||||||
return GNSS_RESPONSE_OK;
|
return GNSS_RESPONSE_OK;
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef GPS_DEBUG
|
||||||
buffer[bytesRead] = '\0';
|
buffer[bytesRead] = '\0';
|
||||||
bytesRead++;
|
bytesRead++;
|
||||||
LOG_INFO("Bytes read:%s\n", (char*) buffer);
|
LOG_INFO("Bytes read:%s\n", (char *)buffer);
|
||||||
|
#endif
|
||||||
bytesRead = 0;
|
bytesRead = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef GPS_DEBUG
|
||||||
buffer[bytesRead] = '\0';
|
buffer[bytesRead] = '\0';
|
||||||
bytesRead++;
|
bytesRead++;
|
||||||
LOG_INFO("Bytes read:%s\n", (char*) buffer);
|
LOG_INFO("Bytes read:%s\n", (char *)buffer);
|
||||||
|
#endif
|
||||||
return GNSS_RESPONSE_NONE;
|
return GNSS_RESPONSE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GPS_RESPONSE GPS::getACK(uint8_t class_id, uint8_t msg_id, int waitMillis)
|
GPS_RESPONSE GPS::getACK(uint8_t class_id, uint8_t msg_id, uint32_t waitMillis)
|
||||||
{
|
{
|
||||||
uint8_t b;
|
uint8_t b;
|
||||||
uint8_t ack = 0;
|
uint8_t ack = 0;
|
||||||
const uint8_t ackP[2] = {class_id, msg_id};
|
const uint8_t ackP[2] = {class_id, msg_id};
|
||||||
uint8_t buf[10] = {0xB5, 0x62, 0x05, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00};
|
uint8_t buf[10] = {0xB5, 0x62, 0x05, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||||
unsigned long startTime = millis();
|
uint32_t startTime = millis();
|
||||||
const char frame_errors[] = "More than 100 frame errors";
|
const char frame_errors[] = "More than 100 frame errors";
|
||||||
int sCounter = 0;
|
int sCounter = 0;
|
||||||
|
|
||||||
@ -99,7 +103,9 @@ GPS_RESPONSE GPS::getACK(uint8_t class_id, uint8_t msg_id, int waitMillis)
|
|||||||
|
|
||||||
while (millis() - startTime < waitMillis) {
|
while (millis() - startTime < waitMillis) {
|
||||||
if (ack > 9) {
|
if (ack > 9) {
|
||||||
// LOG_INFO("Got ACK for class %02X message %02X in %d millis.\n", class_id, msg_id, millis() - startTime);
|
#ifdef GPS_DEBUG
|
||||||
|
LOG_INFO("Got ACK for class %02X message %02X in %d millis.\n", class_id, msg_id, millis() - startTime);
|
||||||
|
#endif
|
||||||
return GNSS_RESPONSE_OK; // ACK received
|
return GNSS_RESPONSE_OK; // ACK received
|
||||||
}
|
}
|
||||||
if (_serial_gps->available()) {
|
if (_serial_gps->available()) {
|
||||||
@ -138,7 +144,7 @@ GPS_RESPONSE GPS::getACK(uint8_t class_id, uint8_t msg_id, int waitMillis)
|
|||||||
* @param requestedID: request message ID constant
|
* @param requestedID: request message ID constant
|
||||||
* @retval length of payload message
|
* @retval length of payload message
|
||||||
*/
|
*/
|
||||||
int GPS::getACK(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t requestedID, int waitMillis)
|
int GPS::getACK(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t requestedID, uint32_t waitMillis)
|
||||||
{
|
{
|
||||||
uint16_t ubxFrameCounter = 0;
|
uint16_t ubxFrameCounter = 0;
|
||||||
uint32_t startTime = millis();
|
uint32_t startTime = millis();
|
||||||
@ -198,8 +204,10 @@ int GPS::getACK(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t
|
|||||||
ubxFrameCounter = 0;
|
ubxFrameCounter = 0;
|
||||||
} else {
|
} else {
|
||||||
// return payload length
|
// return payload length
|
||||||
// LOG_INFO("Got ACK for class %02X message %02X in %d millis.\n", requestedClass, requestedID, millis() -
|
#ifdef GPS_DEBUG
|
||||||
// startTime);
|
LOG_INFO("Got ACK for class %02X message %02X in %d millis.\n", requestedClass, requestedID,
|
||||||
|
millis() - startTime);
|
||||||
|
#endif
|
||||||
return needRead;
|
return needRead;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -548,6 +556,7 @@ bool GPS::setupGPS()
|
|||||||
// set to Interval; otherwise, it must be set to '0'. The 'onTime' field specifies the duration of the ON phase and
|
// set to Interval; otherwise, it must be set to '0'. The 'onTime' field specifies the duration of the ON phase and
|
||||||
// must be smaller than the period. It is only valid when the powerSetupValue is set to Interval; otherwise, it must
|
// must be smaller than the period. It is only valid when the powerSetupValue is set to Interval; otherwise, it must
|
||||||
// be set to '0'.
|
// be set to '0'.
|
||||||
|
if (uBloxProtocolVersion >= 18) {
|
||||||
byte UBX_CFG_PMS[14] = {
|
byte UBX_CFG_PMS[14] = {
|
||||||
0xB5, 0x62, // UBX sync characters
|
0xB5, 0x62, // UBX sync characters
|
||||||
0x06, 0x86, // Message class and ID (UBX-CFG-PMS)
|
0x06, 0x86, // Message class and ID (UBX-CFG-PMS)
|
||||||
@ -567,7 +576,7 @@ bool GPS::setupGPS()
|
|||||||
if (getACK(0x06, 0x86, 300) != GNSS_RESPONSE_OK) {
|
if (getACK(0x06, 0x86, 300) != GNSS_RESPONSE_OK) {
|
||||||
LOG_WARN("Unable to enable powersaving for GPS.\n");
|
LOG_WARN("Unable to enable powersaving for GPS.\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// We need save configuration to flash to make our config changes persistent
|
// We need save configuration to flash to make our config changes persistent
|
||||||
byte _message_SAVE[21] = {
|
byte _message_SAVE[21] = {
|
||||||
0xB5, 0x62, // UBX protocol header
|
0xB5, 0x62, // UBX protocol header
|
||||||
@ -938,6 +947,7 @@ GnssModel_t GPS::probe(int serialSpeed)
|
|||||||
#else
|
#else
|
||||||
_serial_gps->updateBaudRate(serialSpeed);
|
_serial_gps->updateBaudRate(serialSpeed);
|
||||||
#endif
|
#endif
|
||||||
|
delay(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(buffer, 0, sizeof(buffer));
|
memset(buffer, 0, sizeof(buffer));
|
||||||
@ -995,7 +1005,7 @@ GnssModel_t GPS::probe(int serialSpeed)
|
|||||||
} else {
|
} else {
|
||||||
LOG_INFO("UBlox GNSS init succeeded, using UBlox GNSS Module\n");
|
LOG_INFO("UBlox GNSS init succeeded, using UBlox GNSS Module\n");
|
||||||
}
|
}
|
||||||
} else if (!strncmp(info.extension[i], "PROTVER=", 8)) {
|
} else if (!strncmp(info.extension[i], "PROTVER", 7)) {
|
||||||
char *ptr = nullptr;
|
char *ptr = nullptr;
|
||||||
memset(buffer, 0, sizeof(buffer));
|
memset(buffer, 0, sizeof(buffer));
|
||||||
strncpy((char *)buffer, &(info.extension[i][8]), sizeof(buffer));
|
strncpy((char *)buffer, &(info.extension[i][8]), sizeof(buffer));
|
||||||
|
@ -179,9 +179,9 @@ class GPS : private concurrency::OSThread
|
|||||||
String getNMEA();
|
String getNMEA();
|
||||||
GnssModel_t probe(int serialSpeed);
|
GnssModel_t probe(int serialSpeed);
|
||||||
|
|
||||||
int getACK(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t requestedID, int waitMillis);
|
int getACK(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t requestedID, uint32_t waitMillis);
|
||||||
GPS_RESPONSE getACK(uint8_t c, uint8_t i, int waitMillis);
|
GPS_RESPONSE getACK(uint8_t c, uint8_t i, uint32_t waitMillis);
|
||||||
GPS_RESPONSE getACK(const char *message, int waitMillis);
|
GPS_RESPONSE getACK(const char *message, uint32_t waitMillis);
|
||||||
// delay counter to allow more sats before fixed position stops GPS thread
|
// delay counter to allow more sats before fixed position stops GPS thread
|
||||||
uint8_t fixeddelayCtr = 0;
|
uint8_t fixeddelayCtr = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user