XDK API  3.6.0
Documentation
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
AppTxtParser.c File Reference
#include "XdkAppInfo.h"
#include "AppTxtParser.h"
#include <stdio.h>
#include "AppController.h"
#include "BCDS_Assert.h"
+ Include dependency graph for AppTxtParser.c:

Data Structures

struct  AppTxtParser_ConfigLine_S
 

Macros

#define APP_TXT_PARSER_EMPTY   ""
 
#define APP_TXT_PARSER_LINE_SIZE_MAX   UINT8_C(65)
 
#define APP_TXT_PARSER_NO   "NO"
 
#define APP_TXT_PARSER_SPACE   "\t "
 
#define APP_TXT_PARSER_WHITESPACE   "\t\n\r "
 
#define APP_TXT_PARSER_YES   "YES"
 
#define ATP_EXPANDED_LENGTH   UINT8_C(65)
 
#define ATP_MAC_LENGTH   UINT8_C(18)
 
#define ATP_MAGIC_EP_EXPAND   "#-LWM2M-EP-#"
 
#define ATP_MAGIC_MAC_EXPAND   "#---MAC----#"
 
#define BCDS_MODULE_ID   XDK_APP_MODULE_ID_APP_TXT_PARSER
 
#define LWM2M_CON_NOTIFIES_TXT_DEFAULT   APP_TXT_PARSER_NO
 
#define LWM2M_TESTMODE_MIX   UINT8_C(2)
 
#define LWM2M_TESTMODE_OFF   UINT8_C(0)
 
#define LWM2M_TESTMODE_ON   UINT8_C(1)
 
#define WLAN_STATIC_IP_TXT_DEFAULT   APP_TXT_PARSER_NO
 

Typedefs

typedef struct
AppTxtParser_ConfigLine_S 
AppTxtParser_ConfigLine_T
 
typedef enum AppTxtParser_States_E AppTxtParser_States_T
 
typedef enum
AppTxtParser_TokensType_E 
AppTxtParser_TokensType_T
 

Enumerations

enum  AppTxtParser_ConfigArrayIndex_E
 
enum  AppTxtParser_States_E
 
enum  AppTxtParser_TokensType_E
 

Functions

const char * AppTxtParser_DTLSPSKIdentityValue (void)
 returns the DTLS/PSK identity of the configuration file More...
 
uint32_t AppTxtParser_DTLSPSKSecretKeyLengthValue (void)
 returns the DTLS/PSK secret key length of the configuration file More...
 
const char * AppTxtParser_DTLSPSKSecretKeyValue (void)
 returns the DTLS/PSK secret key of the configuration file More...
 
Retcode_T AppTxtParser_Initialize (AppTxtParser_Init_T *initCredentials)
 Parse the config file read inside the buffer. More...
 
const char * AppTxtParser_LWM2MBindingValue (void)
 returns lwm2m binding value More...
 
bool AppTxtParser_LWM2MConNotifiesValue (void)
 returns the Lwm2m connection notify value More...
 
const char * AppTxtParser_LWM2MEndPointValue (void)
 returns attribute value for the token LWM2MENDPOINT as defined at the configuration file More...
 
bool AppTxtParser_LWM2MIsSecureValue (void)
 This function checks whether the lwm2m is secure or not based on the url. More...
 
uint32_t AppTxtParser_LWM2MLifetimeValue (void)
 returns lwm2m lifetime in seconds. More...
 
const char * AppTxtParser_LWM2MMACAddrValue (void)
 returns MAC address value for Lwm2m More...
 
uint32_t AppTxtParser_LWM2MServerPortValue (void)
 returns the port value extracted from the server url More...
 
const char * AppTxtParser_LWM2MServerURLValue (void)
 returns attribute value for the token LWM2MDERSRV as defined at the configuration file More...
 
uint8_t AppTxtParser_LWM2MTestModeValue (void)
 Returns the current configuration for the field TESTMODE set in the *.txt file. More...
 
