summaryrefslogtreecommitdiff
path: root/src/hal-api-nfc.c
blob: ad25aef4b19fae0e0f115b4119690d31cf243d74 (plain)
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
/*
 * HAL (Hardware Abstract Layer) NFC API
 *
 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <stdio.h>
#include <stdint.h>
#include <dlfcn.h>
#include <dlog.h>

#include <hal/hal-common.h>

#include "hal-nfc-interface.h"
#include "hal-nfc.h"
#include "common.h"

#ifndef EXPORT
#define EXPORT __attribute__ ((visibility("default")))
#endif

#define ARRAY_SIZE(name)	(sizeof(name)/sizeof(name[0]))

static hal_backend_nfc_funcs *g_nfc_funcs = NULL;

EXPORT
int hal_nfc_get_backend(void)
{
	int ret;

	if (g_nfc_funcs)
		return 0;

	ret = hal_common_get_backend(HAL_MODULE_NFC, (void **)&g_nfc_funcs);
	if (ret < 0) {
		_E("Failed to get backend\n");
		return -EINVAL;
	}

	return 0;
}

EXPORT
int hal_nfc_put_backend(void)
{
	int ret;

	if (!g_nfc_funcs)
		return -EINVAL;

	ret = hal_common_put_backend(HAL_MODULE_NFC, (void *)g_nfc_funcs);
	if (ret < 0) {
		_E("Failed to put backend\n");
		return -EINVAL;
	}
	g_nfc_funcs = NULL;

	return 0;
}

EXPORT
bool hal_nfc_start(net_nfc_error_e *result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->start)
		return -ENOTSUP;

	return g_nfc_funcs->start(result);
}

EXPORT
bool hal_nfc_stop(void)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->stop)
		return -ENOTSUP;

	return g_nfc_funcs->stop();
}

EXPORT
bool hal_nfc_register_listener(target_detection_listener_cb target_detection_listener, se_transaction_listener_cb se_transaction_listener, llcp_event_listener_cb llcp_event_listener, hce_apdu_listener_cb hce_apdu_listener, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->register_listener)
		return -ENOTSUP;

	return g_nfc_funcs->register_listener(target_detection_listener, se_transaction_listener, llcp_event_listener, hce_apdu_listener, result);
}

EXPORT
bool hal_nfc_unregister_listener(void)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->unregister_listener)
		return -ENOTSUP;

	return g_nfc_funcs->unregister_listener();
}

EXPORT
bool hal_nfc_get_firmware_version(data_s ** data, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->get_firmware_version)
		return -ENOTSUP;

	return g_nfc_funcs->get_firmware_version(data, result);
}

EXPORT
bool hal_nfc_support_nfc(net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->support_nfc)
		return -ENOTSUP;

	return g_nfc_funcs->support_nfc(result);
}

EXPORT
bool hal_nfc_check_firmware_version(net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->check_firmware_version)
		return -ENOTSUP;

	return g_nfc_funcs->check_firmware_version(result);
}

EXPORT
bool hal_nfc_update_firmware(net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->update_firmware)
		return -ENOTSUP;

	return g_nfc_funcs->update_firmware(result);
}

EXPORT
bool hal_nfc_get_stack_information(net_nfc_stack_information_s * stack_info, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->get_stack_information)
		return -ENOTSUP;

	return g_nfc_funcs->get_stack_information(stack_info, result);
}

EXPORT
bool hal_nfc_configure_discovery(net_nfc_discovery_mode_e mode, net_nfc_event_filter_e config, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->configure_discovery)
		return -ENOTSUP;

	return g_nfc_funcs->configure_discovery(mode, config, result);
}

EXPORT
bool hal_nfc_check_target_presence(net_nfc_target_handle_s * handle, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->check_target_presence)
		return -ENOTSUP;

	return g_nfc_funcs->check_target_presence(handle, result);
}

EXPORT
bool hal_nfc_connect(net_nfc_target_handle_s * handle, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->connect)
		return -ENOTSUP;

	return g_nfc_funcs->connect(handle, result);
}

EXPORT
bool hal_nfc_disconnect(net_nfc_target_handle_s * handle, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->disconnect)
		return -ENOTSUP;

	return g_nfc_funcs->disconnect(handle, result);
}

EXPORT
bool hal_nfc_check_ndef(net_nfc_target_handle_s * handle, uint8_t * ndef_card_state, int *max_data_size, int *real_data_size, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->check_ndef)
		return -ENOTSUP;

	return g_nfc_funcs->check_ndef(handle, ndef_card_state, max_data_size, real_data_size, result);
}

EXPORT
bool hal_nfc_read_ndef(net_nfc_target_handle_s * handle, data_s ** data, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->read_ndef)
		return -ENOTSUP;

	return g_nfc_funcs->read_ndef(handle, data, result);
}

EXPORT
bool hal_nfc_write_ndef(net_nfc_target_handle_s * handle, data_s * data, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->write_ndef)
		return -ENOTSUP;

	return g_nfc_funcs->write_ndef(handle, data, result);
}

EXPORT
bool hal_nfc_make_read_only_ndef(net_nfc_target_handle_s * handle, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->make_read_only_ndef)
		return -ENOTSUP;

	return g_nfc_funcs->make_read_only_ndef(handle, result);
}

EXPORT
bool hal_nfc_format_ndef(net_nfc_target_handle_s * handle, data_s * secure_key, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->format_ndef)
		return -ENOTSUP;

	return g_nfc_funcs->format_ndef(handle, secure_key, result);
}

EXPORT
bool hal_nfc_transceive(net_nfc_target_handle_s * handle, net_nfc_transceive_info_s * info, data_s ** data, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->transceive)
		return -ENOTSUP;

	return g_nfc_funcs->transceive(handle, info, data, result);
}

EXPORT
bool hal_nfc_exception_handler(void)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->exception_handler)
		return -ENOTSUP;

	return g_nfc_funcs->exception_handler();
}

EXPORT
bool hal_nfc_is_ready(net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->is_ready)
		return -ENOTSUP;

	return g_nfc_funcs->is_ready(result);
}

/* llcp api */

