I try to develop a Sim Application Toolkit Applet.. Many simple examples found in internet, but no success..
The problem is; My menu entry comes in the STK menu, but if I select it, nothing happens.. I try to display text on event EVENT_MENU_SELECTION. (Actually not only displaying text, also sms, ussd, sub items doesn't work too..)
Here is my sample code.. Hope anybody has an idea.. (Maybe some specific install parameter on loading applet?)
Thanks in advance, Kutschka
package proactive_cmd;
import javacard.framework.*;
import sim.access.*;
import sim.toolkit.*;
public class display_text extends Applet
implements ToolkitConstants, ToolkitInterface
{
private static final byte CMD_QUALIFIER = (byte)0x80;
private byte[] menuEntry = {'M','y','M','e','n','u'};
private byte[] textBuf = {'H','e','l','l','o'};
private ToolkitRegistry reg;
private SIMView gsmFile;
public display_text() {
//Get the GSM application reference
gsmFile = SIMSystem.getTheSIMView();
reg = ToolkitRegistry.getEntry();
reg.initMenuEntry(menuEntry,
(short) 0,
(short) menuEntry.length,
PRO_CMD_DISPLAY_TEXT,
false,
(byte) 0,
(short) 0);
}
public static void install(byte[] bArray, short bOffset, byte bLength)
throws ISOException
{
display_text dt = new display_text();
dt.register();
}
public void processToolkit(byte event)
throws ToolkitException
{
ProactiveHandler ph = ProactiveHandler.getTheHandler();
if (event == EVENT_MENU_SELECTION) {
ph.init((byte) PRO_CMD_DISPLAY_TEXT, (byte) CMD_QUALIFIER, DEV_ID_DISPLAY);
ph.appendTLV((byte)(TAG_TEXT_STRING | TAG_SET_CR),
textBuf,
(short) 0,
(short) textBuf.length);
ph.send();
}
}
public void process(APDU apdu) {
if (selectingApplet()) {
return;
}
}
}
In order to use STK commands you have to properly install your applet. For SIM Toolkit it has to be CA tag in INSTALL MAKE SELECTABLE command. If you'll use UICC toolkit you have to use EA tag. Please refer to ETSI 102 226 standard for full details.