XDK API  3.6.0
Documentation
Macros | Typedefs | Enumerations | Functions
LWM2MObjectFirmwareUpdatePrivate.h File Reference
#include <Serval_Coap.h>
#include "BCDS_DownloadClient.h"
+ Include dependency graph for LWM2MObjectFirmwareUpdatePrivate.h:
+ This graph shows which files directly or indirectly include this file:

Macros

#define FOTA_LWM2M_STATUS_MASK   (UINT8_C(0x0F)) /* lwm2m status mask */
 
#define FOTA_RESOURCE_PACKAGE   (UINT8_C(0))
 
#define FOTA_RESOURCE_PACKAGE_URI   (UINT8_C(1))
 
#define FOTA_RESOURCE_UPDATE   (UINT8_C(2))
 
#define FOTA_RESOURCE_UPDATE_RESULT   (UINT8_C(5))
 
#define FOTA_RESOURCE_UPDATE_STATE   (UINT8_C(3))
 
#define FOTA_RESOURCE_UPDATE_SUPPORT_OBJ   (UINT8_C(4))
 
#define FOTA_RETREIVE_DL_IN_PROGRESS(CMD_PROCESSOR_PARAM_U32, DL_IN_PROGRESS, IS_SET)   DL_IN_PROGRESS=((IS_SET=(((CMD_PROCESSOR_PARAM_U32) & (1UL<<((uint32_t)FOTA_CONTEXT_DOWNLOAD_IN_PROGRESS))) == 0UL) ? false : true) == true)? (CMD_PROCESSOR_PARAM_U32 >> 17UL)&0x01:CMD_PROCESSOR_PARAM_U32
 
#define FOTA_RETREIVE_NEW_FIRMWARE_INFO(CMD_PROCESSOR_PARAM_U32, NEW_FIRMWARE, IS_SET)   NEW_FIRMWARE=((IS_SET=(((CMD_PROCESSOR_PARAM_U32) & (1UL<<((uint32_t)FOTA_CONTEXT_NEW_FIRMWARE))) == 0UL) ? false : true) == true)? (CMD_PROCESSOR_PARAM_U32 >> 16UL)&0x01:CMD_PROCESSOR_PARAM_U32
 
#define FOTA_RETREIVE_STATE_INFO(CMD_PROCESSOR_PARAM_U32, STATE, IS_SET)   STATE=((IS_SET = (((CMD_PROCESSOR_PARAM_U32) & (1UL<<((uint32_t)FOTA_CONTEXT_STATE))) == 0UL) ? false : true) == true)? (CMD_PROCESSOR_PARAM_U32 >> 8UL)&0xFF:CMD_PROCESSOR_PARAM_U32
 
#define FOTA_RETREIVE_UPDATE_RESULT_INFO(CMD_PROCESSOR_PARAM_U32, UPDATE_RESULT, IS_SET)   UPDATE_RESULT=((IS_SET=(((CMD_PROCESSOR_PARAM_U32) & (1UL<<((uint32_t)FOTA_CONTEXT_CURRENT_RESULT))) == 0UL) ? false : true) == true)? (CMD_PROCESSOR_PARAM_U32 >> 20UL)&0x0F:CMD_PROCESSOR_PARAM_U32
 
#define FOTA_RETREIVE_URL_TYPE(CMD_PROCESSOR_PARAM_U32, URL_TYPE, IS_SET)   URL_TYPE=((IS_SET=(((CMD_PROCESSOR_PARAM_U32) & (1UL<<((uint32_t)FOTA_CONTEXT_URL))) == 0UL) ? false : true) == true)? (CMD_PROCESSOR_PARAM_U32 >> 18UL)&0x01:CMD_PROCESSOR_PARAM_U32
 
#define FOTA_SET_DL_IN_PROGRESS(CMD_PROCESSOR_PARAM_U32, DL_IN_PROGRESS)   CMD_PROCESSOR_PARAM_U32=(((uint32_t)((CMD_PROCESSOR_PARAM_U32 & 0xFFFDFFFF) | ((0x00020000 & ((uint32_t) DL_IN_PROGRESS << 17UL)))) | (1UL<<((uint32_t)FOTA_CONTEXT_DOWNLOAD_IN_PROGRESS))))
 
#define FOTA_SET_NEW_FIRMWARE(CMD_PROCESSOR_PARAM_U32, NEW_FIRMWARE)   CMD_PROCESSOR_PARAM_U32=(((uint32_t)((CMD_PROCESSOR_PARAM_U32 & 0xFFFEFFFF) | ((0x00010000 & ((uint32_t) NEW_FIRMWARE << 16UL)))) | (1UL<<((uint32_t)FOTA_CONTEXT_NEW_FIRMWARE))))
 
