Samples

CRC sw

inline uint8_t CRC_Check(uint16_t u16_CrcA, uint16_t u16_CrcB)

Check if two CRC are equal.

Parameters:
  • u16_CrcA[in] First CRC

  • u16_CrcB[in] Second CRC

Returns:

1 equal; 0 otherwise

uint8_t CRC_Compute(uint8_t *p_Buf, uint8_t u8_Sz, uint16_t *p_Crc)

This function compute the CRC as defined by the EN13757 standard.

Parameters:
  • p_Buf[in] Pointer in the message buffer

  • u8_Sz[in] The buffer size

  • p_Crc[out] Computed CRC

Returns:

1 success, 0 otherwise.

static uint16_t _update_crc16_(const uint16_t *p_Table, uint16_t u16_Crc, uint8_t u8_C)

Private function to compute a part of the CRC.

Parameters:
  • p_Table[in] Pointer on the polynomial table

  • u16_Crc[in] The CRC

  • u8_C[in] Current byte to compute on

Returns:

partial CRC.

Crypto

enum crypto_code_e

Returned code from Crypto functions.

Values:

enumerator CRYPTO_KO

Crypto function failed.

enumerator CRYPTO_OK

Crypto function success.

enumerator CRYPTO_KID_UNK_ERR

The key id is unknown.

enumerator CRYPTO_INT_NULL_ERR

Error due to a NULL pointer.

KEY_STORE key_s _a_Key_ []

This table hold all keys used in the system.

inline uint8_t Crypto_Encrypt(uint8_t *p_Out, uint8_t *p_In, uint8_t u8_Sz, uint8_t p_Ctr[CTR_SIZE], uint8_t u8_KeyId)

Wrapper around crypt function.

This function encrypt (with the AES128 in CTR mode) a given message.

Parameters:
  • p_Out[inout] Pointer on output buffer (Cipher text).

  • p_In[inout] Pointer on input buffer (Plain text).

  • u8_Sz[in] Input buffer size

  • p_Ctr[in] Counter buffer. Warning : it will be altered by this function.

  • u8_KeyId[in] The key id to use for encrypt

Return values:

return – crypto_code_e::CRYPTO_OK (1) if everything is fine return crypto_code_e::CRYPTO_KO (0) if something goes wrong return crypto_code_e::CRYPTO_KID_UNK_ERR (2) id the key id is out of box return crypto_code_e::CRYPTO_INT_NULL_ERR (4) if one of the given pointer is NULL

inline uint8_t Crypto_Decrypt(uint8_t *p_Out, uint8_t *p_In, uint8_t u8_Sz, uint8_t p_Ctr[CTR_SIZE], uint8_t u8_KeyId)

Wrapper around the crypt function.

This function decrypt (with the AES128 in CTR mode) a given message.

Parameters:
  • p_Out[inout] Pointer on output buffer (Plain text).

  • p_In[inout] Pointer on input buffer (Cipher text).

  • u8_Sz[in] Input buffer size

  • p_Ctr[in] Counter buffer. Warning : it will be altered by this function.

  • u8_KeyId[in] The key id to use for decrypt

Return values:

return – crypto_code_e::CRYPTO_OK (1) if everything is fine return crypto_code_e::CRYPTO_KO (0) if something goes wrong return crypto_code_e::CRYPTO_KID_UNK_ERR (2) id the key id is out of box return crypto_code_e::CRYPTO_INT_NULL_ERR (4) if one of the given pointer is NULL

inline uint8_t Crypto_AES128_CMAC(uint8_t *p_Hash, uint8_t *p_Msg, uint8_t u8_Sz, uint8_t p_Ctr[CTR_SIZE], uint8_t u8_KeyId)

Wrapper around the AES128_CMAC function.

This function compute the footprint (with the AES128 in CMAC mode) of a given message.

Parameters:
  • p_Hash[inout] Pointer on output buffer (footprint).

  • p_Msg[inout] Pointer on input buffer (the message on which the footprint is computed)

  • u8_Sz[in] Input buffer size

  • p_Ctr[in] Counter buffer.

  • u8_KeyId[in] The key id to use for compute the footprint

Return values:

return – crypto_code_e::CRYPTO_OK (1) if everything is fine return crypto_code_e::CRYPTO_KO (0) if something goes wrong return crypto_code_e::CRYPTO_KID_UNK_ERR (2) id the key id is out of box return crypto_code_e::CRYPTO_INT_NULL_ERR (4) if one of the given pointer is NULL

