1little_endian_packets
2
3/// Packet specification for [NCI] NFC Controller Interface Technical
4/// Specification Version 2.2
5
6enum PacketBoundaryFlag : 1 {
7  COMPLETE_OR_FINAL = 0,
8  INCOMPLETE = 1,
9}
10
11enum MessageType : 3 {
12  DATA = 0,
13  COMMAND = 1,
14  RESPONSE = 2,
15  NOTIFICATION = 3,
16}
17
18enum GroupId : 4 {
19  CORE = 0x0,
20  RF_MANAGEMENT = 0x1,
21  NFCEE_MANAGEMENT = 0x2,
22  NFCC_MANAGEMENT = 0x3,
23  TEST_MANAGEMENT = 0x4,
24  PROPRIETARY = 0xF,
25}
26
27enum CoreOpcodeId : 6 {
28  RESET = 0x0,
29  INIT = 0x1,
30  SET_CONFIG = 0x2,
31  GET_CONFIG = 0x3,
32  CONN_CREATE = 0x4,
33  CONN_CLOSE = 0x5,
34  CONN_CREDITS = 0x6,
35  GENERIC_ERROR = 0x7,
36  INTERFACE_ERROR = 0x8,
37  SET_POWER_SUB_STATE = 0x9,
38  RFU = 0xa..0x3f,
39}
40
41enum RfOpcodeId : 6 {
42  DISCOVER_MAP = 0x0,
43  SET_LISTEN_MODE_ROUTING = 0x1,
44  GET_LISTEN_MODE_ROUTING = 0x2,
45  DISCOVER = 0x3,
46  DISCOVER_SELECT = 0x4,
47  INTF_ACTIVATED = 0x5,
48  DEACTIVATE = 0x6,
49  FIELD_INFO = 0x7,
50  T3T_POLLING = 0x8,
51  NFCEE_ACTION = 0x9,
52  NFCEE_DISCOVERY_REQ = 0xa,
53  PARAMETER_UPDATE = 0xb,
54  INTF_EXT_START = 0xc,
55  INTF_EXT_STOP = 0xd,
56  EXT_AGG_ABORT = 0xe,
57  NDEF_ABORT = 0xf,
58  ISO_DEP_NAK_PRESENCE = 0x10,
59  SET_FORCED_NFCEE_ROUTING_CMD = 0x11,
60  RFU = 0x12..0x3f,
61}
62
63enum NfceeOpcodeId : 6 {
64  DISCOVER = 0x0,
65  MODE_SET = 0x1,
66  STATUS = 0x2,
67  POWER_AND_LINK_CNTRL = 0x3,
68  RFU = 0x4..0x3f,
69}
70
71enum ProprietaryOpcodeId : 6 {
72  ANDROID = 0xC,
73}
74
75enum AndroidSubOpcodeId : 8 {
76  GET_CAPS = 0x0,
77  PASSIVE_OBSERVE_MODE = 0x2,
78  POLLING_FRAME = 0x3,
79  QUERY_PASSIVE_OBSERVE_MODE = 0x4,
80}
81
82enum Status : 8 {
83  OK = 0x00,
84  REJECTED = 0x01,
85  FAILED = 0x03,
86  NOT_INITIALIZED = 0x04,
87  SYNTAX_ERROR = 0x05,
88  SEMANTIC_ERROR = 0x06,
89  INVALID_PARAM = 0x09,
90  MESSAGE_SIZE_EXCEEDED = 0x0A,
91  OK_1_BIT = 0x11,
92  OK_2_BIT = 0x12,
93  OK_3_BIT = 0x13,
94  OK_4_BIT = 0x14,
95  OK_5_BIT = 0x15,
96  OK_6_BIT = 0x16,
97  OK_7_BIT = 0x17,
98  DISCOVERY_ALREADY_STARTED = 0xA0,
99  DISCOVERY_TARGET_ACTIVATION_FAILED = 0xA1,
100  DISCOVERY_TEAR_DOWN = 0xA2,
101  RF_FRAME_CORRUPTED = 0x02,
102  RF_TRANSMISSION_EXCEPTION = 0xB0,
103  RF_PROTOCOL_EXCEPTION = 0xB1,
104  RF_TIMEOUT_EXCEPTION = 0xB2,
105  RF_UNEXPECTED_DATA = 0xB3,
106  NFCEE_INTERFACE_ACTIVATION_FAILED = 0xC0,
107  NFCEE_TRANSMISSION_ERROR = 0xC1,
108  NFCEE_PROTOCOL_ERROR = 0xC2,
109  NFCEE_TIMEOUT_ERROR = 0xC3,
110}
111
112// [NCI] Table 4: Conn ID
113enum ConnId : 4 {
114  STATIC_RF = 0x0,
115  STATIC_HCI = 0x1,
116  DYNAMIC = 0x2 .. 0xf,
117}
118
119// [NCI] Table 67: RF Discovery ID
120enum RfDiscoveryId : 8 {
121  ID = 0x01 .. 0xfe,
122  RFU = ..,
123}
124
125// [NCI] Table 116: NFCEE IDs
126enum NfceeId : 8 {
127  DH = 0x00,
128  HCI_NETWORK = 0x01,
129  NFCEE = 0x10 .. 0x7f,
130  HCI_NFCEE = 0x80 .. 0xfe,
131}
132
133// Generic format for NCI packet headers.
134// The Control and Data packets differ in the reserved fields
135// but the framing information is the same.
136packet PacketHeader {
137  _reserved_ : 4,
138  pbf : PacketBoundaryFlag,
139  mt : MessageType,
140  _reserved_ : 8,
141  payload_length : 8,
142}
143
144// Pre-framed NCI control packet. The framing information is ignored
145// including the payload length.
146packet ControlPacket {
147  gid : GroupId,
148  _reserved_ : 1,
149  mt : MessageType,
150  _payload_,
151}
152
153// Pre-framed NCI data packet. The framing information is ignored
154// including the payload length.
155packet DataPacket {
156  conn_id : ConnId,
157  _reserved_ : 1,
158  mt : MessageType,
159  cr : 2,
160  _reserved_ : 6,
161  _reserved_ : 8,
162  _payload_,
163}
164
165packet CorePacket : ControlPacket (gid = CORE) {
166  oid : CoreOpcodeId,
167  _reserved_ : 2,
168  _reserved_ : 8,
169  _payload_,
170}
171
172enum ResetType : 8 {
173  KEEP_CONFIG = 0,
174  RESET_CONFIG = 1,
175}
176
177packet CoreResetCommand : CorePacket (mt = COMMAND, oid = RESET) {
178  reset_type : ResetType
179}
180
181packet CoreResetResponse : CorePacket (mt = RESPONSE, oid = RESET) {
182  status : Status
183}
184
185enum ResetTrigger : 8 {
186  UNRECOVERABLE_ERROR = 0,
187  POWER_ON = 1,
188  RESET_COMMAND = 2,
189}
190
191enum ConfigStatus : 8 {
192  CONFIG_KEPT = 0x00,
193  CONFIG_RESET = 0x01,
194}
195
196enum NciVersion : 8 {
197  VERSION_1_0 = 0x10,
198  VERSION_1_1 = 0x11,
199  VERSION_2_0 = 0x20,
200  VERSION_2_1 = 0x21,
201  VERSION_2_2 = 0x22,
202}
203
204packet CoreResetNotification : CorePacket (mt = NOTIFICATION, oid = RESET) {
205  trigger : ResetTrigger,
206  config_status : ConfigStatus,
207  nci_version : NciVersion,
208  manufacturer_id: 8,
209  _size_(manufacturer_specific_information) : 8,
210  manufacturer_specific_information : 8[],
211}
212
213struct FeatureEnable {
214  _reserved_ : 16,
215}
216
217packet CoreInitCommand : CorePacket (mt = COMMAND, oid = INIT) {
218  feature_enable : FeatureEnable,
219}
220
221enum FeatureFlag : 1 {
222  DISABLED = 0,
223  ENABLED = 1,
224}
225
226enum DiscoveryConfigurationMode : 2 {
227  DH_ONLY = 0x0,
228  DH_AND_NFCEE = 0x1,
229}
230
231struct NfccFeatures {
232  discovery_frequency_configuration : FeatureFlag,
233  discovery_configuration_mode : DiscoveryConfigurationMode,
234  hci_network_support : FeatureFlag,
235  active_communication_mode : FeatureFlag,
236  _reserved_ : 3,
237  _reserved_: 1,
238  technology_based_routing : FeatureFlag,
239  protocol_based_routing : FeatureFlag,
240  aid_based_routing : FeatureFlag,
241  system_code_based_routing : FeatureFlag,
242  apdu_pattern_based_routing : FeatureFlag,
243  forced_nfcee_routing : FeatureFlag,
244  _reserved_ : 1,
245  battery_off_state : FeatureFlag,
246  switched_off_state : FeatureFlag,
247  switched_on_substates : FeatureFlag,
248  rf_configuration_in_switched_off_state: FeatureFlag,
249  _reserved_ : 4,
250  proprietary_capabilities: 8,
251}
252
253enum RfInterfaceType : 8 {
254  NFCEE_DIRECT = 0x00,
255  FRAME = 0x01,
256  ISO_DEP = 0x02,
257  NFC_DEP = 0x03,
258  NDEF = 0x06,
259  PROPRIETARY = 0x80..0xfe,
260}
261
262enum RfInterfaceExtensionType : 8 {
263  FRAME_AGGREGATED = 0x00,
264  LLCP_SYMMETRY = 0x01,
265}
266
267struct RfInterface {
268  interface : RfInterfaceType,
269  _count_(extensions) : 8,
270  extensions : RfInterfaceExtensionType[],
271}
272
273packet CoreInitResponse : CorePacket (mt = RESPONSE, oid = INIT) {
274  status : Status,
275  nfcc_features : NfccFeatures,
276  max_logical_connections : 8,
277  max_routing_table_size : 16,
278  max_control_packet_payload_size : 8,
279  max_data_packet_payload_size : 8,
280  number_of_credits : 8,
281  max_nfcv_rf_frame_size : 16,
282  _count_(supported_rf_interfaces) : 8,
283  supported_rf_interfaces: RfInterface[],
284}
285
286enum ConfigParameterId : 8 {
287  TOTAL_DURATION = 0x00,
288  CON_DISCOVERY_PARAM = 0x02,
289  POWER_STATE = 0x03,
290  PA_BAIL_OUT = 0x08,
291  PA_DEVICES_LIMIT = 0x09,
292  PB_AFI = 0x10,
293  PB_BAIL_OUT = 0x11,
294  PB_ATTRIB_PARAM1 = 0x12,
295  PB_SENSB_REQ_PARAM = 0x13,
296  PB_DEVICES_LIMIT = 0x14,
297  PF_BIT_RATE = 0x18,
298  PF_BAIL_OUT = 0x19,
299  PF_DEVICES_LIMIT = 0x1A,
300  PI_B_H_INFO = 0x20,
301  PI_BIT_RATE = 0x21,
302  PN_NFC_DEP_PSL = 0x28,
303  PN_ATR_REQ_GEN_BYTES = 0x29,
304  PN_ATR_REQ_CONFIG = 0x2A,
305  PV_DEVICES_LIMIT = 0x2F,
306  LA_BIT_FRAME_SDD = 0x30,
307  LA_PLATFORM_CONFIG = 0x31,
308  LA_SEL_INFO = 0x32,
309  LA_NFCID1 = 0x33,
310  LB_SENSB_INFO = 0x38,
311  LB_NFCID0 = 0x39,
312  LB_APPLICATION_DATA = 0x3A,
313  LB_SFGI = 0x3B,
314  LB_FWI_ADC_FO = 0x3C,
315  LB_BIT_RATE = 0x3E,
316  LF_T3T_IDENTIFIERS_1 = 0x40,
317  LF_T3T_IDENTIFIERS_2 = 0x41,
318  LF_T3T_IDENTIFIERS_3 = 0x42,
319  LF_T3T_IDENTIFIERS_4 = 0x43,
320  LF_T3T_IDENTIFIERS_5 = 0x44,
321  LF_T3T_IDENTIFIERS_6 = 0x45,
322  LF_T3T_IDENTIFIERS_7 = 0x46,
323  LF_T3T_IDENTIFIERS_8 = 0x47,
324  LF_T3T_IDENTIFIERS_9 = 0x48,
325  LF_T3T_IDENTIFIERS_10 = 0x49,
326  LF_T3T_IDENTIFIERS_11 = 0x4A,
327  LF_T3T_IDENTIFIERS_12 = 0x4B,
328  LF_T3T_IDENTIFIERS_13 = 0x4C,
329  LF_T3T_IDENTIFIERS_14 = 0x4D,
330  LF_T3T_IDENTIFIERS_15 = 0x4E,
331  LF_T3T_IDENTIFIERS_16 = 0x4F,
332  LF_T3T_PMM_DEFAULT = 0x51, // deprecated in 2.2
333  LF_T3T_MAX = 0x52,
334  LF_T3T_FLAGS = 0x53,
335  LF_T3T_RD_ALLOWED = 0x55,
336  LF_PROTOCOL_TYPE = 0x50,
337  LI_A_RATS_TB1 = 0x58,
338  LI_A_HIST_BY = 0x59,
339  LI_B_H_INFO_RESP = 0x5A,
340  LI_A_BIT_RATE = 0x5B,
341  LI_A_RATS_TC1 = 0x5C,
342  LN_WT = 0x60,
343  LN_ATR_RES_GEN_BYTES = 0x61,
344  LN_ATR_RES_CONFIG = 0x62,
345  PACM_BIT_RATE = 0x68,
346  RF_FIELD_INFO = 0x80,
347  RF_NFCEE_ACTION = 0x81,
348  NFCDEP_OP = 0x82,
349  LLCP_VERSION = 0x83,
350  NFCC_CONFIG_CONTROL = 0x85,
351  PROP0 = 0xa0,
352  PROP1 = 0xa1,
353  PROP2 = 0xa2,
354  PROP3 = 0xa3,
355  PROP4 = 0xa4,
356  PROP5 = 0xa5,
357  RFU = ..,
358}
359
360struct ConfigParameter {
361  id : ConfigParameterId,
362  _size_(value) : 8,
363  value : 8[],
364}
365
366packet CoreSetConfigCommand : CorePacket (mt = COMMAND, oid = SET_CONFIG) {
367  _count_(parameters) : 8,
368  parameters : ConfigParameter[],
369}
370
371packet CoreSetConfigResponse : CorePacket (mt = RESPONSE, oid = SET_CONFIG) {
372  status : Status,
373  _count_(parameters) : 8,
374  parameters : ConfigParameterId[],
375}
376
377packet CoreGetConfigCommand : CorePacket (mt = COMMAND, oid = GET_CONFIG) {
378  _count_(parameters) : 8,
379  parameters : ConfigParameterId[],
380}
381
382packet CoreGetConfigResponse : CorePacket (mt = RESPONSE, oid = GET_CONFIG) {
383  status : Status,
384  _count_(parameters) : 8,
385  parameters : ConfigParameter[],
386}
387
388// [NCI] Table 133: RF Protocols
389enum RfProtocolType : 8 {
390  UNDETERMINED = 0x00,
391  T1T = 0x01,
392  T2T = 0x02,
393  T3T = 0x03,
394  ISO_DEP = 0x04,
395  NFC_DEP = 0x05,
396  T5T = 0x06,
397  NDEF = 0x07,
398}
399
400enum NfceeProtocolType : 8 {
401  APDU = 0x00,
402  RFU = 0x01,
403  T3CS = 0x02,
404  TRANSPARENT = 0x04,
405}
406
407enum DestinationType : 8 {
408  NFCC_LOOPBACK = 0x01,
409  REMOTE_NFC_ENDPOINT = 0x02,
410  NFCEE = 0x03,
411}
412
413enum DestinationSpecificParameterId : 8 {
414  RF_DISCOVERY = 0x00,
415  NFCEE = 0x01,
416}
417
418struct DestinationSpecificParameter {
419  id : DestinationSpecificParameterId,
420  _size_(value) : 8,
421  value : 8[],
422}
423
424packet CoreConnCreateCommand : CorePacket (mt = COMMAND, oid = CONN_CREATE) {
425  destination_type : DestinationType,
426  _count_(parameters) : 8,
427  parameters : DestinationSpecificParameter[],
428}
429
430packet CoreConnCreateResponse : CorePacket (mt = RESPONSE, oid = CONN_CREATE) {
431  status : Status,
432  max_data_packet_payload_size : 8,
433  initial_number_of_credits : 8,
434  conn_id : ConnId,
435  _reserved_ : 4,
436}
437
438packet CoreConnCloseCommand : CorePacket (mt = COMMAND, oid = CONN_CLOSE) {
439  conn_id : ConnId,
440  _reserved_ : 4,
441}
442
443packet CoreConnCloseResponse : CorePacket (mt = RESPONSE, oid = CONN_CLOSE) {
444  status : Status,
445}
446
447struct ConnectionCredits {
448  conn_id : ConnId,
449  _reserved_ : 4,
450  credits : 8,
451}
452
453packet CoreConnCreditsNotification : CorePacket (mt = NOTIFICATION, oid = CONN_CREDITS) {
454  _count_(connections) : 8,
455  connections : ConnectionCredits[]
456}
457
458enum PowerState : 8 {
459  SWITCHED_ON_STATE = 0x00,
460  SWITCHED_ON_SUBSTATE_1 = 0x01,
461  SWITCHED_ON_SUBSTATE_2 = 0x02,
462  SWITCHED_ON_SUBSTATE_3 = 0x03,
463}
464
465packet CoreSetPowerSubStateCommand : CorePacket (mt = COMMAND, oid = SET_POWER_SUB_STATE) {
466  power_state : PowerState,
467}
468
469packet CoreSetPowerSubStateResponse : CorePacket (mt = RESPONSE, oid = SET_POWER_SUB_STATE) {
470  status : Status,
471}
472
473packet RfPacket : ControlPacket (gid = RF_MANAGEMENT) {
474  oid : RfOpcodeId,
475  _reserved_ : 2,
476  _reserved_ : 8,
477  _payload_,
478}
479
480struct MappingConfigurationMode {
481  listen_mode : FeatureFlag,
482  poll_mode : FeatureFlag,
483  _reserved_ : 6,
484}
485
486struct MappingConfiguration {
487  rf_protocol : RfProtocolType,
488  mode : MappingConfigurationMode,
489  rf_interface : RfInterfaceType,
490}
491
492packet RfDiscoverMapCommand : RfPacket (mt = COMMAND, oid = DISCOVER_MAP) {
493  _count_(mapping_configurations) : 8,
494  mapping_configurations : MappingConfiguration[],
495}
496
497packet RfDiscoverMapResponse : RfPacket (mt = RESPONSE, oid = DISCOVER_MAP) {
498  status : Status,
499}
500
501enum ListenModeRoutingEntryType : 4 {
502  TECHNOLOGY_BASED_ROUTING = 0x0,
503  PROTOCOL_BASED_ROUTING = 0x1,
504  AID_BASED_ROUTING = 0x2,
505  SYSTEM_CODE_BASED_ROUTING = 0x3,
506  APDU_PATTERN_BASED_ROUTING = 0x4,
507}
508
509struct ListenModeRoutingEntry {
510  type : ListenModeRoutingEntryType,
511  match_longer_aids : FeatureFlag,
512  match_shorter_aids : FeatureFlag,
513  routing_blocked_for_unsupported_power_modes : FeatureFlag,
514  _reserved_ : 1,
515  _size_(value) : 8,
516  value : 8[],
517}
518
519packet RfSetListenModeRoutingCommand : RfPacket (mt = COMMAND, oid = SET_LISTEN_MODE_ROUTING) {
520  more_to_follow : 8,
521  _count_(routing_entries) : 8,
522  routing_entries : ListenModeRoutingEntry[],
523}
524
525packet RfSetListenModeRoutingResponse : RfPacket (mt = RESPONSE, oid = SET_LISTEN_MODE_ROUTING) {
526  status : Status,
527}
528
529packet RfGetListenModeRoutingCommand : RfPacket (mt = COMMAND, oid = GET_LISTEN_MODE_ROUTING) {
530}
531
532packet RfGetListenModeRoutingResponse : RfPacket (mt = RESPONSE, oid = GET_LISTEN_MODE_ROUTING) {
533  status : Status,
534  more_to_follow : 8,
535  _count_(routing_entries) : 8,
536  routing_entries : ListenModeRoutingEntry[],
537}
538
539enum RfTechnologyAndMode : 8 {
540  NFC_A_PASSIVE_POLL_MODE = 0x00,
541  NFC_B_PASSIVE_POLL_MODE = 0x01,
542  NFC_F_PASSIVE_POLL_MODE = 0x02,
543  NFC_ACTIVE_POLL_MODE = 0x03,
544  NFC_V_PASSIVE_POLL_MODE = 0x06,
545  PROPRIETARY_POLL_MODE = 0x70 .. 0x7f,
546  NFC_A_PASSIVE_LISTEN_MODE = 0x80,
547  NFC_B_PASSIVE_LISTEN_MODE = 0x81,
548  NFC_F_PASSIVE_LISTEN_MODE = 0x82,
549  NFC_ACTIVE_LISTEN_MODE = 0x83,
550  PROPRIETARY_LISTEN_MODE = 0xf0 .. 0xff,
551}
552
553struct DiscoverConfiguration {
554  technology_and_mode : RfTechnologyAndMode,
555  discovery_frequency : 8,
556}
557
558packet RfDiscoverCommand : RfPacket (mt = COMMAND, oid = DISCOVER) {
559  _count_(configurations) : 8,
560  configurations : DiscoverConfiguration[],
561}
562
563packet RfDiscoverResponse : RfPacket (mt = RESPONSE, oid = DISCOVER) {
564  status : Status,
565}
566
567enum DiscoverNotificationType : 8 {
568  LAST_NOTIFICATION = 0x0,
569  OUT_OF_RESOURCES = 0x1,
570  MORE_NOTIFICATIONS = 0x2,
571}
572
573packet RfDiscoverNotification : RfPacket (mt = NOTIFICATION, oid = DISCOVER) {
574  rf_discovery_id : RfDiscoveryId,
575  rf_protocol : RfProtocolType,
576  rf_technology_and_mode : RfTechnologyAndMode,
577  _size_(rf_technology_specific_parameters) : 8,
578  rf_technology_specific_parameters : 8[],
579  notification_type : DiscoverNotificationType,
580}
581
582/// [NCI] Table 68: Specific Parameters for NFC-A Poll Mode
583packet NfcAPollModeTechnologySpecificParameters {
584  sens_res : 16,
585  _size_(nfcid1) : 8,
586  nfcid1 : 8[],
587  _fixed_ = 1 : 8,
588  sel_res : 8,
589  _fixed_ = 0 : 8,
590}
591
592/// [NCI] Table 69: Specific Parameters for NFC-A Listen Mode
593packet NfcAListenModeTechnologySpecificParameters {
594}
595
596/// [NCI] Table 70: Specific Parameters for NFC-B Poll Mode
597packet NfcBPollModeTechnologySpecificParameters {
598  _size_(sensb_res) : 8,
599  sensb_res : 8[],
600}
601
602/// [NCI] Table 71: Specific Parameters for NFC-B Listen Mode
603packet NfcBListenModeTechnologySpecificParameters {
604  sensb_cmd : 8,
605}
606
607/// [NCI] Table 72: Specific Parameters for NFC-F Poll Mode
608packet NfcFPollModeTechnologySpecificParameters {
609  bit_rate : 8,
610  _size_(sensf_res) : 8,
611  sensf_res : 8[],
612}
613
614/// [NCI] Table 73: Specific Parameters for NFC-F Listen Mode
615packet NfcFListenModeTechnologySpecificParameters {
616  _size_(local_nfcid2) : 8,
617  local_nfcid2 : 8[],
618}
619
620/// [NCI] Table 74: Specific Parameters for NFC-V Poll Mode
621packet NfcVPollModeTechnologySpecificParameters {
622  res_flag : 8,
623  dsfid : 8,
624  uid : 8[8],
625}
626
627/// [NCI] Table 77: Control Messages to select a Discovered Target
628packet RfDiscoverSelectCommand : RfPacket (mt = COMMAND, oid = DISCOVER_SELECT) {
629  rf_discovery_id : RfDiscoveryId,
630  rf_protocol : RfProtocolType,
631  rf_interface : RfInterfaceType,
632}
633
634/// [NCI] Table 77: Control Messages to select a Discovered Target
635packet RfDiscoverSelectResponse : RfPacket (mt = RESPONSE, oid = DISCOVER_SELECT) {
636  status : Status,
637}
638
639enum BitRate : 8 {
640  BIT_RATE_106_KBIT_S = 0x00,
641  BIT_RATE_212_KBIT_S = 0x01,
642  BIT_RATE_424_KBIT_S = 0x02,
643  BIT_RATE_848_KBIT_S = 0x03,
644  BIT_RATE_1695_KBIT_S = 0x04,
645  BIT_RATE_3390_KBIT_S = 0x05,
646  BIT_RATE_6780_KBIT_S = 0x06,
647  BIT_RATE_26_KBIT_S = 0x20,
648}
649
650packet RfIntfActivatedNotification : RfPacket (mt = NOTIFICATION, oid = INTF_ACTIVATED) {
651  rf_discovery_id : RfDiscoveryId,
652  rf_interface : RfInterfaceType,
653  rf_protocol : RfProtocolType,
654  activation_rf_technology_and_mode : RfTechnologyAndMode,
655  max_data_packet_payload_size : 8,
656  initial_number_of_credits : 8,
657  _size_(rf_technology_specific_parameters) : 8,
658  rf_technology_specific_parameters : 8[],
659  data_exchange_rf_technology_and_mode : RfTechnologyAndMode,
660  data_exchange_transmit_bit_rate : BitRate,
661  data_exchange_receive_bit_rate : BitRate,
662  _size_(activation_parameters) : 8,
663  activation_parameters : 8[],
664}
665
666/// [NCI] Table 95: Activation Parameters for NFC-A/ISO-DEP Poll Mode
667packet NfcAIsoDepPollModeActivationParameters {
668  _size_(rats_response) : 8,
669  rats_response : 8[],
670}
671
672/// [NCI] Table 96: Activation Parameters for NFC-B/ISO-DEP Poll Mode
673packet NfcBIsoDepPollModeActivationParameters {
674  _size_(attrib_response) : 8,
675  attrib_response : 8[],
676}
677
678/// [NCI] Table 98: Activation Parameters for NFC-A/ISO-DEP Listen Mode
679packet NfcAIsoDepListenModeActivationParameters {
680  param : 8,
681}
682
683/// [NCI] Table 99: Activation Parameters for NFC-B/ISO-DEP Listen Mode
684packet NfcBIsoDepListenModeActivationParameters {
685  _size_(attrib_command) : 8,
686  attrib_command : 8[],
687}
688
689/// [NCI] Table 102: Activation Parameters for NFC-DEP Poll Mode
690packet NfcDepPollModeActivationParameters {
691  _size_(atr_res) : 8,
692  atr_res : 8[],
693  data_exchange_length_reduction : 8,
694}
695
696/// [NCI] Table 103: Activation Parameters for NFC-DEP Listen Mode
697packet NfcDepListenModeActivationParameters {
698  _size_(atr_req) : 8,
699  atr_req : 8[],
700  data_exchange_length_reduction : 8,
701}
702
703enum DeactivationType : 8 {
704  IDLE_MODE = 0x00,
705  SLEEP_MODE = 0x01,
706  SLEEP_AF_MODE = 0x02,
707  DISCOVERY = 0x03,
708}
709
710enum DeactivationReason : 8 {
711  DH_REQUEST = 0x00,
712  ENDPOINT_REQUEST = 0x01,
713  RF_LINK_LOSS = 0x02,
714  NFC_B_BAD_AFI = 0x03,
715  DH_REQUEST_FAILED = 0x04,
716}
717
718packet RfDeactivateCommand : RfPacket (mt = COMMAND, oid = DEACTIVATE) {
719  deactivation_type : DeactivationType,
720}
721
722packet RfDeactivateResponse : RfPacket (mt = RESPONSE, oid = DEACTIVATE) {
723  status : Status,
724}
725
726packet RfDeactivateNotification : RfPacket (mt = NOTIFICATION, oid = DEACTIVATE) {
727  deactivation_type : DeactivationType,
728  deactivation_reason : DeactivationReason,
729}
730
731// [NCI] Table 85: TLV Coding for RF Discovery Request from NFCEE
732enum InformationEntryType : 8 {
733  ADD_DISCOVERY_REQUEST = 0x00,
734  REMOVE_DISCOVERY_REQUEST = 0x01,
735}
736
737struct InformationEntry {
738  type : InformationEntryType,
739  _fixed_ = 3 : 8,
740  nfcee_id : NfceeId,
741  rf_technology_and_mode : RfTechnologyAndMode,
742  rf_protocol : RfProtocolType,
743}
744
745// [NCI] Table 84: Notification for RF Discovery Request from NFCEE
746packet RfNfceeDiscoveryReqNotification : RfPacket (mt = NOTIFICATION, oid = NFCEE_DISCOVERY_REQ) {
747  _count_ (information_entries) : 8,
748  information_entries : InformationEntry[],
749}
750
751packet NfceePacket : ControlPacket (gid = NFCEE_MANAGEMENT) {
752  oid : NfceeOpcodeId,
753  _reserved_ : 2,
754  _reserved_ : 8,
755  _payload_,
756}
757
758packet NfceeDiscoverCommand : NfceePacket (mt = COMMAND, oid = DISCOVER) {
759}
760
761packet NfceeDiscoverResponse : NfceePacket (mt = RESPONSE, oid = DISCOVER) {
762  status : Status,
763  number_of_nfcees : 8,
764}
765
766enum NfceeStatus : 8 {
767  ENABLED = 0x00,
768  DISABLED = 0x01,
769  UNRESPONSIVE = 0x02,
770}
771
772// [NCI] Table 118: TLV Coding for NFCEE Discovery
773enum NfceeInformationType : 8 {
774  HARDWARE_IDENTIFICATION = 0x00,
775  ATR_BYTES = 0x01,
776  T3T_COMMAND_SET_INTERFACE_SUPPLEMENTARY_INFORMATION = 0x02,
777  HOST_ID = 0x03,
778  NDEF_STORAGE = 0x04,
779}
780
781struct NfceeInformation {
782  type : NfceeInformationType,
783  _size_(value) : 8,
784  value : 8[],
785}
786
787enum NfceeSupplyPower : 8 {
788  NFCC_HAS_NO_CONTROL = 0x00,
789  NFCC_HAS_CONTROL = 0x01,
790}
791
792packet NfceeDiscoverNotification : NfceePacket (mt = NOTIFICATION, oid = DISCOVER) {
793  nfcee_id : NfceeId,
794  nfcee_status : NfceeStatus,
795  _count_(supported_nfcee_protocols) : 8,
796  supported_nfcee_protocols : NfceeProtocolType[],
797  _count_(nfcee_information) : 8,
798  nfcee_information : NfceeInformation[],
799  nfcee_supply_power : NfceeSupplyPower,
800}
801
802enum NfceeMode : 8 {
803  DISABLE = 0x00,
804  ENABLE = 0x01,
805}
806
807packet NfceeModeSetCommand : NfceePacket (mt = COMMAND, oid = MODE_SET) {
808  nfcee_id : NfceeId,
809  nfcee_mode : NfceeMode,
810}
811
812packet NfceeModeSetResponse : NfceePacket (mt = RESPONSE, oid = MODE_SET) {
813  status : Status,
814}
815
816packet NfceeModeSetNotification : NfceePacket (mt = NOTIFICATION, oid = MODE_SET) {
817  status : Status,
818}
819
820packet ProprietaryPacket : ControlPacket (gid = PROPRIETARY) {
821  oid : ProprietaryOpcodeId,
822  _reserved_ : 2,
823  _reserved_ : 8,
824  _payload_,
825}
826
827packet AndroidPacket : ProprietaryPacket (oid = ANDROID) {
828  android_sub_oid: AndroidSubOpcodeId,
829  _payload_,
830}
831
832packet AndroidGetCapsCommand : AndroidPacket (mt = COMMAND, android_sub_oid = GET_CAPS) {
833}
834
835enum CapTlvType: 8 {
836  PASSIVE_OBSERVER_MODE = 0x00,
837  POLLING_FRAME_NOTIFICATION = 0x01,
838  POWER_SAVING_MODE = 0x02,
839}
840
841struct CapTlv {
842  t: CapTlvType,
843  _count_(v): 8,
844  v: 8[],
845}
846
847packet AndroidGetCapsResponse : AndroidPacket (mt = RESPONSE, android_sub_oid = GET_CAPS) {
848  status: Status,
849  android_version: 16,
850  _count_(tlvs): 8,
851  tlvs: CapTlv[],
852}
853
854enum PassiveObserveMode : 8 {
855  DISABLE = 0x0,
856  ENABLE = 0x1,
857}
858
859packet AndroidPassiveObserveModeCommand : AndroidPacket(mt = COMMAND, android_sub_oid = PASSIVE_OBSERVE_MODE) {
860  passive_observe_mode: PassiveObserveMode,
861}
862
863packet AndroidPassiveObserveModeResponse : AndroidPacket(mt = RESPONSE, android_sub_oid = PASSIVE_OBSERVE_MODE) {
864  status: Status,
865}
866
867packet AndroidQueryPassiveObserveModeCommand : AndroidPacket(mt = COMMAND, android_sub_oid = QUERY_PASSIVE_OBSERVE_MODE) {
868}
869
870packet AndroidQueryPassiveObserveModeResponse : AndroidPacket(mt = RESPONSE, android_sub_oid = QUERY_PASSIVE_OBSERVE_MODE) {
871  status: Status,
872  passive_observe_mode: PassiveObserveMode,
873}
874
875enum PollingFrameType : 8 {
876  REMOTE_FIELD = 0x0,
877  REQA = 0x1,
878  REQB = 0x2,
879  REQF = 0x3,
880  WUPA = 0x4,
881  WUPB = 0x5,
882  WUPF = 0x6,
883  UNKNOWN = 0x7,
884  REQV = 0x8,
885  WUPV = 0x9,
886}
887
888struct PollingFrame {
889  type: PollingFrameType,
890  flags: 8,
891  _size_(data): 8,
892  // The timestamp is encoded in big-endian byte order,
893  // whereas other NCI definitions are little-endian.
894  timestamp: 8[4],
895  gain: 8,
896  data: 8[],
897}
898
899packet AndroidPollingLoopNotification : AndroidPacket(mt = NOTIFICATION, android_sub_oid = POLLING_FRAME) {
900  polling_frames: PollingFrame[],
901}
902