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 <stdlib.h>
18 #include <rw_int.h>
19 #include <nfc_int.h>
20
21 extern tRW_CB rw_cb;
22 extern tNFC_CB nfc_cb;
23 void rw_init(void);
24 tNFC_STATUS rw_i93_select(uint8_t* p_uid);
25
GKI_freebuf(void *)26 void GKI_freebuf(void*) {
27 }
28
GKI_start_timer(uint8_t,int32_t,bool)29 void GKI_start_timer(uint8_t, int32_t, bool) {
30 }
31
GKI_stop_timer(uint8_t)32 void GKI_stop_timer(uint8_t) {
33 }
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) * 32);
55 if (!(p_data->data.p_data)) {
56 free(p_data);
57 return EXIT_FAILURE;
58 }
59
60 NFC_HDR *p_resp = (NFC_HDR*) p_data->data.p_data;
61 p_resp->len = 0;
62 p_resp->offset = 0;
63
64 p_i93->state = RW_I93_STATE_UPDATE_NDEF;
65 p_i93->sub_state = RW_I93_SUBSTATE_RESET_LEN;
66 p_i93->block_size = 2 * (I93_MAX_BLOCK_LENGH + 1);
67 p_i93->ndef_tlv_start_offset = 2 * (I93_MAX_BLOCK_LENGH) - 1;
68 p_data->status = NFC_STATUS_OK;
69
70 p_cb->p_cback(0, event, p_data);
71 free(p_data->data.p_data);
72 free(p_data);
73 return EXIT_SUCCESS;
74 }
75