-
Notifications
You must be signed in to change notification settings - Fork 3
/
st-srx.c
31 lines (25 loc) · 853 Bytes
/
st-srx.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//
// Created by depau on 7/2/19.
//
#include <stdio.h>
#include <nfc/nfc.h>
#include "nfc-utils.h"
#include "st-srx.h"
size_t
st_srx_get_uid(nfc_device *pnd, uint8_t *uidRx, bool verbose) {
uint8_t cmd[] = {0x0b};
return transceive_bytes(pnd, (const uint8_t *) &cmd, uidRx, sizeof(cmd), verbose);
}
size_t
st_srx_read_block(nfc_device *pnd, uint8_t *blockRx, uint8_t address, bool verbose) {
uint8_t cmd[2] = {0x08};
memcpy(cmd + 1, &address, 1);
return transceive_bytes(pnd, (const uint8_t *) &cmd, blockRx, sizeof(cmd), verbose);
}
size_t
st_srx_write_block(nfc_device *pnd, uint8_t *blockRx, uint8_t address, uint8_t *data, bool verbose) {
uint8_t cmd[6] = {0x09};
memcpy(cmd + 1, &address, 1);
memcpy(cmd + 2, data, 4);
return transceive_bytes(pnd, (const uint8_t *) &cmd, blockRx, sizeof(cmd), verbose);
}