Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Updated setVal and added 'multi' setVal #28

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions ISSUE_TEMPLATE.md

This file was deleted.

296 changes: 294 additions & 2 deletions src/SparkFun_Ublox_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
- Modified ProcessUBXPacket to parse HPPOSLLH packet
- Added query staleness verification for HPPOSLLH data

Modified by Paul Clark, 1st July 2019
- Added 8 and 32 bit versions of setVal
- Added newCfgValset, addCfgValset and sendCfgValset to support the setting of multiple keyID and value pairs simultaneously

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Expand Down Expand Up @@ -951,19 +955,28 @@ uint8_t SFE_UBLOX_GPS::getVal8(uint32_t key, uint8_t layer, uint16_t maxWait)
return (extractByte(8));
}

//Given a key, set an 8-bit value
//Given a key, set a 16-bit value
//This function takes a full 32-bit key
//Default layer is BBR
//Configuration of modern Ublox modules is now done via getVal/setVal/delVal, ie protocol v27 and above found on ZED-F9P
uint8_t SFE_UBLOX_GPS::setVal(uint32_t key, uint16_t value, uint8_t layer, uint16_t maxWait)
{
return setVal16(key, value, layer, maxWait);
}

//Given a key, set a 16-bit value
//This function takes a full 32-bit key
//Default layer is BBR
//Configuration of modern Ublox modules is now done via getVal/setVal/delVal, ie protocol v27 and above found on ZED-F9P
uint8_t SFE_UBLOX_GPS::setVal16(uint32_t key, uint16_t value, uint8_t layer, uint16_t maxWait)
{
packetCfg.cls = UBX_CLASS_CFG;
packetCfg.id = UBX_CFG_VALSET;
packetCfg.len = 4 + 4 + 2; //4 byte header, 4 byte key ID, 2 bytes of value
packetCfg.startingSpot = 0;

//Clear packet payload
for (uint8_t x = 0; x < packetCfg.len; x++)
for (uint16_t x = 0; x < packetCfg.len; x++)
packetCfg.payload[x] = 0;

payloadCfg[0] = 0; //Message Version - set to 0
Expand All @@ -987,6 +1000,285 @@ uint8_t SFE_UBLOX_GPS::setVal(uint32_t key, uint16_t value, uint8_t layer, uint1
return (true);
}

//Given a key, set an 8-bit value
//This function takes a full 32-bit key
//Default layer is BBR
//Configuration of modern Ublox modules is now done via getVal/setVal/delVal, ie protocol v27 and above found on ZED-F9P
uint8_t SFE_UBLOX_GPS::setVal8(uint32_t key, uint8_t value, uint8_t layer, uint16_t maxWait)
{
packetCfg.cls = UBX_CLASS_CFG;
packetCfg.id = UBX_CFG_VALSET;
packetCfg.len = 4 + 4 + 1; //4 byte header, 4 byte key ID, 1 byte value
packetCfg.startingSpot = 0;

//Clear packet payload
for (uint16_t x = 0; x < packetCfg.len; x++)
packetCfg.payload[x] = 0;

payloadCfg[0] = 0; //Message Version - set to 0
payloadCfg[1] = layer; //By default we ask for the BBR layer

//Load key into outgoing payload
payloadCfg[4] = key >> 8 * 0; //Key LSB
payloadCfg[5] = key >> 8 * 1;
payloadCfg[6] = key >> 8 * 2;
payloadCfg[7] = key >> 8 * 3;

//Load user's value
payloadCfg[8] = value; //Value

//Send VALSET command with this key and value
if (sendCommand(packetCfg, maxWait) == false)
return (false); //If command send fails then bail

//All done
return (true);
}

//Given a key, set a 32-bit value
//This function takes a full 32-bit key
//Default layer is BBR
//Configuration of modern Ublox modules is now done via getVal/setVal/delVal, ie protocol v27 and above found on ZED-F9P
uint8_t SFE_UBLOX_GPS::setVal32(uint32_t key, uint32_t value, uint8_t layer, uint16_t maxWait)
{
packetCfg.cls = UBX_CLASS_CFG;
packetCfg.id = UBX_CFG_VALSET;
packetCfg.len = 4 + 4 + 4; //4 byte header, 4 byte key ID, 4 bytes of value
packetCfg.startingSpot = 0;

//Clear packet payload
for (uint16_t x = 0; x < packetCfg.len; x++)
packetCfg.payload[x] = 0;

payloadCfg[0] = 0; //Message Version - set to 0
payloadCfg[1] = layer; //By default we ask for the BBR layer

//Load key into outgoing payload
payloadCfg[4] = key >> 8 * 0; //Key LSB
payloadCfg[5] = key >> 8 * 1;
payloadCfg[6] = key >> 8 * 2;
payloadCfg[7] = key >> 8 * 3;

//Load user's value
payloadCfg[8] = value >> 8 * 0; //Value LSB
payloadCfg[9] = value >> 8 * 1;
payloadCfg[10] = value >> 8 * 2;
payloadCfg[11] = value >> 8 * 3;

//Send VALSET command with this key and value
if (sendCommand(packetCfg, maxWait) == false)
return (false); //If command send fails then bail

//All done
return (true);
}

//Start defining a new UBX-CFG-VALSET ubxPacket
//This function takes a full 32-bit key and 32-bit value
//Default layer is BBR
//Configuration of modern Ublox modules is now done via getVal/setVal/delVal, ie protocol v27 and above found on ZED-F9P
uint8_t SFE_UBLOX_GPS::newCfgValset32(uint32_t key, uint32_t value, uint8_t layer)
{
packetCfg.cls = UBX_CLASS_CFG;
packetCfg.id = UBX_CFG_VALSET;
packetCfg.len = 4 + 4 + 4; //4 byte header, 4 byte key ID, 4 bytes of value
packetCfg.startingSpot = 0;

//Clear packet payload
for (uint16_t x = 0; x < MAX_PAYLOAD_SIZE; x++)
packetCfg.payload[x] = 0;

payloadCfg[0] = 0; //Message Version - set to 0
payloadCfg[1] = layer; //By default we ask for the BBR layer

//Load key into outgoing payload
payloadCfg[4] = key >> 8 * 0; //Key LSB
payloadCfg[5] = key >> 8 * 1;
payloadCfg[6] = key >> 8 * 2;
payloadCfg[7] = key >> 8 * 3;

//Load user's value
payloadCfg[8] = value >> 8 * 0; //Value LSB
payloadCfg[9] = value >> 8 * 1;
payloadCfg[10] = value >> 8 * 2;
payloadCfg[11] = value >> 8 * 3;

//All done
return (true);
}

//Start defining a new UBX-CFG-VALSET ubxPacket
//This function takes a full 32-bit key and 16-bit value
//Default layer is BBR
//Configuration of modern Ublox modules is now done via getVal/setVal/delVal, ie protocol v27 and above found on ZED-F9P
uint8_t SFE_UBLOX_GPS::newCfgValset16(uint32_t key, uint16_t value, uint8_t layer)
{
packetCfg.cls = UBX_CLASS_CFG;
packetCfg.id = UBX_CFG_VALSET;
packetCfg.len = 4 + 4 + 2; //4 byte header, 4 byte key ID, 2 bytes of value
packetCfg.startingSpot = 0;

//Clear packet payload
for (uint16_t x = 0; x < MAX_PAYLOAD_SIZE; x++)
packetCfg.payload[x] = 0;

payloadCfg[0] = 0; //Message Version - set to 0
payloadCfg[1] = layer; //By default we ask for the BBR layer

//Load key into outgoing payload
payloadCfg[4] = key >> 8 * 0; //Key LSB
payloadCfg[5] = key >> 8 * 1;
payloadCfg[6] = key >> 8 * 2;
payloadCfg[7] = key >> 8 * 3;

//Load user's value
payloadCfg[8] = value >> 8 * 0; //Value LSB
payloadCfg[9] = value >> 8 * 1;

//All done
return (true);
}

//Start defining a new UBX-CFG-VALSET ubxPacket
//This function takes a full 32-bit key and 8-bit value
//Default layer is BBR
//Configuration of modern Ublox modules is now done via getVal/setVal/delVal, ie protocol v27 and above found on ZED-F9P
uint8_t SFE_UBLOX_GPS::newCfgValset8(uint32_t key, uint8_t value, uint8_t layer)
{
packetCfg.cls = UBX_CLASS_CFG;
packetCfg.id = UBX_CFG_VALSET;
packetCfg.len = 4 + 4 + 1; //4 byte header, 4 byte key ID, 1 byte value
packetCfg.startingSpot = 0;

//Clear packet payload
for (uint16_t x = 0; x < MAX_PAYLOAD_SIZE; x++)
packetCfg.payload[x] = 0;

payloadCfg[0] = 0; //Message Version - set to 0
payloadCfg[1] = layer; //By default we ask for the BBR layer

//Load key into outgoing payload
payloadCfg[4] = key >> 8 * 0; //Key LSB
payloadCfg[5] = key >> 8 * 1;
payloadCfg[6] = key >> 8 * 2;
payloadCfg[7] = key >> 8 * 3;

//Load user's value
payloadCfg[8] = value; //Value

//All done
return (true);
}

//Add another keyID and value to an existing UBX-CFG-VALSET ubxPacket
//This function takes a full 32-bit key and 32-bit value
uint8_t SFE_UBLOX_GPS::addCfgValset32(uint32_t key, uint32_t value)
{
//Load key into outgoing payload
payloadCfg[packetCfg.len + 0] = key >> 8 * 0; //Key LSB
payloadCfg[packetCfg.len + 1] = key >> 8 * 1;
payloadCfg[packetCfg.len + 2] = key >> 8 * 2;
payloadCfg[packetCfg.len + 3] = key >> 8 * 3;

//Load user's value
payloadCfg[packetCfg.len + 4] = value >> 8 * 0; //Value LSB
payloadCfg[packetCfg.len + 5] = value >> 8 * 1;
payloadCfg[packetCfg.len + 6] = value >> 8 * 2;
payloadCfg[packetCfg.len + 7] = value >> 8 * 3;

//Update packet length: 4 byte key ID, 4 bytes of value
packetCfg.len = packetCfg.len + 4 + 4;

//All done
return (true);
}

//Add another keyID and value to an existing UBX-CFG-VALSET ubxPacket
//This function takes a full 32-bit key and 16-bit value
uint8_t SFE_UBLOX_GPS::addCfgValset16(uint32_t key, uint16_t value)
{
//Load key into outgoing payload
payloadCfg[packetCfg.len + 0] = key >> 8 * 0; //Key LSB
payloadCfg[packetCfg.len + 1] = key >> 8 * 1;
payloadCfg[packetCfg.len + 2] = key >> 8 * 2;
payloadCfg[packetCfg.len + 3] = key >> 8 * 3;

//Load user's value
payloadCfg[packetCfg.len + 4] = value >> 8 * 0; //Value LSB
payloadCfg[packetCfg.len + 5] = value >> 8 * 1;

//Update packet length: 4 byte key ID, 2 bytes of value
packetCfg.len = packetCfg.len + 4 + 2;

//All done
return (true);
}

//Add another keyID and value to an existing UBX-CFG-VALSET ubxPacket
//This function takes a full 32-bit key and 8-bit value
uint8_t SFE_UBLOX_GPS::addCfgValset8(uint32_t key, uint8_t value)
{
//Load key into outgoing payload
payloadCfg[packetCfg.len + 0] = key >> 8 * 0; //Key LSB
payloadCfg[packetCfg.len + 1] = key >> 8 * 1;
payloadCfg[packetCfg.len + 2] = key >> 8 * 2;
payloadCfg[packetCfg.len + 3] = key >> 8 * 3;

//Load user's value
payloadCfg[packetCfg.len + 4] = value; //Value

//Update packet length: 4 byte key ID, 1 byte value
packetCfg.len = packetCfg.len + 4 + 1;

//All done
return (true);
}

//Add a final keyID and value to an existing UBX-CFG-VALSET ubxPacket and send it
//This function takes a full 32-bit key and 32-bit value
uint8_t SFE_UBLOX_GPS::sendCfgValset32(uint32_t key, uint32_t value, uint16_t maxWait)
{
//Load keyID and value into outgoing payload
addCfgValset32(key, value);

//Send VALSET command with this key and value
if (sendCommand(packetCfg, maxWait) == false)
return (false); //If command send fails then bail

//All done
return (true);
}

//Add a final keyID and value to an existing UBX-CFG-VALSET ubxPacket and send it
//This function takes a full 32-bit key and 16-bit value
uint8_t SFE_UBLOX_GPS::sendCfgValset16(uint32_t key, uint16_t value, uint16_t maxWait)
{
//Load keyID and value into outgoing payload
addCfgValset16(key, value);

//Send VALSET command with this key and value
if (sendCommand(packetCfg, maxWait) == false)
return (false); //If command send fails then bail

//All done
return (true);
}

//Add a final keyID and value to an existing UBX-CFG-VALSET ubxPacket and send it
//This function takes a full 32-bit key and 8-bit value
uint8_t SFE_UBLOX_GPS::sendCfgValset8(uint32_t key, uint8_t value, uint16_t maxWait)
{
//Load keyID and value into outgoing payload
addCfgValset8(key, value);

//Send VALSET command with this key and value
if (sendCommand(packetCfg, maxWait) == false)
return (false); //If command send fails then bail

//All done
return (true);
}

//Get the current TimeMode3 settings - these contain survey in statuses
boolean SFE_UBLOX_GPS::getSurveyMode(uint16_t maxWait)
{
Expand Down
Loading