#define FOTA_SET_STATE(CMD_PROCESSOR_PARAM_U32, STATE)   CMD_PROCESSOR_PARAM_U32=(((uint32_t)((CMD_PROCESSOR_PARAM_U32 & 0xFFFF00FF) | ((0x0000FF00 & ((uint32_t) STATE << 8UL)))) | (1UL<<((uint32_t)FOTA_CONTEXT_STATE))))
 
#define FOTA_SET_UPDATE_RESULT(CMD_PROCESSOR_PARAM_U32, UPDATE_RESULT)   CMD_PROCESSOR_PARAM_U32=(((uint32_t)((CMD_PROCESSOR_PARAM_U32 & 0xFF0FFFFF) | ((0x00F00000 & ((uint32_t) UPDATE_RESULT << 20UL)))) | (1UL<<((uint32_t)FOTA_CONTEXT_CURRENT_RESULT))))
 
#define FOTA_SET_URL_TYPE(CMD_PROCESSOR_PARAM_U32, URL_TYPE)   CMD_PROCESSOR_PARAM_U32=(((uint32_t)((CMD_PROCESSOR_PARAM_U32 & 0xFFFBFFFF) | ((0x00040000 & ((uint32_t) URL_TYPE << 18UL)))) | (1UL<<((uint32_t)FOTA_CONTEXT_URL))))
 

Typedefs

typedef enum
FotaStateMachine_ContextInfo_E 
FotaStateMachine_ContextInfo_T
 Typedef to represent the ID for FOTA state machine environment variables to be read/written (mapped) to the Persistent memory (ex. NVM,EEPROM,etc) More...
 
typedef enum
FotaStateMachine_State_E 
FotaStateMachine_State_T
 Typedef to represent the Firmware download state. More...
 

Enumerations

enum  FotaStateMachine_ContextInfo_E
 Enum to represent the ID's for FOTA state machine environment variables to read/write (map) the Persistent memory (ex. NVM,EEPROM,etc) More...
 
enum  FotaStateMachine_State_E
 Enum to represent the Firmware internal download states. The low nibble encodes the status that is advertised via LWM2M in the state resource ( as per FotaStateMachine_FW_State_T ). The high nibble will denote the state machine intermediate states. More...
 

Functions

static bool FotaIsStateChangePermitted (FotaStateMachine_State_T state)
 This function handles the complete FOTA state machine state transition. More...
 
static retcode_t FotaPackageResource (Lwm2mSerializer_T *serializerPntr, Lwm2mParser_T *parserPntr)
 Fota Resource package definition which will check the parser pointer. More...
 
static retcode_t FotaStateMachine_Update (Lwm2mSerializer_T *serializerPntr, Lwm2mParser_T *parserPntr)
 Notification callback for firmware upgrade to LightWeight M2M or application. More...
 
static retcode_t FotaStateMachine_UriDownload (Lwm2mSerializer_T *serializerPntr, Lwm2mParser_T *parserPntr)
 This function is used to get URI path or new download location from server and parsing it to Download the firmware. More...
 

Macro Definition Documentation