inline uint8_t Crypto_SHA256(uint8_t p_Sha256[SHA256_SIZE], uint8_t *p_Data, uint32_t u32_Sz)

Wrapper around the SHA256 function.

This function compute the SHA256 of given buffer..

Parameters:
  • p_Sha256[in] Pointer on output buffer (sha256, 32 bytes).

  • p_Data[out] Pointer on input buffer (the message on which the footprint is computed)

  • u32_Sz[in] Input buffer size

Return values:

return – crypto_code_e::CRYPTO_OK (1) if everything is fine return crypto_code_e::CRYPTO_KO (0) if something goes wrong return crypto_code_e::CRYPTO_INT_NULL_ERR (4) if one of the given pointer is NULL

uint8_t Crypto_WriteKey(uint8_t p_Key[KEY_SIZE], uint8_t u8_KeyId)

This function set (write) a key at specified key id.

Parameters:
  • p_Key[in] The given key to set.

  • u8_KeyId[in] The key id to use.

Return values:
  • CRYPTO_OK – (1) if everything is fine

  • CRYPTO_KID_UNK_ERR – (2) id the key id is out of box

static uint8_t _crypt_(uint8_t *p_Out, uint8_t *p_In, uint8_t u8_Sz, uint8_t p_Ctr[CTR_SIZE], uint8_t u8_KeyId)

This function en/de crypt with the AES128 in CTR mode.

Parameters:
  • p_Out[inout] Pointer on output buffer. Plain text for decrypt, cipher text for encrypt.

  • p_In[inout] Pointer on input buffer. Cipher text for encrypt, plain text for decrypt.

  • u8_Sz[in] Input buffer size

  • p_Ctr[in] Counter buffer. Warning : it will be altered by this function.

  • u8_KeyId[in] The key id to use for encrypt or decrypt

Return values:

return – crypto_code_e::CRYPTO_OK (1) if everything is fine return crypto_code_e::CRYPTO_KO (0) if something goes wrong return crypto_code_e::CRYPTO_KID_UNK_ERR (2) id the key id is out of box return crypto_code_e::CRYPTO_INT_NULL_ERR (4) if one of the given pointer is NULL

static uint8_t _AES128_CMAC_(uint8_t *p_Hash, uint8_t *p_Msg, uint8_t u8_Sz, uint8_t p_Ctr[CTR_SIZE], uint8_t u8_KeyId)

This function compute the footprint with the AES128 in CMAC mode.

Parameters:
  • p_Hash[inout] Pointer on output buffer (footprint).

  • p_Msg[inout] Pointer on input buffer (the message on which the footprint is computed)

  • u8_Sz[in] Input buffer size

  • p_Ctr[in] Counter buffer.

  • u8_KeyId[in] The key id to use for compute the footprint

Return values:

return – crypto_code_e::CRYPTO_OK (1) if everything is fine return crypto_code_e::CRYPTO_KO (0) if something goes wrong return crypto_code_e::CRYPTO_KID_UNK_ERR (2) id the key id is out of box return crypto_code_e::CRYPTO_INT_NULL_ERR (4) if one of the given pointer is NULL

static uint8_t _SHA256_(uint8_t p_Sha256[SHA256_SIZE], uint8_t *p_Data, uint32_t u32_Sz)

This function compute the SHA256 of given buffer.

Parameters:
  • p_Sha256[in] Pointer on output buffer (sha256, 32 bytes).

  • p_Data[out] Pointer on input buffer (the message on which the footprint is computed)

  • u32_Sz[in] Input buffer size

Return values:

return – crypto_code_e::CRYPTO_OK (1) if everything is fine return crypto_code_e::CRYPTO_KO (0) if something goes wrong return crypto_code_e::CRYPTO_INT_NULL_ERR (4) if one of the given pointer is NULL

static inline uint8_t _set_key_(uint8_t p_Key[KEY_SIZE], uint8_t u8_KeyId)

This function set (write) a key at specified key id.

Parameters:
  • p_Key[in] The given key to set.

  • u8_KeyId[in] The key id to use.

Return values:
  • CRYPTO_OK – (1) if everything is fine

  • CRYPTO_KID_UNK_ERR – (2) id the key id is out of box

void * secure_memcpy (void *__restrict __dest, const void *__restrict __src, size_t __n)

This function is intended to replaced memcpy into secure area.