void AppTxtParser_PrintConfigurations (const char *title, bool defaultsOnly)
 Print list of configured values. More...
 
uint32_t AppTxtParser_WLANDnsAddrValue (void)
 returns attribute value for the token DNSSERVER as defined at the configuration file More...
 
uint32_t AppTxtParser_WLANGwAddrValue (void)
 returns attribute value for the token GATEWAY as defined at the configuration file More...
 
uint32_t AppTxtParser_WLANIpAddrValue (void)
 returns attribute value for the token DNSSERVER as defined at the configuration file More...
 
uint32_t AppTxtParser_WLANMaskValue (void)
 returns attribute value for the token MASK as defined at the configuration file More...
 
const char * AppTxtParser_WLANPasswordValue (void)
 returns attribute value for the token PASSWORD as defined at the configuration file More...
 
const char * AppTxtParser_WLANSsidValue (void)
 returns the attribute value for the token SSID as defined at the configuration file More...
 
bool AppTxtParser_WLANStaticIpValue (void)
 returns attribute value for the token STATICIP as defined at the configuration file More...
 
static const char * AppTxtParserDTLSPSKIdentityValue (void)
 
static const char * AppTxtParserDTLSPSKSecretKeyHexValue (void)
 
static const char * AppTxtParserDTLSPSKSecretKeyValue (void)
 
static bool AppTxtParserInitialize (AppTxtParser_Init_T *initCredentials)
 Parse the config file read inside the buffer. More...
 
static const char * AppTxtParserLWM2MDefaultServerValue (void)
 
static const char * AppTxtParserLWM2MEndPointValue (void)
 
static void AppTxtParserReset (void)
 
static unsigned int ATPDecodeHexToBin (const char *source, char *dest, bool terminatedString)
 Decode hexadecimal string to binary buffer. More...
 
static bool ATPEmptyCfg (const char *value)
 
static void ATPExpandToken (const char *value, const char *magicToken, const char *expand, char *expandedValue, size_t expandedSize)
 
static const char * ATPGetAttValue (int index)
 
static AppTxtParser_TokensType_T ATPGetToken (const char *buffer, uint16_t *idxAtBuffer, uint16_t bufSize, char *token, uint16_t *tokenSize, AppTxtParser_States_T expTokenType)
 extracts tokens from the input buffer , copy into the token buffer and returns its size at tokensize More...
 
static int digitHexToBin (char c)
 Convert hexadecimal character/digit to number. More...
 

Variables

static const char A10Name [] = "DTLSPSKIDENTITY"
 
static const char A11Name [] = "DTLSPSKSECRETKEY"
 
static const char A12Name [] = "DTLSPSKSECRETKEYHEX"
 
static const char A13Name [] = "TESTMODE"
 
static const char A14Name [] = "LWM2MLIFETIME"
 
static const char A15Name [] = "LWM2MBINDING"
 
static const char A16Name [] = "LWM2MCONNOTIFIES"
 
static const char A17Name [] = "LWM2MDTLSSUFFIX"
 
static const char A18Name [] = "ACTIVATEDTLSPSK"
 
static const char A1Name [] = "SSID"
 
static const char A2Name [] = "PASSWORD"
 
static const char A3Name [] = "STATIC"
 
static const char A4Name [] = "STATICIP"
 
static const char A5Name [] = "DNSSERVER"
 
static const char A6Name [] = "GATEWAY"
 
static const char A7Name [] = "MASK"
 
static const char A8Name [] = "LWM2MDEFSRV"
 
static const char A9Name [] = "LWM2MENDPOINT"
 
static AppTxtParser_ConfigLine_T ATPConfigStructure [ATP_IDX_SIZE]
 
static char ATPExpandedEndpointName [ATP_EXPANDED_LENGTH] = { 0 }
 
static char ATPExpandedPskIdentity [ATP_EXPANDED_LENGTH] = { 0 }
 