#define FOTA_LWM2M_STATUS_MASK   (UINT8_C(0x0F)) /* lwm2m status mask */
#define FOTA_RESOURCE_PACKAGE   (UINT8_C(0))
#define FOTA_RESOURCE_PACKAGE_URI   (UINT8_C(1))
#define FOTA_RESOURCE_UPDATE   (UINT8_C(2))
#define FOTA_RESOURCE_UPDATE_RESULT   (UINT8_C(5))
#define FOTA_RESOURCE_UPDATE_STATE   (UINT8_C(3))
#define FOTA_RESOURCE_UPDATE_SUPPORT_OBJ   (UINT8_C(4))
#define FOTA_RETREIVE_DL_IN_PROGRESS (   CMD_PROCESSOR_PARAM_U32,
  DL_IN_PROGRESS,
  IS_SET 
)    DL_IN_PROGRESS=((IS_SET=(((CMD_PROCESSOR_PARAM_U32) & (1UL<<((uint32_t)FOTA_CONTEXT_DOWNLOAD_IN_PROGRESS))) == 0UL) ? false : true) == true)? (CMD_PROCESSOR_PARAM_U32 >> 17UL)&0x01:CMD_PROCESSOR_PARAM_U32
#define FOTA_RETREIVE_NEW_FIRMWARE_INFO (   CMD_PROCESSOR_PARAM_U32,
  NEW_FIRMWARE,
  IS_SET 
)    NEW_FIRMWARE=((IS_SET=(((CMD_PROCESSOR_PARAM_U32) & (1UL<<((uint32_t)FOTA_CONTEXT_NEW_FIRMWARE))) == 0UL) ? false : true) == true)? (CMD_PROCESSOR_PARAM_U32 >> 16UL)&0x01:CMD_PROCESSOR_PARAM_U32
#define FOTA_RETREIVE_STATE_INFO (   CMD_PROCESSOR_PARAM_U32,
  STATE,
  IS_SET 
)    STATE=((IS_SET = (((CMD_PROCESSOR_PARAM_U32) & (1UL<<((uint32_t)FOTA_CONTEXT_STATE))) == 0UL) ? false : true) == true)? (CMD_PROCESSOR_PARAM_U32 >> 8UL)&0xFF:CMD_PROCESSOR_PARAM_U32
#define FOTA_RETREIVE_UPDATE_RESULT_INFO (   CMD_PROCESSOR_PARAM_U32,
  UPDATE_RESULT,
  IS_SET 
)    UPDATE_RESULT=((IS_SET=(((CMD_PROCESSOR_PARAM_U32) & (1UL<<((uint32_t)FOTA_CONTEXT_CURRENT_RESULT))) == 0UL) ? false : true) == true)? (CMD_PROCESSOR_PARAM_U32 >> 20UL)&0x0F:CMD_PROCESSOR_PARAM_U32
#define FOTA_RETREIVE_URL_TYPE (   CMD_PROCESSOR_PARAM_U32,
  URL_TYPE,
  IS_SET 
)    URL_TYPE=((IS_SET=(((CMD_PROCESSOR_PARAM_U32) & (1UL<<((uint32_t)FOTA_CONTEXT_URL))) == 0UL) ? false : true) == true)? (CMD_PROCESSOR_PARAM_U32 >> 18UL)&0x01:CMD_PROCESSOR_PARAM_U32
#define FOTA_SET_DL_IN_PROGRESS (   CMD_PROCESSOR_PARAM_U32,
  DL_IN_PROGRESS 
)    CMD_PROCESSOR_PARAM_U32=(((uint32_t)((CMD_PROCESSOR_PARAM_U32 & 0xFFFDFFFF) | ((0x00020000 & ((uint32_t) DL_IN_PROGRESS << 17UL)))) | (1UL<<((uint32_t)FOTA_CONTEXT_DOWNLOAD_IN_PROGRESS))))
#define FOTA_SET_NEW_FIRMWARE (   CMD_PROCESSOR_PARAM_U32,
  NEW_FIRMWARE 
)    CMD_PROCESSOR_PARAM_U32=(((uint32_t)((CMD_PROCESSOR_PARAM_U32 & 0xFFFEFFFF) | ((0x00010000 & ((uint32_t) NEW_FIRMWARE << 16UL)))) | (1UL<<((uint32_t)FOTA_CONTEXT_NEW_FIRMWARE))))
#define FOTA_SET_STATE (   CMD_PROCESSOR_PARAM_U32,
  STATE 
)    CMD_PROCESSOR_PARAM_U32=(((uint32_t)((CMD_PROCESSOR_PARAM_U32 & 0xFFFF00FF) | ((0x0000FF00 & ((uint32_t) STATE << 8UL)))) | (1UL<<((uint32_t)FOTA_CONTEXT_STATE))))
Note
Below is a set of guard macros to represent the FOTA state machine environment variables. These are mapped to persistent memory based on need.

To improve the code efficiency, a bit-wise operator macro set is used instead of other options (for ex. the bit fields in combination with union).

All the necessary FOTA state machine environment variable changes are mapped into an unsigned 32 bit variable.

The overview is as below:

|b31|b30|b29|b28|b27|b26|b25|b24|b23|b22|b21|b20|b19|b18|b17|b16|b15|b14|b13|b12|b11|b10| b9| b8| b7| b6| b5| b4| b3| b2| b1| b0|

|___________________________| |___________| | | | | |___________________________| |___________________________| | | | | | | | | | | | | | | | v | | | | | | | bit fields representing if a FOTA state machine | | | | | | | environment variables needs to be changed. | | | | | | | Represents the FotaStateMachine_ContextInfo_T | | | | | | | from right to left (only b0 to b4 are used now, | | | | | | | b5 to b7 are used - reserved for future use). | | | | | | v | | | | | | 1 byte representing the FotaStateMachine_State_T value (FOTA_CONTEXT_STATE). | | | | | v | | | | | 1 bit representing the value of the flag representing if a new firmware is available (FOTA_CONTEXT_NEW_FIRMWARE). | | | | v | | | | 1 bit representing the value of the flag representing if download is in progress (FOTA_CONTEXT_DOWNLOAD_IN_PROGRESS). | | | v | | | 1 bit representing the value of the flag representing if empty (on 0) or valid URL (on 1) is to be written (FOTA_CONTEXT_URL). | | v | | Unused (reserved for future use) | v | 1 nibble representing the FOTA firmware update result value (LWM2MObjectFirmwareUpdate_UpdateResult_E) v unused (reserved for future use)

