In UMTS I get a large number returned by getCid()
(larger than the allowed value). Is this the UTRAN Cell Identity (UC-ID)?
UC-Id = RNC-Id + C-Id
Does someone knows that? How to get the C-Id
from the UC-Id
?
Thanks and Best, Benny
The RNC id is the first 2 bytes of the 4 byte Cell Id (3GPP 25.401, section 6.1.5), if the network type is UMTS/HSxPA/HSPA+."
I have access to an operator network and I checked in the system and it's true and correct.
Based on that please see my code how you can easily get RNCID + CID:
Convert CID to ByteArray:
public static byte[] convertByteArray__p(int p_int){
byte[] l_byte_array = new byte[4];
int MASK_c = 0xFF;
for (short i=0; i<=3; i++){
l_byte_array[i] = (byte) ((p_int >> (8*i)) & MASK_c);
}
return l_byte_array;
}
Get the RNCID and CID:
public int getRNCID_or_CID__p(byte[] p_bytes, short p_which){
int MASK_c = 0xFF;
int l_result = 0;
if (p_which == Constants.CID_C) {
l_result = p_bytes[0] & MASK_c ;
l_result = l_result + ((p_bytes[1] & MASK_c ) << 8);
} else if (p_which == Constants.RNCID_C){
l_result = p_bytes[2] & MASK_c ;
l_result = l_result + ((p_bytes[3] & MASK_c ) << 8);
} else {
g_FileHandler.putLog__p('E', "getRNCID_or_CID__p invalid parameter");
}
return l_result;
}
Than you can easily call like this:
byte[] l_byte_array = new byte[4];
l_byte_array = convertByteArray__p(l_cid);
int l_RNC_ID = getRNCID_or_CID__p(l_byte_array,Constants.RNCID_C);
int l_real_CID = getRNCID_or_CID__p(l_byte_array,Constants.CID_C);
Constants RNCID_C(1) and CID_C(2) are only contants just for me to seperate which parameter will be passed through.
If CID is > 65536, it's not actually the cell-ID, but a linear combination of the real cell-ID and RNC-ID:
UTRAN_CELL_ID = RNCID x 65536 + CellID
To extract the cellID, use the modulo operation:
CellID = UTRAN_CELL_ID % 65536
To extract the RNCID, get the integer part:
RNCID = UTRAN_CELL_ID / 65536
try (cell id % 65536) it worked for me.
This is more simple than this. Cell ID is in the low register of the value getCid() returns, the RNC is the high register of this value (http://developer.android.com/reference/android/telephony/gsm/GsmCellLocation.html#getCid()). So:
getCid() == RNC << 16 | CID
CID = getCid() & 0xffff
RNC = (getCid() >> 16) & 0xffff
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With