解决Bug89842
Change-Id: I125f21b2cc227d690a2fb55c9b9128084545b4a9
diff --git a/mbtk/mbtk_rild/src/mbtk_info_server.c b/mbtk/mbtk_rild/src/mbtk_info_server.c
index 9eb165c..a18d51b 100755
--- a/mbtk/mbtk_rild/src/mbtk_info_server.c
+++ b/mbtk/mbtk_rild/src/mbtk_info_server.c
@@ -2314,79 +2314,108 @@
*/
static int req_net_sel_mode_get(mbtk_net_info_t *net, int *cme_err)
{
- //LOG("req_net_sel_mode_get() 0");
- //sleep(1);
ATResponse *response = NULL;
int tmp_int;
+ mbtk_net_opera_format_enum format;
char *tmp_ptr = NULL;
- int err = at_send_command_singleline("AT+COPS?", "+COPS:", &response);
- //LOG("req_net_sel_mode_get() 00");
- //sleep(1);
- if (err < 0 || response->success == 0 || !response->p_intermediates){
+
+ int err = at_send_command("AT+COPS=3,2", &response);
+ if (err < 0 || response->success == 0)
+ {
if(cme_err != NULL)
+ {
*cme_err = at_get_cme_error(response);
- err = -1;
+ }
+ LOGE("[%s] at_send_command err[%d], cme_err[%d], response->success[%d].", __func__, err, *cme_err, response->success);
goto exit;
}
- //LOG("req_net_sel_mode_get() 1");
- //sleep(1);
+ else
+ {
+ if(response)
+ {
+ at_response_free(response);
+ response = NULL;
+ }
+ }
+
+ err = at_send_command_singleline("AT+COPS?", "+COPS:", &response);
+ if (err < 0 || response->success == 0 || !response->p_intermediates)
+ {
+ if(cme_err != NULL)
+ {
+ *cme_err = at_get_cme_error(response);
+ }
+ LOGE("[%s] at_send_command_singleline err[%d], cme_err[%d], response->success[%d].", __func__, err, *cme_err, response->success);
+ goto exit;
+ }
+
char *line = response->p_intermediates->line;
- if(line == NULL) {
- LOG("line is NULL");
+ if(line == NULL)
+ {
+ LOGE("[%s] line is NULL.", __func__);
goto exit;
}
- //LOG("req_net_sel_mode_get() 2");
- //sleep(1);
+
err = at_tok_start(&line);
if (err < 0)
{
+ LOGE("[%s] at_tok_start fail.[%d]", __func__, err);
goto exit;
}
- //LOG("req_net_sel_mode_get() 3");
- //sleep(1);
+
err = at_tok_nextint(&line, &tmp_int);
if (err < 0)
{
+ LOGE("[%s] net_sel_mode fail.[%d]", __func__, err);
goto exit;
}
net->net_sel_mode = (uint8)tmp_int;
- //LOG("req_net_sel_mode_get() 4");
- //sleep(1);
- // +COPS: 1
- if(!at_tok_hasmore(&line)) {
+
+ if(!at_tok_hasmore(&line))
+ {
+ LOGE("[%s] no more data.[%d]", __func__);
goto exit;
}
- //LOG("req_net_sel_mode_get() 5");
- //sleep(1);
+
err = at_tok_nextint(&line, &tmp_int);
if (err < 0)
{
+ LOGE("[%s] format fail.[%d]", __func__, err);
goto exit;
}
- //LOG("req_net_sel_mode_get() 6");
- //sleep(1);
+ format = (mbtk_net_opera_format_enum)tmp_int;
+
err = at_tok_nextstr(&line, &tmp_ptr);
if (err < 0)
{
+ LOGE("[%s] plmn fail.[%d]", __func__, err);
goto exit;
}
- // memcpy(net->plmn, tmp_ptr, strlen(tmp_ptr));
- net->plmn = (uint32)atoi(tmp_ptr);
- //LOG("req_net_sel_mode_get() 7");
- //sleep(1);
+ if(format == MBTK_NET_OPERA_FORMAT_NUMBER)
+ {
+ net->plmn = (uint32)atoi(tmp_ptr);
+ }
+ else
+ {
+ LOGE("[%s] plmn format error.", __func__);
+ goto exit;
+ }
+
err = at_tok_nextint(&line, &tmp_int);
if (err < 0)
{
+ LOGE("[%s] net reg type fail.[%d]", __func__, err);
goto exit;
}
net->net_type = (uint8)tmp_int;
net->net_state = (uint8)MBTK_NET_AVIL_STATE_CURRENT;
-
exit:
- //LOG("req_net_sel_mode_get() 8");
- //sleep(1);
- at_response_free(response);
+ if(response)
+ {
+ at_response_free(response);
+ response = NULL;
+ }
return err;
}