Add toolchain and mbtk source

Change-Id: Ie12546301367ea59240bf23d5e184ad7e36e40b3
diff --git a/mbtk/mbtk_lib/inc/ds_ASBuffer.h b/mbtk/mbtk_lib/inc/ds_ASBuffer.h
new file mode 100644
index 0000000..492b436
--- /dev/null
+++ b/mbtk/mbtk_lib/inc/ds_ASBuffer.h
@@ -0,0 +1,268 @@
+/*==============================================================================

+

+                              ds_ASBuffer.h

+

+GENERAL DESCRIPTION

+  A buffer class with utility functions for parsing raw bytes.

+

+EXTERNALIZED FUNCTIONS

+

+INITIALIZATION AND SEQUENCING REQUIREMENTS

+

+  Copyright (c) 2014 by Qualcomm Technologies Incorporated. All Rights Reserved.

+==============================================================================*/

+

+/*==============================================================================

+                           EDIT HISTORY FOR MODULE

+

+This section contains comments describing changes made to the module.

+Notice that changes are listed in reverse chronological order.

+

+when        who    what, where, why

+--------    ---    ----------------------------------------------------------

+04/21/14    ml     Created file/Initial version.

+==============================================================================*/

+

+#ifndef __DS_AS_BUFFER_H__

+#define __DS_AS_BUFFER_H__

+

+//#include "comdef.h"

+#include "mbtk_type.h"

+class ASString;

+

+

+/*==============================================================================

+CLASS ASBuffer

+

+DESCRIPTION

+  A buffer class with utility functions for parsing raw bytes.

+==============================================================================*/

+class ASBuffer

+{

+public:

+  /*===========================================================================

+  FUNCTION ASBuffer CONSTRUCTOR

+

+  DESCRIPTION

+    Creates a new ASBuffer.

+

+  DEPENDENCIES

+    capacity - The initial buffer capacity to set.

+

+  SIDE EFFECTS

+    None

+  ===========================================================================*/

+  ASBuffer();

+  ASBuffer(uint32 capacity);

+

+  ASBuffer(ASBuffer &buf);

+  ASBuffer(const ASBuffer &buf);

+  ASBuffer(const uint8* buf, uint32 capacity);

+

+  ~ASBuffer();

+

+

+  ASBuffer& operator=(const ASBuffer &rhs);

+

+  /*============================================================================

+  FUNCTION ASBuffer::content

+

+  DESCRIPTION

+    Returns a pointer to the buffer content

+

+  PARAMETERS

+    None

+

+  DEPENDENCIES

+    None

+

+  SIDE EFFECTS

+    None

+  ============================================================================*/

+  const uint8* content() const;

+

+

+

+  /*============================================================================

+  FUNCTION ASBuffer::non_const_content

+

+  DESCRIPTION

+    Returns a pointer to the buffer content. Use this function ONLY if you need

+    a non-const version and it is guaranteed that the returned pointer will

+    never be modified.

+

+    Note: Workaround function for MD5 auth-int. Otherwise shouldn't be used.

+

+  PARAMETERS

+    None

+

+  DEPENDENCIES

+    None

+

+  SIDE EFFECTS

+    None

+  ============================================================================*/

+  uint8* non_const_content();

+

+

+

+  /*============================================================================

+  FUNCTION ASBuffer::c_str

+

+  DESCRIPTION

+    Returns a pointer to the buffer content. This assumes the buffer content is

+    in c-string format

+

+  PARAMETERS

+    None

+

+  DEPENDENCIES

+    None

+

+  SIDE EFFECTS

+    None

+  ============================================================================*/

+  const char* c_str() const;

+

+

+

+  /*============================================================================

+  FUNCTION ASBuffer::size

+

+  DESCRIPTION

+    Returns the size of the buffer

+

+  PARAMETERS

+    None

+

+  DEPENDENCIES

+    None

+

+  SIDE EFFECTS

+    None

+  ============================================================================*/

+  uint32 size() const;

+

+

+

+  /*============================================================================

+  FUNCTION ASBuffer::empty

+

+  DESCRIPTION

+    Returns true if the buffer is empty

+

+  PARAMETERS

+    None

+

+  DEPENDENCIES

+    None

+

+  SIDE EFFECTS

+    None

+  ============================================================================*/

+  bool empty() const;

+

+

+

+  /*============================================================================

+  FUNCTION ASBuffer::error

+

+  DESCRIPTION

+    Returns true if the buffer is in error status due to internal memory

+    allocation failure.

+

+    This can happen when

+      - Constructor fails to allocate memory for the new buffer

+      - Append requires to resize the buffer but fails

+

+  PARAMETERS

+    None

+

+  DEPENDENCIES

+    None

+

+  SIDE EFFECTS

+    None

+  ============================================================================*/

+  bool error() const;

+

+

+

+  /*============================================================================

+  FUNCTION ASBuffer::append

+

+  DESCRIPTION

+    Appends the given data to the buffer. Returns true if append is successful,

+    false if append fails.

+

+  PARAMETERS

+    [In] append_buffer - The data to append

+    [In] size          - The number of bytes to append

+

+  DEPENDENCIES

+    None

+

+  SIDE EFFECTS

+    None

+  ============================================================================*/

+  bool append(const uint8* append_buffer, const uint32 size);

+  bool append(const char append_buffer);

+  bool append(const char* append_buffer);

+  bool append(const char* append_buffer, const uint32 size);

+  bool append(const ASBuffer& append_buffer);

+  bool append(const ASString& append_buffer); // temp

+

+

+  /*============================================================================

+  FUNCTION ASBuffer::clear

+

+  DESCRIPTION

+    Returns true if the buffer is in error status due to internal memory

+    allocation failure.

+

+    This can happen when

+      - Constructor fails to allocate memory for the new buffer

+      - Append requires to resize the buffer but fails

+

+  PARAMETERS

+    None

+

+  DEPENDENCIES

+    None

+

+  SIDE EFFECTS

+    None

+  ============================================================================*/

+  void clear();

+

+

+

+private:

+  /*============================================================================

+  FUNCTION ASBuffer::init

+

+  DESCRIPTION

+    Initialize buffer

+

+  PARAMETERS

+    None

+

+  DEPENDENCIES

+    None

+

+  SIDE EFFECTS

+    None

+  ============================================================================*/

+  void init();

+  bool increment_buffer_capacity(const uint32 req_size);

+

+

+  uint8* buffer; // Buffer object. Memory dynamically allocated as necessary

+  uint32 buffer_size;

+  uint32 buffer_capacity;

+  bool   error_status; // true if error, else false

+};

+

+

+

+#endif /* __DS_AS_BUFFER_H__ */

diff --git a/mbtk/mbtk_lib/inc/ds_ASString.h b/mbtk/mbtk_lib/inc/ds_ASString.h
new file mode 100644
index 0000000..02319ca
--- /dev/null
+++ b/mbtk/mbtk_lib/inc/ds_ASString.h
@@ -0,0 +1,265 @@
+/*==============================================================================

+

+                              ds_ASString.h

+

+GENERAL DESCRIPTION

+  A string class with utility functions for parsing AS.

+

+EXTERNALIZED FUNCTIONS

+

+INITIALIZATION AND SEQUENCING REQUIREMENTS

+

+  Copyright (c) 2014 by Qualcomm Technologies Incorporated. All Rights Reserved.

+==============================================================================*/

+

+/*==============================================================================

+                           EDIT HISTORY FOR MODULE

+

+This section contains comments describing changes made to the module.

+Notice that changes are listed in reverse chronological order.

+

+when        who    what, where, why

+--------    ---    ----------------------------------------------------------

+04/21/14    ml     Created file/Initial version.

+==============================================================================*/

+#ifndef DS_AS_STRING_H

+#define DS_AS_STRING_H

+

+//#include "comdef.h"

+#include "mbtk_type.h"

+

+/*==============================================================================

+CLASS ASString

+

+DESCRIPTION

+  A string class with utility functions for parsing AS.

+==============================================================================*/

+class ASString

+{

+public:

+  /*===========================================================================

+  FUNCTION ASString CONSTRUCTOR

+

+  DESCRIPTION

+    Creates a new ASString. Default constructor will create an empty string.

+    The other constructors will make a copy of the given string.

+

+  DEPENDENCIES

+    None

+

+  SIDE EFFECTS

+    None

+  ===========================================================================*/

+  ASString();

+  ASString(const char* src);

+  ASString(const char* src, uint32 len);

+

+  // copy constructor

+  ASString(ASString& src);

+  ASString(const ASString& src);

+

+  ~ASString();

+

+

+  ASString& operator=(const ASString& rhs);

+  ASString& operator=(const char* rhs);

+  char      operator[](const int index) const;

+  char&     operator[](const int index);

+

+

+  /*============================================================================

+  FUNCTION ASString::c_str

+

+  DESCRIPTION

+    Returns the raw c-string

+

+  PARAMETERS

+    None

+

+  DEPENDENCIES

+    None

+

+  SIDE EFFECTS

+    None

+  ============================================================================*/

+  const char* c_str() const;

+

+  /*============================================================================

+  FUNCTION ASString::size

+  FUNCTION ASString::length

+

+  DESCRIPTION

+    Returns the length of the string

+

+  PARAMETERS

+    None

+

+  DEPENDENCIES

+    None

+

+  SIDE EFFECTS

+    None

+  ============================================================================*/

+  uint32 size() const;

+  uint32 length() const;

+

+  /*============================================================================

+  FUNCTION ASString::empty

+

+  DESCRIPTION

+    Returns true if the string is empty or NULL

+

+  PARAMETERS

+    None

+

+  DEPENDENCIES

+    None

+

+  SIDE EFFECTS

+    None

+  ============================================================================*/

+  bool empty() const;

+

+  /*============================================================================

+  FUNCTION ASString::remove_trailing_spaces

+

+  DESCRIPTION

+    Removes all whiltespace, including tabs and newlines, at the end of the string.

+

+  PARAMETERS

+    None

+

+  DEPENDENCIES

+    None

+

+  SIDE EFFECTS

+    None

+  ============================================================================*/

+  void remove_trailing_spaces();

+

+  /*============================================================================

+  FUNCTION ASString::resolve_xml_escapes

+

+  DESCRIPTION

+    Replaces XML escape strings with the corresponding character.

+

+  PARAMETERS

+    None

+

+  DEPENDENCIES

+    None

+

+  SIDE EFFECTS

+    None

+  ============================================================================*/

+  bool resolve_xml_escapes();

+

+  /*============================================================================

+  FUNCTION ASString::to_lower

+

+  DESCRIPTION

+    Converts all characters in the string to lower case.

+

+  PARAMETERS

+    None

+

+  DEPENDENCIES

+    None

+

+  SIDE EFFECTS

+    None

+  ============================================================================*/

+  void to_lower();

+

+  /*============================================================================

+  FUNCTION ASString::limit_cmp

+

+  DESCRIPTION

+    Partial string compare up to len. Returns true if same, else false.

+

+  PARAMETERS

+    [In] cstr - The string to compare

+    [In] len  - The number of characters to compare.

+

+  DEPENDENCIES

+    None

+

+  SIDE EFFECTS

+    None

+  ============================================================================*/

+  bool limit_cmp(const char* cstr, const uint32 len) const;

+

+  /*============================================================================

+  FUNCTION ASString::append

+

+  DESCRIPTION

+    Appends the given string to the string it holds.

+

+  PARAMETERS

+    [In] append_str - The string to append

+    [In] len        - The number of characters to append

+

+  DEPENDENCIES

+    None

+

+  SIDE EFFECTS

+    None

+  ============================================================================*/

+  void append(const char* append_str);

+  void append(const char* append_str, const uint32 len);

+  void append(const ASString& append_str);

+

+protected:

+  /*============================================================================

+  FUNCTION ASString::copy_string

+

+  DESCRIPTION

+    Partial string compare up to len. Returns true if same, else false.

+

+  PARAMETERS

+    [In] src - The string to copy

+    [In] len - The number of characters to copy

+

+  DEPENDENCIES

+    None

+

+  SIDE EFFECTS

+    None

+  ============================================================================*/

+  void copy_string(const char* src, uint32 len);

+

+  char* str; // C-string object. Memory dynamically allocated as necessary

+};