static const char * ATPHexToBin = "0123456789abcdefABCDEF"
 
static char ATPKeyBuffer [ATP_EXPANDED_LENGTH] = { 0 }
 
static char ATPMacAddress [ATP_MAC_LENGTH] = { 0 }
 
static const char * ATPPskIdentityPtr = NULL
 
static uint32_t ATPPskSecretKeyLength = 0UL
 
static const char * ATPPskSecretKeyPtr = NULL
 
static uint32_t ATPServerPort = 0UL
 
static char ATPServerURL [ATP_EXPANDED_LENGTH] = { 0 }
 
static char * ATPServerURLPtr = NULL
 
static char ATPValues [ATP_IDX_SIZE][APP_TXT_PARSER_LINE_SIZE_MAX]
 

Macro Definition Documentation

#define APP_TXT_PARSER_EMPTY   ""
#define APP_TXT_PARSER_LINE_SIZE_MAX   UINT8_C(65)
#define APP_TXT_PARSER_NO   "NO"
#define APP_TXT_PARSER_SPACE   "\t "
#define APP_TXT_PARSER_WHITESPACE   "\t\n\r "
#define APP_TXT_PARSER_YES   "YES"
#define ATP_EXPANDED_LENGTH   UINT8_C(65)

length of expanded lwm2m endpoint name and dtls identity

#define ATP_MAC_LENGTH   UINT8_C(18)

length of MAC as string

#define ATP_MAGIC_EP_EXPAND   "#-LWM2M-EP-#"

Magic token expanded to LWM2M endpoint name

#define ATP_MAGIC_MAC_EXPAND   "#---MAC----#"

Magic token expanded to MAC

#define BCDS_MODULE_ID   XDK_APP_MODULE_ID_APP_TXT_PARSER
#define LWM2M_CON_NOTIFIES_TXT_DEFAULT   APP_TXT_PARSER_NO

LWM2M binding by Default

#define LWM2M_TESTMODE_MIX   UINT8_C(2)
#define LWM2M_TESTMODE_OFF   UINT8_C(0)
#define LWM2M_TESTMODE_ON   UINT8_C(1)
#define WLAN_STATIC_IP_TXT_DEFAULT   APP_TXT_PARSER_NO

Network static IP Address Default

Typedef Documentation

Enumeration Type Documentation

INDEX at the configuration array

Enumerator
ATP_IDX_WLAN_SSID 
ATP_IDX_WLAN_PASSWORD 
ATP_IDX_WLAN_STATIC_IP 
ATP_IDX_WLAN_IP_ADDR 
ATP_IDX_WLAN_DNS_ADDR 
ATP_IDX_WLAN_GW_ADDR 
ATP_IDX_WLAN_MASK 
ATP_IDX_LWM2M_DEFAULT_SERVER 
ATP_IDX_LWM2M_ENDPOINT 
ATP_IDX_DTLS_PSK_IDENTITY 
ATP_IDX_DTLS_PSK_SECRET_KEY 
ATP_IDX_DTLS_PSK_SECRET_KEY_HEX 
ATP_IDX_TEST_MODE 
ATP_IDX_LWM2M_LIFETIME 
ATP_IDX_LWM2M_BINDING 
ATP_IDX_LWM2M_CON_NOTIFIES 
ATP_IDX_LWM2M_DTLS_SUFFIX 
ATP_IDX_ACTIVATE_DTLS_PSK 
ATP_IDX_MAX 
ATP_IDX_SIZE 

The states on the configuration file parser states machine

Enumerator
ATP_STATE_EXP_NONE 
ATP_STATE_EXP_NAME 
ATP_STATE_EXP_EQUAL 
ATP_STATE_EXP_VALUE 

The possible token types

Enumerator
ATP_TOKEN_TYPE_UNKNOWN 
ATP_TOKEN_EOF 
ATP_TOKEN_ATT_NAME 
ATP_TOKEN_EQUAL 
ATP_TOKEN_VALUE 

