Add T106 header file.
Change-Id: I139abf126f194dc011d5cdf531722152f90a1e90
diff --git a/mbtk/test/lynq_gnss_test.c b/mbtk/test/lynq_gnss_test.c
deleted file mode 100755
index 9ba5185..0000000
--- a/mbtk/test/lynq_gnss_test.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/**
- * \file gnss_test.c
- * \brief A Documented file.
- *
- * Detailed description
- * \Author: Sniper <e190@163.com>
- * \Version: 1.0.0
- * \Date: 2022-03-26
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <errno.h>
-#include <termios.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <termios.h>
-#include <sys/ioctl.h>
-#include "mbtk_type.h"
-#include "lynq/lynq_gnss.h"
-//#include "mbtk_gnss.h"
-
-void gnss_handler_cb
-(
- uint32 h_loc,
- int e_msg_id,
- void *pv_data,
- void *context_ptr
-) {
- printf("e_msg_id=%d\n", e_msg_id);
- switch(e_msg_id)
- {
- case E_LYNQ_LOC_MSG_ID_STATUS_INFO:
- break;
- case E_LYNQ_LOC_MSG_ID_LOCATION_INFO:
- break;
- case E_LYNQ_LOC_MSG_ID_SV_INFO:
- break;
- case E_LYNQ_LOC_MSG_ID_NMEA_INFO:
- {
- LYNQ_LOC_NMEA_INFO_T *pt_nmea = (LYNQ_LOC_NMEA_INFO_T *)pv_data;
-
- printf("NMEA info: timestamp=%lld, length=%d, nmea=%s\n",
- pt_nmea->timestamp, pt_nmea->length, pt_nmea->nmea);
- break;
- }
- case E_LYNQ_LOC_MSG_ID_CAPABILITIES_INFO:
- break;
- case E_LYNQ_LOC_MSG_ID_AGPS_STATUS:
- break;
- case E_LYNQ_LOC_MSG_ID_NI_NOTIFICATION:
- break;
- case E_LYNQ_LOC_MSG_ID_XTRA_REPORT_SERVER:
- break;
- }
-}
-#if 1
-int main(int argc, char *argv[])
-{
- int ret;
-
- ret = lynq_gnss_enable_glonass();
- if(ret < 0) {
- printf("lynq_gnss_init FAIL. ret:%d\n",ret);
- return -1;
- }
-
- ret = lynq_gnss_init();
- if(ret < 0) {
- printf("lynq_gnss_init FAIL. ret:%d\n",ret);
- return -1;
- }
-
- lynq_gnss_callback_reg(gnss_handler_cb);
-
- ret = lynq_gnss_agps_dataconnopen();
- if(ret < 0) {
- printf("lynq_gnss_agps_dataconnopen FAIL. ret:%d\n", ret);
- return -1;
- }
-
- ret = lynq_gnss_start();
- if(ret < 0) {
- printf("lynq_gnss_start FAIL. ret:%d\n",ret);
- return -1;
- }
- sleep(10);
- ret = lynq_gnss_stop();
- if(ret < 0) {
- printf("lynq_gnss_stop FAIL. ret:%d\n",ret);
- return -1;
- }
- ret = lynq_gnss_deinit();
- if(ret < 0) {
- printf("lynq_gnss_deinit FAIL. ret:%d\n",ret);
- return -1;
- }
- return 0;
-}
-
-#else
-
-int main(int argc, char *argv[])
-{
- int ret;
- int opt;
- char dev_file[12] = {0};
-
- while(1)
- {
- printf("=========gnss main=========\n"
- "\t0 exit\n"
- "\t1 gnss init\n"
- "\t2 gnss add callback function\n"
- "\t3 gnss start\n"
- "\t4 gnss stop\n"
- "\t5 gnss deinit\n"
- "\t6 agps down\n"
- "please input operator: >> ");
- scanf("%d", &opt);
- switch (opt)
- {
- case 0:
- printf("main exit\n");
- return 0;
- case 1:
- ret = lynq_gnss_init();
- if(ret < 0)
- {
- printf("lynq_gnss_init FAIL. ret:%d\n",ret);
- return -1;
- }
- opt = 0;
- break;
- case 2:
- {
-
- lynq_gnss_callback_reg(gnss_handler_cb);
- break;
- }
- case 3:
- {
- lynq_gnss_start();
- break;
- }
- case 4:
- {
- lynq_gnss_stop();
- break;
- }
- case 5:
- {
- lynq_gnss_deinit();
- break;
- }
- case 6:
- {
- ret = lynq_gnss_agps_dataconnopen();
- if(ret < 0)
- {
- printf("lynq_gnss_agps_dataconnopen FAIL. ret:%d\n", ret);
- return -1;
- }
- break;
- }
- default:
- break;
- }
- }
-
- return 0;
-}
-#endif
diff --git a/mbtk/test/lynq_sms_test.c b/mbtk/test/lynq_sms_test.c
deleted file mode 100755
index e16893d..0000000
--- a/mbtk/test/lynq_sms_test.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- * \file dtmf_test.c
- * \brief A Documented file.
- *
- * Detailed description
- * \Author: jinLuo
- * \Version: 1.0.0
- * \Date: 2022-12-1
- */
-
-/******************************************************************************\
- * Include files
-\******************************************************************************/
-#include <pthread.h>
-#include <time.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-#include <stdio.h>
-#include <signal.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <poll.h>
-#include <stdlib.h>
-
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include "lynq/lynq_sms_api.h"
-
-
-int main(int argc, char *argv[])
-{
- char operator[20];
- int opt;
- int ret, uToken;
- char serNum[50] = {0};
-
- while(1)
- {
- printf("=========audio main=========\n"
- "\t0 exit\n"
- "\t1 sms init\n"
- "\t2 send sms\n"
- "\t3 wait receive new sms\n"
- "\t4 delete sms(int index);\n"
- "\t5 list sms\n"
- "\t6 query sms storage status\n"
- "\t7 query service number\n"
- "\t8 set service number\n"
- "\t9 deinit sms\n"
- "operator: >> ");
- fgets(operator, sizeof(operator), stdin);
- fflush(stdin);
- opt = atoi(operator);
- switch (opt)
- {
- case 0:
- printf("main exit\n");
- return 0;
- case 1:
- lynq_init_sms(uToken);
- break;
- case 2:
- printf("please input volume (0~1): \n");
- fgets(operator, sizeof(operator), stdin);
- fflush(stdin);
- opt = atoi(operator);
- if(opt)
- {
- lynq_send_sms("15775590631", 1, "nihaoma,wohenhao"); //text mode
- }
- else{
- lynq_send_sms("29", 0, "0891683108200805F011000D91685177550996F70008A80E4F60597D5417FF1F62115F88597D"); //pud mode
- }
- break;
- case 3:
- lynq_wait_receive_new_sms(&uToken);
- break;
- case 4:
- printf("please input volume (0~100): \n");
- fgets(operator, sizeof(operator), stdin);
- fflush(stdin);
- opt = atoi(operator);
- lynq_delete_sms(opt);
- break;
- case 5:
- printf("please input index (0~50): \n");
- fgets(operator, sizeof(operator), stdin);
- fflush(stdin);
- opt = atoi(operator);
- lynq_list_sms(1, opt, "ALL" );
- //opt : 0 ; Query all stored SMS messages
- //opt : > 0 ; Gets the content of the SMS message starting from the index number
- break;
- case 6:
- lynq_query_sms_storage_status();
- break;
- case 7:
- ret = lynq_get_smsc_address(serNum);
- if(!ret)
- printf("get_smsc:%s\n", serNum);
- break;
- case 8:
- printf("please input service num: \n");
- fgets(operator, sizeof(operator), stdin);
- fflush(stdin);
- ret= lynq_set_smsc_address(operator);
- break;
- case 9:
- lynq_deinit_sms();
- break;
- default:
- break;
- }
- }
-
- return 0;
-}
diff --git a/mbtk/test/mbtk_info_test.c b/mbtk/test/mbtk_info_test.c
index 73a7050..7be5f8f 100755
--- a/mbtk/test/mbtk_info_test.c
+++ b/mbtk/test/mbtk_info_test.c
@@ -12,7 +12,8 @@
#include <signal.h>
#include "mbtk_info_api.h"
-#include "lynq/lynq_sms_api.h"
+
+#define DSC_to_msg(DSC) (DSC == 0 ? "Bit7" : (DSC == 1 ? "Bit8" : "UCS2"))
//#include "lynq_net_api.h"
diff --git a/mbtk/test/tcp_test.c b/mbtk/test/tcp_test.c
new file mode 100755
index 0000000..51daace
--- /dev/null
+++ b/mbtk/test/tcp_test.c
@@ -0,0 +1,176 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <netinet/in.h>
+#include <pthread.h>
+#include <sys/epoll.h>
+#include <string.h>
+#include <fcntl.h>
+#include <signal.h>
+
+#include "mbtk_tcpip.h"
+#include "mbtk_log.h"
+
+
+static void help()
+{
+ printf("\n************************************************************************\n");
+ printf("net_open: Open network.\n");
+ printf("net_close: Close network.\n");
+ printf("link_open <link_id> <ser_addr> <ser_port> <loc_port> <TCP/UDP> <CLI/SER> <ack> <ssl> <ignore_cert> <heartbeat_time> <delay_time> <read_cb>: Open link.\n");
+ printf("link_close <link_id>: Close link.\n");
+ printf("send <link_id> <data>:Send data.\n");
+ printf("recv <link_id> <len>:Recv data.\n");
+ printf("traffic_reset <link_id>:Traffic reset.\n");
+ printf("traffic_get <link_id>:Traffic get.\n");
+ printf("state_get <link_id>:Link state get.\n");
+ printf("tcp_info <link_id>:TCP information state get.\n");
+ printf("\n************************************************************************\n");
+}
+
+static void sig_process(int sig)
+{
+ LOGI("I got signal %d\n", sig);
+ switch(sig)
+ {
+ case SIGINT: // Ctrl + C
+ {
+ LOGI("Exit by SIGINT.\n");
+ mbtk_tcpip_err_enum err = mbtk_tcpip_net_close();
+ if(err == MBTK_TCPIP_ERR_SUCCESS) {
+ printf("Net close success.\n");
+ } else {
+ printf("Net close fail:%d\n", err);
+ }
+ exit(0);
+ }
+ case SIGQUIT: // Ctrl + \ (类似 SIGINT ,但要产生core文件)
+ {
+ LOGI("Exit by SIGQUIT.\n");
+ mbtk_tcpip_err_enum err = mbtk_tcpip_net_close();
+ if(err == MBTK_TCPIP_ERR_SUCCESS) {
+ printf("Net close success.\n");
+ } else {
+ printf("Net close fail:%d\n", err);
+ }
+ exit(0);
+ }
+ case SIGTERM:// 默认kill (同 SIGKILL ,但 SIGKILL 不可捕获)
+ {
+ LOGI("Exit by SIGTERM.\n");
+ mbtk_tcpip_err_enum err = mbtk_tcpip_net_close();
+ if(err == MBTK_TCPIP_ERR_SUCCESS) {
+ printf("Net close success.\n");
+ } else {
+ printf("Net close fail:%d\n", err);
+ }
+ exit(0);
+ }
+ case SIGTSTP:// Ctrl + Z (同 SIGSTOP ,但 SIGSTOP 不可捕获)
+ {
+ LOGI("Exit by SIGTSTP.\n");
+ exit(0);
+ }
+ case SIGSEGV: // 如空指针
+ {
+ LOGI("Exit by SIGSEGV.\n");
+ exit(0);
+ }
+ default:
+ {
+ LOGI("Unknown sig:%d\n",sig);
+ break;
+ }
+ }
+}
+
+void tcpip_print_tcp_info(mbtk_tcpip_tcp_state_info_s *info)
+{
+ printf("Link - %d\n", info->link_id);
+ printf("fd - %d\n", info->sock_fd);
+ printf("State - %d\n", info->state);
+ printf("Recv data length - %d\n", info->recv_data_len);
+}
+
+void tcpip_read_cb(int link_id, const char* data, int data_len)
+{
+ printf("\nRECV(%d-%d):%s\n", link_id, data_len, data);
+}
+
+void tcpip_net_callback_func(int state, const char* addr)
+{
+ if(state) {
+ printf("Net conncect, IP : %s\n", addr);
+ } else {
+ printf("Net disconnect.\n");
+ }
+}
+
+
+int main(int argc, char *argv[])
+{
+
+
+ printf(">>>>>>>>>>>START TCP TEST>>>>>>>>>>>>>\r\n");
+ mbtk_tcpip_err_enum err;
+
+ mbtk_tcpip_info_t info;
+ memset(&info, 0x0, sizeof(mbtk_tcpip_info_t));
+ char *ip = "www.chaixiongfeng.group";
+ strcpy(&info.ser_addr,ip);
+ info.link_id=1;
+ info.ser_port =45002;
+ info.prot_type = MBTK_SOCK_TCP;
+ info.tcpip_type = MBTK_TCPIP_TYPE_CLIENT;
+ info.read_cb = NULL;
+
+
+ err = mbtk_tcpip_sock_open((const mbtk_tcpip_info_t*)(&info));
+ if(err == MBTK_TCPIP_ERR_SUCCESS) {
+ printf("Link open success.\n");
+ } else {
+ printf("Link open fail:%d\n", err);
+ return 0;
+ }
+
+ while(1)
+ {
+ char *data="stargcharge connect\r\n";
+ int len = mbtk_tcpip_send(1, data, strlen(data), NULL, 0);
+ if(len == strlen(data))
+ {
+ printf("Send success:%d.\n", len);
+ }
+ else
+ {
+ printf("Send fail:%d/%d\n", len, strlen(data));
+ }
+
+ char buff[128];
+ len = mbtk_tcpip_read(1, buff, 128);
+ if(len > 0)
+ {
+ printf("RECV[%d]:%s\n", len, buff);
+ }
+ else
+ {
+ printf("RECV fail:%d\n", len);
+ }
+
+ err = mbtk_tcpip_sock_close(1);
+ if(err == MBTK_TCPIP_ERR_SUCCESS)
+ {
+ printf("Link close success.\n");
+ }
+ else
+ {
+ printf("Link close fail:%d\n", err);
+ }
+ sleep(5);
+ }
+}
+
+