Skip to content

Commit 2411467

Browse files
committed
Expand math in downloadDeviceConfig
1 parent 95e0a02 commit 2411467

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/SparkFun_u-blox_GNSS_Arduino_Library.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5214,19 +5214,25 @@ uint8_t SFE_UBLOX_GNSS::sendCfgValset8(uint32_t key, uint8_t value, uint16_t max
52145214
return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
52155215
}
52165216

5217-
//Read 18 sets of key values, for a total of 1088 keys
5217+
//u-center reads 19 queries, 64 keys obtained in each query for 1216 keys
52185218
//Format the output to match the config files that u-center can understand
52195219
//Layer number can be 0 (RAM) or layer 7 (Default)
52205220
void SFE_UBLOX_GNSS::downloadDeviceConfig(Stream &downloadPort, uint8_t layerNumber, uint16_t maxWait)
52215221
{
5222-
for (int x = 0; x < 18; x++)
5222+
const uint16_t keysToObtain = 1216;
5223+
const uint16_t keysPerQuery = 64;
5224+
const uint16_t loops = keysToObtain / keysPerQuery;
5225+
5226+
const uint32_t keyIDRequestAll = 0x0FFF0000; //KeyID of 0x0FFF0000 is request for all items known to the receiver in all groups.
5227+
5228+
for (uint16_t x = 0; x < loops; x++)
52235229
{
5224-
//KeyID of 0x0FFF0000 is magic config read key. Found using u-center and downloading Receiver Configuration from Tools menu.
5225-
//Advance by 64 keys each time
5226-
if (getVal(0x0FFF0000, layerNumber, x * 64, maxWait) != SFE_UBLOX_STATUS_SUCCESS)
5230+
5231+
//Advance by keysPerQuery keys each time
5232+
if (getVal(keyIDRequestAll, layerNumber, x * keysPerQuery, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED)
52275233
{
52285234
//Try again
5229-
if (getVal(0x0FFF0000, layerNumber, x * 64, maxWait) != SFE_UBLOX_STATUS_SUCCESS)
5235+
if (getVal(keyIDRequestAll, layerNumber, x * keysPerQuery, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED)
52305236
{
52315237
if (_printDebug == true)
52325238
{
@@ -5249,7 +5255,7 @@ void SFE_UBLOX_GNSS::downloadDeviceConfig(Stream &downloadPort, uint8_t layerNum
52495255
downloadPort.print(responseLength >> 8, HEX);
52505256

52515257
//Pretty print the payload
5252-
for (int x = 0; x < 32; x++)
5258+
for (int x = 0; x < packetCfg.len; x++)
52535259
{
52545260
downloadPort.print(F(" "));
52555261
if (payloadCfg[x] < 0x10)

0 commit comments

Comments
 (0)