Skip to content

Version 3.1.9 #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 3, 2025
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
/*
Configuring the GNSS to automatically send SEC SIG reports over I2C and display them using a callback
By: Paul Clark
SparkFun Electronics
Date: April 3rd, 2025
License: MIT. See license file for more information.

This example shows how to configure the u-blox GNSS to send SEC SIG reports automatically
and access the data via a callback. No more polling!

Feel like supporting open source hardware?
Buy a board from SparkFun!
ZED-F9P RTK2: https://www.sparkfun.com/products/15136

Hardware Connections:
Plug a Qwiic cable into the GPS and a BlackBoard
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
Open the serial monitor at 115200 baud to see the output
*/

#include <Wire.h> //Needed for I2C to GPS

#include <SparkFun_u-blox_GNSS_v3.h> //http://librarymanager/All#SparkFun_u-blox_GNSS_v3
SFE_UBLOX_GNSS myGNSS;

// Callback: newSECSIG will be called when new SEC SIG data arrives
// See u-blox_structs.h for the full definition of UBX_SEC_SIG_data_t
// _____ You can use any name you like for the callback. Use the same name when you call setAutoSECSIGcallback
// / _____ This _must_ be UBX_SEC_SIG_data_t
// | / _____ You can use any name you like for the struct
// | | /
// | | |
void newSECSIG(UBX_SEC_SIG_data_t *ubxDataStruct)
{
Serial.println();

Serial.print(F("New SEC SIG data received. It contains version "));
Serial.print(ubxDataStruct->version);
Serial.println(F(" data."));

if (ubxDataStruct->version == 1)
{
Serial.print(F("Jamming detection is "));
bool jamDetEnabled = (bool)ubxDataStruct->versions.version1.jamFlags.bits.jamDetEnabled;
Serial.println(jamDetEnabled ? "enabled" : "disabled");
if (jamDetEnabled)
{
Serial.print(F("Jamming state: "));
switch (ubxDataStruct->versions.version1.jamFlags.bits.jammingState)
{
case 1:
Serial.println(F("no jamming indicated"));
break;
case 2:
Serial.println(F("warning (jamming indicated but fix OK)"));
break;
case 3:
Serial.println(F("critical (jamming indicated and no fix)"));
break;
case 0:
default:
Serial.println(F("unknown"));
break;
}
}
Serial.print(F("Spoofing detection is "));
bool spfDetEnabled = (bool)ubxDataStruct->versions.version1.spfFlags.bits.spfDetEnabled;
Serial.println(spfDetEnabled ? "enabled" : "disabled");
if (spfDetEnabled)
{
Serial.print(F("Spoofing state: "));
switch (ubxDataStruct->versions.version1.spfFlags.bits.spoofingState)
{
case 1:
Serial.println(F("no spoofing indicated"));
break;
case 2:
Serial.println(F("spoofing indicated"));
break;
case 3:
Serial.println(F("spoofing affirmed"));
break;
case 0:
default:
Serial.println(F("unknown"));
break;
}
}
}

else if (ubxDataStruct->version == 2)
{
Serial.print(F("Jamming detection is "));
bool jamDetEnabled = (bool)ubxDataStruct->versions.version2.sigSecFlags.bits.jamDetEnabled;
Serial.println(jamDetEnabled ? "enabled" : "disabled");
if (jamDetEnabled)
{
Serial.print(F("Jamming state: "));
switch (ubxDataStruct->versions.version2.sigSecFlags.bits.jamState)
{
case 1:
Serial.println(F("no jamming indicated"));
break;
case 2:
Serial.println(F("warning (jamming indicated)"));
break;
case 0:
default:
Serial.println(F("unknown"));
break;
}
}
Serial.print(F("Spoofing detection is "));
bool spfDetEnabled = (bool)ubxDataStruct->versions.version2.sigSecFlags.bits.spfDetEnabled;
Serial.println(spfDetEnabled ? "enabled" : "disabled");
if (spfDetEnabled)
{
Serial.print(F("Spoofing state: "));
switch (ubxDataStruct->versions.version2.sigSecFlags.bits.spfState)
{
case 1:
Serial.println(F("no spoofing indicated"));
break;
case 2:
Serial.println(F("spoofing indicated"));
break;
case 3:
Serial.println(F("spoofing affirmed"));
break;
case 0:
default:
Serial.println(F("unknown"));
break;
}
}
Serial.print(F("Number of jamming center frequencies: "));
uint8_t jamNumCentFreqs = ubxDataStruct->versions.version2.jamNumCentFreqs;
Serial.println(jamNumCentFreqs);
if (jamNumCentFreqs > 0)
{
for (uint8_t i = 0; i < jamNumCentFreqs; i++)
{
Serial.print(F("Center frequency: "));
Serial.print(ubxDataStruct->versions.version2.jamStateCentFreq[i].bits.centFreq);
Serial.print(F(" kHz "));
if (ubxDataStruct->versions.version2.jamStateCentFreq[i].bits.jammed)
Serial.print("- jammed");
Serial.println();
}
}
}
}

