Macros | Functions | Variables
LWM2MObjectDevice.c File Reference

This file provides implementation for LWM2MObjectDevice module. More...

#include "XdkCommonInfo.h"
#include "LWM2MObjectDevice.h"
#include <Serval_Clock.h>
#include <em_system.h>
#include "em_usb.h"
#include <BCDS_FWContainer.h>
#include "BCDS_EFM32XXPartitionAgent.h"
#include <XdkVersion.h>
#include "LWM2MObjectSensorDevice.h"
#include "LWM2MObjects.h"
#include "BatteryMonitor.h"
#include "BCDS_BSP_Charger_BQ2407X.h"
#include "LWM2M.h"
#include "XDK_SNTP.h"
#include "XDK_Utils.h"
+ Include dependency graph for LWM2MObjectDevice.c:

Macros

#define BATTERY_FULL_VOLTAGE   UINT32_C(4650) /* */
 
#define BCDS_MODULE_ID   XDK_COMMON_ID_LWM2MOBJECTDEVICE
 
#define DEVICE_RESOURCES_INDEX(res)   LWM2M_RESOURCES_INDEX(LWM2MObjectDeviceResources, res)
 
#define LWM2M_DEVICE_MANUFACTURER_NAME_S   "Bosch BCDS"
 
#define LWM2M_DEVICE_MODEL_NUMBER_S   "XDK110"
 
#define LWM2M_DEVICE_TIMEZONE_DEFAULT_S   "Europe/Berlin"
 
#define LWM2M_DEVICE_UTC_OFFSET_DEFAULT_S   "UTC+2"
 
#define LWM2M_EIGHT_U32   (UINT32_C(8))
 
#define LWM2M_ONE_U32   (UINT32_C(1))
 
#define LWM2M_STRING_CAPITAL_Q   ("Q")
 
#define LWM2M_STRING_CAPITAL_S   ("S")
 
#define LWM2M_STRING_CAPITAL_SQ   ("SQ")
 
#define LWM2M_STRING_CAPITAL_U   ("U")
 
#define LWM2M_STRING_CAPITAL_UQ   ("UQ")
 
#define LWM2M_STRING_CAPITAL_UQS   ("UQS")
 
#define LWM2M_STRING_CAPITAL_US   ("US")
 
#define LWM2M_STRING_NULL   ("\0")
 
#define LWM2M_THREE_U32   (UINT32_C(3))
 
#define LWM2M_TWO_U32   (UINT32_C(2))
 
#define LWM2M_ZERO_U32   (UINT32_C(0))
 
#define LWM2MOBJECTS_SMS_LENGTH   UINT32_C(1)
 
#define LWM2MOBJECTS_SMS_QUEUED_LENGTH   UINT32_C(2)
 
#define LWM2MOBJECTS_UDP_AND_SMS_LENGTH   UINT32_C(2)
 
#define LWM2MOBJECTS_UDP_LENGTH   UINT32_C(1)
 
#define LWM2MOBJECTS_UDP_QUEUED_AND_SMS_LENGTH   UINT32_C(3)
 
#define LWM2MOBJECTS_UDP_QUEUED_LENGTH   UINT32_C(2)
 
#define MAXIMUM_LENGTH_OF_FIRMVERSION   UINT8_C(16)
 
#define MAXIMUM_LENGTH_OF_FIRMWAREVERSION   UINT8_C(26)
 
#define MAXIMUM_LENGTH_OF_MODELNUMBER   UINT8_C(16)
 
#define MAXIMUM_LENGTH_OF_SERIALNUMBER   UINT8_C(17)
 
#define MAXIMUM_LENGTH_OF_TIMEZONE   UINT8_C(40)
 
#define MAXIMUM_LENGTH_OF_UTCOFFSET   UINT8_C(10)
 
#define POWER_SOURCE_BATTERY   1 /* 1: Internal Battery */
 
#define POWER_SOURCE_USB   5 /* 1: USB Powered */
 
#define POWER_SOURCES_COUNT   2
 
#define STRING_LENGTH   UINT8_C(19)
 
#define STRING_RESOURCES_MAX_LENGTH   UINT32_C(50)
 

Functions

