sparkfun / SparkFun_u-blox_GNSS_Arduino_Library

An Arduino library which allows you to communicate seamlessly with the full range of u-blox GNSS modules
Other
227 stars 100 forks source link

How to change and save the I2C address #212

Closed dizcza closed 8 months ago

dizcza commented 8 months ago

Subject of the issue

The saveConfiguration comments the following docs:

Save current configuration to flash and BBR (battery backed RAM)

This, however, isn't true.

Your workbench

Steps to reproduce

    myGNSS.setI2CAddress(0x43);
    Serial.printf("saveConfiguration %d\n", myGNSS.saveConfiguration());  // prints 1 as expected

Then ping and you should see 0x43. And I do see 0x43 until a power reset, which resets the device address to its default value, 0x42.

Expected behavior

Settings are saved in flash

Actual behavior

Settings are not saved in flash


I noticed that you don't specify the deviceMask and set the packet length to 12. I tried changing your function

// Save current configuration to flash and BBR (battery backed RAM)
// This still works but it is the old way of configuring ublox modules. See getVal and setVal for the new methods
bool SFE_UBLOX_GNSS::saveConfiguration(uint16_t maxWait)
{
  packetCfg.cls = UBX_CLASS_CFG;
  packetCfg.id = UBX_CFG_CFG;
  packetCfg.len = 13;
  packetCfg.startingSpot = 0;

  // Clear packet payload
  memset(payloadCfg, 0, packetCfg.len);

  packetCfg.payload[4] = 0b11111; // Set any bit in the saveMask field to save current config to Flash and BBR
  packetCfg.payload[5] = 0b11111;
  packetCfg.payload[12] = 0b10111;

  return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
}

but this didn't help either.

Any clue?

PaulZC commented 8 months ago

Hi Danylo (@dizcza ),

You are trying to do the saveConfiguration too quickly - before the new address has taken effect. Please look at Example9.

The steps are:

I hope this helps, Paul