Snapdragon® Telematics Application Framework (TelAF) Interface Specification
le_pack.h File Reference

Go to the source code of this file.

Macros

#define LE_PACK_PACK_SIMPLE_VALUE(value)
 
#define LE_PACK_PACKARRAY(bufferPtr, arrayPtr, arrayCount, arrayMaxCount, packFunc, resultPtr)
 
#define LE_PACK_PACKSTRUCTARRAY(bufferPtr, arrayPtr, arrayCount, arrayMaxCount, packFunc, resultPtr)
 
#define LE_PACK_UNPACK_SIMPLE_VALUE(valuePtr)
 
#define LE_PACK_UNPACKARRAY(bufferPtr, arrayPtr, arrayCountPtr, arrayMaxCount, unpackFunc, resultPtr)
 
#define LE_PACK_UNPACKSTRUCTARRAY(bufferPtr, arrayPtr, arrayCountPtr, arrayMaxCount, unpackFunc, resultPtr)
 

Functions

LE_DECLARE_INLINE bool le_pack_PackUint8 (uint8_t **bufferPtr, uint8_t value)
 
LE_DECLARE_INLINE bool le_pack_PackUint16 (uint8_t **bufferPtr, uint16_t value)
 
LE_DECLARE_INLINE bool le_pack_PackUint32 (uint8_t **bufferPtr, uint32_t value)
 
LE_DECLARE_INLINE bool le_pack_PackUint64 (uint8_t **bufferPtr, uint64_t value)
 
LE_DECLARE_INLINE bool le_pack_PackInt8 (uint8_t **bufferPtr, int8_t value)
 
LE_DECLARE_INLINE bool le_pack_PackInt16 (uint8_t **bufferPtr, int16_t value)
 
LE_DECLARE_INLINE bool le_pack_PackInt32 (uint8_t **bufferPtr, int32_t value)
 
LE_DECLARE_INLINE bool le_pack_PackInt64 (uint8_t **bufferPtr, int64_t value)
 
LE_DECLARE_INLINE bool le_pack_PackSize (uint8_t **bufferPtr, size_t value)
 
LE_DECLARE_INLINE bool le_pack_PackBool (uint8_t **bufferPtr, bool value)
 
LE_DECLARE_INLINE bool le_pack_PackChar (uint8_t **bufferPtr, char value)
 
LE_DECLARE_INLINE bool le_pack_PackDouble (uint8_t **bufferPtr, double value)
 
LE_DECLARE_INLINE bool le_pack_PackResult (uint8_t **bufferPtr, le_result_t value)
 
LE_DECLARE_INLINE bool le_pack_PackOnOff (uint8_t **bufferPtr, le_onoff_t value)
 
LE_DECLARE_INLINE bool le_pack_PackReference (uint8_t **bufferPtr, const void *ref)
 
LE_DECLARE_INLINE bool le_pack_PackString (uint8_t **bufferPtr, const char *stringPtr, uint32_t maxStringCount)
 
LE_DECLARE_INLINE bool le_pack_PackArrayHeader (uint8_t **bufferPtr, const void *arrayPtr, size_t elementSize, size_t arrayCount, size_t arrayMaxCount)
 
LE_DECLARE_INLINE bool le_pack_UnpackUint8 (uint8_t **bufferPtr, uint8_t *valuePtr)
 
LE_DECLARE_INLINE bool le_pack_UnpackUint16 (uint8_t **bufferPtr, uint16_t *valuePtr)
 
LE_DECLARE_INLINE bool le_pack_UnpackUint32 (uint8_t **bufferPtr, uint32_t *valuePtr)
 
LE_DECLARE_INLINE bool le_pack_UnpackUint64 (uint8_t **bufferPtr, uint64_t *valuePtr)
 
LE_DECLARE_INLINE bool le_pack_UnpackInt8 (uint8_t **bufferPtr, int8_t *valuePtr)
 
LE_DECLARE_INLINE bool le_pack_UnpackInt16 (uint8_t **bufferPtr, int16_t *valuePtr)
 
LE_DECLARE_INLINE bool le_pack_UnpackInt32 (uint8_t **bufferPtr, int32_t *valuePtr)
 
LE_DECLARE_INLINE bool le_pack_UnpackInt64 (uint8_t **bufferPtr, int64_t *valuePtr)
 
LE_DECLARE_INLINE bool le_pack_UnpackSize (uint8_t **bufferPtr, size_t *valuePtr)
 
LE_DECLARE_INLINE bool le_pack_UnpackBool (uint8_t **bufferPtr, bool *valuePtr)
 
LE_DECLARE_INLINE bool le_pack_UnpackChar (uint8_t **bufferPtr, char *valuePtr)
 
