Add cell get/set API for V2.
Change-Id: I7a001cd0f091a199ef0f7583becead01c38e1777
diff --git a/mbtk/mbtk_rild_v2/src/ril_net.c b/mbtk/mbtk_rild_v2/src/ril_net.c
index 3f02965..6e0cd8c 100755
--- a/mbtk/mbtk_rild_v2/src/ril_net.c
+++ b/mbtk/mbtk_rild_v2/src/ril_net.c
@@ -20,6 +20,8 @@
#include "ril_info.h"
#include "mbtk_str.h"
+mbtk_cell_pack_info_t cell_info;
+
extern ril_band_info_t band_info;
void ril_rsp_pack_send(int fd, int ril_id, int msg_index, const void* data, int data_len);
static int req_apn_get(mbtk_apn_info_array_t *apns, int *cme_err);
@@ -1125,6 +1127,354 @@
}
/*
+AT+EEMOPT=1
+OK
+
+// LTE
+AT+EEMGINFO?
+// <mcc>, <length of mnc>, <mnc>, <tac>, <PCI>, <dlEuarfcn>, < ulEuarfcn >, <band>, <dlBandwidth>,
+// <rsrp>,<rsrq>, <sinr>,
+// errcModeState,emmState,serviceState,IsSingleEmmRejectCause,EMMRejectCause,mmeGroupId,mmeCode,mTmsi,
+// cellId,subFrameAssignType,specialSubframePatterns,transMode
+// mainRsrp,diversityRsrp,mainRsrq,diversityRsrq,rssi,cqi,pathLoss,tb0DlTpt,tb1DlTpt,tb0DlPeakTpt,tb1DlPeakTpt,tb0UlPeakTpt,
+// tb1UlPeakTpt,dlThroughPut,dlPeakThroughPut,averDlPRB,averCQITb0,averCQITb1,rankIndex,grantTotal,ulThroughPut,ulPeakThroughPut,currPuschTxPower,averUlPRB,
+// dlBer, ulBer,
+// diversitySinr, diversityRssi
++EEMLTESVC: 1120, 2, 0, 33584, 430, 40936, 40936, 41, 20,
+0, 0, 0,
+1, 10, 0, 1, 0, 1059, 78, 3959566565,
+105149248, 2, 7, 7,
+0, 0, 0, 0, 0, 0, 0, 1190919, 0, 0, 0, 16779777,
+0, 5112867, 3959566565, 2, 0, 0, 0, 0, 0, 0, 0, 0,
+0, 0,
+7, 44
+
+// index,phyCellId,euArfcn,rsrp,rsrq
++EEMLTEINTER: 0, 65535, 38950, 0, 0
+
++EEMLTEINTER: 1, 0, 0, 0, 0
+
++EEMLTEINTER: 2, 0, 4294967295, 255, 255
+
++EEMLTEINTER: 3, 65535, 1300, 0, 0
+
++EEMLTEINTER: 4, 0, 0, 0, 0
+
++EEMLTEINTER: 5, 0, 4294967295, 247, 0
+
++EEMLTEINTER: 6, 197, 41332, 24, 9
+
++EEMLTEINTER: 7, 0, 0, 0, 0
+
++EEMLTEINTER: 8, 0, 0, 0, 0
+
++EEMLTEINTRA: 0, 429, 40936, 56, 12
+
++EEMLTEINTERRAT: 0,0
+
++EEMLTEINTERRAT: 1,0
+
++EEMGINFO: 3, 2 // <state>:
+ // 0: ME in Idle mode
+ // 1: ME in Dedicated mode
+ // 2: ME in PS PTM mode
+ // 3: invalid state
+ // <nw_type>:
+ // 0: GSM 1: UMTS 2: LTE
+
+OK
+
+// WCDMA
+AT+EEMGINFO?
+// Mode, sCMeasPresent, sCParamPresent, ueOpStatusPresent,
+
+// if sCMeasPresent == 1
+// cpichRSCP, utraRssi, cpichEcN0, sQual, sRxLev, txPower,
+// endif
+
+// if sCParamPresent == 1
+// rac, nom, mcc, mnc_len, mnc, lac, ci,
+// uraId, psc, arfcn, t3212, t3312, hcsUsed, attDetAllowed,
+// csDrxCycleLen, psDrxCycleLen, utranDrxCycleLen, HSDPASupport, HSUPASupport,
+// endif
+
+// if ueOpStatusPresent == 1
+// rrcState, numLinks, srncId, sRnti,
+// algPresent, cipherAlg, cipherOn, algPresent, cipherAlg, cipherOn,
+// HSDPAActive, HSUPAActive, MccLastRegisteredNetwork, MncLastRegisteredNetwork, TMSI, PTMSI, IsSingleMmRejectCause, IsSingleGmmRejectCause,
+// MMRejectCause, GMMRejectCause, mmState, gmmState, gprsReadyState, readyTimerValueInSecs, NumActivePDPContext, ULThroughput, DLThroughput,
+// serviceStatus, pmmState, LAU_status, LAU_count, RAU_status, RAU_count
+// endif
+//
++EEMUMTSSVC: 3, 1, 1, 1,
+-80, 27, -6, -18, -115, -32768,
+1, 1, 1120, 2, 1, 61697, 168432821,
+15, 24, 10763, 0, 0, 0, 0,
+128, 128, 65535, 0, 0,
+2, 255, 65535, 4294967295,
+0, 0, 0, 0, 0, 0,
+0, 0, 0, 0, 0, 0, 1, 1,
+28672, 28672, 0, 0, 0, 0, 0, 0, 0,
+0, 0, 0, 0, 0, 0
+
+// index, cpichRSCP, utraRssi, cpichEcN0, sQual, sRxLev ,mcc, mnc, lac, ci, arfcn, psc
++EEMUMTSINTRA: 0, -32768, -1, -32768, -18, -115, 0, 0, 65534, 1, 10763, 32
+
++EEMUMTSINTRA: 1, -1, -32768, -18, -115, 0, 0, 65534, 2, 10763, 40, 32768
+
++EEMUMTSINTRA: 2, -32768, -18, -115, 0, 0, 65534, 3, 10763, 278, 32768, 65535
+
++EEMUMTSINTRA: 3, -18, -115, 0, 0, -2, 4, 10763, 28, 32768, 65535, 32768
+
++EEMUMTSINTRA: 4, -115, 0, 0, -2, 5, 10763, 270, 32768, 65535, 32768, 65518
+
++EEMUMTSINTRA: 5, 0, 0, -2, 6, 10763, 286, 32768, 65535, 32768, 65518, 65421
+
++EEMUMTSINTRA: 6, 0, -2, 7, 10763, 80, 32768, 65535, 32768, 65518, 65421, 0
+
++EEMUMTSINTRA: 7, -2, 8, 10763, 206, -32768, 65535, 32768, 65518, 65421, 0, 0
+
++EEMUMTSINTRA: 8, 9, 10763, 11, -32768, -1, 32768, 65518, 65421, 0, 0, 65534
+
++EEMUMTSINTRA: 9, 10763, 19, -32768, -1, -32768, 65518, 65421, 0, 0, 65534, 11
+
++EEMUMTSINTRA: 10, 232, -32768, -1, -32768, -18, 65421, 0, 0, 65534, 12, 10763
+
++EEMUMTSINTRA: 11, -32768, -1, -32768, -18, -115, 0, 0, 65534, 13, 10763, 66
+
++EEMUMTSINTRA: 12, -1, -32768, -18, -115, 0, 0, 65534, 14, 10763, 216, 32768
+
++EEMUMTSINTRA: 13, -32768, -18, -115, 0, 0, 65534, 15, 10763, 183, 32768, 65535
+
++EEMUMTSINTRA: 14, -18, -115, 0, 0, -2, 16, 10763, 165, 32768, 65535, 32768
+
++EEMUMTSINTRA: 15, -115, 0, 0, -2, 17, 10763, 151, 32768, 65535, 32768, 65518
+
++EEMUMTSINTRA: 16, 0, 0, -2, 18, 10763, 43, 32768, 65535, 32768, 65518, 65421
+
++EEMUMTSINTRA: 17, 0, -2, 19, 10763, 72, 32768, 65535, 32768, 65518, 65421, 0
+
++EEMUMTSINTRA: 18, -2, 20, 10763, 157, -32768, 65535, 32768, 65518, 65421, 0, 0
+
++EEMUMTSINTRA: 19, 21, 10763, 165, -32768, -1, 32768, 65518, 65421, 0, 0, 65534
+
++EEMUMTSINTRA: 20, 10763, 301, -32768, -1, -32768, 65518, 65421, 0, 0, 65534, 23
+
++EEMUMTSINTRA: 21, 23, -32768, -1, -32768, -18, 65421, 0, 0, 65534, 24, 10763
+
++EEMUMTSINTRA: 22, -32768, -1, -32768, -18, -115, 0, 0, 65534, 25, 10763, 0
+
++EEMUMTSINTRA: 23, -1, -32768, -18, -115, 0, 0, 65534, 26, 10763, 167, 32768
+
++EEMUMTSINTRA: 24, -32768, -18, -115, 0, 0, 65534, 27, 10763, 34, 32768, 65535
+
++EEMUMTSINTRA: 25, -18, -115, 0, 0, -2, 28, 10763, 313, 32768, 65535, 32768
+
++EEMUMTSINTRA: 26, -115, 0, 0, -2, 29, 10763, 152, 32768, 65535, 32768, 65518
+
++EEMUMTSINTRA: 27, 0, 0, -2, 30, 10763, 239, 0, 0, 0, 0, 0
+
++EEMUMTSINTRA: 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+
++EEMUMTSINTRA: 29, 0, 0, 0, 0, -115, 0, 0, 65534, 30, 10763, 239
+
+// index,gsmRssi,rxLev,C1,C2,mcc,mnc,lac,ci,arfcn,bsic
++EEMUMTSINTERRAT: 0, -32768, -107, -1, -1, 0, 0, 65534, 0, 117, 36
+
++EEMUMTSINTERRAT: 1, -107, -1, -1, 0, 0, 65534, 1, 72, 49, 0
+
++EEMUMTSINTERRAT: 2, -1, -1, 0, 0, 65534, 2, 119, 15, 32768, 149
+
++EEMUMTSINTERRAT: 3, -1, 0, 0, -2, 3, 121, 23, 0, 0, 0
+
++EEMGINFO: 3, 1
+
+OK
+
+
+// GSM
+AT+EEMGINFO?
++EEMGINFOBASIC: 2
+
+// mcc, mnc_len, mnc, lac, ci, nom, nco,
+// bsic, C1, C2, TA, TxPwr,
+// RxSig, RxSigFull, RxSigSub, RxQualFull, RxQualSub,
+// ARFCB_tch, hopping_chnl, chnl_type, TS, PacketIdle, rac, arfcn,
+// bs_pa_mfrms, C31, C32, t3212, t3312, pbcch_support, EDGE_support,
+// ncc_permitted, rl_timeout, ho_count, ho_succ, chnl_access_count, chnl_access_succ_count,
+// gsmBand,channelMode
++EEMGINFOSVC: 1120, 2, 0, 32784, 24741, 2, 0,
+63, 36, 146, 1, 7,
+46, 42, 42, 7, 0,
+53, 0, 8, 0, 1, 6, 53,
+2, 0, 146, 42, 54, 0, 1,
+1, 32, 0, 0, 0, 0,
+0, 0
+
+// PS_attached, attach_type, service_type, tx_power, c_value,
+// ul_ts, dl_ts, ul_cs, dl_cs, ul_modulation, dl_modulation,
+// gmsk_cv_bep, 8psk_cv_bep, gmsk_mean_bep, 8psk_mean_bep, EDGE_bep_period, single_gmm_rej_cause
+// pdp_active_num, mac_mode, network_control, network_mode, EDGE_slq_measurement_mode, edge_status
++EEMGINFOPS: 1, 255, 0, 0, 0,
+0, 0, 268435501, 1, 0, 0,
+4, 0, 96, 0, 0, 0,
+0, 0, 0, 65535, 0, 13350
+
++EEMGINFO: 0, 0
+
+OK
+
+*/
+static int req_cell_info_get(int *cme_err)
+{
+ ATResponse *response = NULL;
+ int tmp_int;
+ int buff_size = 0;
+ // AT+EEMOPT=1 in the first.
+ int err = at_send_command("AT+EEMOPT=1", &response);
+ if (err < 0 || response->success == 0){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+ // Reset buffer in the first.
+ memset(&cell_info, 0xFF, sizeof(mbtK_cell_pack_info_t));
+ cell_info.running = true;
+ cell_info.cell_list.num = 0;
+
+ err = at_send_command_singleline("AT+EEMGINFO?", "+EEMGINFO:", &response);
+ if (err < 0 || response->success == 0 || !response->p_intermediates){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+ // Now, cell infomation has get from URC message.
+
+ 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;
+ }
+ err = at_tok_nextint(&line, &tmp_int);
+ if (err < 0)
+ {
+ goto exit;
+ }
+
+ cell_info.cell_list.type = (uint8)tmp_int;
+ cell_info.running = false;
+
+#if 0
+ while(lines_ptr)
+ {
+ // LTE
+ if(strStartsWith(line, "+EEMLTESVC:")) // LTE Server Cell
+ {
+
+ }
+ else if(strStartsWith(line, "+EEMLTEINTER:")) // LTE
+ {
+
+ }
+ else if(strStartsWith(line, "+EEMLTEINTRA:")) // LTE
+ {
+
+ }
+ else if(strStartsWith(line, "+EEMLTEINTERRAT:")) // LTE
+ {
+
+ }
+ else if(strStartsWith(line, "+EEMGINFO:")) // <state>: 0: ME in Idle mode 1: ME in Dedicated mode 2: ME in PS PTM mode 3: invalid state
+ // <nw_type>: 0: GSM 1: UMTS 2: LTE
+ {
+
+ }
+ // WCDMA
+ else if(strStartsWith(line, "+EEMUMTSSVC:")) // WCDMA Server Cell
+ {
+
+ }
+ else if(strStartsWith(line, "+EEMUMTSINTRA:")) // WCDMA
+ {
+
+ }
+ else if(strStartsWith(line, "+EEMUMTSINTERRAT:")) // WCDMA
+ {
+
+ }
+ // GSM
+ else if(strStartsWith(line, "+EEMGINFOBASIC:")) // Basic information in GSM
+ // 0: ME in Idle mode 1: ME in Dedicated mode 2: ME in PS PTM mode
+ {
+
+ }
+ else if(strStartsWith(line, "+EEMGINFOSVC:")) // GSM Server Cell
+ {
+
+ }
+ else if(strStartsWith(line, "+EEMGINFOPS:")) // PS
+ {
+
+ }
+
+
+ lines_ptr = lines_ptr->p_next;
+ }
+#endif
+
+exit:
+ at_response_free(response);
+ return buff_size;
+}
+
+static int req_cell_info_set(const char *cmgl, char *reg, int len, int *cme_err)
+{
+ ATResponse *response = NULL;
+ char cmd[30] = {0};
+ char data[218] = {0};
+ int err = 0;
+
+ memcpy(data, cmgl, len);
+
+ sprintf(cmd, "AT*CELL=%s", data);
+
+ if(strlen(cmd) > 0)
+ {
+ err = at_send_command_multiline(cmd, "", &response);
+ if (err < 0 || response->success == 0 || !response->p_intermediates){
+ *cme_err = at_get_cme_error(response);
+ goto exit;
+ }
+
+ ATLine* lines_ptr = response->p_intermediates;
+ char *line = NULL;
+ int reg_len = 0;
+ bool flag = false;
+ while(lines_ptr)
+ {
+ line = lines_ptr->line;
+ if(line ==NULL)
+ {
+ LOGD("line is null----------------------");
+ }
+ lines_ptr = lines_ptr->p_next;
+ }
+ }
+ err = 0;
+ memcpy(reg, "req_cell_info_set succss", strlen("req_cell_info_set succss"));
+exit:
+ at_response_free(response);
+ return err;
+}
+
+
+/*
AT+CGDCONT?
+CGDCONT: 1,"IPV4V6","ctnet","10.142.64.116 254.128.0.0.0.0.0.0.0.0.0.0.0.0.0.1",0,0,0,2,0,0
@@ -1696,28 +2046,40 @@
}
case RIL_MSG_ID_NET_CELL:
{
- if(pack->data_len == 0 || pack->data == NULL)
+ if(pack->data_len == 0 || pack->data == NULL) // Get net cell.
{
- mbtk_net_info_array_t net_array;
- memset(&net_array, 0, sizeof(mbtk_net_info_array_t));
- if(req_available_net_get(&net_array, &cme_err) || cme_err != MBTK_RIL_ERR_CME_NON)
+ if(req_cell_info_get(&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;
}
- LOGD("Get Available Net fail.");
+ LOG("Get net cell fail.");
}
else
{
- ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &net_array, sizeof(mbtk_net_info_array_t));
+ LOG("req_cell_info_get() success,cell number: %d", cell_info.cell_list.num);
+ ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, &cell_info.cell_list, sizeof(mbtk_cell_info_array_t));
}
}
- else // Set
+ else // Lock cell
{
- err = MBTK_RIL_ERR_UNSUPPORTED;
- LOGW("Unsupport set available net.");
+ char *mem = (char*)(pack->data);
+ int len = pack->data_len;
+ char reg[100] = {0};
+ if(req_cell_info_set(mem, reg, len, &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;
+ }
+ }
+ else
+ {
+ ril_rsp_pack_send(cli_info->fd, pack->msg_id, pack->msg_index, reg, strlen(reg));
+ }
}
break;
}