1c2fec8e0e283eec0fc63c117c5cdff97d8e95a2
[platform/hal/api/nfc.git] / include / hal-nfc-interface.h
1 /*
2  * HAL (Hardware Abstract Layer) NFC API
3  *
4  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the License);
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #ifndef __HAL_NFC_INTERFACE__
20 #define __HAL_NFC_INTERFACE__
21
22 #include <hal/hal-common-interface.h>
23 #include <stdbool.h>
24 #include <hal-nfc-types.h>
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 typedef struct _hal_backend_nfc_funcs {
31         bool (*start)(net_nfc_error_e * result);;
32         bool (*stop)(void);
33         bool (*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);
34         bool (*unregister_listener)(void);
35         bool (*get_firmware_version)(data_s ** data, net_nfc_error_e * result);
36         bool (*support_nfc)(net_nfc_error_e * result);
37         bool (*check_firmware_version)(net_nfc_error_e * result);
38         bool (*update_firmware)(net_nfc_error_e * result);
39         bool (*get_stack_information)(net_nfc_stack_information_s * stack_info, net_nfc_error_e * result);
40         bool (*configure_discovery)(net_nfc_discovery_mode_e mode, net_nfc_event_filter_e config, net_nfc_error_e * result);
41         bool (*check_target_presence)(net_nfc_target_handle_s * handle, net_nfc_error_e * result);
42         bool (*connect)(net_nfc_target_handle_s * handle, net_nfc_error_e * result);
43         bool (*disconnect)(net_nfc_target_handle_s * handle, net_nfc_error_e * result);
44         bool (*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);
45         bool (*read_ndef)(net_nfc_target_handle_s * handle, data_s ** data, net_nfc_error_e * result);
46         bool (*write_ndef)(net_nfc_target_handle_s * handle, data_s * data, net_nfc_error_e * result);
47         bool (*make_read_only_ndef)(net_nfc_target_handle_s * handle, net_nfc_error_e * result);
48         bool (*format_ndef)(net_nfc_target_handle_s * handle, data_s * secure_key, net_nfc_error_e * result);
49         bool (*transceive)(net_nfc_target_handle_s * handle, net_nfc_transceive_info_s * info, data_s ** data, net_nfc_error_e * result);
50         bool (*exception_handler)(void);
51         bool (*is_ready)(net_nfc_error_e * result);
52         bool (*llcp_config)(net_nfc_llcp_config_info_s * config, net_nfc_error_e * result);
53         bool (*llcp_check_llcp)(net_nfc_target_handle_s * handle, net_nfc_error_e * result);
54         bool (*llcp_activate_llcp)(net_nfc_target_handle_s * handle, net_nfc_error_e * result);
55         bool (*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);
56         bool (*llcp_bind)(net_nfc_llcp_socket_t socket, uint8_t service_access_point, net_nfc_error_e * result);
57         bool (*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);
58         bool (*llcp_accept)(net_nfc_llcp_socket_t socket, net_nfc_error_e * result, void *user_param);
59         bool (*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);
60         bool (*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);
61         bool (*llcp_disconnect)(net_nfc_target_handle_s * handle, net_nfc_llcp_socket_t socket, net_nfc_error_e * result, void *user_param);
62         bool (*llcp_socket_close)(net_nfc_llcp_socket_t socket, net_nfc_error_e * result);
63         bool (*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);
64         bool (*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);
65         bool (*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);
66         bool (*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);
67         bool (*llcp_reject)(net_nfc_target_handle_s * handle, net_nfc_llcp_socket_t socket, net_nfc_error_e * result);
68         bool (*llcp_get_remote_config)(net_nfc_target_handle_s * handle, net_nfc_llcp_config_info_s * config, net_nfc_error_e * result);
69         bool (*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);
70         bool (*secure_element_open)(net_nfc_secure_element_type_e element_type, net_nfc_target_handle_s ** handle, net_nfc_error_e * result);
71         bool (*secure_element_get_atr)(net_nfc_target_handle_s * handle, data_s ** atr, net_nfc_error_e * result);
72         bool (*secure_element_send_apdu)(net_nfc_target_handle_s * handle, data_s * command, data_s ** response, net_nfc_error_e * result);
73         bool (*secure_element_close)(net_nfc_target_handle_s * handle, net_nfc_error_e * result);
74         bool (*get_secure_element_list)(net_nfc_secure_element_info_s * list, int *count, net_nfc_error_e * result);
75         bool (*set_secure_element_mode)(net_nfc_secure_element_type_e element_type, net_nfc_secure_element_mode_e mode, net_nfc_error_e * result);
76         bool (*sim_test)(net_nfc_error_e * result);
77         bool (*prbs_test)(net_nfc_error_e * result, uint32_t tech, uint32_t rate);
78         bool (*test_mode_on)(net_nfc_error_e * result);
79         bool (*test_mode_off)(net_nfc_error_e * result);
80         bool (*eedata_register_set)(net_nfc_error_e * result, uint32_t mode, uint32_t reg_id, data_s * data);
81         bool (*ese_test)(net_nfc_error_e * result);
82         bool (*test_set_se_tech_type)(net_nfc_error_e * result, net_nfc_se_type_e type, uint32_t tech);
83         bool (*hce_response_apdu)(net_nfc_target_handle_s * handle, data_s * response, net_nfc_error_e * result);
84         bool (*secure_element_route_aid)(data_s * aid, net_nfc_se_type_e se_type, int power, net_nfc_error_e * result);
85         bool (*secure_element_unroute_aid)(data_s * aid, net_nfc_error_e * result);
86         bool (*secure_element_commit_routing)(net_nfc_error_e * result);
87         bool (*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);
88         bool (*secure_element_clear_aid_table)(net_nfc_error_e * result);
89         bool (*secure_element_get_aid_table_size)(int *AIDTableSize, net_nfc_error_e * result);
90         bool (*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);
91         bool (*secure_element_clear_routing_entry)(net_nfc_se_entry_type_e type, net_nfc_error_e * result);
92         bool (*secure_element_set_listen_tech_mask)(net_nfc_se_tech_protocol_type_e screen_state, net_nfc_error_e * result);
93         bool (*set_screen_state)(net_nfc_screen_state_type_e screen_state, net_nfc_error_e * result);
94 } hal_backend_nfc_funcs;
95
96 #ifdef __cplusplus
97 }
98 #endif
99 #endif /* __HAL_NFC_INTERFACE__ */