Function Documentation

const char* AppTxtParser_DTLSPSKIdentityValue ( void  )

Refer interface header for description

+ Here is the caller graph for this function:

uint32_t AppTxtParser_DTLSPSKSecretKeyLengthValue ( void  )

Refer interface header for description

+ Here is the caller graph for this function:

const char* AppTxtParser_DTLSPSKSecretKeyValue ( void  )

Refer interface header for description

+ Here is the caller graph for this function:

Retcode_T AppTxtParser_Initialize ( AppTxtParser_Init_T initCredentials)

Refer interface header for description

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const char* AppTxtParser_LWM2MBindingValue ( void  )

Refer interface header for description

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool AppTxtParser_LWM2MConNotifiesValue ( void  )

Refer interface header for description

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const char* AppTxtParser_LWM2MEndPointValue ( void  )

Refer interface header for description

+ Here is the caller graph for this function:

bool AppTxtParser_LWM2MIsSecureValue ( void  )

Refer interface header for description

+ Here is the caller graph for this function:

uint32_t AppTxtParser_LWM2MLifetimeValue ( void  )

Refer interface header for description

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const char* AppTxtParser_LWM2MMACAddrValue ( void  )

Refer interface header for description

uint32_t AppTxtParser_LWM2MServerPortValue ( void  )

Refer interface header for description

+ Here is the caller graph for this function:

const char* AppTxtParser_LWM2MServerURLValue ( void  )

Refer interface header for description

+ Here is the caller graph for this function:

uint8_t AppTxtParser_LWM2MTestModeValue ( void  )

Refer interface header for description

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AppTxtParser_PrintConfigurations ( const char *  title,
bool  defaultsOnly 
)

Refer interface header for description

+ Here is the caller graph for this function:

uint32_t AppTxtParser_WLANDnsAddrValue ( void  )

Refer interface header for description

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32_t AppTxtParser_WLANGwAddrValue ( void  )

Refer interface header for description

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32_t AppTxtParser_WLANIpAddrValue ( void  )

Refer interface header for description

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32_t AppTxtParser_WLANMaskValue ( void  )

Refer interface header for description

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const char* AppTxtParser_WLANPasswordValue ( void  )

Refer interface header for description

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const char* AppTxtParser_WLANSsidValue ( void  )

Refer interface header for description

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool AppTxtParser_WLANStaticIpValue ( void  )

Refer interface header for description

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static const char* AppTxtParserDTLSPSKIdentityValue ( void  )
static

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static const char* AppTxtParserDTLSPSKSecretKeyHexValue ( void  )
static

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static const char* AppTxtParserDTLSPSKSecretKeyValue ( void  )
static

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool AppTxtParserInitialize ( AppTxtParser_Init_T initCredentials)
static
Parameters
[in]initCredentialscredentials for parsing
Returns
true if configuration file is correct and contains necessary attribute/values

If the secret key is provided in the config.txt, disable the compiled default for secret key hex to ensure, that the provided key is used and not the default hexadecimal key.

If the LWM2M endpoint name is provided in the config.txt, disable the compiled default for DTLS PSK identity to ensure, that the provided LWM2M endpoint name is used and not the default DTLS PSK identity.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static const char* AppTxtParserLWM2MDefaultServerValue ( void  )
static

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static const char* AppTxtParserLWM2MEndPointValue ( void  )
static

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void AppTxtParserReset ( void  )
static

+ Here is the caller graph for this function:

static unsigned int ATPDecodeHexToBin ( const char *  source,
char *  dest,
bool  terminatedString 
)
static
Parameters
[in]sourceHexadecimal string
[out]destBinary destination buffer.
[in]terminatedStringDest should be handled as string (0 terminated)
Returns
number of converted bytes dest (excluding 0 termination, if applied):

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool ATPEmptyCfg ( const char *  value)
static

+ Here is the caller graph for this function:

