You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+82Lines changed: 82 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,7 @@ This library is the new and improved version of the very popular SparkFun u-blox
37
37
* The hardware interface has been abstracted:
38
38
* All hardware communication is performed through ```class GNSSDeviceBus```
39
39
* This makes it _much_ easier to re-use this library on other hardware platforms. Only ```sfe_bus.h``` and ```sfe_bus.cpp``` need to be updated
40
+
* Template methods simplify multiple-VALGET and multiple-VALSET configuration
40
41
41
42
## Migrating to v3
42
43
@@ -133,6 +134,87 @@ key &= ~UBX_CFG_SIZE_MASK; // Mask off the size identifer bits
133
134
134
135
The get and set template methods are based on an idea by Michael Ammann. Thank you @mazgch
135
136
137
+
#### Multiple-VALGET
138
+
139
+
Start by creating a custom ```ubxPacket``` :
140
+
141
+
```
142
+
const uint16_t maxPayloadSize = 100; // Make this large enough to hold all keys and values
143
+
uint8_t customPayload[maxPayloadSize]; // This array holds the payload data bytes
144
+
ubxPacket customCfg = {0, 0, 0, 0, 0, customPayload, 0, 0, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED}; // Create and initialise the custom packet
145
+
myGNSS.newCfgValget(&customCfg, maxPayloadSize, VAL_LAYER_RAM); // Create a new VALGET construct inside the custom packet
146
+
```
147
+
148
+
Add the Keys you want to get using ```addCfgValget``` :
149
+
150
+
```
151
+
myGNSS.addCfgValget(&customCfg, UBLOX_CFG_I2C_ADDRESS); // Get the I2C address (see u-blox_config_keys.h for details)
152
+
myGNSS.addCfgValget(&customCfg, UBLOX_CFG_I2COUTPROT_NMEA); // Get the flag indicating is NMEA should be output on I2C
153
+
myGNSS.addCfgValget(&customCfg, UBLOX_CFG_UART1_BAUDRATE); // Get the UART1 baud rate
154
+
```
155
+
156
+
Perform the VALGET by calling ```sendCfgValget(&customCfg)```. The method returns true if the VALGET was successful.
157
+
158
+
Extract the Key Values using the template method ```extractConfigValueByKey```.
159
+
160
+
**Note:** you do still need to know the data type to extract the data correctly.
161
+
162
+
Consult the u-blox Interface Description or [u-blox_config_keys.h](./src/u-blox_config_keys.h) to see the data type (size) for each Key ID.
163
+
* L : bool
164
+
* U1/E1/X1 : uint8_t
165
+
* I1 : int8_t
166
+
* U2/E2/X2 : uint16_t
167
+
* I2 : int16_t
168
+
* U4/E4/X4 : uint32_t
169
+
* I4 : int32_t
170
+
* U8/X8 : uint64_t
171
+
* I8 : int64_t
172
+
* R4 : float (32-bit)
173
+
* R8 : double (64-bit)
174
+
175
+
Pass a pointer to, or the address of, your variable plus its size (in bytes) to ```extractConfigValueByKey``` to extract the value.
176
+
The method returns true if the extraction was successful.
177
+
178
+
```
179
+
uint32_t baud; // U4
180
+
myGNSS.extractConfigValueByKey(&customCfg, UBLOX_CFG_UART1_BAUDRATE, &baud, sizeof(baud)); // Get the baud rate - using the key and the address of and sizeof baud
181
+
```
182
+
183
+
Please see [VALGET_and_VALSET/Example6](./examples/VALGET_and_VALSET/Example6_multiSetVal_and_GetVal_Templates/) for more details.
184
+
185
+
#### Multiple-VALSET
186
+
187
+
In v2 of the library, you had to specify the key value size when calling ```addCfgValset```. v3 uses a template method to deduce the size automatically
188
+
using the size encoded into the key itself.
189
+
190
+
Start by creating a new VALSET:
191
+
192
+
```
193
+
myGNSS.newCfgValset(VAL_LAYER_RAM); // Create a new VALSET construct (internally in packetCfg)
194
+
```
195
+
196
+
Add each key and value that you wish to set. The type / size is deduced automatically if required. The method returns true if the add is successful.
0 commit comments