+

+

+

+/*============================================================================

+FUNCTION operator==

+FUNCTION operator!=

+FUNCTION operator<

+FUNCTION operator>

+

+DESCRIPTION

+  Compares the two strings and returns true/false based on the operator. The

+  comparison will be case insensitive.

+

+PARAMETERS

+  [In] lhs - The string to compare

+  [In] rhs - The other string to compare

+

+DEPENDENCIES

+  None

+

+SIDE EFFECTS

+  None

+============================================================================*/

+bool operator== (const ASString& lhs, const ASString& rhs);

+bool operator!= (const ASString& lhs, const ASString& rhs);

+

+bool operator== (const ASString& lhs, const char* rhs);

+bool operator!= (const ASString& lhs, const char* rhs);

+

+bool operator< (const ASString& lhs, const ASString& rhs);

+bool operator> (const ASString& lhs, const ASString& rhs);

+

+#endif /* DS_AS_STRING_H */

diff --git a/mbtk/mbtk_lib/inc/g711_pcm_convert.h b/mbtk/mbtk_lib/inc/g711_pcm_convert.h
new file mode 100644
index 0000000..688dcb4
--- /dev/null
+++ b/mbtk/mbtk_lib/inc/g711_pcm_convert.h
@@ -0,0 +1,46 @@
+#ifndef G711_PCM_CONVERT_H_
+#define G711_PCM_CONVERT_H_
+
+enum g711type {
+    G711ALAW,
+    G711ULAW
+};
+
+/**
+ * @brief pcm data encode to g711 data
+ * 
+ *  user should be responsible for pCodecbit memmory
+ * 
+ * @param pCodecBits store g711 encoded data 
+ * @param pBuffer pcm raw data
+ * @param BufferSize pcm data len
+ * @param type g711 data type
+ * @return int encode data length
+ */
+int G711EnCode(char* pCodecBits, char* pBuffer, int BufferSize, enum g711type type);
+
+/**
+ * @brief g711 data decode to pcm data
+ * 
+ * user should be responsible for pRawData memmory
+ * 
+ * @param pRawData store uncoded pcm data
+ * @param pBuffer g711 encoded data
+ * @param BufferSize g711 data len
+ * @param type g711 data type
+ * @return int pcm data len
+ */
+int G711Decode(char* pRawData, char* pBuffer, int BufferSize, enum g711type type);
+
+/**
+ * @brief g711 u-law data and a-law data convert
+ * 
+ * @param alawdata g711 a-law data
+ * @param ulawdata g711 u-lwa data
+ * @param datasize input data length
+ * @param type target g711 data type
+ * @return int sucess:1; failed:0
+ */
+int G711TypeChange(unsigned char* alawdata, unsigned char* ulawdata, int datasize, enum g711type type);
+
+#endif /* G711_PCM_CONVERT_H_ */
\ No newline at end of file
diff --git a/mbtk/mbtk_lib/inc/gpio-define.h b/mbtk/mbtk_lib/inc/gpio-define.h
new file mode 100644
index 0000000..36c497e
--- /dev/null
+++ b/mbtk/mbtk_lib/inc/gpio-define.h
@@ -0,0 +1,133 @@
+/**
+ *   \file gpio-define.h
+ *   \brief A Documented file.
+ *
+ *  Detailed description
+ *   \Author:  Sniper <js.wang@mobiletek.cn>
+ *   \Version: 1.0.0
+ *   \Date: 2022-04-26
+ */
+
+#ifndef __GPIO_DEFINE_H__
+#define __GPIO_DEFINE_H__
+
+/*
+4组GPIO共128个GPIO,分别从GPIO_0到GPIO_127
+GPIO22位于0xd4019000这一组的BIT22
+
+GPIO0_BASE 0xD4019000
+GPIO1_BASE 0xD4019004
+GPIO2_BASE 0xD4019008
+GPIO3_BASE 0xD4019100
+ */
+/*
+MMC_CMD	    GPIO_41
+MMC_DATA0	GPIO_40
+MMC_DATA1	GPIO_39
+MMC_DATA2	GPIO_38
+MMC_DATA3	GPIO_37
+
+SD_DET	GPIO_43
+WLAN_DAT3	GPIO_48
+
+
+*/
+#define  GPIO_FUNC_MMC1_DAT3	0xD401E094
+#define  GPIO_FUNC_MMC1_DAT2	0xD401E098
+#define  GPIO_FUNC_MMC1_DAT1	0xD401E09C
+#define  GPIO_FUNC_MMC1_DAT0	0xD401E0A0
+#define  GPIO_FUNC_MMC1_CMD	0xD401E0A4
+#define  GPIO_FUNC_MMC1_CLK	0xD401E0A8
+#define  GPIO_FUNC_MMC1_CD	0xD401E0AC
+#define  GPIO_FUNC_USB_ID	    0xD401E0B0
+#define  GPIO_FUNC_PRI_TDI	0xD401E0B4
+#define  GPIO_FUNC_PRI_TMS	0xD401E0B8
+#define  GPIO_FUNC_PRI_TCK	0xD401E0BC
+#define  GPIO_FUNC_PRI_TDO	0xD401E0C0
+#define  GPIO_FUNC_QSPI_VMODE_GPIO	0xD401E0C4
+#define  GPIO_FUNC_VBUS_DRV	0xD401E0C8
+#define  GPIO_FUNC_CLK_REQ	0xD401E0CC
+#define  GPIO_FUNC_VCXO_REQ	0xD401E0D4
+#define  GPIO_FUNC_VCXO_OUT	0xD401E0D8
+#define  GPIO_FUNC_GPIO_00	0xD401E0DC
+#define  GPIO_FUNC_GPIO_01	0xD401E0E0
+#define  GPIO_FUNC_GPIO_02	0xD401E0E4
+#define  GPIO_FUNC_GPIO_03	0xD401E0E8
+#define  GPIO_FUNC_GPIO_04	0xD401E0EC
+#define  GPIO_FUNC_GPIO_05	0xD401E0F0
+#define  GPIO_FUNC_GPIO_06	0xD401E0F4
+#define  GPIO_FUNC_GPIO_07	0xD401E0F8
+#define  GPIO_FUNC_GPIO_08	0xD401E0FC
+#define  GPIO_FUNC_GPIO_09	0xD401E100
+#define  GPIO_FUNC_GPIO_10	0xD401E104
+#define  GPIO_FUNC_GPIO_11	0xD401E108
+#define  GPIO_FUNC_GPIO_12	0xD401E10C
+#define  GPIO_FUNC_GPIO_13	0xD401E110
+#define  GPIO_FUNC_GPIO_14	0xD401E114
+#define  GPIO_FUNC_GPIO_15	0xD401E118
+#define  GPIO_FUNC_GPIO_16	0xD401E11C
+#define  GPIO_FUNC_GPIO_17	0xD401E120
+#define  GPIO_FUNC_GPIO_18	0xD401E124
+#define  GPIO_FUNC_GPIO_19	0xD401E128
+#define  GPIO_FUNC_GPIO_20	0xD401E12C
+#define  GPIO_FUNC_GPIO_21	0xD401E130
+#define  GPIO_FUNC_GPIO_22	0xD401E134
+#define  GPIO_FUNC_GPIO_23	0xD401E138
+#define  GPIO_FUNC_GPIO_24	0xD401E13C
+#define  GPIO_FUNC_GPIO_25	0xD401E140
+#define  GPIO_FUNC_GPIO_26	0xD401E144
+#define  GPIO_FUNC_GPIO_27	0xD401E148
+#define  GPIO_FUNC_GPIO_28	0xD401E14C
+#define  GPIO_FUNC_GPIO_29	0xD401E150
+#define  GPIO_FUNC_GPIO_30	0xD401E154
+#define  GPIO_FUNC_GPIO_31	0xD401E158
+#define  GPIO_FUNC_GPIO_32	0xD401E15C
+#define  GPIO_FUNC_GPIO_33	0xD401E160
+#define  GPIO_FUNC_GPIO_34	0xD401E164
+#define  GPIO_FUNC_GPIO_35	0xD401E168
+#define  GPIO_FUNC_GPIO_36	0xD401E16C
+#define  GPIO_FUNC_GPIO_49	0xD401E1A0
+#define  GPIO_FUNC_GPIO_50	0xD401E1A4
+#define  GPIO_FUNC_GPIO_51	0xD401E1A8
+#define  GPIO_FUNC_GPIO_52	0xD401E1AC
+#define  GPIO_FUNC_GPIO_53	0xD401E1B0
+#define  GPIO_FUNC_GPIO_54	0xD401E1B4
+#define  GPIO_FUNC_DVL_0      0xD401E2B4
+#define  GPIO_FUNC_DVL_1      0xD401E2B8
+#define  GPIO_FUNC_GPIO_69	0xD401E2BC
+#define  GPIO_FUNC_GPIO_70	0xD401E2C0
+#define  GPIO_FUNC_QSPI_DAT3	0xD401E2C4
+#define  GPIO_FUNC_QSPI_DAT2	0xD401E2C8
+#define  GPIO_FUNC_QSPI_DAT1	0xD401E2CC
+#define  GPIO_FUNC_QSPI_DAT0	0xD401E2D0
+#define  GPIO_FUNC_QSPI_CLK	0xD401E2D4
+#define  GPIO_FUNC_QSPI_CS1	0xD401E2D8
+#define  GPIO_FUNC_GPIO_77	0xD401E2DC
+#define  GPIO_FUNC_GPIO_78	0xD401E2E0
+#define  GPIO_FUNC_GPIO_79	0xD401E2E4
+#define  GPIO_FUNC_GPIO_80	0xD401E2E8
+#define  GPIO_FUNC_SDIO_DAT3	0xD401E2EC
+#define  GPIO_FUNC_SDIO_DAT2	0xD401E2F0
+#define  GPIO_FUNC_SDIO_DAT1	0xD401E2F4
+#define  GPIO_FUNC_SDIO_DAT0	0xD401E2F8
+#define  GPIO_FUNC_SDIO_CMD	0xD401E2FC
+#define  GPIO_FUNC_SDIO_CLK	0xD401E300
+#define  GPIO_FUNC_GPIO_60	0xD401E304
+#define  GPIO_FUNC_USIM_UCLK	0xD401E320
+#define  GPIO_FUNC_USIM_UIO	0xD401E324
+#define  GPIO_FUNC_USIM_URSTn	0xD401E328
+
+
+#define  GPIO0_BASE 0xD4019000
+#define  GPIO1_BASE 0xD4019004
+#define  GPIO2_BASE 0xD4019008
+#define  GPIO3_BASE 0xD4019100
+
+struct gpio_register_function
+{
+    int  reg;
+    int  func_gpio; // 第 [func_gpio] 功能为 GPIO
+};
+
+
+#endif /*__GPIO_DEFINE_H__*/
diff --git a/mbtk/mbtk_lib/inc/mbtk_alphabet.h b/mbtk/mbtk_lib/inc/mbtk_alphabet.h
new file mode 100644
index 0000000..1ffece7
--- /dev/null
+++ b/mbtk/mbtk_lib/inc/mbtk_alphabet.h
@@ -0,0 +1,140 @@
+//
+// Created by hitmoon on 15-12-10.
+//
+
+
+struct map_node {
+    unsigned short key;
+    unsigned short value;
+};
+
+
+#define map_size(map) (sizeof(map) / sizeof(struct map_node))
+
+
+// Unicode编码到GSM编码转换
+struct map_node UCS2ToBIT7[] = {
+        {0x000C, 0x1B0A},
+        {0x0024, 0x0002},
+        {0x0040, 0x0000},
+        {0x005B, 0x1B3C},
+        {0x005C, 0x1B2F},
+        {0x005D, 0x1B3E},
+        {0x005E, 0x1B14},
+        {0x005F, 0x0011},
+        {0x007B, 0x1B28},
+        {0x007C, 0x1B40},
+        {0x007D, 0x1B29},
+        {0x007E, 0x1B3D},
+        {0x00A0, 0x001B},
+        {0x00A1, 0x0040},
+        {0x00A3, 0x0001},
+        {0x00A4, 0x0024},
+        {0x00A5, 0x0003},
+        {0x00A7, 0x005F},
+        {0x00BF, 0x0060},
+        {0x00C4, 0x005B},
+        {0x00C5, 0x000E},
+        {0x00C6, 0x001C},
+        {0x00C9, 0x001F},
+        {0x00D1, 0x005D},
+        {0x00D6, 0x005C},
+        {0x00D8, 0x000B},
+        {0x00DC, 0x005E},
+        {0x00DF, 0x001E},
+        {0x00E0, 0x007F},
+        {0x00E4, 0x007B},
+        {0x00E5, 0x000F},
+        {0x00E6, 0x001D},
+        {0x00E7, 0x0009},
+        {0x00E8, 0x0004},
+        {0x00E9, 0x0005},
+        {0x00EC, 0x0007},
+        {0x00F1, 0x007D},
+        {0x00F2, 0x0008},
+        {0x00F6, 0x007C},
+        {0x00F8, 0x000C},
+        {0x00F9, 0x0006},
+        {0x00FC, 0x007E},
+        {0x0393, 0x0013},
+        {0x0394, 0x0010},
+        {0x0398, 0x0019},
+        {0x039B, 0x0014},
+        {0x039E, 0x001A},
+        {0x03A0, 0x0016},
+        {0x03A3, 0x0018},
+        {0x03A6, 0x0012},
+        {0x03A8, 0x0017},
+        {0x03A9, 0x0015},
+        {0x20AC, 0x1B65}
+};
+
+// GSM编码到Unicode编码转换
+struct map_node BIT7ToUCS2[] = {
+        {0x0000, 0x0040},
+        {0x0001, 0x00A3},
+        {0x0002, 0x0024},
+        {0x0003, 0x00A5},
+        {0x0004, 0x00E8},
+        {0x0005, 0x00E9},
+        {0x0006, 0x00F9},
+        {0x0007, 0x00EC},
+        {0x0008, 0x00F2},
+        {0x0009, 0x00E7},
+        {0x000B, 0x00D8},
+        {0x000C, 0x00F8},
+        {0x000E, 0x00C5},
+        {0x000F, 0x00E5},
+        {0x0010, 0x0394},
+        {0x0011, 0x005F},
+        {0x0012, 0x03A6},
+        {0x0013, 0x0393},
+        {0x0014, 0x039B},
+        {0x0015, 0x03A9},
+        {0x0016, 0x03A0},
+        {0x0017, 0x03A8},
+        {0x0018, 0x03A3},
+        {0x0019, 0x0398},
+        {0x001A, 0x039E},
+        {0x001B, 0x00A0},
+        {0x001C, 0x00C6},
+        {0x001D, 0x00E6},
+        {0x001E, 0x00DF},
+        {0x001F, 0x00C9},
+        {0x0024, 0x00A4},
+        {0x0040, 0x00A1},
+        {0x005B, 0x00C4},
+        {0x005C, 0x00D6},
+        {0x005D, 0x00D1},
+        {0x005E, 0x00DC},
+        {0x005F, 0x00A7},
+        {0x0060, 0x00BF},
+        {0x007B, 0x00E4},
+        {0x007C, 0x00F6},
+        {0x007D, 0x00F1},
+        {0x007E, 0x00FC},
+        {0x007F, 0x00E0}
+};
+// GSM编码转义序列到Unicode编码转换
+struct map_node BIT7EToUCS2[] = {
+        {0x000A, 0x000C},
+        {0x0014, 0x005E},
+        {0x0028, 0x007B},
+        {0x0029, 0x007D},
+        {0x002F, 0x005C},
+        {0x003C, 0x005B},
+        {0x003D, 0x007E},
+        {0x003E, 0x005D},
+        {0x0040, 0x007C},
+        {0x0065, 0x20AC}
+};
+
+// map 中查询键值
+int32_t map_get_value(struct map_node *map, unsigned int size, unsigned short key) {
+	int i = 0;
+    for (i = 0; i < size; i++) {
+        if (map[i].key == key)
+            return map[i].value;
+    }
+    return -1;
+}
diff --git a/mbtk/mbtk_lib/inc/mbtk_coap_pdu.h b/mbtk/mbtk_lib/inc/mbtk_coap_pdu.h
new file mode 100644
index 0000000..334301a
--- /dev/null
+++ b/mbtk/mbtk_lib/inc/mbtk_coap_pdu.h
@@ -0,0 +1,288 @@
+

+#ifndef __MBTK_COAP_H__

+#define __MBTK_COAP_H__

+#include <stdint.h>

+//#include "ps_in.h"

+#include "ds_ASBuffer.h"

+#include "mbtk_type.h"

+

+#define COAP_HDR_SIZE 4

+#define COAP_OPTION_HDR_BYTE 1

+

+typedef unsigned char               uint8_t;

+typedef unsigned short              uint16_t;

+//typedef unsigned long               uint32_t;

+typedef unsigned long long          uint64_t;

+

+/*

+enum ds_appsrv_mem_e_type { APPSRV_MEM };

+

+void* operator new(unsigned int size, void* alloc, ds_appsrv_mem_e_type mem_type) throw();

+void  operator delete(void* obj, void* alloc, ds_appsrv_mem_e_type mem_type) throw();

+*/

+

+#define ps_ntohs(x)                                                      \

+          (((((uint16)(x) & 0x00FF) << 8) | (((uint16)(x) & 0xFF00) >> 8)))

+

+

+#define endian_be16(x) ps_ntohs(x)

+

+#define endian_load16(cast, from) ((cast)( \

+        (((uint16_t)((uint8_t*)(from))[0]) << 8) | \

+        (((uint16_t)((uint8_t*)(from))[1])     ) ))

+

+#define endian_load32(cast, from) ((cast)( \

+        (((uint32_t)((uint8_t*)(from))[0]) << 24) | \

+        (((uint32_t)((uint8_t*)(from))[1]) << 16) | \

+        (((uint32_t)((uint8_t*)(from))[2]) <<  8) | \

+        (((uint32_t)((uint8_t*)(from))[3])      ) ))

+

+#define endian_load64(cast, from) ((cast)( \

+        (((uint64_t)((uint8_t*)(from))[0]) << 56) | \

+        (((uint64_t)((uint8_t*)(from))[1]) << 48) | \

+        (((uint64_t)((uint8_t*)(from))[2]) << 40) | \

+        (((uint64_t)((uint8_t*)(from))[3]) << 32) | \

+        (((uint64_t)((uint8_t*)(from))[4]) << 24) | \

+        (((uint64_t)((uint8_t*)(from))[5]) << 16) | \

+        (((uint64_t)((uint8_t*)(from))[6]) << 8)  | \

+        (((uint64_t)((uint8_t*)(from))[7])     )  ))

+

+#define endian_store16(to, num) \

+    do { uint16_t val = endian_be16(num); memcpy(to, &val, 2); } while(0)

+

+// CoAP PDU format

+

+//   0                   1                   2                   3

+//  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1

+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

+// |Ver| T |  TKL  |      Code     |          Message ID           |

+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

+// |   Token (if any, TKL bytes) ...

+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

+// |   Options (if any) ...

+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

+// |1 1 1 1 1 1 1 1|    Payload (if any) ...

+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

+

+class CoapPDU

+{

+

+

+public:

+    /// CoAP message types. Note, values only work as enum.

+    enum Type

+    {

+        COAP_CONFIRMABLE=0x00,

+        COAP_NON_CONFIRMABLE=0x10,

+        COAP_ACKNOWLEDGEMENT=0x20,

+        COAP_RESET=0x30

+    };

+

+    // CoAP response codes.

+    enum Code

+    {

+        COAP_EMPTY=0x00,

+        COAP_GET,

+        COAP_POST,

+        COAP_PUT,

+        COAP_DELETE,

+        COAP_LASTMETHOD=0x1F,

+        COAP_CREATED=0x41,

+        COAP_DELETED,

+        COAP_VALID,

+        COAP_CHANGED,

+        COAP_CONTENT,

+        COAP_CONTINUE=0x5F,

+        COAP_BAD_REQUEST=0x80,

+        COAP_UNAUTHORIZED,

+        COAP_BAD_OPTION,

+        COAP_FORBIDDEN,

+        COAP_NOT_FOUND,

+        COAP_METHOD_NOT_ALLOWED,

+        COAP_NOT_ACCEPTABLE,

+        COAP_PRECONDITION_FAILED=0x8C,

+        COAP_REQUEST_ENTITY_TOO_LARGE=0x8D,

+        COAP_UNSUPPORTED_CONTENT_FORMAT=0x8F,

+        COAP_INTERNAL_SERVER_ERROR=0xA0,

+        COAP_NOT_IMPLEMENTED,

+        COAP_BAD_GATEWAY,

+        COAP_SERVICE_UNAVAILABLE,

+        COAP_GATEWAY_TIMEOUT,

+        COAP_PROXYING_NOT_SUPPORTED,

+        COAP_UNDEFINED_CODE=0xFF

+    };

+

+    /// CoAP option numbers.

+    enum Option

+    {

+        COAP_OPTION_IF_MATCH=1,

+        COAP_OPTION_URI_HOST=3,

+        COAP_OPTION_ETAG,

+        COAP_OPTION_IF_NONE_MATCH,

+        COAP_OPTION_OBSERVE,

+        COAP_OPTION_URI_PORT,

+        COAP_OPTION_LOCATION_PATH,

+        COAP_OPTION_URI_PATH=11,

+        COAP_OPTION_CONTENT_FORMAT,

+        COAP_OPTION_MAX_AGE=14,

+        COAP_OPTION_URI_QUERY,

+        COAP_OPTION_ACCEPT=17,

+        COAP_OPTION_LOCATION_QUERY=20,

+        COAP_OPTION_BLOCK2=23,

+        COAP_OPTION_BLOCK1=27,

+        COAP_OPTION_SIZE2,

+        COAP_OPTION_PROXY_URI=35,

+        COAP_OPTION_PROXY_SCHEME=39,

+        COAP_OPTION_SIZE1=60

+    };

+

+    /// CoAP content-formats.

+    enum ContentFormat

+    {

+        COAP_CONTENT_FORMAT_TEXT_PLAIN = 0,

+        COAP_CONTENT_FORMAT_APP_LINK  = 40,

+        COAP_CONTENT_FORMAT_APP_XML,

+        COAP_CONTENT_FORMAT_APP_OCTET,

+        COAP_CONTENT_FORMAT_APP_EXI   = 47,

+        COAP_CONTENT_FORMAT_APP_JSON  = 50

+    };

+

+    /// Sequence of these is returned by CoapPDU::getOptions()

+    struct CoapOption

+    {

+        uint16_t optionDelta;

+        uint16_t optionNumber;

+        uint16_t optionValueLength;

+        int totalLength;

+        uint8_t *optionPointer;

+        uint8_t *optionValuePointer;

+    };

+

+    // construction and destruction

+    CoapPDU();

+    CoapPDU(uint8_t *buffer, int bufferLength, int pduLength);

+    ~CoapPDU();

+    int reset();

+    int validate();

+

+    // version

+    int setVersion(uint8_t version);

+    uint8_t getVersion();

+

+    // message type

+    void setType(int type);

+    int getType();

+

+    // tokens

+    int setTokenLength(uint8_t tokenLength);

+    int getTokenLength();

+    uint8_t* getTokenPointer();

+    int setToken(uint8_t *token, uint8_t tokenLength);

+

+    // message code

+    void setCode(int code);

+    int getCode();

+    int httpStatusToCode(int httpStatus);

+

+    // message ID

+    int setMessageID(uint16_t messageID);

+    uint16_t getMessageID();

+

+    // options

+    int addOption(uint16_t optionNumber, uint16_t optionLength, uint8_t *optionValue);

+    // gets a list of all options

+    CoapOption* getOptions();

+    int getNumOptions();

+    // shorthand helpers

+    int setURI(char *uri);

+    int setURI(char *uri, int urilen);

+    int getURI(char *dst, int dstlen, int *outLen);

+    int addURIQuery(char *query);

+

+    // content format helper

+    int setContentFormat(int format);

+

+    // payload

+    uint8_t* mallocPayload(int bytes);

+    int setPayload(uint8_t *value, int len);

+    uint8_t* getPayloadPointer();

+    int getPayloadLength();

+    uint8_t* getPayloadCopy();

+

+    // pdu

+    int getPDULength();

+    uint8_t* getPDUPointer();

+    void setPDULength(int len);

+    void getOptionValueById(uint16_t optionNumber, uint16_t *optionValueLength,uint8_t *optionValuePointer);

+    const char *printHuman();

+    const char * printHex();

+    int hasOption(uint16_t optionNumber);

+private:

+    // variables

+    uint8_t *_pdu;

+    int _pduLength;

+

+    int _constructedFromBuffer;

+    int _bufferLength;

+

+    uint8_t *_payloadPointer;

+    int _payloadLength;

+

+    int _numOptions;

+    uint16_t _maxAddedOptionNumber;

+    ASBuffer content;

+

+    // functions

+    void shiftPDUUp(int shiftOffset, int shiftAmount);

+    void shiftPDUDown(int startLocation, int shiftOffset, int shiftAmount);

+    uint8_t codeToValue(int c);

+

+    // option stuff

+    int findInsertionPosition(uint16_t optionNumber, uint16_t *prevOptionNumber);

+    int computeExtraBytes(uint16_t n);

+    int insertOption(int insertionPosition, uint16_t optionDelta, uint16_t optionValueLength, uint8_t *optionValue);

+    uint16_t getOptionDelta(uint8_t *option);

+    void setOptionDelta(int optionPosition, uint16_t optionDelta);

+    uint16_t getOptionValueLength(uint8_t *option);

+

+};

+

+/*

+#define COAP_CODE_EMPTY 0x00

+

+// method codes 0.01-0.31

+#define COAP_CODE_GET   0x01

+#define COAP_CODE_POST  0x02

+#define COAP_CODE_PUT   0x03

+#define COAP_CODE_DELETE 0x04

+

+// Response codes 2.00 - 5.31

+// 2.00 - 2.05

+#define COAP_CODE_CREATED 0x41

+#define COAP_CODE_DELETED 0x42

+#define COAP_CODE_VALID   0x43

+#define COAP_CODE_CHANGED 0x44

+#define COAP_CODE_CONTENT 0x45

+

+// 4.00 - 4.15

+#define COAP_CODE_BAD_REQUEST                0x80

+#define COAP_CODE_UNAUTHORIZED               0x81

+#define COAP_CODE_BAD_OPTION                 0x82

+#define COAP_CODE_FORBIDDEN                  0x83

+#define COAP_CODE_NOT_FOUND                  0x84

+#define COAP_CODE_METHOD_NOT_ALLOWED         0x85

+#define COAP_CODE_NOT_ACCEPTABLE             0x86

+#define COAP_CODE_PRECONDITION_FAILED        0x8C

+#define COAP_CODE_REQUEST_ENTITY_TOO_LARGE   0x8D

+#define COAP_CODE_UNSUPPORTED_CONTENT_FORMAT 0x8F

+

+// 5.00 - 5.05

+#define COAP_CODE_INTERNAL_SERVER_ERROR      0xA0

+#define COAP_CODE_NOT_IMPLEMENTED            0xA1

+#define COAP_CODE_BAD_GATEWAY                0xA2

+#define COAP_CODE_SERVICE_UNAVAILABLE        0xA3

+#define COAP_CODE_GATEWAY_TIMEOUT            0xA4

+#define COAP_CODE_PROXYING_NOT_SUPPORTED     0xA5

+*/

+

+#endif

diff --git a/mbtk/mbtk_lib/inc/mbtk_http_base.h b/mbtk/mbtk_lib/inc/mbtk_http_base.h
new file mode 100644
index 0000000..2490b78
--- /dev/null
+++ b/mbtk/mbtk_lib/inc/mbtk_http_base.h
@@ -0,0 +1,124 @@
+/*************************************************************
+Description:
+    HTTP platform related function implementation.
+Author:
+    LiuBin
+Date:
+    2020/4/30 14:02:58
+*************************************************************/
+#ifndef _MBTK_HTTP_BASE_H
+#define _MBTK_HTTP_BASE_H
+
+#include <stdio.h>
+
+#include "mbtk_type.h"
+#include "mbtk_log.h"
+#include "mbtk_sock2.h"
+
+/*************************************************************
+    Public Function Declaration
+*************************************************************/
+int mbtk_http_init();
+int mbtk_http_deinit();
+int mbtk_http_open
+(
+    bool is_ssl,
+    bool ingnore_cert,
+    const void *host,
+    uint16 port
+);
+
+/*=============================================
+FUNCTION
+    mbtk_http_read
+
+DESCRIPTION
+    read content from socket.
+
+DEPENDENCIES
+    None
+
+PARAMETERS
+    *buf      Store read content.
+    len       the length of Content.
+    timeout   Set timeout
+
+RETURN VALUE
+    Length of read content
+
+SIDE EFFECTS
+    None
+=============================================*/
+int mbtk_http_read
+(
+    int sock_fd,
+    void *buf,
+    uint16 len,
+    int timeout_ms
+);
+
+#if 0
+int mbtk_http_read_line
+(
+    FILE *file,
+    void *buf,
+    uint16 len
+);
+#else
+int mbtk_http_read_line
+(
+    int sock_fd,
+    void *buf,
+    uint16 len
+);
+#endif
+
+/*=============================================
+FUNCTION
+    mbtk_http_write
+
+DESCRIPTION
+    Write content to socket.
+
+DEPENDENCIES
+    None
+
+PARAMETERS
+    *buf    Content to be transferred
+    len     the length of Content.
+
+RETURN VALUE
+    Length of written content
+
+SIDE EFFECTS
+    None
+=============================================*/
+int mbtk_http_write
+(
+    int sock_fd,
+    void *buf,
+    uint16 len
+);
+
+/*=============================================
+FUNCTION
+    mbtk_http_close
+
+DESCRIPTION
+    close HTTP service.
+
+DEPENDENCIES
+    None
+
+PARAMETERS
+    *err    Error number
+
+RETURN VALUE
+    TURE or FALSE
+
+SIDE EFFECTS
+    None
+=============================================*/
+int mbtk_http_close(int sock_fd);
+
+#endif /* _MBTK_HTTP_BASE_H */
diff --git a/mbtk/mbtk_lib/inc/mbtk_http_chunks.h b/mbtk/mbtk_lib/inc/mbtk_http_chunks.h
new file mode 100644
index 0000000..eff228c
--- /dev/null
+++ b/mbtk/mbtk_lib/inc/mbtk_http_chunks.h
@@ -0,0 +1,66 @@
+#ifndef _MBTK_HTTP_CHUNKS_H
+#define _MBTK_HTTP_CHUNKS_H
+#include "mbtk_type.h"
+
+/*
+ * The longest possible hexadecimal number we support in a chunked transfer.
+ * Weird enough, RFC2616 doesn't set a maximum size! Since we use strtoul()
+ * to convert it, we "only" support 2^32 bytes chunk data.
+ */
+#define MAXNUM_SIZE 16
+
+typedef enum {
+  /* await and buffer all hexadecimal digits until we get one that isn't a
+     hexadecimal digit. When done, we go CHUNK_LF */
+  CHUNK_HEX,
+
+  /* wait for LF, ignore all else */
+  CHUNK_LF,
+
+  /* We eat the amount of data specified. When done, we move on to the
+     POST_CR state. */
+  CHUNK_DATA,
+
+  /* POSTLF should get a CR and then a LF and nothing else, then move back to
+     HEX as the CRLF combination marks the end of a chunk. A missing CR is no
+     big deal. */
+  CHUNK_POSTLF,
+
+  /* At this point optional trailer headers can be found, unless the next line
+     is CRLF */
+  CHUNK_TRAILER,
+
+  /* Used to mark that we're out of the game.  NOTE: that there's a 'dataleft'
+     field in the struct that will tell how many bytes that were not passed to
+     the client in the end of the last buffer! */
+  CHUNK_STOP
+} http_chunk_state;
+
+typedef enum {
+  CHUNKE_STOP = -1,
+  CHUNKE_OK = 0,
+  CHUNKE_TOO_LONG_HEX = 1,
+  CHUNKE_ILLEGAL_HEX,
+  CHUNKE_BAD_CHUNK,
+  CHUNKE_BAD_ENCODING,
+  CHUNKE_OUT_OF_MEMORY,
+  CHUNKE_PASSTHRU_ERROR, /* Curl_httpchunk_read() returns a CURLcode to use */
+  CHUNKE_LAST
+} http_chunk_code;
+
+typedef struct {
+  char hexbuffer[MAXNUM_SIZE + 1];
+  int hexindex;
+  http_chunk_state state;
+  int datasize;
+  int dataleft; /* untouched data amount at the end of the last buffer */
+} http_chunker_t;
+
+/* The following functions are defined in http_chunks.c */
+void http_chunk_init(http_chunker_t *chunker);
+http_chunk_code http_chunk_parse(http_chunker_t *chunker, char *src, int src_len,
+            char *dest,int *dest_len);
+
+#endif /* _MBTK_HTTP_CHUNKS_H */
+
+
diff --git a/mbtk/mbtk_lib/inc/mbtk_info.h b/mbtk/mbtk_lib/inc/mbtk_info.h
new file mode 100755
index 0000000..7277171
--- /dev/null
+++ b/mbtk/mbtk_lib/inc/mbtk_info.h
@@ -0,0 +1,496 @@
+#ifndef MBTK_INFO_INCLUDE
+#define MBTK_INFO_INCLUDE
+#include <netinet/in.h>
+
+#include "mbtk_type.h"
+#include "mbtk_list.h"
+#include "mbtk_log.h"
+#include "mbtk_utils.h"
+#include "mbtk_info_api.h"
+
+#define MBTK_INFO_PACKET_FLAG 0x5F6F7F8F
+#define SOCK_INFO_PATH "/tmp/info_sock"
+#define SOCK_MSG_LEN_MAX 2048
+
+// Tag(4) + Packet_Length(2)
+#define SOCK_PACK_EXTRA_LEN 6
+// SOCK_PACK_EXTRA_LEN + Id(2) + Error(2) + Number(2)
+#define SOCK_PACK_LEN_MIN (SOCK_PACK_EXTRA_LEN + 6)
+
+typedef enum
+{
+    MBTK_INFO_TYPE_REQ,
+    MBTK_INFO_TYPE_RSP,
+    MBTK_INFO_TYPE_IND,
+    MBTK_INFO_TYPE_UNKNOWN
+} mbtk_info_type_enum;
+
+typedef enum
+{
+    // Device Information
+    MBTK_INFO_ID_DEV_BEGIN = 0,
+    // <string> IMEI
+    MBTK_INFO_ID_DEV_IMEI_REQ,
+    MBTK_INFO_ID_DEV_IMEI_RSP,
+    // <string> SN
+    MBTK_INFO_ID_DEV_SN_REQ,
+    MBTK_INFO_ID_DEV_SN_RSP,
+    // <string> MEID
+    MBTK_INFO_ID_DEV_MEID_REQ,
+    MBTK_INFO_ID_DEV_MEID_RSP,
+    // <string> VERSION
+    MBTK_INFO_ID_DEV_VERSION_REQ,
+    MBTK_INFO_ID_DEV_VERSION_RSP,
+    // <string> MODEL
+    MBTK_INFO_ID_DEV_MODEL_REQ,
+    MBTK_INFO_ID_DEV_MODEL_RSP,
+    // <uint8> 0:Close 1:Open
+    MBTK_INFO_ID_DEV_VOLTE_REQ,
+    MBTK_INFO_ID_DEV_VOLTE_RSP,
+    // <string> Temperature
+    MBTK_INFO_ID_DEV_TEMP_REQ,  // Temperature
+    MBTK_INFO_ID_DEV_TEMP_RSP,
+    // <uint8><string>  YYYY-MM-DD-HH:MM:SS
+    MBTK_INFO_ID_DEV_TIME_REQ,  // Time
+    MBTK_INFO_ID_DEV_TIME_RSP,
+    //<string>  "23/03/20,01:58:00+32"
+    MBTK_INFO_ID_NET_TIME_REQ,  // Time
+    MBTK_INFO_ID_NET_TIME_RSP,
+
+    MBTK_INFO_ID_DEV_MODEM_REQ,
+    MBTK_INFO_ID_DEV_MODEM_RSP,
+
+    MBTK_INFO_ID_DEV_END,
+
+    // Sim Information
+    MBTK_INFO_ID_SIM_BEGIN = 1000,
+    // <uint8> 0:NOT_EXIST 1:READY ...
+    MBTK_INFO_ID_SIM_STATE_REQ,
+    MBTK_INFO_ID_SIM_STATE_RSP,
+    // <uint8> 0: SIM 1: USIM 2: TEST SIM 3: TEST USIM 4: UNKNOWN
+    MBTK_INFO_ID_SIM_STYPE_REQ,
+    MBTK_INFO_ID_SIM_STYPE_RSP,
+    // <string> PIN
+    MBTK_INFO_ID_SIM_PIN_REQ,
+    MBTK_INFO_ID_SIM_PIN_RSP,
+    // <string> PIN
+    MBTK_INFO_ID_SIM_ENABLE_PIN_REQ,
+    MBTK_INFO_ID_SIM_ENABLE_PIN_RSP,
+    // <string> PUK
+    MBTK_INFO_ID_SIM_PUK_REQ,
+    MBTK_INFO_ID_SIM_PUK_RSP,
+    // <string> PLMN
+    MBTK_INFO_ID_SIM_PLMN_REQ,
+    MBTK_INFO_ID_SIM_PLMN_RSP,
+    // <uint8> <uint8> <uint8> <uint8> PIN PUK LAST TIMES
+    MBTK_INFO_ID_SIM_PINPUK_TIMES_REQ,
+    MBTK_INFO_ID_SIM_PINPUK_TIMES_RSP,
+    // <string> IMSI
+    MBTK_INFO_ID_SIM_IMSI_REQ,
+    MBTK_INFO_ID_SIM_IMSI_RSP,
+    // <string> ICCID
+    MBTK_INFO_ID_SIM_ICCID_REQ,
+    MBTK_INFO_ID_SIM_ICCID_RSP,
+    // <string> Phone Number
+    MBTK_INFO_ID_SIM_PN_REQ,
+    MBTK_INFO_ID_SIM_PN_RSP,
+    // <string> <string> old_PIN new_PIN
+    MBTK_INFO_ID_SIM_CHANGE_PIN_REQ,
+    MBTK_INFO_ID_SIM_CHANGE_PIN_RSP,
+
+    MBTK_INFO_ID_SIM_END,
+
+    // Network Information
+    MBTK_INFO_ID_NET_BEGIN = 2000,
+    // <uint8> 0:OFF 1:ON
+    MBTK_INFO_ID_NET_RADIO_REQ,
+    MBTK_INFO_ID_NET_RADIO_RSP,
+    // sel_mode(uint8)type(uint8)plmn(uint32)...sel_mode(uint8)type(uint8)plmn(uint32)
+    MBTK_INFO_ID_NET_AVAILABLE_REQ,
+    MBTK_INFO_ID_NET_AVAILABLE_RSP,
+    // <uint8> 0: automatic 1: manual
+    // or
+    // sel_mode(uint8)type(uint8)plmn(uint32)
+    MBTK_INFO_ID_NET_SEL_MODE_REQ,
+    MBTK_INFO_ID_NET_SEL_MODE_RSP,
+    // mbtk_band_info_t
+    MBTK_INFO_ID_NET_BAND_REQ,
+    MBTK_INFO_ID_NET_BAND_RSP,
+    // mbtk_signal_info_t
+    MBTK_INFO_ID_NET_SIGNAL_REQ,
+    MBTK_INFO_ID_NET_SIGNAL_RSP,
+    // mbtk_net_reg_info_t
+    MBTK_INFO_ID_NET_REG_REQ,
+    MBTK_INFO_ID_NET_REG_RSP,
+    // mbtk_apn_info_t
+    MBTK_INFO_ID_NET_APN_REQ,
+    MBTK_INFO_ID_NET_APN_RSP,
+    // mbtk_cell_info_t[]
+    MBTK_INFO_ID_NET_CELL_REQ,
+    MBTK_INFO_ID_NET_CELL_RSP,
+    // REQ:
+    // <call_type[1]><cid[1]><timeout[1]>
+    //  call_type : mbtk_data_call_type_enum
+    //  cid : 1 - 15
+    //  timeout : second
+    // RSP:
+    //  <type[1]><ipv4><ipv6>
+    //  type : 0-IPV4   1-IPV6  2-IPV4V6
+    //  ipv4 : mbtk_ipv4_info_t
+    //  ipv6 : mbtk_ipv6_info_t
+    MBTK_INFO_ID_NET_DATA_CALL_REQ,
+    MBTK_INFO_ID_NET_DATA_CALL_RSP,
+
+    MBTK_INFO_ID_NET_END,
+
+    // Call Information
+    MBTK_INFO_ID_CALL_BEGIN = 3000,
+    MBTK_INFO_ID_CALL_STATE_REQ,
+    MBTK_INFO_ID_CALL_STATE_RSP,
+
+    // Start call.
+    MBTK_INFO_ID_CALL_START_REQ,
+    MBTK_INFO_ID_CALL_START_RSP,
+    //answer call
+    MBTK_INFO_ID_CALL_ANSWER_REQ,
+    MBTK_INFO_ID_CALL_ANSWER_RSP,
+    //hang up all call
+    MBTK_INFO_ID_CALL_HANGUP_REQ,
+    MBTK_INFO_ID_CALL_HANGUP_RSP,
+    //hang up a call
+    MBTK_INFO_ID_CALL_HANGUP_A_REQ,
+    MBTK_INFO_ID_CALL_HANGUP_A_RSP,
+    //hang up waiting or background call
+    MBTK_INFO_ID_CALL_HANGUP_B_REQ,
+    MBTK_INFO_ID_CALL_HANGUP_B_RSP,
+    //hang up foreground resume background
+    MBTK_INFO_ID_CALL_HANGUP_C_REQ,
+    MBTK_INFO_ID_CALL_HANGUP_C_RSP,
+    //wait in call
+    MBTK_INFO_ID_CALL_WAITIN_REQ,
+    MBTK_INFO_ID_CALL_WAITIN_RSP,
+    //mute call
+    MBTK_INFO_ID_CALL_MUTE_REQ,
+    MBTK_INFO_ID_CALL_MUTE_RSP,
+    //dtmf call
+    MBTK_INFO_ID_CALL_DTMF_REQ,
+    MBTK_INFO_ID_CALL_DTMF_RSP,
+
+    MBTK_INFO_ID_CALL_END,
+
+    // SMS Information
+    MBTK_INFO_ID_SMS_BEGIN = 4000,
+    MBTK_INFO_ID_SMS_STATE_REQ,
+    MBTK_INFO_ID_SMS_STATE_RSP,
+    MBTK_INFO_ID_SMS_CMGF_REQ,
+    MBTK_INFO_ID_SMS_CMGF_RSP,
+    MBTK_INFO_ID_SMS_CPMS_REQ,
+    MBTK_INFO_ID_SMS_CPMS_RSP,
+    MBTK_INFO_ID_SMS_CMGS_REQ,
+    MBTK_INFO_ID_SMS_CMGS_RSP,
+    MBTK_INFO_ID_SMS_CMSS_REQ,
+    MBTK_INFO_ID_SMS_CMSS_RSP,
+    MBTK_INFO_ID_SMS_CMGR_REQ,
+    MBTK_INFO_ID_SMS_CMGR_RSP,
+    MBTK_INFO_ID_SMS_CMGW_REQ,
+    MBTK_INFO_ID_SMS_CMGW_RSP,
+    MBTK_INFO_ID_SMS_CMGD_REQ,
+    MBTK_INFO_ID_SMS_CMGD_RSP,
+    MBTK_INFO_ID_SMS_CMGL_REQ,
+    MBTK_INFO_ID_SMS_CMGL_RSP,
+    MBTK_INFO_ID_SMS_CSCA_REQ,
+    MBTK_INFO_ID_SMS_CSCA_RSP,
+    MBTK_INFO_ID_SMS_CSMP_REQ,
+    MBTK_INFO_ID_SMS_CSMP_RSP,
+    MBTK_INFO_ID_SMS_CSCB_REQ,
+    MBTK_INFO_ID_SMS_CSCB_RSP,
+    MBTK_INFO_ID_SMS_CNMI_REQ,
+    MBTK_INFO_ID_SMS_CNMI_RSP,
+
+    MBTK_INFO_ID_SMS_END,
+
+    // PhoneBook Information
+    MBTK_INFO_ID_PB_BEGIN = 5000,
+    MBTK_INFO_ID_PB_STATE_REQ,
+    MBTK_INFO_ID_PB_STATE_RSP,
+
+    MBTK_INFO_ID_PB_END,
+
+    // IND Information
+    MBTK_INFO_ID_IND_BEGIN = 10000,
+    // <uint8>  State
+    MBTK_INFO_ID_IND_NET_STATE_CHANGE,
+    // <uint8>  State
+    MBTK_INFO_ID_IND_CALL_STATE_CHANGE,
+    // <uint8>  State
+    MBTK_INFO_ID_IND_SMS_STATE_CHANGE,
+    // <uint8>  State
+    MBTK_INFO_ID_IND_RADIO_STATE_CHANGE,
+    // <uint8>  State
+    MBTK_INFO_ID_IND_SIM_STATE_CHANGE,
+    // <uint8>  State
+    MBTK_INFO_ID_IND_PDP_STATE_CHANGE,
+    // <uint8> State
+    MBTK_INFO_ID_IND_SERVER_STATE_CHANGE,////mbtk wyq for server_ready_status add
+
+    MBTK_INFO_ID_IND_END,
+    MBTK_INFO_ID_REQ_UNKNOWN        // Unknown information.
+} mbtk_info_id_enum;
+
+typedef enum {
+    MBTK_NET_CS_STATE = 0,
+    MBTK_NET_PS_STATE
+} mbtk_net_state_type_enum;
+
+typedef enum {
+    MBTK_INFO_ERR_SUCCESS = 300,
+    MBTK_INFO_ERR_FORMAT,       // Packet format error.
+    MBTK_INFO_ERR_REQ_UNKNOWN,  // Unknown request.
+    MBTK_INFO_ERR_REQ_PARAMETER,  // Request parameter error.
+    MBTK_INFO_ERR_UNSUPPORTED,  // Unsupported operation.
+    MBTK_INFO_ERR_MEMORY,       // Insufficient memory.
+    MBTK_INFO_ERR_IND_FULL,     // Register IND fail(FULL).
+    MBTK_INFO_ERR_IND_UNKNOWN,  // Register IND fail(Unknown IND).
+    MBTK_INFO_ERR_CID,  // CID error.
+    MBTK_INFO_ERR_TIMEOUT,  // Timeout.
+    MBTK_INFO_ERR_TIME_FORMAT,  // Time format error.
+    
+    //mbtk wyq for data_call add start
+    MBTK_INFO_ERR_CID_EXIST,
+    MBTK_INFO_ERR_CID_NO_EXIST,
+    MBTK_INFO_ERR_NET_NO_INIT,
+    //mbtk wyq for data_call add end
+
+    MBTK_INFO_ERR_UNKNOWN = 400,  // Unknown error.
+    // CME error start index.
+    MBTK_INFO_ERR_CME = 500,
+    MBTK_INFO_ERR_CME_NON = 1000
+} mbtk_info_err_enum;
+
+/*
+GSM band��
+    1 �C PGSM 900 (standard or primary)
+    2 �C DCS GSM 1800
+    4 �C PCS GSM 1900
+    8 �C EGSM 900 (extended)
+    16 �C GSM 450
+    32 �C GSM 480
+    64 �C GSM 850
+    512 - BAND_LOCK_BIT // used for GSM band setting
+*/
+typedef enum
+{
+    MBTK_GSM_BAND_PGSM_900 = 1,
+    MBTK_GSM_BAND_DCS_GSM_1800 = 2,
+    MBTK_GSM_BAND_PCS_GSM_1900 = 4,
+    MBTK_GSM_BAND_EGSM_900 = 8,
+    MBTK_GSM_BAND_GSM_450 = 16,
+    MBTK_GSM_BAND_GSM_480 = 32,
+    MBTK_GSM_BAND_GSM_850 = 64,
+    MBTK_GSM_BAND_BAND_LOCK_BIT = 512
+} mbtk_gsm_band_enum;
+
+/*
+UMTS band��
+    1 �C UMTS_BAND_1
+    2 �C UMTS_BAND_2
+    4 �C UMTS_BAND_3
+    8 �C UMTS_BAND_4
+    16 �C UMTS_BAND_5
+    32 �C UMTS_BAND_6
+    64 �C UMTS_BAND_7
+    128 �C UMTS_BAND_8
+    256 �C UMTS_BAND_9
+*/
+typedef enum
+{
+    MBTK_UMTS_BAND_1 = 1,
+    MBTK_UMTS_BAND_2 = 2,
+    MBTK_UMTS_BAND_3 = 4,
+    MBTK_UMTS_BAND_4 = 8,
+    MBTK_UMTS_BAND_5 = 16,
+    MBTK_UMTS_BAND_6 = 32,
+    MBTK_UMTS_BAND_7 = 64,
+    MBTK_UMTS_BAND_8 = 128,
+    MBTK_UMTS_BAND_9 = 256
+} mbtk_umts_band_enum;
+
+/*
+LTEbandH(TDD-LTE band)
+    32 �C TDLTE_BAND_38
+    64 �C TDLTE_BAND_39
+    128 �C TDLTE_BAND_40
+    256 �C TDLTE_BAND_41
+*/
+typedef enum
+{
+    MBTK_TDLTE_BAND_38 = 32,
+    MBTK_TDLTE_BAND_39 = 64,
+    MBTK_TDLTE_BAND_40 = 128,
+    MBTK_TDLTE_BAND_41 = 256
+} mbtk_tdlte_band_enum;
+
+/*
+LTEbandL(FDD-LTE band)
+    1 �C FDDLTE_BAND_1
+    4 �C FDDLTE _BAND_3
+    8 �C FDDLTE _BAND_4
+    64 �C FDDLTE _BAND_7
+    65536 �C FDDLTE _BAND_17
+    524288 �C FDDLTE _BAND_20
+*/
+typedef enum
+{
+    MBTK_FDDLTE_BAND_1 = 1,
+    MBTK_FDDLTE_BAND_3 = 4,
+    MBTK_FDDLTE_BAND_4 = 8,
+    MBTK_FDDLTE_BAND_7 = 64,
+    MBTK_FDDLTE_BAND_17 = 65536,
+    MBTK_FDDLTE_BAND_20 = 524288
+} mbtk_fddlte_band_enum;
+
+/*
+0: unknown
+1: available
+2: current
+3: forbidden
+*/
+typedef enum
+{
+    MBTK_NET_AVIL_STATE_UNKNOWN = 0,
+    MBTK_NET_AVIL_STATE_AVAILABLE,
+    MBTK_NET_AVIL_STATE_CURRENT,
+    MBTK_NET_AVIL_STATE_FORBIDDEN
+} mbtk_net_avil_state_enum;
+
+typedef struct
+{
+    uint16 tac;
+    uint16 earfcn;
+} mbtk_local_info_t;
+
+typedef struct
+{
+    uint16 info_id;
+    uint16 info_err;
+    const uint8 *data;
+    uint16 data_len;
+} mbtk_info_pack_t;
+
+typedef struct
+{
+    uint8 type; // 0: GSM 1: UMTS 2: LTE
+    bool running;
+
+    int cell_num;
+    mbtk_cell_info_t cell[CELL_NUM_MAX];
+} mbtK_cell_pack_info_t;
+
+typedef enum {
+    MBTK_MOBILE_ORIGINATED_CALL,
+    MBTK_TERMINATED_CALL,
+} mbtk_call_dir_enum;
+
+typedef enum {
+    MBTK_VOICE,
+    MBTK_DATA,
+    MBTK_FAX,
+    MBTK_VOICE_FOLLOWED_BY_DATA_VOICE_MODE,
+    MBTK_ALTERNATING_VOICE_VOICE_MODE,
+    MBTK_ALTERNATING_FAX_VOICE_MODE,
+    MBTK_VOICE_FOLLOWED_BY_DATA_DATA_MODE,
+    MBTK_ALTERNATING_VOICE_DATA_MODE,
+    MBTK_ALTERNATING_FAX_FAX_MODE,
+    MBTL_UNKNOW,
+} mbtk_call_mode_enum;
+
+typedef enum {
+    MBTK_NOT_MULITYPARTY_CALL,
+    MBTK_MULITYPARTY__CALL,
+} mbtk_call_mpty_enum;
+
+typedef struct
+{
+    int cid;
+    bool act;
+    bool waitting;
+} info_cgact_wait_t;
+
+typedef struct
+{
+    uint32 count;
+    list_node_t *net_list;
+} mbtk_net_array_info_t;
+
+typedef struct
+{
+    bool inited;
+    mbtk_radio_state_enum radio_state;
+    mbtk_sim_state_enum sim_state;
+    mbtk_radio_technology_enum net_type;
+    mbtk_ip_type_enum ip_type;
+    struct sockaddr_in addr4;
+    struct sockaddr_in preferred_dns4;
+    struct sockaddr_in alternate_dns4;
+
+    struct sockaddr_in6 addr6;
+    struct sockaddr_in6 preferred_dns6;
+    struct sockaddr_in6 alternate_dns6;
+} net_info_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+char* type2str(mbtk_info_type_enum type);
+
+char* apn2str(mbtk_ip_type_enum type);
+
+char* id2str(int id);
+
+char* err2str(mbtk_info_err_enum err);
+
+/*
+IPv6 : 254.128.0.0.0.0.0.0.0.1.0.2.144.5.212.239 -> uint128
+*/
+int str_2_ipv6(const void *ip_str, void *ipv6);
+
+/*
+IPv6 : uint128 -> fe80::215:1dff:fe81:484c
+*/
+int ipv6_2_str(const void *ipv6, void *ipv6_str);
+
+/*
+0   GSM
+1   GSM_COMPACT
+2   UTRAN
+3   GSM_EGPRS
+4   UTRAN_HSDPA
+5   UTRAN_HSUPA
+6   UTRAN_HSDPA_HSUPA
+7   EUTRAN
+8   ECGSM
+*/
+mbtk_net_type_enum mbtk_net_type_get(mbtk_radio_technology_enum radio_tech);
+
+mbtk_info_type_enum mbtk_info_type_get(int info_id);
+
+mbtk_info_pack_t* mbtk_info_pack_creat(int info_id);
+
+#if 0
+int mbtk_info_pack_data_set(mbtk_info_pack_t *pack, const void *data, int data_len);
+void* mbtk_info_pack_data_get(mbtk_info_pack_t *pack, int *data_len);
+#endif
+
+int mbtk_info_pack_send(int fd, mbtk_info_pack_t *pack);
+
+mbtk_info_pack_t** mbtk_info_pack_recv(int fd, bool is_server, mbtk_info_err_enum *err);
+
+int mbtk_info_pack_free(mbtk_info_pack_t **pack);
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* MBTK_INFO_INCLUDE */
+
+
diff --git a/mbtk/mbtk_lib/inc/mbtk_pdu_sms.h b/mbtk/mbtk_lib/inc/mbtk_pdu_sms.h
new file mode 100755
index 0000000..c6416df
--- /dev/null
+++ b/mbtk/mbtk_lib/inc/mbtk_pdu_sms.h
@@ -0,0 +1,191 @@
+//