Parameters:
  • __dest[in] The destination pointer

  • __src[in] The source pointer

  • __n[in] Number of byte to copy

Return values:

return – the destination pointer

void *secure_memset(void *__s, int __c, size_t __n)

This function is intended to replaced memset into secure area.

Parameters:
  • __s[in] The destination pointer

  • __c[in] The character value to set

  • __n[in] The number of char to set

Return values:

return – the destination pointer

KEY_STORE
KEY_MAX_NB

Define the maximum number of key.

KEY_NONE_ID

Define the key id for no encryption.

KEY_ENC_MIN

Define the first key id for the kenc key.

KEY_ENC_MAX

Define the last key id for the kenc key.

KEY_CHG_ID

Define the key id for the kchg key.

KEY_MOB_ID

Define the key id for the kmob key.

KEY_MAC_ID

Define the key id for the kmac key.

KEY_LOG_ID

Define the key id for the klog key.

Crypto_KEY_PRIV_H_
struct key_s
#include <key_priv.h>

This structure hold a key used for en/de-cryption and authentication.

Reed-Solomon

static const uint8_t pp[mm + 1] = {1, 0, 1, 1, 1, 0, 0, 0, 1}

This variable hold the irreducible polynomial coefficients (1+x^^2+x^^3+x^^4+x^^8)

static int16_t index_of[nn + 1]

This variable hold the index values.

static uint8_t alpha_to[nn + 1]

This variable hold the alpha values.

static uint8_t gg[nn - kk + 1]

This variable hold the Galois Field values.

void RS_Init(void)

This function initialize the Galois field and polynomial generator tables.

uint8_t RS_Decode(uint8_t b_recd[RS_MESSAGE_SZ + RS_PARITY_SZ])

This function detect and correct the given message.

Parameters:

b_recd[inout] Pointer on source and destination data (Message and Parity). b_recd[0 to 222] contains message data, while b_recd[223 to 223 + 32] contains the parity bytes).

Return values:
  • 0 – Error;

  • 1 – Success

void RS_Encode(uint8_t p_Data[RS_MESSAGE_SZ], uint8_t p_Out[RS_PARITY_SZ])

This function generate the parity word of the given message.

Parameters:
  • p_Data[in] Pointer on message (source data).

  • p_Out[out] Pointer on parity (destination).

uint32_t RS_GetMsgSize(void)

This function give the message size (in byte).

Returns:

The message size.

uint32_t RS_GetParitySize(void)

This function give the parity word size (in byte).

Returns:

The parity word size.

const uint8_t *RS_GetGG_ptr(uint32_t *u32_ggSz)

This function give the generator polynomial pointer.

Parameters:

*u32_ggSz[inout] This pointer will hold the generator polynomial size.

Returns:

The generator polynomial pointer.

const uint8_t *RS_GetAlphaOf_ptr(uint32_t *u32_alphaOfSz)

This function give the alpha_to pointer.

Parameters:

*u32_alphaOfSz[inout] This pointer will hold the alpha_to size.

Returns:

The alpha_to pointer.

const int16_t *RS_GetIndexOf_ptr(uint32_t *u32_indexOfSz)

This function give the index_of pointer.

Parameters:

*u32_indexOfSz[inout] This pointer will hold the index_of size.

Returns:

The index_of pointer.

static void _generate_gf_(void)

This private function generate the Galois-Field.

Generate GF(2**mm) from the irreducible polynomial p(X) in pp[0]..pp[mm] lookup tables:

  • index->polynomial form alpha_to[] contains j=alpha**i;

  • polynomial form -> index form index_of[j=alpha**i] = i alpha=2 is the primitive element of GF(2**mm).

static void _gen_poly_(void)

This private function compute the generator polynomial.

Obtain the generator polynomial of the tt-error correcting, length nn=(2**mm -1) Reed Solomon code from the product of (X+alpha**i), i=1..2*tt

mm

Define the symboles bits number.

nn

Define the total message size (with parity word)

tt

Define the number of error that can be corrected.

kk

Define the useable message size.

RS_MESSAGE_SZ

Define an alias to kk.

RS_PARITY_SZ

Define the parity word size.

Parameters

enum param_access_e

This enum defines the parameter access type.

Values:

enumerator NA

No Access.

enumerator RO

Read only.

enumerator WO

Write only.

enumerator RW

Read/Write.

enum param_effective_e

This enum defines the parameter update effectiveness.

Values:

enumerator IMM

Immediate.

enumerator ACK

After the write request acknowledge.

enumerator MNT

At the next maintenance period.

enumerator HGA

At the next Gas Hour.

enumerator UTC

At the next 0h00 UTC.

enum param_ref_e

This enum defines if the parameter is saved or not into the referential.

Values:

enumerator REF_N

Not saved into the referential.

enumerator REF_Y

Saved into the referential.

enum restr_type_e

This enum defines the parameter restriction type.

Values:

enumerator RESTR_MODULO

Restriction on modulo.

enumerator RESTR_RANGE

Restriction on range.

enumerator RESTR_ENUM

Restriction on enum list.

enum restr_sz_type_e

This enum defines the size on which restriction is applied.

Values:

enumerator RESTR_8BITS

Restriction values are on 8 bits.

enumerator RESTR_16BITS

Restriction values are on 16 bits.

enumerator RESTR_32BITS

Restriction values are on 32 bits.

enumerator RESTR_64BITS

Restriction values are on 64 bits.

enum param_lan_ids_e

This enum defines the lan parameter ids.

Values:

enumerator VERS_HW_TRX

Hardware version number of the device (or transceiver for a remote module)

enumerator VERS_FW_TRX

Software version number run by the device (or transceiver for a remote module)

enumerator DATEHOUR_LAST_UPDATE

Date/time of the last successful firmware download.

enumerator L6App

Version of the application layer.

Frequency channel to be used for all uplink message transmissions.

Frequency channel to be used for all message receptions (except firmware download)

Modulation to be used for all uplink message transmissions.

Modulation to be used for all message receptions (except firmware download)

enumerator TX_POWER

Transceiver nominal transmission power.

enumerator TX_DELAY_FULLPOWER

Maximum time between two COMMAND messages before the device automatically returns to maximum transmission power.

enumerator TX_FREQ_OFFSET

Absolute transmission correction frequency of.

enumerator EXCH_RX_DELAY

Fixed wait time after transmission of a DATA message by the device and before opening the COMMAND message listening window.

enumerator EXCH_RX_LENGTH

Duration of the COMMAND message listening window by the device.

enumerator EXCH_RESPONSE_DELAY

Time between reception of a COMMAND message by the device and transmission of the corresponding RESPONSE message.

enumerator EXCH_RESPONSE_DELAY_MIN

Minimum value accepted for the EXCH_RESPONSE_DELAY parameter (defined by the device MANUFACTURER)

enumerator L7TRANSMIT_LENGTH_MAX

Maximum length of application messages that can be sent by the device.

enumerator L7RECEIVE_LENGTH_MAX

Maximum length of application messages that can be received by the device.

enumerator CLOCK_CURRENT_EPOC

Current time of device.

enumerator CLOCK_OFFSET_CORRECTION

Relative correction (time delta) to be applied to the device clock once only to correct its absolute drift.

enumerator CLOCK_DRIFT_CORRECTION

Correction of device clock frequency.

enumerator CIPH_CURRENT_KEY

Current key number.

enumerator CIPH_KEY_COUNT

Number of encryption keys available in the device.

enumerator L6NetwIdSelect

Kmac key index.

enumerator PING_RX_DELAY

Fixed waiting time after transmission of an INSTPING message by the device and before opening the INSTPONG message listening window.

enumerator PING_RX_LENGTH

Duration of the INSTPONG message listening window by the device.

enumerator PING_RX_DELAY_MIN

Minimum value of the PING_RX_DELAY parameter.

enumerator PING_RX_LENGTH_MAX

Maximum value of the PING_RX_LENGTH parameter.

enumerator PING_LAST_EPOCH

Execution time of the last connectivity test (INSTPING/INSTPONG)

enumerator PING_NBFOUND

Number of different INSTPONG messages received in response to the last connectivity test.

enumerator PING_REPLY1

Response 1 received for the last connectivity test (Bigest L7RssiDown)

enumerator PING_REPLY2

Response 2 received for the last connectivity test.

enumerator PING_REPLY3

Response 3 received for the last connectivity test.

enumerator PING_REPLY4

Response 4 received for the last connectivity test.

enumerator PING_REPLY5

Response 5 received for the last connectivity test.

enumerator PING_REPLY6

Response 6 received for the last connectivity test.

enumerator PING_REPLY7

Response 7 received for the last connectivity test.

enumerator PING_REPLY8

Response 8 received for the last connectivity test (Weakess L7RssiDown)

enumerator EXECPING_PERIODE

Periodic time of execping sending by the device, in months.

enumerator LAST_ID

Don’t remove, it marks the end of table.

param_s
const uint16_t u16_ParamValueSz

This external variable hold the parameters table value size.

This external variable hold the parameters table value size.

uint8_t a_ParamValue[]

This external variable hold the parameters table value.

const uint8_t u8_ParamAccessCfgSz

This external variable hold the parameters access table size.

This external variable hold the parameters access table size.

const param_s a_ParamAccess[]

This external variable hold parameters access table.

const uint8_t u8_ParamRestrCfgSz

This external variable hold the parameters restriction table size.

This external variable hold the parameters restriction table size.

const restr_s a_ParamRestr[]

This external variable hold the parameters restriction table.

void Param_Init(const uint8_t *p_Param)

Init parameters by with default values.

Parameters:

p_Param[in] Pointer on input parameters table.

Returns:

None

uint8_t Param_IsValidId(uint8_t u8_Id)

Check if Id is in acess table.

Parameters:

u8_Id[in] The parameter Id.

Return values:
  • 0 – : not valid

  • 1 – : valid

uint8_t Param_GetSize(uint8_t u8_Id)

Get the parameter size.

Parameters:

u8_Id[in] The parameter Id.

Returns:

The parameter size.

param_access_e Param_GetLocAccess(uint8_t u8_Id)

Get the local access rights field of the parameter.

Parameters:

u8_Id[in] The parameter Id.

Returns:

The local access rights field.

param_access_e Param_GetRemAccess(uint8_t u8_Id)

Get the remote access rights field of the parameter.

Parameters:

u8_Id[in] The parameter Id.

Returns:

The remote access rights field.

param_effective_e Param_GetEffect(uint8_t u8_Id)

Get the “effective” field of the parameter.

Parameters:

u8_Id[in] The parameter Id.

Returns:

The “effective” field.

param_ref_e Param_GetReferenced(uint8_t u8_Id)

Get the “referenced” field of the parameter.

Parameters:

u8_Id[in] The parameter Id.

Returns:

The “referenced” field.

uint32_t Param_GetAddOf(uint8_t u8_Id)

Get the memory address of the parameter.

Parameters:

u8_Id[in] The parameter Id.

Returns:

The parameter address

uint8_t Param_GetRestrId(uint8_t u8_Id)

Get the restriction id of the parameter.

Parameters:

u8_Id[in] The parameter Id.

Returns:

The restriction id field.

const void *Param_GetRestrTableAdd(uint8_t u8_Id)

Get the restriction table address of the parameter.

Parameters:

u8_Id[in] The parameter Id.

Returns:

The restriction table address.

uint8_t Param_CheckConformity(uint8_t u8_Id, uint8_t *p_Data)

Check that given value conform to its restriction definition.

Parameters:
  • u8_Id[in] id of the parameter to check

  • *p_Data[in] point on the data to check

Return values:
  • 0 – : not conform

  • 1 – : conform

uint8_t Param_Access(uint8_t u8_Id, uint8_t *p_Data, uint8_t u8_Dir)

Pseudo-Direct access to the parameters table.

Parameters:
  • u8_Id[in] The parameter Id.

  • p_Data[inout] Pointer on source or destination data.

  • u8_Dir[in] The access direction (0:read; 1:write).

Return values:
  • 0 – Error

  • 1 – success

uint8_t Param_LocalAccess(uint8_t u8_Id, uint8_t *p_Data, uint8_t u8_Dir)

Local access to the parameters table.

Parameters:
  • u8_Id[in] The parameter Id.

  • p_Data[inout] Pointer on source or destination data.

  • u8_Dir[in] The access direction (0:read; 1:write).

Return values:
  • 0 – access is forbidden

  • 1 – access granted

uint8_t Param_RemoteAccess(uint8_t u8_Id, uint8_t *p_Data, uint8_t u8_Dir)

Remote access to the parameters table.

Parameters:
  • u8_Id[in] The parameter Id.

  • p_Data[inout] Pointer on source or destination data.

  • u8_Dir[in] The access direction (0:read; 1:write).

Return values:

0 – access is forbidden; 1: access granted

struct __attribute__ ((__packed__))

This structure defines the parameter properties.

