Add mbtk ecall v1 API.
Change-Id: Icfdb8ccf399a4e052484f6419e44755780c04725
diff --git a/mbtk/include/mbtk/mbtk_info_api.h b/mbtk/include/mbtk/mbtk_info_api.h
index 3877e54..627f3ab 100755
--- a/mbtk/include/mbtk/mbtk_info_api.h
+++ b/mbtk/include/mbtk/mbtk_info_api.h
@@ -20,6 +20,9 @@
// LOG_DEBUG_LEVEL 7
#define LOG LOGI
+#define RIL_MAX_NUMBER_LEN 40
+#define MBTK_ECALL_MSD_LEN_MAX 600
+
#define CELL_NUM_MAX 50
#define APN_STR_MAX 128
#if (defined(MBTK_AF_SUPPORT) || defined(MBTK_ALL_CID_SUPPORT))
@@ -525,10 +528,10 @@
#endif
} mbtk_apn_auth_proto_enum;
-typedef struct
-{
- uint8 urc_id;
- uint8 urc_data[5];
+typedef struct
+{
+ uint8 urc_id;
+ uint8 urc_data[5];
} mbtk_ril_ecall_state_info_t;
typedef struct {
@@ -546,6 +549,110 @@
} mbtk_qser_apn_info_s;
/**************qser data_call*****************/
+
+typedef enum {
+ MBTK_ECALL_MSD_ITEM_VERSION = 0,
+ MBTK_ECALL_MSD_ITEM_MSG_ID,
+ MBTK_ECALL_MSD_ITEM_CONTROLTYPE,
+ MBTK_ECALL_MSD_ITEM_VIN,
+ MBTK_ECALL_MSD_ITEM_STORAGETYPE,
+ MBTK_ECALL_MSD_ITEM_TIMESTAMP,
+ MBTK_ECALL_MSD_ITEM_LOCATION,
+ MBTK_ECALL_MSD_ITEM_DIRECTION,
+ MBTK_ECALL_MSD_ITEM_LOCATIONN1,
+ MBTK_ECALL_MSD_ITEM_LOCATIONN2,
+ MBTK_ECALL_MSD_ITEM_NUMBEROFOCCUPANTS,
+ MBTK_ECALL_MSD_ITEM_ADDITIONALDATA,
+ MBTK_ECALL_MSD_ITEM_ALL_IN_ONE,
+ MBTK_ECALL_MSD_ITEM_ASI,
+ MBTK_ECALL_MSD_ITEM_VEHICLE_DIAGNOSTIC,
+ MBTK_ECALL_MSD_ITEM_CRASH_INFO,
+ MBTK_ECALL_MSD_ITEM_GNSS_TYPE
+} mbtk_ecall_msd_item_enum;
+
+typedef struct
+{
+ mbtk_ecall_msd_item_enum item_type;
+
+ uint8 data[64];
+} mbtk_ecall_msd_cfg_info_t;
+
+typedef enum {
+ MBTK_ECALL_ONLY_TYPE_DISABLE = 0,
+ MBTK_ECALL_ONLY_TYPE_ENABLE_ECALL,
+ MBTK_ECALL_ONLY_TYPE_ENABLE_NG_ECALL,
+ MBTK_ECALL_ONLY_TYPE_ENABLE_ALL,
+ MBTK_ECALL_ONLY_TYPE_CONF_NUM,
+ MBTK_ECALL_ONLY_TYPE_NORMAL
+} mbtk_ecall_only_type_enum;
+
+typedef enum {
+ MBTK_ECALL_SIM_TYPE_NO_SUPPORT = 0,
+ MBTK_ECALL_SIM_TYPE_SUPPORT_ECALL,
+ MBTK_ECALL_SIM_TYPE_SUPPORT_ECALL_ONLY
+} mbtk_ecall_sim_type_enum;
+
+typedef struct {
+ mbtk_ecall_only_type_enum active : 8;
+ mbtk_ecall_sim_type_enum sim_type : 8; // Only for GET.
+ uint8 test_num[RIL_MAX_NUMBER_LEN];
+ uint8 reconfig_num[RIL_MAX_NUMBER_LEN];
+} mbtk_ecall_only_info_t;
+
+typedef enum {
+ MBTK_ECALL_DIAL_TYPE_TEST = 0,
+ MBTK_ECALL_DIAL_TYPE_RECONFIG,
+ MBTK_ECALL_DIAL_TYPE_MANUALLY,
+ MBTK_ECALL_DIAL_TYPE_AUTO,
+ MBTK_ECALL_DIAL_TYPE_NOT_ACTIVATED,
+ MBTK_ECALL_DIAL_TYPE_RELEASE
+} mbtk_ecall_dial_type_enum;
+
+typedef enum {
+ MBTK_ECALL_MODE_TYPE_EU = 0,
+ MBTK_ECALL_MODE_TYPE_ERA
+} mbtk_ecall_mode_type_enum;
+
+typedef enum {
+ MBTK_ECALL_CFG_ITEM_T3 = 0, // ms
+ MBTK_ECALL_CFG_ITEM_T5, // ms
+ MBTK_ECALL_CFG_ITEM_T6, // ms
+ MBTK_ECALL_CFG_ITEM_T7, // ms
+ MBTK_ECALL_CFG_ITEM_TH, // ms
+ MBTK_ECALL_CFG_ITEM_TIMER_CALLBACK, // T9 // 5
+ MBTK_ECALL_CFG_ITEM_TIMER_CLEARDOWN, // T2
+ MBTK_ECALL_CFG_ITEM_TIMER_DEREG, // T10
+ MBTK_ECALL_CFG_ITEM_TIMER_DIAL, // "dial"
+ MBTK_ECALL_CFG_ITEM_TIMER_REDIAL, // "redialtmr"
+ MBTK_ECALL_CFG_ITEM_TIMER_SMS, // "sms" // 10
+ MBTK_ECALL_CFG_ITEM_REDIALCNT, // "redialcnt"
+ MBTK_ECALL_CFG_ITEM_SMSPROCESS, // "smsprocess"
+ MBTK_ECALL_CFG_ITEM_SMSMSDCNT, // "smsmsdcnt"
+
+ MBTK_ECALL_CFG_ITEM_MAX
+} mbtk_ecall_cfg_item_enum;
+
+typedef struct {
+ mbtk_ecall_cfg_item_enum type;
+
+ uint32 data;
+} mbtk_ecall_cfg_info_t;
+
+typedef enum {
+ MBTK_ECALL_GAIN_MODE_TX = 0,
+ MBTK_ECALL_GAIN_MODE_RX,
+ MBTK_ECALL_GAIN_MODE_SIDETONE
+} mbtk_ecall_gain_mode_enum;
+
+typedef struct {
+ mbtk_ecall_gain_mode_enum mode;
+
+ int8 gain;
+} mbtk_ecall_gain_info_t;
+
+
+
+
mbtk_info_handle_t* mbtk_info_handle_get();
int mbtk_info_handle_free(mbtk_info_handle_t** handle);
diff --git a/mbtk/libmbtk_lib/ril/mbtk_info.h b/mbtk/libmbtk_lib/ril/mbtk_info.h
index d51ed69..462e2b9 100755
--- a/mbtk/libmbtk_lib/ril/mbtk_info.h
+++ b/mbtk/libmbtk_lib/ril/mbtk_info.h
@@ -254,6 +254,47 @@
MBTK_INFO_ID_LED_RSP,
MBTK_INFO_ID_LED_END,
+ // Ecall
+ RIL_MSG_ID_ECALL_BEGIN = 9000,
+ // mbtk_ecall_msd_cfg_info_t
+ RIL_MSG_ID_ECALL_MSDCFG_REQ,
+ RIL_MSG_ID_ECALL_MSDCFG_RSP,
+ // NULL
+ RIL_MSG_ID_ECALL_MSDGEN_REQ,
+ RIL_MSG_ID_ECALL_MSDGEN_RSP,
+ // uint8[]
+ RIL_MSG_ID_ECALL_MSD_REQ,
+ RIL_MSG_ID_ECALL_MSD_RSP,
+ // NULL
+ RIL_MSG_ID_ECALL_PUSH_REQ,
+ RIL_MSG_ID_ECALL_PUSH_RSP,
+ // mbtk_ecall_only_info_t
+ RIL_MSG_ID_ECALL_ONLY_REQ,
+ RIL_MSG_ID_ECALL_ONLY_RSP,
+ // reg <uint8>
+ RIL_MSG_ID_ECALL_REG_REQ,
+ RIL_MSG_ID_ECALL_REG_RSP,
+ // mbtk_ecall_dial_type_enum
+ RIL_MSG_ID_ECALL_DIAL_REQ,
+ RIL_MSG_ID_ECALL_DIAL_RSP,
+ // mbtk_ecall_mode_type_enum
+ RIL_MSG_ID_ECALL_MODE_REQ,
+ RIL_MSG_ID_ECALL_MODE_RSP,
+ // mbtk_ecall_cfg_item_enum / mbtk_ecall_cfg_info_t
+ RIL_MSG_ID_ECALL_CFG_REQ,
+ RIL_MSG_ID_ECALL_CFG_RSP,
+ // uint8[]
+ RIL_MSG_ID_ECALL_SMS_NUM_REQ,
+ RIL_MSG_ID_ECALL_SMS_NUM_RSP,
+ // uint8
+ RIL_MSG_ID_ECALL_MUTESPK_REQ,
+ RIL_MSG_ID_ECALL_MUTESPK_RSP,
+ // mbtk_ecall_gain_info_t
+ RIL_MSG_ID_ECALL_DSP_GAIN_REQ,
+ RIL_MSG_ID_ECALL_DSP_GAIN_RSP,
+
+ RIL_MSG_ID_ECALL_END,
+
// IND Information
MBTK_INFO_ID_IND_BEGIN = 10000,
// <uint8> State
diff --git a/mbtk/libmbtk_lib/ril/mbtk_info_api.c b/mbtk/libmbtk_lib/ril/mbtk_info_api.c
index 222bcf1..b751aa6 100755
--- a/mbtk/libmbtk_lib/ril/mbtk_info_api.c
+++ b/mbtk/libmbtk_lib/ril/mbtk_info_api.c
@@ -2490,6 +2490,415 @@
return info_item_process(handle, MBTK_INFO_ID_LED_REQ, buff, 2, NULL) ? handle->info_err : 0;
}
+
+/*
+* Set msd item.
+*
+*/
+int mbtk_ecall_msd_item_set(mbtk_info_handle_t* handle, const mbtk_ecall_msd_cfg_info_t *msd_cfg)
+{
+ if(handle == NULL)
+ {
+ return -1;
+ }
+
+ if(msd_cfg == NULL)
+ {
+ LOGE("ARG error.");
+ return -1;
+ }
+
+ if(info_item_process(handle, RIL_MSG_ID_ECALL_MSDCFG_REQ, msd_cfg, sizeof(mbtk_ecall_msd_cfg_info_t), NULL) >= 0) {
+ return 0;
+ } else {
+ return handle->info_err;
+ }
+}
+
+/*
+* Generate msd after msd item set.
+*
+*/
+int mbtk_ecall_msd_gen(mbtk_info_handle_t* handle)
+{
+ if(handle == NULL)
+ {
+ return -1;
+ }
+
+ if(info_item_process(handle, RIL_MSG_ID_ECALL_MSDGEN_REQ, NULL, 0, NULL) >= 0) {
+ return 0;
+ } else {
+ return handle->info_err;
+ }
+}
+
+/*
+* Set ecall msd.
+*
+*/
+int mbtk_ecall_msd_set(mbtk_info_handle_t* handle, const void* msd)
+{
+ if(handle == NULL || str_empty(msd))
+ {
+ LOGE("ARG error.");
+ return -1;
+ }
+
+ if(info_item_process(handle, RIL_MSG_ID_ECALL_MSD_REQ, msd, strlen(msd), NULL) >= 0) {
+ return 0;
+ } else {
+ return handle->info_err;
+ }
+}
+
+/*
+* Get ecall msd.
+*
+*/
+int mbtk_ecall_msd_get(mbtk_info_handle_t* handle, void* msd)
+{
+ if(!handle)
+ {
+ return -1;
+ }
+
+ if(msd == NULL)
+ {
+ LOGE("ARG error.");
+ return -1;
+ }
+
+ if(info_item_process(handle, RIL_MSG_ID_ECALL_MSD_REQ, NULL, 0, msd) >= 0) {
+ return 0;
+ } else {
+ return handle->info_err;
+ }
+}
+
+
+/*
+* Set ecall msd item.
+*
+*/
+int mbtk_ecall_push(mbtk_info_handle_t* handle)
+{
+ if(!handle)
+ {
+ return -1;
+ }
+
+ if(info_item_process(handle, RIL_MSG_ID_ECALL_PUSH_REQ, NULL, 0, NULL) >= 0) {
+ return 0;
+ } else {
+ return handle->info_err;
+ }
+}
+
+/*
+* Set ecall only configs.
+*
+*/
+int mbtk_ecall_only_set(mbtk_info_handle_t* handle, const mbtk_ecall_only_info_t* info)
+{
+ if(!handle)
+ {
+ return -1;
+ }
+
+ if(info == NULL)
+ {
+ LOGE("ARG error.");
+ return -1;
+ }
+
+ if(info_item_process(handle, RIL_MSG_ID_ECALL_ONLY_REQ, info, sizeof(mbtk_ecall_only_info_t), NULL) >= 0) {
+ return 0;
+ } else {
+ return handle->info_err;
+ }
+}
+
+/*
+* Get ecall only configs.
+*
+*/
+int mbtk_ecall_only_get(mbtk_info_handle_t* handle, mbtk_ecall_only_info_t* info)
+{
+ if(!handle)
+ {
+ return -1;
+ }
+
+ if(info == NULL)
+ {
+ LOGE("ARG error.");
+ return -1;
+ }
+
+ if(info_item_process(handle, RIL_MSG_ID_ECALL_ONLY_REQ, NULL, 0, info) >= 0) {
+ return 0;
+ } else {
+ return handle->info_err;
+ }
+}
+
+/*
+* Set ecall network reg.
+*
+*/
+int mbtk_ecall_reg_set(mbtk_info_handle_t* handle, int reg)
+{
+ if(!handle)
+ {
+ return -1;
+ }
+
+ if(reg != 0 && reg != 1)
+ {
+ LOGE("ARG error.");
+ return -1;
+ }
+
+ if(info_item_process(handle, RIL_MSG_ID_ECALL_REG_REQ, ®, 1, NULL) >= 0) {
+ return 0;
+ } else {
+ return handle->info_err;
+ }
+}
+
+/*
+* Start ecall dial start.
+*
+*/
+int mbtk_ecall_dial_start(mbtk_info_handle_t* handle, mbtk_ecall_dial_type_enum type)
+{
+ if(!handle)
+ {
+ return -1;
+ }
+
+ if(info_item_process(handle, RIL_MSG_ID_ECALL_DIAL_REQ, &type, 1, NULL) >= 0) {
+ return 0;
+ } else {
+ return handle->info_err;
+ }
+}
+
+/*
+* Get ecall dial state.
+*
+*/
+int mbtk_ecall_dial_state_get(mbtk_info_handle_t* handle, mbtk_ecall_dial_type_enum* type)
+{
+ if(!handle)
+ {
+ return -1;
+ }
+
+ if(type == NULL)
+ {
+ LOGE("ARG error.");
+ return -1;
+ }
+ memset(type, 0, sizeof(mbtk_ecall_dial_type_enum));
+
+ if(info_item_process(handle, RIL_MSG_ID_ECALL_DIAL_REQ, NULL, 0, type) >= 0) {
+ return 0;
+ } else {
+ return handle->info_err;
+ }
+}
+
+/*
+* Set ecall mode.
+*
+*/
+int mbtk_ecall_mode_set(mbtk_info_handle_t* handle, mbtk_ecall_mode_type_enum mode)
+{
+ if(handle == NULL)
+ {
+ return -1;
+ }
+
+ if(info_item_process(handle, RIL_MSG_ID_ECALL_MODE_REQ, &mode, 1, NULL) >= 0) {
+ return 0;
+ } else {
+ return handle->info_err;
+ }
+}
+
+/*
+* Get ecall mode.
+*
+*/
+int mbtk_ecall_mode_get(mbtk_info_handle_t* handle, mbtk_ecall_mode_type_enum *mode)
+{
+ if(handle == NULL)
+ {
+ return -1;
+ }
+
+ if(mode == NULL)
+ {
+ LOGE("ARG error.");
+ return -1;
+ }
+ memset(mode, 0, sizeof(mbtk_ecall_mode_type_enum));
+
+ if(info_item_process(handle, RIL_MSG_ID_ECALL_MODE_REQ, NULL, 0, mode) >= 0) {
+ return 0;
+ } else {
+ return handle->info_err;
+ }
+}
+
+/*
+* Set ecall configs.
+*
+*/
+int mbtk_ecall_cfg_set(mbtk_info_handle_t* handle, const mbtk_ecall_cfg_info_t *cfg)
+{
+ if(handle == NULL)
+ {
+ return -1;
+ }
+
+ if(cfg == NULL || cfg->type >= MBTK_ECALL_CFG_ITEM_MAX)
+ {
+ LOGE("ARG error.");
+ return -1;
+ }
+
+ if(info_item_process(handle, RIL_MSG_ID_ECALL_CFG_REQ, cfg, sizeof(mbtk_ecall_cfg_info_t), NULL) >= 0) {
+ return 0;
+ } else {
+ return handle->info_err;
+ }
+}
+
+/*
+* Get ecall configs.
+*
+*/
+int mbtk_ecall_cfg_get(mbtk_info_handle_t* handle, mbtk_ecall_cfg_info_t* cfg)
+{
+ if(handle == NULL)
+ {
+ return -1;
+ }
+
+ if(cfg == NULL || cfg->type >= MBTK_ECALL_CFG_ITEM_MAX)
+ {
+ LOGE("ARG error.");
+ return -1;
+ }
+ mbtk_ecall_cfg_item_enum type = cfg->type;
+
+ if(info_item_process(handle, RIL_MSG_ID_ECALL_CFG_REQ, &type, 1, cfg) >= 0) {
+ return 0;
+ } else {
+ return handle->info_err;
+ }
+}
+
+/*
+* Set ecall sms number.
+*
+*/
+int mbtk_ecall_sms_number_set(mbtk_info_handle_t* handle, const void *number)
+{
+ if(handle == NULL)
+ {
+ return -1;
+ }
+
+ if(str_empty(number))
+ {
+ LOGE("ARG error.");
+ return -1;
+ }
+
+ if(info_item_process(handle, RIL_MSG_ID_ECALL_SMS_NUM_REQ, number, strlen(number), NULL) >= 0) {
+ return 0;
+ } else {
+ return handle->info_err;
+ }
+}
+
+/*
+* Get ecall sms number.
+*
+*/
+int mbtk_ecall_sms_number_get(mbtk_info_handle_t* handle, void *number)
+{
+ if(handle == NULL)
+ {
+ return -1;
+ }
+
+ if(number == NULL)
+ {
+ LOGE("ARG error.");
+ return -1;
+ }
+
+ if(info_item_process(handle, RIL_MSG_ID_ECALL_SMS_NUM_REQ, NULL, 0, number) >= 0) {
+ return 0;
+ } else {
+ return handle->info_err;
+ }
+}
+
+/*
+* Set ecall mute speaker.
+*
+*/
+int mbtk_ecall_mute_spk_set(mbtk_info_handle_t* handle, int mute)
+{
+ if(handle == NULL)
+ {
+ return -1;
+ }
+
+ if(mute != 0 && mute != 1)
+ {
+ LOGE("ARG error.");
+ return -1;
+ }
+
+ if(info_item_process(handle, RIL_MSG_ID_ECALL_MUTESPK_REQ, &mute, 1, NULL) >= 0) {
+ return 0;
+ } else {
+ return handle->info_err;
+ }
+}
+
+/*
+* Set ecall dsp gain.
+*
+*/
+int mbtk_ecall_dsp_gain_set(mbtk_info_handle_t* handle, const mbtk_ecall_gain_info_t *gain_info)
+{
+ if(handle == NULL)
+ {
+ return -1;
+ }
+
+ if(gain_info == NULL)
+ {
+ LOGE("ARG error.");
+ return -1;
+ }
+
+ if(info_item_process(handle, RIL_MSG_ID_ECALL_DSP_GAIN_REQ, gain_info, sizeof(mbtk_ecall_gain_info_t), NULL) >= 0) {
+ return 0;
+ } else {
+ return handle->info_err;
+ }
+}
+
+
/*
* Set pdp state change callback function.
*/
diff --git a/mbtk/libmbtk_lib_v2/ril/mbtk_pdu_sms.c b/mbtk/libmbtk_lib_v2/ril/mbtk_pdu_sms.c
index 5825cb6..05da8a8 100755
--- a/mbtk/libmbtk_lib_v2/ril/mbtk_pdu_sms.c
+++ b/mbtk/libmbtk_lib_v2/ril/mbtk_pdu_sms.c
@@ -842,7 +842,7 @@
}
char *result, *buf;
int len = strlen(DA);
- int index;
+ int index = 0;
result = (char *) malloc(sizeof(char) * (len + 5));
buf = result;
diff --git a/mbtk/libmbtk_lib_v2/wifi/sta_cli.c b/mbtk/libmbtk_lib_v2/wifi/sta_cli.c
index 316d70f..0cf37fd 100755
--- a/mbtk/libmbtk_lib_v2/wifi/sta_cli.c
+++ b/mbtk/libmbtk_lib_v2/wifi/sta_cli.c
@@ -16,6 +16,8 @@
#include "sta_cli.h"
#include "sta_ctrl.h"
+#include "mbtk_log.h"
+
//#include "sta_log.h"
//#include "mbtk_string.h"
@@ -83,14 +85,14 @@
fgets(ssid,200,fd_tmp);
pclose(fd_tmp);
if(strlen(ssid) > 0){
- printf("test 100:%s, len:%d\n", ssid, strlen(ssid));
+ LOGE("test 100:%s, len:%d\n", ssid, strlen(ssid));
}else{// Open wpa_supplicant
- printf("test 101:%s\n", ssid);
+ LOGE("test 101:%s\n", ssid);
}
}else{
- printf("test 102:%s\n");
+ LOGE("test 102:%s\n");
}
return 0;
@@ -107,20 +109,47 @@
fgets(psk,200,fd_tmp);
pclose(fd_tmp);
if(strlen(psk) > 0){
- printf("test 100:%s\n", psk);
+ LOGE("test 100:%s\n", psk);
}else{// Open wpa_supplicant
- printf("test 101:%s\n", psk);
+ LOGE("test 101:%s\n", psk);
}
}else{
- printf("test 102:%s\n");
+ LOGE("test 102:%s\n");
}
return 0;
}
+int sta_cli_ssid_set(char *ssid)
+{
+
+ char buf[100] = {0};
+ snprintf(buf, 100, "sed -i 's/SSID=.*$/SSID=%s/g' /etc/wifi/sta_network.conf", ssid);
+ LOGE("set ssid:%s", buf);
+ system(buf);
+
+
+ return 0;
+}
+
+int sta_cli_psk_set(char *psk)
+{
+
+ char buf[100] = {0};
+ snprintf(buf, 100, "sed -i 's/PASSWORD=.*$/PASSWORD=%s/g' /etc/wifi/sta_network.conf", psk);
+ LOGE("set ssid:%s", buf);
+ system(buf);
+
+
+ return 0;
+}
+
+
+
+
static char*
sta_cli_ssid_process
@@ -135,7 +164,7 @@
int i;
for (i = 0; i < strlen(ssid); i++){
if (!isascii(ssid[i])){
- //printf("0x%02x\n",(unsigned char)ssid[i]);
+ //LOGE("0x%02x\n",(unsigned char)ssid[i]);
//return 0;
ascii = 0;
break;
@@ -149,7 +178,7 @@
}else{
int pos = 0;
for (i = 0; i < strlen(ssid); i++){
- printf("0x%02x\n",(unsigned char)ssid[i]);
+ LOGE("0x%02x\n",(unsigned char)ssid[i]);
snprintf(result + pos,len - pos,
"%02x",(unsigned char)ssid[i]);
pos += 2;
@@ -173,13 +202,13 @@
if((sock=socket(AF_INET,SOCK_STREAM,0))<0)
{
- printf("socket:errno(%d)\n",errno);
+ LOGE("socket:errno(%d)\n",errno);
return NULL;
}
strcpy(ifreq.ifr_name,ifname);
if(ioctl(sock,SIOCGIFHWADDR,&ifreq) <0)
{
- printf("ioctl:errno(%d)\n",errno);
+ LOGE("ioctl:errno(%d)\n",errno);
return NULL;
}
snprintf(mac,mac_len,
@@ -268,12 +297,12 @@
buf[len] = '\0';
if(sta_cli_conn_fd != -1){
if(write(sta_cli_conn_fd,buf,len) != len){
- printf("Send open msg to client fail.\n");
+ LOGE("Send open msg to client fail.\n");
}else{
- printf("Send open msg to client success.\n");
+ LOGE("Send open msg to client success.\n");
}
}else{
- printf("No client connected.\n");
+ LOGE("No client connected.\n");
}
sta_should_send_connected_msg = FALSE;
}
@@ -285,16 +314,16 @@
char *msg
)
{
- printf("cmd_id = %d,[%s]\n",sta_cli_cmd_id,msg);
+ LOGE("cmd_id = %d,[%s]\n",sta_cli_cmd_id,msg);
// if(sta_cli_conn_fd != -1){
// if(write(sta_cli_conn_fd,msg,strlen(msg)) != strlen(msg)){
-// printf("Send msg to client fail.\n");
+// LOGE("Send msg to client fail.\n");
// }else{
-// printf("Send msg to client success.\n");
+// LOGE("Send msg to client success.\n");
// }
// }else{
-// printf("No client connected.\n");
+// LOGE("No client connected.\n");
// }
// Send msg(CMD_OPEN_SUCCESS) to wifi_server.
@@ -321,12 +350,12 @@
if(sta_cli_conn_fd != -1){
usleep(500);
if(write(sta_cli_conn_fd,buf,len) != len){
- printf("Send msg to client fail.\n");
+ LOGE("Send msg to client fail.\n");
}else{
- printf("Send msg to client success.\n");
+ LOGE("Send msg to client success.\n");
}
}else{
- printf("No client connected.\n");
+ LOGE("No client connected.\n");
}
}
return;
@@ -346,12 +375,12 @@
buf[len] = '\0';
if(sta_cli_conn_fd != -1){
if(write(sta_cli_conn_fd,buf,len) != len){
- printf("Send msg to client fail.\n");
+ LOGE("Send msg to client fail.\n");
}else{
- printf("Send msg to client success.\n");
+ LOGE("Send msg to client success.\n");
}
}else{
- printf("No client connected.\n");
+ LOGE("No client connected.\n");
}
//sta_connected = FALSE;
//pthread_mutex_unlock(&sta_mutex);
@@ -371,7 +400,7 @@
case CMD_ID_SCAN:
{
if(str_contains(msg, "CTRL-EVENT-SCAN-RESULTS")){
- printf("Start resume thread.\n");
+ LOGE("Start resume thread.\n");
pthread_mutex_lock(&mutex);
pthread_cond_signal(&cond);
//pthread_cond_broadcast(&cond);
@@ -380,7 +409,7 @@
break;
}
default:
- printf("cmd_id[%d] unknown.\n",sta_cli_cmd_id);
+ LOGE("cmd_id[%d] unknown.\n",sta_cli_cmd_id);
break;
}
}
@@ -394,14 +423,14 @@
struct timeval now_1;
struct timespec outtime;
int thread_id = pthread_self();
- printf("Thread(%ld) pause.\n",thread_id);
+ LOGE("Thread(%ld) pause.\n",thread_id);
pthread_mutex_lock(&mutex);
gettimeofday(&now_1, NULL);
outtime.tv_sec = now_1.tv_sec + time / 1000;
outtime.tv_nsec = now_1.tv_usec * 1000;
pthread_cond_timedwait(&cond, &mutex, &outtime);
pthread_mutex_unlock(&mutex);
- printf("Thread(%ld) resume.\n",thread_id);
+ LOGE("Thread(%ld) resume.\n",thread_id);
}
static bool
@@ -451,7 +480,7 @@
)
{
char *data_base = data;
- printf("SCAN:\n%s\n",reply);
+ LOGE("SCAN:\n%s\n",reply);
bzero(data,len);
const char *ptr = reply;
bool start = FALSE;
@@ -488,7 +517,7 @@
}
}
- printf("SCAN 0:\n%s\n",data_base);
+ LOGE("SCAN 0:\n%s\n",data_base);
// Delete empty ssid line.
char *tmp = (char*)calloc(len,1);
@@ -497,16 +526,16 @@
char *ptr_pre = tmp;
ptr = strstr(ptr_pre,"\r\n");
- printf("line:%s\n",ptr == NULL?"NULL":ptr);
+ LOGE("line:%s\n",ptr == NULL?"NULL":ptr);
char ssid[STA_BUF_SIZE] = {0};
char *p;
while(ptr)
{
- printf("Get line.\n");
+ LOGE("Get line.\n");
// Get ssid.
if(*(ptr - 1) == ',') // No ssid
{
- printf("Delete one line.\n");
+ LOGE("Delete one line.\n");
}else{
char s[STA_BUF_SIZE] = {0};
p = ptr - 1;
@@ -516,10 +545,10 @@
}
p += 2;
memcpy(s,p,len);
- printf("ssid = %s;s = %s\n",ssid,s);
+ LOGE("ssid = %s;s = %s\n",ssid,s);
if(str_contains(ssid,s))
{
- printf("Jump the same ssid:%s\n",s);
+ LOGE("Jump the same ssid:%s\n",s);
ptr_pre = ptr + 2;
ptr = strstr(ptr_pre,"\r\n");
continue;
@@ -531,18 +560,18 @@
memcpy(ssid + strlen(ssid),s,len);
memcpy(data_base + strlen(data_base),ptr_pre,ptr + 2 - ptr_pre);
- printf("Copy ssid:\"%s\"\n",s);
+ LOGE("Copy ssid:\"%s\"\n",s);
}
ptr_pre = ptr + 2;
ptr = strstr(ptr_pre,"\r\n");
}
- printf("Scan parse end.\n");
+ LOGE("Scan parse end.\n");
free(tmp);
tmp = NULL;
- printf("SCAN 1:\n%s\n",data_base);
+ LOGE("SCAN 1:\n%s\n",data_base);
return STA_ERR_SUCCESS;
}
@@ -555,7 +584,7 @@
size_t data_len
)
{
- printf("STATUS:\n%s\n",reply);
+ LOGE("STATUS:\n%s\n",reply);
bzero(data,data_len);
@@ -597,7 +626,7 @@
}else{
memcpy(data + len,",",1);
len += 1;
- printf("Not get own MAC address.\n");
+ LOGE("Not get own MAC address.\n");
}
// net_id
@@ -612,7 +641,7 @@
}else{
memcpy(data + len,",",1);
len += 1;
- printf("Not get net id.\n");
+ LOGE("Not get net id.\n");
}
// ssid
@@ -627,7 +656,7 @@
}else{
memcpy(data + len,",",1);
len += 1;
- printf("Not get ssid.\n");
+ LOGE("Not get ssid.\n");
}
// freq
@@ -644,7 +673,7 @@
}else{
memcpy(data + len,",",1);
len += 1;
- printf("Not get freq.\n");
+ LOGE("Not get freq.\n");
}
// auth
@@ -679,13 +708,13 @@
}else{
memcpy(data + len,",",1);
len += 1;
- printf("Not get group_cipher.\n");
+ LOGE("Not get group_cipher.\n");
}
}
}else{
memcpy(data + len,",",1);
len += 1;
- printf("Not get key_mgmt.\n");
+ LOGE("Not get key_mgmt.\n");
}
// mac_ap
@@ -705,7 +734,7 @@
}else{
memcpy(data + len,",",1);
len += 1;
- printf("Not get IP.\n");
+ LOGE("Not get IP.\n");
}
}else{
memcpy(data + len,"0",1);
@@ -723,7 +752,7 @@
}else{
memcpy(data + len,",",1);
len += 1;
- printf("Not get MAC address.\n");
+ LOGE("Not get MAC address.\n");
}
memcpy(data + len,",,,,,,,",7);
@@ -734,7 +763,7 @@
len += 2;
data[len] = '\0';
- printf("STATUS:\n%s\n",data);
+ LOGE("STATUS:\n%s\n",data);
#undef BUF_SIZE
return STA_ERR_SUCCESS;
}
@@ -747,7 +776,7 @@
size_t len
)
{
- printf("MIB:\n%s\n",reply);
+ LOGE("MIB:\n%s\n",reply);
memcpy(data,reply,strlen(reply));
@@ -762,7 +791,7 @@
size_t len
)
{
- printf("LIST_NETWORK:\n%s\n",reply);
+ LOGE("LIST_NETWORK:\n%s\n",reply);
bzero(data,len);
const char *ptr = reply;
@@ -808,7 +837,7 @@
//memcpy(data,reply,strlen(reply));
- printf("LIST_NETWORK:\n%s\n",data);
+ LOGE("LIST_NETWORK:\n%s\n",data);
return STA_ERR_SUCCESS;
}
@@ -823,17 +852,17 @@
if(err == STA_ERR_SUCCESS){
if(strncmp(cmd,STA_CMD_SCAN,strlen(STA_CMD_SCAN)) == 0
&& strncmp(sta_cli_cmd_reply,STA_TAG_CMD_FAIL_BUSY,strlen(STA_TAG_CMD_FAIL_BUSY)) == 0){
- printf("\"%s\" busy.\n",cmd);
+ LOGE("\"%s\" busy.\n",cmd);
return STA_ERR_SUCCESS;
}
if(strncmp(sta_cli_cmd_reply,STA_TAG_CMD_FAIL,strlen(STA_TAG_CMD_FAIL)) == 0){
- printf("\"%s\" fail.\n",cmd);
+ LOGE("\"%s\" fail.\n",cmd);
return STA_ERR_UNKNOWN;
}
- printf("[%s]:\n%s\n",cmd,sta_cli_cmd_reply);
+ LOGE("[%s]:\n%s\n",cmd,sta_cli_cmd_reply);
}else{
- printf("[%s]:FAIL\n",cmd);
+ LOGE("[%s]:FAIL\n",cmd);
}
return err;
}
@@ -864,17 +893,17 @@
data,
len);
}else{
- printf("SCAN_RESULTS cmd fail.\n");
+ LOGE("SCAN_RESULTS cmd fail.\n");
return STA_ERR_UNKNOWN;
}
}else{
sta_cli_cmd_id = CMD_ID_NON;
- printf("SCAN cmd fail.\n");
+ LOGE("SCAN cmd fail.\n");
return STA_ERR_UNKNOWN;
}
}else{
sta_cli_cmd_id = CMD_ID_NON;
- printf("SCAN cmd fail.\n");
+ LOGE("SCAN cmd fail.\n");
return err;
}
}
@@ -910,11 +939,11 @@
ptr++; // Point to flag.
memcpy(flag,ptr,len);
- printf("%s : %s\n",ssid,flag);
+ LOGE("%s : %s\n",ssid,flag);
return flag;
}
}else{
- printf("SCAN_RESULTS cmd fail.");
+ LOGE("SCAN_RESULTS cmd fail.");
return NULL;
}
return NULL;
@@ -938,7 +967,7 @@
data,
len);
}else{
- printf("STATUS cmd fail.\n");
+ LOGE("STATUS cmd fail.\n");
return err;
}
}
@@ -960,7 +989,7 @@
data,
len);
}else{
- printf("MIB cmd fail.\n");
+ LOGE("MIB cmd fail.\n");
return err;
}
}
@@ -978,12 +1007,12 @@
if(strncmp(sta_cli_cmd_reply,"OK",2) == 0){
return STA_ERR_SUCCESS;
}else{
- printf("RECONFIGURE cmd fail.\n");
+ LOGE("RECONFIGURE cmd fail.\n");
return STA_ERR_UNKNOWN;
}
}else{
sta_cli_cmd_id = CMD_ID_NON;
- printf("RECONFIGURE cmd fail.\n");
+ LOGE("RECONFIGURE cmd fail.\n");
return err;
}
}
@@ -1001,12 +1030,12 @@
if(strncmp(sta_cli_cmd_reply,"OK",2) == 0){
return STA_ERR_SUCCESS;
}else{
- printf("DISCONNECT cmd fail.\n");
+ LOGE("DISCONNECT cmd fail.\n");
return STA_ERR_UNKNOWN;
}
}else{
sta_cli_cmd_id = CMD_ID_NON;
- printf("DISCONNECT cmd fail.\n");
+ LOGE("DISCONNECT cmd fail.\n");
return err;
}
}
@@ -1024,12 +1053,12 @@
if(strncmp(sta_cli_cmd_reply,"OK",2) == 0){
return STA_ERR_SUCCESS;
}else{
- printf("RECONNECT cmd fail.\n");
+ LOGE("RECONNECT cmd fail.\n");
return STA_ERR_UNKNOWN;
}
}else{
sta_cli_cmd_id = CMD_ID_NON;
- printf("RECONNECT cmd fail.\n");
+ LOGE("RECONNECT cmd fail.\n");
return err;
}
}
@@ -1048,12 +1077,12 @@
if(strncmp(sta_cli_cmd_reply,"OK",2) == 0){
return STA_ERR_SUCCESS;
}else{
- printf("SAVE_CONFIG cmd fail.\n");
+ LOGE("SAVE_CONFIG cmd fail.\n");
return STA_ERR_UNKNOWN;
}
}else{
sta_cli_cmd_id = CMD_ID_NON;
- printf("SAVE_CONFIG cmd fail.\n");
+ LOGE("SAVE_CONFIG cmd fail.\n");
return err;
}
}
@@ -1064,7 +1093,7 @@
char *c
)
{
- printf("cmd = %s\n",c);
+ LOGE("cmd = %s\n",c);
char *ptr = c;
sta_cli_cmd_id = CMD_ID_SET_NETWORK;
@@ -1088,22 +1117,22 @@
if(STA_ERR_SUCCESS == err){
if(strncmp(sta_cli_cmd_reply,"OK",2) == 0){
//return STA_ERR_SUCCESS;
- printf("Success:%s\n",cmd);
+ LOGE("Success:%s\n",cmd);
}else{
- printf("Fail:%s\n",cmd);
+ LOGE("Fail:%s\n",cmd);
sta_cli_cmd_id = CMD_ID_NON;
return STA_ERR_UNKNOWN;
}
}else{
sta_cli_cmd_id = CMD_ID_NON;
- printf("Fail:%s\n",cmd);
+ LOGE("Fail:%s\n",cmd);
return err;
}
if(ptr == NULL)
break;
- printf("ptr = %s",ptr);
+ LOGE("ptr = %s",ptr);
index = str_indexof(ptr,"#");
bzero(cmd,100);
@@ -1129,26 +1158,26 @@
const char *flag
)
{
- printf("cmd = %s\n",cmd);
+ LOGE("cmd = %s\n",cmd);
char buf[500];
- printf("test11\n");
+ LOGE("test11\n");
int index = str_indexof(cmd," psk ");
- printf("test12\n");
+ LOGE("test12\n");
int net_id = atoi(cmd + strlen(STA_CMD_SET_NETWORK) + 1);
- printf("test13\n");
+ LOGE("test13\n");
if(index > 0){ // Is set "psk"
- printf("test14\n");
+ LOGE("test14\n");
char psk[64] = {0};
int start = index + 5; // " psk "
if(*(cmd + start) == '"')
{
- printf("test15\n");
+ LOGE("test15\n");
memcpy(psk,cmd + start + 1,strlen(cmd) - start - 2);
}else{
- printf("test16\n");
+ LOGE("test16\n");
memcpy(psk,cmd + start,strlen(cmd) - start);
}
- printf("psk = %s\n",psk);
+ LOGE("psk = %s\n",psk);
// Set to OPEN (No psk)
// SET_NETWORK <net_id> key_mgmt NONE
@@ -1212,7 +1241,7 @@
}
else // SSID
{
- printf("test21\n");
+ LOGE("test21\n");
index = str_indexof(cmd," ssid ");
char ssid[STA_BUF_SIZE] = {0};
int start = index + 6; // " ssid "
@@ -1222,12 +1251,12 @@
}else{
memcpy(ssid,cmd + start,strlen(cmd) - start);
}
- printf("ssid = %s\n",ssid);
+ LOGE("ssid = %s\n",ssid);
//char ssid_result[STA_SSID_MAX_LEN + 1];
//sta_cli_ssid_process(ssid,ssid_result,STA_SSID_MAX_LEN + 2 + 1);
- // printf("test22, ssid_result: %s\n", ssid_result);
+ // LOGE("test22, ssid_result: %s\n", ssid_result);
char cmd_result[STA_BUF_SIZE];
int size = snprintf(cmd_result,STA_BUF_SIZE,
"%s %d ssid %s",
@@ -1235,7 +1264,7 @@
net_id,
ssid);
cmd_result[size] = '\0';
- printf("cmd = %s\n",cmd_result);
+ LOGE("cmd = %s\n",cmd_result);
return sta_cli_cmd_set_network_process(cmd);
}
@@ -1269,11 +1298,11 @@
tmp--;
}
- printf("GET_NETWORK:%s.\n",value);
+ LOGE("GET_NETWORK:%s.\n",value);
return STA_ERR_SUCCESS;
}else{
sta_cli_cmd_id = CMD_ID_NON;
- printf("GET_NETWORK cmd fail.\n");
+ LOGE("GET_NETWORK cmd fail.\n");
return err;
}
}
@@ -1291,12 +1320,12 @@
if(strncmp(sta_cli_cmd_reply,"OK",2) == 0){
return STA_ERR_SUCCESS;
}else{
- printf("REMOVE_NETWORK cmd fail.\n");
+ LOGE("REMOVE_NETWORK cmd fail.\n");
return STA_ERR_UNKNOWN;
}
}else{
sta_cli_cmd_id = CMD_ID_NON;
- printf("REMOVE_NETWORK cmd fail.\n");
+ LOGE("REMOVE_NETWORK cmd fail.\n");
return err;
}
}
@@ -1308,17 +1337,17 @@
const char *cmd
)
{
- printf("cmd = %s\n",cmd);
+ LOGE("cmd = %s\n",cmd);
sta_cli_cmd_id = CMD_ID_ADD_NETWORK;
sta_err_enum err = sta_cli_process_cmd(STA_CMD_ADD_NETWORK);
- printf("test1\n");
+ LOGE("test1\n");
if(STA_ERR_SUCCESS == err){
sta_cli_cmd_id = CMD_ID_NON;
int net_id = atoi(sta_cli_cmd_reply);
- printf("test2\n");
+ LOGE("test2\n");
if(net_id >= 0){ // Add network success.
// Point to ssid
- printf("test3\n");
+ LOGE("test3\n");
/*
const char *ptr = cmd + strlen(STA_CMD_ADD_NETWORK) + 1;
@@ -1331,7 +1360,7 @@
char ssid[STA_BUF_SIZE] = {0};
- printf("test4\n");
+ LOGE("test4\n");
memcpy(ssid,ptr,pass_ptr - ptr - 1);
*/
@@ -1339,7 +1368,7 @@
char ssid[STA_BUF_SIZE] = {'\0'};
char psk[STA_BUF_SIZE] = {'\0'};
int len = 0;
- printf("test5\n");
+ LOGE("test5\n");
sta_cli_ssid_get(ssid);
len = strlen(ssid);
@@ -1355,12 +1384,12 @@
STA_CMD_SET_NETWORK,
net_id,
ssid);
- printf("test6\n");
+ LOGE("test6\n");
buf[size] = '\0';
err = sta_cli_cmd_set_network(buf,NULL);
- printf("test7\n");
+ LOGE("test7\n");
if(STA_ERR_SUCCESS == err){
char flag[50];
sta_cli_flag_get(ssid,flag,50);
@@ -1388,11 +1417,11 @@
return err;
}else{
- printf("ADD_NETWORK cmd fail.\n");
+ LOGE("ADD_NETWORK cmd fail.\n");
return STA_ERR_UNKNOWN;
}
}else{
- printf("ADD_NETWORK cmd fail.\n");
+ LOGE("ADD_NETWORK cmd fail.\n");
sta_cli_cmd_id = CMD_ID_NON;
return err;
}
@@ -1411,12 +1440,12 @@
if(strncmp(sta_cli_cmd_reply,"OK",2) == 0){
return STA_ERR_SUCCESS;
}else{
- printf("DISABLE_NETWORK cmd fail.\n");
+ LOGE("DISABLE_NETWORK cmd fail.\n");
return STA_ERR_UNKNOWN;
}
}else{
sta_cli_cmd_id = CMD_ID_NON;
- printf("DISABLE_NETWORK cmd fail.\n");
+ LOGE("DISABLE_NETWORK cmd fail.\n");
return err;
}
}
@@ -1434,12 +1463,12 @@
if(strncmp(sta_cli_cmd_reply,"OK",2) == 0){
return STA_ERR_SUCCESS;
}else{
- printf("ENABLE_NETWORK cmd fail.\n");
+ LOGE("ENABLE_NETWORK cmd fail.\n");
return STA_ERR_UNKNOWN;
}
}else{
sta_cli_cmd_id = CMD_ID_NON;
- printf("ENABLE_NETWORK cmd fail.\n");
+ LOGE("ENABLE_NETWORK cmd fail.\n");
return err;
}
}
@@ -1457,12 +1486,12 @@
if(strncmp(sta_cli_cmd_reply,"OK",2) == 0){
return STA_ERR_SUCCESS;
}else{
- printf("SELECT_NETWORK cmd fail.\n");
+ LOGE("SELECT_NETWORK cmd fail.\n");
return STA_ERR_UNKNOWN;
}
}else{
sta_cli_cmd_id = CMD_ID_NON;
- printf("SELECT_NETWORK cmd fail.\n");
+ LOGE("SELECT_NETWORK cmd fail.\n");
return err;
}
}
@@ -1484,7 +1513,7 @@
data,
len);
}else{
- printf("LIST_NETWORKS cmd fail.\n");
+ LOGE("LIST_NETWORKS cmd fail.\n");
return err;
}
}
@@ -1502,12 +1531,12 @@
if(strncmp(sta_cli_cmd_reply,"OK",2) == 0){
return STA_ERR_SUCCESS;
}else{
- printf("REASSOCIATE cmd fail.\n");
+ LOGE("REASSOCIATE cmd fail.\n");
return STA_ERR_UNKNOWN;
}
}else{
sta_cli_cmd_id = CMD_ID_NON;
- printf("REASSOCIATE cmd fail.\n");
+ LOGE("REASSOCIATE cmd fail.\n");
return err;
}
}
@@ -1525,12 +1554,12 @@
if(strncmp(sta_cli_cmd_reply,"OK",2) == 0){
return STA_ERR_SUCCESS;
}else{
- printf("REATTACH cmd fail.\n");
+ LOGE("REATTACH cmd fail.\n");
return STA_ERR_UNKNOWN;
}
}else{
sta_cli_cmd_id = CMD_ID_NON;
- printf("REATTACH cmd fail.\n");
+ LOGE("REATTACH cmd fail.\n");
return err;
}
}
@@ -1543,7 +1572,7 @@
{
sta_err_enum result = STA_ERR_SUCCESS;
if((result = sta_ctrl_driver_init(TRUE)) != STA_ERR_SUCCESS){
- printf("Driver init fail(%d).\n",result);
+ LOGE("Driver init fail(%d).\n",result);
return result;
}
@@ -1551,7 +1580,7 @@
"/etc/wifi/wpa_supplicant.conf",
"wlan0",
sta_cli_wpa_msg_cb)) != STA_ERR_SUCCESS){
- printf("wpa_supplicant init fail(%d).\n",result);
+ LOGE("wpa_supplicant init fail(%d).\n",result);
return result;
}
//pthread_mutex_init(&sta_mutex,NULL);
@@ -1566,12 +1595,12 @@
{
sta_err_enum result = STA_ERR_SUCCESS;
if((result = sta_ctrl_wpa_deinit()) != STA_ERR_SUCCESS){
- printf("sta_ctrl_wpa_deinit fail(%d).",result);
+ LOGE("sta_ctrl_wpa_deinit fail(%d).",result);
return result;
}
if((result = sta_ctrl_driver_init(FALSE)) != STA_ERR_SUCCESS){
- printf("Driver close fail(%d).\n",result);
+ LOGE("Driver close fail(%d).\n",result);
return result;
}
//pthread_mutex_destroy(&sta_mutex);
@@ -1594,7 +1623,7 @@
size_t reply_len
)
{
- printf("cmd:%s\n",cmd);
+ LOGE("cmd:%s\n",cmd);
bzero(reply,reply_len);
sta_err_enum err = STA_ERR_UNKNOWN;
if(strncmp(cmd,(STA_CMD_OPEN),strlen(STA_CMD_OPEN)) == 0){
@@ -1637,9 +1666,7 @@
err = sta_cli_cmd_scan(cmd, data,STA_BUF_SIZE);
if(err == STA_ERR_SUCCESS){
snprintf(reply,reply_len,
- "%s-%s-%s"STA_CMD_SEPARATED,
- STA_TAG_CMD,
- cmd,
+ "%s"STA_CMD_SEPARATED,
data);
}else{
snprintf(reply,reply_len,
@@ -1721,7 +1748,7 @@
#endif
if(err == STA_ERR_SUCCESS)
{
- printf("sta_cli_cmd_disconnect success.\n");
+ LOGE("sta_cli_cmd_disconnect success.\n");
//pthread_mutex_lock(&sta_mutex);
//if(sta_connected)
//{
@@ -1739,7 +1766,7 @@
mac_ap,
STA_MAC_LEN + 1)) // Disconnected.
{
- printf("Disconnected success.\n");
+ LOGE("Disconnected success.\n");
snprintf(reply,reply_len,
"%s-%s-%s"STA_CMD_SEPARATED,
STA_TAG_CMD,
@@ -1748,18 +1775,18 @@
ok = TRUE;
break;
}else{ // Connected.
- printf("Not disconnected.Try again(STATUS).\n");
+ LOGE("Not disconnected.Try again(STATUS).\n");
usleep(500);
}
}else{
- printf("STATUS cmd fail.\n");
+ LOGE("STATUS cmd fail.\n");
break;
}
}
if(!ok) // fail
{
- printf("Disconnect fail.\n");
+ LOGE("Disconnect fail.\n");
snprintf(reply,reply_len,
"%s-%s-%s:%d"STA_CMD_SEPARATED,
STA_TAG_CMD,
@@ -1771,7 +1798,7 @@
//}
//pthread_mutex_unlock(&sta_mutex);
}else{
- printf("sta_cli_cmd_disconnect fail.\n");
+ LOGE("sta_cli_cmd_disconnect fail.\n");
snprintf(reply,reply_len,
"%s-%s-%s:%d"STA_CMD_SEPARATED,
STA_TAG_CMD,
@@ -1999,7 +2026,7 @@
err);
}
}else{
- printf("Unknown cmd:%s\n",cmd);
+ LOGE("Unknown cmd:%s\n",cmd);
return FALSE;
}
return TRUE;
diff --git a/mbtk/libmbtk_lib_v2/wifi/sta_ctrl.c b/mbtk/libmbtk_lib_v2/wifi/sta_ctrl.c
index 66c55f5..e5e24aa 100755
--- a/mbtk/libmbtk_lib_v2/wifi/sta_ctrl.c
+++ b/mbtk/libmbtk_lib_v2/wifi/sta_ctrl.c
@@ -10,6 +10,8 @@
#include "wpa_ctrl.h"
#include "sta_ctrl.h"
+#include "mbtk_log.h"
+
//#include "sta_log.h"
#define WPA_SUPPLICANT_LOG_FILE "/data/wpa_supplicant.log"
@@ -54,7 +56,7 @@
static void
sta_ctrl_wpa_req_cb(char *msg, size_t len)
{
- printf("%s\n", msg);
+ LOGE("%s\n", msg);
}
bool
@@ -66,17 +68,17 @@
int result = TRUE;
FILE *stream = NULL;
- printf("system call: %s\n", command);
+ LOGE("system call: %s\n", command);
stream = popen( command, "w" );
if( stream == NULL )
{
- printf("system command failed\n");
+ LOGE("system command failed\n");
result = FALSE;
}
else if( 0 > pclose( stream ) )
{
- printf("pclose command failed\n");
+ LOGE("pclose command failed\n");
}
return result;
@@ -110,7 +112,7 @@
pclose(cmd);
}
pid = atoi(pid_s);
- printf("%s pid =%d\n", name,pid);
+ LOGE("%s pid =%d\n", name,pid);
/* If pid is zero we break from while*/
if(pid == 0)
{
@@ -119,7 +121,7 @@
}
}
- printf("PID still running after waiting 2 second.\n");
+ LOGE("PID still running after waiting 2 second.\n");
result = FALSE;
exit_end:
#undef PROCESS_KILL_RETRY
@@ -145,14 +147,14 @@
}
int pid = atoi(pid_s);
- printf("%s pid =%d\n", name,pid);
+ LOGE("%s pid =%d\n", name,pid);
/* If pid is zero we break from while*/
if(pid == 0)
{
- printf("%s not runnig.\n",name);
+ LOGE("%s not runnig.\n",name);
return FALSE;
}else{
- printf("%s is runnig.\n",name);
+ LOGE("%s is runnig.\n",name);
return TRUE;
}
}
@@ -161,7 +163,7 @@
static void*
sta_ctrl_event_thread_run( void *arg )
{
- printf("Thread[%ld] run().\n",pthread_self());
+ LOGE("Thread[%ld] run().\n",pthread_self());
int nready;
struct epoll_event ev_sock,ev_pipe,events[20];
@@ -178,9 +180,9 @@
if(!sta_event_thread_is_running){
break;
}
- printf("epoll_wait waitting...\n",nready);
+ LOGE("epoll_wait waitting...\n",nready);
nready = epoll_wait(epfd,events,20,-1);
- printf("epoll_wait return.(count = %d)\n",nready);
+ LOGE("epoll_wait return.(count = %d)\n",nready);
int i;
for(i=0;i<nready;++i) {
if (events[i].events & EPOLLIN) {// Read
@@ -191,7 +193,7 @@
&& events[i].data.fd == wpa_ctrl_get_fd(sta_mon_conn)){
sta_ctrl_recv_event();
}else if(events[i].data.fd == sta_ctrl_pipe_fd[0]){
- printf("Thread end.[fd = %d]\n",events[i].data.fd);
+ LOGE("Thread end.[fd = %d]\n",events[i].data.fd);
// End thread
char buf_end[10] = {0};
if(read(sta_ctrl_pipe_fd[0],buf_end,10) > 0
@@ -200,23 +202,23 @@
break;
}
}else{
- printf("No such fd[%d].\n",events[i].data.fd);
+ LOGE("No such fd[%d].\n",events[i].data.fd);
}
} else {
- printf("event error.\n");
+ LOGE("event error.\n");
}
}
}
close(epfd);
- printf("Thread exit.\n");
+ LOGE("Thread exit.\n");
return ((void*)0);
}
static sta_err_enum
sta_ctrl_close_connection(void)
{
- printf("start.\n");
+ LOGE("start.\n");
if (sta_ctrl_conn == NULL)
return STA_ERR_UNKNOWN;
@@ -231,7 +233,7 @@
sta_mon_conn = NULL;
}
- printf("end.\n");
+ LOGE("end.\n");
return STA_ERR_SUCCESS;
}
@@ -247,14 +249,14 @@
char ctrl_path[100] = {0};
result = sta_ctrl_conf_file_parse("ctrl_interface", ctrl_path);
if(STA_ERR_SUCCESS != result){
- printf("sta_ctrl_conf_file_parse() fail(%d).\n",result);
+ LOGE("sta_ctrl_conf_file_parse() fail(%d).\n",result);
return result;
}
snprintf(ctrl_path + strlen(ctrl_path),10,
"/%s",
sta_ctrl_ifname);
- printf("ctrl_path = \"%s\"\n",ctrl_path);
+ LOGE("ctrl_path = \"%s\"\n",ctrl_path);
sta_ctrl_conn = wpa_ctrl_open(ctrl_path);
if (sta_ctrl_conn == NULL) {
@@ -270,7 +272,7 @@
if (wpa_ctrl_attach(sta_mon_conn) == 0) {
sta_ctrl_attached = 1;
} else {
- printf("Warning: Failed to attach to "
+ LOGE("Warning: Failed to attach to "
"wpa_supplicant.\n");
sta_ctrl_close_connection();
return STA_ERR_UNKNOWN;
@@ -283,10 +285,10 @@
sta_ctrl_event_thread_run,
NULL);
if( ret != 0 ) {
- printf( "Create thread error!\n");
+ LOGE( "Create thread error!\n");
}
}else{
- printf("sta_event_thread is running.\n");
+ LOGE("sta_event_thread is running.\n");
return STA_ERR_UNKNOWN;
}
return result;
@@ -305,10 +307,10 @@
static void
sta_ctrl_recv_event(void)
{
- printf("start.\n");
+ LOGE("start.\n");
if (sta_ctrl_conn == NULL) {
sta_ctrl_reconnect();
- printf("sta_ctrl_conn == NULL:end.\n");
+ LOGE("sta_ctrl_conn == NULL:end.\n");
return;
}
@@ -317,22 +319,22 @@
size_t len = sizeof(buf) - 1;
if (wpa_ctrl_recv(sta_mon_conn, buf, &len) == 0) {
buf[len] = '\0';
- printf("<<%s>>\n",buf);
+ LOGE("<<%s>>\n",buf);
if(sta_ctrl_msg)
sta_ctrl_msg(buf);
} else {
- printf("Could not read pending message.\n");
+ LOGE("Could not read pending message.\n");
break;
}
}
if (wpa_ctrl_pending(sta_mon_conn) < 0) {
- printf("Connection to wpa_supplicant lost - trying to "
+ LOGE("Connection to wpa_supplicant lost - trying to "
"reconnect\n");
sta_ctrl_reconnect();
}
- printf("end.\n");
+ LOGE("end.\n");
}
static sta_err_enum
@@ -345,7 +347,7 @@
sta_err_enum result = STA_ERR_UNKNOWN;
FILE *fd = fopen(sta_ctrl_conf_file_path,"r");
if(!fd){
- printf("Open file(%s) fail(%d).\n",sta_ctrl_conf_file_path,errno);
+ LOGE("Open file(%s) fail(%d).\n",sta_ctrl_conf_file_path,errno);
return STA_ERR_UNKNOWN;
}
@@ -399,19 +401,19 @@
&reply_len,
sta_ctrl_wpa_req_cb);
if (ret == -2) {
- printf("command timed out.\n");
+ LOGE("command timed out.\n");
result = STA_ERR_TIMEOUT;
goto end_fail;
} else if (ret < 0) {
- printf("command failed.\n");
+ LOGE("command failed.\n");
result = STA_ERR_UNKNOWN;
goto end_fail;
} else {
reply[reply_len] = '\0';
- printf("1:%s\n", reply);
+ LOGE("1:%s\n", reply);
if(reply_len > 0 && reply[reply_len - 1] != '\n')
- printf("\n");
+ LOGE("\n");
}
end_success:
@@ -434,7 +436,7 @@
if(open){
fd_tmp = popen("/etc/wifi/mbtk_wifi_driver.sh sta start","r");
}else{
- fd_tmp = popen("/etc/wifi/mbtk_wifi_driver.sh driver_rmmod","r");
+ fd_tmp = popen("/etc/wifi/mbtk_wifi_driver.sh sta stop","r");
}
if(fd_tmp){
@@ -442,13 +444,13 @@
fgets(buf,200,fd_tmp);
pclose(fd_tmp);
if(strlen(buf) > 0){
- printf("Driver %s fail.(%s)\n",(open?"open":"close"),buf);
+ LOGE("Driver %s fail.(%s)\n",(open?"open":"close"),buf);
result = STA_ERR_DRIVER;
}else{// Open wpa_supplicant
- printf("Driver %s success.\n",(open?"open":"close"));
+ LOGE("Driver %s success.\n",(open?"open":"close"));
}
}else{
- printf("Driver %s fail.(%s)\n",(open?"open":"close"));
+ LOGE("Driver %s fail.(%s)\n",(open?"open":"close"));
result = STA_ERR_DRIVER;
}
@@ -490,7 +492,7 @@
sta_ctrl_ifname[size] = '\0';
if(pipe(sta_ctrl_pipe_fd)){
- printf("pipe() fail(%d).\n",errno);
+ LOGE("pipe() fail(%d).\n",errno);
result = STA_ERR_UNKNOWN;
goto end_fail;
}
@@ -501,7 +503,7 @@
fgets(buf,200,fd_tmp);
pclose(fd_tmp);
if(strlen(buf) > 0){
- printf("wpa_supplicant is running.(%s)\n",buf);
+ LOGE("wpa_supplicant is running.(%s)\n",buf);
}else{// Open wpa_supplicant
bzero(buf,200);
@@ -516,23 +518,23 @@
"wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wifi/wpa_supplicant.conf -B");
*/
if (sta_ctrl_system(buf)){
- printf("\"%s\" success.\n",buf);
+ LOGE("\"%s\" success.\n",buf);
sleep(1);
}else{
- printf("\"%s\" fail.\n",buf);
+ LOGE("\"%s\" fail.\n",buf);
result = STA_ERR_UNKNOWN;
goto end_fail;
}
}
}else{
- printf("\"pidof wpa_supplicant\" fail\n");
+ LOGE("\"pidof wpa_supplicant\" fail\n");
result = STA_ERR_UNKNOWN;
goto end_fail;
}
result = sta_ctrl_open_connection();
if(STA_ERR_SUCCESS != result) {
- printf("sta_ctrl_open_connection() fail(%d).\n",result);
+ LOGE("sta_ctrl_open_connection() fail(%d).\n",result);
goto end_fail;
}
@@ -564,11 +566,11 @@
write(sta_ctrl_pipe_fd[1],"0",1);
- printf("Waitting for thread(%ld) exit.\n",sta_event_thread_id);
+ LOGE("Waitting for thread(%ld) exit.\n",sta_event_thread_id);
pthread_join(sta_event_thread_id,NULL);
- printf("pthread_join() return.\n");
+ LOGE("pthread_join() return.\n");
close(sta_ctrl_pipe_fd[0]);
@@ -580,20 +582,20 @@
// Stop process wpa_supplicant
if(sta_ctrl_system("killall -15 wpa_supplicant")
&& sta_ctrl_kill_check("wpa_supplicant")){
- printf("\"killall -15 wpa_supplicant\" success.\n");
+ LOGE("\"killall -15 wpa_supplicant\" success.\n");
}else{
if(sta_ctrl_system("killall -9 wpa_supplicant")){
- printf("\"killall -9 wpa_supplicant\" success.\n");
+ LOGE("\"killall -9 wpa_supplicant\" success.\n");
}else{
- printf("\"killall -9 wpa_supplicant\" fail.\n");
+ LOGE("\"killall -9 wpa_supplicant\" fail.\n");
}
}
end_success:
- printf("sta_ctrl_wpa_deinit() end(success).\n");
+ LOGE("sta_ctrl_wpa_deinit() end(success).\n");
return result;
end_fail:
- printf("sta_ctrl_wpa_deinit() end(fail)[%s].\n",result);
+ LOGE("sta_ctrl_wpa_deinit() end(fail)[%s].\n",result);
return result;
}
diff --git a/mbtk/mbtk_rild/src/atchannel.c b/mbtk/mbtk_rild/src/atchannel.c
index a1a9f21..56b1d08 100755
--- a/mbtk/mbtk_rild/src/atchannel.c
+++ b/mbtk/mbtk_rild/src/atchannel.c
@@ -36,7 +36,7 @@
#define MAX_AT_RESPONSE (8 * 1024)
#define HANDSHAKE_RETRY_COUNT 20
#define HANDSHAKE_TIMEOUT_MSEC 500
-#define AT_BUFF_MAX 100
+#define AT_BUFF_MAX 1024
static pthread_t s_tid_reader;
static int s_at_fd = -1; /* fd of the AT channel */
diff --git a/mbtk/mbtk_rild/src/mbtk_info_server.c b/mbtk/mbtk_rild/src/mbtk_info_server.c
index f09e33c..27d08d4 100755
--- a/mbtk/mbtk_rild/src/mbtk_info_server.c
+++ b/mbtk/mbtk_rild/src/mbtk_info_server.c
@@ -65,6 +65,7 @@
static mbtk_signal_info_t signal_globe;
+mbtk_info_err_enum ecall_pack_req_process(sock_client_info_t* cli_info, mbtk_info_pack_t* pack);
/*
AT*POWERIND=0"
@@ -596,7 +597,7 @@
ret = MBTK_SIM_NOT_READY;
goto done;
}
-
+
/* CPIN? has succeeded, now look at the result */
cpinLine = p_response->p_intermediates->line;
@@ -1220,27 +1221,27 @@
{
line = lines_ptr->line;
char *start = strstr(line, "FALCON_CP_SDK");
- if(start)
+ if(start)
{
char *end = strstr(start, "_Linux");
- if(end)
+ if(end)
{
- end += strlen("_Linux");
+ end += strlen("_Linux");
int length = end - start;
if (length)
{
strncpy(data, start, length);
((char*)data)[length] = '\0';
break;
- }
+ }
else
{
err = -1;
goto exit;
-
+
}
- }
- else
+ }
+ else
{
err = -1;
goto exit;
@@ -1248,7 +1249,7 @@
}
lines_ptr = lines_ptr->p_next;
}
-
+
goto exit;
exit:
at_response_free(response);
@@ -1862,7 +1863,7 @@
{
ATResponse *response = NULL;
char cmd[64]={0};
-
+
int err = at_send_command_singleline("AT+CLCK=SC,2", "+CLCK:", &response);
if (err < 0 || response == NULL || response->success == 0 || !response->p_intermediates)
{
@@ -1886,7 +1887,7 @@
LOGE("[req_get_pin_state] at_tok_start fail.[%d]", err);
goto exit;
}
-
+
int clck;
err = at_tok_nextint(&line, &clck);
if (err < 0)
@@ -4182,6 +4183,8 @@
return sms_pack_req_process(cli_info, pack);
} else if(pack->info_id > MBTK_INFO_ID_PB_BEGIN && pack->info_id < MBTK_INFO_ID_PB_END) {
return pb_pack_req_process(cli_info, pack);
+ } else if(pack->info_id > RIL_MSG_ID_ECALL_BEGIN && pack->info_id < RIL_MSG_ID_ECALL_END) {
+ return ecall_pack_req_process(cli_info, pack);
} else {
mbtk_info_err_enum err = MBTK_INFO_ERR_SUCCESS;
int cme_err = MBTK_INFO_ERR_CME_NON;
@@ -6773,7 +6776,7 @@
strftime(tmp, 50, "%F %T", tm_t);
snprintf(buff, sizeof(buff), "%s:%d,%d,%d,%d,%d,%d,%d,%d", tmp, signal.type, signal.rssi, signal.rxlev, signal.ber, signal.rscp, signal.ecno,
signal.rsrq, signal.rsrp);
- mbtk_signal_log(buff);
+ mbtk_signal_log(buff);
}
if(signal_globe.type != signal.type)
diff --git a/mbtk/mbtk_rild/src/ril_ecall.c b/mbtk/mbtk_rild/src/ril_ecall.c
new file mode 100755
index 0000000..8d7a5e8
--- /dev/null
+++ b/mbtk/mbtk_rild/src/ril_ecall.c
@@ -0,0 +1,1141 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <netinet/in.h>
+#include <pthread.h>
+#include <sys/epoll.h>
+#include <fcntl.h>
+#include <signal.h>
+
+#include "mbtk_type.h"
+#include "info_data.h"
+#include "atchannel.h"
+#include "at_tok.h"
+#include "mbtk_utils.h"
+#include "mbtk_info.h"
+
+static mbtk_ecall_mode_type_enum ecall_mode = MBTK_ECALL_MODE_TYPE_EU;
+
+void pack_rsp_send(int fd, int info_id, const void* data, int data_len);
+
+static int req_ecall_msdcfg(mbtk_ecall_msd_cfg_info_t *cfg_info, int *cme_err)
+{
+ ATResponse *response = NULL;
+ char cmd[1024] = {0};
+ sprintf(cmd, "AT*ECALLMSDCFG=%d,\"%s\",0", cfg_info->item_type, cfg_info->data);
+ int err = at_send_command(cmd, &response);
+ if (err < 0 || response->success == 0){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+exit:
+ at_response_free(response);
+ return err;
+}
+
+static int req_ecall_msdgen(int *cme_err)
+{
+ ATResponse *response = NULL;
+ int err = at_send_command("AT*ECALLMSDGEN", &response);
+ if (err < 0 || response->success == 0){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+exit:
+ at_response_free(response);
+ return err;
+}
+
+static int req_ecall_msd_set(const uint8 *msd, int *cme_err)
+{
+ ATResponse *response = NULL;
+ char cmd[1024] = {0};
+ sprintf(cmd, "AT*ECALLMSD=\"%s\"", msd);
+ int err = at_send_command(cmd, &response);
+ if (err < 0 || response->success == 0){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+exit:
+ at_response_free(response);
+ return err;
+}
+
+static int req_ecall_msd_get(uint8 *msd, int *cme_err)
+{
+ ATResponse *response = NULL;
+ char *tmp_ptr = NULL;
+ int err = at_send_command_singleline("AT*ECALLMSD?", "*ECALLMSD:", &response);
+
+ if (err < 0 || response->success == 0 || !response->p_intermediates){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+ char *line = response->p_intermediates->line;
+ err = at_tok_start(&line);
+ if (err < 0)
+ {
+ goto exit;
+ }
+
+ err = at_tok_nextstr(&line, &tmp_ptr);
+ if (err < 0)
+ {
+ goto exit;
+ }
+
+ if(tmp_ptr && strlen(tmp_ptr) > 0) {
+ memcpy(msd, tmp_ptr, strlen(tmp_ptr));
+ }
+
+ goto exit;
+exit:
+ at_response_free(response);
+ return err;
+}
+
+static int req_ecall_push(int *cme_err)
+{
+ ATResponse *response = NULL;
+ int err = at_send_command("AT*ECALLPUSH", &response);
+ if (err < 0 || response->success == 0){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+exit:
+ at_response_free(response);
+ return err;
+}
+
+/*
+AT*ECALLONLY?
+*ECALLONLY: 0,0,18981911691,18981911691
+
+OK
+
+*/
+static int req_ecall_only_get(mbtk_ecall_only_info_t *only_info, int *cme_err)
+{
+ ATResponse *response = NULL;
+ char *tmp_ptr = NULL;
+ int tmp_int;
+ int err = at_send_command_singleline("AT*ECALLONLY?", "*ECALLONLY:", &response);
+
+ if (err < 0 || response->success == 0 || !response->p_intermediates){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+ char *line = response->p_intermediates->line;
+ err = at_tok_start(&line);
+ if (err < 0)
+ {
+ goto exit;
+ }
+
+ err = at_tok_nextint(&line, &tmp_int);
+ if (err < 0)
+ {
+ goto exit;
+ }
+ only_info->active = (mbtk_ecall_only_type_enum)tmp_int;
+
+ err = at_tok_nextint(&line, &tmp_int);
+ if (err < 0)
+ {
+ goto exit;
+ }
+ only_info->sim_type = (mbtk_ecall_sim_type_enum)tmp_int;
+
+ err = at_tok_nextstr(&line, &tmp_ptr);
+ if (err < 0)
+ {
+ goto exit;
+ }
+
+ if(tmp_ptr && strlen(tmp_ptr) > 0) {
+ memcpy(only_info->test_num, tmp_ptr, strlen(tmp_ptr));
+ }
+
+ err = at_tok_nextstr(&line, &tmp_ptr);
+ if (err < 0)
+ {
+ goto exit;
+ }
+
+ if(tmp_ptr && strlen(tmp_ptr) > 0) {
+ memcpy(only_info->reconfig_num, tmp_ptr, strlen(tmp_ptr));
+ }
+
+ goto exit;
+exit:
+ at_response_free(response);
+ return err;
+}
+
+/*
+AT*ECALLONLY?
+*ECALLONLY: 0,0,18981911691,18981911691
+
+OK
+
+*/
+static int req_ecall_only_set(const mbtk_ecall_only_info_t *only_info, int *cme_err)
+{
+ ATResponse *response = NULL;
+ char cmd[1024] = {0};
+ sprintf(cmd, "AT*ECALLONLY=%d,%s,%s", only_info->active,only_info->test_num,only_info->reconfig_num);
+ int err = at_send_command(cmd, &response);
+ if (err < 0 || response->success == 0){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+exit:
+ at_response_free(response);
+ return err;
+}
+
+/*
+AT*ECALLREG=0/1
+
+*/
+static int req_ecall_reg_set(uint8 reg, int *cme_err)
+{
+ ATResponse *response = NULL;
+ char cmd[30] = {0};
+ sprintf(cmd, "AT*ECALLREG=%d", reg);
+ int err = at_send_command(cmd, &response);
+ if (err < 0 || response->success == 0){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+exit:
+ at_response_free(response);
+ return err;
+}
+
+/*
+AT+CECALL?
++CECALL: 4
+
+OK
+
+*/
+static int req_ecall_dial_state_get(mbtk_ecall_dial_type_enum *type, int *cme_err)
+{
+ ATResponse *response = NULL;
+ int tmp_int;
+ int err = at_send_command_singleline("AT+CECALL?", "+CECALL:", &response);
+
+ if (err < 0 || response->success == 0 || !response->p_intermediates){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+ char *line = response->p_intermediates->line;
+ err = at_tok_start(&line);
+ if (err < 0)
+ {
+ goto exit;
+ }
+
+ err = at_tok_nextint(&line, &tmp_int);
+ if (err < 0)
+ {
+ goto exit;
+ }
+ *type = (mbtk_ecall_dial_type_enum)tmp_int;
+
+ goto exit;
+exit:
+ at_response_free(response);
+ return err;
+}
+
+/*
+AT+CECALL=<ecalltype>
+OK
+*/
+static int req_ecall_dial_start(mbtk_ecall_dial_type_enum type, int *cme_err)
+{
+ ATResponse *response = NULL;
+ char cmd[1024] = {0};
+ sprintf(cmd, "AT+CECALL=%d", type);
+ int err = at_send_command(cmd, &response);
+ if (err < 0 || response->success == 0){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+exit:
+ at_response_free(response);
+ return err;
+}
+
+
+/*
+AT*ECALLMODE?
+*ECALLMODE: "ERA"
+
+OK
+
+*/
+static int req_ecall_mode_get(mbtk_ecall_mode_type_enum *mode, int *cme_err)
+{
+ ATResponse *response = NULL;
+ char *tmp_ptr = NULL;
+ int err = at_send_command_singleline("AT*ECALLMODE?", "*ECALLMODE:", &response);
+
+ if (err < 0 || response->success == 0 || !response->p_intermediates){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+ char *line = response->p_intermediates->line;
+ err = at_tok_start(&line);
+ if (err < 0)
+ {
+ goto exit;
+ }
+
+ err = at_tok_nextstr(&line, &tmp_ptr);
+ if (err < 0)
+ {
+ goto exit;
+ }
+
+ if(tmp_ptr && strlen(tmp_ptr) > 0) {
+ if(strcmp(tmp_ptr, "ERA") == 0) {
+ *mode = MBTK_ECALL_MODE_TYPE_ERA;
+ } else {
+ *mode = MBTK_ECALL_MODE_TYPE_EU;
+ }
+
+ ecall_mode = *mode;
+ } else {
+ err = -1;
+ }
+
+ goto exit;
+exit:
+ at_response_free(response);
+ return err;
+}
+
+/*
+AT*ECALLMODE="ERA"
+OK
+
+*/
+static int req_ecall_mode_set(mbtk_ecall_mode_type_enum mode, int *cme_err)
+{
+ ATResponse *response = NULL;
+ char cmd[1024] = {0};
+ if(mode == MBTK_ECALL_MODE_TYPE_EU) {
+ sprintf(cmd, "AT*ECALLMODE=\"EU\"");
+ } else {
+ sprintf(cmd, "AT*ECALLMODE=\"ERA\"");
+ }
+ int err = at_send_command(cmd, &response);
+ if (err < 0 || response->success == 0){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+ ecall_mode = mode;
+
+exit:
+ at_response_free(response);
+ return err;
+}
+
+/*
+AT*ECALLDATA=5,2
+*ECALLDATA: 5,2,250
+
+OK
+
+AT*ECALLTIMER?
+*ECALLTIMER: ERA mode, callback timer: 1200s, dial setup timer: 30s, NAD deregister timer: 7200s, cleardown timer: 3600s, redial attempts count: 10, redial wait timer: 30s, smsprocess: 1, SMS resend timer: 3600s, sms msd send count: 10.
+
+OK
+
+*/
+static int req_ecall_cfg_get(mbtk_ecall_cfg_item_enum type, mbtk_ecall_cfg_info_t *cfg, int *cme_err)
+{
+ ATResponse *response = NULL;
+ char *tmp_ptr = NULL;
+ int tmp_int;
+ char cmd[1024] = {0};
+ int err = 0;
+
+ cfg->type = type;
+ switch(type)
+ {
+ case MBTK_ECALL_CFG_ITEM_T3:
+ case MBTK_ECALL_CFG_ITEM_T5:
+ case MBTK_ECALL_CFG_ITEM_T6:
+ case MBTK_ECALL_CFG_ITEM_T7:
+ case MBTK_ECALL_CFG_ITEM_TH:
+ snprintf(cmd, sizeof(cmd), "AT*ECALLDATA=5,%d", type);
+
+ err = at_send_command_singleline(cmd, "*ECALLDATA:", &response);
+ break;
+ default:
+ snprintf(cmd, sizeof(cmd), "AT*ECALLTIMER?");
+
+ err = at_send_command_singleline(cmd, "*ECALLTIMER:", &response);
+ break;
+ }
+
+ if (err < 0 || response->success == 0 || !response->p_intermediates){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+ char *line = response->p_intermediates->line;
+ err = at_tok_start(&line);
+ if (err < 0)
+ {
+ goto exit;
+ }
+
+ if(strstr(cmd, "AT*ECALLDATA")) {
+ err = at_tok_nextint(&line, &tmp_int);
+ if (err < 0)
+ {
+ goto exit;
+ }
+
+ err = at_tok_nextint(&line, &tmp_int);
+ if (err < 0)
+ {
+ goto exit;
+ }
+
+ err = at_tok_nextint(&line, &tmp_int);
+ if (err < 0)
+ {
+ goto exit;
+ }
+
+ cfg->data = (uint32)(tmp_int * 20); // ms
+ } else {
+ // *ECALLTIMER: ERA mode, callback timer: 1200s,
+ // dial setup timer: 30s, NAD deregister timer: 7200s,
+ // cleardown timer: 3600s, redial attempts count: 10,
+ // redial wait timer: 30s, smsprocess: 1, SMS resend timer: 3600s,
+ // sms msd send count: 10.
+
+ if(strstr(line, "ERA mode") != NULL) {
+ ecall_mode = MBTK_ECALL_MODE_TYPE_ERA;
+ } else {
+ ecall_mode = MBTK_ECALL_MODE_TYPE_EU;
+ }
+
+ switch(type)
+ {
+ case MBTK_ECALL_CFG_ITEM_TIMER_CALLBACK:
+ {
+ if((tmp_ptr = strstr(line, "callback timer: ")) != NULL) {
+ cfg->data = (uint32)atoi(tmp_ptr + 16); // s
+ cfg->data *= 1000; // s -> ms
+ }
+ break;
+ }
+ case MBTK_ECALL_CFG_ITEM_TIMER_CLEARDOWN:
+ {
+ if((tmp_ptr = strstr(line, "cleardown timer: ")) != NULL) {
+ cfg->data = (uint32)atoi(tmp_ptr + 17); // s
+ cfg->data *= 1000; // s -> ms
+ }
+ break;
+ }
+ case MBTK_ECALL_CFG_ITEM_TIMER_DEREG:
+ {
+ if((tmp_ptr = strstr(line, "deregister timer: ")) != NULL) {
+ cfg->data = (uint32)atoi(tmp_ptr + 18); // s
+ cfg->data *= 1000; // s -> ms
+ }
+ break;
+ }
+ case MBTK_ECALL_CFG_ITEM_TIMER_DIAL:
+ {
+ if((tmp_ptr = strstr(line, "dial setup timer: ")) != NULL) {
+ cfg->data = (uint32)atoi(tmp_ptr + 18); // s
+ }
+ break;
+ }
+ case MBTK_ECALL_CFG_ITEM_TIMER_REDIAL:
+ {
+ if((tmp_ptr = strstr(line, "redial wait timer: ")) != NULL) {
+ cfg->data = (uint32)atoi(tmp_ptr + 19); // s
+ cfg->data *= 1000; // s -> ms
+ }
+ break;
+ }
+ case MBTK_ECALL_CFG_ITEM_TIMER_SMS:
+ {
+ if((tmp_ptr = strstr(line, "SMS resend timer: ")) != NULL) {
+ cfg->data = (uint32)atoi(tmp_ptr + 18);
+ cfg->data *= 1000; // s -> ms
+ }
+ break;
+ }
+ case MBTK_ECALL_CFG_ITEM_REDIALCNT:
+ {
+ if((tmp_ptr = strstr(line, "redial attempts count: ")) != NULL) {
+ cfg->data = (uint32)atoi(tmp_ptr + 23);
+ }
+ break;
+ }
+ case MBTK_ECALL_CFG_ITEM_SMSPROCESS:
+ {
+ if((tmp_ptr = strstr(line, "smsprocess: ")) != NULL) {
+ cfg->data = (uint32)atoi(tmp_ptr + 12);
+ }
+ break;
+ }
+ case MBTK_ECALL_CFG_ITEM_SMSMSDCNT:
+ {
+ if((tmp_ptr = strstr(line, "sms msd send count: ")) != NULL) {
+ cfg->data = (uint32)atoi(tmp_ptr + 20);
+ }
+ break;
+ }
+ default:
+ LOGE("Unknown config item : %d", type);
+ err = -1;
+ break;
+ }
+ }
+
+ goto exit;
+exit:
+ at_response_free(response);
+ return err;
+}
+
+/*
+AT*ECALLDATA=5,2,250
+OK
+
+AT*ECALLTIMER=dereg,300
+OK
+*/
+static int req_ecall_cfg_set(const mbtk_ecall_cfg_info_t *cfg_info, int *cme_err)
+{
+ ATResponse *response = NULL;
+ char cmd[1024] = {0};
+ int err = 0;
+
+ if(ecall_mode == MBTK_ECALL_MODE_TYPE_EU) {
+ if(cfg_info->type != MBTK_ECALL_CFG_ITEM_TIMER_CALLBACK
+ && cfg_info->type != MBTK_ECALL_CFG_ITEM_TIMER_DIAL
+ && cfg_info->type != MBTK_ECALL_CFG_ITEM_TIMER_DEREG
+ && cfg_info->type != MBTK_ECALL_CFG_ITEM_TIMER_CLEARDOWN){
+ LOGW("No support for EU.");
+ return -1;
+ }
+ }
+
+ switch(cfg_info->type)
+ {
+ case MBTK_ECALL_CFG_ITEM_T3:
+ case MBTK_ECALL_CFG_ITEM_T5:
+ case MBTK_ECALL_CFG_ITEM_T6:
+ case MBTK_ECALL_CFG_ITEM_T7:
+ case MBTK_ECALL_CFG_ITEM_TH:
+ snprintf(cmd, sizeof(cmd), "AT*ECALLDATA=5,%d,%d", cfg_info->type, cfg_info->data / 20);
+ break;
+ case MBTK_ECALL_CFG_ITEM_TIMER_CALLBACK:
+ {
+ snprintf(cmd, sizeof(cmd), "AT*ECALLTIMER=callback,%d", cfg_info->data / 1000);
+ break;
+ }
+ case MBTK_ECALL_CFG_ITEM_TIMER_CLEARDOWN:
+ {
+ snprintf(cmd, sizeof(cmd), "AT*ECALLTIMER=cleardown,%d", cfg_info->data / 1000);
+ break;
+ }
+ case MBTK_ECALL_CFG_ITEM_TIMER_DEREG:
+ {
+ snprintf(cmd, sizeof(cmd), "AT*ECALLTIMER=dereg,%d", cfg_info->data / 1000);
+ break;
+ }
+ case MBTK_ECALL_CFG_ITEM_TIMER_DIAL:
+ {
+ snprintf(cmd, sizeof(cmd), "AT*ECALLTIMER=dial,%d", cfg_info->data / 1000);
+ break;
+ }
+ case MBTK_ECALL_CFG_ITEM_TIMER_REDIAL:
+ {
+ snprintf(cmd, sizeof(cmd), "AT*ECALLTIMER=redialtmr,%d", cfg_info->data / 1000);
+ break;
+ }
+ case MBTK_ECALL_CFG_ITEM_TIMER_SMS:
+ {
+ snprintf(cmd, sizeof(cmd), "AT*ECALLTIMER=sms,%d", cfg_info->data / 1000);
+ break;
+ }
+ case MBTK_ECALL_CFG_ITEM_REDIALCNT:
+ {
+ snprintf(cmd, sizeof(cmd), "AT*ECALLTIMER=redialcnt,%d", cfg_info->data);
+ break;
+ }
+ case MBTK_ECALL_CFG_ITEM_SMSPROCESS:
+ {
+ snprintf(cmd, sizeof(cmd), "AT*ECALLTIMER=smsprocess,%d", cfg_info->data);
+ break;
+ }
+ case MBTK_ECALL_CFG_ITEM_SMSMSDCNT:
+ {
+ snprintf(cmd, sizeof(cmd), "AT*ECALLTIMER=smsmsdcnt,%d", cfg_info->data);
+ break;
+ }
+ default:
+ LOGE("Unknown config item : %d", cfg_info->type);
+ err = -1;
+ goto exit;
+ }
+
+ err = at_send_command(cmd, &response);
+ if (err < 0 || response->success == 0){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+exit:
+ at_response_free(response);
+ return err;
+}
+
+/*
+AT*ECALLMUTESPK=1
+OK
+
+*/
+static int req_ecall_spkmute_set(int mute, int *cme_err)
+{
+ ATResponse *response = NULL;
+ char cmd[100] = {0};
+ sprintf(cmd, "AT*ECALLMUTESPK=%d", mute);
+ int err = at_send_command(cmd, &response);
+ if (err < 0 || response->success == 0){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+exit:
+ at_response_free(response);
+ return err;
+}
+
+
+/*
+AT*ECALLSMSNUM?
+*ECALLSMSNUM: "18981991452"
+
+OK
+
+*/
+static int req_ecall_sms_num_get(uint8 *number, int *cme_err)
+{
+ ATResponse *response = NULL;
+ char *tmp_ptr = NULL;
+ int err = at_send_command_singleline("AT*ECALLSMSNUM?", "*ECALLSMSNUM:", &response);
+
+ if (err < 0 || response->success == 0 || !response->p_intermediates){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+ char *line = response->p_intermediates->line;
+ err = at_tok_start(&line);
+ if (err < 0)
+ {
+ goto exit;
+ }
+
+ err = at_tok_nextstr(&line, &tmp_ptr);
+ if (err < 0)
+ {
+ goto exit;
+ }
+
+ if(tmp_ptr && strlen(tmp_ptr) > 0) {
+ memcpy(number, tmp_ptr, strlen(tmp_ptr));
+ }
+
+ goto exit;
+exit:
+ at_response_free(response);
+ return err;
+}
+
+/*
+AT*ECALLSMSNUM=18981991452
+OK
+
+*/
+static int req_ecall_sms_num_set(const uint8 *number, int *cme_err)
+{
+ ATResponse *response = NULL;
+ char cmd[100] = {0};
+ sprintf(cmd, "AT*ECALLSMSNUM=%s", number);
+ int err = at_send_command(cmd, &response);
+ if (err < 0 || response->success == 0){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+exit:
+ at_response_free(response);
+ return err;
+}
+
+/*
+AT*AUDGAIN=8,1 // Set Rx voice gain = 8dB
+OK
+
+*/
+static int req_ecall_gain_set(mbtk_ecall_gain_info_t *gain, int *cme_err)
+{
+ ATResponse *response = NULL;
+ char cmd[100] = {0};
+ sprintf(cmd, "AT*AUDGAIN=%d,%d", gain->gain, gain->mode);
+ int err = at_send_command(cmd, &response);
+ if (err < 0 || response->success == 0){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+exit:
+ at_response_free(response);
+ return err;
+}
+
+//void net_list_free(void *data);
+// Return MBTK_INFO_ERR_SUCCESS,will call pack_error_send() to send RSP.
+// Otherwise, do not call pack_error_send().
+mbtk_info_err_enum ecall_pack_req_process(sock_client_info_t* cli_info, mbtk_info_pack_t* pack)
+{
+ mbtk_info_err_enum err = MBTK_INFO_ERR_SUCCESS;
+ int cme_err = MBTK_INFO_ERR_CME_NON;
+ switch(pack->info_id)
+ {
+ case RIL_MSG_ID_ECALL_MSDCFG_REQ: // mbtk_ecall_msd_cfg_info_t
+ {
+ if(pack->data_len == 0 || pack->data == NULL)
+ {
+ err = MBTK_INFO_ERR_UNSUPPORTED;
+ }
+ else // Set
+ {
+ mbtk_ecall_msd_cfg_info_t *cfg_info = (mbtk_ecall_msd_cfg_info_t*)(pack->data);
+ if(req_ecall_msdcfg(cfg_info, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+ {
+ if(cme_err != MBTK_INFO_ERR_CME_NON) {
+ err = MBTK_INFO_ERR_CME + cme_err;
+ } else {
+ err = MBTK_INFO_ERR_UNKNOWN;
+ }
+ LOG("AT*ECALLMSDCFG fail.");
+ }
+ else
+ {
+ pack_rsp_send(cli_info->fd, RIL_MSG_ID_ECALL_MSDCFG_RSP, NULL, 0);
+ }
+ }
+ break;
+ }
+ case RIL_MSG_ID_ECALL_MSDGEN_REQ:
+ {
+ if(pack->data_len == 0 || pack->data == NULL)
+ {
+ if(req_ecall_msdgen(&cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+ {
+ if(cme_err != MBTK_INFO_ERR_CME_NON) {
+ err = MBTK_INFO_ERR_CME + cme_err;
+ } else {
+ err = MBTK_INFO_ERR_UNKNOWN;
+ }
+ LOG("AT*ECALLMSDGEN fail.");
+ }
+ else
+ {
+ pack_rsp_send(cli_info->fd, RIL_MSG_ID_ECALL_MSDGEN_RSP, NULL, 0);
+ }
+ }
+ else // Set
+ {
+ err = MBTK_INFO_ERR_UNSUPPORTED;
+ }
+ break;
+ }
+ case RIL_MSG_ID_ECALL_MSD_REQ: // uint8[]
+ {
+ uint8 msd[MBTK_ECALL_MSD_LEN_MAX];
+ memset(msd, 0, sizeof(msd));
+ if(pack->data_len == 0 || pack->data == NULL)
+ {
+ if(req_ecall_msd_get(msd, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+ {
+ if(cme_err != MBTK_INFO_ERR_CME_NON) {
+ err = MBTK_INFO_ERR_CME + cme_err;
+ } else {
+ err = MBTK_INFO_ERR_UNKNOWN;
+ }
+ LOG("Get MSD fail.");
+ }
+ else
+ {
+ pack_rsp_send(cli_info->fd, RIL_MSG_ID_ECALL_MSD_RSP, msd, strlen(msd));
+ }
+ }
+ else // Set
+ {
+ memcpy(msd, pack->data, pack->data_len);
+ if(req_ecall_msd_set(msd, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+ {
+ if(cme_err != MBTK_INFO_ERR_CME_NON) {
+ err = MBTK_INFO_ERR_CME + cme_err;
+ } else {
+ err = MBTK_INFO_ERR_UNKNOWN;
+ }
+ LOG("AT*ECALLMSD fail.");
+ }
+ else
+ {
+ pack_rsp_send(cli_info->fd, RIL_MSG_ID_ECALL_MSD_RSP, NULL, 0);
+ }
+ }
+ break;
+ }
+ case RIL_MSG_ID_ECALL_PUSH_REQ:
+ {
+ if(pack->data_len == 0 || pack->data == NULL)
+ {
+ if(req_ecall_push(&cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+ {
+ if(cme_err != MBTK_INFO_ERR_CME_NON) {
+ err = MBTK_INFO_ERR_CME + cme_err;
+ } else {
+ err = MBTK_INFO_ERR_UNKNOWN;
+ }
+ LOG("AT*ECALLPUSH fail.");
+ }
+ else
+ {
+ pack_rsp_send(cli_info->fd, RIL_MSG_ID_ECALL_PUSH_RSP, NULL, 0);
+ }
+ }
+ else // Set
+ {
+ err = MBTK_INFO_ERR_UNSUPPORTED;
+ }
+ break;
+ }
+ case RIL_MSG_ID_ECALL_ONLY_REQ: // mbtk_ecall_only_info_t
+ {
+ if(pack->data_len == 0 || pack->data == NULL)
+ {
+ mbtk_ecall_only_info_t only_info;
+ memset(&only_info, 0, sizeof(mbtk_ecall_only_info_t));
+ if(req_ecall_only_get(&only_info, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+ {
+ if(cme_err != MBTK_INFO_ERR_CME_NON) {
+ err = MBTK_INFO_ERR_CME + cme_err;
+ } else {
+ err = MBTK_INFO_ERR_UNKNOWN;
+ }
+ LOG("Get ecall only mode fail.");
+ }
+ else
+ {
+ pack_rsp_send(cli_info->fd, RIL_MSG_ID_ECALL_ONLY_RSP, &only_info, sizeof(mbtk_ecall_only_info_t));
+ }
+ }
+ else // Set
+ {
+ mbtk_ecall_only_info_t *only_info = (mbtk_ecall_only_info_t*)(pack->data);
+ if(req_ecall_only_set(only_info, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+ {
+ if(cme_err != MBTK_INFO_ERR_CME_NON) {
+ err = MBTK_INFO_ERR_CME + cme_err;
+ } else {
+ err = MBTK_INFO_ERR_UNKNOWN;
+ }
+ LOG("AT*ECALLONLY fail.");
+ }
+ else
+ {
+ pack_rsp_send(cli_info->fd, RIL_MSG_ID_ECALL_ONLY_RSP, NULL, 0);
+ }
+ }
+ break;
+ }
+ case RIL_MSG_ID_ECALL_REG_REQ: // reg <uint8>
+ {
+ if(pack->data_len == 0 || pack->data == NULL)
+ {
+ err = MBTK_INFO_ERR_UNSUPPORTED;
+ }
+ else
+ {
+ uint8 reg = pack->data[0];
+ if(req_ecall_reg_set(reg, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+ {
+ if(cme_err != MBTK_INFO_ERR_CME_NON) {
+ err = MBTK_INFO_ERR_CME + cme_err;
+ } else {
+ err = MBTK_INFO_ERR_UNKNOWN;
+ }
+ LOG("ecall reg(%d) fail.", reg);
+ }
+ else
+ {
+ pack_rsp_send(cli_info->fd, RIL_MSG_ID_ECALL_REG_RSP, NULL, 0);
+ }
+ }
+ break;
+ }
+ case RIL_MSG_ID_ECALL_DIAL_REQ: // mbtk_ecall_dial_type_enum
+ {
+ if(pack->data_len == 0 || pack->data == NULL)
+ {
+ mbtk_ecall_dial_type_enum type;
+ if(req_ecall_dial_state_get(&type, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+ {
+ if(cme_err != MBTK_INFO_ERR_CME_NON) {
+ err = MBTK_INFO_ERR_CME + cme_err;
+ } else {
+ err = MBTK_INFO_ERR_UNKNOWN;
+ }
+ LOG("Get ecall type fail.");
+ }
+ else
+ {
+ pack_rsp_send(cli_info->fd, RIL_MSG_ID_ECALL_DIAL_RSP, &type, sizeof(uint8));
+ }
+ }
+ else
+ {
+ mbtk_ecall_dial_type_enum type = (mbtk_ecall_dial_type_enum)pack->data[0];
+ if(req_ecall_dial_start(type, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+ {
+ if(cme_err != MBTK_INFO_ERR_CME_NON) {
+ err = MBTK_INFO_ERR_CME + cme_err;
+ } else {
+ err = MBTK_INFO_ERR_UNKNOWN;
+ }
+ LOG("Start ecall %d fail.", type);
+ }
+ else
+ {
+ pack_rsp_send(cli_info->fd, RIL_MSG_ID_ECALL_DIAL_RSP, NULL, 0);
+ }
+ }
+ break;
+ }
+ case RIL_MSG_ID_ECALL_MODE_REQ: // mbtk_ecall_cfg_item_enum / mbtk_ecall_cfg_info_t
+ {
+ if(pack->data_len == 0 || pack->data == NULL)
+ {
+ mbtk_ecall_mode_type_enum mode;
+ if(req_ecall_mode_get(&mode, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+ {
+ if(cme_err != MBTK_INFO_ERR_CME_NON) {
+ err = MBTK_INFO_ERR_CME + cme_err;
+ } else {
+ err = MBTK_INFO_ERR_UNKNOWN;
+ }
+ LOG("Get ecall mode fail.");
+ }
+ else
+ {
+ pack_rsp_send(cli_info->fd, RIL_MSG_ID_ECALL_MODE_RSP, &mode, sizeof(uint8));
+ }
+ }
+ else
+ {
+ mbtk_ecall_mode_type_enum mode = (mbtk_ecall_mode_type_enum)pack->data[0];
+ if(req_ecall_mode_set(mode, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+ {
+ if(cme_err != MBTK_INFO_ERR_CME_NON) {
+ err = MBTK_INFO_ERR_CME + cme_err;
+ } else {
+ err = MBTK_INFO_ERR_UNKNOWN;
+ }
+ LOG("Set ecall mode %d fail.", mode);
+ }
+ else
+ {
+ pack_rsp_send(cli_info->fd, RIL_MSG_ID_ECALL_MODE_RSP, NULL, 0);
+ }
+ }
+ break;
+ }
+ case RIL_MSG_ID_ECALL_CFG_REQ: // mbtk_ecall_cfg_item_enum / mbtk_ecall_cfg_info_t
+ {
+ if(pack->data_len == 0 || pack->data == NULL)
+ {
+ err = MBTK_INFO_ERR_UNSUPPORTED;
+ }
+ else
+ {
+ if(pack->data_len == sizeof(mbtk_ecall_cfg_info_t)) { // Set
+ mbtk_ecall_cfg_info_t *cfg_info = (mbtk_ecall_cfg_info_t*)pack->data;
+ if(req_ecall_cfg_set(cfg_info, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+ {
+ if(cme_err != MBTK_INFO_ERR_CME_NON) {
+ err = MBTK_INFO_ERR_CME + cme_err;
+ } else {
+ err = MBTK_INFO_ERR_UNKNOWN;
+ }
+ LOG("Set ecall config[%d] fail.", cfg_info->type);
+ }
+ else
+ {
+ pack_rsp_send(cli_info->fd, RIL_MSG_ID_ECALL_CFG_RSP, NULL, 0);
+ }
+ } else { // Get
+ mbtk_ecall_cfg_info_t cfg_info;
+ memset(&cfg_info, 0, sizeof(mbtk_ecall_cfg_info_t));
+ mbtk_ecall_cfg_item_enum type = (mbtk_ecall_cfg_item_enum)pack->data[0];
+ if(req_ecall_cfg_get(type, &cfg_info, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+ {
+ if(cme_err != MBTK_INFO_ERR_CME_NON) {
+ err = MBTK_INFO_ERR_CME + cme_err;
+ } else {
+ err = MBTK_INFO_ERR_UNKNOWN;
+ }
+ LOG("Get ecall config[%d] fail.", type);
+ }
+ else
+ {
+ pack_rsp_send(cli_info->fd, RIL_MSG_ID_ECALL_CFG_RSP, &cfg_info, sizeof(mbtk_ecall_cfg_info_t));
+ }
+ }
+ }
+ break;
+ }
+ case RIL_MSG_ID_ECALL_SMS_NUM_REQ: // uint8[]
+ {
+ uint8 number[RIL_MAX_NUMBER_LEN];
+ memset(number, 0, sizeof(number));
+ if(pack->data_len == 0 || pack->data == NULL)
+ {
+ if(req_ecall_sms_num_get(number, &cme_err) || strlen(number) == 0 || cme_err != MBTK_INFO_ERR_CME_NON)
+ {
+ if(cme_err != MBTK_INFO_ERR_CME_NON) {
+ err = MBTK_INFO_ERR_CME + cme_err;
+ } else {
+ err = MBTK_INFO_ERR_UNKNOWN;
+ }
+ LOG("Get ecall sms number fail.");
+ }
+ else
+ {
+ pack_rsp_send(cli_info->fd, RIL_MSG_ID_ECALL_SMS_NUM_RSP, number, strlen(number));
+ }
+ }
+ else // Set
+ {
+ memcpy(number, pack->data, pack->data_len);
+ if(req_ecall_sms_num_set(number, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+ {
+ if(cme_err != MBTK_INFO_ERR_CME_NON) {
+ err = MBTK_INFO_ERR_CME + cme_err;
+ } else {
+ err = MBTK_INFO_ERR_UNKNOWN;
+ }
+ LOG("Set ecall sms number fail.");
+ }
+ else
+ {
+ pack_rsp_send(cli_info->fd, RIL_MSG_ID_ECALL_SMS_NUM_RSP, NULL, 0);
+ }
+ }
+ break;
+ }
+ case RIL_MSG_ID_ECALL_MUTESPK_REQ:
+ {
+ if(pack->data_len == 0 || pack->data == NULL)
+ {
+ err = MBTK_INFO_ERR_UNSUPPORTED;
+ }
+ else // Set mute state.
+ {
+ uint8 mute = pack->data[0];
+ if(pack->data_len != sizeof(uint8) || (mute != 0 && mute != 1))
+ {
+ err = MBTK_INFO_ERR_REQ_PARAMETER;
+ LOG("Set spk mute parameter error.");
+ break;
+ }
+
+ if(req_ecall_spkmute_set(mute, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+ {
+ if(cme_err != MBTK_INFO_ERR_CME_NON) {
+ err = MBTK_INFO_ERR_CME + cme_err;
+ } else {
+ err = MBTK_INFO_ERR_UNKNOWN;
+ }
+ LOG("Set spk mute state fail.");
+ }
+ else
+ {
+ pack_rsp_send(cli_info->fd, RIL_MSG_ID_ECALL_MUTESPK_RSP, NULL, 0);
+ }
+ }
+ break;
+ }
+ case RIL_MSG_ID_ECALL_DSP_GAIN_REQ: // mbtk_ecall_gain_info_t
+ {
+ if(pack->data_len == 0 || pack->data == NULL)
+ {
+ err = MBTK_INFO_ERR_UNSUPPORTED;
+ }
+ else // Set
+ {
+ mbtk_ecall_gain_info_t *gain_info = (mbtk_ecall_gain_info_t *)pack->data;
+ if(req_ecall_gain_set(gain_info, &cme_err) || cme_err != MBTK_INFO_ERR_CME_NON)
+ {
+ if(cme_err != MBTK_INFO_ERR_CME_NON) {
+ err = MBTK_INFO_ERR_CME + cme_err;
+ } else {
+ err = MBTK_INFO_ERR_UNKNOWN;
+ }
+ LOGE("Set ecall gain fail.");
+ }
+ else
+ {
+ pack_rsp_send(cli_info->fd, RIL_MSG_ID_ECALL_DSP_GAIN_RSP, NULL, 0);
+ }
+ }
+ break;
+ }
+ default:
+ {
+ err = MBTK_INFO_ERR_REQ_UNKNOWN;
+ LOG("Unknown request : %s", id2str(pack->info_id));
+ break;
+ }
+ }
+
+ return err;
+}
+
+
+
diff --git a/mbtk/mbtk_rild_v2/src/atchannel.c b/mbtk/mbtk_rild_v2/src/atchannel.c
index 316e62a..56b1d08 100755
--- a/mbtk/mbtk_rild_v2/src/atchannel.c
+++ b/mbtk/mbtk_rild_v2/src/atchannel.c
@@ -621,6 +621,14 @@
}
}
+typedef struct
+{
+ int cid;
+ bool act;
+ bool waitting;
+} info_cgact_wait_t;
+extern info_cgact_wait_t cgact_wait;
+
static void *readerLoop(void *arg)
{
UNUSED(arg);
@@ -638,6 +646,10 @@
if(strStartsWith(line, "MBTK_AT_READY")) {
//handleUnsolicited(line);
continue;
+ } else if(strStartsWith(line, "CONNECT")) {
+ if(cgact_wait.waitting && cgact_wait.act) {
+ cgact_wait.waitting = false;
+ }
}
if(isSMSUnsolicited(line))
@@ -835,7 +847,7 @@
pthread_attr_init (&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- ret = pthread_create(&s_tid_reader, &attr, readerLoop, NULL);
+ ret = pthread_create(&s_tid_reader, &attr, readerLoop, &attr);
if (ret < 0)
{
LOGE("AT thread create fail.");
@@ -843,7 +855,7 @@
}
pthread_t uart_tid_reader;
- ret = pthread_create(&uart_tid_reader, &attr, readerUrcLoop, NULL);
+ ret = pthread_create(&uart_tid_reader, &attr, readerUrcLoop, &attr);
if (ret < 0)
{
LOGE("Uart thread create fail.");
diff --git a/mbtk/test/libmbtk_ecall/mbtk_ecall_test_v1.c b/mbtk/test/libmbtk_ecall/mbtk_ecall_test_v1.c
index 0f18108..d6b2b32 100755
--- a/mbtk/test/libmbtk_ecall/mbtk_ecall_test_v1.c
+++ b/mbtk/test/libmbtk_ecall/mbtk_ecall_test_v1.c
@@ -115,6 +115,7 @@
while(1)
{
memset(cmd, 0, sizeof(cmd));
+ int err;
if(fgets(cmd, sizeof(cmd), stdin))
{
char *ptr = cmd + strlen(cmd) - 1;
@@ -122,8 +123,219 @@
{
*ptr-- = '\0';
}
-
- if(!strcasecmp(cmd, "h") || !strcasecmp(cmd, "help")) {
+
+ if(!strncasecmp(cmd, "msdcfg", 6)) // msdcfg <item> <value>
+ {
+ mbtk_ecall_msd_cfg_info_t cfg;
+ memset(&cfg, 0, sizeof(mbtk_ecall_msd_cfg_info_t));
+ int item;
+ int count = sscanf(cmd, "msdcfg %d %s", &item, cfg.data);
+ if(count == 2 && strlen(cfg.data) > 0) {
+ cfg.item_type = (mbtk_ecall_msd_item_enum)item;
+ err = mbtk_ecall_msd_item_set(info_handle, &cfg);
+ if(err) {
+ printf("Error : %d\n", err);
+ } else {
+ printf("MSD item set success\n");
+ }
+ }
+ }
+ else if(!strncasecmp(cmd, "msdgen", 6)){
+ err = mbtk_ecall_msd_gen(info_handle);
+ if(err) {
+ printf("Error : %d\n", err);
+ } else {
+ printf("MSD gen success\n");
+ }
+ } else if(!strncasecmp(cmd, "msdpush", 7)){
+ err = mbtk_ecall_push(info_handle);
+ if(err) {
+ printf("Error : %d\n", err);
+ } else {
+ printf("MSD PUSH success\n");
+ }
+ } else if(!strncasecmp(cmd, "msd", 3)){ // msd <MSD>
+ uint8 msd[500] = {0};
+ if(!strcasecmp(cmd, "msd")) { // Get
+ err = mbtk_ecall_msd_get(info_handle, msd);
+ if(err) {
+ printf("Error : %d\n", err);
+ } else {
+ printf("MSD : %s\n", msd);
+ }
+ } else { // Set
+ int count = sscanf(cmd, "msd %s", msd);
+ if(count == 1 && strlen(msd) > 0) { // set
+ err = mbtk_ecall_msd_set(info_handle, msd);
+ if(err) {
+ printf("Error : %d\n", err);
+ } else {
+ printf("MSD set success\n");
+ }
+ }
+ }
+ } else if(!strncasecmp(cmd, "only", 4)){ // only <0-5> <test_num> <reconfig_num>
+ mbtk_ecall_only_info_t only_info;
+ if(strcasecmp(cmd, "only") == 0) { // Get
+ memset(&only_info, 0, sizeof(mbtk_ecall_only_info_t));
+ err = mbtk_ecall_only_get(info_handle, &only_info);
+ if(err) {
+ printf("Error : %d\n", err);
+ } else {
+ printf("Only : active-%d,sim_type-%d,test_num-%s,reconfig_num-%s\n", only_info.active, only_info.sim_type, only_info.test_num, only_info.reconfig_num);
+ }
+ } else { // Set
+ memset(&only_info, 0, sizeof(mbtk_ecall_only_info_t));
+ int tmp_int = -1;
+ int count = sscanf(cmd, "only %d %s %s", &tmp_int, only_info.test_num, only_info.reconfig_num);
+ if(count > 0 && tmp_int >= 0) { // set
+ only_info.active = (mbtk_ecall_only_type_enum)tmp_int;
+ err = mbtk_ecall_only_set(info_handle, &only_info);
+ if(err) {
+ printf("Error : %d\n", err);
+ } else {
+ printf("MSD set success\n");
+ }
+ }
+ }
+ } else if(!strncasecmp(cmd, "dial", 4)){ // dial <0-5>
+ mbtk_ecall_dial_type_enum type;
+ if(!strcasecmp(cmd, "dial")) { // Get
+ err = mbtk_ecall_dial_state_get(info_handle, &type);
+ if(err) {
+ printf("Error : %d\n", err);
+ } else {
+ printf("Type : %d\n", type);
+ }
+ } else { // Set
+ int reset;
+ int count = sscanf(cmd, "dial %d", &reset);
+ if(count == 1) {
+ err = mbtk_ecall_dial_start(info_handle, (mbtk_ecall_dial_type_enum)reset);
+ if(err) {
+ printf("Error : %d\n", err);
+ } else {
+ printf("Start ecall dial success\n");
+ }
+ }
+ }
+ } else if(!strncasecmp(cmd, "reg", 3)){ // reg <0/1>
+ if(!strcasecmp(cmd, "reg 0")) {
+ err = mbtk_ecall_reg_set(info_handle, 0);
+ if(err) {
+ printf("Error : %d\n", err);
+ } else {
+ printf("Set net reg 0\n");
+ }
+ } else if(!strcasecmp(cmd, "reg 1")) {
+ err = mbtk_ecall_reg_set(info_handle, 1);
+ if(err) {
+ printf("Error : %d\n", err);
+ } else {
+ printf("Set net reg 1\n");
+ }
+ }
+ } else if(!strncasecmp(cmd, "mode", 4)){ // mode EU/ERA
+ if(!strcasecmp(cmd, "mode")) {
+ mbtk_ecall_mode_type_enum mode;
+ err = mbtk_ecall_mode_get(info_handle, &mode);
+ if(err) {
+ printf("Error : %d\n", err);
+ } else {
+ printf("Ecall mode[%d] : %s\n", mode, mode == MBTK_ECALL_MODE_TYPE_EU ? "EU" : "ERA");
+ }
+ } else if(!strcasecmp(cmd, "mode EU")) {
+ err = mbtk_ecall_mode_set(info_handle, MBTK_ECALL_MODE_TYPE_EU);
+ if(err) {
+ printf("Error : %d\n", err);
+ } else {
+ printf("Set mode EU\n");
+ }
+ } else if(!strcasecmp(cmd, "mode ERA")) {
+ err = mbtk_ecall_mode_set(info_handle, MBTK_ECALL_MODE_TYPE_ERA);
+ if(err) {
+ printf("Error : %d\n", err);
+ } else {
+ printf("Set mode ERA\n");
+ }
+ }
+ } else if(!strncasecmp(cmd, "cfg", 3)){ // cfg <type> <value>
+ int tmp1 = -1, tmp2 = -1;
+ int count = sscanf(cmd, "cfg %d %d", &tmp1, &tmp2);
+ mbtk_ecall_cfg_info_t cfg;
+ if(count == 1 && tmp1 >= 0) { // Get
+ memset(&cfg, 0, sizeof(cfg));
+ cfg.type = (mbtk_ecall_cfg_item_enum)tmp1;
+ err = mbtk_ecall_cfg_get(info_handle, &cfg);
+ if(err) {
+ printf("Error : %d\n", err);
+ } else {
+ printf("Ecall config[%d] is %d\n", cfg.type, cfg.data);
+ }
+ } else if(count == 2 && tmp1 >= 0 && tmp2 >= 0) { // Set
+ memset(&cfg, 0, sizeof(cfg));
+ cfg.type = (mbtk_ecall_cfg_item_enum)tmp1;
+ cfg.data = (uint32)tmp2;
+ err = mbtk_ecall_cfg_set(info_handle, &cfg);
+ if(err) {
+ printf("Error : %d\n", err);
+ } else {
+ printf("Set ecall config[%d] to %d success\n", cfg.type, cfg.data);
+ }
+ }
+ } else if(!strncasecmp(cmd, "sms_num", 7)){ // sms_num <number>
+ uint8 number[RIL_MAX_NUMBER_LEN] = {0};
+ if(!strcasecmp(cmd, "sms_num")) { // Get
+ err = mbtk_ecall_sms_number_get(info_handle, number);
+ if(err) {
+ printf("Error : %d\n", err);
+ } else {
+ printf("SMS number : %s\n", number);
+ }
+ } else { // Set
+ int count = sscanf(cmd, "sms_num %s", number);
+ if(count == 1 && strlen(number) > 0) {
+ err = mbtk_ecall_sms_number_set(info_handle, number);
+ if(err) {
+ printf("Error : %d\n", err);
+ } else {
+ printf("Set SMS number[%s] success\n", number);
+ }
+ }
+ }
+ } else if(!strncasecmp(cmd, "mute_spk", 8)){ // mute_spk <0/1>
+ if(!strcasecmp(cmd, "mute_spk 0")) {
+ err = mbtk_ecall_mute_spk_set(info_handle, 0);
+ if(err) {
+ printf("Error : %d\n", err);
+ } else {
+ printf("Set mute spk to 0\n");
+ }
+ } else if(!strcasecmp(cmd, "mute_spk 1")) {
+ err = mbtk_ecall_mute_spk_set(info_handle, 1);
+ if(err) {
+ printf("Error : %d\n", err);
+ } else {
+ printf("Set mute spk to 1\n");
+ }
+ }
+ } else if(!strncasecmp(cmd, "gain", 4)){ // gain <0/1/2> <gain>
+ int tmp1 = -1, tmp2 = -1;
+ int count = sscanf(cmd, "gain %d %d", &tmp1, &tmp2);
+ mbtk_ecall_gain_info_t gain;
+ if(count == 2 && tmp1 >= 0) { // Get
+ memset(&gain, 0, sizeof(gain));
+ gain.mode = (mbtk_ecall_gain_mode_enum)tmp1;
+ gain.gain = (int8)tmp2;
+ err = mbtk_ecall_dsp_gain_set(info_handle, &gain);
+ if(err) {
+ printf("Error : %d\n", err);
+ } else {
+ printf("Set DSP gain[%d] to %d\n", gain.mode, gain.gain);
+ }
+ }
+ }
+ else if(!strcasecmp(cmd, "h") || !strcasecmp(cmd, "help")) {
help();
} else if(!strcasecmp(cmd, "q")) {
break;