+// Created by hitmoon on 15-12-9.

+//

+

+#ifndef SMS_SMS_H

+#define SMS_SMS_H

+

+#include <string.h>

+#include "mbtk_utf.h"

+#include "mbtk_type.h"

+

+#define MAX_SMS_NR 32

+

+//typedef int bool;

+

+#define true 1

+#define false 0

+

+enum EnumDCS {

+    BIT7 = 0,            // GSM 字符集

+    BIT8 = 1,            // ASCII字符集

+    UCS2 = 2             // Unicode 字符集

+};

+

+enum EnumUDL {

+    BIT7UDL = 160,

+    BIT8UDL = 140,

+    UCS2UDL = 70

+};

+

+enum EnumCSMIEI {

+    BIT8MIEI = 0,

+    BIT16MIEI = 8

+};

+

+struct PDUUDH {

+    unsigned int count;    // 信息元素数据字节数

+    char IEI;           // 信息元素标识

+    char *IED;          // 信息元素数据

+};

+

+// 用户数据头

+struct UDHS {

+    int count;

+    struct PDUUDH *UDH;

+};

+

+// 用户数据数组,用于拆分短信

+struct UDS {

+    unsigned int total;

+    char **Data;

+};

+

+// 编码后短信

+struct PDUS {

+    unsigned int count;

+    char **PDU;

+};

+

+struct ByteArray {

+    char *array;

+    unsigned int len;

+};

+

+struct SMS_Struct {

+    char *SCA;         // 服务中心地址

+    char *OA;          // 发送方地址

+    char *SCTS;        // 服务中心时间戳

+    struct UDHS *UDH;     // 用户数据头

+    char *UD;          // 用户数据

+

+    bool RP;              // 应答路径

+    bool UDHI;            // 用户数据头标识

+    bool SRI;             // 状态报告指示

+    bool MMS;             // 更多信息发送

+    int MTI;              // 信息类型指示

+

+    char PID;          // PID 协议标识

+

+    enum EnumDCS DCS;      // 数据编码方案

+    bool TC;              // 文本压缩指示 0: 未压缩 1:压缩

+    int MC;               // 消息类型 -1: 无 1:移动设备特定类型 2:SIM特定类型 3:终端设备特定类型

+

+};

+

+

+// 短信解码

+struct SMS_Struct PDUDecoding(const char *data);

+

+// 短信编码, 自动确定编码方案

+struct PDUS *PDUEncoding(char *SCA, char *DA, char *UDC, struct UDHS *udhs);

+

+// 短信编码真正的工作

+/// 发送方PDU格式(SMS-SUBMIT-PDU)

+/// SCA(Service Center Adress):短信中心,长度1-12

+/// PDU-Type(Protocol Data Unit Type):协议数据单元类型,长度1

+/// MR(Message Reference):消息参考值,为0~255。长度1

+/// DA(Destination Adress):接收方SME的地址,长度2-12

+/// PID(Protocol Identifier):协议标识,长度1

+/// DCS(Data Coding Scheme):编码方案,长度1

+/// VP(Validity Period):有效期,长度为1(相对)或者7(绝对或增强)

+/// UDL(User Data Length):用户数据段长度,长度1

+/// UD(User Data):用户数据,长度0-140

+

+struct PDUS *PDUDoEncoding(char *SCA, char *DA, char *UDC, struct UDHS *udhs, enum EnumDCS DCS);

+

+

+// 服务中心地址解码

+char *SCADecoding(const char *data, int *EndIndex);

+

+// 原始地址解码

+char *OADecoding(const char *data, int index, int *EndIndex);

+

+// 服务中心时间戳解码

+char *SCTSDecoding(const char *data, int index);

+

+// BCD 解码

+int BCDDecoding(const char *data, int index, bool isMSB);

+

+// 用户数据头解码

+struct UDHS *UDHDecoding(const char *data, int index);

+

+// 用户数据解码

+char *UserDataDecoding(const char *data, int index, bool UDHI, enum EnumDCS dcs);

+

+// 7-Bit编码解压缩

+char *BIT7Unpack(const char *data, int index, int Septets, int FillBits);

+

+// 转换GSM字符编码到Unicode编码

+char *BIT7Decoding(char *BIT7Data, unsigned int size);

+

+// 7-Bit序列和Unicode编码是否相同

+int isBIT7Same(u_int16_t UCS2);

+

+// 判断是否是GSM字符串

+int isGSMString(char *Data);

+

+// 用户数据拆分

+struct UDS *UDCSplit(char *UDC, struct UDHS *uhds, enum EnumDCS DCS);

+

+// 获得用户数据头长度

+int getUDHL(struct UDHS *udhs);

+

+// 计算需要的7-Bit编码字节数

+int SeptetsLength(char *source);

+

+// 将7-Bit编码字节数换算成UCS2编码字符数

+int SeptetsToChars(char *source, int index, int septets);

+

+// 在用户数据头中增加长短信信息元素

+struct UDHS *UpdateUDH(struct UDHS *udhs, int CSMMR, int total, int index);

+

+//单条短信编码

+char *SoloPDUEncoding(char *SCA, char *DA, char *UC, struct UDHS *udhs, enum EnumDCS DCS);

+

+// SCA编码

+char *SCAEncoding(char *SCA);

+

+// PDUTYPE 编码

+char *PDUTypeEncoding(bool UDH);

+

+// MR,消息参考值

+char *MREncoding();

+

+//接收方SME地址

+char *DAEncoding(char *DA);

+

+// 协议标识

+char *PIDEncoding();

+

+// 编码方案

+char *DCSEncoding(char *UD, enum EnumDCS DCS);

+

+// 用户数据长度及内容

+char *UDEncoding(char *UD, struct UDHS *udhs, enum EnumDCS DCS);

+

+// 用户数据头编码

+char *UDHEncoding(struct UDHS *udhs, int *UDHL);

+

+// 用户数据内容编码

+char *UDCEncoding(char *UDC, int *UDCL, int UDHL, enum EnumDCS DCS);

+

+// 将UCS2编码字符串转换成7-Bit编码字节 序列

+struct ByteArray *BIT7Encoding(char *UDC, int *Septets);

+

+//  7-Bit编码压缩

+char *BIT7Pack(struct ByteArray *Bit7Array, int UDHL);

+

+void sms_init();

+

+#endif //SMS_SMS_H

diff --git a/mbtk/mbtk_lib/inc/mbtk_sock_internal.h b/mbtk/mbtk_lib/inc/mbtk_sock_internal.h
new file mode 100644
index 0000000..9e2ec2e
--- /dev/null
+++ b/mbtk/mbtk_lib/inc/mbtk_sock_internal.h
@@ -0,0 +1,58 @@
+#ifndef MBTK_SOCK_INTERNAL_INCLUDE
+#define MBTK_SOCK_INTERNAL_INCLUDE
+#include "mbtk_sock2.h"
+//#include <openssl/ssl.h>
+
+#define MBTK_HANDLE_MAX_NUM 5
+#define MBTK_SOCK_MAX_NUM 10
+
+typedef struct {
+    int fd;
+    entropy_context* entropy;
+    ctr_drbg_context* ctr_drbg;
+    ssl_context *ssl;
+    ssl_session *saved_session;
+    x509_crt *cacert;
+    x509_crt *clicert;
+    pk_context* pkey;
+} mbtk_sock_inter_info_s;
+
+typedef struct {
+    mbtk_init_info init_info;
+    int sock_num;
+    mbtk_sock_inter_info_s inter_infos[MBTK_SOCK_MAX_NUM];
+    mbtk_sock_info infos[MBTK_SOCK_MAX_NUM];
+} mbtk_sock_s;
+struct options
+{
+    const char *server_name;    /* hostname of the server (client only)     */
+    const char *server_addr;    /* address of the server (client only)      */
+    int server_port;            /* port on which the ssl service runs       */
+    int debug_level;            /* level of debugging                       */
+    int nbio;                   /* should I/O be blocking?                  */
+    const char *request_page;   /* page on server to request                */
+    int request_size;           /* pad request with header to requested size */
+    const char *ca_file;        /* the file with the CA certificate(s)      */
+    const char *ca_path;        /* the path with the CA certificate(s) reside */
+    const char *crt_file;       /* the file with the client certificate     */
+    const char *key_file;       /* the file with the client key             */
+    const char *psk;            /* the pre-shared key                       */
+    const char *psk_identity;   /* the pre-shared key identity              */
+    int force_ciphersuite[2];   /* protocol/ciphersuite to use, or all      */
+    int renegotiation;          /* enable / disable renegotiation           */
+    int allow_legacy;           /* allow legacy renegotiation               */
+    int renegotiate;            /* attempt renegotiation?                   */
+    int renego_delay;           /* delay before enforcing renegotiation     */
+    int exchanges;              /* number of data exchanges                 */
+    int min_version;            /* minimum protocol version accepted        */
+    int max_version;            /* maximum protocol version accepted        */
+    int auth_mode;              /* verify mode for connection               */
+    unsigned char mfl_code;     /* code for maximum fragment length         */
+    int trunc_hmac;             /* negotiate truncated hmac or not          */
+    int reconnect;              /* attempt to resume session                */
+    int reco_delay;             /* delay in seconds before resuming session */
+    int tickets;                /* enable / disable session tickets         */
+    const char *alpn_string;    /* ALPN supported protocols                 */
+} opt;
+
+#endif /* MBTK_SOCK_INTERNAL_INCLUDE */
\ No newline at end of file
diff --git a/mbtk/mbtk_lib/inc/mbtk_utf.h b/mbtk/mbtk_lib/inc/mbtk_utf.h
new file mode 100644
index 0000000..6a16ced
--- /dev/null
+++ b/mbtk/mbtk_lib/inc/mbtk_utf.h
@@ -0,0 +1,85 @@
+//

+// Created by hitmoon on 15-12-17.

+//

+

+#ifndef SMS_UTF_H

+#define SMS_UTF_H

+

+#include <stddef.h>

+#include <sys/types.h>

+

+typedef unsigned int UTF32;

+/* at least 32 bits */

+typedef unsigned short UTF16;

+/* at least 16 bits */

+typedef unsigned char UTF8;

+/* typically 8 bits */

+typedef unsigned char Boolean; /* 0 or 1 */

+

+/* Some fundamental constants */

+#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD

+#define UNI_MAX_BMP (UTF32)0x0000FFFF

+#define UNI_MAX_UTF16 (UTF32)0x0010FFFF

+#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF

+#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF

+

+typedef enum {

+    conversionOK, /* conversion successful */

+            sourceExhausted, /* partial character in source, but hit end */

+            targetExhausted, /* insuff. room in target for conversion */

+            sourceIllegal        /* source sequence is illegal/malformed */

+} ConversionResult;

+

+typedef enum {

+    strictConversion = 0,

+    lenientConversion

+} ConversionFlags;

+

+/* This is for C++ and does no harm in C */

+#ifdef __cplusplus

+extern "C" {

+#endif

+

+ConversionResult ConvertUTF8toUTF16(

+        const UTF8 **sourceStart, const UTF8 *sourceEnd,

+        UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags);

+

+ConversionResult ConvertUTF16toUTF8(

+        const UTF16 **sourceStart, const UTF16 *sourceEnd,

+        UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags);

+

+ConversionResult ConvertUTF8toUTF32(

+        const UTF8 **sourceStart, const UTF8 *sourceEnd,

+        UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags);

+

+ConversionResult ConvertUTF32toUTF8(

+        const UTF32 **sourceStart, const UTF32 *sourceEnd,

+        UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags);

+

+ConversionResult ConvertUTF16toUTF32(

+        const UTF16 **sourceStart, const UTF16 *sourceEnd,

+        UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags);

+

+ConversionResult ConvertUTF32toUTF16(

+        const UTF32 **sourceStart, const UTF32 *sourceEnd,

+        UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags);

+

+Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd);

+

+#ifdef __cplusplus

+}

+#endif

+

+// 获得下一个char的起始地址

+u_int32_t next_char(unsigned char **string);

+

+const unsigned char *utf32toutf8(wchar_t *source, unsigned char *target, size_t size,  int *len);

+

+unsigned char *utf16toutf8(unsigned short *source, unsigned char *target, size_t size,  int *len);

+unsigned short *utf8toutf16(unsigned char *source, unsigned short *target, size_t size,  int *len);

+

+int utf8len(unsigned char *string);

+int is_acsii(unsigned char *string);

+size_t utf8_get_size(unsigned char *source, size_t num);

+

+#endif //SMS_UTF_H

diff --git a/mbtk/mbtk_lib/inc/ringbuffer.h b/mbtk/mbtk_lib/inc/ringbuffer.h
new file mode 100755
index 0000000..dfe8b4c
--- /dev/null
+++ b/mbtk/mbtk_lib/inc/ringbuffer.h
@@ -0,0 +1,138 @@
+#include <inttypes.h>
+#include <stddef.h>
+#include <assert.h>
+/**
+ * @file
+ * Prototypes and structures for the ring buffer module.
+ */
+
+#ifndef RINGBUFFER_H
+#define RINGBUFFER_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define RING_BUFFER_ASSERT(x) assert(x)
+
+/**
+ * Checks if the buffer_size is a power of two.
+ * Due to the design only <tt> RING_BUFFER_SIZE-1 </tt> items
+ * can be contained in the buffer.
+ * buffer_size must be a power of two.
+*/
+#define RING_BUFFER_IS_POWER_OF_TWO(buffer_size) ((buffer_size & (buffer_size - 1)) == 0)
+
+/**
+ * The type which is used to hold the size
+ * and the indicies of the buffer.
+ */
+typedef size_t ring_buffer_size_t;
+
+/**
+ * Used as a modulo operator
+ * as <tt> a % b = (a & (b − 1)) </tt>
+ * where \c a is a positive index in the buffer and
+ * \c b is the (power of two) size of the buffer.
+ */
+#define RING_BUFFER_MASK(rb) (rb->buffer_mask)
+
+/**
+ * Simplifies the use of <tt>struct ring_buffer_t</tt>.
+ */
+typedef struct ring_buffer_t ring_buffer_t;
+
+/**
+ * Structure which holds a ring buffer.
+ * The buffer contains a buffer array
+ * as well as metadata for the ring buffer.
+ */
+struct ring_buffer_t {
+  /** Buffer memory. */
+  char *buffer;
+  /** Buffer mask. */
+  ring_buffer_size_t buffer_mask;
+  /** Index of tail. */
+  ring_buffer_size_t tail_index;
+  /** Index of head. */
+  ring_buffer_size_t head_index;
+};
+
+/**
+ * Initializes the ring buffer pointed to by <em>buffer</em>.
+ * This function can also be used to empty/reset the buffer.
+ * @param buffer The ring buffer to initialize.
+ * @param buf The buffer allocated for the ringbuffer.
+ * @param buf_size The size of the allocated ringbuffer.
+ */
+void ring_buffer_init(ring_buffer_t *buffer, char *buf, size_t buf_size);
+
+/**
+ * Adds a byte to a ring buffer.
+ * @param buffer The buffer in which the data should be placed.
+ * @param data The byte to place.
+ */
+void ring_buffer_queue(ring_buffer_t *buffer, char data);
+
+/**
+ * Adds an array of bytes to a ring buffer.
+ * @param buffer The buffer in which the data should be placed.
+ * @param data A pointer to the array of bytes to place in the queue.
+ * @param size The size of the array.
+ */
+void ring_buffer_queue_arr(ring_buffer_t *buffer, const char *data, ring_buffer_size_t size);
+
+/**
+ * Returns the oldest byte in a ring buffer.
+ * @param buffer The buffer from which the data should be returned.
+ * @param data A pointer to the location at which the data should be placed.
+ * @return 1 if data was returned; 0 otherwise.
+ */
+uint8_t ring_buffer_dequeue(ring_buffer_t *buffer, char *data);
+
+/**
+ * Returns the <em>len</em> oldest bytes in a ring buffer.
+ * @param buffer The buffer from which the data should be returned.
+ * @param data A pointer to the array at which the data should be placed.
+ * @param len The maximum number of bytes to return.
+ * @return The number of bytes returned.
+ */
+ring_buffer_size_t ring_buffer_dequeue_arr(ring_buffer_t *buffer, char *data, ring_buffer_size_t len);
+/**
+ * Peeks a ring buffer, i.e. returns an element without removing it.
+ * @param buffer The buffer from which the data should be returned.
+ * @param data A pointer to the location at which the data should be placed.
+ * @param index The index to peek.
+ * @return 1 if data was returned; 0 otherwise.
+ */
+uint8_t ring_buffer_peek(ring_buffer_t *buffer, char *data, ring_buffer_size_t index);
+
+
+/**
+ * Returns whether a ring buffer is empty.
+ * @param buffer The buffer for which it should be returned whether it is empty.
+ * @return 1 if empty; 0 otherwise.
+ */
+uint8_t ring_buffer_is_empty(ring_buffer_t *buffer);
+/**
+ * Returns whether a ring buffer is full.
+ * @param buffer The buffer for which it should be returned whether it is full.
+ * @return 1 if full; 0 otherwise.
+ */
+uint8_t ring_buffer_is_full(ring_buffer_t *buffer);
+
+/**
+ * Returns the number of items in a ring buffer.
+ * @param buffer The buffer for which the number of items should be returned.
+ * @return The number of items in the ring buffer.
+ */
+ring_buffer_size_t ring_buffer_num_items(ring_buffer_t *buffer);
+
+void ring_buffer_clean(ring_buffer_t *buffer);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RINGBUFFER_H */