AssetTrackerRK
Public Member Functions
UbloxCommand< PAYLOAD_SIZE > Class Template Reference

Class to hold a command to send or a command to decode. More...

#include <UbloxGPS.h>

Inheritance diagram for UbloxCommand< PAYLOAD_SIZE >:
UbloxCommandBase

Public Member Functions

 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...
 

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.
 
- 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.
 

Detailed Description

template<size_t PAYLOAD_SIZE>
class UbloxCommand< PAYLOAD_SIZE >

Class to hold a command to send or a command to decode.

It's a templated to specify the size of the buffer. The value is the size of the payload; the actual buffer will be HEADER_PLUS_CRC_LEN more.

Constructor & Destructor Documentation

◆ UbloxCommand()

template<size_t PAYLOAD_SIZE>
UbloxCommand< PAYLOAD_SIZE >::UbloxCommand ( )
inlineexplicit

Constructs a command buffer of BUFFER_SIZE bytes.

Must be a minimum of HEADER_PLUS_CRC_LEN bytes.


The documentation for this class was generated from the following file: