WE310F5  39.00.000

This section describes the M2MB APIs for XML module. More...

enum  M2MB_XML_OBJ_TYPE {
  M2MB_XML_COMPLEX_ELEMENT,
  M2MB_XML_SIMPLE_ELEMENT,
  M2MB_XML_ATTRIBUTE,
  M2MB_XML_NONE
}
 Object type supported by the xml. More...
 
enum  M2MB_XML_DATA_TYPE {
  M2MB_XML_DT_NONE,
  M2MB_XML_DT_UINT8,
  M2MB_XML_DT_INT8,
  M2MB_XML_DT_UINT16,
  M2MB_XML_DT_INT16,
  M2MB_XML_DT_UINT32,
  M2MB_XML_DT_INT32,
  M2MB_XML_DT_UINT64,
  M2MB_XML_DT_INT64,
  M2MB_XML_DT_FLOAT,
  M2MB_XML_DT_DOUBLE,
  M2MB_XML_DT_STR,
  M2MB_XML_DT_TOKEN,
  M2MB_XML_DT_BASE64BIN,
  M2MB_XML_DT_HEXBIN,
  M2MB_XML_DT_DATE,
  M2MB_XML_DT_TIME,
  M2MB_XML_DT_DATE_TIME,
  M2MB_XML_DT_DURATION
}
 Data type supported by the XML. More...
 
typedef enum M2MB_XML_OBJ_TYPE M2MB_XML_OBJ_TYPE_T
 Object type supported by the xml. More...
 
typedef enum M2MB_XML_DATA_TYPE M2MB_XML_DATA_TYPE_T
 Data type supported by the XML. More...
 
typedef struct M2MB_XML_NODE M2MB_XML_NODE_T
 Xml node structure. More...
 
typedef struct M2MB_XML_DATE M2MB_XML_DATE_T
 XML date structure xml. More...
 
typedef struct M2MB_XML_TIME M2MB_XML_TIME_T
 Xml time structure xml. More...
 
typedef struct M2MB_XML_DATE_TIME M2MB_XML_DATE_TIME_T
 Xml date & time structure xml. More...
 
typedef struct M2MB_XML_DURATION M2MB_XML_DURATION_T
 Xml duration structure. More...
 
typedef struct M2MB_XML_STRING M2MB_XML_STRING_T
 Duration structure XML. More...
 
typedef struct M2MB_XML_OBJ M2MB_XML_OBJ_T
 Xml object structure. More...
 
typedef struct M2MB_XML_COMPLEX_INFO M2MB_XML_COMPLEX_INFO_T
 XML complex information structure. More...
 
typedef struct M2MB_XML_COMPLEX_OBJ M2MB_XML_COMPLEX_OBJ_T
 Xml complex object structure. More...
 
M2MB_STATUS_T m2mb_xml_encode (M2MB_XML_COMPLEX_OBJ_T *xml_schema, UINT8 *user_struct, UINT8 *xml_file_buffer, UINT32 xml_file_buffer_Size, UINT32 *len_of_xml_written)
 Encode API for XML module. More...
 
M2MB_STATUS_T m2mb_xml_decode (UINT8 *parent_start, UINT8 *parent_end, M2MB_XML_COMPLEX_OBJ_T *xml_schema, UINT8 *return_struct)
 Decode API for XML module. More...
 
M2MB_STATUS_T m2mb_xml_node_get (M2MB_XML_NODE_T *child_node, UINT8 *parent_node_start, UINT8 *parent_node_end, UINT8 *tag_end)
 Get node API for XML module. More...
 
UINT8 m2mb_xml_node_occ_get (UINT8 *pTName, UINT8 *pPNStart, UINT8 *pPNEnd)
 Occurrence of node present API for XML module. More...
 

Detailed Description

This section describes the M2MB APIs for XML module.

XML modules provides APIs to decodes a XML string and fills the parameters in the provided structure. Similarly, it also provides APIs to encode XMLstring from the provided structure. The structure information and the XML tag information are given to the XML module in a proprietary embedded schema format. Each TAG in XML string is defined in a structured format that gives the detail information about it, like the tag name, tag type, info on where to decode and fill the data of the tag, tag data type.

Typedef Documentation

◆ M2MB_XML_COMPLEX_INFO_T

XML complex information structure.

XML complex information structure.

◆ M2MB_XML_COMPLEX_OBJ_T

Xml complex object structure.

Xml complex object structure.

◆ M2MB_XML_DATA_TYPE_T

Data type supported by the XML.

List of data types supported by XML module.

◆ M2MB_XML_DATE_T

XML date structure xml.

Date structure XML module.

◆ M2MB_XML_DATE_TIME_T

Xml date & time structure xml.

Date & Time structure xml module.

◆ M2MB_XML_DURATION_T

Xml duration structure.

Duration structure xml module.

◆ M2MB_XML_NODE_T

Xml node structure.

Xml node structure.

◆ M2MB_XML_OBJ_T

typedef struct M2MB_XML_OBJ M2MB_XML_OBJ_T

Xml object structure.

Xml object structure.

◆ M2MB_XML_OBJ_TYPE_T

