No need to connect/disconnect FeliCa targets.

This commit is contained in:
Romain Tartière 2015-05-13 19:52:08 +02:00
parent 6049acaf5a
commit ac50476c99
5 changed files with 0 additions and 59 deletions

View file

@ -51,10 +51,6 @@ main (void)
} }
for (int i = 0; tags[i]; i++) { for (int i = 0; tags[i]; i++) {
int r = felica_connect (tags[i]);
if (r < 0)
errx (EXIT_FAILURE, "Cannot connect to FeliCa target");
printf ("Dumping %s tag %s\n", freefare_get_tag_friendly_name (tags[i]), freefare_get_tag_uid (tags[i])); printf ("Dumping %s tag %s\n", freefare_get_tag_friendly_name (tags[i]), freefare_get_tag_uid (tags[i]));
printf ("Number\tName\tData\n"); printf ("Number\tName\tData\n");
@ -92,8 +88,6 @@ main (void)
} }
printf ("\n"); printf ("\n");
} }
felica_disconnect (tags[i]);
} }
freefare_free_tags (tags); freefare_free_tags (tags);

View file

@ -91,10 +91,6 @@ main (int argc, char *argv[])
} }
for (int i = 0; (!error) && tags[i]; i++) { for (int i = 0; (!error) && tags[i]; i++) {
int r = felica_connect (tags[i]);
if (r < 0)
errx (EXIT_FAILURE, "Cannot connect to FeliCa target");
int block = 1; int block = 1;
uint8_t ndef_message[NDEF_BUFFER_SIZE]; uint8_t ndef_message[NDEF_BUFFER_SIZE];
int ndef_space_left = NDEF_BUFFER_SIZE; int ndef_space_left = NDEF_BUFFER_SIZE;
@ -153,8 +149,6 @@ main (int argc, char *argv[])
err (EXIT_FAILURE, "Can't write NDEF message"); err (EXIT_FAILURE, "Can't write NDEF message");
fclose (f); fclose (f);
felica_disconnect (tags[i]);
} }
freefare_free_tags (tags); freefare_free_tags (tags);

View file

@ -64,47 +64,9 @@ felica_tag_free (FreefareTag tag)
int
felica_connect (FreefareTag tag)
{
ASSERT_INACTIVE (tag);
ASSERT_FELICA (tag);
nfc_target pnti;
nfc_modulation modulation = {
.nmt = NMT_FELICA,
.nbr = NBR_212,
};
if (nfc_initiator_select_passive_target (tag->device, modulation, tag->info.nti.nfi.abtId, 0, &pnti) >= 0) {
tag->active = 1;
} else {
errno = EIO;
return -1;
}
return 0;
}
int
felica_disconnect (FreefareTag tag)
{
ASSERT_ACTIVE (tag);
ASSERT_FELICA (tag);
if (nfc_initiator_deselect_target (tag->device) >= 0) {
tag->active = 0;
} else {
errno = EIO;
return -1;
}
return 0;
}
ssize_t ssize_t
felica_read_ex (FreefareTag tag, uint16_t service, uint8_t block_count, uint8_t blocks[], uint8_t *data, size_t length) felica_read_ex (FreefareTag tag, uint16_t service, uint8_t block_count, uint8_t blocks[], uint8_t *data, size_t length)
{ {
ASSERT_ACTIVE (tag);
ASSERT_FELICA (tag); ASSERT_FELICA (tag);
assert (block_count <= MAX_BLOCK_COUNT); assert (block_count <= MAX_BLOCK_COUNT);
@ -158,7 +120,6 @@ felica_read (FreefareTag tag, uint16_t service, uint8_t block, uint8_t *data, si
ssize_t ssize_t
felica_write_ex (FreefareTag tag, uint16_t service, uint8_t block_count, uint8_t blocks[], uint8_t *data, size_t length) felica_write_ex (FreefareTag tag, uint16_t service, uint8_t block_count, uint8_t blocks[], uint8_t *data, size_t length)
{ {
ASSERT_ACTIVE (tag);
ASSERT_FELICA (tag); ASSERT_FELICA (tag);
DEBUG_FUNCTION(); DEBUG_FUNCTION();

View file

@ -70,9 +70,6 @@ void freefare_perror (FreefareTag tag, const char *string);
#define FELICA_SC_RW 0x0009 #define FELICA_SC_RW 0x0009
#define FELICA_SC_RO 0x000b #define FELICA_SC_RO 0x000b
int felica_connect (FreefareTag tag);
int felica_disconnect (FreefareTag tag);
ssize_t felica_read (FreefareTag tag, uint16_t service, uint8_t block, uint8_t *data, size_t length); ssize_t felica_read (FreefareTag tag, uint16_t service, uint8_t block, uint8_t *data, size_t length);
ssize_t felica_read_ex (FreefareTag tag, uint16_t service, uint8_t block_count, uint8_t blocks[], uint8_t *data, size_t length); ssize_t felica_read_ex (FreefareTag tag, uint16_t service, uint8_t block_count, uint8_t blocks[], uint8_t *data, size_t length);
ssize_t felica_write (FreefareTag tag, uint16_t service, uint8_t block, uint8_t *data, size_t length); ssize_t felica_write (FreefareTag tag, uint16_t service, uint8_t block, uint8_t *data, size_t length);

View file

@ -51,8 +51,6 @@ cut_setup (void)
for (int i=0; tags[i]; i++) { for (int i=0; tags[i]; i++) {
if (freefare_get_tag_type(tags[i]) == FELICA) { if (freefare_get_tag_type(tags[i]) == FELICA) {
tag = tags[i]; tag = tags[i];
res = felica_connect (tag);
cut_assert_equal_int (0, res, cut_message ("felica_connect() failed"));
return; return;
} }
} }
@ -67,9 +65,6 @@ cut_setup (void)
void void
cut_teardown (void) cut_teardown (void)
{ {
if (tag)
mifare_classic_disconnect (tag);
if (tags) { if (tags) {
freefare_free_tags (tags); freefare_free_tags (tags);
tags = NULL; tags = NULL;