LE_DECLARE_INLINE bool le_pack_UnpackDouble (uint8_t **bufferPtr, double *valuePtr)
 
LE_DECLARE_INLINE bool le_pack_UnpackResult (uint8_t **bufferPtr, le_result_t *valuePtr)
 
LE_DECLARE_INLINE bool le_pack_UnpackOnOff (uint8_t **bufferPtr, le_onoff_t *valuePtr)
 
LE_DECLARE_INLINE bool le_pack_UnpackReference (uint8_t **bufferPtr, void *refPtr)
 
LE_DECLARE_INLINE bool le_pack_UnpackString (uint8_t **bufferPtr, char *stringPtr, uint32_t bufferSize, uint32_t maxStringCount)
 
LE_DECLARE_INLINE bool le_pack_UnpackArrayHeader (uint8_t **bufferPtr, const void *arrayPtr, size_t elementSize, size_t *arrayCountPtr, size_t arrayMaxCount)
 

Macro Definition Documentation

◆ LE_PACK_PACK_SIMPLE_VALUE

#define LE_PACK_PACK_SIMPLE_VALUE (   value)
Value:
do { \
memcpy(*bufferPtr, &(value), sizeof(value)); \
*bufferPtr = *bufferPtr + sizeof(value); \
} while (0)

Pack Definitions and Types

◆ LE_PACK_PACKARRAY

#define LE_PACK_PACKARRAY (   bufferPtr,
  arrayPtr,
  arrayCount,
  arrayMaxCount,
  packFunc,
  resultPtr 
)
Value:
do { \
*(resultPtr) = le_pack_PackArrayHeader((bufferPtr), \
(arrayPtr), sizeof((arrayPtr)[0]), \
(arrayCount), (arrayMaxCount)); \
if (*(resultPtr)) \
{ \
uint32_t i; \
for (i = 0; i < (arrayCount); ++i) \
{ \
LE_ASSERT(packFunc((bufferPtr), (arrayPtr)[i])); \
} \
*(resultPtr) = true; \
} \
} while (0)
LE_DECLARE_INLINE bool le_pack_PackArrayHeader(uint8_t **bufferPtr, const void *arrayPtr, size_t elementSize, size_t arrayCount, size_t arrayMaxCount)
Definition: le_pack.h:1012
const char le_result_t * resultPtr
< [OUT] Return Code
Definition: le_comm.h:50

Pack an array into a buffer, incrementing the buffer pointer.

Note
Will assert if the resulted array exceeds the maximum size allowed.

◆ LE_PACK_PACKSTRUCTARRAY

#define LE_PACK_PACKSTRUCTARRAY (   bufferPtr,
  arrayPtr,
  arrayCount,
  arrayMaxCount,
  packFunc,
  resultPtr 
)
Value:
do { \
*(resultPtr) = le_pack_PackArrayHeader((bufferPtr), \
(arrayPtr), sizeof((arrayPtr)[0]), \
(arrayCount), (arrayMaxCount)); \
if (*(resultPtr)) \
{ \
uint32_t i; \
for (i = 0; i < (arrayCount); ++i) \
{ \
LE_ASSERT(packFunc((bufferPtr), &((arrayPtr)[i]))); \
} \
*(resultPtr) = true; \
} \
} while (0)
LE_DECLARE_INLINE bool le_pack_PackArrayHeader(uint8_t **bufferPtr, const void *arrayPtr, size_t elementSize, size_t arrayCount, size_t arrayMaxCount)
Definition: le_pack.h:1012
const char le_result_t * resultPtr
< [OUT] Return Code
Definition: le_comm.h:50

Pack an array of struct into a buffer, incrementing the buffer pointer.

Note
Will assert if the resulted array of struct exceeds the maximum size allowed.

◆ LE_PACK_UNPACK_SIMPLE_VALUE

#define LE_PACK_UNPACK_SIMPLE_VALUE (   valuePtr)
Value:
do { \
memcpy((valuePtr), *bufferPtr, sizeof(*(valuePtr))); \
*bufferPtr = (*bufferPtr) + sizeof(*(valuePtr)); \
} while (0)

◆ LE_PACK_UNPACKARRAY

#define LE_PACK_UNPACKARRAY (   bufferPtr,
  arrayPtr,
  arrayCountPtr,
  arrayMaxCount,
  unpackFunc,
  resultPtr 
)
Value:
do { \
if (!le_pack_UnpackArrayHeader((bufferPtr), \
(arrayPtr), sizeof((arrayPtr)[0]), \
(arrayCountPtr), (arrayMaxCount))) \
{ \
*(resultPtr) = false; \
} \
else \
{ \
uint32_t i; \
for (i = 0; i < *(arrayCountPtr); ++i) \
{ \
LE_ASSERT(unpackFunc((bufferPtr), &(arrayPtr)[i])); \
} \
*(resultPtr) = true; \
} \
} while (0)
const char le_result_t * resultPtr
< [OUT] Return Code
Definition: le_comm.h:50
LE_DECLARE_INLINE bool le_pack_UnpackArrayHeader(uint8_t **bufferPtr, const void *arrayPtr, size_t elementSize, size_t *arrayCountPtr, size_t arrayMaxCount)
Definition: le_pack.h:1617

