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.
18 #include "net_nfc_test_jewel.h"
19 #include "net_nfc_typedef_internal.h"
20 #include "net_nfc_test_util.h"
21 #include "net_nfc_client_tag_jewel.h"
22 #include "net_nfc_target_info.h"
23 #include "net_nfc_test_tag.h"
26 static net_nfc_target_handle_s* get_handle()
28 net_nfc_target_info_s *info = NULL;
29 net_nfc_target_handle_s *handle = NULL;
31 info = net_nfc_test_tag_get_target_info();
33 net_nfc_get_tag_handle(info, &handle);
38 static void run_next_callback(gpointer user_data)
44 callback = (GCallback)(user_data);
51 /*********************************** Callbacks *************************************/
53 static void jewel_read_cb(net_nfc_error_e result,
58 g_print("jewel_read_cb Completed %d\n", result);
60 print_received_data(resp_data);
62 run_next_callback(user_data);
65 static void jewel_write_cb(net_nfc_error_e result,
68 g_print("jewel_write_cb Completed %d\n", result);
70 run_next_callback(user_data);
74 /*********************************** Function Calls *************************************/
77 void net_nfc_test_tag_jewel_read_id(gpointer data,
80 net_nfc_error_e result = NET_NFC_OK;
81 net_nfc_target_handle_s *handle = NULL;
83 handle = get_handle();
85 result = net_nfc_client_jewel_read_id(handle,
88 g_print("net_nfc_client_jewel_read_id() : %d\n", result);
91 void net_nfc_test_tag_jewel_read_byte(gpointer data,
94 net_nfc_error_e result = NET_NFC_OK;
95 net_nfc_target_handle_s *handle = NULL;
99 handle = get_handle();
101 result = net_nfc_client_jewel_read_byte(handle,
106 g_print("net_nfc_client_jewel_read_byte() : %d\n", result);
109 void net_nfc_test_tag_jewel_read_all(gpointer data,
112 net_nfc_error_e result = NET_NFC_OK;
113 net_nfc_target_handle_s *handle = NULL;
115 handle = get_handle();
117 result = net_nfc_client_jewel_read_all(handle,
120 g_print("net_nfc_client_jewel_read_all() : %d\n", result);
123 void net_nfc_test_tag_jewel_write_with_erase(gpointer data,
126 net_nfc_error_e result = NET_NFC_OK;
127 net_nfc_target_handle_s *handle = NULL;
128 uint8_t block = 0x01;
130 uint8_t data_to_write = 'A';
132 handle = get_handle();
134 result = net_nfc_client_jewel_write_with_erase(handle,
140 g_print("net_nfc_client_jewel_write_with_erase() : %d\n", result);
143 void net_nfc_test_tag_jewel_write_with_no_erase(gpointer data,
146 net_nfc_error_e result = NET_NFC_OK;
147 net_nfc_target_handle_s *handle = NULL;
148 uint8_t block = 0x01;
150 uint8_t data_to_write = 'A';
152 handle = get_handle();
154 result = net_nfc_client_jewel_write_with_erase(handle,
160 g_print("net_nfc_client_jewel_write_with_erase() : %d\n", result);