Merge "修复当mbtk_log.json 文件,syslog 和radio log 关闭时,mbtk_logd 进程free 无效参数问题" into mbtk_source_v2
diff --git a/mbtk/include/mbtk/mbtk_info_api.h b/mbtk/include/mbtk/mbtk_info_api.h
index 14e62cc..3f3e08a 100755
--- a/mbtk/include/mbtk/mbtk_info_api.h
+++ b/mbtk/include/mbtk/mbtk_info_api.h
@@ -138,6 +138,34 @@
MBTK_CELL_TYPE_LTE
} mbtk_cell_type_enum;
+/*
+ 0 : Plmm long character format
+ 1 : Plmn Short character format
+ 2 : Plmn number format
+*/
+typedef enum
+{
+ MBTK_NET_OPERA_FORMAT_LONG_CHAR = 0,
+ MBTK_NET_OPERA_FORMAT_SHORT_CHAR,
+ MBTK_NET_OPERA_FORMAT_NUMBER,
+} mbtk_net_opera_format_enum;
+
+/*
+ 0 : Automatic registration
+ 1 : Manual registration
+ 2 : Forced cancellation
+ 3 : Set format only
+ 4 : Manual registration is performed first, and automatic registration fails
+*/
+typedef enum
+{
+ MBTK_NET_OPERA_REG_MODE_AUTO = 0,
+ MBTK_NET_OPERA_REG_MODE_MANUAL,
+ MBTK_NET_OPERA_REG_MODE_LOGOUT,
+ MBTK_NET_OPERA_REG_MODE_SET_FORMAT,
+ MBTK_NET_OPERA_REG_MODE_MANUAL_AUTO,
+} mbtk_net_opera_reg_mode_enum;
+
typedef struct
{
int client_fd;
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;
}