static uint8_t _param_access_(uint8_t u8_Id, uint8_t *p_Data, uint8_t u8_Dir, uint8_t u8_Access)

This private function deal with access to parameter table.

Parameters:
  • u8_Id[in] The parameter Id.

  • p_Data[inout] Pointer on source or destination data.

  • u8_Dir[in] The access direction (0:read; 1:write).

  • u8_Access[in] The access rights.

Return values:
  • 0 – Error

  • 1 – Success

static restr_s *_get_restr_add_(uint8_t u8_Id)

Get the restriction table address of the parameter.

Parameters:

u8_Id[in] The parameter Id.

Returns:

The restriction table address.

static uint8_t _check_conform_modulo_(restr_s *p_Restr, uint8_t *p_Data)

Check that given value conform to the modulo value.

Parameters:
  • *p_Restr[in] point on the restriction table

  • *p_Data[in] point on the data to check

Return values:
  • 0 – : not conform

  • 1 – : conform

static uint8_t _check_conform_enum_(restr_s *p_Restr, uint8_t *p_Data)

Check that given value conform to one of the enum value.

Parameters:
  • *p_Restr[in] point on the restriction table

  • *p_Data[in] point on the data to check

Return values:
  • 0 – : not conform

  • 1 – : conform

static uint8_t _check_conform_range_(restr_s *p_Restr, uint8_t *p_Data)

Check that given value conform to the range value.

Parameters:
  • *p_Restr[in] point on the restriction table

  • *p_Data[in] point on the data to check

Return values:
  • 0 – : not conform

  • 1 – : conform

struct restr_s
#include <parameters_def.h>

This structure defines the parameter restriction table.

Event

enum time_evt_cfg_e

This enum define the timer configuration type.

Values:

enumerator TIMEEVT_CFG_ONESHOT

One-shot relative timer.

enumerator TIMEEVT_CFG_PERIODIC

Periodic relative timer.

enumerator TIMEEVT_CFG_ABSOLUTE

One-shot absolute timer.

typedef struct time_evt_s time_evt_t

This struct defines the timer type.

typedef void (*pfTimeEvt_HandlerCB_t)(void)

This defines the interrupt call back for the TimeEvt.

struct time_evt_ctx_s sTimeEvtCtx

This define the TimeEvt context instance.

uint8_t TimeEvt_TimerInit(time_evt_t *pTimeEvt, void (*pvTaskHandle)(uint32_t evt), time_evt_cfg_e eCfg)

Initialize the given timer.

Parameters:
  • pTimeEvt[in] Pointer a Timer to initialize

  • pvTaskHandle[in] Task handler to notify

  • eCfg[in] The timer configuration

Return values:
  • 0 – Success

  • 1 – Failed (given is/are null)

uint8_t TimeEvt_TimerStart(time_evt_t *pTimeEvt, uint32_t u32Value, int16_t i16DeltaMs, uint32_t u32Event)

Start the given timer.

Parameters:
  • pTimeEvt[in] Pointer a Timer to start (insert)

  • u32Value[in] The Timer value in second

  • i16DeltaMs[in] The Delta timer value in millisecond

  • u32Event[in] Event to notify on timer expire

Return values:
  • 0 – Success

  • 1 – Failed (the given time value is passed or negative)

void TimeEvt_TimerStop(time_evt_t *pTimeEvt)

Stop the given timer.

Parameters:

pTimeEvt[in] Pointer a Timer to stop (remove)

Returns:

None

void TimeEvt_Setup(void)

Initialize the TimeEvt Context.

Returns:

None

void TimeEvt_Init(void)

Initialize the TimeEvt module.

Returns:

None

void TimeEvt_UpdateTime(time_t t)

This function update time and internal structure.

Parameters:

t[in] The new time value to update

Returns:

None

void TimeEvt_EventHandler(void)

Callback handler on alarm interrupt.

Returns:

None

static void _reset(struct time_evt_ctx_s *pCtx)

Reset the TimeEvt context.

Parameters:

pCtx[in] Pointer a TimeEvt context

Returns:

None

static void *_current(struct time_evt_ctx_s *pCtx)

Get the pointer on the current timer.

Parameters:

pCtx[in] Pointer a TimeEvt context

Returns:

the pointer on the current timer

static void _update(struct time_evt_ctx_s *pCtx, uint64_t u64Now)

Update the TimeEvt.

Parameters:
  • pCtx[in] Pointer a TimeEvt context

  • u64Now[in] Current time to update with

