diff options
author | Jihoon Jung <jh8801.jung@samsung.com> | 2021-01-13 16:01:40 +0900 |
---|---|---|
committer | Jihoon Jung <jh8801.jung@samsung.com> | 2021-02-08 14:50:15 +0900 |
commit | f6ac343927ac5437ae67393573ef1e96b849f26b (patch) | |
tree | 5dc7193173add1b5ac6a057796f073665469cdf2 | |
parent | 44ce5f2fe60b3e9f48017e2742992283c3ae6d47 (diff) | |
download | nfc-f6ac343927ac5437ae67393573ef1e96b849f26b.tar.gz nfc-f6ac343927ac5437ae67393573ef1e96b849f26b.tar.bz2 nfc-f6ac343927ac5437ae67393573ef1e96b849f26b.zip |
NFC hal : Implementation of HAL interfacesubmit/tizen/20210209.075006submit/tizen/20210208.055328
Change-Id: I7e19c95f8de214f8beeda7101e1a2e31bcc6518d
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
-rw-r--r-- | CMakeLists.txt | 52 | ||||
-rw-r--r-- | LICENSE | 203 | ||||
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | hal-api-nfc.pc | 16 | ||||
-rwxr-xr-x | include/hal-nfc-interface.h | 99 | ||||
-rwxr-xr-x | include/hal-nfc-types.h | 1022 | ||||
-rwxr-xr-x | include/hal-nfc.h | 105 | ||||
-rw-r--r-- | packaging/hal-api-nfc-devel.manifest | 6 | ||||
-rw-r--r-- | packaging/hal-api-nfc.manifest | 6 | ||||
-rw-r--r-- | packaging/hal-api-nfc.spec | 73 | ||||
-rwxr-xr-x | src/common.h | 26 | ||||
-rwxr-xr-x | src/hal-api-nfc.c | 583 |
12 files changed, 2192 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..6216e6b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,52 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(hal-api-nfc C) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(EXEC_PREFIX "${CMAKE_INSTALL_PREFIX}/bin") +SET(INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include") +SET(LIBDIR ${CMAKE_LIBDIR_PREFIX}) +SET(VERSION_MAJOR 0) +SET(VERSION "${VERSION_MAJOR}.1.0") + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(EXEC_PREFIX "${PREFIX}/bin") +SET(INCLUDEDIR "${PREFIX}/include") +SET(LIBDIR ${CMAKE_LIBDIR_PREFIX}) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) + +SET(PKG_MODULES + dlog + hal-api-common +) + +INCLUDE(FindPkgConfig) +pkg_check_modules(pkgs REQUIRED ${PKG_MODULES}) + +FOREACH(flag ${pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -fPIE") +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -lrt") +SET(CMAKE_EXE_LINKER_FLAGS "-pie") + +ADD_DEFINITIONS("-DLOG_TAG=\"HALAPI_NFC\"") + +SET(SRCS + src/hal-api-nfc.c) + +ADD_LIBRARY( ${PROJECT_NAME} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${pkgs_LDFLAGS} -ldl -lm -Wl,-z,nodelete,--no-undefined) +SET_TARGET_PROPERTIES( ${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR}) +SET_TARGET_PROPERTIES( ${PROJECT_NAME} PROPERTIES VERSION ${VERSION}) + +CONFIGURE_FILE( ${PROJECT_NAME}.pc ${PROJECT_NAME}.pc @ONLY) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIBDIR}/hal) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/hal-nfc.h DESTINATION ${INCLUDEDIR}/hal) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/hal-nfc-interface.h DESTINATION ${INCLUDEDIR}/hal) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/hal-nfc-types.h DESTINATION ${INCLUDEDIR}/hal) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIBDIR}/pkgconfig) @@ -0,0 +1,203 @@ +Copyright (c) 2000 - 2021 Samsung Electronics Co., Ltd. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..6320886 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +nfc halapi diff --git a/hal-api-nfc.pc b/hal-api-nfc.pc new file mode 100644 index 0000000..8a95f21 --- /dev/null +++ b/hal-api-nfc.pc @@ -0,0 +1,16 @@ +# Package Information for pkg-config + +package_name=hal-api-nfc +prefix=@PREFIX@ +exec_prefix=@EXEC_PREFIX@/hal +libdir=@LIBDIR@/hal +includedir=@INCLUDEDIR@/hal + +Name: ${package_name} +Description: ${package_name} interface +Version: @VERSION@ + +Requires: +Libs: -L${libdir} -l${package_name} +Cflags: -I${includedir} +CXXflags: -I${includedir} diff --git a/include/hal-nfc-interface.h b/include/hal-nfc-interface.h new file mode 100755 index 0000000..1c2fec8 --- /dev/null +++ b/include/hal-nfc-interface.h @@ -0,0 +1,99 @@ +/* + * 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. + */ + +#ifndef __HAL_NFC_INTERFACE__ +#define __HAL_NFC_INTERFACE__ + +#include <hal/hal-common-interface.h> +#include <stdbool.h> +#include <hal-nfc-types.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _hal_backend_nfc_funcs { + bool (*start)(net_nfc_error_e * result);; + bool (*stop)(void); + 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); + bool (*unregister_listener)(void); + bool (*get_firmware_version)(data_s ** data, net_nfc_error_e * result); + bool (*support_nfc)(net_nfc_error_e * result); + bool (*check_firmware_version)(net_nfc_error_e * result); + bool (*update_firmware)(net_nfc_error_e * result); + bool (*get_stack_information)(net_nfc_stack_information_s * stack_info, net_nfc_error_e * result); + bool (*configure_discovery)(net_nfc_discovery_mode_e mode, net_nfc_event_filter_e config, net_nfc_error_e * result); + bool (*check_target_presence)(net_nfc_target_handle_s * handle, net_nfc_error_e * result); + bool (*connect)(net_nfc_target_handle_s * handle, net_nfc_error_e * result); + bool (*disconnect)(net_nfc_target_handle_s * handle, net_nfc_error_e * result); + 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); + bool (*read_ndef)(net_nfc_target_handle_s * handle, data_s ** data, net_nfc_error_e * result); + bool (*write_ndef)(net_nfc_target_handle_s * handle, data_s * data, net_nfc_error_e * result); + bool (*make_read_only_ndef)(net_nfc_target_handle_s * handle, net_nfc_error_e * result); + bool (*format_ndef)(net_nfc_target_handle_s * handle, data_s * secure_key, net_nfc_error_e * result); + bool (*transceive)(net_nfc_target_handle_s * handle, net_nfc_transceive_info_s * info, data_s ** data, net_nfc_error_e * result); + bool (*exception_handler)(void); + bool (*is_ready)(net_nfc_error_e * result); + bool (*llcp_config)(net_nfc_llcp_config_info_s * config, net_nfc_error_e * result); + bool (*llcp_check_llcp)(net_nfc_target_handle_s * handle, net_nfc_error_e * result); + bool (*llcp_activate_llcp)(net_nfc_target_handle_s * handle, net_nfc_error_e * result); + 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); + bool (*llcp_bind)(net_nfc_llcp_socket_t socket, uint8_t service_access_point, net_nfc_error_e * result); + 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); + bool (*llcp_accept)(net_nfc_llcp_socket_t socket, net_nfc_error_e * result, void *user_param); + 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); + 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); + bool (*llcp_disconnect)(net_nfc_target_handle_s * handle, net_nfc_llcp_socket_t socket, net_nfc_error_e * result, void *user_param); + bool (*llcp_socket_close)(net_nfc_llcp_socket_t socket, net_nfc_error_e * result); + 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); + 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); + 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); + 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); + bool (*llcp_reject)(net_nfc_target_handle_s * handle, net_nfc_llcp_socket_t socket, net_nfc_error_e * result); + bool (*llcp_get_remote_config)(net_nfc_target_handle_s * handle, net_nfc_llcp_config_info_s * config, net_nfc_error_e * result); + 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); + bool (*secure_element_open)(net_nfc_secure_element_type_e element_type, net_nfc_target_handle_s ** handle, net_nfc_error_e * result); + bool (*secure_element_get_atr)(net_nfc_target_handle_s * handle, data_s ** atr, net_nfc_error_e * result); + bool (*secure_element_send_apdu)(net_nfc_target_handle_s * handle, data_s * command, data_s ** response, net_nfc_error_e * result); + bool (*secure_element_close)(net_nfc_target_handle_s * handle, net_nfc_error_e * result); + bool (*get_secure_element_list)(net_nfc_secure_element_info_s * list, int *count, net_nfc_error_e * result); + 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); + bool (*sim_test)(net_nfc_error_e * result); + bool (*prbs_test)(net_nfc_error_e * result, uint32_t tech, uint32_t rate); + bool (*test_mode_on)(net_nfc_error_e * result); + bool (*test_mode_off)(net_nfc_error_e * result); + bool (*eedata_register_set)(net_nfc_error_e * result, uint32_t mode, uint32_t reg_id, data_s * data); + bool (*ese_test)(net_nfc_error_e * result); + bool (*test_set_se_tech_type)(net_nfc_error_e * result, net_nfc_se_type_e type, uint32_t tech); + bool (*hce_response_apdu)(net_nfc_target_handle_s * handle, data_s * response, net_nfc_error_e * result); + bool (*secure_element_route_aid)(data_s * aid, net_nfc_se_type_e se_type, int power, net_nfc_error_e * result); + bool (*secure_element_unroute_aid)(data_s * aid, net_nfc_error_e * result); + bool (*secure_element_commit_routing)(net_nfc_error_e * result); + 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); + bool (*secure_element_clear_aid_table)(net_nfc_error_e * result); + bool (*secure_element_get_aid_table_size)(int *AIDTableSize, net_nfc_error_e * result); + 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); + bool (*secure_element_clear_routing_entry)(net_nfc_se_entry_type_e type, net_nfc_error_e * result); + bool (*secure_element_set_listen_tech_mask)(net_nfc_se_tech_protocol_type_e screen_state, net_nfc_error_e * result); + bool (*set_screen_state)(net_nfc_screen_state_type_e screen_state, net_nfc_error_e * result); +} hal_backend_nfc_funcs; + +#ifdef __cplusplus +} +#endif +#endif /* __HAL_NFC_INTERFACE__ */ diff --git a/include/hal-nfc-types.h b/include/hal-nfc-types.h new file mode 100755 index 0000000..8ddb37a --- /dev/null +++ b/include/hal-nfc-types.h @@ -0,0 +1,1022 @@ +/* + * 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. + */ + +#ifndef __HAL_NFC_TYPES__ +#define __HAL_NFC_TYPES__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + net_nfc_error_e is enum type that returned from each functions + it mostly contains the error codes and it may contains status codes. + */ +typedef enum { + /*000 */ NET_NFC_OK = 0, + /**< Status is OK */ + /*999 */ NET_NFC_UNKNOWN_ERROR = -999, + /**< Unknown error */ + /*998 */ NET_NFC_ALLOC_FAIL, + /**< Memory allocation is failed */ + /*997 */ NET_NFC_THREAD_CREATE_FAIL, + /**< Thread creation is failed */ + /*996 */ NET_NFC_INVALID_STATE, + /**< State of NFC-Manager or nfc-stack is not normal */ + /*995 */ NET_NFC_IPC_FAIL, + /**< Communication with ipc is failed. (from client to server)*/ + /*994 */ NET_NFC_OUT_OF_BOUND, + /**< Index is out of bound */ + /*993 */ NET_NFC_NULL_PARAMETER, + /**< Unexpected NULL parameter is received */ + /*992 */ NET_NFC_BUFFER_TOO_SMALL, + /**< Requested buffer is too small to store data, this error should be received */ + /*991 */ NET_NFC_ALREADY_INITIALIZED, + /**< You tried to initialized again without de-init */ + /*990 */ NET_NFC_COMMUNICATE_WITH_CONTROLLER_FAILED, + /**< Communication with Controller Chipset is failed this is Fatal Error */ + /*989 */ NET_NFC_RF_TIMEOUT, + /**< Timeout is raised while communicate with a tag */ + /*988 */ NET_NFC_RF_ERROR, + /**< Unexpected package is received from target, you may receive this error comes by the low level RF communication fault*/ + /*987 */ NET_NFC_NOT_INITIALIZED, + /**< Application tries to request without initialization */ + /*986 */ NET_NFC_NOT_SUPPORTED, + /**< Request information or command is not supported in current connected target */ + /*985 */ NET_NFC_ALREADY_REGISTERED, + /**< Requested SAP number is already used by other socket or data is already appended or registered */ + /*984 */ NET_NFC_NOT_ALLOWED_OPERATION, + /**< Requested Operation is not allowed in the situation in critical time (such as write data on target)*/ + /*983 */ NET_NFC_BUSY, + /**< Previous operation is not finished. don't worry to get this message, most of request will be executed in the serial queue */ + /*982 */ NET_NFC_INVALID_HANDLE, + /**< Requested Device in not valid device */ + /*981 */ NET_NFC_TAG_READ_FAILED, + /**< Tag reading is failed because of unexpected chunk data is received or error ack is received */ + /*980 */ NET_NFC_TAG_WRITE_FAILED, + /**< When you try to write on read only tag or error ack is received */ + /*979 */ NET_NFC_NO_NDEF_SUPPORT, + /**< Tag is not supported NDEF format for tag is not formatted for NDEF */ + /*978 */ NET_NFC_NO_NDEF_MESSAGE, + /**< No data is received after NDEF reading */ + /*977 */ NET_NFC_INVALID_FORMAT, + /**< Received data is not readable or it has illegal values or format */ + /*976 */ NET_NFC_INSUFFICIENT_STORAGE, + /**< The connected tag does not have enough information */ + /*975 */ NET_NFC_OPERATION_FAIL, + /**< The remote target returned error while doing a operation*/ + /*974 */ NET_NFC_NOT_CONNECTED, + /**< remote is not connected correctly. This can be happened when the RF does not have enough strength */ + /*973 */ NET_NFC_NO_DATA_FOUND, + /**< Requested data is not found in the list or properties */ + /*972 */ NET_NFC_SECURITY_FAIL, + /**< Authentication is failed while communication with nfc-manager server */ + /*971 */ NET_NFC_TARGET_IS_MOVED_AWAY, + /**< Target is lost while doing a operation */ + /*970 */ NET_NFC_TAG_IS_ALREADY_FORMATTED, + /** Target is already formatted */ + /*969 */ NET_NFC_NOT_REGISTERED, + /**< removal is requested but requested data is not registered */ + /*968 */ NET_NFC_INVALID_PARAM, + /**< removal is requested but requested data is not registered */ + /*967 */ NET_NFC_PERMISSION_DENIED, + /**< privilege check is failed */ + /*966 */ NET_NFC_NOT_ACTIVATED, + /**< Application tries to request without activation */ + /*965 */ NET_NFC_DATA_CONFLICTED, + /**< Data is conflicted with another one */ + + /*499 */ NET_NFC_NDEF_TYPE_LENGTH_IS_NOT_OK = -499, + /**< Illegal ndef record type length */ + /*498 */ NET_NFC_NDEF_PAYLOAD_LENGTH_IS_NOT_OK, + /**< Illegal ndef record payload length */ + /*497 */ NET_NFC_NDEF_ID_LENGTH_IS_NOT_OK, + /**< Illegal ndef record id length */ + /*496 */ NET_NFC_NDEF_RECORD_IS_NOT_EXPECTED_TYPE, + /**< Parameter record is not expected record. for example, try to URI from text record */ + /*495 */ NET_NFC_NDEF_BUF_END_WITHOUT_ME, + /**< NDEF messages is terminated without ME flag */ + /*494 */ NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC, + /**< Current device does not support NFC feature or this manager does not found plugin library */ + + /*399 */ NET_NFC_LLCP_INVALID_SOCKET = -399, + /**< socket is not valid socket */ + /*398 */ NET_NFC_LLCP_SOCKET_DISCONNECTED, + /**< socket is disconnected */ + /*397 */ NET_NFC_LLCP_SOCKET_FRAME_REJECTED, + /**< send data is rejected from remote side */ + + /*299 */ NET_NFC_P2P_SEND_FAIL = -299, + /**< P2P data send fail */ +} net_nfc_error_e; + +/** +Enum value of the record type ( TNF value ) +*/ +typedef enum { + NET_NFC_RECORD_EMPTY = 0x0, + NET_NFC_RECORD_WELL_KNOWN_TYPE, + NET_NFC_RECORD_MIME_TYPE, // Media type + NET_NFC_RECORD_URI, + NET_NFC_RECORD_EXTERNAL_RTD, + NET_NFC_RECORD_UNKNOWN, + NET_NFC_RECORD_UNCHAGNED, +} net_nfc_record_tnf_e; + +/** +net_nfc_message_e is identify the events comes from nfc-manager. +most of the events response event that you requested operations. +and some of the events are generated by nfc-manager. (example, NET_NFC_MESSAGE_TAG_DISCOVERED, NET_NFC_MESSAGE_TAG_DETACHED, +NET_NFC_MESSAGE_LLCP_DISCOVERED and NET_NFC_MESSAGE_LLCP_DETACHED) + +All of the events are delivered by the the callback function that registered with "net_nfc_set_response_callback" +*/ + +typedef enum { + NET_NFC_MESSAGE_TRANSCEIVE = 0, /**< Type: Response Event, <br> This events is received after calling the "net_nfc_tranceive" + <br> if the operation is success, the data parameter should cast into data_h or it return NULL*/ + NET_NFC_MESSAGE_READ_NDEF, /**< Type: Response Event, <br> This events is received after calling the "net_nfc_read_tag" + <br> if the operation is success, the data parameter should cast into ndef_message_h or it return NULL */ + NET_NFC_MESSAGE_WRITE_NDEF, /**< Type: Response Event, <br> This events is received after calling the "net_nfc_write_ndef" + <br> data pointer always returns NULL */ + NET_NFC_MESSAGE_MAKE_READ_ONLY_NDEF, /**< Type: Response Event, <br> This events is received after calling the "net_nfc_make_read_only_ndef" + <br> data pointer always returns NULL */ + NET_NFC_MESSAGE_IS_TAG_CONNECTED, /**< Type: Response Event, <br> This events is received after calling the "net_nfc_is_tag_conneced" + <br> data pointer always returns NULL */ + NET_NFC_MESSAGE_GET_CURRENT_TAG_INFO, /**< Type: Response Event, <br> This events is received after calling the "net_nfc_get_current_tag_infof" + <br> if the operation is success, the data parameter should cast into net_nfc_target_info_h or it return NULL */ + NET_NFC_MESSAGE_GET_CURRENT_TARGET_HANDLE, /**< Type: Response Event, <br> This events is received after calling the "net_nfc_get_current_target_handle" + <br> if the operation is success, the data parameter should cast into net_nfc_target_handle_h or it return NULL */ + NET_NFC_MESSAGE_TAG_DISCOVERED, /**< Type: Notify Event, <br> When a tag or SE is detected, you got this event. + <br> The data contains the target info , need to cast to net_nfc_target_info_h*/ + NET_NFC_MESSAGE_NOTIFY, /**< This Notify Event <br> when the unexpected error has occurred, this event is delivered. data pointer always returns NULL */ + NET_NFC_MESSAGE_TAG_DETACHED, /**< Type: Notify Event, <br> When a tag or SE is disappeared, you got this event. + <br> The data contains the target info , need to cast to net_nfc_target_info_h but it does not have detail target info + <br> please, do not use "net_nfc_get_tag_info_keys" when you got this event*/ + /*10 */ NET_NFC_MESSAGE_FORMAT_NDEF, + /**< Type: Response Event <br> After complete "net_nfc_format_ndef", this event is delivered */ + NET_NFC_MESSAGE_LLCP_DISCOVERED, /**< Type: Notify Event <br> When LLCP is discovered and remote device is support llcp, you receive this event + <br> data pointer contains the remote llcp configuration info. Cast to net_nfc_llcp_config_info_h*/ + NET_NFC_MESSAGE_P2P_DETACHED, /**< Type: Notify Event <br> When LLCP is de-activated by removing the device, you receive this event*/ + NET_NFC_MESSAGE_LLCP_CONFIG, /**< Type: Response Event. <br> The operation of "net_nfc_set_llcp_local_configure" is completed */ + + NET_NFC_MESSAGE_P2P_DISCOVERED, /**< Type: Notify Event <br> The remove device is detected and ready for transferring data to remote side */ + NET_NFC_MESSAGE_P2P_SEND, /**< Type: Response Event, <br> This events is received after calling the "net_nfc_send_exchanger_data" */ + NET_NFC_MESSAGE_P2P_RECEIVE, /**< Type: Notify Event, <br> When llcp server socket receive some data, this event is delivered. */ + + NET_NFC_MESSAGE_SE_START_TRANSACTION, + /**< Type: Notify Event, indicates external reader start transaction*/ + NET_NFC_MESSAGE_SE_END_TRANSACTION, + /**< Type: Notify Event, indicates external reader end transaction*/ + NET_NFC_MESSAGE_SE_TYPE_TRANSACTION, + /**< Type: Notify Event, Indicates external reader trying to access secure element */ + /*20 */ NET_NFC_MESSAGE_SE_CONNECTIVITY, + /**< Type: Notify Event, This event notifies the terminal host that it shall send a connectivity event from UICC */ + NET_NFC_MESSAGE_SE_FIELD_ON, + /**< Type: Notify Event, indicates external reader field is on*/ + NET_NFC_MESSAGE_SE_FIELD_OFF, + /**< Type: Notify Event, indicates external reader field is off*/ + NET_NFC_MESSAGE_SE_TYPE_CHANGED, + /**< Type: Notify Event, indicates secure element type is changed*/ + NET_NFC_MESSAGE_SE_CARD_EMULATION_CHANGED, + /**< Type: Notify Event, indicates card emulation mode is changed*/ + NET_NFC_MESSAGE_CONNECTION_HANDOVER, + /**< Type: Response Event. <br> The result of connection handover. If it has been completed successfully, this event will include the information of alternative carrier. */ + + NET_NFC_MESSAGE_SET_SE, + NET_NFC_MESSAGE_GET_SE, + NET_NFC_MESSAGE_OPEN_INTERNAL_SE, + NET_NFC_MESSAGE_CLOSE_INTERNAL_SE, +/*30*/ NET_NFC_MESSAGE_SEND_APDU_SE, + NET_NFC_MESSAGE_GET_ATR_SE, + NET_NFC_GET_SERVER_STATE, + + NET_NFC_MESSAGE_SIM_TEST, + + NET_NFC_MESSAGE_INIT, + NET_NFC_MESSAGE_DEINIT, + + NET_NFC_MESSAGE_PRBS_TEST, + + NET_NFC_MESSAGE_GET_FIRMWARE_VERSION, + + NET_NFC_MESSAGE_SET_EEDATA, + + NET_NFC_MESSAGE_SNEP_START_SERVER, + NET_NFC_MESSAGE_SNEP_START_CLIENT, +/*40*/ NET_NFC_MESSAGE_SNEP_REQUEST, + NET_NFC_MESSAGE_SNEP_STOP_SERVICE, + NET_NFC_MESSAGE_SNEP_REGISTER_SERVER, + NET_NFC_MESSAGE_SNEP_UNREGISTER_SERVER, + + NET_NFC_MESSAGE_CONNECT, + NET_NFC_MESSAGE_DISCONNECT, + NET_NFC_MESSAGE_SET_CARD_EMULATION, + +/*47*/ NET_NFC_MESSAGE_ROUTING_HOST_EMU_ACTIVATED, + NET_NFC_MESSAGE_ROUTING_HOST_EMU_DEACTIVATED, + NET_NFC_MESSAGE_ROUTING_HOST_EMU_DATA, +} net_nfc_message_e; + +typedef enum { + NET_NFC_UNKNOWN_TARGET = 0x00U, + + /* Specific PICC Devices */ + + NET_NFC_GENERIC_PICC, + NET_NFC_ISO14443_A_PICC, + NET_NFC_ISO14443_4A_PICC, + NET_NFC_ISO14443_3A_PICC, + NET_NFC_MIFARE_MINI_PICC, + NET_NFC_MIFARE_1K_PICC, + NET_NFC_MIFARE_4K_PICC, + NET_NFC_MIFARE_ULTRA_PICC, + NET_NFC_MIFARE_DESFIRE_PICC, + NET_NFC_ISO14443_B_PICC, + NET_NFC_ISO14443_4B_PICC, + NET_NFC_ISO14443_BPRIME_PICC, + NET_NFC_FELICA_PICC, + NET_NFC_JEWEL_PICC, + NET_NFC_ISO15693_PICC, + NET_NFC_BARCODE_128_PICC, + NET_NFC_BARCODE_256_PICC, + + /* NFC-IP1 Device Types */ + NET_NFC_NFCIP1_TARGET, + NET_NFC_NFCIP1_INITIATOR, + +} net_nfc_target_type_e; + +/** +Card states for nfc tag +*/ +typedef enum { + NET_NFC_NDEF_CARD_INVALID = 0x00, + /**< The card is not NFC forum specified tag. The ndef format will be needed. */ + NET_NFC_NDEF_CARD_INITIALISED, + /**< The card is NFC forum specified tag, but It has no actual data. So, the ndef write will be needed. */ + NET_NFC_NDEF_CARD_READ_WRITE, + /**< The card is NFC forum specified tag. The ndef read and write will be allowed. */ + NET_NFC_NDEF_CARD_READ_ONLY + /**< The card is NFC forum specified tag, but only the ndef read will be allowed. */ +} net_nfc_ndef_card_state_e; + +/** +Encoding type for string message +*/ +typedef enum { + NET_NFC_ENCODE_UTF_8 = 0x00, + NET_NFC_ENCODE_UTF_16, +} net_nfc_encode_type_e; + +/** +URI scheme type defined in the NFC forum "URI Record Type Definition" +*/ +typedef enum { + NET_NFC_SCHEMA_FULL_URI = 0x00, /**< protocol is specify by payload */ + NET_NFC_SCHEMA_HTTP_WWW, /**< http://www. */ + NET_NFC_SCHEMA_HTTPS_WWW, /**< https://www. */ + NET_NFC_SCHEMA_HTTP, /**< http:// */ + NET_NFC_SCHEMA_HTTPS, /**< https:// */ + NET_NFC_SCHEMA_TEL, /**< tel: */ + NET_NFC_SCHEMA_MAILTO, /**< mailto: */ + NET_NFC_SCHEMA_FTP_ANONYMOUS, /**< ftp://anonymouse:anonymouse@ */ + NET_NFC_SCHEMA_FTP_FTP, /**< ftp://ftp. */ + NET_NFC_SCHEMA_FTPS, /**< ftps:// */ + NET_NFC_SCHEMA_SFTP, /**< sftp:// */ + NET_NFC_SCHEMA_SMB, /**< smb:// */ + NET_NFC_SCHEMA_NFS, /**< nfs:// */ + NET_NFC_SCHEMA_FTP, /**< ftp:// */ + NET_NFC_SCHEMA_DAV, /**< dav:// */ + NET_NFC_SCHEMA_NEWS, /**< news:// */ + NET_NFC_SCHEMA_TELNET, /**< telnet:// */ + NET_NFC_SCHEMA_IMAP, /**< imap: */ + NET_NFC_SCHEMA_RTSP, /**< rtsp:// */ + NET_NFC_SCHEMA_URN, /**< urn: */ + NET_NFC_SCHEMA_POP, /**< pop: */ + NET_NFC_SCHEMA_SIP, /**< sip: */ + NET_NFC_SCHEMA_SIPS, /**< sips: */ + NET_NFC_SCHEMA_TFTP, /**< tftp: */ + NET_NFC_SCHEMA_BTSPP, /**< btspp:// */ + NET_NFC_SCHEMA_BTL2CAP, /**< btl2cap:// */ + NET_NFC_SCHEMA_BTGOEP, /**< btgoep:// */ + NET_NFC_SCHEMA_TCPOBEX, /**< tcpobex:// */ + NET_NFC_SCHEMA_IRDAOBEX, /**< irdaobex:// */ + NET_NFC_SCHEMA_FILE, /**< file:// */ + NET_NFC_SCHEMA_URN_EPC_ID, /**< urn:epc:id: */ + NET_NFC_SCHEMA_URN_EPC_TAG, /**< urn:epc:tag: */ + NET_NFC_SCHEMA_URN_EPC_PAT, /**< urn:epc:pat: */ + NET_NFC_SCHEMA_URN_EPC_RAW, /**< urn:epc:raw: */ + NET_NFC_SCHEMA_URN_EPC, /**< urn:epc: */ + NET_NFC_SCHEMA_URN_NFC, /**< urn:epc:nfc: */ + NET_NFC_SCHEMA_MAX /**< -- indicating max-- */ +} net_nfc_schema_type_e; + +// this is for target detect event filter + +typedef enum { + NET_NFC_ALL_DISABLE = 0x0000, + NET_NFC_ISO14443A_ENABLE = 0x0001, + NET_NFC_ISO14443B_ENABLE = 0x0002, + NET_NFC_ISO15693_ENABLE = 0x0004, + NET_NFC_FELICA_ENABLE = 0x0008, + NET_NFC_JEWEL_ENABLE = 0x0010, + NET_NFC_IP_ENABLE = 0x0020, + NET_NFC_ALL_ENABLE = ~0, + +} net_nfc_event_filter_e; + +/* +************************************** +LLCP defines +************************************** +*/ +/** +These events are delivered to the each socket callback. These events are separated events that comes from "net_nfc_set_response_callback" callback +*/ +typedef enum { + /* start number should be larger than "net_nfc_message_e" + because to make seperate with net_nfc_message_e event it may conflict in + the dispatcher and ipc part */ + NET_NFC_MESSAGE_LLCP_LISTEN = 1000, + /**< Type: Response Event <br> this event indicates "net_nfc_listen_llcp" requested is completed*/ + NET_NFC_MESSAGE_LLCP_ACCEPTED, + /**< Type: Notify Event. <br> Remote socket is accepted to listening socket + <br> data pointer contains the remote socket info (Cast to net_nfc_llcp_socket_option_h)*/ + NET_NFC_MESSAGE_LLCP_CONNECT, + /**< Type: Response Event. <br> "net_nfc_connect_llcp_with" request is completed and your socket is connected to remote site with url*/ + NET_NFC_MESSAGE_LLCP_CONNECT_SAP, + /**< Type: Response Event.<br> "net_nfc_connect_llcp_with_sap" request is completed and your socket is connected to remote site with sap number*/ + NET_NFC_MESSAGE_LLCP_SEND, + /**< Type: Response Event,<br> "net_nfc_send_llcp" operation is completed (connection mode)*/ + NET_NFC_MESSAGE_LLCP_SEND_TO, + /**< Type: Response Event,<br> "net_nfc_send_llcp_to"operation is completed (connectionless mode)*/ + NET_NFC_MESSAGE_LLCP_RECEIVE, + /**< Type: Response Event,<br> "net_nfc_receive_llcp" operation is completed (connection mode) + <br> data pointer contains received data (Cast to data_h)*/ + NET_NFC_MESSAGE_LLCP_RECEIVE_FROM, + /**< Type: Response Event,<br> "net_nfc_receive_llcp_from" operation is completed (connectionless mode)*/ + NET_NFC_MESSAGE_LLCP_DISCONNECT, + /**< Type: Response Event,<br> "net_nfc_disconnect_llcp" request is completed */ + NET_NFC_MESSAGE_LLCP_ERROR, + /**< Type: Notify Event,<br> when the socket is disconnected, you may receive this event */ + NET_NFC_MESSAGE_LLCP_CONNECT_REQ, + /**< Type: Notify Event,<br> when the peer requests connect, you may receive this event */ + NET_NFC_MESSAGE_LLCP_ACCEPT, + /**< Type: Response Event <br> this event indicates "net_nfc_accept_llcp" requested is completed*/ + NET_NFC_MESSAGE_LLCP_REJECT, + /**< Type: Response Event <br> this event indicates "net_nfc_reject_llcp" requested is completed*/ + NET_NFC_MESSAGE_LLCP_REJECTED, + /**< Type: Notify Event,<br> when the socket is rejected, you may receive this event */ + NET_NFC_MESSAGE_LLCP_CLOSE, + /**< Type: Response Event,<br> "net_nfc_close_llcp_socket" request is completed */ + +} net_nfc_llcp_message_e; + +typedef enum { + NET_NFC_LLCP_SOCKET_TYPE_CONNECTIONORIENTED, + NET_NFC_LLCP_SOCKET_TYPE_CONNECTIONLESS, +} net_nfc_socket_type_e; + +typedef enum { + NET_NFC_SNEP = 0x00, + NET_NFC_NPP, +} llcp_app_protocol_e; + +typedef struct _data_s *data_h; + +typedef struct _ndef_record_s *ndef_record_h; + +typedef struct _ndef_message_s *ndef_message_h; + +typedef struct _net_nfc_target_info_s *net_nfc_target_info_h; + +typedef uint32_t net_nfc_traceive_cmd; + +typedef struct _net_nfc_llcp_config_info_s *net_nfc_llcp_config_info_h; + +typedef struct _net_nfc_llcp_socket_option_s *net_nfc_llcp_socket_option_h; + +typedef struct _net_nfc_target_handle_s *net_nfc_target_handle_h; + +typedef struct _net_nfc_connection_handover_info_s *net_nfc_connection_handover_info_h; + +typedef uint8_t sap_t; + +typedef uint32_t net_nfc_llcp_socket_t; + +typedef void *net_nfc_snep_handle_h; + +// LLCP Callback +typedef void (*net_nfc_llcp_socket_cb) (net_nfc_llcp_message_e message, net_nfc_error_e result, void *data, void *user_data, void *trans_data); + +// Main Callback +typedef void (*net_nfc_response_cb) (net_nfc_message_e message, net_nfc_error_e result, void *data, void *user_param, void *trans_data); + +typedef void (*net_nfc_internal_se_response_cb) (net_nfc_message_e message, net_nfc_error_e result, void *data, void *user_param, void *trans_data); + +typedef void (*net_nfc_set_activation_completed_cb) (net_nfc_error_e error, void *user_data); + +// handover + +typedef enum { + NET_NFC_CONN_HANDOVER_CARRIER_BT = 0x00, + NET_NFC_CONN_HANDOVER_CARRIER_WIFI_WPS, /* Wifi Protected Setup */ +#define NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS NET_NFC_CONN_HANDOVER_CARRIER_WIFI_WPS + NET_NFC_CONN_HANDOVER_CARRIER_WIFI_P2P, /* Wifi Peer-to-Peer */ +#define NET_NFC_CONN_HANDOVER_CARRIER_WIFI_IBSS NET_NFC_CONN_HANDOVER_CARRIER_WIFI_P2P +#define NET_NFC_CONN_HANDOVER_CARRIER_WIFI_DIRECT NET_NFC_CONN_HANDOVER_CARRIER_WIFI_P2P + NET_NFC_CONN_HANDOVER_CARRIER_BT_LE, + NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN, +} net_nfc_conn_handover_carrier_type_e; + +typedef enum { + NET_NFC_CONN_HANDOVER_CARRIER_INACTIVATE = 0x00, + NET_NFC_CONN_HANDOVER_CARRIER_ACTIVATE, + NET_NFC_CONN_HANDOVER_CARRIER_ACTIVATING, + NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN_STATUS, +} net_nfc_conn_handover_carrier_state_e; + +typedef struct _net_nfc_conn_handover_carrier_info_s *net_nfc_conn_handover_carrier_info_h; +typedef struct _net_nfc_conn_handover_info_s *net_nfc_conn_handover_info_h; + +#define MIFARE_KEY_DEFAULT {(uint8_t)0xFF, (uint8_t)0xFF, (uint8_t)0xFF, (uint8_t)0xFF, (uint8_t)0xFF, (uint8_t)0xFF} +#define MIFARE_KEY_APPLICATION_DIRECTORY {(uint8_t)0xA0, (uint8_t)0xA1, (uint8_t)0xA2, (uint8_t)0xA3, (uint8_t)0xA4, (uint8_t)0xA5} +#define MIFARE_KEY_NET_NFC_FORUM {(uint8_t)0xD3, (uint8_t)0xF7, (uint8_t)0xD3, (uint8_t)0xF7, (uint8_t)0xD3, (uint8_t)0xF7} +#define MIFARE_KEY_LENGTH 6 + +typedef enum { + NET_NFC_FELICA_POLL_NO_REQUEST = 0x00, + NET_NFC_FELICA_POLL_SYSTEM_CODE_REQUEST, + NET_NFC_FELICA_POLL_COMM_SPEED_REQUEST, + NET_NFC_FELICA_POLL_MAX = 0xFF, +} net_nfc_felica_poll_request_code_e; + +/** +WIFI configuration key enums for connection handover. +*/ + +typedef enum { + NET_NFC_WIFI_ATTRIBUTE_VERSION = 0x104A, + NET_NFC_WIFI_ATTRIBUTE_CREDENTIAL = 0x100E, + NET_NFC_WIFI_ATTRIBUTE_NET_INDEX = 0x1026, + NET_NFC_WIFI_ATTRIBUTE_SSID = 0x1045, + NET_NFC_WIFI_ATTRIBUTE_AUTH_TYPE = 0x1003, /*< WPA2PSK 0x0020 */ + NET_NFC_WIFI_ATTRIBUTE_ENC_TYPE = 0x100F, /*< AES 0x0008 */ + NET_NFC_WIFI_ATTRIBUTE_NET_KEY = 0x1027, + NET_NFC_WIFI_ATTRIBUTE_MAC_ADDR = 0x1020, + NET_NFC_WIFI_ATTRIBUTE_CHANNEL = 0x1001, /* Channel number - based on IEEE */ + NET_NFC_WIFI_ATTRIBUTE_VEN_EXT = 0x1049, + NET_NFC_WIFI_ATTRIBUTE_VERSION2 = 0x00, +} net_nfc_carrier_wifi_attribute_e; + +typedef enum { + NET_NFC_WIFI_P2P_ATTRIBUTE_MANUFACTURER = 0x1021, + NET_NFC_WIFI_P2P_ATTRIBUTE_MODEL_NAME = 0x1023, + NET_NFC_WIFI_P2P_ATTRIBUTE_MODEL_NUMBER = 0x1024, + NET_NFC_WIFI_P2P_ATTRIBUTE_OOB_DEVICE_PASSWORD = 0x102C, + NET_NFC_WIFI_P2P_ATTRIBUTE_RF_BANDS = 0x103C, + NET_NFC_WIFI_P2P_ATTRIBUTE_SERIAL_NUMBER = 0x1042, + NET_NFC_WIFI_P2P_ATTRIBUTE_UUID_E = 0x1047, + NET_NFC_WIFI_P2P_ATTRIBUTE_VEN_EXT = 0x1049, + + NET_NFC_WIFI_P2P_ATTRIBUTE_CAPABILITY = 0x02, + NET_NFC_WIFI_P2P_ATTRIBUTE_DEVICE_INFO = 0x0D, + NET_NFC_WIFI_P2P_ATTRIBUTE_OOB_GROUP_OWNER_NEGO_CHANNEL = 0x13, + NET_NFC_WIFI_P2P_ATTRIBUTE_CHANNEL_LIST = 0x0B, + NET_NFC_WIFI_P2P_ATTRIBUTE_GROUP_INFO = 0x0E, + NET_NFC_WIFI_P2P_ATTRIBUTE_GROUP_ID = 0x0F, +} net_nfc_carrier_wifi_p2p_attribute_e; + +typedef enum { + NET_NFC_BT_ATTRIBUTE_UUID16_PART = 0x02, /* More 16-bit UUIDs available */ + NET_NFC_BT_ATTRIBUTE_UUID16 = 0x03, /* Complete list of 16-bit UUIDs */ + NET_NFC_BT_ATTRIBUTE_UUID32_PART = 0x04, /* More 32-bit UUIDs available */ + NET_NFC_BT_ATTRIBUTE_UUID32 = 0x05, /* Complete list of 32-bit UUIDs */ + NET_NFC_BT_ATTRIBUTE_UUID128_PART = 0x06, /* More 128-bit UUIDs available */ + NET_NFC_BT_ATTRIBUTE_UUID128 = 0x07, /* Complete list of 128-bit UUIDs */ + NET_NFC_BT_ATTRIBUTE_NAME_PART = 0x08, /* Shortened local name */ + NET_NFC_BT_ATTRIBUTE_NAME = 0x09, /* Complete local name */ + NET_NFC_BT_ATTRIBUTE_TXPOWER = 0x0a, /* TX Power level */ + NET_NFC_BT_ATTRIBUTE_OOB_COD = 0x0d, /* SSP OOB Class of Device */ + NET_NFC_BT_ATTRIBUTE_OOB_HASH_C = 0x0e, /* SSP OOB Hash C */ + NET_NFC_BT_ATTRIBUTE_OOB_HASH_R = 0x0f, /* SSP OOB Randomizer R */ + NET_NFC_BT_ATTRIBUTE_ID = 0x10, /* Device ID */ + NET_NFC_BT_ATTRIBUTE_MANUFACTURER = 0xFF, /* Manufacturer Specific Data */ + NET_NFC_BT_ATTRIBUTE_ADDRESS = 0xF0, /* Bluetooth device Address */ +} net_nfc_handover_bt_attribute_e; + +typedef struct _net_nfc_carrier_config_s *net_nfc_carrier_config_h; +typedef struct _net_nfc_carrier_property_s *net_nfc_property_group_h; + +typedef struct _net_nfc_ch_message_s *net_nfc_ch_message_h; +typedef struct _net_nfc_ch_carrier_s *net_nfc_ch_carrier_h; + +typedef enum { + NET_NFC_SE_TYPE_NONE = 0x00, + /**< Invalid */ + NET_NFC_SE_TYPE_ESE = 0x01, + /**< SmartMX */ + NET_NFC_SE_TYPE_UICC = 0x02, + /**< UICC */ + NET_NFC_SE_TYPE_SDCARD = 0x03, /* SDCard type is not currently supported */ + NET_NFC_SE_TYPE_HCE = 0x04, /* SDCard type is not currently supported */ +} net_nfc_se_type_e; + +typedef enum { + NET_NFC_SE_INVALID_ENTRY = 0x00, + /**< Indicates SE type is Invalid */ + NET_NFC_SE_TECH_ENTRY = 0x01, /*Technology */ + NET_NFC_SE_PROTOCOL_ENTRY = 0x02, /*Protocol */ + NET_NFC_SE_AID_ENTRY = 0x04, /*Using it clear aid table */ +} net_nfc_se_entry_type_e; + +typedef enum { + NET_NFC_SE_INVALID_TECH_PROTO = 0x00, + /**< Indicates SE type is Invalid */ + NET_NFC_SE_TECH_A_ISODEP = 0x01, /*Type A /ISO DEP */ + NET_NFC_SE_TECH_B_NFCDEP = 0x02, /*Type B / NFC DEP */ + NET_NFC_SE_TECH_A_B_ISO_NFC_DEP = 0x03, /*Type B / NFC DEP */ + NET_NFC_SE_TECH_F = 0x04, /*Type F */ +} net_nfc_se_tech_protocol_type_e; + +typedef enum { + NET_NFC_SE_INVALID = 0x00, + /**< Indicates SE type is Invalid */ + NET_NFC_SE_SWITCH_ON = 0x01, /* Target On */ + NET_NFC_SE_SWITCH_OFF = 0x02, /*Target Off */ + NET_NFC_SE_SCREEN_OFF = 0x08, + NET_NFC_SE_SCREEN_ON_LOCK = 0x10, + NET_NFC_SE_SCREEN_ON_UNLOCK = 0x20, +} net_nfc_se_power_state_type_e; + +typedef enum { + NET_NFC_SIGN_TYPE_NO_SIGN = 0, + NET_NFC_SIGN_TYPE_PKCS_1, + NET_NFC_SIGN_TYPE_PKCS_1_V_1_5, + NET_NFC_SIGN_TYPE_DSA, +#if OPENSSL_VERSION_NUMBER < 0x10100000L + NET_NFC_SIGN_TYPE_ECDSA, +#endif + NET_NFC_MAX_SIGN_TYPE, +} net_nfc_sign_type_t; + +typedef enum { + NET_NFC_CERT_FORMAT_X_509 = 0, + NET_NFC_CERT_FORMAT_X9_86, + NET_NFC_MAX_CERT_FORMAT, +} net_nfc_cert_format_t; + +typedef enum { + NET_NFC_SNEP_GET = 1, + NET_NFC_SNEP_PUT = 2, +} net_nfc_snep_type_t; + +typedef enum { + NET_NFC_LLCP_REGISTERED = -1, + NET_NFC_LLCP_UNREGISTERED = -2, + NET_NFC_LLCP_START = -3, + NET_NFC_LLCP_STOP = -4, +} net_nfc_llcp_state_t; + +typedef enum { + NET_NFC_CARD_EMULATION_DISABLE = 0, + NET_NFC_CARD_EMELATION_ENABLE +} net_nfc_card_emulation_mode_t; + +typedef enum { + NET_NFC_HCE_EVENT_DEACTIVATED = 0, + NET_NFC_HCE_EVENT_ACTIVATED = 1, + NET_NFC_HCE_EVENT_APDU_RECEIVED = 2, +} net_nfc_hce_event_t; + +typedef enum { + NET_NFC_CARD_EMULATION_CATEGORY_UNKNOWN = 0, + NET_NFC_CARD_EMULATION_CATEGORY_PAYMENT = 1, + NET_NFC_CARD_EMULATION_CATEGORY_OTHER = 2, + NET_NFC_CARD_EMULATION_CATEGORY_MAX = 3, +} net_nfc_card_emulation_category_t; + +typedef enum { + NET_NFC_POLL_START = 0x01, + NET_NFC_POLL_STOP, +} net_nfc_detect_mode_e; + +/** + This structure is just data, to express bytes array + */ +typedef struct _data_s { + uint8_t *buffer; + uint32_t length; +} data_s; + +typedef struct _net_nfc_data_t { + uint32_t length; + uint8_t buffer[0]; +} net_nfc_data_s; + +typedef enum _net_nfc_connection_type_e { + NET_NFC_TAG_CONNECTION = 0x00, + NET_NFC_P2P_CONNECTION_TARGET, + NET_NFC_P2P_CONNECTION_INITIATOR, + NET_NFC_SE_CONNECTION +} net_nfc_connection_type_e; + +typedef struct _net_nfc_target_handle_s { + uint32_t connection_id; + net_nfc_connection_type_e connection_type; + net_nfc_target_type_e target_type; + /*++npp++ */ + llcp_app_protocol_e app_type; + /*--npp--*/ +} net_nfc_target_handle_s; + +typedef struct _net_nfc_current_target_info_s { + net_nfc_target_handle_s *handle; + uint32_t devType; + int number_of_keys; + net_nfc_data_s target_info_values; +} net_nfc_current_target_info_s; + +typedef struct _net_nfc_llcp_config_info_s { + uint16_t miu; /** The remote Maximum Information Unit (NOTE: this is MIU, not MIUX !)*/ + uint16_t wks; /** The remote Well-Known Services*/ + uint8_t lto; /** The remote Link TimeOut (in 1/100s)*/ + uint8_t option; /** The remote options*/ +} net_nfc_llcp_config_info_s; + +typedef struct _net_nfc_llcp_socket_option_s { + uint16_t miu; /** The remote Maximum Information Unit */ + uint8_t rw; /** The Receive Window size (4 bits)*/ + net_nfc_socket_type_e type; +} net_nfc_llcp_socket_option_s; + +typedef struct _net_nfc_llcp_internal_socket_s { + uint16_t miu; /** The remote Maximum Information Unit */ + uint8_t rw; /** The Receive Window size (4 bits)*/ + net_nfc_socket_type_e type; + net_nfc_llcp_socket_t oal_socket; + net_nfc_llcp_socket_t client_socket; + sap_t sap; + uint8_t *service_name; + net_nfc_target_handle_s *device_id; + net_nfc_llcp_socket_cb cb; + bool close_requested; + void *register_param; /* void param that has been registered in callback register time */ +} net_nfc_llcp_internal_socket_s; + +/** + ndef_record_s structure has the NDEF record data. it is only a record not a message + */ +typedef struct _record_s { + uint8_t MB:1; + uint8_t ME:1; + uint8_t CF:1; + uint8_t SR:1; + uint8_t IL:1; + uint8_t TNF:3; + data_s type_s; + data_s id_s; + data_s payload_s; + struct _record_s *next; +} ndef_record_s; + +/** + NDEF message it has record counts and records (linked listed form) + */ +typedef struct _ndef_message_s { + uint32_t recordCount; + ndef_record_s *records; // linked list +} ndef_message_s; + +/** + Enum value to stop or start the discovery mode + */ + +#define NET_NFC_MAX_UID_LENGTH 0x0AU /**< Maximum UID length expected */ +#define NET_NFC_MAX_ATR_LENGTH 0x30U /**< Maximum ATR_RES (General Bytes) */ +#define NET_NFC_ATQA_LENGTH 0x02U /**< ATQA length */ +#define NET_NFC_ATQB_LENGTH 0x0BU /**< ATQB length */ + +#define NET_NFC_PUPI_LENGTH 0x04U /**< PUPI length */ +#define NET_NFC_APP_DATA_B_LENGTH 0x04U /**< Application Data length for Type B */ +#define NET_NFC_PROT_INFO_B_LENGTH 0x03U /**< Protocol info length for Type B */ + +#define NET_NFC_MAX_ATR_LENGTH 0x30U /**< Maximum ATR_RES (General Bytes) */ +#define NET_NFC_MAX_UID_LENGTH 0x0AU /**< Maximum UID length expected */ +#define NET_NFC_FEL_ID_LEN 0x08U /**< Felica current ID Length */ +#define NET_NFC_FEL_PM_LEN 0x08U /**< Felica current PM Length */ +#define NET_NFC_FEL_SYS_CODE_LEN 0x02U /**< Felica System Code Length */ + +#define NET_NFC_15693_UID_LENGTH 0x08U /**< Length of the Inventory bytes for */ + +typedef struct _net_nfc_tag_info_s { + char *key; + data_h value; +} net_nfc_tag_info_s; + +typedef struct _net_nfc_target_info_s { + net_nfc_target_handle_s *handle; + net_nfc_target_type_e devType; + uint8_t is_ndef_supported; + uint8_t ndefCardState; + uint32_t maxDataSize; + uint32_t actualDataSize; + int number_of_keys; + net_nfc_tag_info_s *tag_info_list; + char **keylist; + data_s raw_data; +} net_nfc_target_info_s; + +typedef struct _net_nfc_se_event_info_s { + data_s aid; + data_s param; +} net_nfc_se_event_info_s; + +typedef struct _net_nfc_transceive_info_s { + uint32_t dev_type; + data_s trans_data; +} net_nfc_transceive_info_s; + +typedef struct _net_nfc_connection_handover_info_s { + net_nfc_conn_handover_carrier_type_e type; + data_s data; +} net_nfc_connection_handover_info_s; + +typedef enum _client_state_e { + NET_NFC_CLIENT_INACTIVE_STATE = 0x00, + NET_NFC_CLIENT_ACTIVE_STATE, +} client_state_e; + +typedef enum _net_nfc_launch_popup_check_e { + CHECK_FOREGROUND = 0x00, + NO_CHECK_FOREGROUND, +} net_nfc_launch_popup_check_e; + +typedef enum _net_nfc_launch_popup_state_e { + NET_NFC_LAUNCH_APP_SELECT = 0x00, + NET_NFC_NO_LAUNCH_APP_SELECT, +} net_nfc_launch_popup_state_e; + +typedef enum _net_nfc_privilege_e { + NET_NFC_PRIVILEGE_NFC = 0x00, + NET_NFC_PRIVILEGE_NFC_ADMIN, + NET_NFC_PRIVILEGE_NFC_TAG, + NET_NFC_PRIVILEGE_NFC_P2P, + NET_NFC_PRIVILEGE_NFC_CARD_EMUL +} net_nfc_privilege_e; + +/* server state */ +#define NET_NFC_SERVER_IDLE 0 +#define NET_NFC_SERVER_DISCOVERY (1 << 1) +#define NET_NFC_TAG_CONNECTED (1 << 2) +#define NET_NFC_SE_CONNECTED (1 << 3) +#define NET_NFC_SNEP_CLIENT_CONNECTED (1 << 4) +#define NET_NFC_NPP_CLIENT_CONNECTED (1 << 5) +#define NET_NFC_SNEP_SERVER_CONNECTED (1 << 6) +#define NET_NFC_NPP_SERVER_CONNECTED (1 << 7) + +// these are messages for request +#define NET_NFC_REQUEST_MSG_HEADER \ + /* DON'T MODIFY THIS CODE - BEGIN */ \ + uint32_t length; \ + uint32_t request_type; \ + uint32_t client_fd; \ + uint32_t flags; \ + void *user_param; \ + /* DON'T MODIFY THIS CODE - END */ + +typedef struct _net_nfc_request_msg_t { +NET_NFC_REQUEST_MSG_HEADER} net_nfc_request_msg_t; + +typedef struct _net_nfc_request_target_detected_t { + NET_NFC_REQUEST_MSG_HEADER net_nfc_target_handle_s *handle; + uint32_t devType; + int number_of_keys; + net_nfc_data_s target_info_values; +} net_nfc_request_target_detected_t; + +typedef struct _net_nfc_request_se_event_t { + NET_NFC_REQUEST_MSG_HEADER data_s aid; + data_s param; +} net_nfc_request_se_event_t; + +typedef struct _net_nfc_request_llcp_msg_t { + NET_NFC_REQUEST_MSG_HEADER uint32_t result; + net_nfc_llcp_socket_t llcp_socket; +} net_nfc_request_llcp_msg_t; + +typedef struct _net_nfc_request_hce_apdu_t { + NET_NFC_REQUEST_MSG_HEADER data_s apdu; +} net_nfc_request_hce_apdu_t; + +typedef struct _net_nfc_request_listen_socket_t { + NET_NFC_REQUEST_MSG_HEADER uint32_t result; + net_nfc_target_handle_s *handle; + net_nfc_llcp_socket_t client_socket; + uint16_t miu; /** The remote Maximum Information Unit */ + uint8_t rw; /** The Receive Window size (4 bits)*/ + net_nfc_socket_type_e type; + net_nfc_llcp_socket_t oal_socket; + sap_t sap; + void *trans_param; + net_nfc_data_s service_name; +} net_nfc_request_listen_socket_t; + +typedef struct _net_nfc_request_receive_socket_t { + NET_NFC_REQUEST_MSG_HEADER uint32_t result; + net_nfc_target_handle_s *handle; + net_nfc_llcp_socket_t client_socket; + net_nfc_llcp_socket_t oal_socket; + size_t req_length; + void *trans_param; + net_nfc_data_s data; +} net_nfc_request_receive_socket_t; + +typedef struct _net_nfc_request_receive_from_socket_t { + NET_NFC_REQUEST_MSG_HEADER uint32_t result; + net_nfc_target_handle_s *handle; + net_nfc_llcp_socket_t client_socket; + net_nfc_llcp_socket_t oal_socket; + size_t req_length; + sap_t sap; + void *trans_param; + net_nfc_data_s data; +} net_nfc_request_receive_from_socket_t; + +// these are messages for response + +typedef void (*target_detection_listener_cb) (void *data, void *user_param); +typedef void (*se_transaction_listener_cb) (void *data, void *user_param); +typedef void (*llcp_event_listener_cb) (void *data, void *user_param); + +/*HCE CB*/ +typedef void (*hce_active_listener_cb) (void *user_param); +typedef void (*hce_deactive_listener_cb) (void *user_param); +typedef void (*hce_apdu_listener_cb) (void *data, void *user_param); + +typedef enum _llcp_event_e { + LLCP_EVENT_SOCKET_ACCEPTED = 0x1, + LLCP_EVENT_SOCKET_ERROR, + LLCP_EVENT_DEACTIVATED, +} llcp_event_e; + +typedef struct _net_nfc_stack_information_s { + uint32_t net_nfc_supported_tagetType; + uint32_t net_nfc_fw_version; +} net_nfc_stack_information_s; + +typedef enum _net_nfc_discovery_mode_e { + NET_NFC_DISCOVERY_MODE_STOP = 0x00, + NET_NFC_DISCOVERY_MODE_CONFIG_POLLING = 0x01, + NET_NFC_DISCOVERY_MODE_CONFIG_LISTENING = 0x02, + NET_NFC_DISCOVERY_MODE_CONFIG_P2P = 0x04, + NET_NFC_DISCOVERY_MODE_CONFIG_ALL = NET_NFC_DISCOVERY_MODE_CONFIG_POLLING | NET_NFC_DISCOVERY_MODE_CONFIG_LISTENING | NET_NFC_DISCOVERY_MODE_CONFIG_P2P, + NET_NFC_DISCOVERY_MODE_CONFIG_DEFAULT = NET_NFC_DISCOVERY_MODE_CONFIG_POLLING | NET_NFC_DISCOVERY_MODE_CONFIG_LISTENING, + NET_NFC_DISCOVERY_MODE_CONFIG = NET_NFC_DISCOVERY_MODE_CONFIG_DEFAULT, + NET_NFC_DISCOVERY_MODE_START_LISTENING = NET_NFC_DISCOVERY_MODE_CONFIG_LISTENING, + NET_NFC_DISCOVERY_MODE_START_POLLING = NET_NFC_DISCOVERY_MODE_CONFIG_POLLING, + NET_NFC_DISCOVERY_MODE_START_ALL = NET_NFC_DISCOVERY_MODE_CONFIG_ALL, + NET_NFC_DISCOVERY_MODE_START_DEFAULT = NET_NFC_DISCOVERY_MODE_CONFIG_DEFAULT, + NET_NFC_DISCOVERY_MODE_START = NET_NFC_DISCOVERY_MODE_START_DEFAULT, + NET_NFC_DISCOVERY_MODE_RESUME = NET_NFC_DISCOVERY_MODE_START +} net_nfc_discovery_mode_e; + +typedef enum _net_nfc_secure_element_policy_e { + SECURE_ELEMENT_POLICY_INVALID = 0x00, + SECURE_ELEMENT_POLICY_UICC_ON = 0x01, + SECURE_ELEMENT_POLICY_UICC_OFF = 0x02, + SECURE_ELEMENT_POLICY_ESE_ON = 0x03, + SECURE_ELEMENT_POLICY_ESE_OFF = 0x04, + SECURE_ELEMENT_POLICY_HCE_ON = 0x05, + SECURE_ELEMENT_POLICY_HCE_OFF = 0x06, + SECURE_ELEMENT_POLICY_SDCARD_ON = 0x07, + SECURE_ELEMENT_POLICY_SDCARD_OFF = 0x08, +} net_nfc_secure_element_policy_e; + +typedef enum _net_nfc_secure_element_type_e { + SECURE_ELEMENT_TYPE_INVALID = 0x00, /**< Indicates SE type is Invalid */ + SECURE_ELEMENT_TYPE_ESE = 0x01, /**< Indicates SE type is SmartMX */ + SECURE_ELEMENT_TYPE_UICC = 0x02, /**<Indicates SE type is UICC */ + SECURE_ELEMENT_TYPE_SDCARD = 0x03, /**<Indicates SE type is UICC */ + SECURE_ELEMENT_TYPE_HCE = 0x04, /**<Indicates SE type is HCE */ + SECURE_ELEMENT_TYPE_UNKNOWN = 0x05 /**< Indicates SE type is Unknown */ +} net_nfc_secure_element_type_e; + +typedef enum _net_nfc_secure_element_state_e { + SECURE_ELEMENT_INACTIVE_STATE = 0x00, /**< state of the SE is In active*/ + SECURE_ELEMENT_ACTIVE_STATE = 0x01, /**< state of the SE is active */ +} net_nfc_secure_element_state_e; + +typedef enum _net_nfc_wallet_mode_e { + NET_NFC_WALLET_MODE_MANUAL = 0x00, + NET_NFC_WALLET_MODE_AUTOMATIC = 0x01, + NET_NFC_WALLET_MODE_UICC = 0x02, + NET_NFC_WALLET_MODE_ESE = 0x03, + NET_NFC_WALLET_MODE_HCE = 0x04, +} net_nfc_wallet_mode_e; + +typedef struct _secure_element_info_s { + net_nfc_target_handle_s *handle; + net_nfc_secure_element_type_e secure_element_type; + net_nfc_secure_element_state_e secure_element_state; + +} net_nfc_secure_element_info_s; + +typedef enum _net_nfc_secure_element_mode_e { + SECURE_ELEMENT_WIRED_MODE = 0x00, /**< Enables Wired Mode communication.This mode shall be applied to */ + SECURE_ELEMENT_VIRTUAL_MODE, /**< Enables Virtual Mode communication.This can be applied to UICC as well as SmartMX*/ + SECURE_ELEMENT_OFF_MODE /**< Inactivate SE.This means,put SE in in-active state */ +} net_nfc_secure_element_mode_e; + +typedef enum _net_nfc_message_service_e { + NET_NFC_MESSAGE_SERVICE_RESET = 2000, + NET_NFC_MESSAGE_SERVICE_INIT, + NET_NFC_MESSAGE_SERVICE_ACTIVATE, + NET_NFC_MESSAGE_SERVICE_DEACTIVATE, + NET_NFC_MESSAGE_SERVICE_DEINIT, + NET_NFC_MESSAGE_SERVICE_STANDALONE_TARGET_DETECTED, + NET_NFC_MESSAGE_SERVICE_SE, + NET_NFC_MESSAGE_SERVICE_TERMINATION, + NET_NFC_MESSAGE_SERVICE_SLAVE_TARGET_DETECTED, + NET_NFC_MESSAGE_SERVICE_SLAVE_ESE_DETECTED, + NET_NFC_MESSAGE_SERVICE_RESTART_POLLING_LOOP, + NET_NFC_MESSAGE_SERVICE_LLCP_LISTEN, + NET_NFC_MESSAGE_SERVICE_LLCP_INCOMING, + NET_NFC_MESSAGE_SERVICE_LLCP_ACCEPT, + NET_NFC_MESSAGE_SERVICE_LLCP_REJECT, + NET_NFC_MESSAGE_SERVICE_LLCP_SEND, + NET_NFC_MESSAGE_SERVICE_LLCP_SEND_TO, + NET_NFC_MESSAGE_SERVICE_LLCP_RECEIVE, + NET_NFC_MESSAGE_SERVICE_LLCP_RECEIVE_FROM, + NET_NFC_MESSAGE_SERVICE_LLCP_CONNECT, + NET_NFC_MESSAGE_SERVICE_LLCP_CONNECT_SAP, + NET_NFC_MESSAGE_SERVICE_LLCP_DISCONNECT, + NET_NFC_MESSAGE_SERVICE_LLCP_DEACTIVATED, + NET_NFC_MESSAGE_SERVICE_LLCP_SOCKET_ERROR, + NET_NFC_MESSAGE_SERVICE_LLCP_SOCKET_ACCEPTED_ERROR, + NET_NFC_MESSAGE_SERVICE_CHANGE_CLIENT_STATE, + NET_NFC_MESSAGE_SERVICE_WATCH_DOG, + NET_NFC_MESSAGE_SERVICE_CLEANER, + NET_NFC_MESSAGE_SERVICE_SET_LAUNCH_STATE, +} net_nfc_message_service_e; + +typedef enum _net_nfc_se_command_e { + NET_NFC_SE_CMD_UICC_ON = 0, + NET_NFC_SE_CMD_ESE_ON, + NET_NFC_SE_CMD_ALL_OFF, + NET_NFC_SE_CMD_ALL_ON, +} net_nfc_se_command_e; + +/* connection handover info */ + +typedef enum { + NET_NFC_CONN_HANDOVER_ERR_REASON_RESERVED = 0x00, + NET_NFC_CONN_HANDOVER_ERR_REASON_TEMP_MEM_CONSTRAINT, + NET_NFC_CONN_HANDOVER_ERR_REASON_PERM_MEM_CONSTRAINT, + NET_NFC_CONN_HANDOVER_ERR_REASON_CARRIER_SPECIFIC_CONSTRAINT, +} net_nfc_conn_handover_error_reason_e; + +#define SMART_POSTER_RECORD_TYPE "Sp" +#define URI_RECORD_TYPE "U" +#define TEXT_RECORD_TYPE "T" +#define GC_RECORD_TYPE "Gc" + +#define URI_SCHEM_FILE "file://" + +typedef void (*net_nfc_service_llcp_cb) (net_nfc_llcp_socket_t socket, net_nfc_error_e result, data_s * data, void *extra, void *user_param); + +typedef struct _net_nfc_llcp_param_t { + net_nfc_llcp_socket_t socket; + net_nfc_service_llcp_cb cb; + data_s data; + void *user_param; +} net_nfc_llcp_param_t; + +typedef enum { + NET_NFC_SCREEN_INVALID = 0x00, + NET_NFC_SCREEN_OFF = 0x01, + NET_NFC_SCREEN_ON_LOCK = 0x02, + NET_NFC_SCREEN_ON_UNLOCK = 0x03, +} net_nfc_screen_state_type_e; + +#ifdef __cplusplus +} +#endif +#endif /* __HAL_NFC__ */ + diff --git a/include/hal-nfc.h b/include/hal-nfc.h new file mode 100755 index 0000000..1e8b7bc --- /dev/null +++ b/include/hal-nfc.h @@ -0,0 +1,105 @@ +/* + * 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. + */ + +#ifndef __HAL_NFC__ +#define __HAL_NFC__ + +#ifdef __cplusplus +extern "C" { +#endif + +int hal_nfc_get_backend(void); +int hal_nfc_put_backend(void); + +bool hal_nfc_start(int *result); +bool hal_nfc_stop(void); + +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); +bool hal_nfc_unregister_listener(void); +bool hal_nfc_support_nfc(net_nfc_error_e * result); +bool hal_nfc_get_firmware_version(data_s ** data, net_nfc_error_e * result); +bool hal_nfc_check_firmware_version(net_nfc_error_e * result); +bool hal_nfc_update_firmware(net_nfc_error_e * result); +bool hal_nfc_get_stack_information(net_nfc_stack_information_s * stack_info, net_nfc_error_e * result); +bool hal_nfc_configure_discovery(net_nfc_discovery_mode_e mode, net_nfc_event_filter_e config, net_nfc_error_e * result); +bool hal_nfc_check_target_presence(net_nfc_target_handle_s * handle, net_nfc_error_e * result); +bool hal_nfc_connect(net_nfc_target_handle_s * handle, net_nfc_error_e * result); +bool hal_nfc_disconnect(net_nfc_target_handle_s * handle, net_nfc_error_e * result); +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); +bool hal_nfc_read_ndef(net_nfc_target_handle_s * handle, data_s ** data, net_nfc_error_e * result); +bool hal_nfc_write_ndef(net_nfc_target_handle_s * handle, data_s * data, net_nfc_error_e * result); +bool hal_nfc_make_read_only_ndef(net_nfc_target_handle_s * handle, net_nfc_error_e * result); +bool hal_nfc_format_ndef(net_nfc_target_handle_s * handle, data_s * secure_key, net_nfc_error_e * result); +bool hal_nfc_transceive(net_nfc_target_handle_s * handle, net_nfc_transceive_info_s * info, data_s ** data, net_nfc_error_e * result); +bool hal_nfc_exception_handler(void); +bool hal_nfc_is_ready(net_nfc_error_e * result); + +/* llcp api */ +bool hal_nfc_llcp_config(net_nfc_llcp_config_info_s * config, net_nfc_error_e * result); +bool hal_nfc_llcp_check_llcp(net_nfc_target_handle_s * handle, net_nfc_error_e * result); +bool hal_nfc_llcp_activate_llcp(net_nfc_target_handle_s * handle, net_nfc_error_e * result); +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); +bool hal_nfc_llcp_bind(net_nfc_llcp_socket_t socket, uint8_t service_access_point, net_nfc_error_e * result); +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); +bool hal_nfc_llcp_accept(net_nfc_llcp_socket_t socket, net_nfc_error_e * result, void *user_param); +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); +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); +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); +bool hal_nfc_llcp_socket_close(net_nfc_llcp_socket_t socket, net_nfc_error_e * result); +bool hal_nfc_llcp_recv(net_nfc_target_handle_s * handle, net_nfc_llcp_socket_t socket, data_s * max_len, net_nfc_error_e * result, void *user_param); +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); +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); +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); +bool hal_nfc_llcp_reject(net_nfc_target_handle_s * handle, net_nfc_llcp_socket_t socket, net_nfc_error_e * result); +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); +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); + +/* secure element api */ +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); +bool hal_nfc_secure_element_get_atr(net_nfc_target_handle_s * handle, data_s ** atr, net_nfc_error_e * result); +bool hal_nfc_secure_element_send_apdu(net_nfc_target_handle_s * handle, data_s * command, data_s ** response, net_nfc_error_e * result); +bool hal_nfc_secure_element_close(net_nfc_target_handle_s * handle, net_nfc_error_e * result); +bool hal_nfc_get_secure_element_list(net_nfc_secure_element_info_s * list, int *count, net_nfc_error_e * result); +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); + +/* test api */ +bool hal_nfc_sim_test(net_nfc_error_e * result); +bool hal_nfc_prbs_test(net_nfc_error_e * result, uint32_t tech, uint32_t rate); +bool hal_nfc_test_mode_on(net_nfc_error_e * result); +bool hal_nfc_test_mode_off(net_nfc_error_e * result); +bool hal_nfc_eedata_register_set(net_nfc_error_e * result, uint32_t mode, uint32_t reg_id, data_s * data); +bool hal_nfc_ese_test(net_nfc_error_e * result); +bool hal_nfc_test_set_se_tech_type(net_nfc_error_e * result, net_nfc_se_type_e type, uint32_t tech); + +/* hce api */ +bool hal_nfc_hce_response_apdu(net_nfc_target_handle_s * handle, data_s * response, net_nfc_error_e * result); +bool hal_nfc_secure_element_route_aid(data_s * aid, net_nfc_se_type_e se_type, int power, net_nfc_error_e * result); +bool hal_nfc_secure_element_unroute_aid(data_s * aid, net_nfc_error_e * result); +bool hal_nfc_secure_element_commit_routing(net_nfc_error_e * result); +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); +bool hal_nfc_secure_element_clear_aid_table(net_nfc_error_e * result); +bool hal_nfc_secure_element_get_aid_table_size(int *AIDTableSize, net_nfc_error_e * result); +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); +bool hal_nfc_secure_element_clear_routing_entry(net_nfc_se_entry_type_e type, net_nfc_error_e * result); +bool hal_nfc_secure_element_set_listen_tech_mask(net_nfc_se_tech_protocol_type_e screen_state, net_nfc_error_e * result); +bool hal_nfc_set_screen_state(net_nfc_screen_state_type_e screen_state, net_nfc_error_e * result); + +#ifdef __cplusplus +} +#endif +#endif /* __HAL_NFC__ */ diff --git a/packaging/hal-api-nfc-devel.manifest b/packaging/hal-api-nfc-devel.manifest new file mode 100644 index 0000000..81ace0c --- /dev/null +++ b/packaging/hal-api-nfc-devel.manifest @@ -0,0 +1,6 @@ +<manifest> + <request> + <domain name="_"/> + </request> +</manifest> + diff --git a/packaging/hal-api-nfc.manifest b/packaging/hal-api-nfc.manifest new file mode 100644 index 0000000..81ace0c --- /dev/null +++ b/packaging/hal-api-nfc.manifest @@ -0,0 +1,6 @@ +<manifest> + <request> + <domain name="_"/> + </request> +</manifest> + diff --git a/packaging/hal-api-nfc.spec b/packaging/hal-api-nfc.spec new file mode 100644 index 0000000..ccec6d7 --- /dev/null +++ b/packaging/hal-api-nfc.spec @@ -0,0 +1,73 @@ +%define module_name nfc +%define name hal-api-nfc +%define devel_name hal-api-nfc-devel + +### main package ######### +Name: %{name} +Summary: %{name} interface +Version: 0.0.1 +Release: 1 +Group: Development/Libraries +License: Apache-2.0 +Source0: %{name}-%{version}.tar.gz +Source1: %{name}.manifest +Source2: %{devel_name}.manifest + +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig +BuildRequires: cmake +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(gio-2.0) +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(gmock) +BuildRequires: pkgconfig(hal-api-common) + +%description +%{name} interface + +### devel package ######### +%package -n %{devel_name} +Summary: %{name} interface +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description -n %{devel_name} +%{name} Interface for product vendor developer + +### build and install ######### +%prep +%setup -q + +cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_LIBDIR_PREFIX=%{_libdir}/ + +%build +cp %{SOURCE1} . +cp %{SOURCE2} . +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install + +%clean +rm -rf %{buildroot} + +%post +/sbin/ldconfig + +%postun +/sbin/ldconfig + +### contain files to package ######### +%files -n %{name} +%manifest %{name}.manifest +%license LICENSE +%defattr(-,root,root,-) +%{_libdir}/hal/*.so* + +%files -n %{devel_name} +%defattr(-,root,root,-) +%manifest %{devel_name}.manifest +%license LICENSE +%{_includedir}/hal/*.h +%{_libdir}/pkgconfig/%{name}.pc diff --git a/src/common.h b/src/common.h new file mode 100755 index 0000000..b69f8b8 --- /dev/null +++ b/src/common.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __COMMON_H__ +#define __COMMON_H__ + +#include <dlog.h> +#define _D(fmt, args...) SLOGD(fmt, ##args) +#define _I(fmt, args...) SLOGI(fmt, ##args) +#define _W(fmt, args...) SLOGW(fmt, ##args) +#define _E(fmt, args...) SLOGE(fmt, ##args) + +#endif /* __COMMON_H__ */ diff --git a/src/hal-api-nfc.c b/src/hal-api-nfc.c new file mode 100755 index 0000000..026a06b --- /dev/null +++ b/src/hal-api-nfc.c @@ -0,0 +1,583 @@ +/* + * 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(int *result) +{ + if (!g_nfc_funcs) + return -ENOTSUP; + return g_nfc_funcs->start(result); +} + +EXPORT +bool hal_nfc_stop(void) +{ + if (!g_nfc_funcs) + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + return g_nfc_funcs->transceive(handle, info, data, result); +} + +EXPORT +bool hal_nfc_exception_handler(void) +{ + if (!g_nfc_funcs) + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + return g_nfc_funcs->set_screen_state(screen_state, result); +} |