Hi all,
I'm new to NFC and I started by trying out the TargetDetectorMidlet example from Nokia which worked quite well.
Then, I wanted to test a command so I changed the targetDetected method :
My response is always the same as my command.Code:public void targetDetected(TargetProperties[] prop) { clearScreen(); siScreenText.setText("Target detected, target contains " + prop.length +" contactless targets"); TargetProperties target = prop[0]; Class[] classes = target.getConnectionNames(); try { for (int i=0; i<classes.length; i++) { if(classes[i].equals(Class.forName("javax.microedition.contactless.sc.ISO14443Connection"))) { String url = target.getUrl(classes[i]); // Open connection to external smart card ISO14443Connection smc = (ISO14443Connection)Connector.open(url); byte[] cmd2 = {(byte)0x00, (byte) 0xA4, (byte) 0x04, (byte) 0x00, (byte)0x08, (byte)0xA0, (byte)0x00, (byte)0x00, (byte)0x04, (byte)0x04, (byte)0x01, (byte)0x25, (byte)0x09}; byte[] response = smc.exchangeData(cmd2); siScreenText.setText(siScreenText.getText()+"\n\nResponse "+toHexString(response)); smc.close(); } } }catch (IOException e) { siScreenText.setText("IOException"+e.getMessage()); }catch (ClassNotFoundException e) { siScreenText.setText("ClassNotFoundException"+e.getMessage()); } catch (ContactlessException e) { siScreenText.setText("ContactlessException"+e.getMessage()); } } public static String toHexString(byte[] value) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < value.length; i++) { String val = Integer.toHexString(value[i] & 0xff).toUpperCase(); if (val.length() == 1) { buf.append('0'); } buf.append(val); } return buf.toString(); }
How is that possible, what am I doing wrong ?

Reply With Quote

