Вопрос

How to get the Radio Network Controller (RNC) in Android?

http://en.wikipedia.org/wiki/Radio_Network_Controller

Это было полезно?

Решение

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+.

Другие советы


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;     
}

Then 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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top