static void ATPExpandToken ( const char *  value,
const char *  magicToken,
const char *  expand,
char *  expandedValue,
size_t  expandedSize 
)
static

+ Here is the caller graph for this function:

static const char * ATPGetAttValue ( int  index)
static

+ Here is the caller graph for this function:

static AppTxtParser_TokensType_T ATPGetToken ( const char *  buffer,
uint16_t *  idxAtBuffer,
uint16_t  bufSize,
char *  token,
uint16_t *  tokenSize,
AppTxtParser_States_T  expTokenType 
)
static
Parameters
[in]bufferThe input buffer
[in]idxAtBufferThe index from which we have to look after tokens
[in]bufSizeThe size of the input buffer (param one)
[out]tokenThe buffer that will contain the token (must be different to NULL )
[in]expTokenTypeexpected token type awaited from attribute parser
[out]tokenSizeThe pointer to the variable that receive the size of the buffer
Returns
the TOKEN types found (ATP_TOKEN_TYPE_UNKNOWN is EOF)

+ Here is the caller graph for this function:

static int digitHexToBin ( char  c)
static

'0' ... '9' to 0 ... 9 'a' ... 'f' to 10 ... 15 'A' ... 'F' to 10 ... 15

Parameters
[in]ccharacter to be converted
Returns
number, or -1, if provided character wasN::t a valid hexadecimal character.

+ Here is the caller graph for this function:

Variable Documentation

const char A10Name[] = "DTLSPSKIDENTITY"
static
const char A11Name[] = "DTLSPSKSECRETKEY"
static
const char A12Name[] = "DTLSPSKSECRETKEYHEX"
static
const char A13Name[] = "TESTMODE"
static
const char A14Name[] = "LWM2MLIFETIME"
static
const char A15Name[] = "LWM2MBINDING"
static
const char A16Name[] = "LWM2MCONNOTIFIES"
static
const char A17Name[] = "LWM2MDTLSSUFFIX"
static
const char A18Name[] = "ACTIVATEDTLSPSK"
static
const char A1Name[] = "SSID"
static

Variable containers for configuration values Attribute names on the configuration file