void setup()
{
Serial.begin(115200);
while (!Serial); //Wait for user to open terminal
Serial.println("SparkFun u-blox Example");

Wire.begin();

//myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
//myGNSS.enableDebugging(Serial, true); // Uncomment this line to enable only the major debug messages on Serial

while (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
{
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring."));
}

myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only. Stop the NMEA messages
myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR

// Just to prove we can, poll the SEC SIG data manually
Serial.println("Polling SEC SIG data:");
UBX_SEC_SIG_data_t secSig;
if (myGNSS.getSECSIG(&secSig))
newSECSIG(&secSig); // Call the callback manually to print the data
else
Serial.println("getSECSIG failed!");

// Now enable automatic (periodic) SEC SIG messages with callback to newSECSIG
myGNSS.setAutoSECSIGcallbackPtr(&newSECSIG);
}

void loop()
{
myGNSS.checkUblox(); // Check for the arrival of new data and process it.
myGNSS.checkCallbacks(); // Check if any callbacks are waiting to be processed.

Serial.print(".");
delay(50);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
0x101100d7
0x10170001
0x10170002
0x10220001
0x10220002
0x10220003
0x10220004
0x10240012
0x10240020
0x10240030
Expand Down Expand Up @@ -120,10 +124,9 @@
0x10a30033
0x10a30034
0x10a30035
0x10c70001
0x10c70002
0x10f60009
0x10f60051
0x10f6005d
0x2005000c
0x20050023
0x20050030
Expand All @@ -134,6 +137,7 @@
0x20060016
0x2006001e
0x2006001f
0x20060030
0x2007000b
0x20090009
0x20110011
Expand All @@ -150,6 +154,11 @@
0x20140011
0x20210003
0x20210004
0x20220005
0x20220021
0x20220022
0x20220031
0x20220032
0x20240011
0x20240013
0x20240014
Expand Down Expand Up @@ -262,6 +271,11 @@
0x2091006c
0x2091006d
0x2091006e
0x2091007e
0x2091007f
0x20910080
0x20910081
0x20910082
0x20910083
0x20910084
0x20910085
Expand Down Expand Up @@ -347,6 +361,11 @@
0x209100e4
0x209100e5
0x209100e6
0x209100e7
0x209100e8
0x209100e9
0x209100ea
0x209100eb
0x209100ec
0x209100ed
0x209100ee
Expand Down Expand Up @@ -718,17 +737,25 @@
0x20a30063
0x20a30064
0x20a70001
0x20c70003
0x30050001
0x30060007
0x3006000a
0x3006000b
0x30060017
0x30060018
0x30060020
0x30060021
0x30060022
0x3006002e
0x3006002f
0x3007000a
0x3007000e
0x30070012
0x30070013
0x30070014
0x30080002
0x30080003
0x30080004
0x30090008
0x30110017
0x301100b1
Expand All @@ -738,13 +765,16 @@
0x301100b5
0x30210001
0x30210002
0x30250016
0x3025003b
0x30360008
0x30370008
0x3065000a
0x3065000b
0x3065000c
0x30930033
0x30a20004
0x30a3003c
0x30f6000a
0x30f6000b
0x40050002
Expand Down Expand Up @@ -798,7 +828,3 @@
0x50650016
0x50650017
0x50650018
0x50c70004
0x50c70005
0x50c70006
0x50c70007
11 changes: 11 additions & 0 deletions keys/u-blox_config_keys_sorted.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@
0x20060016
0x2006001e
0x2006001f
0x20060030
0x2007000b
0x20090009
0x20110011
Expand Down Expand Up @@ -954,10 +955,19 @@
0x3006000b
0x30060017
0x30060018
0x30060020
0x30060021
0x30060022
0x3006002e
0x3006002f
0x3007000a
0x3007000e
0x30070012
0x30070013
0x30070014
0x30080002
0x30080003
0x30080004
0x30090001
0x30090008
0x30110017
Expand All @@ -970,6 +980,7 @@
0x30210001
0x30210002
0x30230002
0x30250016
0x3025003b
0x30360008
0x30370008
Expand Down
8 changes: 8 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,14 @@ assumeAutoHNRPVT KEYWORD2
flushHNRPVT KEYWORD2
logHNRPVT KEYWORD2

getSECSIG KEYWORD2
setAutoSECSIG KEYWORD2
setAutoSECSIGrate KEYWORD2
setAutoSECSIGcallbackPtr KEYWORD2
assumeAutoSECSIG KEYWORD2
flushSECSIG KEYWORD2
logSECSIG KEYWORD2

setNavigationFrequency KEYWORD2
getNavigationFrequency KEYWORD2
setMeasurementRate KEYWORD2
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SparkFun u-blox GNSS v3
version=3.1.8
version=3.1.9
author=SparkFun Electronics <[email protected]>
maintainer=SparkFun Electronics <sparkfun.com>
sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules<br/><br/>
Expand Down
10 changes: 6 additions & 4 deletions src/u-blox_Class_and_ID.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ const uint8_t UBX_RXM_SPARTNKEY = 0x36; // Poll/transfer dynamic SPARTN keys

// Class: SEC
// The following are used to configure the SEC UBX messages (security feature messages). Descriptions from UBX messages overview (ZED_F9P Interface Description Document page 36)
const uint8_t UBX_SEC_SIG = 0x09; // Signal security information
const uint8_t UBX_SEC_UNIQID = 0x03; // Unique chip ID

// Class: TIM
Expand Down Expand Up @@ -402,10 +403,11 @@ enum dynModel // Possible values for the dynamic platform model, which provide m
DYN_MODEL_AIRBORNE1g, // Airborne <1g acceleration. Used for applications with a higher dynamic range and greater vertical acceleration than a passenger car. No 2D position fixes supported.
DYN_MODEL_AIRBORNE2g, // Airborne <2g acceleration. Recommended for typical airborne environments. No 2D position fixes supported.
DYN_MODEL_AIRBORNE4g, // Airborne <4g acceleration. Only recommended for extremely dynamic environments. No 2D position fixes supported.
DYN_MODEL_WRIST, // Not supported in protocol versions less than 18. Only recommended for wrist worn applications. Receiver will filter out arm motion.
DYN_MODEL_BIKE, // Supported in protocol versions 19.2. (not available in all products)
DYN_MODEL_MOWER, // Added in HPS 1.21 (not available in all products)
DYN_MODEL_ESCOOTER, // Added in HPS 1.21 (not available in all products)
DYN_MODEL_WRIST, // Wrist-worn watch. Not supported in protocol versions less than 18. Only recommended for wrist worn applications. Receiver will filter out arm motion.
DYN_MODEL_BIKE, // Motorbike. Supported in protocol versions 19.2. (not available in all products)
DYN_MODEL_MOWER, // Robotic lawn mower. Added in HPS 1.21 (not available in all products)
DYN_MODEL_ESCOOTER, // E-scooter. Added in HPS 1.21 (not available in all products)
DYN_MODEL_RAIL, // Rail vehicles (trains, trams). Added in HPS 1.40 (not available in all products)
DYN_MODEL_UNKNOWN = 255 // getDynamicModel will return 255 if sendCommand fails
};

Expand Down
Loading