raul Newbie
Messages : 4 Reputation : 0 Date d'inscription : 2017-08-18
| Subject: HCE connnectivity Wed 23 Aug - 16:47 | |
| Hi, Actually i work in my project off a smart lock. I buy a keyduino for this. My idea was that use my smartphone like a key that de smart lock off the door can recognize me (my smartphone). But if I scan the tag of my smartphone (using the code tag identification) all the time change and show numbers random. I want to find a way to solve that problem. | |
|
raul Newbie
Messages : 4 Reputation : 0 Date d'inscription : 2017-08-18
| Subject: Re: HCE connnectivity Wed 23 Aug - 18:18 | |
| I try to use hce_unlock code but this is the result | |
|
MrStein KeyDuino TEAM
Messages : 85 Reputation : 4 Date d'inscription : 2015-10-10 Age : 31 Localisation : Lille, FRANCE
| Subject: Re: HCE connnectivity Thu 24 Aug - 13:46 | |
| To use HCE you will need an application with a defined AID LIKE THIS ONE from frugalprototype.com in this APK, the AID is 0xF0, 0x46, 0x52, 0x55, 0x47, 0x41, 0x4c. (F0 + "FRUGAL"). Here is the new code exemple with the AID: - Code:
-
/* This sketch is made to be used with an HCE (Host-based Card Emulation) application, for example to unlock a door. KeyDuino sends an APDU command to select an Application ID, and receives an answer from the app. You can then compare the answer with what you expect, and proceed to unlocking if it matches.
Author: Raymond Borenstein - CITC-EuraRFID
Compatible with KeyDuino 5.1
Join http://keyduino.forumsactifs.com/ to ask your questions, suggest your ideas, and show your projects! */
#include <KeyDuino.h>
KeyDuino keyDuino;
uint8_t openingCode[] = { 0x01, 0x02, 0x03, 0x37, 0x90, 0x00 }; //90 00 is the success code, you need to add it - the rest of the code is the same as the one defined in the HCE application
void setup() { Serial.begin(115200); Serial.println("-------Peer to Peer HCE--------");
keyDuino.begin(); }
void loop() { bool success;
uint8_t responseLength = 32;
Serial.println("Waiting for an HCE Application...");
// set shield to inListPassiveTarget success = keyDuino.inListPassiveTarget(PN532_MIFARE_ISO14443A); //If it doesn't work with your device, you can try with PN532_ISO14443B
if(success) {
Serial.println("Found something!");
uint8_t selectApdu[] = { 0x00, /* CLA */ 0xA4, /* INS */ 0x04, /* P1 */ 0x00, /* P2 */ 0x07, /* Length of AID */ 0xF0, 0x46, 0x52, 0x55, 0x47, 0x41, 0x4c, /* AID defined on HCE App */ };
uint8_t response[32];
success = keyDuino.inDataExchange(selectApdu, sizeof(selectApdu), response, &responseLength);
if(success) {
Serial.print("responseLength: "); Serial.println(responseLength);
Serial.print("response: "); keyDuino.PrintHex(&response[0], responseLength); if (sizeof(openingCode)/sizeof(uint8_t) == responseLength && memcmp(response, openingCode, responseLength) == 0){ //Response is correct, do whatever you need here Serial.println("Opening!"); } else { Serial.println("Incorrect response, not opening..."); } } else { Serial.println("Failed sending SELECT AID"); } } delay(1000); }
If you want more information, here is a good tutorial (sadly in french) with the source of the apk: https://www.frugalprototype.com/android-nfc-hce/ | |
|
raul Newbie
Messages : 4 Reputation : 0 Date d'inscription : 2017-08-18
| Subject: Re: HCE connnectivity Fri 25 Aug - 14:25 | |
| Thanks Mr stein you help me a lot | |
|
raul Newbie
Messages : 4 Reputation : 0 Date d'inscription : 2017-08-18
| Subject: Re: HCE connnectivity Sun 12 Nov - 22:37 | |
| I have a problem. I am working in devoloping an app with hce in android studio. And it works perfectly. But anyone knows how to start and stop a HostApduservice? | |
|
Sponsored content
| Subject: Re: HCE connnectivity | |
| |
|