EXPORT
bool hal_nfc_llcp_config(net_nfc_llcp_config_info_s * config, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->llcp_config)
		return -ENOTSUP;

	return g_nfc_funcs->llcp_config(config, result);
}

EXPORT
bool hal_nfc_llcp_check_llcp(net_nfc_target_handle_s * handle, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->llcp_check_llcp)
		return -ENOTSUP;

	return g_nfc_funcs->llcp_check_llcp(handle, result);
}

EXPORT
bool hal_nfc_llcp_activate_llcp(net_nfc_target_handle_s * handle, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->llcp_activate_llcp)
		return -ENOTSUP;

	return g_nfc_funcs->llcp_activate_llcp(handle, result);
}

EXPORT
bool hal_nfc_llcp_create_socket(net_nfc_llcp_socket_t * socket, net_nfc_socket_type_e socketType, uint16_t miu, uint8_t rw, net_nfc_error_e * result, void *user_param)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->llcp_create_socket)
		return -ENOTSUP;

	return g_nfc_funcs->llcp_create_socket(socket, socketType, miu, rw, result, user_param);
}

EXPORT
bool hal_nfc_llcp_bind(net_nfc_llcp_socket_t socket, uint8_t service_access_point, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->llcp_bind)
		return -ENOTSUP;

	return g_nfc_funcs->llcp_bind(socket, service_access_point, result);
}

EXPORT
bool hal_nfc_llcp_listen(net_nfc_target_handle_s * handle, uint8_t * service_access_name, net_nfc_llcp_socket_t socket, net_nfc_error_e * result, void *user_param)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->llcp_listen)
		return -ENOTSUP;

	return g_nfc_funcs->llcp_listen(handle, service_access_name, socket, result, user_param);
}

EXPORT
bool hal_nfc_llcp_accept(net_nfc_llcp_socket_t socket, net_nfc_error_e * result, void *user_param)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->llcp_accept)
		return -ENOTSUP;

	return g_nfc_funcs->llcp_accept(socket, result, user_param);
}

EXPORT
bool hal_nfc_llcp_connect_by_url(net_nfc_target_handle_s * handle, net_nfc_llcp_socket_t socket, uint8_t * service_access_name, net_nfc_error_e * result, void *user_param)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->llcp_connect_by_url)
		return -ENOTSUP;

	return g_nfc_funcs->llcp_connect_by_url(handle, socket, service_access_name, result, user_param);
}

EXPORT
bool hal_nfc_llcp_connect(net_nfc_target_handle_s * handle, net_nfc_llcp_socket_t socket, uint8_t service_access_point, net_nfc_error_e * result, void *user_param)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->llcp_connect)
		return -ENOTSUP;

	return g_nfc_funcs->llcp_connect(handle, socket, service_access_point, result, user_param);
}

