Difficulty Adding "Static Hold Set" to "SFE_UBLOX_GNSS::setDynamicModel" Message

Hi,

I am trying to set the static hold value through a message and add this capability to “setDynamicModel” function in SparkFun GNSS Library.

Here is the modified code. However, Once flashed, the changes do not go into effect.
Can anyone help what is wrong with this modification?

Thanks

‘’
bool SFE_UBLOX_GNSS::setDynamicModel(dynModel newDynamicModel, uint16_t maxWait, uint8_t staticHoldThresh, uint16_t staticHoldMaxDist)
{
packetCfg.cls = UBX_CLASS_CFG;
packetCfg.id = UBX_CFG_NAV5;
packetCfg.len = 0;
packetCfg.startingSpot = 0;

// Ask module for the current navigation model settings. Loads into payloadCfg.
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
return (false);

payloadCfg[0] = 0b01000001; // mask: set only the dyn bit (0)
payloadCfg[1] = 0b00000000; // mask
payloadCfg[2] = newDynamicModel; // dynModel
payloadCfg[22] = staticHoldThresh;
payloadCfg[28] = staticHoldMaxDist & 0xFF;
payloadCfg[29] = (staticHoldMaxDist >> 8) & 0xFF;

packetCfg.len = 36;
packetCfg.startingSpot = 0;

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

Hi @msh911 ,

Which module are you using? It might be easier to do this through the Configuration Interface - if your module supports it.

Your code looks OK. You appear to be setting the correct bits and bytes.

My only suggestion would be to use read-modify-write (OR, |=) on the mask flags. I changed this in the library recently.

payloadCfg[0] |= 0b01000001; // mask: set the dyn bit (0) and staticHoldMask bit (6). Leave others unchanged

Also, try calling saveConfiguration() to ensure the changes are saved in BBR and Flash.

Maybe try increasing the static hold threshold? The units are cm/s.

I hope this helps,
Paul

1 Like

How’s data getting in/out of payloadCfg here? You’re passing packetCfg in both instances
I’d only set the bits for the things being changed.

1 Like

@PaulZC
That solved the problem,
Thanks so much

(Ps:I am using M8U module)

@clive1
Thanks for your help