2 * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "nfc_common.h"
19 bool nfc_manager_is_supported(void)
21 bool nfc_supported = false;
25 nfc_supported = nfc_common_is_supported(NFC_FEATURE);
27 if (nfc_supported == true)
28 set_last_result(NFC_ERROR_NONE);
30 set_last_result(NFC_ERROR_NOT_SUPPORTED); // LCOV_EXCL_LINE
36 static void _activation_changed_cb(net_nfc_error_e result, void *user_data)
38 nfc_activation_data_s *data = user_data;
42 if (user_data == NULL) {
43 LOG_ERR("user_data is NULL");
47 if (data->callback != NULL)
48 data->callback(nfc_common_convert_error_code(__func__, result), data->user_data);
54 int nfc_manager_set_activation(bool activation,
55 nfc_activation_completed_cb callback,
62 CHECK_SUPPORTED(NFC_FEATURE);
67 if (nfc_manager_is_activated() == activation) {
69 ret = NFC_ERROR_ALREADY_ACTIVATED;
71 ret = NFC_ERROR_ALREADY_DEACTIVATED;
73 nfc_activation_data_s *data = NULL;
75 data = (nfc_activation_data_s *)malloc(sizeof(nfc_activation_data_s));
78 data->callback = callback;
79 data->user_data = user_data;
80 ret = net_nfc_client_manager_set_active(activation,
81 _activation_changed_cb,
83 if (ret != NET_NFC_OK) {
84 LOG_ERR("net_nfc_client_manager_set_active fail");
89 ret = NET_NFC_ALLOC_FAIL;
92 ret = nfc_common_convert_error_code(__func__, ret);
99 int nfc_manager_configure_discovery(int mode)
105 CHECK_SUPPORTED(NFC_FEATURE);
107 /* LCOV_EXCL_START */
111 ret = net_nfc_client_manager_configure_discovery_sync(mode);
113 return nfc_common_convert_error_code(__func__, ret);
117 int nfc_manager_test_mode_on(void)
123 CHECK_SUPPORTED(NFC_FEATURE);
125 /* LCOV_EXCL_START */
129 ret = net_nfc_client_test_test_mode_on_sync();
131 return nfc_common_convert_error_code(__func__, ret);
135 int nfc_manager_test_mode_off(void)
141 CHECK_SUPPORTED(NFC_FEATURE);
143 /* LCOV_EXCL_START */
147 ret = net_nfc_client_test_test_mode_off_sync();
149 return nfc_common_convert_error_code(__func__, ret);
153 bool nfc_manager_is_activated(void)
160 if (nfc_common_is_supported(NFC_FEATURE) == false) {
161 set_last_result(NFC_ERROR_NOT_SUPPORTED);
165 /* LCOV_EXCL_START */
166 ret = net_nfc_client_get_nfc_state(&activated);
168 set_last_result(nfc_common_convert_error_code(__func__, ret));
170 return (!!activated);
174 int nfc_manager_set_activation_changed_cb(nfc_activation_changed_cb callback,
179 CHECK_SUPPORTED(NFC_FEATURE);
181 /* LCOV_EXCL_START */
183 CHECK_INVALID(callback == NULL);
185 net_nfc_client_manager_set_activated(callback, user_data);
187 return NFC_ERROR_NONE;
191 void nfc_manager_unset_activation_changed_cb(void)
195 if (nfc_common_is_supported(NFC_FEATURE) == false) {
196 /* LCOV_EXCL_START */
197 LOG_ERR("NFC not supported");
198 set_last_result(NFC_ERROR_NOT_SUPPORTED);
203 /* LCOV_EXCL_START */
204 if (nfc_common_is_initialized() == false) {
205 LOG_ERR("NFC not initialized");
206 set_last_result(NFC_ERROR_NOT_INITIALIZED);
210 net_nfc_client_manager_unset_activated();
212 set_last_result(NFC_ERROR_NONE);
216 int nfc_manager_initialize(void)
218 int ret = NET_NFC_OK;
222 CHECK_SUPPORTED(NFC_FEATURE);
224 /* LCOV_EXCL_START */
225 if (!nfc_common_is_initialized()) {
226 ret = net_nfc_client_initialize();
227 if (ret != NET_NFC_OK)
228 return nfc_common_convert_error_code(__func__, ret);
230 memset(&gdbus_nfc_context, 0, sizeof(gdbus_nfc_context));
232 gdbus_nfc_context.initialized = true;
235 return nfc_common_convert_error_code(__func__, ret);
239 int nfc_manager_deinitialize(void)
241 int ret = NET_NFC_OK;
245 CHECK_SUPPORTED(NFC_FEATURE);
247 /* LCOV_EXCL_START */
248 if (nfc_common_is_initialized()) {
249 net_nfc_client_se_unset_event_cb();
251 net_nfc_client_p2p_unset_device_discovered();
252 net_nfc_client_p2p_unset_device_detached();
254 net_nfc_client_tag_unset_tag_discovered();
255 net_nfc_client_tag_unset_tag_detached();
257 ret = net_nfc_client_deinitialize();
259 gdbus_nfc_context.initialized = false;
262 return nfc_common_convert_error_code(__func__, ret);
266 /* LCOV_EXCL_START */
267 static void _tag_discovered_cb(net_nfc_target_info_h info, void *user_data)
271 gdbus_nfc_context.current_tag = info;
273 if (gdbus_nfc_context.on_tag_discovered_cb != NULL) {
274 gdbus_nfc_context.on_tag_discovered_cb(
275 NFC_DISCOVERED_TYPE_ATTACHED,
276 (nfc_tag_h)gdbus_nfc_context.current_tag,
277 gdbus_nfc_context.on_tag_discovered_user_data);
280 /* ndef discovered cb */
281 if (gdbus_nfc_context.on_ndef_discovered_cb) {
282 ndef_message_h ndef_message = NULL;
284 if (net_nfc_get_tag_ndef_message((net_nfc_target_info_h)info,
285 &ndef_message) == NET_NFC_OK) {
286 gdbus_nfc_context.on_ndef_discovered_cb(ndef_message,
287 gdbus_nfc_context.on_ndef_discovered_user_data);
289 net_nfc_free_ndef_message(ndef_message);
294 static void _tag_detached_cb(void *user_data)
298 if (gdbus_nfc_context.on_tag_discovered_cb != NULL) {
299 gdbus_nfc_context.on_tag_discovered_cb(
300 NFC_DISCOVERED_TYPE_DETACHED,
301 (nfc_tag_h)gdbus_nfc_context.current_tag,
302 gdbus_nfc_context.on_tag_discovered_user_data);
305 gdbus_nfc_context.current_tag = NULL;
309 int nfc_manager_set_ndef_discovered_cb(
310 nfc_ndef_discovered_cb callback,
315 CHECK_SUPPORTED(NFC_FEATURE);
317 /* LCOV_EXCL_START */
319 CHECK_INVALID(callback == NULL);
321 net_nfc_client_tag_set_tag_discovered(_tag_discovered_cb, NULL);
322 net_nfc_client_tag_set_tag_detached(_tag_detached_cb, NULL);
324 gdbus_nfc_context.on_ndef_discovered_cb = callback;
325 gdbus_nfc_context.on_ndef_discovered_user_data = user_data;
327 return NFC_ERROR_NONE;
331 void nfc_manager_unset_ndef_discovered_cb(void)
335 if (nfc_common_is_supported(NFC_FEATURE) == false) {
336 /* LCOV_EXCL_START */
337 LOG_ERR("NFC not supported");
338 set_last_result(NFC_ERROR_NOT_SUPPORTED);
343 /* LCOV_EXCL_START */
344 if (nfc_common_is_initialized() == false) {
345 LOG_ERR("NFC not initialized");
346 set_last_result(NFC_ERROR_NOT_INITIALIZED);
350 gdbus_nfc_context.on_ndef_discovered_cb = NULL;
351 gdbus_nfc_context.on_ndef_discovered_user_data = NULL;
353 set_last_result(NFC_ERROR_NONE);
357 void nfc_manager_set_tag_filter(int filter)
361 if (nfc_common_is_supported(NFC_TAG_FEATURE) == false) {
362 LOG_ERR("NFC not supported");
363 set_last_result(NFC_ERROR_NOT_SUPPORTED);
367 /* LCOV_EXCL_START */
368 if (nfc_common_is_initialized() == false) {
369 LOG_ERR("NFC not initialized");
370 set_last_result(NFC_ERROR_NOT_INITIALIZED);
374 if (filter < NET_NFC_ALL_ENABLE) {
375 LOG_ERR("Invalid parameter");
376 set_last_result(NFC_ERROR_INVALID_PARAMETER);
380 net_nfc_client_tag_set_filter(filter);
382 set_last_result(NFC_ERROR_NONE);
386 int nfc_manager_get_tag_filter(void)
390 if (nfc_common_is_supported(NFC_TAG_FEATURE) == false) {
391 LOG_ERR("NFC not supported");
392 set_last_result(NFC_ERROR_NOT_SUPPORTED);
396 /* LCOV_EXCL_START */
397 if (nfc_common_is_initialized() == false) {
398 LOG_ERR("NFC not initialized");
399 set_last_result(NFC_ERROR_NOT_INITIALIZED);
403 set_last_result(NFC_ERROR_NONE);
405 return net_nfc_client_tag_get_filter();
409 int nfc_manager_get_connected_tag(nfc_tag_h *tag)
412 net_nfc_target_info_h result = NULL;
416 CHECK_SUPPORTED(NFC_TAG_FEATURE);
418 /* LCOV_EXCL_START */
420 CHECK_INVALID(tag == NULL);
424 net_nfc_client_tag_set_tag_discovered(_tag_discovered_cb, NULL);
425 net_nfc_client_tag_set_tag_detached(_tag_detached_cb, NULL);
428 if (gdbus_nfc_context.current_tag == NULL) {
429 ret = net_nfc_client_tag_get_current_tag_info_sync(&result);
430 if (ret == NET_NFC_OK)
431 *tag = (nfc_tag_h)result;
434 *tag = gdbus_nfc_context.current_tag;
439 return nfc_common_convert_error_code(__func__, ret);
443 int nfc_manager_get_connected_target(nfc_p2p_target_h *target)
446 net_nfc_target_handle_h result = NULL;
450 CHECK_SUPPORTED(NFC_P2P_FEATURE);
452 /* LCOV_EXCL_START */
454 CHECK_INVALID(target == NULL);
458 net_nfc_client_tag_set_tag_discovered(_tag_discovered_cb, NULL);
459 net_nfc_client_tag_set_tag_detached(_tag_detached_cb, NULL);
461 if (gdbus_nfc_context.current_target == NULL) {
462 ret = net_nfc_client_tag_get_current_target_handle_sync(&result);
463 if (ret == NET_NFC_OK) {
464 gdbus_nfc_context.current_target = result;
466 *target = gdbus_nfc_context.current_target;
470 *target = gdbus_nfc_context.current_target;
475 return nfc_common_convert_error_code(__func__, ret);
479 int nfc_manager_set_tag_discovered_cb(nfc_tag_discovered_cb callback,
484 CHECK_SUPPORTED(NFC_TAG_FEATURE);
486 /* LCOV_EXCL_START */
488 CHECK_INVALID(callback == NULL);
490 net_nfc_client_tag_set_tag_discovered(_tag_discovered_cb, NULL);
491 net_nfc_client_tag_set_tag_detached(_tag_detached_cb, NULL);
493 gdbus_nfc_context.on_tag_discovered_cb = callback;
494 gdbus_nfc_context.on_tag_discovered_user_data = user_data;
496 return NFC_ERROR_NONE;
500 void nfc_manager_unset_tag_discovered_cb(void)
504 if (nfc_common_is_supported(NFC_TAG_FEATURE) == false) {
505 LOG_ERR("NFC not supported");
506 set_last_result(NFC_ERROR_NOT_SUPPORTED);
510 /* LCOV_EXCL_START */
511 if (nfc_common_is_initialized() == false) {
512 LOG_ERR("NFC not initialized");
513 set_last_result(NFC_ERROR_NOT_INITIALIZED);
517 gdbus_nfc_context.on_tag_discovered_cb = NULL;
518 gdbus_nfc_context.on_tag_discovered_user_data = NULL;
520 set_last_result(NFC_ERROR_NONE);
524 /* LCOV_EXCL_START */
525 static void _p2p_discovered_cb(
526 net_nfc_target_handle_h handle_info,
531 gdbus_nfc_context.current_target = handle_info;
533 if (gdbus_nfc_context.on_p2p_target_discovered_cb != NULL) {
534 gdbus_nfc_context.on_p2p_target_discovered_cb(
535 NFC_DISCOVERED_TYPE_ATTACHED,
536 (nfc_p2p_target_h)gdbus_nfc_context.current_target,
537 gdbus_nfc_context.on_p2p_target_discovered_user_data);
541 static void _p2p_detached_cb(void *user_data)
543 nfc_p2p_target_h handle =
544 (nfc_p2p_target_h)gdbus_nfc_context.current_target;
548 if (gdbus_nfc_context.on_p2p_target_discovered_cb != NULL) {
549 gdbus_nfc_context.on_p2p_target_discovered_cb(
550 NFC_DISCOVERED_TYPE_DETACHED,
552 gdbus_nfc_context.on_p2p_target_discovered_user_data);
555 /* unset data_received callback */
556 nfc_p2p_unset_data_received_cb(handle);
558 gdbus_nfc_context.current_target = NULL;
562 int nfc_manager_set_p2p_target_discovered_cb(
563 nfc_p2p_target_discovered_cb callback,
568 CHECK_SUPPORTED(NFC_P2P_FEATURE);
570 /* LCOV_EXCL_START */
572 CHECK_INVALID(callback == NULL);
574 net_nfc_client_p2p_set_device_discovered(_p2p_discovered_cb, NULL);
575 net_nfc_client_p2p_set_device_detached(_p2p_detached_cb, NULL);
577 gdbus_nfc_context.on_p2p_target_discovered_cb = callback;
578 gdbus_nfc_context.on_p2p_target_discovered_user_data = user_data;
580 return NFC_ERROR_NONE;
584 void nfc_manager_unset_p2p_target_discovered_cb(void)
588 if (nfc_common_is_supported(NFC_P2P_FEATURE) == false) {
589 LOG_ERR("NFC not supported");
590 set_last_result(NFC_ERROR_NOT_SUPPORTED);
594 /* LCOV_EXCL_START */
595 if (nfc_common_is_initialized() == false) {
596 LOG_ERR("NFC not initialized");
597 set_last_result(NFC_ERROR_NOT_INITIALIZED);
601 gdbus_nfc_context.on_p2p_target_discovered_cb = NULL;
602 gdbus_nfc_context.on_p2p_target_discovered_user_data = NULL;
604 set_last_result(NFC_ERROR_NONE);
608 int nfc_manager_set_system_handler_enable(bool enable)
615 CHECK_SUPPORTED(NFC_FEATURE);
617 /* LCOV_EXCL_START */
625 ret = net_nfc_client_sys_handler_set_launch_popup_state(state);
627 return nfc_common_convert_error_code(__func__, ret);
631 int nfc_manager_set_system_handler_enable_force(bool enable)
638 CHECK_SUPPORTED(NFC_FEATURE);
640 /* LCOV_EXCL_START */
648 ret = net_nfc_client_sys_handler_set_launch_popup_state_force(state);
650 return nfc_common_convert_error_code(__func__, ret);
654 bool nfc_manager_is_system_handler_enabled(void)
661 if (nfc_common_is_supported(NFC_FEATURE) == false) {
662 /* LCOV_EXCL_START */
663 LOG_ERR("NFC not supported");
664 set_last_result(NFC_ERROR_NOT_SUPPORTED);
669 /* LCOV_EXCL_START */
670 if (nfc_common_is_initialized() == false) {
671 LOG_ERR("NFC not initialized");
672 set_last_result(NFC_ERROR_NOT_INITIALIZED);
676 ret = net_nfc_client_sys_handler_get_launch_popup_state(&state);
678 set_last_result(nfc_common_convert_error_code(__func__, ret));
684 int nfc_manager_get_cached_message(nfc_ndef_message_h *ndef_message)
690 CHECK_SUPPORTED(NFC_FEATURE);
692 /* LCOV_EXCL_START */
694 CHECK_INVALID(ndef_message == NULL);
696 ret = net_nfc_retrieve_current_ndef_message(ndef_message);
698 return nfc_common_convert_error_code(__func__, ret);
702 /* LCOV_EXCL_START */
703 static void _se_event_cb(net_nfc_message_e message, void *user_data)
707 if (gdbus_nfc_context.on_se_event_cb != NULL) {
708 if (message == NET_NFC_MESSAGE_SE_CARD_EMULATION_CHANGED)
709 gdbus_nfc_context.on_se_event_cb(
710 NFC_SE_EVENT_CARD_EMULATION_CHANGED,
711 gdbus_nfc_context.on_se_event_user_data);
713 else if (message == NET_NFC_MESSAGE_SE_TYPE_CHANGED)
714 gdbus_nfc_context.on_se_event_cb(
715 NFC_SE_EVENT_SE_TYPE_CHANGED,
716 gdbus_nfc_context.on_se_event_user_data);
717 else if (message == NET_NFC_MESSAGE_SE_FIELD_ON)
718 gdbus_nfc_context.on_se_event_cb(
719 NFC_SE_EVENT_FIELD_ON,
720 gdbus_nfc_context.on_se_event_user_data);
725 int nfc_manager_set_se_event_cb(nfc_se_event_cb callback, void *user_data)
729 CHECK_SUPPORTED(NFC_CE_FEATURE);
731 /* LCOV_EXCL_START */
733 CHECK_INVALID(callback == NULL);
735 net_nfc_client_se_set_event_cb(_se_event_cb, NULL);
737 gdbus_nfc_context.on_se_event_cb = callback;
738 gdbus_nfc_context.on_se_event_user_data = user_data;
740 return NFC_ERROR_NONE;
744 void nfc_manager_unset_se_event_cb(void)
748 if (nfc_common_is_supported(NFC_CE_FEATURE) == false) {
749 /* LCOV_EXCL_START */
750 LOG_ERR("NFC not supported");
751 set_last_result(NFC_ERROR_NOT_SUPPORTED);
756 /* LCOV_EXCL_START */
757 if (nfc_common_is_initialized() == false) {
758 LOG_ERR("NFC not initialized");
759 set_last_result(NFC_ERROR_NOT_INITIALIZED);
763 gdbus_nfc_context.on_se_event_cb = NULL;
764 gdbus_nfc_context.on_se_event_user_data = NULL;
766 set_last_result(NFC_ERROR_NONE);
770 /* LCOV_EXCL_START */
771 static void _se_transaction_event_cb(net_nfc_se_type_e se_type, data_h aid,
772 data_h param, void *user_data)
776 if (gdbus_nfc_context.on_se_transaction_event_cb != NULL) {
777 gdbus_nfc_context.on_se_transaction_event_cb(
779 net_nfc_get_data_buffer(aid),
780 net_nfc_get_data_length(aid),
781 net_nfc_get_data_buffer(param),
782 net_nfc_get_data_length(param),
783 gdbus_nfc_context.on_se_transaction_event_user_data);
788 int nfc_manager_set_se_transaction_event_cb(
789 nfc_se_type_e se_type,
790 nfc_se_transaction_event_cb callback,
793 net_nfc_se_type_e type = NET_NFC_SE_TYPE_NONE;
797 CHECK_SUPPORTED(NFC_CE_FEATURE);
799 /* LCOV_EXCL_START */
801 CHECK_INVALID(callback == NULL);
803 gdbus_nfc_context.on_se_transaction_event_cb = callback;
804 gdbus_nfc_context.on_se_transaction_event_user_data = user_data;
807 case NFC_SE_TYPE_ESE:
808 type = NET_NFC_SE_TYPE_ESE;
811 case NFC_SE_TYPE_UICC:
812 type = NET_NFC_SE_TYPE_UICC;
814 case NET_NFC_SE_TYPE_HCE:
815 type = NET_NFC_SE_TYPE_HCE;
818 return NFC_ERROR_INVALID_PARAMETER;
822 net_nfc_client_se_set_transaction_event_cb(type, _se_transaction_event_cb, user_data);
824 return NFC_ERROR_NONE;
828 void nfc_manager_unset_se_transaction_event_cb(nfc_se_type_e se_type)
830 net_nfc_se_type_e type = NET_NFC_SE_TYPE_NONE;
834 if (nfc_common_is_supported(NFC_CE_FEATURE) == false) {
835 /* LCOV_EXCL_START */
836 LOG_ERR("NFC not supported");
837 set_last_result(NFC_ERROR_NOT_SUPPORTED);
842 /* LCOV_EXCL_START */
843 if (nfc_common_is_initialized() == false) {
844 LOG_ERR("NFC not initialized");
845 set_last_result(NFC_ERROR_NOT_INITIALIZED);
850 case NFC_SE_TYPE_ESE:
851 type = NET_NFC_SE_TYPE_ESE;
854 case NFC_SE_TYPE_UICC:
855 type = NET_NFC_SE_TYPE_UICC;
858 type = NET_NFC_SE_TYPE_NONE;
862 net_nfc_client_se_unset_transaction_event_cb(type);
864 set_last_result(NFC_ERROR_NONE);
868 int nfc_manager_enable_transaction_fg_dispatch()
870 net_nfc_error_e result;
874 CHECK_SUPPORTED(NFC_CE_FEATURE);
876 /* LCOV_EXCL_START */
879 result = net_nfc_client_se_set_transaction_fg_dispatch(true);
881 return nfc_common_convert_error_code(__func__, result);
885 int nfc_manager_disable_transaction_fg_dispatch()
887 net_nfc_error_e result;
889 CHECK_SUPPORTED(NFC_CE_FEATURE);
891 /* LCOV_EXCL_START */
894 result = net_nfc_client_se_set_transaction_fg_dispatch(false);
896 return nfc_common_convert_error_code(__func__, result);
900 int nfc_manager_set_se_type(nfc_se_type_e type)
903 net_nfc_se_type_e se_type = NET_NFC_SE_TYPE_NONE;
907 CHECK_SUPPORTED(NFC_CE_FEATURE);
909 /* LCOV_EXCL_START */
911 CHECK_INVALID(type < NFC_SE_TYPE_DISABLE);
912 CHECK_INVALID(type > NFC_SE_TYPE_HCE);
915 case NFC_SE_TYPE_ESE:
916 se_type = NET_NFC_SE_TYPE_ESE;
918 case NFC_SE_TYPE_UICC:
919 se_type = NET_NFC_SE_TYPE_UICC;
921 case NFC_SE_TYPE_SDCARD:
922 se_type = NET_NFC_SE_TYPE_SDCARD;
924 case NFC_SE_TYPE_HCE:
925 se_type = NET_NFC_SE_TYPE_HCE;
928 se_type = NET_NFC_SE_TYPE_NONE;
932 ret = net_nfc_client_se_set_secure_element_type_sync(se_type);
934 return nfc_common_convert_error_code(__func__, ret);
938 int nfc_manager_get_se_type(nfc_se_type_e *type)
941 net_nfc_se_type_e se_type = NET_NFC_SE_TYPE_NONE;
945 CHECK_SUPPORTED(NFC_CE_FEATURE);
947 /* LCOV_EXCL_START */
949 CHECK_INVALID(type == NULL);
951 ret = net_nfc_client_se_get_secure_element_type_sync(&se_type);
954 case NET_NFC_SE_TYPE_ESE:
955 *type = NFC_SE_TYPE_ESE;
957 case NET_NFC_SE_TYPE_UICC:
958 *type = NFC_SE_TYPE_UICC;
960 case NET_NFC_SE_TYPE_SDCARD:
961 *type = NFC_SE_TYPE_SDCARD;
963 case NET_NFC_SE_TYPE_HCE:
964 *type = NFC_SE_TYPE_HCE;
967 *type = NFC_SE_TYPE_DISABLE;
971 return nfc_common_convert_error_code(__func__, ret);
975 /* LCOV_EXCL_START */
976 static void _hce_event_cb(net_nfc_target_handle_h handle,
977 net_nfc_hce_event_t event, data_h apdu, void *user_data)
981 if (gdbus_nfc_context.on_hce_event_cb != NULL) {
982 gdbus_nfc_context.on_hce_event_cb(
984 (nfc_hce_event_type_e)event,
985 net_nfc_get_data_buffer(apdu),
986 net_nfc_get_data_length(apdu),
987 gdbus_nfc_context.on_hce_event_user_data);
992 int nfc_manager_set_hce_event_cb(nfc_hce_event_cb callback, void *user_data)
994 net_nfc_error_e result;
997 CHECK_SUPPORTED(NFC_CE_HCE_FEATURE);
999 /* LCOV_EXCL_START */
1001 CHECK_INVALID(callback == NULL);
1003 gdbus_nfc_context.on_hce_event_cb = callback;
1004 gdbus_nfc_context.on_hce_event_user_data = user_data;
1006 result = net_nfc_client_hce_set_event_received_cb(_hce_event_cb, user_data);
1008 return nfc_common_convert_error_code(__func__, result);
1009 /* LCOV_EXCL_STOP */
1012 void nfc_manager_unset_hce_event_cb(void)
1016 if (nfc_common_is_supported(NFC_CE_HCE_FEATURE) == false) {
1017 /* LCOV_EXCL_START */
1018 LOG_ERR("NFC not supported");
1019 set_last_result(NFC_ERROR_NOT_SUPPORTED);
1021 /* LCOV_EXCL_STOP */
1024 /* LCOV_EXCL_START */
1025 if (nfc_common_is_initialized() == false) {
1026 LOG_ERR("NFC not initialized");
1027 set_last_result(NFC_ERROR_NOT_INITIALIZED);
1031 net_nfc_client_hce_unset_event_received_cb();
1033 set_last_result(NFC_ERROR_NONE);
1034 /* LCOV_EXCL_STOP */