Object type supported by the xml.

List of object types supported by xml module.

◆ M2MB_XML_STRING_T

Duration structure XML.

Duration structure XML module.

◆ M2MB_XML_TIME_T

Xml time structure xml.

Time structure xml module.

Enumeration Type Documentation

◆ M2MB_XML_DATA_TYPE

Data type supported by the XML.

List of data types supported by XML module.

Enumerator
M2MB_XML_DT_NONE 

If data type is not any of the below mention. Used for complex objects.

M2MB_XML_DT_UINT8 

Unsigned 8-bit integer

M2MB_XML_DT_INT8 

Signed 8-bit integer

M2MB_XML_DT_UINT16 

Unsigned 16-bit integer

M2MB_XML_DT_INT16 

Signed 16-bit integer

M2MB_XML_DT_UINT32 

Unsigned 32-bit integer

M2MB_XML_DT_INT32 

Signed 32-bit integer

M2MB_XML_DT_UINT64 

Unsigned 64-bit integer

M2MB_XML_DT_INT64 

Signed 64-bit integer

M2MB_XML_DT_FLOAT 

Float value

M2MB_XML_DT_DOUBLE 

Double value

M2MB_XML_DT_STR 

String

M2MB_XML_DT_TOKEN 

String but LF, CR, TAB and trailing spaces are removed from the string

M2MB_XML_DT_BASE64BIN 

Base64-encoded binary data

M2MB_XML_DT_HEXBIN 

Hexadecimal-encoded binary data

M2MB_XML_DT_DATE 

Date in Format: YYYY-MM-DD-/+hh:mm, where-/+ specifies the time offset from the UTC time

M2MB_XML_DT_TIME 

Time in Format:HH:MM:SS-/+hh:mm, where-/+ specifies the time offset from the UTC time

M2MB_XML_DT_DATE_TIME 

Date and time in Format:YYYY_MM_DDTHH:MM:SS-/+hh:mm, where-/+ specifies the time offset from the UTC time

M2MB_XML_DT_DURATION 

Duration in Format:PnYnMnDTnHnMnS

Definition at line 87 of file m2mb_xml.h.

◆ M2MB_XML_OBJ_TYPE

Object type supported by the xml.

List of object types supported by xml module.

Enumerator
M2MB_XML_COMPLEX_ELEMENT 

Complex element

M2MB_XML_SIMPLE_ELEMENT 

Simple element

M2MB_XML_ATTRIBUTE 

Attribute

M2MB_XML_NONE 

Not in use

Definition at line 72 of file m2mb_xml.h.

Function Documentation

◆ m2mb_xml_decode()

M2MB_STATUS_T m2mb_xml_decode ( UINT8 parent_start,
UINT8 parent_end,
M2MB_XML_COMPLEX_OBJ_T xml_schema,
UINT8 return_struct 
)

Decode API for XML module.

This function decode the XML file, extract the data and fill that on user structure.

Parameters
[in]parent_startThe starting address of the XML file
[in]parent_endThe Ending address of the XML file.
[in]xml_schema
[in]return_structThe user structure buffer to be filled with the data.
Returns
M2MB_OK – when xml decode was successful M2MB_ERROR – when xml decode failed
Note
<Notes> Example
typedef struct M2M_XML_WLAN_STA_CFG_S
{
UINT8 enable;
}M2M_XML_WLAN_STA_CFG_T;
const M2MB_XML_OBJ_T xml_sta_enable_in =
{
"enable",
1,
offsetof(M2M_XML_WLAN_STA_CFG_T, enable),
};
const M2MB_XML_OBJ_T xml_sta_wlan_ssid_in =
{
"ssid",
1,
offsetof(M2M_XML_WLAN_STA_CFG_T, ssid),
};
const M2MB_XML_OBJ_T xml_sta_wlan_pwd_in =
{
"pwd",
1,
offsetof(M2M_XML_WLAN_STA_CFG_T, pwd),
};
const M2MB_XML_OBJ_T* xml_sta_wlan_input[] = {
( const M2MB_XML_OBJ_T* )&xml_sta_enable_in,
( const M2MB_XML_OBJ_T* )&xml_sta_wlan_ssid_in,
( const M2MB_XML_OBJ_T* )&xml_sta_wlan_pwd_in,
};
const M2MB_XML_COMPLEX_OBJ_T xml_sta_wlan_schema = {
"sta",
1,
offsetof( M2M_XML_WLAN_CFG_T, sta ),
{
sizeof(xml_sta_wlan_input)/sizeof(M2MB_XML_OBJ_T*),
sizeof( M2M_XML_WLAN_STA_CFG_T ),
xml_sta_wlan_input
}
};
M2M_XML_WLAN_STA_CFG_T sta_cfg;
UINT8 *xml_encoded_str = "<sta><enable>1<//enable><ssid>SSID1<//ssid><pwd>PWD1<//pwd><//sta>";
UINT32 length;
M2MB_STATUS_T return_status = m2mb_xml_decode(( UINT8* )xml_encoded_str,
strlen(xml_encoded_str),(M2MB_XML_COMPLEX_OBJ_T *)&xml_sta_wlan_schema,
( UINT8* )&sta_cfg );

