Add RIL 5G support.
Change-Id: I06020103aad9a5f1975b49fbe494cbecbfac4b7f
diff --git a/mbtk/mbtk_rild_v2/src/ril_net.c b/mbtk/mbtk_rild_v2/src/ril_net.c
index 3c0ee24..649fd72 100755
--- a/mbtk/mbtk_rild_v2/src/ril_net.c
+++ b/mbtk/mbtk_rild_v2/src/ril_net.c
@@ -25,6 +25,19 @@
extern ril_band_info_t band_info;
void ril_rsp_pack_send(ATPortType_enum port, int fd, int ril_id, int msg_index, const void* data, int data_len);
+static bool net_support_check(uint32 net_type, uint32 net_flag)
+{
+#ifdef MBTK_DEV_INFO_VERSION_2
+ return (net_type & net_flag);
+#else
+ if(net_flag == MBTK_NET_SUPPORT_5G) {
+ return FALSE;
+ } else {
+ return TRUE;
+ }
+#endif
+}
+
/*
AT+COPS=?
@@ -260,45 +273,48 @@
if(band->gsm_band == 0 && band->umts_band == 0
&& band->tdlte_band == 0 && band->fddlte_band == 0 && band->lte_ext_band == 0
-#ifdef MBTK_DEV_INFO_VERSION_2
&& band->nr_3_band == 0 && band->nr_2_band == 0
&& band->nr_1_band == 0 && band->nr_0_band == 0
-#endif
) {
sprintf(cmd, "AT*BAND=%d", band->net_pref);
} else {
log_hex("BAND_SUPPORT", &band_info.band_support, sizeof(mbtk_band_info_t));
log_hex("BAND", band, sizeof(mbtk_band_info_t));
- if(band->gsm_band == 0) {
+ if(band->gsm_band == 0 && net_support_check(band_info.net_support, MBTK_NET_SUPPORT_2G)) {
band->gsm_band = band_info.band_support.gsm_band;
}
- if(band->umts_band == 0) {
+ if(band->umts_band == 0 && net_support_check(band_info.net_support, MBTK_NET_SUPPORT_3G)) {
band->umts_band = band_info.band_support.umts_band;
}
- if(band->tdlte_band == 0) {
- band->tdlte_band = band_info.band_support.tdlte_band;
+
+ if(net_support_check(band_info.net_support, MBTK_NET_SUPPORT_4G)) {
+ if(band->tdlte_band == 0) {
+ band->tdlte_band = band_info.band_support.tdlte_band;
+ }
+ if(band->fddlte_band == 0) {
+ band->fddlte_band = band_info.band_support.fddlte_band;
+ }
+ if(band->lte_ext_band == 0) {
+ band->lte_ext_band = band_info.band_support.lte_ext_band;
+ }
}
- if(band->fddlte_band == 0) {
- band->fddlte_band = band_info.band_support.fddlte_band;
+
+ if(net_support_check(band_info.net_support, MBTK_NET_SUPPORT_5G)) {
+ if(band->nr_3_band == 0) {
+ band->nr_3_band = band_info.band_support.nr_3_band;
+ }
+ if(band->nr_2_band == 0) {
+ band->nr_2_band = band_info.band_support.nr_2_band;
+ }
+ if(band->nr_1_band == 0) {
+ band->nr_1_band = band_info.band_support.nr_1_band;
+ }
+ if(band->nr_0_band == 0) {
+ band->nr_0_band = band_info.band_support.nr_0_band;
+ }
}
- if(band->lte_ext_band == 0) {
- band->lte_ext_band = band_info.band_support.lte_ext_band;
- }
-#ifdef MBTK_DEV_INFO_VERSION_2
- if(band->nr_3_band == 0) {
- band->nr_3_band = band_info.band_support.nr_3_band;
- }
- if(band->nr_2_band == 0) {
- band->nr_2_band = band_info.band_support.nr_2_band;
- }
- if(band->nr_1_band == 0) {
- band->nr_1_band = band_info.band_support.nr_1_band;
- }
- if(band->nr_0_band == 0) {
- band->nr_0_band = band_info.band_support.nr_0_band;
- }
-#endif
+
if((band->gsm_band & band_info.band_support.gsm_band) != band->gsm_band) {
LOG("GSM band error.");
goto exit;
@@ -323,7 +339,6 @@
LOG("EXT_LTE band error.");
goto exit;
}
-#ifdef MBTK_DEV_INFO_VERSION_2
if((band->nr_3_band & band_info.band_support.nr_3_band) != band->nr_3_band) {
LOG("nr_3_band band error.");
goto exit;
@@ -343,7 +358,6 @@
LOG("nr_0_band band error.");
goto exit;
}
-#endif
if(band->net_pref == 0xFF) { // No change net_pref.
int tmp_int;
err = at_send_command_singleline(port, "AT*BAND?", "*BAND:", &response);
@@ -370,7 +384,6 @@
at_response_free(response);
}
-#ifdef MBTK_DEV_INFO_VERSION_2
// Only support 4G/5G
if(band_info.net_support & MBTK_NET_SUPPORT_5G) {
// AT*band=19,0,0,482,134742231,0,24576,256,134217877,0
@@ -388,13 +401,6 @@
sprintf(cmd, "AT*BAND=%d,%d,%d,%d,%d", band->net_pref, band->gsm_band, band->umts_band, band->tdlte_band, band->fddlte_band);
}
}
-#else
- if(band->lte_ext_band > 0) {
- sprintf(cmd, "AT*BAND=%d,%d,%d,%d,%d,,,,%d", band->net_pref, band->gsm_band, band->umts_band, band->tdlte_band, band->fddlte_band, band->lte_ext_band);
- } else {
- sprintf(cmd, "AT*BAND=%d,%d,%d,%d,%d", band->net_pref, band->gsm_band, band->umts_band, band->tdlte_band, band->fddlte_band);
- }
-#endif
}
err = at_send_command(port, cmd, &response);
@@ -537,7 +543,6 @@
}
band->fddlte_band = (uint32)tmp_int;
-#ifdef MBTK_DEV_INFO_VERSION_2
if(band_info.net_support & MBTK_NET_SUPPORT_5G)
{
err = at_tok_nextint(&line, &tmp_int);
@@ -568,7 +573,6 @@
}
band->nr_0_band = (uint32)tmp_int;
}
-#endif
// roamingConfig
err = at_tok_nextint(&line, &tmp_int);
@@ -714,6 +718,31 @@
}
signal->rsrp = (uint8)tmp_int;
+ if(at_tok_hasmore(&line)) {
+ err = at_tok_nextint(&line, &tmp_int);
+ if (err < 0)
+ {
+ goto exit;
+ }
+ signal->ss_rsrq = (uint8)tmp_int;
+ }
+ if(at_tok_hasmore(&line)) {
+ err = at_tok_nextint(&line, &tmp_int);
+ if (err < 0)
+ {
+ goto exit;
+ }
+ signal->ss_rsrp = (uint8)tmp_int;
+ }
+ if(at_tok_hasmore(&line)) {
+ err = at_tok_nextint(&line, &tmp_int);
+ if (err < 0)
+ {
+ goto exit;
+ }
+ signal->ss_sinr = (uint8)tmp_int;
+ }
+
at_response_free(response);
err = at_send_command_singleline(port, "AT+COPS?", "+COPS:", &response);
if (err < 0 || response->success == 0 || !response->p_intermediates){
@@ -901,6 +930,56 @@
goto exit;
}
reg->type = (uint8)tmp_int;
+ } else if(reg->data_state == 0 && (band_info.net_support & MBTK_NET_SUPPORT_5G)) {
+ at_response_free(response);
+ err = at_send_command_multiline(port, "AT+C5GREG?", "+C5GREG:", &response);
+ if (err < 0 || response->success == 0 || !response->p_intermediates){
+ if(cme_err) {
+ *cme_err = at_get_cme_error(response);
+ }
+ goto exit;
+ }
+
+ line = response->p_intermediates->line;
+ err = at_tok_start(&line);
+ if (err < 0)
+ {
+ goto exit;
+ }
+ err = at_tok_nextint(&line, &tmp_int); // n
+ if (err < 0)
+ {
+ goto exit;
+ }
+ err = at_tok_nextint(&line, &tmp_int);// stat
+ if (err < 0)
+ {
+ goto exit;
+ }
+ reg->data_state = (uint8)tmp_int;
+
+ if(/*reg->lac == 0 && */at_tok_hasmore(&line)) {
+ err = at_tok_nextstr(&line, &tmp_str); // lac
+ if (err < 0)
+ {
+ goto exit;
+ }
+ reg->lac = strtol(tmp_str, NULL, 16);
+
+ err = at_tok_nextstr(&line, &tmp_str); // ci
+ if (err < 0)
+ {
+ goto exit;
+ }
+ reg->ci = strtol(tmp_str, NULL, 16);
+
+ err = at_tok_nextint(&line, &tmp_int);// AcT
+ if (err < 0)
+ {
+ goto exit;
+ }
+ reg->type = (uint8)tmp_int;
+ }
}
at_response_free(response);
@@ -1517,7 +1596,7 @@
ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &band, sizeof(mbtk_band_info_t));
}
} else { // Get support bands.
- ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &band_info.band_support , sizeof(mbtk_band_info_t));
+ ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &band_info.band_support, sizeof(mbtk_band_info_t));
}
} else { // Set current bands.
mbtk_band_info_t* band = (mbtk_band_info_t*)pack->data;
@@ -1615,6 +1694,7 @@
else
{
LOG("req_cell_info_get() success,cell number: %d", cell_info.cell_list.num);
+ LOGD("data_len = %d", sizeof(mbtk_cell_info_array_t));
ril_rsp_pack_send(cli_info->port, cli_info->fd, pack->msg_id, pack->msg_index, &cell_info.cell_list, sizeof(mbtk_cell_info_array_t));
}
}