Since there are 5 valid FotaStateMachine_ContextInfo_T values, there are 5 pair of macros to set and retrieve the individual values.

#define FOTA_SET_UPDATE_RESULT (   CMD_PROCESSOR_PARAM_U32,
  UPDATE_RESULT 
)    CMD_PROCESSOR_PARAM_U32=(((uint32_t)((CMD_PROCESSOR_PARAM_U32 & 0xFF0FFFFF) | ((0x00F00000 & ((uint32_t) UPDATE_RESULT << 20UL)))) | (1UL<<((uint32_t)FOTA_CONTEXT_CURRENT_RESULT))))
#define FOTA_SET_URL_TYPE (   CMD_PROCESSOR_PARAM_U32,
  URL_TYPE 
)    CMD_PROCESSOR_PARAM_U32=(((uint32_t)((CMD_PROCESSOR_PARAM_U32 & 0xFFFBFFFF) | ((0x00040000 & ((uint32_t) URL_TYPE << 18UL)))) | (1UL<<((uint32_t)FOTA_CONTEXT_URL))))

Typedef Documentation

Enumeration Type Documentation

Enumerator
FOTA_CONTEXT_STATE 
FOTA_CONTEXT_NEW_FIRMWARE 
FOTA_CONTEXT_DOWNLOAD_IN_PROGRESS 
FOTA_CONTEXT_URL 
FOTA_CONTEXT_CURRENT_RESULT 
FOTA_CONTEXT_DOWNLOAD_CRC 
FOTA_CONTEXT_MAX 
Enumerator
FOTA_IDLE 
FOTA_FAILED_NOTIFY 
FOTA_DOWNLOADING_READY_FOR_REQUEST 
FOTA_DOWNLOADING_NOTIFY 
FOTA_DOWNLOADING_WAITING_FOR_RESPONSE 
FOTA_DOWNLOADING_PROCESSING_RESPONSE 
FOTA_DOWNLOADING_SUSPEND 
FOTA_DOWNLOADING_RESUME 
FOTA_DOWNLOADED 
FOTA_UPDATING_NOTIFY 
FOTA_UPDATING 
FOTA_INVALID 
FOTA_STATE_NOT_IN_USERPAGE 

Function Documentation

static bool FotaIsStateChangePermitted ( FotaStateMachine_State_T  state)
static
Parameters
[in]statestate to be changed.
Return values
boolboolean representing if the state change is permitted or not.
See also
FotaStateTransitionTable
static retcode_t FotaPackageResource ( Lwm2mSerializer_T serializerPntr,
Lwm2mParser_T parserPntr 
)
static
Parameters
[in]serializer_ptrReference to a CoapSerializer_T object which identifies the current instance of serializing context which should be used for serializing. It has to be a valid pointer.
[in]parser_ptrReference to a parser_ptr object which represents current outgoing message.
Return values
retcode_tRC_OK, if successful RC_LWM2M_BAD_REQUEST otherwise.
static retcode_t FotaStateMachine_Update ( Lwm2mSerializer_T serializerPntr,
Lwm2mParser_T parserPntr 
)
static
Parameters
[in]serializer_ptrReference to a CoapSerializer_T object which identifies the current instance of serializing context which should be used for serializing. It has to be a valid pointer.
[in]parser_ptrReference to a parser_ptr object which represents current outgoing message.
Return values
retcode_tRC_OK, if successful RC_LWM2M_BAD_REQUEST otherwise.
static retcode_t FotaStateMachine_UriDownload ( Lwm2mSerializer_T serializerPntr,
Lwm2mParser_T parserPntr 
)
static
Parameters
[in]serializer_ptrReference to a CoapSerializer_T object which identifies the current instance of serializing context which should be used for serializing. It has to be a valid pointer.
[in]parser_ptrReference to a parser_ptr object which represents current outgoing message.
Return values
retcode_tRC_OK, if successful RC_LWM2M_PARSING_ERROR, if data could not be parsed properly. RC_LWM2M_METHOD_NOT_ALLOWED, if invalid pointer passed.

All rights reserved. The use is subject to the XDK SDK EULA by Bosch Connected Devices and Solutions GmbH.
This documentation file has been automatically generated on Thu Mar 14 2019 19:12:40 by doxygen 1.8.8