Add powerind set API.
Change-Id: Ie4e0b2f677e15ff7f78c3f679ae27d21d0c5fe0e
diff --git a/mbtk/include/mbtk/mbtk_ril_api.h b/mbtk/include/mbtk/mbtk_ril_api.h
index f4c3c59..43b2877 100755
--- a/mbtk/include/mbtk/mbtk_ril_api.h
+++ b/mbtk/include/mbtk/mbtk_ril_api.h
@@ -998,6 +998,16 @@
mbtk_ril_err_enum mbtk_oos_set(mbtk_ril_handle* handle, const mbtk_ril_oos_info_t *oos_info);
/*
+* Set wakeup state.
+*
+* wakeup_state:(0~31)
+* 0 : means resume all
+* 1~31 means suspend
+* Control the active reporting of some platform modems to reduce wakeup
+*/
+mbtk_ril_err_enum mbtk_wakeup_state_set(mbtk_ril_handle* handle, int wakeup_state);
+
+/*
* Get current APN informations.
*/
mbtk_ril_err_enum mbtk_apn_get(mbtk_ril_handle* handle, mbtk_apn_info_array_t *apns);
diff --git a/mbtk/libmbtk_lib/ril/inc/mbtk_ril.h b/mbtk/libmbtk_lib/ril/inc/mbtk_ril.h
index add0fdc..efd67fc 100755
--- a/mbtk/libmbtk_lib/ril/inc/mbtk_ril.h
+++ b/mbtk/libmbtk_lib/ril/inc/mbtk_ril.h
@@ -54,6 +54,8 @@
RIL_MSG_ID_DEV_CELL_TIME, // Time
// <uint8><uint8>
RIL_MSG_ID_DEV_MODEM,
+ // <uint8>
+ RIL_MSG_ID_DEV_POWERIND,
RIL_MSG_ID_DEV_END,
diff --git a/mbtk/libmbtk_lib/ril/v2/mbtk_ril_api.c b/mbtk/libmbtk_lib/ril/v2/mbtk_ril_api.c
index 1b04cd8..8a37ce4 100755
--- a/mbtk/libmbtk_lib/ril/v2/mbtk_ril_api.c
+++ b/mbtk/libmbtk_lib/ril/v2/mbtk_ril_api.c
@@ -1503,6 +1503,34 @@
return ril_req_process(port_info->port, RIL_MSG_ID_NET_OOS, oos_info, sizeof(mbtk_ril_oos_info_t), NULL, FALSE);
}
+/*
+* Set wakeup state.
+*
+* wakeup_state:(0~31)
+* 0 : means resume all
+* 1~31 means suspend
+* Control the active reporting of some platform modems to reduce wakeup
+*/
+mbtk_ril_err_enum mbtk_wakeup_state_set(mbtk_ril_handle* handle, int wakeup_state)
+{
+ if(!ril_cli.ril_ready)
+ {
+ return MBTK_RIL_ERR_NOT_INIT;
+ }
+
+ if(wakeup_state < 0 || wakeup_state > 31)
+ {
+ LOGE("ARG error.");
+ return MBTK_RIL_ERR_PARAMETER;
+ }
+
+ ril_at_port_info_t *port_info = (ril_at_port_info_t*)handle;
+ if(!at_port_check(port_info->port)) {
+ return MBTK_RIL_ERR_PORT;
+ }
+
+ return ril_req_process(port_info->port, RIL_MSG_ID_DEV_POWERIND, &wakeup_state, sizeof(uint8), NULL, FALSE);
+}
/*
* Get all APN informations.
diff --git a/mbtk/libmbtk_lib/ril/v2/ril_utils.c b/mbtk/libmbtk_lib/ril/v2/ril_utils.c
index d6ce141..b3f3fdd 100755
--- a/mbtk/libmbtk_lib/ril/v2/ril_utils.c
+++ b/mbtk/libmbtk_lib/ril/v2/ril_utils.c
@@ -223,7 +223,8 @@
return "CELL_TIME";
case RIL_MSG_ID_DEV_MODEM:
return "MODEM";
-
+ case RIL_MSG_ID_DEV_POWERIND:
+ return "POWERIND";
// Sim Information
// <uint8> 0:NOT_EXIST 1:READY ...
diff --git a/mbtk/mbtk_rild_v2/src/ril_dev.c b/mbtk/mbtk_rild_v2/src/ril_dev.c
index d2d8c9f..fc70b70 100755
--- a/mbtk/mbtk_rild_v2/src/ril_dev.c
+++ b/mbtk/mbtk_rild_v2/src/ril_dev.c
@@ -431,6 +431,47 @@
return ret;
}
+/*
+AT*POWERIND=0"
+or
+AT*POWERIND=1~31"
+
+OK
+
+AT*POWERIND=31£¬¾ÍÏ൱ÓÚÉèÖÃNETWORK¡¢SIM¡¢SMS¡¢CS CALL¡¢PS DATA±ä»¯Ê±¶¼²»Ö÷¶¯Éϱ¨£¬
+ÆäÖÐPS DATAĿǰÔÝʱ²»Ö§³Ö£¬Ö»ÊDZ£ÁôÁËÕâ¸ö±ê־λ,0 means resume all.
+
+AP power state: 1~31 means suspend,
+bitmap:
+bit0 - NETWORK;
+bit1 - SIM;
+bit2 - SMS;
+bit3 - CS CALL
+bit4 - PS DATA
+
+*/
+static int req_powerind_set(ATPortType_enum port, uint8 state, int *cme_err)
+{
+ ATResponse *response = NULL;
+ int err = -1;
+
+ if (state >= 0 && state < 32)
+ {
+ char cmd[100] = {0};
+ sprintf(cmd, "AT*POWERIND=%d", state);
+ LOG("Set the powerind command is = [%s]\n", cmd);
+ int err = at_send_command(port, 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.
@@ -689,6 +730,33 @@
}
break;
}
+ case RIL_MSG_ID_DEV_POWERIND:
+ {
+ if(pack->data_len == 0 || pack->data == NULL)
+ {
+ err = MBTK_RIL_ERR_UNSUPPORTED;
+ LOG("Get POWERIND state UNSUPPORTED.");
+ }
+ else // Set powerind state.
+ {
+ uint8 state = *(pack->data);
+ if(req_powerind_set(cli_info->port, state, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+ {
+ if(cme_err != MBTK_RIL_ERR_CME_NON) {
+ err = MBTK_RIL_ERR_CME + cme_err;
+ } else {
+ err = MBTK_RIL_ERR_UNKNOWN;
+ }
+ LOG("Set POWERIND state fail.");
+ }
+ else
+ {
+ // pack_rsp_send(cli_info->fd, MBTK_INFO_ID_WAKEUP_STA_RSP, NULL, 0);
+ ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, NULL, 0);
+ }
+ }
+ break;
+ }
default:
{
err = MBTK_RIL_ERR_REQ_UNKNOWN;