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

Commit e6a0ae6

Browse files
authored
Merge pull request #98 from sparkfun/getDynamicModel
Added getDynamicModel
2 parents f74d097 + 30620cb commit e6a0ae6

File tree

4 files changed

+38
-7
lines changed

4 files changed

+38
-7
lines changed

examples/Example19_DynamicModel/Example19_DynamicModel.ino

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
Set Dynamic Model
33
By: Paul Clark (PaulZC)
4-
Date: March 9th, 2020
5-
4+
Date: April 22nd, 2020
5+
66
Based extensively on Example3_GetPosition
77
By: Nathan Seidle
88
SparkFun Electronics
@@ -18,7 +18,7 @@
1818
SEA, AIRBORNE1g, AIRBORNE2g, AIRBORNE4g, WRIST, BIKE
1919
2020
Note: Long/lat are large numbers because they are * 10^7. To convert lat/long
21-
to something google maps understands simply divide the numbers by 10,000,000. We
21+
to something google maps understands simply divide the numbers by 10,000,000. We
2222
do this so that we don't have to use floating point numbers.
2323
2424
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
@@ -47,18 +47,19 @@ void setup()
4747
Serial.begin(115200);
4848
while (!Serial)
4949
; //Wait for user to open terminal
50-
Serial.println("SparkFun Ublox Example");
50+
Serial.println(F("SparkFun Ublox Example"));
5151

5252
Wire.begin();
5353

54+
//myGPS.enableDebugging(); // Uncomment this line to enable debug messages
55+
5456
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
5557
{
5658
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
5759
while (1)
5860
;
5961
}
6062

61-
//myGPS.enableDebugging(); // Uncomment this line to enable debug messages
6263
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
6364

6465
// If we are going to change the dynamic platform model, let's do it here.
@@ -67,11 +68,23 @@ void setup()
6768

6869
if (myGPS.setDynamicModel(DYN_MODEL_PORTABLE) == false) // Set the dynamic model to PORTABLE
6970
{
70-
Serial.println("***!!! Warning: setDynamicModel failed !!!***");
71+
Serial.println(F("***!!! Warning: setDynamicModel failed !!!***"));
72+
}
73+
else
74+
{
75+
Serial.println(F("Dynamic platform model changed successfully!"));
76+
}
77+
78+
// Let's read the new dynamic model to see if it worked
79+
uint8_t newDynamicModel = myGPS.getDynamicModel();
80+
if (newDynamicModel == 255)
81+
{
82+
Serial.println(F("***!!! Warning: getDynamicModel failed !!!***"));
7183
}
7284
else
7385
{
74-
Serial.println("Dynamic platform model changed successfully!");
86+
Serial.print(F("The new dynamic model is: "));
87+
Serial.println(newDynamicModel);
7588
}
7689

7790
//myGPS.saveConfigSelective(VAL_CFG_SUBSEC_NAVCONF); //Uncomment this line to save only the NAV settings to flash and BBR

keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ clearGeofences KEYWORD2
134134
getGeofenceState KEYWORD2
135135

136136
setDynamicModel KEYWORD2
137+
getDynamicModel KEYWORD2
137138
powerSaveMode KEYWORD2
138139

139140
configureMessage KEYWORD2

src/SparkFun_Ublox_Arduino_Library.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2537,6 +2537,22 @@ boolean SFE_UBLOX_GPS::setDynamicModel(dynModel newDynamicModel, uint16_t maxWai
25372537
return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
25382538
}
25392539

2540+
//Get the dynamic platform model using UBX-CFG-NAV5
2541+
//Returns 255 if the sendCommand fails
2542+
uint8_t SFE_UBLOX_GPS::getDynamicModel(uint16_t maxWait)
2543+
{
2544+
packetCfg.cls = UBX_CLASS_CFG;
2545+
packetCfg.id = UBX_CFG_NAV5;
2546+
packetCfg.len = 0;
2547+
packetCfg.startingSpot = 0;
2548+
2549+
//Ask module for the current navigation model settings. Loads into payloadCfg.
2550+
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
2551+
return (255);
2552+
2553+
return (payloadCfg[2]); // Return the dynamic model
2554+
}
2555+
25402556
//Given a spot in the payload array, extract four bytes and build a long
25412557
uint32_t SFE_UBLOX_GPS::extractLong(uint8_t spotToStart)
25422558
{

src/SparkFun_Ublox_Arduino_Library.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ class SFE_UBLOX_GPS
617617

618618
//Change the dynamic platform model using UBX-CFG-NAV5
619619
boolean setDynamicModel(dynModel newDynamicModel = DYN_MODEL_PORTABLE, uint16_t maxWait = 1100);
620+
uint8_t getDynamicModel(uint16_t maxWait = 1100); // Get the dynamic model - returns 255 if the sendCommand fails
620621

621622
//Survey-in specific controls
622623
struct svinStructure

0 commit comments

Comments
 (0)