Remove unnecessary setting
[platform/core/connectivity/nfc-manager-neard.git] / tests / net_nfc_test_jewel.c
1 /*
2  * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  *                               http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17
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"
24
25
26 static net_nfc_target_handle_s* get_handle()
27 {
28         net_nfc_target_info_s *info = NULL;
29         net_nfc_target_handle_s *handle = NULL;
30
31         info = net_nfc_test_tag_get_target_info();
32
33         net_nfc_get_tag_handle(info, &handle);
34
35         return handle;
36 }
37
38 static void run_next_callback(gpointer user_data)
39 {
40         if (user_data)
41         {
42                 GCallback callback;
43
44                 callback = (GCallback)(user_data);
45
46                 callback();
47         }
48 }
49
50
51 /*********************************** Callbacks *************************************/
52
53 static void jewel_read_cb(net_nfc_error_e result,
54                 data_s *resp_data,
55                 void *user_data)
56 {
57
58         g_print("jewel_read_cb Completed %d\n", result);
59
60         print_received_data(resp_data);
61
62         run_next_callback(user_data);
63 }
64
65 static void jewel_write_cb(net_nfc_error_e result,
66                 void* user_data)
67 {
68         g_print("jewel_write_cb Completed %d\n", result);
69
70         run_next_callback(user_data);
71 }
72
73
74 /*********************************** Function Calls *************************************/
75
76
77 void net_nfc_test_tag_jewel_read_id(gpointer data,
78                 gpointer user_data)
79 {
80         net_nfc_error_e result = NET_NFC_OK;
81         net_nfc_target_handle_s *handle = NULL;
82
83         handle = get_handle();
84
85         result = net_nfc_client_jewel_read_id(handle,
86                         jewel_read_cb,
87                         user_data);
88         g_print("net_nfc_client_jewel_read_id() : %d\n", result);
89 }
90
91 void net_nfc_test_tag_jewel_read_byte(gpointer data,
92                 gpointer user_data)
93 {
94         net_nfc_error_e result = NET_NFC_OK;
95         net_nfc_target_handle_s *handle = NULL;
96         uint8_t block = 0x01;
97         uint8_t byte = 1;
98
99         handle = get_handle();
100
101         result = net_nfc_client_jewel_read_byte(handle,
102                         block,
103                         byte,
104                         jewel_read_cb,
105                         user_data);
106         g_print("net_nfc_client_jewel_read_byte() : %d\n", result);
107 }
108
109 void net_nfc_test_tag_jewel_read_all(gpointer data,
110                 gpointer user_data)
111 {
112         net_nfc_error_e result = NET_NFC_OK;
113         net_nfc_target_handle_s *handle = NULL;
114
115         handle = get_handle();
116
117         result = net_nfc_client_jewel_read_all(handle,
118                         jewel_read_cb,
119                         user_data);
120         g_print("net_nfc_client_jewel_read_all() : %d\n", result);
121 }
122
123 void net_nfc_test_tag_jewel_write_with_erase(gpointer data,
124                 gpointer user_data)
125 {
126         net_nfc_error_e result = NET_NFC_OK;
127         net_nfc_target_handle_s *handle = NULL;
128         uint8_t block = 0x01;
129         uint8_t byte = 1;
130         uint8_t data_to_write = 'A';
131
132         handle = get_handle();
133
134         result = net_nfc_client_jewel_write_with_erase(handle,
135                         block,
136                         byte,
137                         data_to_write,
138                         jewel_write_cb,
139                         user_data);
140         g_print("net_nfc_client_jewel_write_with_erase() : %d\n", result);
141 }
142
143 void net_nfc_test_tag_jewel_write_with_no_erase(gpointer data,
144                 gpointer user_data)
145 {
146         net_nfc_error_e result = NET_NFC_OK;
147         net_nfc_target_handle_s *handle = NULL;
148         uint8_t block = 0x01;
149         uint8_t byte = 1;
150         uint8_t data_to_write = 'A';
151
152         handle = get_handle();
153
154         result = net_nfc_client_jewel_write_with_erase(handle,
155                         block,
156                         byte,
157                         data_to_write,
158                         jewel_write_cb,
159                         user_data);
160         g_print("net_nfc_client_jewel_write_with_erase() : %d\n", result);
161 }