mirror of
https://github.com/whowechina/aic_pico.git
synced 2024-11-12 00:40:47 +01:00
Add FeliCa read to nfc interface
This commit is contained in:
parent
8c74095e42
commit
dd817f089e
@ -58,4 +58,6 @@ const char *nfc_module_name();
|
||||
bool nfc_mifare_auth(const uint8_t uid[4], uint8_t block_id, uint8_t key_id, const uint8_t *key);
|
||||
bool nfc_mifare_read(uint8_t block_id, uint8_t block_data[16]);
|
||||
|
||||
bool nfc_felica_read(uint16_t svc_code, uint16_t block_id, uint8_t block_data[16]);
|
||||
|
||||
#endif
|
||||
|
@ -55,18 +55,21 @@ struct {
|
||||
void (*rf_field)(bool on);
|
||||
bool (*mifare_auth)(const uint8_t uid[4], uint8_t block_id, uint8_t key_id, const uint8_t key[6]);
|
||||
bool (*mifare_read)(uint8_t block_id, uint8_t block_data[16]);
|
||||
bool (*felica_read)(uint16_t svc_code, uint16_t block_id, uint8_t block_data[16]);
|
||||
void (*set_wait_loop)(nfc_wait_loop_t loop);
|
||||
} api[3] = {
|
||||
{
|
||||
pn532_poll_mifare, pn532_poll_felica, func_null,
|
||||
pn532_rf_field,
|
||||
pn532_mifare_auth, pn532_mifare_read,
|
||||
pn532_felica_read,
|
||||
pn532_set_wait_loop
|
||||
},
|
||||
{
|
||||
pn5180_poll_mifare, pn5180_poll_felica, pn5180_poll_vicinity,
|
||||
pn5180_rf_field,
|
||||
pn5180_mifare_auth, pn5180_mifare_read,
|
||||
NULL,
|
||||
pn5180_set_wait_loop
|
||||
},
|
||||
{ 0 },
|
||||
@ -248,3 +251,11 @@ bool nfc_mifare_read(uint8_t block_id, uint8_t block_data[16])
|
||||
}
|
||||
return api[nfc_module].mifare_read(block_id, block_data);
|
||||
}
|
||||
|
||||
bool nfc_felica_read(uint16_t svc_code, uint16_t block_id, uint8_t block_data[16])
|
||||
{
|
||||
if (!api[nfc_module].felica_read) {
|
||||
return false;
|
||||
}
|
||||
return api[nfc_module].felica_read(svc_code, block_id, block_data);
|
||||
}
|
||||
|
@ -443,7 +443,7 @@ int pn532_felica_command(uint8_t cmd, const uint8_t *param, uint8_t param_len, u
|
||||
}
|
||||
|
||||
|
||||
bool pn532_felica_read_wo_encrypt(uint16_t svc_code, uint16_t block_id, uint8_t block_data[16])
|
||||
bool pn532_felica_read(uint16_t svc_code, uint16_t block_id, uint8_t block_data[16])
|
||||
{
|
||||
uint8_t param[] = { 1, svc_code & 0xff, svc_code >> 8,
|
||||
1, block_id >> 8, block_id & 0xff };
|
||||
@ -451,11 +451,7 @@ bool pn532_felica_read_wo_encrypt(uint16_t svc_code, uint16_t block_id, uint8_t
|
||||
int result = pn532_felica_command(0x06, param, sizeof(param), readbuf);
|
||||
|
||||
if (result != 12 + 16 || readbuf[9] != 0 || readbuf[10] != 0) {
|
||||
//printf("\nPN532 Felica READ read failed %d %02x %02x",
|
||||
// result, readbuf[9], readbuf[10]);
|
||||
for (int i = 0; i < result; i++) {
|
||||
printf(" %02x", readbuf[i]);
|
||||
}
|
||||
printf("\nPN532 Felica read failed [%04x:%04x]", svc_code, block_id);
|
||||
memset(block_data, 0, 16);
|
||||
return true; // we fake the result when it fails
|
||||
}
|
||||
@ -466,7 +462,7 @@ bool pn532_felica_read_wo_encrypt(uint16_t svc_code, uint16_t block_id, uint8_t
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pn532_felica_write_wo_encrypt(uint16_t svc_code, uint16_t block_id, const uint8_t block_data[16])
|
||||
bool pn532_felica_write(uint16_t svc_code, uint16_t block_id, const uint8_t block_data[16])
|
||||
{
|
||||
uint8_t param[22] = { 1, svc_code & 0xff, svc_code >> 8,
|
||||
1, block_id >> 8, block_id & 0xff };
|
||||
|
@ -32,7 +32,7 @@ bool pn532_poll_felica(uint8_t uid[8], uint8_t pmm[8], uint8_t syscode[2], bool
|
||||
bool pn532_mifare_auth(const uint8_t uid[4], uint8_t block_id, uint8_t key_id, const uint8_t key[6]);
|
||||
bool pn532_mifare_read(uint8_t block_id, uint8_t block_data[16]);
|
||||
|
||||
bool pn532_felica_read_wo_encrypt(uint16_t svc_code, uint16_t block_id, uint8_t block_data[16]);
|
||||
bool pn532_felica_write_wo_encrypt(uint16_t svc_code, uint16_t block_id, const uint8_t block_data[16]);
|
||||
bool pn532_felica_read(uint16_t svc_code, uint16_t block_id, uint8_t block_data[16]);
|
||||
bool pn532_felica_write(uint16_t svc_code, uint16_t block_id, const uint8_t block_data[16]);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user