Unpack an array into from buffer, incrementing the buffer pointer and decrementing the available size.

Note
Always decrements available size according to the max possible size used, not actual size used. Will assert if the resulted array exceeds the maximum size allowed.

◆ LE_PACK_UNPACKSTRUCTARRAY

#define LE_PACK_UNPACKSTRUCTARRAY (   bufferPtr,
  arrayPtr,
  arrayCountPtr,
  arrayMaxCount,
  unpackFunc,
  resultPtr 
)
Value:
LE_PACK_UNPACKARRAY((bufferPtr), (arrayPtr), (arrayCountPtr), \
(arrayMaxCount), (unpackFunc), (resultPtr))
#define LE_PACK_UNPACKARRAY(bufferPtr, arrayPtr, arrayCountPtr, arrayMaxCount, unpackFunc, resultPtr)
Definition: le_pack.h:1650
const char le_result_t * resultPtr
< [OUT] Return Code
Definition: le_comm.h:50

Unpack an array of struct from buffer. Since its logic is the same as that for unpacking an array, here it calls LE_PACK_UNPACKSTRUCTARRAY() to do the work.

Function Documentation

◆ le_pack_PackUint8()

LE_DECLARE_INLINE bool le_pack_PackUint8 ( uint8_t **  bufferPtr,
uint8_t  value 
)

Pack a uint8_t into a buffer, incrementing the buffer pointer as appropriate.

Note
By making this an inline function, gcc can often optimize out the size check if the buffer size is known at compile time.

◆ le_pack_PackUint16()

LE_DECLARE_INLINE bool le_pack_PackUint16 ( uint8_t **  bufferPtr,
uint16_t  value 
)

Pack a uint16_t into a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_PackUint32()

LE_DECLARE_INLINE bool le_pack_PackUint32 ( uint8_t **  bufferPtr,
uint32_t  value 
)

Pack a uint32_t into a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_PackUint64()

LE_DECLARE_INLINE bool le_pack_PackUint64 ( uint8_t **  bufferPtr,
uint64_t  value 
)

Pack a uint64_t into a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_PackInt8()

LE_DECLARE_INLINE bool le_pack_PackInt8 ( uint8_t **  bufferPtr,
int8_t  value 
)

Pack a int8_t into a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_PackInt16()

LE_DECLARE_INLINE bool le_pack_PackInt16 ( uint8_t **  bufferPtr,
int16_t  value 
)

Pack a int16_t into a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_PackInt32()

LE_DECLARE_INLINE bool le_pack_PackInt32 ( uint8_t **  bufferPtr,
int32_t  value 
)

Pack a int32_t into a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_PackInt64()

LE_DECLARE_INLINE bool le_pack_PackInt64 ( uint8_t **  bufferPtr,
int64_t  value 
)

Pack a int64_t into a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_PackSize()

LE_DECLARE_INLINE bool le_pack_PackSize ( uint8_t **  bufferPtr,
size_t  value 
)

Pack a size_t into a buffer, incrementing the buffer pointer as appropriate.

Note
Packed sizes are limited to 2^32-1, regardless of platform

◆ le_pack_PackBool()

LE_DECLARE_INLINE bool le_pack_PackBool ( uint8_t **  bufferPtr,
bool  value 
)

Pack a bool into a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_PackChar()

LE_DECLARE_INLINE bool le_pack_PackChar ( uint8_t **  bufferPtr,
char  value 
)

Pack a char into a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_PackDouble()

LE_DECLARE_INLINE bool le_pack_PackDouble ( uint8_t **  bufferPtr,
double  value 
)

Pack a double into a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_PackResult()

LE_DECLARE_INLINE bool le_pack_PackResult ( uint8_t **  bufferPtr,
le_result_t  value 
)

Pack a le_result_t into a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_PackOnOff()

LE_DECLARE_INLINE bool le_pack_PackOnOff ( uint8_t **  bufferPtr,
le_onoff_t  value 
)

Pack le_onoff_t into a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_PackReference()

LE_DECLARE_INLINE bool le_pack_PackReference ( uint8_t **  bufferPtr,
const void *  ref 
)

Pack a reference into a buffer, incrementing the buffer pointer.

◆ le_pack_PackString()

LE_DECLARE_INLINE bool le_pack_PackString ( uint8_t **  bufferPtr,
const char *  stringPtr,
uint32_t  maxStringCount 
)

