[Feature][T108][task-view-1632]【gsw】【nw】add gsw reg set gnss status event call back
Only Configure:No
Affected branch:GSW_V1453
Affected module:gsw_nw_interface
Is it affected on: only ASR
Self-test: Yes
Doc Update:No
Change-Id: Icda493413df35b8eb7e78a2a0c0159dc7d609a54
diff --git a/mbtk/libgsw_lib/gsw_nw_interface.c b/mbtk/libgsw_lib/gsw_nw_interface.c
index beb811c..5f83c41 100755
--- a/mbtk/libgsw_lib/gsw_nw_interface.c
+++ b/mbtk/libgsw_lib/gsw_nw_interface.c
@@ -43,7 +43,7 @@
typedef void (*mbtk_info_callback_func)(const void* data, int data_len);
//#define MBTK_READY_UCI "persist.mbtk.sdk.state"
-#define SDK_READY_CMD "uci get persist.mbtk.sdk__state"
+#define SDK_READY_CMD "uci get lynq_uci.sdk_ready"
#define MBTK_READY_STRING_SIZE_MAX (3+1)
@@ -1197,20 +1197,6 @@
*/
-static void convert_uci_to_gsw_modem_state(int uci, int *state)
-{
- switch(uci)
- {
- case MBTK_READY_SUCCESS:
- *state=GSW_MODEM_STATE_ONLINE;
- return;
- case MBTK_READY_INIT:
- *state=GSW_MODEM_STATE_UNKNOWN;
- return;
- }
- *state=GSW_MODEM_STATE_OFFLINE;
- return;
-}
static void gsw_serving_info_callback_thread()
{
@@ -1467,38 +1453,65 @@
return atoi(buffer);
}
-int gsw_get_modem_state(int *state)
-{
- int uci_value = get_sdk_ready();
- if(uci_value < 0)
- {
- return GSW_HAL_NORMAL_FAIL;
- }
- convert_uci_to_gsw_modem_state(uci_value,state);
- return GSW_HAL_SUCCESS;
-}
+static int g_modem_state = ((int)(GSW_MODEM_STATE_UNKNOWN)) - 1;
+static int g_gnss_state = ((int)(GSW_MODEM_STATE_UNKNOWN)) - 1;
-int g_mode_state=((int)(GSW_MODEM_STATE_UNKNOWN))-1;
void gsw_modem_state_timer()
-{
- while(nw_init_flag)
+{
+ int modem_state;
+ int gnss_state;
+
+ while (nw_init_flag)
{
- int state;
- int ret = gsw_get_modem_state(&state);
- if(modem_cb != NULL)
+ int uci_value = get_sdk_ready();
+ if (uci_value < 0)
{
- if(ret != 0)
+ modem_state = GSW_MODEM_STATE_UNKNOWN;
+ gnss_state = GSW_SDK_STATE_GPS_DOWN;
+ }
+ else
+ {
+ if ((uci_value & 0x0F) == 0)
{
- modem_cb(GSW_MODEM_STATE_UNKNOWN);
- }
- else if(state!=g_mode_state)
+ modem_state = GSW_MODEM_STATE_ONLINE;
+ }
+ else if (uci_value > 0 && uci_value <= 15)
{
- LOGE(GSW_NW,"modem state changed from %d to %d",g_mode_state,state);
- g_mode_state=state;
- modem_cb(state);
+ modem_state = GSW_MODEM_STATE_OFFLINE;
}
- }
- sleep(MODEM_TIMER);
+ else
+ {
+ modem_state = GSW_MODEM_STATE_UNKNOWN;
+ }
+
+ if (uci_value & (1 << 4))
+ {
+ gnss_state = GSW_SDK_STATE_GPS_DOWN;
+ }
+ else
+ {
+ gnss_state = GSW_SDK_STATE_GPS_UP;
+ }
+ }
+
+ if (modem_cb != NULL)
+ {
+
+ if (modem_state != g_modem_state)
+ {
+ LOGE(GSW_NW, "Modem state changed from %d to %d", g_modem_state, modem_state);
+ modem_cb(modem_state);
+ g_modem_state = modem_state;
+ }
+
+ if (gnss_state != g_gnss_state)
+ {
+ LOGE(GSW_NW, "GNSS state changed from %d to %d", g_gnss_state, gnss_state);
+ modem_cb(gnss_state);
+ g_gnss_state = gnss_state;
+ }
+ }
+ sleep(MODEM_TIMER);
}
}