EXPORT
bool hal_nfc_llcp_disconnect(net_nfc_target_handle_s * handle, net_nfc_llcp_socket_t socket, net_nfc_error_e * result, void *user_param)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->llcp_disconnect)
		return -ENOTSUP;

	return g_nfc_funcs->llcp_disconnect(handle, socket, result, user_param);
}

EXPORT
bool hal_nfc_llcp_socket_close(net_nfc_llcp_socket_t socket, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->llcp_socket_close)
		return -ENOTSUP;

	return g_nfc_funcs->llcp_socket_close(socket, result);
}

EXPORT
bool hal_nfc_llcp_recv(net_nfc_target_handle_s * handle, net_nfc_llcp_socket_t socket, data_s * data, net_nfc_error_e * result, void *user_param)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->llcp_recv)
		return -ENOTSUP;

	return g_nfc_funcs->llcp_recv(handle, socket, data, result, user_param);
}

EXPORT
bool hal_nfc_llcp_send(net_nfc_target_handle_s * handle, net_nfc_llcp_socket_t socket, data_s * data, net_nfc_error_e * result, void *user_param)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->llcp_send)
		return -ENOTSUP;

	return g_nfc_funcs->llcp_send(handle, socket, data, result, user_param);
}

EXPORT
bool hal_nfc_llcp_recv_from(net_nfc_target_handle_s * handle, net_nfc_llcp_socket_t socket, data_s * data, net_nfc_error_e * result, void *user_param)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->llcp_recv_from)
		return -ENOTSUP;

	return g_nfc_funcs->llcp_recv_from(handle, socket, data, result, user_param);
}

EXPORT
bool hal_nfc_llcp_send_to(net_nfc_target_handle_s * handle, net_nfc_llcp_socket_t socket, data_s * data, uint8_t service_access_point, net_nfc_error_e * result, void *user_param)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->llcp_send_to)
		return -ENOTSUP;

	return g_nfc_funcs->llcp_send_to(handle, socket, data, service_access_point, result, user_param);
}

EXPORT
bool hal_nfc_llcp_reject(net_nfc_target_handle_s * handle, net_nfc_llcp_socket_t socket, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->llcp_reject)
		return -ENOTSUP;

	return g_nfc_funcs->llcp_reject(handle, socket, result);
}

EXPORT
bool hal_nfc_llcp_get_remote_config(net_nfc_target_handle_s * handle, net_nfc_llcp_config_info_s * config, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->llcp_get_remote_config)
		return -ENOTSUP;

	return g_nfc_funcs->llcp_get_remote_config(handle, config, result);
}

EXPORT
bool hal_nfc_llcp_get_remote_socket_info(net_nfc_target_handle_s * handle, net_nfc_llcp_socket_t socket, net_nfc_llcp_socket_option_s * option, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->llcp_get_remote_socket_info)
		return -ENOTSUP;

	return g_nfc_funcs->llcp_get_remote_socket_info(handle, socket, option, result);
}

/* secure element api */

EXPORT
bool hal_nfc_secure_element_open(net_nfc_secure_element_type_e element_type, net_nfc_target_handle_s ** handle, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->secure_element_open)
		return -ENOTSUP;

	return g_nfc_funcs->secure_element_open(element_type, handle, result);
}

EXPORT
bool hal_nfc_secure_element_get_atr(net_nfc_target_handle_s * handle, data_s ** atr, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->secure_element_get_atr)
		return -ENOTSUP;

	return g_nfc_funcs->secure_element_get_atr(handle, atr, result);
}

EXPORT
bool hal_nfc_secure_element_send_apdu(net_nfc_target_handle_s * handle, data_s * command, data_s ** response, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->secure_element_send_apdu)
		return -ENOTSUP;

	return g_nfc_funcs->secure_element_send_apdu(handle, command, response, result);
}

EXPORT
bool hal_nfc_secure_element_close(net_nfc_target_handle_s * handle, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->secure_element_close)
		return -ENOTSUP;

	return g_nfc_funcs->secure_element_close(handle, result);
}

EXPORT
bool hal_nfc_get_secure_element_list(net_nfc_secure_element_info_s * list, int *count, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->get_secure_element_list)
		return -ENOTSUP;

	return g_nfc_funcs->get_secure_element_list(list, count, result);
}

EXPORT
bool hal_nfc_set_secure_element_mode(net_nfc_secure_element_type_e element_type, net_nfc_secure_element_mode_e mode, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->set_secure_element_mode)
		return -ENOTSUP;

	return g_nfc_funcs->set_secure_element_mode(element_type, mode, result);
}

/* test api */

EXPORT
bool hal_nfc_sim_test(net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->sim_test)
		return -ENOTSUP;

	return g_nfc_funcs->sim_test(result);
}

