AssetTrackerRK
|
Class for implementing u-blox GPS support. More...
#include <UbloxGPS.h>
Public Types | |
enum | StartType { StartType::HOT = 0, StartType::WARM = 1, StartType::COLD = 0xFFFF } |
Constants for whether to do a hot, warm, or cold restart using resetReceiver. More... | |
enum | ResetMode { ResetMode::HARDWARE_RESET_IMMEDIATE = 0x00, ResetMode::CONTROLLED_SOFTWARE_RESET = 0x01, ResetMode::CONTROLLED_SOFTWARE_RESET_GNSS_ONLY = 0x02, ResetMode::HARDWARE_RESET_AFTER_SHUTDOWN = 0x04, ResetMode::CONTROLLED_GNSS_STOP = 0x08, ResetMode::CONTROLLED_GNSS_START = 0x09 } |
Constants for how to do the reset when using resetReceiver. More... | |
Public Member Functions | |
Ublox () | |
Constructor. You typically instantiate one of these as a global variable in your main application file. | |
virtual | ~Ublox () |
Destructor. As it is typically a global variable, you don't generally delete this. | |
void | setup () |
Call from main application setup. Required! | |
void | loop () |
Call from main application loop. Required! | |
void | getValue (uint8_t msgClass, uint8_t msgId, std::function< void(UbloxCommandBase *)> callback) |
Get a command value from the u-blox modem. More... | |
void | sendCommand (UbloxCommandBase *cmd) |
Send a command top the GPS. More... | |
void | setAntenna (bool external) |
Sets the antenna to external or internal on the AssetTracker V2. | |
void | enableAckAiding () |
This function does not appear to work, but if it did, it would enable ACKs for aiding data. | |
void | resetReceiver (StartType startType, ResetMode resetMode=ResetMode::CONTROLLED_SOFTWARE_RESET) |
Resets the GPS. Note: This often does not work. More... | |
Public Member Functions inherited from UbloxCommand< 100 > | |
UbloxCommand () | |
Constructs a command buffer of BUFFER_SIZE bytes. More... | |
Public Member Functions inherited from UbloxCommandBase | |
UbloxCommandBase (uint8_t *buffer, size_t bufferSize) | |
Construct a UbloxCommandBase object. Normally you'd use UbloxCommand instead, which handles the buffer management for you. More... | |
virtual | ~UbloxCommandBase () |
Destructor. | |
bool | decode (char ch) |
Decode a single character. More... | |
void | discardToNextSync1 () |
Used internally to discard invalid data. You probably won't need to call this. | |
void | updateChecksum () |
When preparing a command to send, updates the checksum, sync, and length bytes. More... | |
void | calculateChecksum (uint8_t &ckA, uint8_t &ckB) const |
Calculates the checksum based on the data in the buffer. More... | |
void | addHandler (UbloxMessageHandler *handler) |
Add a message handler. More... | |
void | removeHandler (UbloxMessageHandler *handler) |
Remove a message handler. More... | |
void | callHandlers () |
Used internally to call all of the message handlers that match this class and id. | |
uint8_t | getMsgClass () const |
Gets the message class of the current command. More... | |
uint8_t | getMsgId () const |
Gets the message ID of the current command. More... | |
void | setClassId (uint8_t msgClass, uint8_t msgId) |
When sending a message, sets the message class and ID. More... | |
size_t | getPayloadLen () const |
Gets the payload length, the number of bytes available from getData() | |
const uint8_t * | getData () const |
Get a const pointer to the data payload. More... | |
bool | getData (size_t offset, void *data, size_t dataLen) const |
Copies data from the buffer. More... | |
bool | setData (size_t offset, const void *data, size_t dataLen) |
Set data in the buffer. More... | |
bool | appendData (const void *data, size_t dataLen) |
Appends data into the buffer at the current payloadLen. More... | |
bool | fillData (uint8_t value, size_t dataLen) |
Works like appendData(), but fill with a value instead. More... | |
uint8_t | getU1 (size_t offset) const |
Get a uint8_t value at offset. More... | |
bool | setU1 (size_t offset, uint8_t value) |
Set a uint8_t value at offset in the payload. More... | |
bool | appendU1 (uint8_t value) |
Append a uint8_t value to the current end of the payload. More... | |
int8_t | getI1 (size_t offset) const |
Get a int8_t value (signed) at offset. More... | |
bool | setI1 (size_t offset, int8_t value) |
Set a int8_t value at offset in the payload. More... | |
bool | appendI1 (int8_t value) |
Append a int8_t value to the current end of the payload. More... | |
uint16_t | getU2 (size_t offset) const |
Get a uint16_t value (little endian) at offset. More... | |
bool | setU2 (size_t offset, uint16_t value) |
Set a uint16_t value at offset in the payload. More... | |
bool | appendU2 (uint16_t value) |
Append a uint16_t value to the current end of the payload. More... | |
int16_t | getI2 (size_t offset) const |
Get a int16_t value (little endian, signed) at offset. More... | |
bool | setI2 (size_t offset, int16_t value) |
Set an int16_t value at offset in the payload. More... | |
bool | appendI2 (int16_t value) |
Append an int16_t value to the current end of the payload. More... | |
uint32_t | getU4 (size_t offset) const |
Get a uint32_t value (little endian, 4 bytes) at offset. More... | |
bool | setU4 (size_t offset, uint32_t value) |
Set a uint32_t value at offset in the payload. More... | |
bool | appendU4 (uint32_t value) |
Append a uint32_t value to the current end of the payload. More... | |
int32_t | getI4 (size_t offset) const |
Get a int32_t value (little endian, 4 bytes, signed) at offset. More... | |
bool | setI4 (size_t offset, int32_t value) |
Set an int16_t value at offset in the payload. More... | |
bool | appendI4 (int32_t value) |
Append a int32_t value to the current end of the payload. More... | |
float | getR4 (size_t offset) const |
Get a float value (4 bytes) at offset. More... | |
bool | setR4 (size_t offset, float value) |
Set an float (4 byte floating point) value at offset in the payload. More... | |
bool | appendR4 (float value) |
Append a float (4 byte floating point) value to the current end of the payload. More... | |
double | getR8 (size_t offset) const |
Get a double value (8 bytes) at offset. More... | |
bool | setR8 (size_t offset, double value) |
Set an double (8 byte floating point) value at offset in the payload. More... | |
bool | appendR8 (double value) |
Append a double (8 byte floating point) value to the current end of the payload. More... | |
const uint8_t * | getBuffer () const |
Get a pointer to the buffer, typically to send data. More... | |
size_t | getSendLength () const |
Get the length of the data, typically to send it. More... | |
Static Public Member Functions | |
static Ublox * | getInstance () |
Get the singleton instance of this class. | |
Static Protected Attributes | |
static Ublox * | instance = 0 |
Singleton instance of this class. | |
Static Protected Attributes inherited from UbloxCommandBase | |
static const uint8_t | SYNC_1 = 0xb5 |
value of the first sync byte at buffer[0] | |
static const uint8_t | SYNC_2 = 0x62 |
value of the second sync byte at buffer[1] | |
static const size_t | CLASS_OFFSET = 2 |
offset in buffer where the message class is stored | |
static const size_t | ID_OFFSET = 3 |
offset in buffer where the message ID is stored | |
static const size_t | DATA_OFFSET = 6 |
offset in buffer where data begins (after sync, class, id, and length) | |
static const size_t | HEADER_PLUS_CRC_LEN = 8 |
size of the header data (6 bytes) plus CRC (2 bytes). Minimum size of a valid packet with 0 bytes of payload data. | |
static const size_t | CRC_START_OFFSET = 2 |
offset in buffer where the CRC calculation starts (does not include sync bytes) | |
static const size_t | CRC_HEADER_LEN = 4 |
number of header bytes included in the CRC. The total CRC length is this plus payloadLen. | |
Additional Inherited Members | |
Protected Types inherited from UbloxCommandBase | |
enum | State { State::LOOKING_FOR_START, State::LOOKING_FOR_LENGTH, State::LOOKING_FOR_MESSAGE } |
u-blox parsing state constants More... | |
Protected Attributes inherited from UbloxCommandBase | |
uint8_t * | buffer |
Buffer to hold data (received data or data for composing a packet to send) | |
size_t | bufferSize |
Size of the buffer. Maximum payload is bufferSize - HEADER_PLUS_CRC_LEN. | |
size_t | bufferOffset = 0 |
Current offset being written to in buffer when using encode() | |
size_t | payloadLen = 0 |
Length of the data payload (0 = no data). This does not include the header or CRC. | |
State | state = State::LOOKING_FOR_START |
Current parsing state. | |
std::vector< UbloxMessageHandler * > | handlers |
Vector of message handler objects, contains filter and callback function to handle incoming messages. | |
Class for implementing u-blox GPS support.
You typically instantiate one of these as a global variable in your main application code if you want to use the u-blox specific features. It is optional.
If you are using it, be sure to call the setup() and loop() methods from your application setup() and loop()!
|
strong |
Constants for how to do the reset when using resetReceiver.
|
strong |
void Ublox::getValue | ( | uint8_t | msgClass, |
uint8_t | msgId, | ||
std::function< void(UbloxCommandBase *)> | callback | ||
) |
Get a command value from the u-blox modem.
msgClass | The class of the data to get |
msgId | The ID of the data to get |
callback | The function to call with the value |
Get operations typically work by sending a command with a 0 byte payload. When the message is received (with the values), the callback is called
The callback has the prototype:
void callback(UbloxCommandBase *cmd);
The cmd parameter allows the data to be examined.
Note that when the AssetTracker is running in threaded mode, this will be called from the GPS reading thread so you should not do operations that block or are lengthy from the callback as it will affect GPS performance.
void Ublox::resetReceiver | ( | StartType | startType, |
ResetMode | resetMode = ResetMode::CONTROLLED_SOFTWARE_RESET |
||
) |
Resets the GPS. Note: This often does not work.
startType | whether to to a HOT, WARM, or COLD start |
resetMode | how to do the reset when using resetReceiver (default: CONTROLLED_SOFTWARE_RESET) |
In theory you could use this to cold start the GPS for more easily testing things like AssistNow but in reality, cold booting seems to have no effect.
void Ublox::sendCommand | ( | UbloxCommandBase * | cmd | ) |
Send a command top the GPS.
cmd | The command object to send |
This class has some pre-made commands like setAntenna() but the sendCommand() can be used to send any arbitrary command.