◆ m2mb_xml_encode()

M2MB_STATUS_T m2mb_xml_encode ( M2MB_XML_COMPLEX_OBJ_T xml_schema,
UINT8 user_struct,
UINT8 xml_file_buffer,
UINT32  xml_file_buffer_Size,
UINT32 len_of_xml_written 
)

Encode API for XML module.

This function create the XML file from the data structure and the XML schema.

Parameters
[in]xml_schemaThe xml schema for XML file.
[in]user_structThe user structure which holds all data to be encoded.
[in]xml_file_bufferThe user buffer which will be filled with the XML file.
[in]xml_file_buffer_SizeTotal Size of the user buffer.
[in]len_of_xml_writtenSize of the user buffer filled with XML file.
Returns
M2MB_OK – when xml encode was successful M2MB_ERROR – when xml encode failed
Note
<Notes> Example
typedef struct M2M_XML_WLAN_STA_CFG_S
{
UINT8 enable;
}M2M_XML_WLAN_STA_CFG_T;
const M2MB_XML_OBJ_T xml_sta_enable_in =
{
"enable",
1,
offsetof(M2M_XML_WLAN_STA_CFG_T, enable),
};
const M2MB_XML_OBJ_T xml_sta_wlan_ssid_in =
{
"ssid",
1,
offsetof(M2M_XML_WLAN_STA_CFG_T, ssid),
};
const M2MB_XML_OBJ_T xml_sta_wlan_pwd_in =
{
"pwd",
1,
offsetof(M2M_XML_WLAN_STA_CFG_T, pwd),
};
const M2MB_XML_OBJ_T* xml_sta_wlan_input[] = {
( const M2MB_XML_OBJ_T* )&xml_sta_enable_in,
( const M2MB_XML_OBJ_T* )&xml_sta_wlan_ssid_in,
( const M2MB_XML_OBJ_T* )&xml_sta_wlan_pwd_in,
};
const M2MB_XML_COMPLEX_OBJ_T xml_sta_wlan_schema = {
"sta",
1,
offsetof( M2M_XML_WLAN_CFG_T, sta ),
{
sizeof(xml_sta_wlan_input)/sizeof(M2MB_XML_OBJ_T*),
sizeof( M2M_XML_WLAN_STA_CFG_T ),
xml_sta_wlan_input
}
};
M2M_XML_WLAN_STA_CFG_T sta_cfg = {
.enable = TRUE,
.ssid = {.type = 0, .len = 5, .ptr = "SSID1" },
.pwd = { .type = 0, .len = 4, .ptr = "PWD1" }
};
UINT8 xml_encoded_str[1024];
UINT32 length;
M2MB_STATUS_T return_status = m2mb_xml_encode(
(M2MB_XML_COMPLEX_OBJ_T *)&xml_sta_wlan_schema,
( UINT8* )&sta_cfg, ( UINT8* )xml_encoded_str,
sizeof(xml_encoded_str), ( UINT32* )&length );
xml_encoded_str[length++] = '\0';

◆ m2mb_xml_node_get()

M2MB_STATUS_T m2mb_xml_node_get ( M2MB_XML_NODE_T child_node,
UINT8 parent_node_start,
UINT8 parent_node_end,
UINT8 tag_end 
)

Get node API for XML module.

This function gets the node information from the XML file. It fills the child_node(child node structure) if it finds the tag. The tag name is taken from the parent name element in the child_node

Parameters
[in]child_nodeXML child node details. User has to fill the name of the tag and the API would fill the start and end pointer with in the pPNStart and pPNEnd pointer.
[in]parent_node_startThe starting address of the XML file.
[in]parent_node_endThe Ending address of the XML file.
[in]tag_endThe Ending tag of the XML file.
Returns
M2MB_OK – when xml decode was successful. M2MB_ERROR – when xml decode failed.
Note
<Notes> Example
M2MB_XML_NODE_T *child_node;
UINT8 tag_end;
UINT8 *xml_encoded_str = "<sta><enable>1<//enable><ssid>SSID1<//ssid><pwd>PWD1<//pwd><//sta>";
m2mb_xml_node_get( &child_node, xml_encoded_str,
xml_encoded_str + strlen(xml_encoded_str), &tag_end );

◆ m2mb_xml_node_occ_get()

UINT8 m2mb_xml_node_occ_get ( UINT8 pTName,
UINT8 pPNStart,
UINT8 pPNEnd 
)

Occurrence of node present API for XML module.

This function finds the occurrence of a tag within the start and end pointer given.

Parameters
[in]pTNameName of the tag.
[in]pPNStartThe starting address of the XML file.
[in]pPNEndThe Ending address of the XML file.
Returns
Number of occurrence of the tag within the start and end pointer.
Note
<Notes> Example
UINT8 *xml_encoded_str = "<sta><enable>1<//enable><ssid>SSID1<//ssid><pwd>PWD1<//pwd><//sta>";
m2mb_xml_node_get( "sta", xml_encoded_str,
xml_encoded_str + strlen(xml_encoded_str) );