[Feature][T108][task-view-1501][NW]add an event timer,get signal information every 5 seconds,and call gsw_reg_sig_info_callback

Only Configure: No
Affected branch: GSW_V1453
Affected module: Network
Is it affected on IC: only ASR
Self-test: yes
Doc Update: no

Change-Id: I407dc3ede5272d131ffc941430edc239b71e14ac
diff --git a/mbtk/libgsw_lib/gsw_nw_interface.c b/mbtk/libgsw_lib/gsw_nw_interface.c
index eff5e5b..8b36c6d 100755
--- a/mbtk/libgsw_lib/gsw_nw_interface.c
+++ b/mbtk/libgsw_lib/gsw_nw_interface.c
@@ -1227,6 +1227,77 @@
 }

 

 

+void gsw_sig_info_timer()

+{

+    int ret = -1;

+    if(nw_init_flag == 0 || nw_info_handle == NULL)

+    {

+        return;

+    }

+

+    mbtk_signal_info_t signal;

+    signalStrength_t sig_strength;

+

+    while(nw_init_flag)

+    {

+        memset(&signal, 0x0, sizeof(mbtk_signal_info_t));

+        memset(&sig_strength, 0x0, sizeof(signalStrength_t));

+        ret = mbtk_net_signal_get(nw_info_handle, &signal);

+        if(ret != 0)

+        {

+            LOGE("mbtk_net_signal_get fail\n");

+        }

+

+        else

+        {

+            LOGD("signal.type=%d\n", signal.type);

+            switch(signal.type)

+            {

+                case MBTK_RADIO_TECH_GSM:

+                case MBTK_RADIO_TECH_GSM_COMPACT:

+                case MBTK_RADIO_TECH_GSM_EGPRS:

+                {

+                    LOGD("rssi = %d\n",signal.rssi);

+                    sig_strength.gw_sig_valid = 1;

+                    sig_strength.rssi = rssi_convert_to_dBm(signal.rssi);

+                    break;

+                }

+                case MBTK_RADIO_TECH_E_UTRAN:

+                {

+                    LOGD("rsrp = %d\n",signal.rsrp);

+                    sig_strength.lte_sig_valid = 1;

+                    sig_strength.rsrp = rsrp_convert_to_dBm(signal.rsrp);

+                    sig_strength.rsrq = rsrq_convert_to_dB(signal.rsrq);

+                    break;

+                }

+                case MBTK_RADIO_TECH_UTRAN:

+                case MBTK_RADIO_TECH_UTRAN_HSDPA:

+                case MBTK_RADIO_TECH_UTRAN_HSUPA:

+                case MBTK_RADIO_TECH_UTRAN_HSDPA_HSUPA:

+                case MBTK_RADIO_TECH_UTRAN_HSPA:

+                {

+                    LOGD("rscp = %d\n",signal.rscp);

+                    sig_strength.wcdma_sig_valid = 1;

+                    sig_strength.rscp = rssi_convert_to_dBm(signal.rscp);

+                    sig_strength.ecno = ecno_convert_to_dB(signal.ecno);

+                    break;

+                }

+                default:

+                {

+                    LOGD("[%s] unknown reg type.[%d]\n", __func__, signal.type);

+                }

+            }

+        }

+        

+        if(sig_cb != NULL)

+        {

+            sig_cb(sig_strength);

+        }

+

+        sleep(SIG_TIMER);

+    }

+}

+

 

 /**

  * @brief SDK interface to call back serving info

@@ -1314,6 +1385,7 @@
 int gsw_nw_sdk_init(int token)

 {

     int ret = -1;

+    pthread_t nw_info_thread;

 

     if (nw_init_flag == 1 && nw_info_handle != NULL)

     {

@@ -1359,6 +1431,13 @@
         return GSW_HAL_NORMAL_FAIL;

     }

 

+    ret = pthread_create(&nw_info_thread, NULL, (void*)gsw_sig_info_timer, NULL);

+    if (ret != 0)

+    {

+        LOGE("pthread_create fail\n");

+        return GSW_HAL_NORMAL_FAIL;

+    }

+

     nw_init_flag = 1;

 

     return GSW_HAL_SUCCESS;