PROVIDE_LOCAL_INFORMATION
843851Nov 3 2008 — edited Nov 10 2008Hi there,
i'm new in developing with JavaCard, and i tried to make a simple applet, using a PROVIDE_LOCAL_INFORMATION stk command, and return the output in a DISPLAY TEXT. Simple, no?
Code:
(...)
proHdlr.init(PRO_CMD_PROVIDE_LOCAL_INFORMATION, (byte) 0x00, DEV_ID_ME);
ProactiveResponseHandler ProRespHdlr; // get the system instance
ProRespHdlr = ProactiveResponseHandler.getTheHandler();
short len = proHdlr.getLength(); // length should be 14 !
byte result = proHdlr.send();
byte[] data;
data = new byte[32]; // build a buffer
result = ProRespHdlr.getGeneralResult();
byte res=ProRespHdlr.findTLV(TAG_LOCATION_INFORMATION, (byte)1);
short length = ProRespHdlr.getValueLength();
if (length > 1) {
// not empty string: to be copied
ProRespHdlr.copyValue((short)0, data, (short)0, (short)(length - 1));
}
// build and send a DisplayText command
proHdlr.initDisplayText( (byte) 0x80, DCS_UCS2, data, (short) 0, length);
result = proHdlr.send();
Two problems:
1)When i call the method findTLV, it returns 2 (it means "TLV_FOUND_CR_NOT_SET if the required occurence exists and Comprehension Required flag is not set")
What is a "Comprehension Required" flag?
2) The Terminal_Response to the PROVIDE_LOCAL_INFO has this data inside tag TAG_LOCATION_INFORMATION:
0x13 LOCI tag
0x07 - length
0x02 0xF8 0x00 - MCC/MNC
0x00 0x00 - LAC
0x00 0x00 Cell ID
(it's in hexadecimal)
When i copy it to my variable "data[]" using method "ProRespHdlr.copyValue" it copies the values in decimal.
So, what i have inside data[] is:
data[0]=2
data[1]=-8
data[2]=0
data[3]=0
data[4]=0
data[5]=0
data[6]=0
If i use the DISPLAY_TEXT with any of the Data Coding Schemes available (UCS2, DEFAULT or 8-bit), it shows in the terminal strange characters..
How can i make a DISPLAY_TEXT of this in a readable way? (showing for example "2-800000")
Or to convert it to hexadecimal? (2-800000 -> 02 F8 00 00 00 00 00)
Thanks in advance!