Pack a string into a buffer, incrementing the buffer pointer.

Note
Will assert if provided string is larger than maximum allowable string.

◆ le_pack_PackArrayHeader()

LE_DECLARE_INLINE bool le_pack_PackArrayHeader ( uint8_t **  bufferPtr,
const void *  arrayPtr,
size_t  elementSize,
size_t  arrayCount,
size_t  arrayMaxCount 
)

Pack the size information for an array into a buffer, incrementing the buffer pointer.

Note
Users of this API should generally use LE_PACK_PACKARRAY macro instead which also packs the array data.

◆ le_pack_UnpackUint8()

LE_DECLARE_INLINE bool le_pack_UnpackUint8 ( uint8_t **  bufferPtr,
uint8_t *  valuePtr 
)

Unpack a uint8_t from a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_UnpackUint16()

LE_DECLARE_INLINE bool le_pack_UnpackUint16 ( uint8_t **  bufferPtr,
uint16_t *  valuePtr 
)

Unpack a uint16_t from a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_UnpackUint32()

LE_DECLARE_INLINE bool le_pack_UnpackUint32 ( uint8_t **  bufferPtr,
uint32_t *  valuePtr 
)

Unpack a uint32_t from a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_UnpackUint64()

LE_DECLARE_INLINE bool le_pack_UnpackUint64 ( uint8_t **  bufferPtr,
uint64_t *  valuePtr 
)

Unpack a uint64_t from a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_UnpackInt8()

LE_DECLARE_INLINE bool le_pack_UnpackInt8 ( uint8_t **  bufferPtr,
int8_t *  valuePtr 
)

Unpack a int8_t from a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_UnpackInt16()

LE_DECLARE_INLINE bool le_pack_UnpackInt16 ( uint8_t **  bufferPtr,
int16_t *  valuePtr 
)

Unpack a int16_t from a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_UnpackInt32()

LE_DECLARE_INLINE bool le_pack_UnpackInt32 ( uint8_t **  bufferPtr,
int32_t *  valuePtr 
)

Unpack a int32_t from a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_UnpackInt64()

LE_DECLARE_INLINE bool le_pack_UnpackInt64 ( uint8_t **  bufferPtr,
int64_t *  valuePtr 
)

Unpack a int64_t from a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_UnpackSize()

LE_DECLARE_INLINE bool le_pack_UnpackSize ( uint8_t **  bufferPtr,
size_t *  valuePtr 
)

Pack a size_t into a buffer, incrementing the buffer pointer as appropriate.

Note
Packed sizes are limited to 2^32-1, regardless of platform

◆ le_pack_UnpackBool()

LE_DECLARE_INLINE bool le_pack_UnpackBool ( uint8_t **  bufferPtr,
bool *  valuePtr 
)

Unpack a bool from a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_UnpackChar()

LE_DECLARE_INLINE bool le_pack_UnpackChar ( uint8_t **  bufferPtr,
char *  valuePtr 
)

Unpack a char from a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_UnpackDouble()

LE_DECLARE_INLINE bool le_pack_UnpackDouble ( uint8_t **  bufferPtr,
double *  valuePtr 
)

Unpack a double from a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_UnpackResult()

LE_DECLARE_INLINE bool le_pack_UnpackResult ( uint8_t **  bufferPtr,
le_result_t valuePtr 
)

Unpack a le_result_t from a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_UnpackOnOff()

LE_DECLARE_INLINE bool le_pack_UnpackOnOff ( uint8_t **  bufferPtr,
le_onoff_t valuePtr 
)

Pack le_onoff_t into a buffer, incrementing the buffer pointer as appropriate.

◆ le_pack_UnpackReference()

LE_DECLARE_INLINE bool le_pack_UnpackReference ( uint8_t **  bufferPtr,
void *  refPtr 
)

Unpack a reference from a buffer, incrementing the buffer pointer.

Parameters
refPtrPointer to the reference. Declared as void * to allow implicit conversion from pointer to reference types.

◆ le_pack_UnpackString()

LE_DECLARE_INLINE bool le_pack_UnpackString ( uint8_t **  bufferPtr,
char *  stringPtr,
uint32_t  bufferSize,
uint32_t  maxStringCount 
)

Unpack a string from a buffer, incrementing the buffer pointer.

◆ le_pack_UnpackArrayHeader()

LE_DECLARE_INLINE bool le_pack_UnpackArrayHeader ( uint8_t **  bufferPtr,
const void *  arrayPtr,
size_t  elementSize,
size_t *  arrayCountPtr,
size_t  arrayMaxCount 
)

Pack the size information for an array into a buffer, incrementing the buffer pointer.

Note
Users of this API should generally use LE_PACK_PACKARRAY macro instead which also packs the array data.