Returns:

None

static void _insert(struct time_evt_ctx_s *pCtx, struct time_evt_s *pNew)

Insert a Timer from the TimeEvt.

Parameters:
  • pCtx[in] Pointer a TimeEvt context

  • pNew[in] Pointer on Timer to insert

Returns:

None

static void _remove(struct time_evt_ctx_s *pCtx, struct time_evt_s *pDel)

Remove a Timer from the TimeEvt.

Parameters:
  • pCtx[in] Pointer a TimeEvt context

  • pDel[in] Pointer on Timer to remove

Returns:

None

TIME_EVT_ALARM_ID

This macro define the used alarm id.

struct time_evt_s
#include <time_evt.h>

This struct define the timer context.

struct time_evt_ctx_s

This struct define the TimeEvt context.

Image Storage

enum img_pend_e

This enum define pending image entry.

Values:

enumerator PENDING_SETUP
enumerator PENDING_NONE
enumerator PENDING_LOCAL
enumerator PENDING_REMOTE
typedef uint8_t (*pfWriteFlash_t)(uint32_t u32Addr, uint64_t *pData, uint32_t u32NbDoubleWord)
typedef uint8_t (*pfEraseFlash_t)(uint32_t u32Addr, uint32_t u32Size)
typedef struct img_mgr_ctx_s img_mgr_ctx_t

This struct defines the image context type.

struct sw_pend_ctrl_s __attribute__
struct img_mgr_ctx_s sImgMgrCtx
void ImgStore_StoreBlock(uint16_t u16_BlkId, uint8_t *p_Blk)

Save the given software block and set its corresponding bit “on” into the bitmap.

Parameters:
  • u16_BlkId[in] The Id of the given block.

  • *p_Blk[in] Pointer on the software block.

uint8_t ImgStore_IsComplete(void)

Check if the given software image is complete.

Return values:
  • 0 – Not complete

  • 1 – Complete

uint8_t ImgStore_Verify(uint8_t *pImgHash, uint8_t u8DigestSz)

Verify the sw image integrity (sha256).

Parameters:
  • pImgHash[in] Pointer on expected image sha256

  • u8DigestSz[in] Size of expected image sha256

Return values:
  • 0 – Success

  • 1 – Failed

uint8_t ImgStore_GetBitmapLine(uint16_t u16_Id)

Get the line value (from bitmap) of the given block Id.

Parameters:

u16_Id[in] The Id of the block.

Return values:

The – 8 bits bitmap line

uint16_t ImgStore_GetMaxBlockNb(void)

Get the maximum admissible block number.

Return values:

The – maximum block number

inline img_pend_e ImgStore_GetPending(void)

Get the pending flag.

Return values:

return – img_pend_e::PENDING_SETUP return img_pend_e::PENDING_NONE return img_pend_e::PENDING_LOCAL return img_pend_e::PENDING_REMOTE

inline void ImgStore_SetPending(img_pend_e ePend)

Set the pending flag.

Parameters:

ePend[in] The pending flag to set

Return values:

None

int8_t ImgStore_Init(uint16_t u16NbExpectedBlk)

Initialize the image manager context.

Parameters:

u16NbExpectedBlk[in] The number block for expected new sw image

Return values:
  • 0 – Success

  • 1 – Failed (at least one of given parameters is out of range)

  • -1 – Fatal (unable to erase the flash memory area)

int8_t ImgStore_Setup(uint32_t u32ImgAdd, pfWriteFlash_t pfWrite, pfEraseFlash_t pfErase)

Initialize the image manager context.

Parameters:
  • u32ImgAdd[in] Software Image address (64 bits aligned)

  • pfWrite[in] Function pointer on write sub function

  • pfErase[in] Function pointer on erase sub function

Return values:
  • 0 – Success

  • 1 – Failed (at least one of given parameters is out of range)

struct sw_pend_buff_s __attribute__ ((aligned(8)))
uint8_t _get_bitmap_line(struct img_mgr_ctx_s *pCtx, uint16_t u16_Id)

Get the line value (from bitmap) of the given block Id.

Parameters:
  • pCtx[in] Pointer on image manager context

  • u16_Id[in] The Id of the block.

Returns:

the line value.

uint8_t _get_bitmap_bit(struct img_mgr_ctx_s *pCtx, uint16_t u16_Id)

Get the bit value (from bitmap) of the given block Id.

