add mbtk_fplmn_set/get to modify fplmn list for GSW
Change-Id: I2b81ce7ca355a0acfd85f87082511bcdc0cb9c91
diff --git a/mbtk/mbtk_rild/src/mbtk_info_server.c b/mbtk/mbtk_rild/src/mbtk_info_server.c
index 5dbf8c0..365215d 100644
--- a/mbtk/mbtk_rild/src/mbtk_info_server.c
+++ b/mbtk/mbtk_rild/src/mbtk_info_server.c
@@ -1322,6 +1322,81 @@
}
/*
+AT+CRSM=176,28539,0,0,0
++CRSM: 144,0,"64F00064F01064F02064F06064F07064F00264F051FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
+*/
+static int req_fplmn_get(char *req, int *cme_err)
+{
+ ATResponse *response = NULL;
+
+ int err = at_send_command_singleline("AT+CRSM=176,28539,0,0,0", "", &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;
+ LOG("req_fplmn_get() ---line = %s\n", line);
+ char *ptr = strstr(line, "+CRSM: 144,0,");
+ LOG("req_fplmn_get() ---ptr = %s\n", ptr+strlen("+CRSM: 144,0,"));
+
+ if(ptr)
+ {
+ char* start = strchr(ptr, '"') + 1;
+ char* end = strrchr(ptr, '"') - 1;
+ LOG("start = %s\n end = %s",start,end);
+ size_t length = end - start + 1;
+
+ LOG("length = %d",length);
+ strncpy(req, start, length);
+ req[length] = '\0';
+
+ LOG("err:%d, req:%s\n", err, req);
+ err = 0;
+ }
+ else
+ {
+ err = -1;
+ }
+
+exit:
+ at_response_free(response);
+ return err;
+}
+
+
+/*
+AT+CRSM=214,28539,0,0,0,64F00064F01064F02064F06064F07064F00264F051FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+OK
+*/
+
+static int req_fplmn_set(char *req, char *reg, int *cme_err)
+{
+ ATResponse *response = NULL;
+ char cmd[256] = {0};
+ LOG("req_fplmn_set() ---cmd = %s\n", req);
+ sprintf(cmd, "AT+CRSM=214,28539,0,0,0,%s", req);
+ LOG("req_fplmn_set() ---cmd = %s\n", cmd);
+
+ int err = at_send_command_singleline(cmd, "+CRSM: 144,0",&response);
+ LOG("err:%d, response:%d", err, response->success);
+
+ if (err < 0 || response->success == 0){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+exit:
+ at_response_free(response);
+ return err;
+}
+
+
+
+
+
+/*
AT+ACONFIG="IMSD=1"
or
AT+ACONFIG="IMSD=0"
@@ -5809,6 +5884,56 @@
}
break;
}
+ case MBTK_INFO_ID_NET_FPLMN_REQ:
+ {
+ LOG("MBTK_INFO_ID_NET_FPLMN_REQ in\n");
+ if(pack->data_len == 0 || pack->data == NULL) //Get
+ {
+ char fplmn[256] = {0};
+ LOG("fplmn_test");
+ if(req_fplmn_get(fplmn, &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("Get FPLMN fail.");
+ printf("get fplmn fail\n");
+ }
+ else
+ {
+ printf("get fplmn success\n");
+ LOGE("Get FPLMN success.");
+ pack_rsp_send(cli_info->fd, MBTK_INFO_ID_NET_FPLMN_RSP, fplmn, strlen(fplmn));
+ }
+ }
+ else //set
+ {
+ char *fplmn_temp = (char *)pack->data;
+ char fplmn[128] = {0};
+ int data_len = pack->data_len;
+ char reg[50] = {0};
+ memcpy(fplmn, fplmn_temp, data_len);
+ LOG("fplmn_test_set ,fplmn_temp = %s,len = %d\n",fplmn_temp,data_len);
+ LOG("fplmn_test_set ,fplmn = %s, len = %d\n",fplmn,strlen(fplmn));
+ if(req_fplmn_set(fplmn,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("req_fplmn_set fail.");
+ }
+ else
+ {
+ LOG("req_fplmn_set success.,reg:%s",reg);
+ pack_rsp_send(cli_info->fd, MBTK_INFO_ID_NET_FPLMN_RSP, NULL, 0);
+ }
+ }
+ break;
+ }
case MBTK_INFO_ID_WAKEUP_STA_REQ:
{
if(pack->data_len == 0 || pack->data == NULL)