const char A2Name[] = "PASSWORD"
static
const char A3Name[] = "STATIC"
static
const char A4Name[] = "STATICIP"
static
const char A5Name[] = "DNSSERVER"
static
const char A6Name[] = "GATEWAY"
static
const char A7Name[] = "MASK"
static
const char A8Name[] = "LWM2MDEFSRV"
static
const char A9Name[] = "LWM2MENDPOINT"
static
AppTxtParser_ConfigLine_T ATPConfigStructure[ATP_IDX_SIZE]
static
Initial value:
=
{
{ A1Name, WLAN_SSID_DEFAULT, false, false, ATPValues[0] },
{ A2Name, WLAN_PASSWORD_DEFAULT, false, false, ATPValues[1] },
{ A4Name, WLAN_IP_ADDR_DEFAULT, false, false, ATPValues[3] },
{ A5Name, WLAN_DNS_ADDR_DEFAULT, false, false, ATPValues[4] },
{ A6Name, WLAN_GW_ADDR_DEFAULT, false, false, ATPValues[5] },
{ A7Name, WLAN_MASK_DEFAULT, false, false, ATPValues[6] },
{ A8Name, LWM2M_DEF_SERVER_DEFAULT, false, false, ATPValues[7] },
{ A13Name, LWM2M_TEST_MODE_DEFAULT, false, false, ATPValues[12] },
{ A14Name, LWM2M_LIFETIME_DEFAULT, false, false, ATPValues[13] },
{ A15Name, LWM2M_BINDING_DEFAULT, false, false, ATPValues[14] },
{ A17Name, APP_TXT_PARSER_EMPTY, true, false, ATPValues[16] },
{ A18Name, APP_TXT_PARSER_EMPTY, true, false, ATPValues[17] },
}
static const char A12Name[]
Definition: AppTxtParser.c:98
#define WLAN_DNS_ADDR_DEFAULT
Definition: AppController.h:97
static const char A2Name[]
Definition: AppTxtParser.c:88
#define LWM2M_DEF_SERVER_DEFAULT
Definition: AppController.h:112
#define LWM2M_DTLS_PSK_SECRET_KEY_DEFAULT
Definition: AppController.h:120
static const char A3Name[]
Definition: AppTxtParser.c:89
static const char A15Name[]
Definition: AppTxtParser.c:101
static const char A8Name[]
Definition: AppTxtParser.c:94
static const char A16Name[]
Definition: AppTxtParser.c:102
#define WLAN_SSID_DEFAULT
Definition: AppController.h:65
static const char A5Name[]
Definition: AppTxtParser.c:91
#define WLAN_IP_ADDR_DEFAULT
Definition: AppController.h:83
#define WLAN_MASK_DEFAULT
Definition: AppController.h:104
static const char A6Name[]
Definition: AppTxtParser.c:92
#define WLAN_PASSWORD_DEFAULT
Definition: AppController.h:71
static const char A13Name[]
Definition: AppTxtParser.c:99
static const char A18Name[]
Definition: AppTxtParser.c:104
static const char A1Name[]
Definition: AppTxtParser.c:87
#define WLAN_STATIC_IP_TXT_DEFAULT
Definition: AppTxtParser.c:64
#define LWM2M_DTLS_PSK_SECRET_KEY_HEX_DEFAULT
Definition: AppController.h:119
static const char A4Name[]
Definition: AppTxtParser.c:90
static const char A7Name[]
Definition: AppTxtParser.c:93
#define LWM2M_ENDPOINT_NAME_DEFAULT
Definition: AppController.h:115
#define LWM2M_DTLS_PSK_IDENTITY_DEFAULT
Definition: AppController.h:118
static const char A9Name[]
Definition: AppTxtParser.c:95
#define WLAN_GW_ADDR_DEFAULT
Definition: AppController.h:90
static const char A17Name[]
Definition: AppTxtParser.c:103
static const char A11Name[]
Definition: AppTxtParser.c:97
#define LWM2M_LIFETIME_DEFAULT
Definition: AppController.h:124
static char ATPValues[ATP_IDX_SIZE][APP_TXT_PARSER_LINE_SIZE_MAX]
Definition: AppTxtParser.c:174
#define LWM2M_CON_NOTIFIES_TXT_DEFAULT
Definition: AppTxtParser.c:70
static const char A14Name[]
Definition: AppTxtParser.c:100
#define LWM2M_TEST_MODE_DEFAULT
Definition: AppController.h:125
static const char A10Name[]
Definition: AppTxtParser.c:96
#define LWM2M_BINDING_DEFAULT
Definition: AppController.h:122
#define APP_TXT_PARSER_EMPTY
Definition: AppTxtParser.c:57
char ATPExpandedEndpointName[ATP_EXPANDED_LENGTH] = { 0 }
static
char ATPExpandedPskIdentity[ATP_EXPANDED_LENGTH] = { 0 }
static
const char* ATPHexToBin = "0123456789abcdefABCDEF"
static
char ATPKeyBuffer[ATP_EXPANDED_LENGTH] = { 0 }
static
char ATPMacAddress[ATP_MAC_LENGTH] = { 0 }
static
const char* ATPPskIdentityPtr = NULL
static
uint32_t ATPPskSecretKeyLength = 0UL
static
const char* ATPPskSecretKeyPtr = NULL
static
uint32_t ATPServerPort = 0UL
static
char ATPServerURL[ATP_EXPANDED_LENGTH] = { 0 }
static
char* ATPServerURLPtr = NULL
static
char ATPValues[ATP_IDX_SIZE][APP_TXT_PARSER_LINE_SIZE_MAX]
static

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:39 by doxygen 1.8.8