Parameters:
  • pCtx[in] Pointer on image manager context

  • u16_Id[in] The Id of the block.

Return values:
  • 0 – this block is not yet present.

  • 1 – this block is already present.

void _set_bitmap(struct img_mgr_ctx_s *pCtx, uint16_t u16_Id)

Set “on” the bit corresponding to the given block Id into the bitmap.

Parameters:
  • pCtx[in] Pointer on image manager context

  • u16_Id[in] The Id of block to set “on”.

void _clr_bitmap(struct img_mgr_ctx_s *pCtx)

Clear the entire bitmap.

Parameters:

pCtx[in] Pointer on image manager context

void _clr_pending(struct img_mgr_ctx_s *pCtx)

Clear the pending table.

Parameters:

pCtx[in] Pointer on image manager context

struct sw_pend_buff_s
#include <img_storage_private.h>

This structure hold a pending entry.

struct sw_pend_ctrl_s
#include <img_storage_private.h>

This structure hold a pending entry control.

struct img_mgr_ctx_s
#include <img_storage_private.h>

This structure hold a image manager context.

Logger

enum logger_level_e

This enum define the logger output level

Values:

enumerator LOG_LV_QUIET

Quite, no log is output.

enumerator LOG_LV_ERR

Error log is output.

enumerator LOG_LV_WRN

Warning log is output.

enumerator LOG_LV_INF

Info log is output.

enumerator LOG_LV_DBG

Debug log is output.

enumerator LOG_LV_FRM_IN

Frame in log is output.

enumerator LOG_LV_FRM_OUT

Frame out log is output.

enum logger_tstamp_e

This enum define the Timestamp added to the log output

Values:

enumerator LOG_TSTAMP_NONE

No Timestamp.

enumerator LOG_TSTAMP_NORM

Add Timestamp (epoch) to the log output.

enumerator LOG_TSTAMP_HIRES

Add Timestamp (epoch) plus millisecond to the log output.

enumerator LOG_TSTAMP_TRUNC

Truncate Timestamp on 5 digits.

uint8_t gLoggerLevel

This global variable define the output logger level.

uint8_t gLoggerLevel = LOG_LV_QUIET

This global variable define the output logger level.

static struct logger_ctx_s sLoggerCtx
void Logger_Setup(int32_t (*pfOut)(const char*, FILE*), FILE *pFile)

This function initialize the Logger module.

Returns:

None

inline void Logger_SetLevel(uint8_t u8LogLevel, uint8_t u8Tstmp)

This function setup the Logger module.

Parameters:
  • u8LogLevel[in] Logger level (ORed logger_level_e values)

  • u8Tstmp[in] Type of time-stamp to use

Returns:

None

void Logger_Put(char *str, uint32_t u32Nb)

This function “put” a raw string to the logger.

Parameters:
  • str[in] Raw string

  • u32Nb[in] The number of char to logout

Returns:

None

void Logger_Post(uint8_t level, char *format, ...)

This function “post” a formated string to the logger.

Parameters:
  • level[in] Level of verbosity

  • format[in] Formated string

  • ...[in] va_args List of variable to log

Returns:

None

void Logger_Frame(char *pStr, uint8_t *pData, uint8_t u8NbData)

This function log a frame as formated string of bytes array.

Parameters:
  • pStr[in] Formated string

  • pData[in] Frame data to log

  • u8NbData[in] Number of byte to log

Returns:

None

static int32_t _logger_add_timestamp_(int32_t id)

Internal function to add timestamp.

Parameters:

id[in] The buffer id on which to add the timestamp

Returns:

The number of written bytes

static int32_t _logger_acquire_id_()

Internal function to acquire an available buffer id.

Returns:

The buffer id

static void _logger_release_id_(int32_t id)

Internal function to release a buffer id.

Parameters:

id[in] The buffer id to release

Returns:

None

static void _logger_main_(void const *argument)

This is the main task function.

Parameters:

argument[in] (not used)

Returns:

None

Logger_Setup(...)
Logger_SetLevel(...)
Logger_Put(...)
Logger_Post(...)
Logger_Frame(...)
LOG_MSG(level, fmt, ...)
LOG_ERR(fmt, ...)
LOG_WRN(fmt, ...)
LOG_INF(fmt, ...)
LOG_DBG(fmt, ...)
LOG_FRM_OUT(pFrm, nb_data)
LOG_FRM_IN(pFrm, nb_data)
struct logger_ctx_s