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_tag_felica.h"
19 #include "net_nfc_typedef_internal.h"
20 #include "net_nfc_test_tag.h"
21 #include "net_nfc_target_info.h"
22 #include "net_nfc_test_util.h"
23 #include "net_nfc_client_tag_felica.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);
50 static void felica_cb(net_nfc_error_e result, data_s *resp_data, void *user_data)
52 g_print("felica_cb Completed %d\n", result);
54 print_received_data(resp_data);
56 run_next_callback(user_data);
59 void net_nfc_test_felica_poll(gpointer data, gpointer user_data)
61 net_nfc_error_e result = NET_NFC_OK;
62 net_nfc_target_handle_s *handle = NULL;
63 net_nfc_felica_poll_request_code_e req_code = 0x00;
64 uint8_t time_slot = 2;
66 handle = get_handle();
70 result = net_nfc_client_felica_poll(handle, req_code, time_slot, felica_cb, user_data);
72 g_print("net_nfc_client_felica_poll() : %d\n", result);
75 void net_nfc_test_felica_request_service(gpointer data, gpointer user_data)
77 net_nfc_error_e result = NET_NFC_OK;
78 net_nfc_target_handle_s *handle = NULL;
79 uint8_t number_of_area_service = 4;
80 uint16_t area_service_list[10] = { 0,};
81 uint8_t number_of_services = 5;
83 handle = get_handle();
87 result = net_nfc_client_felica_request_service(handle,
88 number_of_area_service,
93 g_print("net_nfc_client_felica_request_service() : %d\n", result);
96 void net_nfc_test_felica_request_response(gpointer data, gpointer user_data)
98 net_nfc_error_e result = NET_NFC_OK;
99 net_nfc_target_handle_s *handle = NULL;
101 handle = get_handle();
105 result = net_nfc_client_felica_request_response(handle, felica_cb, user_data);
106 g_print("net_nfc_client_felica_request_response() : %d\n", result);
109 void net_nfc_test_felica_read_without_encryption(gpointer data,
112 net_nfc_error_e result = NET_NFC_OK;
113 net_nfc_target_handle_s *handle = NULL;
114 uint8_t number_of_services = 10;
115 uint16_t service_list[10] = {0,};
116 uint8_t number_of_blocks = 1;
117 uint8_t block_list[3] = {0,};
119 handle = get_handle();
123 result = net_nfc_client_felica_read_without_encryption(handle,
130 g_print("net_nfc_client_felica_read_without_encryption() : %d\n", result);
133 void net_nfc_test_felica_write_without_encryption(gpointer data,
136 net_nfc_error_e result = NET_NFC_OK;
137 net_nfc_target_handle_s *handle = NULL;
138 uint8_t number_of_services = 10;
139 uint16_t service_list[10] = {0,};
140 uint8_t number_of_blocks = 1;
141 uint8_t block_list[3] = {0,};
142 data_s *data_to_write = NULL;
144 handle = get_handle();
148 result = net_nfc_client_felica_write_without_encryption(handle,
156 g_print("net_nfc_client_felica_write_without_encryption() : %d\n", result);
159 void net_nfc_test_felica_request_system_code(gpointer data, gpointer user_data)
161 net_nfc_error_e result = NET_NFC_OK;
162 net_nfc_target_handle_s *handle = NULL;
164 handle = get_handle();
168 result = net_nfc_client_felica_request_system_code(handle, felica_cb, user_data);
169 g_print("net_nfc_client_felica_request_system_code() : %d\n", result);