-
Notifications
You must be signed in to change notification settings - Fork 9
/
nfc.i
1168 lines (889 loc) · 27.1 KB
/
nfc.i
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* File: nfc.i */
%module(docstring="Bindings for libnfc") nfc
%{
#include <stdbool.h>
#include "python_wrapping.h"
%}
%include <typemaps.i>
%include <exception.i>
%include <cstring.i>
%rename("%(strip:[nfc_])s") "";
%apply int { size_t };
%typemap(in) uint8_t = int;
%typemap(out) uint8_t = int;
%define uint8_t_array_member_helper(name, size)
%typemap(out) uint8_t name[size] { $result = PyByteArray_FromStringAndSize((char *)$1, size); }
%typemap(in) uint8_t name[size] %{
uint8_t * vs = (uint8_t *)fromPyBytes($input);
if (!vs)
SWIG_exception(SWIG_RuntimeError, "could not convert array argument");
int len = PySequence_Size($input);
if (len > size)
SWIG_exception(SWIG_RuntimeError, "expected at most size elements in array argument");
uint8_t res[size];
int max_len = len < size ? len : size;
memcpy(res, vs, max_len * sizeof(uint8_t));
$1 = res;
%}
%typemap(memberin) uint8_t name[size] %{
memcpy($1, $input, max_len * sizeof(uint8_t));
%}
%enddef
uint8_t_array_member_helper(abtNFCID3, 10)
uint8_t_array_member_helper(abtGB, 48)
uint8_t_array_member_helper(abtAtqa, 2)
uint8_t_array_member_helper(abtUid, 10)
uint8_t_array_member_helper(abtAts, 254)
uint8_t_array_member_helper(abtId, 8)
uint8_t_array_member_helper(abtPad, 8)
uint8_t_array_member_helper(abtSysCode, 2)
uint8_t_array_member_helper(abtPupi, 4)
uint8_t_array_member_helper(abtApplicationData, 4)
uint8_t_array_member_helper(abtProtocolInfo, 3)
uint8_t_array_member_helper(abtDIV, 4)
uint8_t_array_member_helper(abtAtr, 33)
uint8_t_array_member_helper(abtUID, 4)
uint8_t_array_member_helper(abtUID, 8)
uint8_t_array_member_helper(abtData, 32)
%typemap(typecheck,precedence=SWIG_TYPECHECK_INTEGER) uint8_t * {
$1 = checkPyBytes($input) || (checkPyInt($input) && (PyLong_AsUnsignedLong($input)==0))
}
%typemap(in) uint8_t * %{
$1 = 0;
if (checkPyBytes($input)) {
$1 = (uint8_t *)fromPyBytes($input);
}
%}
%define nfc_init_doc
"init() -> context
Initialize libnfc. This function must be called before calling any other libnfc function.
Returns
-------
context : nfc_context
Output location for nfc_context"
%enddef
%feature("autodoc", nfc_init_doc) nfc_init;
//%newobject nfc_init;
%typemap(in,numinputs=0) SWIGTYPE** OUTPUT ($*ltype temp) %{ $1 = &temp; %}
%typemap(argout) SWIGTYPE** OUTPUT %{ $result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj(*$1,$*descriptor,0)); %}
%apply SWIGTYPE** OUTPUT { nfc_context **context };
void nfc_init(nfc_context **context);
%clear nfc_context **context;
%typemap(newfree) nfc_context * "nfc_exit($1);";
%define nfc_exit_doc
"Deinitialize libnfc. Should be called after closing all open devices and before your application terminates.
Parameters
----------
context : nfc_context
Output location for nfc_context"
%enddef
%feature("autodoc", nfc_exit_doc) nfc_exit;
//%delobject nfc_exit;
void nfc_exit(nfc_context *context);
%define nfc_open_doc
"Open a NFC device.
Parameters
----------
context : nfc_context
The context to operate on.
connstring : string
The device connection string if specific device is wanted, 0 otherwise
Returns
-------
pnd : nfc_device
device if successfull, else None"
%enddef
//%feature("autodoc", nfc_open_doc) nfc_open;
//%newobject nfc_open;
%typemap(newfree) nfc_device * "nfc_close($1);";
%typemap(typecheck,precedence=SWIG_TYPECHECK_INTEGER) const nfc_connstring {
$1 = checkPyString($input) ||(checkPyInt($input) && (PyLong_AsUnsignedLong($input)==0))
}
%typemap(in) const nfc_connstring %{
$1 = 0;
if(checkPyString($input)) {
$1 = fromPyString($input);
}
%}
%typemap(default) const nfc_connstring {$1 = 0;}
nfc_device *nfc_open(nfc_context *context, const nfc_connstring connstring);
%clear nfc_device *;
%define nfc_close_doc
"Close from a NFC device.
Parameters
----------
pnd : nfc_device
device that represents the currently used device
"
%enddef
%feature("autodoc", nfc_close_doc) nfc_close;
void nfc_close(nfc_device *pnd);
//%delobject nfc_close;
%define nfc_abort_command_doc
"Abort current running command.
Parameters
----------
pnd : nfc_device
device that represents the currently used device
Returns
-------
ret : int
Returns 0 on success, otherwise returns libnfc's error code.
"
%enddef
%feature("autodoc", nfc_abort_command_doc) nfc_abort_command;
int nfc_abort_command(nfc_device *pnd);
%define nfc_list_devices_doc
"Scan for discoverable supported devices.
Only available for some drivers
Parameters
----------
context : nfc_context
The context
connstrings_len : int
size of the connstrings array
Returns
-------
connstrings : array of nfc_connstring
devices list
"
%enddef
%feature("autodoc", nfc_list_devices_doc) nfc_list_devices;
%apply SWIGTYPE** OUTPUT { nfc_connstring connstrings[] };
%typemap(in,numinputs=1) (nfc_connstring connstrings[], size_t connstrings_len) %{ $2 = PyInt_AsLong($input);$1 = (nfc_connstring *)calloc($2,sizeof(nfc_connstring)); %}
%typemap(argout) (nfc_connstring connstrings[], size_t connstrings_len) %{
PyObject * connstrings = PyList_New(result);
size_t i;
for(i = 0; i < result; ++i) {
PyObject * connstring = toPyString($1[i]);
PyList_SetItem( connstrings, i, connstring );
}
free($1);
$result = connstrings;
%}
size_t nfc_list_devices(nfc_context *context, nfc_connstring connstrings[], size_t connstrings_len);
%define nfc_idle_doc
"Turn NFC device in idle mode.
Parameters
----------
pnd : nfc_device
currently used device
"
%enddef
%feature("autodoc", nfc_idle_doc) nfc_idle;
int nfc_idle(nfc_device *pnd);
%define initiator_init_doc
"Initialize NFC device as initiator (reader)
Parameters
----------
pnd : nfc_device
currently used device
"
%enddef
int nfc_initiator_init(nfc_device *pnd);
%define nfc_initiator_nfc_init_secure_element_doc
"Initialize NFC device as initiator with its secure element initiator (reader).
Parameters
----------
pnd : nfc_device
currently used device"
%enddef
%feature("autodoc", nfc_initiator_nfc_init_secure_element_doc) nfc_initiator_init_secure_element;
int nfc_initiator_init_secure_element(nfc_device *pnd);
%define nfc_initiator_select_passive_target_doc
"Initialize NFC device as initiator with its secure element initiator (reader).
Parameters
----------
pnd : nfc_device
currently used device
nm : nfc_modulation
desired modulation
pbtInitData : bytearray
data
szInitData : int
data size
pnt : nfc_target
target
Returns
-------
ret : int
libnfc's error code
"
%enddef
// allow to interrupt this blocking call
%exception nfc_initiator_select_passive_target {
Py_BEGIN_ALLOW_THREADS
$action
Py_END_ALLOW_THREADS
}
%feature("autodoc", nfc_initiator_select_passive_target_doc) nfc_initiator_select_passive_target;
int nfc_initiator_select_passive_target(nfc_device *pnd, const nfc_modulation nm, const uint8_t *pbtInitData, const size_t szInitData, nfc_target *pnt);
%define nfc_initiator_list_passive_targets_doc
"List passive or emulated tags.
Parameters
----------
pnd : nfc_device
currently used device
nm : nfc_modulation
desired modulation
szTargets : int
size of ant (will be the max targets listed)
Returns
-------
ret : int
number of targets found on success, otherwise returns libnfc's error code (negative value)
ant : array of nfc_target
will be filled with targets info
"
%enddef
%feature("autodoc", nfc_initiator_list_passive_targets_doc) nfc_initiator_list_passive_targets;
%apply SWIGTYPE** OUTPUT { nfc_target ant[] };
%typemap(in,numinputs=1) (nfc_target ant[], const size_t szTargets) %{ $2 = PyInt_AsLong($input);$1 = (nfc_target *)calloc($2,sizeof(nfc_target)); %}
%typemap(argout) (nfc_target ant[], const size_t szTargets) %{
PyObject * ant = PyList_New(result);
int i;
for(i = 0; i < result; ++i) {
nfc_target *trg_copy = malloc(sizeof(nfc_target));
memcpy(trg_copy, &($1[i]), sizeof(nfc_target));
PyObject * target = SWIG_NewPointerObj(trg_copy,$descriptor,SWIG_POINTER_OWN);
PyList_SetItem( ant, i, target );
}
free($1);
$result = SWIG_Python_AppendOutput($result, ant);
%}
int nfc_initiator_list_passive_targets(nfc_device *pnd, const nfc_modulation nm, nfc_target ant[], const size_t szTargets);
%define nfc_initiator_poll_target_doc
"Poll for NFC targets.
Parameters
----------
pnd : nfc_device
currently used device
pnmTargetTypes : nfc_modulation
desired modulations
szTargets : int
size of pnmModulations
uiPollNr : int
specifies the number of polling (0x01 - 0xFE: 1 up to 254 polling, 0xFF: Endless polling)
uiPeriod : int
indicates the polling period in units of 150 ms (0x01 - 0x0F: 150ms - 2.25s)
Returns
-------
ret : int
polled targets count, otherwise returns libnfc's error code (negative value)
pnt : nfc_target
(over)writable struct
"
%enddef
// allow to interrupt this blocking call
%exception nfc_initiator_poll_target {
Py_BEGIN_ALLOW_THREADS
$action
Py_END_ALLOW_THREADS
}
%feature("autodoc", nfc_initiator_poll_target_doc) nfc_initiator_poll_target;
int nfc_initiator_poll_target(nfc_device *pnd, const nfc_modulation *pnmTargetTypes, const size_t szTargetTypes, const uint8_t uiPollNr, const uint8_t uiPeriod, nfc_target *pnt);
%define nfc_initiator_select_dep_target_doc
"Select a target and request active or passive mode for D.E.P. (Data Exchange Protocol).
Parameters
----------
pnd : nfc_device
currently used device
ndm : nfc_dep_mode
desired D.E.P. mode (NDM_ACTIVE or NDM_PASSIVE for active, respectively passive mode)
nbr : nfc_baud_rate
desired baud rate
pndiInitiator : nfc_dep_info
contains NFCID3 and General Bytes to set to the initiator device (optionnal, can be NULL)
timeout : int
timeout in milliseconds
Returns
-------
ret : int
selected D.E.P targets count on success, otherwise returns libnfc's error code (negative value).
pnt : nfc_target
(over)writable struct
"
%enddef
%feature("autodoc", nfc_initiator_select_dep_target_doc) nfc_initiator_select_dep_target;
int nfc_initiator_select_dep_target(nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info *pndiInitiator, nfc_target *pnt, const int timeout);
%define nfc_initiator_poll_dep_target_doc
"Poll a target and request active or passive mode for D.E.P. (Data Exchange Protocol).
Parameters
----------
pnd : nfc_device
currently used device
ndm :
desired D.E.P. mode (NDM_ACTIVE or NDM_PASSIVE for active, respectively passive mode)
nbr :
desired baud rate
pndiInitiator : nfc_dep_info
contains NFCID3 and General Bytes to set to the initiator device (optionnal, can be NULL)
timeout : int
timeout in milliseconds
Returns
-------
ret : int
selected D.E.P targets count on success, otherwise returns libnfc's error code (negative value).
pnt : nfc_target
where target information will be put.
"
%enddef
%feature("autodoc", nfc_initiator_poll_dep_target_doc) nfc_initiator_poll_dep_target;
int nfc_initiator_poll_dep_target(nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info *pndiInitiator, nfc_target *pnt, const int timeout);
%define nfc_initiator_deselect_target_doc
"Deselect target.
Parameters
----------
pnd : nfc_device
represents the currently used device
Returns
-------
ret : int
0 on success, otherwise returns libnfc's error code (negative value).
"
%enddef
%feature("autodoc", nfc_initiator_deselect_target_doc) nfc_initiator_deselect_target;
int nfc_initiator_deselect_target(nfc_device *pnd);
%define nfc_initiator_transceive_bytes_doc
"Send data to target then retrieve data from target.
Parameters
----------
pnd : nfc_device
currently used device
pbtTx : bytes
contains a byte array of the frame that needs to be transmitted.
szTx : int
contains the length in bytes.
szRx : int
size of pbtRx (Will return NFC_EOVFLOW if RX exceeds this size)
timeout : int
timeout in milliseconds
Returns
-------
ret : int
received bytes count on success, otherwise returns libnfc's error code
pbtRx : bytes
response from the target
"
%enddef
%feature("autodoc", nfc_initiator_transceive_bytes_doc) nfc_initiator_transceive_bytes;
%typemap(in,numinputs=1) (uint8_t *pbtRx, const size_t szRx) %{ $2 = PyInt_AsLong($input);$1 = (uint8_t *)calloc($2,sizeof(uint8_t)); %}
%typemap(argout) (uint8_t *pbtRx, const size_t szRx) %{
if (result<0)
$2=0;
$result = SWIG_Python_AppendOutput($result, PyByteArray_FromStringAndSize((char *)$1, $2)); free($1);
%}
int nfc_initiator_transceive_bytes(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, const size_t szRx, int timeout);
%define nfc_initiator_transceive_bits_doc
"Transceive raw bit-frames to a target.
Parameters
----------
pnd : nfc_device
currently used device
pbtTx : bytes
contains a byte array of the frame that needs to be transmitted.
szTxBits : int
contains the length in bits
pbtTxPar : bytes
contains a byte array of the corresponding parity bits needed to send per byte.
szRx : int
size of pbtRx (Will return NFC_EOVFLOW if RX exceeds this size)
Returns
-------
ret : int
received bits count on success, otherwise returns libnfc's error code
pbtRx : bytes
response from the target
pbtRxPar : bytes
parameter contains a byte array of the corresponding parity bits
"
%enddef
%feature("autodoc", nfc_initiator_transceive_bits_doc) nfc_initiator_transceive_bits;
%apply (uint8_t *pbtRx, const size_t szRx) { (uint8_t *pbtRx, const size_t szTxBits) };
int nfc_initiator_transceive_bits(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, uint8_t *pbtRx, const size_t szRx, uint8_t *pbtRxPar);
%define nfc_initiator_transceive_bytes_timed_doc
"Send data to target then retrieve data from target.
Parameters
----------
pnd : nfc_device
currently used device
pbtTx : bytes
contains a byte array of the frame that needs to be transmitted
szTx : int
contains the length in bytes
pbtTxPar : bytes
contains a byte array of the corresponding parity bits needed to send per byte.
szRx : int
size of pbtRx (Will return NFC_EOVFLOW if RX exceeds this size)
Returns
-------
ret : int
received bytes count on success, otherwise returns libnfc's error code
pbtRx : bytes
response from the target
cycles : int
number of cycles
"
%enddef
%feature("autodoc", nfc_initiator_transceive_bytes_timed_doc) nfc_initiator_transceive_bytes_timed;
%typemap(in,numinputs=0) uint32_t *cycles ($*ltype temp) %{ temp = 0; $1 = &temp; %}
%typemap(argout) uint32_t *cycles %{ $result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj(*$1,$*descriptor,0)); %}
int nfc_initiator_transceive_bytes_timed(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, uint8_t *pbtRx, const size_t szRx, uint32_t *cycles);
%define nfc_initiator_transceive_bits_timed_doc
"Transceive raw bit-frames to a target.
Parameters
----------
pnd : nfc_device
currently used device
pbtTx : bytes
contains a byte array of the frame that needs to be transmitted.
szTxBits : int
contains the length in bits
pbtTxPar : bytes
contains a byte array of the corresponding parity bits needed to send per byte.
szRx : int
size of pbtRx (Will return NFC_EOVFLOW if RX exceeds this size)
Returns
-------
ret : int
received bits count on success, otherwise returns libnfc's error code
pbtRx : bytes
response from the target
cycles : int
number of cycles
"
%enddef
%feature("autodoc", nfc_initiator_transceive_bits_timed_doc) nfc_initiator_transceive_bits_timed;
int nfc_initiator_transceive_bits_timed(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, uint8_t *pbtRx, const size_t szRx, uint8_t *pbtRxPar, uint32_t *cycles);
%define nfc_target_init_doc
"Initialize NFC device as an emulated tag.
Parameters
----------
pnd : nfc_device
currently used device
pnt : nfc_target
wanted emulated target
timeout : int
timeout in milliseconds
Returns
-------
ret : int
received bits count on success, otherwise returns libnfc's error code
pbtRx : bytes
response from the target
"
%enddef
%feature("autodoc", nfc_target_init_doc) nfc_target_init;
int nfc_target_init(nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, const size_t szRx, int timeout);
%define nfc_target_send_bytes_doc
"Send bytes and APDU frames.
Parameters
----------
pnd : nfc_device
currently used device
pbtTx : bytes
Tx buffer
timeout : int
timeout in milliseconds
Returns
-------
ret : int
sent bytes count on success, otherwise returns libnfc's error code
"
%enddef
%feature("autodoc", nfc_target_send_bytes_doc) nfc_target_send_bytes;
int nfc_target_send_bytes(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, int timeout);
%define nfc_target_receive_bytes_doc
"Receive bytes and APDU frames.
Parameters
----------
pnd : nfc_device
currently used device
pbtTx : bytes
Tx buffer
szRx : int
size of Rx buffer
timeout : int
timeout in milliseconds
Returns
-------
ret : int
received bytes count on success, otherwise returns libnfc's error code
pbtTx : bytes
Rx buffer
"
%enddef
%feature("autodoc", nfc_target_receive_bytes_doc) nfc_target_receive_bytes;
int nfc_target_receive_bytes(nfc_device *pnd, uint8_t *pbtRx, const size_t szRx, int timeout);
%define nfc_target_send_bits_doc
"Send raw bit-frames.
Parameters
----------
pnd : nfc_device
currently used device
pbtTx : bytes
Tx buffer
pbtTxPar : bytes
a byte array of the corresponding parity bits
Returns
-------
ret : int
sent bits count on success, otherwise returns libnfc's error code
"
%enddef
%feature("autodoc", nfc_target_send_bytes_doc) nfc_target_send_bits;
int nfc_target_send_bits(nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar);
%define nfc_target_receive_bits_doc
"Receive bit-frames.
Parameters
----------
pnd : nfc_device
currently used device
szRx : int
size of Rx buffer
Returns
-------
ret : int
received bytes count on success, otherwise returns libnfc's error code
pbtTx : bytes
Rx buffer
pbtRxPar : bytes
parameter contains a byte array of the corresponding parity bits"
%enddef
%feature("autodoc", nfc_target_receive_bits_doc) nfc_target_receive_bits;
int nfc_target_receive_bits(nfc_device *pnd, uint8_t *pbtRx, const size_t szRx, uint8_t *pbtRxPar);
%define nfc_strerror_doc
"Return the last error string.
Parameters
----------
pnd : nfc_device
the currently used device
Returns
-------
error : string
error string"
%enddef
%feature("autodoc", nfc_strerror_doc) nfc_strerror;
const char *nfc_strerror(const nfc_device *pnd);
%define nfc_strerror_r_doc
"Render the last error in buf for a maximum size of buflen chars.
Parameters
---------
pnd : nfc_device
currently used device
buf : string
a string that contains the last error
buflen : int
size of buffer
Returns
-------
ret : int
0 upon success
"
%enddef
%feature("autodoc", nfc_strerror_r_doc) nfc_strerror_r;
int nfc_strerror_r(const nfc_device *pnd, char *buf, size_t buflen);
%define nfc_perror_doc
"Display the last error occured on a nfc_device.
Parameters
---------
pnd : nfc_device
currently used device
s : string
a string
"
%enddef
%feature("autodoc", nfc_perror_doc) nfc_perror;
void nfc_perror(const nfc_device *pnd, const char *s);
%define nfc_device_get_last_error_doc
"Return the last error occured on a nfc_device.
Parameters
---------
pnd : nfc_device
currently used device
Returns
-------
ret : int
represents libnfc's error code.
"
%enddef
%feature("autodoc", nfc_device_get_last_error_doc) nfc_device_get_last_error;
int nfc_device_get_last_error(const nfc_device *pnd);
%define nfc_device_get_name_doc
"Return the device name.
Parameters
----------
pnd : nfc_device
currently used device
Returns
-------
name : string
device name
"
%enddef
%feature("autodoc", nfc_device_get_name_doc) nfc_device_get_name;
const char *nfc_device_get_name(nfc_device *pnd);
%define nfc_device_get_connstring_doc
"Return the device connection string.
Parameters
----------
pnd : nfc_device
currently used device
Returns
-------
name : string
device connection string"
%enddef
%feature("autodoc", nfc_device_get_connstring_doc) nfc_device_get_connstring;
const char *nfc_device_get_connstring(nfc_device *pnd);
%define nfc_device_get_supported_modulation_doc
"Get supported modulations.
Parameters
----------
pnd : nfc_device
currently used device
mode : nfc_mode
mode
Returns
-------
ret : integet
0 on success, otherwise returns libnfc's error code (negative value)
supported_mt : nfc_modulation_type array
the supported modulations
"
%enddef
%feature("autodoc", nfc_device_get_supported_modulation_doc) nfc_device_get_supported_modulation;
int nfc_device_get_supported_modulation(nfc_device *pnd, const nfc_mode mode, const nfc_modulation_type **const supported_mt);
%define nfc_device_get_supported_baud_rate_doc
"Get supported baud rates.
Parameters
----------
pnd : nfc_device
currently used device
nmt : nfc_modulation_type
desired modulation
Returns
-------
ret : integer
0 on success, otherwise returns libnfc's error code (negative value)
supported_br : nfc_modulation_type array
supported baud rates
"
%enddef
%feature("autodoc", nfc_device_get_supported_baud_rate_doc) nfc_device_get_supported_baud_rate;
int nfc_device_get_supported_baud_rate(nfc_device *pnd, const nfc_modulation_type nmt, const nfc_baud_rate **const supported_br);
%define nfc_device_set_property_int_doc
"Set a device's integer-property value.
Parameters
----------
pnd : nfc_device
currently used device
property : nfc_property
property which will be set
value : int
value
Returns
-------
ret : int
0 on success, otherwise returns libnfc's error code (negative value)
"
%enddef
%feature("autodoc", nfc_device_set_property_int_doc) nfc_device_set_property_int;
int nfc_device_set_property_int(nfc_device *pnd, const nfc_property property, const int value);
%define nfc_device_set_property_bool_doc
"Set a device's boolean-property value.
Parameters
----------
pnd : nfc_device
currently used device
property : nfc_property
property which will be set
bEnable : bool
activate/disactivate the property
Returns
-------
ret : int
0 on success, otherwise returns libnfc's error code (negative value)"
%enddef
%feature("autodoc", nfc_device_set_property_bool_doc) nfc_device_set_property_bool;
int nfc_device_set_property_bool(nfc_device *pnd, const nfc_property property, const bool bEnable);
%define iso14443a_crc_doc
"iso14443a_crc(pbtData, szLen, pbtCrc)"
%enddef
%feature("autodoc", iso14443a_crc_doc) iso14443a_crc;
void iso14443a_crc(uint8_t *pbtData, size_t szLen, uint8_t *pbtCrc);
%define iso14443a_crc_append_doc
"iso14443a_crc_append(pbtData, szLen)"
%enddef
%feature("autodoc", iso14443a_crc_append_doc) iso14443a_crc_append;
void iso14443a_crc_append(uint8_t *pbtData, size_t szLen);
#ifdef NO_ISO14443B_CRC
%ignore iso14443b_crc;
%ignore iso14443b_crc_append;
#else
%define iso14443b_crc_doc
"iso14443b_crc(pbtData, szLen, pbtCrc)"
%enddef
%feature("autodoc", iso14443b_crc_doc) iso14443b_crc;
void iso14443b_crc(uint8_t *pbtData, size_t szLen, uint8_t *pbtCrc);
%define iso14443b_crc_append_doc
"iso14443b_crc_append(pbtData, szLen)"
%enddef
%feature("autodoc", iso14443b_crc_append_doc) iso14443b_crc_append;
void iso14443b_crc_append(uint8_t *pbtData, size_t szLen);
#endif
%define iso14443a_locate_historical_bytes_doc
"iso14443a_locate_historical_bytes(pbtAts, szAts, pszTk) -> ret"
%enddef
%feature("autodoc", iso14443a_locate_historical_bytes_doc) iso14443a_locate_historical_bytes;
uint8_t *iso14443a_locate_historical_bytes(uint8_t *pbtAts, size_t szAts, size_t *pszTk);
%define nfc_free_doc
"free(p)
Free buffer allocated by libnfc."
%enddef
%feature("autodoc", nfc_free_doc) nfc_free;
void nfc_free(void *p);
%define nfc_version_doc
"Return the library version.
Parameters
----------
pnd : nfc_device
currently used device
Returns
-------
version : a string with the library version"
%enddef
%feature("autodoc", nfc_version_doc) nfc_version;
const char *nfc_version(void);
%define nfc_device_get_information_about_doc
"Print information about NFC device.
Parameters
----------
pnd : nfc_device