Reset : Update LYNQ test

Change-Id: I1846ff06ae0414fe6f3c7e83af14e55da98a4e96
diff --git a/mbtk/test/liblynq_lib/lynq_nw_test.c b/mbtk/test/liblynq_lib/lynq_nw_test.c
new file mode 100755
index 0000000..82cd6d8
--- /dev/null
+++ b/mbtk/test/liblynq_lib/lynq_nw_test.c
@@ -0,0 +1,265 @@
+#include "lynq_qser_network.h"
+#include "mbtk_type.h"
+#include "mbtk_info_api.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+
+char *tech_domain[] = {"NONE", "3GPP", "3GPP2"};
+char *radio_tech[] = {"unknown", 
+    "TD_SCDMA", "GSM",      "HSPAP",    "LTE",      "EHRPD",    "EVDO_B", 
+    "HSPA",     "HSUPA",    "HSDPA",    "EVDO_A",   "EVDO_0",   "1xRTT", 
+    "IS95B",    "IS95A",    "UMTS",     "EDGE",     "GPRS",     "NONE"};
+
+void nw_event_ind_handler (
+    nw_client_handle_type h_nw, 
+    u_int32_t ind_flag, 
+    void                  *ind_msg_buf, 
+    u_int32_t              ind_msg_len, 
+    void                  *contextPtr)
+{
+    uint8 *net_data = NULL;
+
+    net_data = (uint8*)ind_msg_buf;
+
+    if(ind_msg_buf && ind_msg_len > 0)//无处理原始数据传输过来
+    {
+        if(*net_data == 0)
+        { // CS
+                printf("CS:act=%d, mode=%d\n", *(net_data + 1), *(net_data + 2));
+        }
+        else
+        { // PS
+                printf("PS[%s]:act=%d, mode=%d\n", *(net_data + 3) == 0 ? "GSM/WCDMA" : "LTE", *(net_data + 1), *(net_data + 2));
+        }
+    }
+    else
+    {
+        printf("NET_CB : NULL");
+    }
+
+}
+
+
+int main(int argc, char *argv[])
+{
+    char operator[10];
+    int opt;
+    int lv_voll = 0;
+    nw_client_handle_type handle = -1;
+    mbtk_log_init("radio", "NW_TEST");
+
+    while(1)
+    {
+        printf("=========network main=========\n"
+            "\t0 exit\n"
+            "\t1 network init\n"
+            "\t2 network add rx msg handle\n"
+            "\t3 network band set config\n"
+            "\t4 network get operator name\n"
+            "\t5 network get reg status\n"
+            "\t6 network get signal strength\n"
+            "\t7 network set oos config\n"
+            "\t8 network get oos config\n"
+            "\t9 network set rf config\n"
+            "\t10 network get rf config\n"
+            "\t11 network deinit\n"
+            "operator: >> ");
+
+        fgets(operator, sizeof(operator), stdin);
+        fflush(stdin);
+        opt = atoi(operator);
+        switch (opt)
+        {
+        case 0:
+            printf("main exit\n");
+            return 0;
+        case 1:
+            qser_nw_client_init(&handle);
+            break;
+        case 2:
+            qser_nw_add_rx_msg_handler(handle, nw_event_ind_handler, NULL);
+            break;
+        case 3:
+            {
+                //漫游开关现在不支持,所以就不用配置
+                printf("please input \n"
+                        "\t1:GSM \n"
+                        "\t2:WCDMA \n"
+                        "\t4:CDMA \n"
+                        "\t8:EVDO \n"
+                        "\t16:LTE \n"
+                        "\t32:TDSCDMA \n"
+                );
+                memset(operator,0x00, sizeof(operator));
+                fgets(operator, sizeof(operator)-1, stdin);
+                fflush(stdin);
+                opt = atoi(operator);
+                QSER_NW_CONFIG_INFO_T t_info;
+                switch(opt)
+                {
+                    case 1:
+                        t_info.preferred_nw_mode = QSER_NW_MODE_GSM;//2G
+                        break;
+                    case 2:
+                        t_info.preferred_nw_mode = QSER_NW_MODE_WCDMA;//3G
+                        break;
+                    case 4:
+                        t_info.preferred_nw_mode = QSER_NW_MODE_CDMA;//3G
+                        break;
+                    case 8:
+                        t_info.preferred_nw_mode = QSER_NW_MODE_EVDO;//3G
+                        break;
+                    case 16:
+                        t_info.preferred_nw_mode = QSER_NW_MODE_LTE;//4G
+                        break;
+                    case 32:
+                        t_info.preferred_nw_mode = QSER_NW_MODE_TDSCDMA;//3G
+                        break;
+                    default:
+                        t_info.preferred_nw_mode = QSER_NW_MODE_LTE;//4G
+                        break;
+                }
+                qser_nw_set_config(handle, &t_info);
+            }
+            break;
+        case 4:
+            {
+                QSER_NW_OPERATOR_NAME_INFO_T t_info;
+                int err = qser_nw_get_operator_name(handle, &t_info);
+                if(err)
+                {
+                    printf("Error : %d\n", err);
+                } else
+                {
+                    printf("Operator : %s, %s, %s, %s\n", t_info.long_eons, t_info.short_eons, t_info.mcc, t_info.mnc);
+                }
+            }
+            break;
+        case 5:
+            {
+                QSER_NW_REG_STATUS_INFO_T reg;
+                int err = qser_nw_get_reg_status(handle, &reg);
+                if(err)
+                {
+                    printf("Error : %d\n", err);
+                }
+                else
+                {
+                    if(reg.voice_registration_details_3gpp_valid)
+                    {
+                        printf("voice_registration_details_3gpp: tech_domain=%d, radio_tech=%d, mcc=%s, mnc=%s, roaming=%d, forbidden=%d, cid=0x%X, lac=%d, psc=%d, tac=%d\n", 
+                        reg.voice_registration_details_3gpp.tech_domain, 
+                        reg.voice_registration_details_3gpp.radio_tech,
+                        reg.voice_registration_details_3gpp.mcc,
+                        reg.voice_registration_details_3gpp.mnc,
+                        reg.voice_registration_details_3gpp.roaming,
+                        reg.voice_registration_details_3gpp.forbidden,                    
+                        reg.voice_registration_details_3gpp.cid,
+                        reg.voice_registration_details_3gpp.lac,
+                        reg.voice_registration_details_3gpp.psc,
+                        reg.voice_registration_details_3gpp.tac);
+                    }
+                    if(reg.data_registration_details_3gpp_valid)
+                    {
+                        printf("data_registration_details_3gpp: tech_domain=%d, radio_tech=%d, mcc=%s, mnc=%s, roaming=%d, forbidden=%d, cid=0x%X, lac=%d, psc=%d, tac=%d\n", 
+                         reg.data_registration_details_3gpp.tech_domain, 
+                         reg.data_registration_details_3gpp.radio_tech,
+                         reg.data_registration_details_3gpp.mcc,
+                         reg.data_registration_details_3gpp.mnc,
+                         reg.data_registration_details_3gpp.roaming,
+                         reg.data_registration_details_3gpp.forbidden,                    
+                         reg.data_registration_details_3gpp.cid,
+                         reg.data_registration_details_3gpp.lac,
+                         reg.data_registration_details_3gpp.psc,
+                         reg.data_registration_details_3gpp.tac);
+                    }
+                    //printf("Data Reg: radio_tech = %d, lac = %x, cid = %x\n", reg.data_registration_details_3gpp.radio_tech, reg.data_registration_details_3gpp.lac, reg.data_registration_details_3gpp.cid);
+                    //printf("Voice Reg: radio_tech = %d, lac = %x, cid = %x\n", reg.voice_registration_details_3gpp.radio_tech, reg.voice_registration_details_3gpp.lac, reg.voice_registration_details_3gpp.cid);
+                }
+            }
+            break;
+        case 6:
+            {
+                QSER_NW_SIGNAL_STRENGTH_INFO_T sig;
+                int err = qser_nw_get_signal_strength(handle, &sig);
+                if(err)
+                {
+                    printf("Error : %d\n", err);
+                }
+                else
+                {
+                    if (sig.gsm_sig_info_valid == TRUE)
+                        printf("Signal GSM: rssi = %d\n", sig.gsm_sig_info.rssi);
+                    else if (sig.lte_sig_info_valid == TRUE)
+                        printf("Signal LTE: rssi = %d, rsrp = %d, rsrq = %d, snr = %d\n", sig.lte_sig_info.rssi , sig.lte_sig_info.rsrp, sig.lte_sig_info.rsrq, sig.lte_sig_info.snr);
+                    else if (sig.wcdma_sig_info_valid == TRUE)
+                        printf("Signal UTRAN: rssi = %d, ecio = %d\n", sig.wcdma_sig_info.rssi , sig.wcdma_sig_info.ecio);
+                    else
+                        printf("Signal type not supported \n");
+                }
+            }
+            break;
+        case 7:
+            {
+                QSER_NW_OOS_CONFIG_INFO_T pt_info_s;
+                memset(&pt_info_s, 0x00, sizeof(QSER_NW_OOS_CONFIG_INFO_T));
+                /*取值范围0-255,设置时间自定义
+                phase 1   5次       次数无法更改,这五次都是以10秒为一次的间隔搜网
+                phase 2   5次      次数无法更改,这五次都是以15秒为一次的间隔搜网
+                phase 3   不限制次数的秒数设置,第三阶段不限制次数以20秒为一次的间隔搜网
+                如果要关闭OOS配置,则把min step max 全部配置为0即可
+                */
+                pt_info_s.type = QSER_NW_OOS_CFG_TYPE_FULL_BAND_SCAN;//平台提供自定义配置搜网时间间隔
+                {
+                    pt_info_s.u.full_band_scan_info.t_min = 10;//phase 1
+                    pt_info_s.u.full_band_scan_info.t_step = 15;//phase 2
+                    pt_info_s.u.full_band_scan_info.t_num = 0;//可以不配置,并没有使用
+                    pt_info_s.u.full_band_scan_info.t_max = 20;//phase 3
+                }
+                printf("set OOS %d %d %d \n",pt_info_s.u.full_band_scan_info.t_min, pt_info_s.u.full_band_scan_info.t_step, pt_info_s.u.full_band_scan_info.t_max);
+                //pt_info_s.type = QSER_NW_OOS_CFG_TYPE_FAST_SCAN;平台本身有历史频点优先处理的逻辑(无接口不需要我们进行处理)
+                qser_nw_set_oos_config(handle, &pt_info_s);
+            }
+            break;
+        case 8:
+            {
+                QSER_NW_OOS_CONFIG_INFO_T pt_info_g;
+                qser_nw_get_oos_config(handle, &pt_info_g);
+                if (pt_info_g.type == QSER_NW_OOS_CFG_TYPE_FULL_BAND_SCAN)
+                    printf("TYPE: %d min: %d setp: %d max: %d\n", pt_info_g.type, pt_info_g.u.full_band_scan_info.t_min, pt_info_g.u.full_band_scan_info.t_step, pt_info_g.u.full_band_scan_info.t_max);
+                else
+                    printf("type not supported \n");
+            }
+            break;
+        case 9:
+            {
+                printf("please input 0 or 1 or 4: \n");
+                memset(operator,0x00, sizeof(operator));
+                fgets(operator, sizeof(operator)-1, stdin);
+                fflush(stdin);
+                opt = atoi(operator);
+                printf("rf_mode: [%d]\n",opt);
+                qser_nw_set_rf_mode(handle, opt);
+            }
+            break;
+        case 10:
+            {
+                int rf_t;
+                qser_nw_get_rf_mode(handle, &rf_t);
+                printf(">>>rf_mode = [%d]\n",rf_t);
+            }
+            break;
+        case 11:
+            qser_nw_client_deinit(handle);
+            break;
+        default:
+            break;
+        }
+
+    }
+
+    return 0;
+}
+