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