EXPORT
bool hal_nfc_prbs_test(net_nfc_error_e * result, uint32_t tech, uint32_t rate)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->prbs_test)
		return -ENOTSUP;

	return g_nfc_funcs->prbs_test(result, tech, rate);
}

EXPORT
bool hal_nfc_test_mode_on(net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->test_mode_on)
		return -ENOTSUP;

	return g_nfc_funcs->test_mode_on(result);
}

EXPORT
bool hal_nfc_test_mode_off(net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->test_mode_off)
		return -ENOTSUP;

	return g_nfc_funcs->test_mode_off(result);
}

EXPORT
bool hal_nfc_eedata_register_set(net_nfc_error_e * result, uint32_t mode, uint32_t reg_id, data_s * data)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->eedata_register_set)
		return -ENOTSUP;

	return g_nfc_funcs->eedata_register_set(result, mode, reg_id, data);
}

EXPORT
bool hal_nfc_ese_test(net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->ese_test)
		return -ENOTSUP;

	return g_nfc_funcs->ese_test(result);
}

EXPORT
bool hal_nfc_test_set_se_tech_type(net_nfc_error_e * result, net_nfc_se_type_e type, uint32_t tech)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->test_set_se_tech_type)
		return -ENOTSUP;

	return g_nfc_funcs->test_set_se_tech_type(result, type, tech);
}

/* hce api */

EXPORT
bool hal_nfc_hce_response_apdu(net_nfc_target_handle_s * handle, data_s * response, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->hce_response_apdu)
		return -ENOTSUP;

	return g_nfc_funcs->hce_response_apdu(handle, response, result);
}

EXPORT
bool hal_nfc_secure_element_route_aid(data_s * aid, net_nfc_se_type_e se_type, int power, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->secure_element_route_aid)
		return -ENOTSUP;

	return g_nfc_funcs->secure_element_route_aid(aid, se_type, power, result);
}

EXPORT
bool hal_nfc_secure_element_unroute_aid(data_s * aid, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->secure_element_unroute_aid)
		return -ENOTSUP;

	return g_nfc_funcs->secure_element_unroute_aid(aid, result);
}

EXPORT
bool hal_nfc_secure_element_commit_routing(net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->secure_element_commit_routing)
		return -ENOTSUP;

	return g_nfc_funcs->secure_element_commit_routing(result);
}

EXPORT
bool hal_nfc_secure_element_set_default_route(net_nfc_se_type_e switch_on, net_nfc_se_type_e switch_off, net_nfc_se_type_e battery_off, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->secure_element_set_default_route)
		return -ENOTSUP;

	return g_nfc_funcs->secure_element_set_default_route(switch_on, switch_off, battery_off, result);
}

EXPORT
bool hal_nfc_secure_element_clear_aid_table(net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->secure_element_clear_aid_table)
		return -ENOTSUP;

	return g_nfc_funcs->secure_element_clear_aid_table(result);
}

EXPORT
bool hal_nfc_secure_element_get_aid_table_size(int *AIDTableSize, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->secure_element_get_aid_table_size)
		return -ENOTSUP;

	return g_nfc_funcs->secure_element_get_aid_table_size(AIDTableSize, result);
}

EXPORT
bool hal_nfc_secure_element_set_route_entry(net_nfc_se_entry_type_e type, net_nfc_se_tech_protocol_type_e value, net_nfc_se_type_e route, int power, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->secure_element_set_route_entry)
		return -ENOTSUP;

	return g_nfc_funcs->secure_element_set_route_entry(type, value, route, power, result);
}

EXPORT
bool hal_nfc_secure_element_clear_routing_entry(net_nfc_se_entry_type_e type, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->secure_element_clear_routing_entry)
		return -ENOTSUP;

	return g_nfc_funcs->secure_element_clear_routing_entry(type, result);
}

EXPORT
bool hal_nfc_secure_element_set_listen_tech_mask(net_nfc_se_tech_protocol_type_e screen_state, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->secure_element_set_listen_tech_mask)
		return -ENOTSUP;

	return g_nfc_funcs->secure_element_set_listen_tech_mask(screen_state, result);
}

EXPORT
bool hal_nfc_set_screen_state(net_nfc_screen_state_type_e screen_state, net_nfc_error_e * result)
{
	if (!g_nfc_funcs)
		return -ENOTSUP;
	if (!g_nfc_funcs->set_screen_state)
		return -ENOTSUP;

	return g_nfc_funcs->set_screen_state(screen_state, result);
}