static retcode_t availablePowerSourcesfunc (Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
 This function is used to update the Available Power Sources Resource value into the LWM2M Server*. More...
 
static retcode_t batteryLevelFunc (Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
 This function is used to update the batteryLevel Resource value into the LWM2M Server*. More...
 
static retcode_t batteryStatusFunc (Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
 This function is used to update the battery Status Resource value into the LWM2M Server*. More...
 
static uint8_t * convDecToStr (uint8_t data, uint8_t *str)
 Convert Decimal/Hex value to String Format to display Version Information. More...
 
uint8_t * convert32IntegerToVersionString (uint32_t appVersion, uint32_t xdkVersion, uint8_t *str)
 This function is to convert the integer data into a string data. More...
 
static retcode_t deviceRebootFunc (Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
 This function is used to update the deviceReboot Resource value into the LWM2M Server*. More...
 
static retcode_t errorCodeFunc (Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
 This function is used to update the errorCode Resource value into the LWM2M Server*. More...
 
static retcode_t factoryResetFunc (Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
 This function is used to update the factoryReset Resource value into the LWM2M Server*. More...
 
static retcode_t firmwareVersionNumber_RO (Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
 This function is used to set the firmware version number present as part of the firmware binary from the Server. More...
 
static retcode_t getCurrentTime (Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
 This function is used to update the currentTime Resource value into the LWM2M Server*. More...
 
static retcode_t getTimeZone (Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
 This function is used to update the tzone Resource value into the LWM2M Server*. More...
 
static retcode_t lwm2mDeviceGetBinding (Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
 This function is used to update the getBinding Resource value into the LWM2M Server*. More...
 
static retcode_t lwm2mDeviceUtcOffset (Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
 
void LWM2MObjectDevice_Enable (void)
 Enable LWM2M object instance. Start reporting values. Function is thread safe, it schedules a job for serval. Execution may therefore be deferred. More...
 
void LWM2MObjectDevice_Init (void)
 Initialize LWM2M object instance. Must be called before any other function call. More...
 
void LWM2MObjectDevice_NotifyTimeChanged (void)
 notify that the device time has changed. Will send a notification to observers. Function is thread safe, it schedules a job for serval. Execution may therefore be deferred. More...
 
static retcode_t powerSourceVoltageFunc (Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
 This function is used to update the Power source Voltage Resource value into the LWM2M Server*. More...
 
static retcode_t resetErrorCodeFunc (Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
 This function is used to update the resetErrorCode Resource value into the LWM2M Server*. More...
 
static retcode_t serialNumber_RO (Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
 This function is used to set the device serial number resource with the XDK CoreID in the LWM2M Server*. More...
 
static retcode_t util_serialize_array (Lwm2mSerializer_T *serializer_ptr, int count, int32_t values[])
 This function is used to update the errorCode Resource value into the LWM2M Server*. More...
 

Variables

static uint8_t DeviceFirmwareVersion [MAXIMUM_LENGTH_OF_FIRMWAREVERSION] = { 0 }
 
static const char DeviceManufacturer [] = LWM2M_DEVICE_MANUFACTURER_NAME_S
 
static const char DeviceModelNumber [MAXIMUM_LENGTH_OF_MODELNUMBER] = LWM2M_DEVICE_MODEL_NUMBER_S
 
static char DeviceSerialNumber [MAXIMUM_LENGTH_OF_SERIALNUMBER] = { 0 }
 
static char DeviceTimezone [MAXIMUM_LENGTH_OF_TIMEZONE] = LWM2M_DEVICE_TIMEZONE_DEFAULT_S
 
static char DeviceUtcOffset [MAXIMUM_LENGTH_OF_UTCOFFSET] = LWM2M_DEVICE_UTC_OFFSET_DEFAULT_S
 
static int32_t error_codes [5] = { 0, 0, 0, 0, 0 }
 
static int error_codes_count = 1
 
static const StringDescr_T Lwm2m_deviceBindingAttributes []
 Structure for device binding attributes. Refer enum Lwm2m_Binding_E under Serval_Lwm2m.h to check the mapped stings. More...
 
static StringDescr_T Lwm2m_tzone
 
static StringDescr_T Lwm2m_utcOffset
 
LWM2MObjectDevice_Resources_T LWM2MObjectDeviceResources
 
static volatile bool started = false
 

Macro Definition Documentation

#define BATTERY_FULL_VOLTAGE   UINT32_C(4650) /* */
#define BCDS_MODULE_ID   XDK_COMMON_ID_LWM2MOBJECTDEVICE
#define DEVICE_RESOURCES_INDEX (   res)    LWM2M_RESOURCES_INDEX(LWM2MObjectDeviceResources, res)
#define LWM2M_DEVICE_MANUFACTURER_NAME_S   "Bosch BCDS"
#define LWM2M_DEVICE_MODEL_NUMBER_S   "XDK110"
#define LWM2M_DEVICE_TIMEZONE_DEFAULT_S   "Europe/Berlin"
#define LWM2M_DEVICE_UTC_OFFSET_DEFAULT_S   "UTC+2"
#define LWM2M_EIGHT_U32   (UINT32_C(8))
#define LWM2M_ONE_U32   (UINT32_C(1))

unsigned integer value 1

#define LWM2M_STRING_CAPITAL_Q   ("Q")

string "Q" representation

#define LWM2M_STRING_CAPITAL_S   ("S")

string "S" representation

#define LWM2M_STRING_CAPITAL_SQ   ("SQ")

string "SQ" representation

#define LWM2M_STRING_CAPITAL_U   ("U")

string "U" representation

#define LWM2M_STRING_CAPITAL_UQ   ("UQ")

string "UQ" representation

#define LWM2M_STRING_CAPITAL_UQS   ("UQS")

string "UQS" representation

#define LWM2M_STRING_CAPITAL_US   ("US")

string "US" representation

#define LWM2M_STRING_NULL   ("\0")

string "X" representation

#define LWM2M_THREE_U32   (UINT32_C(3))

unsigned integer value 3

#define LWM2M_TWO_U32   (UINT32_C(2))

unsigned integer value 2

#define LWM2M_ZERO_U32   (UINT32_C(0))

unsigned integer value 0

#define LWM2MOBJECTS_SMS_LENGTH   UINT32_C(1)
#define LWM2MOBJECTS_SMS_QUEUED_LENGTH   UINT32_C(2)
#define LWM2MOBJECTS_UDP_AND_SMS_LENGTH   UINT32_C(2)
#define LWM2MOBJECTS_UDP_LENGTH   UINT32_C(1)
#define LWM2MOBJECTS_UDP_QUEUED_AND_SMS_LENGTH   UINT32_C(3)
#define LWM2MOBJECTS_UDP_QUEUED_LENGTH   UINT32_C(2)
#define MAXIMUM_LENGTH_OF_FIRMVERSION   UINT8_C(16)
#define MAXIMUM_LENGTH_OF_FIRMWAREVERSION   UINT8_C(26)
#define MAXIMUM_LENGTH_OF_MODELNUMBER   UINT8_C(16)

Unware which model number we're going to use (HW/SW) but 16 bytes should be enough

#define MAXIMUM_LENGTH_OF_SERIALNUMBER   UINT8_C(17)

Same as BSE ID which is 13 bytes

#define MAXIMUM_LENGTH_OF_TIMEZONE   UINT8_C(40)

The maximum length occupied by a timezone from the IANA database is 32. The length is set to 40 just to accommodate few more characters, if the database is updated in future.

#define MAXIMUM_LENGTH_OF_UTCOFFSET   UINT8_C(10)

As per ISO 8061 Expected not exceed 9 bytes

#define POWER_SOURCE_BATTERY   1 /* 1: Internal Battery */
#define POWER_SOURCE_USB   5 /* 1: USB Powered */
#define POWER_SOURCES_COUNT   2
#define STRING_LENGTH   UINT8_C(19)
#define STRING_RESOURCES_MAX_LENGTH   UINT32_C(50)

Function Documentation

static retcode_t availablePowerSourcesfunc ( Lwm2mSerializer_T serializer_ptr,
Lwm2mParser_T parser_ptr 
)
static

+ Here is the call graph for this function:

static retcode_t batteryLevelFunc ( Lwm2mSerializer_T serializer_ptr,
Lwm2mParser_T parser_ptr 
)
static

+ Here is the call graph for this function:

static retcode_t batteryStatusFunc ( Lwm2mSerializer_T serializer_ptr,
Lwm2mParser_T parser_ptr 
)
static

+ Here is the call graph for this function:

static uint8_t* convDecToStr ( uint8_t  data,
uint8_t *  str 
)
static
Parameters
[in]dataNumber which needs to be convert into string to display in Decimal instead of HEX values.
in/out]*str pointer to Store/write the Version number in String Format.

+ Here is the caller graph for this function:

uint8_t* convert32IntegerToVersionString ( uint32_t  appVersion,
uint32_t  xdkVersion,
uint8_t *  str 
)
Parameters
[in]appVersion32 bit value containing the FOTA version information
[in]xdkVersion32 bit value containing the XDK SW version information
in/out]str pointer to the parsed version string
[out]Returnsindex where the application version starts

1. FOTA capable device only has the Valid application firmware version in that case output format will be example:v3.0.1-0.0.1( XDK Version + Application version)

  1. For Non- FOTA capable device version number will be v3.0.1-xx.xx.xx( XDK Version-xx.xx.xx)
  2. Also note that the XDK version number is represented in Decimal format (i.e if XDK version is 3.0.1).
    the following macros maintain to represent the XDK SW release version #define XDKVERSION_MAJOR 3 #define XDKVERSION_MINOR 0 #define XDKVERSION_PATCH 1
  3. Also note that the Application version number is represented in Decimal format. example: if user modifies the application version value macros under application.mk as follows MAJOR_SW_NO ?= 0xFF MINOR_SW_NO ?= 0xFF PATCH_SW_NO ?= 0xFF so, the appVersion will be represented as 255.255.255

+ Here is the call graph for this function:

static retcode_t deviceRebootFunc ( Lwm2mSerializer_T serializer_ptr,
Lwm2mParser_T parser_ptr 
)
static

+ Here is the call graph for this function:

static retcode_t errorCodeFunc ( Lwm2mSerializer_T serializer_ptr,
Lwm2mParser_T parser_ptr 
)
static

+ Here is the call graph for this function:

static retcode_t factoryResetFunc ( Lwm2mSerializer_T serializer_ptr,
Lwm2mParser_T parser_ptr 
)
static
static retcode_t firmwareVersionNumber_RO ( Lwm2mSerializer_T serializer_ptr,
Lwm2mParser_T parser_ptr 
)
static

+ Here is the call graph for this function:

static retcode_t getCurrentTime ( Lwm2mSerializer_T serializer_ptr,
Lwm2mParser_T parser_ptr 
)
static

+ Here is the call graph for this function:

static retcode_t getTimeZone ( Lwm2mSerializer_T serializer_ptr,
Lwm2mParser_T parser_ptr 
)
static

+ Here is the call graph for this function:

static retcode_t lwm2mDeviceGetBinding ( Lwm2mSerializer_T serializer_ptr,
Lwm2mParser_T parser_ptr 
)
static

+ Here is the call graph for this function:

static retcode_t lwm2mDeviceUtcOffset ( Lwm2mSerializer_T serializer_ptr,
Lwm2mParser_T parser_ptr 
)
static

The description is in the configuration header

+ Here is the call graph for this function:

void LWM2MObjectDevice_Enable ( void  )

Refer interface header for description

void LWM2MObjectDevice_Init ( void  )

Refer interface header for description

+ Here is the call graph for this function:

void LWM2MObjectDevice_NotifyTimeChanged ( void  )

Refer interface header for description

+ Here is the call graph for this function:

static retcode_t powerSourceVoltageFunc ( Lwm2mSerializer_T serializer_ptr,
Lwm2mParser_T parser_ptr 
)
static

+ Here is the call graph for this function:

static retcode_t resetErrorCodeFunc ( Lwm2mSerializer_T serializer_ptr,
Lwm2mParser_T parser_ptr 
)
static

+ Here is the call graph for this function:

static retcode_t serialNumber_RO ( Lwm2mSerializer_T serializer_ptr,
Lwm2mParser_T parser_ptr 
)
static

+ Here is the call graph for this function:

static retcode_t util_serialize_array ( Lwm2mSerializer_T serializer_ptr,
int  count,
int32_t  values[] 
)
static

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

uint8_t DeviceFirmwareVersion[MAXIMUM_LENGTH_OF_FIRMWAREVERSION] = { 0 }
static
const char DeviceManufacturer[] = LWM2M_DEVICE_MANUFACTURER_NAME_S
static
const char DeviceModelNumber[MAXIMUM_LENGTH_OF_MODELNUMBER] = LWM2M_DEVICE_MODEL_NUMBER_S
static
char DeviceSerialNumber[MAXIMUM_LENGTH_OF_SERIALNUMBER] = { 0 }
static
int32_t error_codes[5] = { 0, 0, 0, 0, 0 }
static
int error_codes_count = 1
static
const StringDescr_T Lwm2m_deviceBindingAttributes[]
static
Initial value:
=
{
}
#define LWM2M_STRING_CAPITAL_U
Definition: LWM2MObjectDevice.c:117
#define LWM2M_STRING_CAPITAL_UQ
Definition: LWM2MObjectDevice.c:118
#define LWM2M_STRING_CAPITAL_S
Definition: LWM2MObjectDevice.c:119
#define LWM2M_STRING_NULL
Definition: LWM2MObjectDevice.c:115
#define LWM2M_THREE_U32
Definition: LWM2MObjectDevice.c:112
#define LWM2M_STRING_CAPITAL_US
Definition: LWM2MObjectDevice.c:121
#define LWM2M_ONE_U32
Definition: LWM2MObjectDevice.c:110
#define LWM2M_TWO_U32
Definition: LWM2MObjectDevice.c:111
#define LWM2M_STRING_CAPITAL_UQS
Definition: LWM2MObjectDevice.c:122
#define LWM2M_STRING_CAPITAL_SQ
Definition: LWM2MObjectDevice.c:120
StringDescr_T Lwm2m_tzone
static
Initial value:
=
{
.start = DeviceTimezone,
.length = sizeof(DeviceTimezone)
}
static char DeviceTimezone[MAXIMUM_LENGTH_OF_TIMEZONE]
Definition: LWM2MObjectDevice.c:139
StringDescr_T Lwm2m_utcOffset
static
Initial value:
=
{
.start = DeviceUtcOffset,
.length = sizeof(DeviceUtcOffset)
}
static char DeviceUtcOffset[MAXIMUM_LENGTH_OF_UTCOFFSET]
Definition: LWM2MObjectDevice.c:138
LWM2MObjectDevice_Resources_T LWM2MObjectDeviceResources
Initial value:
=
{
}
static const char DeviceModelNumber[MAXIMUM_LENGTH_OF_MODELNUMBER]
Definition: LWM2MObjectDevice.c:134
static retcode_t availablePowerSourcesfunc(Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
This function is used to update the Available Power Sources Resource value into the LWM2M Server*...
Definition: LWM2MObjectDevice.c:573
static retcode_t factoryResetFunc(Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
This function is used to update the factoryReset Resource value into the LWM2M Server*.
Definition: LWM2MObjectDevice.c:366
static retcode_t getTimeZone(Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
This function is used to update the tzone Resource value into the LWM2M Server*.
Definition: LWM2MObjectDevice.c:507
static retcode_t batteryLevelFunc(Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
This function is used to update the batteryLevel Resource value into the LWM2M Server*.
Definition: LWM2MObjectDevice.c:659
static retcode_t firmwareVersionNumber_RO(Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
This function is used to set the firmware version number present as part of the firmware binary from ...
Definition: LWM2MObjectDevice.c:325
#define LWM2M_READ_ONLY
Definition: Serval_Lwm2m.h:218
#define LWM2M_DYNAMIC(dyn)
Definition: Serval_Lwm2m.h:105
static retcode_t powerSourceVoltageFunc(Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
This function is used to update the Power source Voltage Resource value into the LWM2M Server*...
Definition: LWM2MObjectDevice.c:612
static retcode_t deviceRebootFunc(Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
This function is used to update the deviceReboot Resource value into the LWM2M Server*.
Definition: LWM2MObjectDevice.c:347
static retcode_t lwm2mDeviceGetBinding(Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
This function is used to update the getBinding Resource value into the LWM2M Server*.
Definition: LWM2MObjectDevice.c:547
static retcode_t serialNumber_RO(Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
This function is used to set the device serial number resource with the XDK CoreID in the LWM2M Serve...
Definition: LWM2MObjectDevice.c:308
#define LWM2M_STRING_RO(string)
Definition: Serval_Lwm2m.h:95
static retcode_t getCurrentTime(Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
This function is used to update the currentTime Resource value into the LWM2M Server*.
Definition: LWM2MObjectDevice.c:417
static retcode_t lwm2mDeviceUtcOffset(Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
Definition: LWM2MObjectDevice.c:471
#define LWM2M_FUNCTION(function)
Definition: Serval_Lwm2m.h:109
static retcode_t errorCodeFunc(Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
This function is used to update the errorCode Resource value into the LWM2M Server*.
Definition: LWM2MObjectDevice.c:378
static retcode_t resetErrorCodeFunc(Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
This function is used to update the resetErrorCode Resource value into the LWM2M Server*.
Definition: LWM2MObjectDevice.c:392
static const char DeviceManufacturer[]
Definition: LWM2MObjectDevice.c:133
#define LWM2M_DYNAMIC_ARRAY(dyn)
Definition: Serval_Lwm2m.h:107
static retcode_t batteryStatusFunc(Lwm2mSerializer_T *serializer_ptr, Lwm2mParser_T *parser_ptr)
This function is used to update the battery Status Resource value into the LWM2M Server*.
Definition: LWM2MObjectDevice.c:695
volatile bool started = false
static

This documentation file has been automatically generated on Fri Oct 4 2019 03:47:00 by doxygen 1.8.8