[android-developers] Re: NFC Secure Element
I polished the patches so now you have some options from Settings application: Card Emulation Only Mode. This disables reader function. Card emulation mode is always enabled. Be careful because P2P mode may not work (not tested) Use External Secure Element if Available. This makes the phone to use the SE of the UICC if available instead of embedded one. I posted the patches on xda-developershttp://forum.xda-developers.com/showthread.php?t=1281946 As a bonus I also removed the stupid time-limit when enable discoverable option of Bluetooth. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: NFC Secure Element
For the time being I can not share the ROM but you can compile it yourself with the supplied patches. Take a look at the last ones: https://groups.google.com/d/msg/android-developers/1fw1qfFqpGc/pvhc11jVDEUJ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: NFC Secure Element
Hi Michael, Correct, for the SE connected through NFC-WI/S2C, the NFC controller has three modes: off, wired and virtual mode. Off means that there is no communication with the secure element. Wired mode means that the secure element is visible to the application processor as if it was a (contactless) smartcard connected to the RF reader. Virtual mode means that the secure element is visible to external readers as if the phone were a contactless smartcard. That's right. From what I've read in the PN544 User Manual, I don't think that there is an equvalent for the wired mode with SWP/HCI (I would be happy to be proven wrong). Usually for the wired mode, the contact interface of the UICC would be used so it wouldn't really make sense if the NFC controller allowed for an additional* channel between the UICC and the application processor. *) Additional once the RIL supported APDU exchange with the UICC. Well, here is where the *phHal4Nfc_Switch_Swp_Mode() *comes*. *It is analog to the *phHal4Nfc_Switch_SMX_Mode() *which is used to set the wired mode to work with the SmartMX. In function *phLibNfc_SE_SetMode() *when told to enable wired mode it ignores to enable it if secure element is UICC instead of SmartMX. In this last case it uses *phHal4Nfc_Switch_SMX_Mode() *with the parameter *eSmartMx_Wired. *I modified the function to use *phHal4Nfc_Switch_Swp_Mode() *with parameter *eSWP_Switch_On *(this parameter has an incorrect value by default, it must be enabled by using nemik's patches). This function (phHal4Hnfc_Switch_Swp_Mode()) succeeds, which makes me think there could be a wired SWP mode. Although the SWP mode is enabled, no SE seems to be detected this way. When opening SMX in wired mode from *com_android_nfc_NativeNfcSecureElement_doOpenSecureElementConnection() *the callback is called twice after calling *phLibNfc_SE_SetMode(). *However if SWP is enabled (using external SE element) callback is only called once after *phLibNfc_SE_SetMode(). *If we avoid waiting for second callback * phLibNfc_RemoteDev_Connect()* always fails (internally no SE has been discovered). When it comes to RIL issue. I patched the sources with SEEK diffs too but rild daemon crashes. SEEK mantainers say it is due to baseband processor not implementing required (AT+CSIM, AT+CCHO, AT+CCHC, AT+CGLA) commands ( http://code.google.com/p/seek-for-android/wiki/UICCSupport). Is there any way to reverse engineer baseband firmware or get access to a modified version implementing those commands? Or has anyone discovered whether Samsung has other propietary commands achieving the same results (raw APDU exchange with SIM/UICC)? regards, Fernando -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: NFC Secure Element
Hi Michael, As far as I understand sending APDUs to the SmartMX SE element is possible because the NFC Controller (PN544) is told to enable the NFC-WI interface with SE. This is carried out by calling *phHal4Nfc_Switch_SMX_Mode()*, with parameter *eSmartMx_Wired *(function *phLibNfc_SE_SetMode()).* * * Wouldn't it be possible to use the SWP channel to send APDUs to UICC SE through NFC Controller in an wired mode from an application the same way it is performed when sending APDUs to the SmartMX element? Or is SWP only supposed for raw RF Communication and has no such equivalent capabilities used by NFC-WI? Taking a look at the libnfc-nxp library theare are some SWP related functions that are not being used.Maybe *phHal4Nfc_Switch_Swp_Mode() *could be used in a similar fashion to *phHal4Nfc_Switch_SMX_Mode()*? * * * * -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: NFC Secure Element
I got it working on 2.3.4_r1!!! The key was enabling discoverability but in card emulation mode. The strange thing is now I can detect two smart card types with an Arcontia smart card reader: - ISO14443A tag CL1 tag (This is the Mifare 4K) - FELICA RCS-885 424kbs tag (I suppose this is really the Javacard, not a Felica card) I managed to write and read a block (4) to the Mifare 4K with default keys. Next thing will be investigating wheter 2.3.4 adds support by means of nxp-nfc library to directly send APDUs to the SE. You and Michael Roland already confirmed it was not possible with prior gingerbread versions. I post the corrected patch to get card emulation on 2.3.4_r1. One thing. Card stops being readable from an external reader after screen goes off and back on. However if you disable NFC and re-enable it (from settings) card is discoverable again. Thanks nemik for your work (you can update your patches with these corretions to work with gingerbread 2.3.4_r1 at your site if you want). -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=endiff -urBNp Nfc.orig/jni/com_android_nfc_NativeNfcManager.cpp Nfc/jni/com_android_nfc_NativeNfcManager.cpp --- Nfc.orig/jni/com_android_nfc_NativeNfcManager.cpp 2011-07-19 12:32:17.545611859 +0200 +++ Nfc/jni/com_android_nfc_NativeNfcManager.cpp 2011-07-18 10:50:27.665620770 +0200 @@ -341,6 +341,7 @@ static int nfc_jni_initialize(struct nfc /* == CONFIGURE DRIVER === */ TRACE(phLibNfc_Mgt_ConfigureDriver(0x%08x, 0x%08x), gDrvCfg.nClientId, gDrvCfg.nLinkType); + LOGD(phLibNfc_Mgt_ConfigureDriver(0x%08x, 0x%08x), gDrvCfg.nClientId, gDrvCfg.nLinkType); REENTRANCE_LOCK(); status = phLibNfc_Mgt_ConfigureDriver(gDrvCfg, gHWRef); REENTRANCE_UNLOCK(); @@ -364,6 +365,7 @@ static int nfc_jni_initialize(struct nfc /* == INITIALIZE === */ TRACE(phLibNfc_Mgt_Initialize()); + LOGD(phLibNfc_Mgt_Initialize()); REENTRANCE_LOCK(); status = phLibNfc_Mgt_Initialize(gHWRef, nfc_jni_init_callback, (void *)cb_data); REENTRANCE_UNLOCK(); @@ -373,6 +375,7 @@ static int nfc_jni_initialize(struct nfc goto clean_and_return; } TRACE(phLibNfc_Mgt_Initialize returned 0x%04x[%s], status, nfc_jni_get_status_name(status)); + LOGD(phLibNfc_Mgt_Initialize returned 0x%04x[%s], status, nfc_jni_get_status_name(status)); /* Wait for callback response */ if(sem_wait(cb_data.sem)) @@ -433,6 +436,7 @@ static int nfc_jni_initialize(struct nfc // Update EEPROM settings TRACE(** START EEPROM SETTINGS UPDATE **); + LOGD(** START EEPROM SETTINGS UPDATE **); for (i = 0; i EEDATA_SETTINGS_NUMBER; i++) { gInputParam.buffer = EEDATA_Settings[i]; @@ -440,6 +444,7 @@ static int nfc_jni_initialize(struct nfc gOutputParam.buffer = resp; TRACE( EEPROM SETTING: %d, i); + LOGD( EEPROM SETTING: %d, i); REENTRANCE_LOCK(); status = phLibNfc_Mgt_IoCtl(gHWRef, NFC_MEM_WRITE, gInputParam, gOutputParam, nfc_jni_ioctl_callback, (void *)cb_data); REENTRANCE_UNLOCK(); @@ -461,6 +466,7 @@ static int nfc_jni_initialize(struct nfc } } TRACE(** ALL EEPROM SETTINGS UPDATED **); + LOGD(** ALL EEPROM SETTINGS UPDATED **); /* == SECURE ELEMENTS === */ @@ -511,6 +517,7 @@ static int nfc_jni_initialize(struct nfc /* LLCP Params */ TRACE(** NFC Config Mode NFCIP1 - LLCP **); + LOGD(** NFC Config Mode NFCIP1 - LLCP **); LlcpConfigInfo.miu= nat-miu; LlcpConfigInfo.lto= nat-lto; LlcpConfigInfo.wks= nat-wks; @@ -529,6 +536,8 @@ static int nfc_jni_initialize(struct nfc } TRACE(phLibNfc_Mgt_SetLlcp_ConfigParams returned 0x%04x[%s], status, nfc_jni_get_status_name(status)); + LOGD(phLibNfc_Mgt_SetLlcp_ConfigParams returned 0x%04x[%s], status, + nfc_jni_get_status_name(status)); /* Wait for callback response */ if(sem_wait(cb_data.sem)) @@ -602,6 +611,7 @@ void nfc_jni_restart_discovery_locked(st struct nfc_jni_callback_data cb_data; TRACE(Restarting polling loop); + LOGD(Restarting polling loop); /* Create the local semaphore */ if (!nfc_cb_data_init(cb_data, NULL)) @@ -614,6 +624,7 @@ void nfc_jni_restart_discovery_locked(st /* Restart Polling loop */ TRACE(** Start NFC Discovery **); + LOGD(** Start NFC Discovery **); REENTRANCE_LOCK(); ret = phLibNfc_Mgt_ConfigureDiscovery(NFC_DISCOVERY_RESUME,nat-discovery_cfg, nfc_jni_discover_callback, (void *)cb_data); REENTRANCE_UNLOCK(); @@ -626,7 +637,16 @@ void
[android-developers] Re: NFC Secure Element
Hi Nemik, I just applied your patches to 2.3.4_r1 version (I had to change them a little bit) but card emulation does not seem to work (an external reader detects nothing). Could you please tell us what tag of AOSP gingerbread did you use? Thanks -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: NFC Secure Element
Yes I know. I revised them manually and adapted to 2.3.4_r1. However I must be missing something. I see the Secure Element SMX selected, the embedded Mifare card is not detected by means of external readers. The external reader detects a memory card but it can not read the CSN (UID). It seems as if the card emulation were enabled but then disabled. This is my init sequence as seen by logcat: http://pastebin.com/XpyLUGaJ I can see the following sequence. So I assume the embedded secure element is enabled: I/NFC JNI ( 198): NFC Initialized D/NfcService( 198): NFC-EE routing ON D/NFC JNI ( 198): ** Select Secure Element ** D/NFC JNI ( 198): phLibNfc_SE_SetMode(0x00abcdef, ...) D/NFC JNI ( 198): phLibNfc_SE_SetMode() returned 0x000d[NFCSTATUS_PENDING] What is the correct message sequence? I attach your patches modified to compile against 2.3.4_r1. Someone could find them useful. By the way in this tag Nfc is disabled by default. So the patch device_base_2_3_4_r1.diff must be also applied. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=endiff -urBNp libnfc-nxp.orig/inc/phNfcConfig.h libnfc-nxp/inc/phNfcConfig.h --- libnfc-nxp.orig/inc/phNfcConfig.h 2011-07-18 18:15:27.215614224 +0200 +++ libnfc-nxp/inc/phNfcConfig.h 2011-07-18 18:20:33.823504089 +0200 @@ -286,6 +286,7 @@ #ifndef NXP_UICC_RD_RIGHTS #define NXP_UICC_RD_RIGHTS 0x00U +//#define NXP_UICC_RD_RIGHTS 0x0FU #endif @@ -367,7 +368,7 @@ #define RECONNECT_SUPPORT /** Macro to Enable the Card Emulation Feature */ -/* #define HOST_EMULATION */ +#define HOST_EMULATION /** Macro to Enable the Download Mode Feature */ #define FW_DOWNLOAD diff -urBNp Nfc.orig/jni/com_android_nfc_NativeNfcManager.cpp Nfc/jni/com_android_nfc_NativeNfcManager.cpp --- Nfc.orig/jni/com_android_nfc_NativeNfcManager.cpp 2011-07-18 18:03:05.825613188 +0200 +++ Nfc/jni/com_android_nfc_NativeNfcManager.cpp 2011-07-18 10:50:27.665620770 +0200 @@ -341,6 +341,7 @@ static int nfc_jni_initialize(struct nfc /* == CONFIGURE DRIVER === */ TRACE(phLibNfc_Mgt_ConfigureDriver(0x%08x, 0x%08x), gDrvCfg.nClientId, gDrvCfg.nLinkType); + LOGD(phLibNfc_Mgt_ConfigureDriver(0x%08x, 0x%08x), gDrvCfg.nClientId, gDrvCfg.nLinkType); REENTRANCE_LOCK(); status = phLibNfc_Mgt_ConfigureDriver(gDrvCfg, gHWRef); REENTRANCE_UNLOCK(); @@ -364,6 +365,7 @@ static int nfc_jni_initialize(struct nfc /* == INITIALIZE === */ TRACE(phLibNfc_Mgt_Initialize()); + LOGD(phLibNfc_Mgt_Initialize()); REENTRANCE_LOCK(); status = phLibNfc_Mgt_Initialize(gHWRef, nfc_jni_init_callback, (void *)cb_data); REENTRANCE_UNLOCK(); @@ -373,6 +375,7 @@ static int nfc_jni_initialize(struct nfc goto clean_and_return; } TRACE(phLibNfc_Mgt_Initialize returned 0x%04x[%s], status, nfc_jni_get_status_name(status)); + LOGD(phLibNfc_Mgt_Initialize returned 0x%04x[%s], status, nfc_jni_get_status_name(status)); /* Wait for callback response */ if(sem_wait(cb_data.sem)) @@ -433,6 +436,7 @@ static int nfc_jni_initialize(struct nfc // Update EEPROM settings TRACE(** START EEPROM SETTINGS UPDATE **); + LOGD(** START EEPROM SETTINGS UPDATE **); for (i = 0; i EEDATA_SETTINGS_NUMBER; i++) { gInputParam.buffer = EEDATA_Settings[i]; @@ -440,6 +444,7 @@ static int nfc_jni_initialize(struct nfc gOutputParam.buffer = resp; TRACE( EEPROM SETTING: %d, i); + LOGD( EEPROM SETTING: %d, i); REENTRANCE_LOCK(); status = phLibNfc_Mgt_IoCtl(gHWRef, NFC_MEM_WRITE, gInputParam, gOutputParam, nfc_jni_ioctl_callback, (void *)cb_data); REENTRANCE_UNLOCK(); @@ -461,6 +466,7 @@ static int nfc_jni_initialize(struct nfc } } TRACE(** ALL EEPROM SETTINGS UPDATED **); + LOGD(** ALL EEPROM SETTINGS UPDATED **); /* == SECURE ELEMENTS === */ @@ -511,6 +517,7 @@ static int nfc_jni_initialize(struct nfc /* LLCP Params */ TRACE(** NFC Config Mode NFCIP1 - LLCP **); + LOGD(** NFC Config Mode NFCIP1 - LLCP **); LlcpConfigInfo.miu= nat-miu; LlcpConfigInfo.lto= nat-lto; LlcpConfigInfo.wks= nat-wks; @@ -529,6 +536,8 @@ static int nfc_jni_initialize(struct nfc } TRACE(phLibNfc_Mgt_SetLlcp_ConfigParams returned 0x%04x[%s], status, nfc_jni_get_status_name(status)); + LOGD(phLibNfc_Mgt_SetLlcp_ConfigParams returned 0x%04x[%s], status, + nfc_jni_get_status_name(status)); /* Wait for callback response */ if(sem_wait(cb_data.sem)) @@ -602,6 +611,7 @@ void nfc_jni_restart_discovery_locked(st struct
[android-developers] Re: NFC Secure Element
For convenience I post the filtered NFC related I can see after initialization. As I said the card is detected on reader but only after phone restarts (however it can not read any UID). If I approach it latter it is not recognized. 07-18 17:01:54.800: DEBUG/NFC JNI(283): NFC Service : loading JNI 07-18 17:01:54.847: INFO/NfcService(283): Starting NFC service 07-18 17:01:54.992: DEBUG/NFC JNI(283): Set NFC DISCOVERY A to 1 07-18 17:01:54.992: DEBUG/NFC JNI(283): Set NFC DISCOVERY B to 1 07-18 17:01:54.992: DEBUG/NFC JNI(283): Set NFC DISCOVERY F to 1 07-18 17:01:54.992: DEBUG/NFC JNI(283): Set NFC DISCOVERY 15693 to 1 07-18 17:01:54.992: DEBUG/NFC JNI(283): Set NFC DISCOVERY 15693 to 1 07-18 17:01:55.089: DEBUG/NFC JNI(283): phLibNfc_Mgt_Initialize returned 0x000d[NFCSTATUS_PENDING] 07-18 17:01:55.113: DEBUG/NFC JNI(283): NFC client started 07-18 17:01:55.250: DEBUG/NFC JNI(283): NFC capabilities: HAL = 8150100, FW = a70414, HW = 620003, Model = 0, HCI = 1, Full_FW = 104, FW Update Info = 0 07-18 17:01:55.582: DEBUG/NFC JNI(283): phLibNfc_SE_SetMode() returned 0x000d[NFCSTATUS_PENDING] 07-18 17:01:55.597: DEBUG/NFC JNI(283): ** NFC Config Mode NFCIP1 - LLCP ** 07-18 17:01:55.597: DEBUG/NFC JNI(283): phLibNfc_Mgt_SetLlcp_ConfigParams returned 0x000d[NFCSTATUS_PENDING] 07-18 17:01:55.644: INFO/NFC JNI(283): NFC Initialized 07-18 17:01:55.644: DEBUG/NfcService(283): NFC-EE routing ON 07-18 17:01:55.644: DEBUG/NFC JNI(283): phLibNfc_SE_SetMode() returned 0x000d[NFCSTATUS_PENDING] 07-18 17:01:55.664: DEBUG/NfcService(283): NFC-C discovery OFF 07-18 17:01:55.664: DEBUG/NFC JNI(283): ** Stop NFC Discovery ** 07-18 17:01:55.746: DEBUG/NFC JNI(283): phLibNfc_Llcp_Socket() returned 0x[NFCSTATUS_SUCCESS] 07-18 17:01:55.750: DEBUG/NFC JNI(283): phLibNfc_Llcp_Bind() returned 0x[NFCSTATUS_SUCCESS] 07-18 17:01:55.750: DEBUG/NFC JNI(283): phLibNfc_Llcp_Listen() returned 0x[NFCSTATUS_SUCCESS] -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: NFC Secure Element
Have somebody activate the Card Emulation with UICC? Yes. I tryed it, with SmartMX SE it was no problem Card Emulation was running. When I tried the ID of my UICC in the Method doSelectSecureElement from NFC Service, then the Card Emulation was not running, Reader dont detect a Tag. Somebody knows why doSelectSecureElement Method dont working with UICC? If the UICC supports SWP, the doSelectSecureElement method works just fine here. (ID is 11259376 for UICC) Hi Michael, I am new to this forum and I am impressed of the level your mastership and the rest of the members. Do you mean you could enable card emulation mode from UICC? Could you read the contents of a smartcard through an external reader and also from an android application? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Problem getting Bluetooth RSSI (Signal Strength)
It may not work because EXTRA_RSSI value is a short type instead of int. This works great for me: short rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI, Short.MIN_VALUE); Take into consideration that rssi values are usually negative (it could be dBm but I am not sure). On 28 ene, 20:47, Chris crystalredve...@gmail.com wrote: I'm trying to determine location via bluetooth beacons and while I can discover and find all of the devices around me, when I try to grab the EXTRA_RSSI that's supposed to come through it doesn't work. Here's the code I'm using and I get a 0 every time. private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Toast.makeText(ScannerActivity.this, In BroadcastReceiver, 3); String action = intent.getAction(); // When discovery finds a device if (BluetoothDevice.ACTION_FOUND.equals(action)) { // Get the BluetoothDevice object from the Intent BluetoothDevice device = intent.getParcelableExtra (BluetoothDevice.EXTRA_DEVICE); int rssi = intent.getIntExtra (BluetoothDevice.EXTRA_RSSI, 0); // Add the name and address to an array adapter to show in a ListView if (device.getBondState() != BluetoothDevice.BOND_BONDED) { //do something } } } } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en