1 /*
2  * Copyright (C) 2021 The Android Open Source Project
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 #include <nfc_api.h>
18 #include <nfc_int.h>
19 #include <rw_int.h>
20 #include <stdlib.h>
21 #include <tags_defs.h>
22 
23 extern tRW_CB rw_cb;
24 extern tNFC_CB nfc_cb;
25 void rw_init(void);
26 tNFC_STATUS rw_i93_select(uint8_t* p_uid);
27 
GKI_freebuf(void * p_buf)28 void GKI_freebuf(void* p_buf __attribute__((unused))) {}
29 
GKI_start_timer(uint8_t,int32_t,bool)30 void GKI_start_timer(uint8_t, int32_t, bool) {}
31 
GKI_stop_timer(uint8_t)32 void GKI_stop_timer(uint8_t) {}
33 
main()34 int main() {
35     tRW_I93_CB* p_i93 = &rw_cb.tcb.i93;
36 
37     GKI_init();
38     rw_init();
39 
40     uint8_t p_uid = 1;
41     if (rw_i93_select(&p_uid) != NFC_STATUS_OK) {
42         return EXIT_FAILURE;
43     }
44 
45     tNFC_CONN_CB* p_cb = &nfc_cb.conn_cb[NFC_RF_CONN_ID];
46     tNFC_CONN_EVT event = NFC_DATA_CEVT;
47 
48     tNFC_CONN* p_data = (tNFC_CONN*)malloc(sizeof(tNFC_CONN));
49     if (!p_data) {
50         return EXIT_FAILURE;
51     }
52 
53     p_data->data.p_data = (NFC_HDR*)malloc(sizeof(NFC_HDR));
54     if (!(p_data->data.p_data)) {
55         free(p_data);
56         return EXIT_FAILURE;
57     }
58 
59     p_i93->state = RW_I93_STATE_BUSY;
60     p_i93->sub_state = RW_I93_SUBSTATE_CHECK_READ_ONLY;
61     p_i93->block_size = I93_MAX_BLOCK_LENGH - 1;
62     p_i93->sent_cmd = I93_CMD_GET_SYS_INFO;
63     p_data->status = NFC_STATUS_OK;
64 
65     NFC_HDR* p_resp = (NFC_HDR*)p_data->data.p_data;
66     p_resp->len = 1;
67     p_resp->offset = 0;
68 
69     p_cb->p_cback(0, event, p_data);
70     free(p_data->data.p_data);
71     free(p_data);
72     return EXIT_SUCCESS;
73 }
74