KeyDuino forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.


Un échange d'information autour de la carte KeyDuino
 
HomeHome  Latest imagesLatest images  RegisterRegister  Log inLog in  

 

 HCE connnectivity

Go down 
2 posters
AuthorMessage
raul
Newbie
Newbie



Messages : 4
Reputation : 0
Date d'inscription : 2017-08-18

HCE connnectivity Empty
PostSubject: HCE connnectivity   HCE connnectivity EmptyWed 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.
Back to top Go down
raul
Newbie
Newbie



Messages : 4
Reputation : 0
Date d'inscription : 2017-08-18

HCE connnectivity Empty
PostSubject: Re: HCE connnectivity   HCE connnectivity EmptyWed 23 Aug - 18:18

HCE connnectivity Img_2010
I try to use hce_unlock code but this is the result
Back to top Go down
MrStein
KeyDuino TEAM
MrStein


Messages : 85
Reputation : 4
Date d'inscription : 2015-10-10
Age : 31
Localisation : Lille, FRANCE

HCE connnectivity Empty
PostSubject: Re: HCE connnectivity   HCE connnectivity EmptyThu 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/
Back to top Go down
https://keyduino.forumsactifs.com
raul
Newbie
Newbie



Messages : 4
Reputation : 0
Date d'inscription : 2017-08-18

HCE connnectivity Empty
PostSubject: Re: HCE connnectivity   HCE connnectivity EmptyFri 25 Aug - 14:25

Thanks Mr stein you help me a lot I love you
Back to top Go down
raul
Newbie
Newbie



Messages : 4
Reputation : 0
Date d'inscription : 2017-08-18

HCE connnectivity Empty
PostSubject: Re: HCE connnectivity   HCE connnectivity EmptySun 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?
Back to top Go down
Sponsored content





HCE connnectivity Empty
PostSubject: Re: HCE connnectivity   HCE connnectivity Empty

Back to top Go down
 
HCE connnectivity
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
KeyDuino forum :: KeyDuino projects & tutorial :: Projects :: Idea / proposition of project-
Jump to: