Loading...
Searching...
No Matches
felica_poller_i.h
1#pragma once
2
3#include "felica_poller.h"
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
10#define FELICA_POLLER_MAX_BUFFER_SIZE (256U)
11
12#define FELICA_POLLER_POLLING_FWT (200000U)
13
14// FeliCa spec section 4.4.3: 1 ≤ n ≤ 32
15#define FELICA_REQUEST_SERVICE_MAX_NODES (32U)
16
17#define FELICA_POLLER_CMD_POLLING_REQ_CODE (0x00U)
18#define FELICA_POLLER_CMD_POLLING_RESP_CODE (0x01U)
19
21typedef enum {
22 FelicaPollerCommandClassVariable,
23 FelicaPollerCommandClassFixed,
24 FelicaPollerCommandClassMutualAuth,
25 FelicaPollerCommandClassRead,
26 FelicaPollerCommandClassWrite,
27 FelicaPollerCommandClassOther,
28} FelicaPollerCommandClass;
29
30typedef enum {
31 FelicaPollerStateIdle,
32 FelicaPollerStateActivated,
33 FelicaPollerStateListSystem,
34 FelicaPollerStateSelectSystemIndex,
35 FelicaPollerStateAuthenticateInternal,
36 FelicaPollerStateAuthenticateExternal,
37 FelicaPollerStateTraverseStandardSystem,
38 FelicaPollerStateReadStandardBlocks,
39 FelicaPollerStateReadLiteBlocks,
40 FelicaPollerStateReadSuccess,
41 FelicaPollerStateReadFailed,
42
43 FelicaPollerStateNum
44} FelicaPollerState;
45
47 Nfc* nfc;
48 FelicaPollerState state;
50
51 FelicaData* data;
52 BitBuffer* tx_buffer;
53 BitBuffer* rx_buffer;
54
55 NfcGenericEvent general_event;
56 FelicaPollerEvent felica_event;
57 FelicaPollerEventData felica_event_data;
58 NfcGenericCallback callback;
59 uint8_t block_index;
60 uint8_t systems_read;
61 uint8_t systems_total;
62 // IDm/PMm obtained from the initial (wildcard) activation Polling - this is the
63 // card's own identity, distinct from whatever System is currently selected via
64 // instance->data->idm while traversing. Restored into instance->data on success/
65 // failure so the saved/displayed IDm always reflects the card, not the last
66 // System visited.
67 FelicaIDm card_idm;
68 FelicaPMm card_pmm;
69 void* context;
70};
71
72typedef struct {
73 uint16_t system_code;
74 uint8_t request_code;
75 uint8_t time_slot;
77
78typedef struct {
79 FelicaIDm idm;
80 FelicaPMm pmm;
81 uint8_t request_data[2];
83
84typedef union {
85 FelicaData* data;
87
88const FelicaData* felica_poller_get_data(FelicaPoller* instance);
89
98FelicaError felica_poller_polling(
99 FelicaPoller* instance,
102
113FelicaError felica_poller_write_blocks(
114 const FelicaPoller* instance,
115 const uint8_t block_count,
116 const uint8_t* const block_numbers,
117 const uint8_t* data,
118 FelicaPollerWriteCommandResponse** const response_ptr);
119
132FelicaError felica_poller_frame_exchange(
133 const FelicaPoller* instance,
134 const BitBuffer* tx_buffer,
135 BitBuffer* rx_buffer,
136 uint32_t fwt);
137
146uint32_t felica_poller_get_fwt(
147 const FelicaPoller* instance,
148 FelicaPollerCommandClass command_class,
149 uint8_t units);
150
151FelicaError felica_poller_list_service_by_cursor(
152 FelicaPoller* instance,
153 uint16_t cursor,
154 FelicaListServiceCommandResponse** response_ptr);
155
156FelicaError felica_poller_list_system_code(
157 FelicaPoller* instance,
159
160FelicaError felica_poller_request_service(
161 FelicaPoller* instance,
162 const uint16_t* codes,
163 uint8_t code_count,
164 uint16_t* key_versions_out);
165
166#ifdef __cplusplus
167}
168#endif
Bit Buffer.
NfcCommand(* NfcGenericCallback)(NfcGenericEvent event, void *context)
Generic Nfc event callback type.
Definition nfc_generic_event.h:75
Definition bit_buffer.c:7
Structure used to hold authentication related fields.
Definition felica.h:147
Definition felica.h:246
Structure used to store Felica data and additional values about reading.
Definition felica.h:226
Felica ID block.
Definition felica.h:154
Definition felica.h:285
Felica PMm block.
Definition felica.h:159
FelicaPoller poller event structure.
Definition felica_poller.h:40
Definition felica_poller_i.h:46
Definition felica_poller_i.h:72
Definition felica_poller_i.h:78
Generic Nfc event type.
Definition nfc_generic_event.h:58
Definition nfc.c:44
Definition felica_poller_i.h:84
Felica poller event data.
Definition felica_poller.h:30