nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright (C) 2010-2014 Broadcom Corporation |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at: |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | * |
| 17 | ******************************************************************************/ |
| 18 | |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 19 | /****************************************************************************** |
| 20 | * |
| 21 | * NFA interface for tag Reader/Writer |
| 22 | * |
| 23 | ******************************************************************************/ |
| 24 | #include <string.h> |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 25 | |
| 26 | #include <android-base/stringprintf.h> |
| 27 | #include <base/logging.h> |
| 28 | |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 29 | #include "nfa_api.h" |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 30 | #include "nfa_rw_int.h" |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 31 | |
| 32 | using android::base::StringPrintf; |
| 33 | |
| 34 | extern bool nfc_debug_enabled; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 35 | |
| 36 | /***************************************************************************** |
| 37 | ** Constants |
| 38 | *****************************************************************************/ |
| 39 | |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 40 | /***************************************************************************** |
| 41 | ** APIs |
| 42 | *****************************************************************************/ |
| 43 | |
| 44 | /******************************************************************************* |
| 45 | ** |
| 46 | ** Function NFA_RwDetectNDef |
| 47 | ** |
| 48 | ** Description Perform the NDEF detection procedure using the appropriate |
| 49 | ** method for the currently activated tag. |
| 50 | ** |
| 51 | ** Upon successful completion of NDEF detection, a |
| 52 | ** NFA_NDEF_DETECT_EVT will be sent, to notify the application |
| 53 | ** of the NDEF attributes (NDEF total memory size, current |
| 54 | ** size, etc.). |
| 55 | ** |
| 56 | ** It is not mandatory to call this function - NFA_RwReadNDef |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 57 | ** and NFA_RwWriteNDef will perform NDEF detection internally |
| 58 | ** if not performed already. This API may be called to get a |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 59 | ** tag's NDEF size before issuing a write-request. |
| 60 | ** |
| 61 | ** Returns: |
| 62 | ** NFA_STATUS_OK if successfully initiated |
| 63 | ** NFC_STATUS_REFUSED if tag does not support NDEF |
| 64 | ** NFA_STATUS_FAILED otherwise |
| 65 | ** |
| 66 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 67 | tNFA_STATUS NFA_RwDetectNDef(void) { |
| 68 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 69 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 70 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 71 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 72 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 73 | if (p_msg != NULL) { |
| 74 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 75 | p_msg->op = NFA_RW_OP_DETECT_NDEF; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 76 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 77 | nfa_sys_sendmsg(p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 78 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 79 | return (NFA_STATUS_OK); |
| 80 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 81 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 82 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | /******************************************************************************* |
| 86 | ** |
| 87 | ** Function NFA_RwReadNDef |
| 88 | ** |
| 89 | ** Description Read NDEF message from tag. This function will internally |
| 90 | ** perform the NDEF detection procedure (if not performed |
| 91 | ** previously), and read the NDEF tag data using the |
| 92 | ** appropriate method for the currently activated tag. |
| 93 | ** |
| 94 | ** Upon successful completion of NDEF detection (if performed), |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 95 | ** a NFA_NDEF_DETECT_EVT will be sent, to notify the |
| 96 | ** application of the NDEF attributes (NDEF total memory size, |
| 97 | ** current size, etc.). |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 98 | ** |
| 99 | ** Upon receiving the NDEF message, the message will be sent to |
| 100 | ** the handler registered with NFA_RegisterNDefTypeHandler or |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 101 | ** NFA_RequestExclusiveRfControl (if exclusive RF mode is |
| 102 | ** active) |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 103 | ** |
| 104 | ** Returns: |
| 105 | ** NFA_STATUS_OK if successfully initiated |
| 106 | ** NFC_STATUS_REFUSED if tag does not support NDEF |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 107 | ** NFC_STATUS_NOT_INITIALIZED if NULL NDEF was detected on the |
| 108 | ** tag |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 109 | ** NFA_STATUS_FAILED otherwise |
| 110 | ** |
| 111 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 112 | tNFA_STATUS NFA_RwReadNDef(void) { |
| 113 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 114 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 115 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 116 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 117 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 118 | if (p_msg != NULL) { |
| 119 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 120 | p_msg->op = NFA_RW_OP_READ_NDEF; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 121 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 122 | nfa_sys_sendmsg(p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 123 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 124 | return (NFA_STATUS_OK); |
| 125 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 126 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 127 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 128 | } |
| 129 | |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 130 | /******************************************************************************* |
| 131 | ** |
| 132 | ** Function NFA_RwWriteNDef |
| 133 | ** |
| 134 | ** Description Write NDEF data to the activated tag. This function will |
| 135 | ** internally perform NDEF detection if necessary, and write |
| 136 | ** the NDEF tag data using the appropriate method for the |
| 137 | ** currently activated tag. |
| 138 | ** |
| 139 | ** When the entire message has been written, or if an error |
| 140 | ** occurs, the app will be notified with NFA_WRITE_CPLT_EVT. |
| 141 | ** |
| 142 | ** p_data needs to be persistent until NFA_WRITE_CPLT_EVT |
| 143 | ** |
| 144 | ** |
| 145 | ** Returns: |
| 146 | ** NFA_STATUS_OK if successfully initiated |
| 147 | ** NFC_STATUS_REFUSED if tag does not support NDEF/locked |
| 148 | ** NFA_STATUS_FAILED otherwise |
| 149 | ** |
| 150 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 151 | tNFA_STATUS NFA_RwWriteNDef(uint8_t* p_data, uint32_t len) { |
| 152 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 153 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 154 | DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("ndef len: %i", len); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 155 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 156 | /* Validate parameters */ |
| 157 | if (p_data == NULL) return (NFA_STATUS_INVALID_PARAM); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 158 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 159 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 160 | if (p_msg != NULL) { |
| 161 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 162 | p_msg->op = NFA_RW_OP_WRITE_NDEF; |
| 163 | p_msg->params.write_ndef.len = len; |
| 164 | p_msg->params.write_ndef.p_data = p_data; |
| 165 | nfa_sys_sendmsg(p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 166 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 167 | return (NFA_STATUS_OK); |
| 168 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 169 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 170 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | /***************************************************************************** |
| 174 | ** |
| 175 | ** Function NFA_RwPresenceCheck |
| 176 | ** |
| 177 | ** Description Check if the tag is still in the field. |
| 178 | ** |
| 179 | ** The NFA_RW_PRESENCE_CHECK_EVT w/ status is used to |
| 180 | ** indicate presence or non-presence. |
| 181 | ** |
| 182 | ** option is used only with ISO-DEP protocol |
| 183 | ** |
| 184 | ** Returns |
| 185 | ** NFA_STATUS_OK if successfully initiated |
| 186 | ** NFA_STATUS_FAILED otherwise |
| 187 | ** |
| 188 | *****************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 189 | tNFA_STATUS NFA_RwPresenceCheck(tNFA_RW_PRES_CHK_OPTION option) { |
| 190 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 191 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 192 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 193 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 194 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 195 | if (p_msg != NULL) { |
| 196 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 197 | p_msg->op = NFA_RW_OP_PRESENCE_CHECK; |
| 198 | p_msg->params.option = option; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 199 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 200 | nfa_sys_sendmsg(p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 201 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 202 | return (NFA_STATUS_OK); |
| 203 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 204 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 205 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | /***************************************************************************** |
| 209 | ** |
| 210 | ** Function NFA_RwFormatTag |
| 211 | ** |
| 212 | ** Description Check if the tag is NDEF Formatable. If yes Format the tag |
| 213 | ** |
| 214 | ** The NFA_RW_FORMAT_CPLT_EVT w/ status is used to |
| 215 | ** indicate if tag is successfully formated or not |
| 216 | ** |
| 217 | ** Returns |
| 218 | ** NFA_STATUS_OK if successfully initiated |
| 219 | ** NFA_STATUS_FAILED otherwise |
| 220 | ** |
| 221 | *****************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 222 | tNFA_STATUS NFA_RwFormatTag(void) { |
| 223 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 224 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 225 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 226 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 227 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 228 | if (p_msg != NULL) { |
| 229 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 230 | p_msg->op = NFA_RW_OP_FORMAT_TAG; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 231 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 232 | nfa_sys_sendmsg(p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 233 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 234 | return (NFA_STATUS_OK); |
| 235 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 236 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 237 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | /******************************************************************************* |
| 241 | ** |
| 242 | ** Function NFA_RwSetTagReadOnly |
| 243 | ** |
| 244 | ** Description: |
| 245 | ** Sets tag as read only. |
| 246 | ** |
| 247 | ** When tag is set as read only, or if an error occurs, the app will be |
| 248 | ** notified with NFA_SET_TAG_RO_EVT. |
| 249 | ** |
| 250 | ** Returns: |
| 251 | ** NFA_STATUS_OK if successfully initiated |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 252 | ** NFA_STATUS_REJECTED if protocol is not T1/T2/T5T |
| 253 | ** (or) if hard lock is not requested for protocol T5T |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 254 | ** NFA_STATUS_FAILED otherwise |
| 255 | ** |
| 256 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 257 | tNFA_STATUS NFA_RwSetTagReadOnly(bool b_hard_lock) { |
| 258 | tNFA_RW_OPERATION* p_msg; |
| 259 | tNFC_PROTOCOL protocol = nfa_rw_cb.protocol; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 260 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 261 | if ((protocol != NFC_PROTOCOL_T1T) && (protocol != NFC_PROTOCOL_T2T) && |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 262 | (protocol != NFC_PROTOCOL_T5T) && (protocol != NFC_PROTOCOL_ISO_DEP) && |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 263 | (protocol != NFC_PROTOCOL_T3T)) { |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 264 | DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf( |
| 265 | "Cannot Configure as read only for Protocol: " |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 266 | "%d", |
| 267 | protocol); |
| 268 | return (NFA_STATUS_REJECTED); |
| 269 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 270 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 271 | if ((!b_hard_lock && (protocol == NFC_PROTOCOL_T5T)) || |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 272 | (b_hard_lock && (protocol == NFC_PROTOCOL_ISO_DEP))) { |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 273 | DLOG_IF(INFO, nfc_debug_enabled) |
| 274 | << StringPrintf("Cannot %s for Protocol: %d", |
| 275 | b_hard_lock ? "Hard lock" : "Soft lock", protocol); |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 276 | return (NFA_STATUS_REJECTED); |
| 277 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 278 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 279 | DLOG_IF(INFO, nfc_debug_enabled) |
| 280 | << StringPrintf("%s", b_hard_lock ? "Hard lock" : "Soft lock"); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 281 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 282 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 283 | if (p_msg != NULL) { |
| 284 | /* Fill in tNFA_RW_OPERATION struct */ |
| 285 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 286 | p_msg->op = NFA_RW_OP_SET_TAG_RO; |
| 287 | p_msg->params.set_readonly.b_hard_lock = b_hard_lock; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 288 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 289 | nfa_sys_sendmsg(p_msg); |
| 290 | return (NFA_STATUS_OK); |
| 291 | } |
| 292 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | /******************************************************************************* |
| 296 | ** Tag specific APIs |
| 297 | ** (note: for Type-4 tags, use NFA_SendRawFrame to exchange APDUs) |
| 298 | *******************************************************************************/ |
| 299 | |
| 300 | /******************************************************************************* |
| 301 | ** |
| 302 | ** Function NFA_RwLocateTlv |
| 303 | ** |
| 304 | ** Description: |
| 305 | ** Search for the Lock/Memory contril TLV on the activated Type1/Type2 tag |
| 306 | ** |
| 307 | ** Data is returned to the application using the NFA_TLV_DETECT_EVT. When |
| 308 | ** search operation has completed, or if an error occurs, the app will be |
| 309 | ** notified with NFA_TLV_DETECT_EVT. |
| 310 | ** |
| 311 | ** Description Perform the TLV detection procedure using the appropriate |
| 312 | ** method for the currently activated tag. |
| 313 | ** |
| 314 | ** Upon successful completion of TLV detection in T1/T2 tag, a |
| 315 | ** NFA_TLV_DETECT_EVT will be sent, to notify the application |
| 316 | ** of the TLV attributes (total lock/reserved bytes etc.). |
| 317 | ** However if the TLV type specified is NDEF then it is same as |
| 318 | ** calling NFA_RwDetectNDef and should expect to receive |
| 319 | ** NFA_NDEF_DETECT_EVT instead of NFA_TLV_DETECT_EVT |
| 320 | ** |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 321 | ** It is not mandatory to call this function - |
| 322 | ** NFA_RwDetectNDef, NFA_RwReadNDef and NFA_RwWriteNDef will |
| 323 | ** perform TLV detection internally if not performed already. |
| 324 | ** An application may call this API to check the a |
| 325 | ** tag/card-emulator's total Reserved/ |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 326 | ** Lock bytes before issuing a write-request. |
| 327 | ** |
| 328 | ** Returns: |
| 329 | ** NFA_STATUS_OK if successfully initiated |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 330 | ** NFC_STATUS_REFUSED if tlv_type is NDEF & tag won't support |
| 331 | ** NDEF |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 332 | ** NFA_STATUS_FAILED otherwise |
| 333 | ** |
| 334 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 335 | tNFA_STATUS NFA_RwLocateTlv(uint8_t tlv_type) { |
| 336 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 337 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 338 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 339 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 340 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 341 | if (p_msg != NULL) { |
| 342 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 343 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 344 | if (tlv_type == TAG_LOCK_CTRL_TLV) { |
| 345 | p_msg->op = NFA_RW_OP_DETECT_LOCK_TLV; |
| 346 | } else if (tlv_type == TAG_MEM_CTRL_TLV) { |
| 347 | p_msg->op = NFA_RW_OP_DETECT_MEM_TLV; |
| 348 | } else if (tlv_type == TAG_NDEF_TLV) { |
| 349 | p_msg->op = NFA_RW_OP_DETECT_NDEF; |
| 350 | } else |
| 351 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 352 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 353 | nfa_sys_sendmsg(p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 354 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 355 | return (NFA_STATUS_OK); |
| 356 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 357 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 358 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | /******************************************************************************* |
| 362 | ** |
| 363 | ** Function NFA_RwT1tRid |
| 364 | ** |
| 365 | ** Description: |
| 366 | ** Send a RID command to the activated Type 1 tag. |
| 367 | ** |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 368 | ** Data is returned to the application using the NFA_DATA_EVT. When the |
| 369 | ** read operation has completed, or if an error occurs, the app will be |
| 370 | ** notified with NFA_READ_CPLT_EVT. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 371 | ** |
| 372 | ** Returns: |
| 373 | ** NFA_STATUS_OK if successfully initiated |
| 374 | ** NFA_STATUS_FAILED otherwise |
| 375 | ** |
| 376 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 377 | tNFA_STATUS NFA_RwT1tRid(void) { |
| 378 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 379 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 380 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 381 | if (p_msg != NULL) { |
| 382 | /* Fill in tNFA_RW_OPERATION struct */ |
| 383 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 384 | p_msg->op = NFA_RW_OP_T1T_RID; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 385 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 386 | nfa_sys_sendmsg(p_msg); |
| 387 | return (NFA_STATUS_OK); |
| 388 | } |
| 389 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | /******************************************************************************* |
| 393 | ** |
| 394 | ** Function NFA_RwT1tReadAll |
| 395 | ** |
| 396 | ** Description: |
| 397 | ** Send a RALL command to the activated Type 1 tag. |
| 398 | ** |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 399 | ** Data is returned to the application using the NFA_DATA_EVT. When the |
| 400 | ** read operation has completed, or if an error occurs, the app will be |
| 401 | ** notified with NFA_READ_CPLT_EVT. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 402 | ** |
| 403 | ** Returns: |
| 404 | ** NFA_STATUS_OK if successfully initiated |
| 405 | ** NFA_STATUS_FAILED otherwise |
| 406 | ** |
| 407 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 408 | tNFA_STATUS NFA_RwT1tReadAll(void) { |
| 409 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 410 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 411 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 412 | if (p_msg != NULL) { |
| 413 | /* Fill in tNFA_RW_OPERATION struct */ |
| 414 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 415 | p_msg->op = NFA_RW_OP_T1T_RALL; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 416 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 417 | nfa_sys_sendmsg(p_msg); |
| 418 | return (NFA_STATUS_OK); |
| 419 | } |
| 420 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | /******************************************************************************* |
| 424 | ** |
| 425 | ** Function NFA_RwT1tRead |
| 426 | ** |
| 427 | ** Description: |
| 428 | ** Send a READ command to the activated Type 1 tag. |
| 429 | ** |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 430 | ** Data is returned to the application using the NFA_DATA_EVT. When the |
| 431 | ** read operation has completed, or if an error occurs, the app will be |
| 432 | ** notified with NFA_READ_CPLT_EVT. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 433 | ** |
| 434 | ** Returns: |
| 435 | ** NFA_STATUS_OK if successfully initiated |
| 436 | ** NFA_STATUS_FAILED otherwise |
| 437 | ** |
| 438 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 439 | tNFA_STATUS NFA_RwT1tRead(uint8_t block_number, uint8_t index) { |
| 440 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 441 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 442 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 443 | if (p_msg != NULL) { |
| 444 | /* Fill in tNFA_RW_OPERATION struct */ |
| 445 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 446 | p_msg->op = NFA_RW_OP_T1T_READ; |
| 447 | p_msg->params.t1t_read.block_number = block_number; |
| 448 | p_msg->params.t1t_read.index = index; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 449 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 450 | nfa_sys_sendmsg(p_msg); |
| 451 | return (NFA_STATUS_OK); |
| 452 | } |
| 453 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | /******************************************************************************* |
| 457 | ** |
| 458 | ** Function NFA_RwT1tWrite |
| 459 | ** |
| 460 | ** Description: |
| 461 | ** Send a WRITE command to the activated Type 1 tag. |
| 462 | ** |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 463 | ** Data is returned to the application using the NFA_DATA_EVT. When the |
| 464 | ** write operation has completed, or if an error occurs, the app will be |
| 465 | ** notified with NFA_WRITE_CPLT_EVT. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 466 | ** |
| 467 | ** Returns: |
| 468 | ** NFA_STATUS_OK if successfully initiated |
| 469 | ** NFA_STATUS_FAILED otherwise |
| 470 | ** |
| 471 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 472 | tNFA_STATUS NFA_RwT1tWrite(uint8_t block_number, uint8_t index, uint8_t data, |
| 473 | bool b_erase) { |
| 474 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 475 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 476 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 477 | if (p_msg != NULL) { |
| 478 | /* Fill in tNFA_RW_OPERATION struct */ |
| 479 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 480 | p_msg->params.t1t_write.b_erase = b_erase; |
| 481 | p_msg->op = NFA_RW_OP_T1T_WRITE; |
| 482 | p_msg->params.t1t_write.block_number = block_number; |
| 483 | p_msg->params.t1t_write.index = index; |
| 484 | p_msg->params.t1t_write.p_block_data[0] = data; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 485 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 486 | nfa_sys_sendmsg(p_msg); |
| 487 | return (NFA_STATUS_OK); |
| 488 | } |
| 489 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 490 | } |
| 491 | |
| 492 | /******************************************************************************* |
| 493 | ** |
| 494 | ** Function NFA_RwT1tReadSeg |
| 495 | ** |
| 496 | ** Description: |
| 497 | ** Send a RSEG command to the activated Type 1 tag. |
| 498 | ** |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 499 | ** Data is returned to the application using the NFA_DATA_EVT. When the |
| 500 | ** read operation has completed, or if an error occurs, the app will be |
| 501 | ** notified with NFA_READ_CPLT_EVT. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 502 | ** |
| 503 | ** Returns: |
| 504 | ** NFA_STATUS_OK if successfully initiated |
| 505 | ** NFA_STATUS_FAILED otherwise |
| 506 | ** |
| 507 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 508 | tNFA_STATUS NFA_RwT1tReadSeg(uint8_t segment_number) { |
| 509 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 510 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 511 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 512 | if (p_msg != NULL) { |
| 513 | /* Fill in tNFA_RW_OPERATION struct */ |
| 514 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 515 | p_msg->op = NFA_RW_OP_T1T_RSEG; |
| 516 | p_msg->params.t1t_read.segment_number = segment_number; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 517 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 518 | nfa_sys_sendmsg(p_msg); |
| 519 | return (NFA_STATUS_OK); |
| 520 | } |
| 521 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | /******************************************************************************* |
| 525 | ** |
| 526 | ** Function NFA_RwT1tRead8 |
| 527 | ** |
| 528 | ** Description: |
| 529 | ** Send a READ8 command to the activated Type 1 tag. |
| 530 | ** |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 531 | ** Data is returned to the application using the NFA_DATA_EVT. When the |
| 532 | ** read operation has completed, or if an error occurs, the app will be |
| 533 | ** notified with NFA_READ_CPLT_EVT. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 534 | ** |
| 535 | ** Returns: |
| 536 | ** NFA_STATUS_OK if successfully initiated |
| 537 | ** NFA_STATUS_FAILED otherwise |
| 538 | ** |
| 539 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 540 | tNFA_STATUS NFA_RwT1tRead8(uint8_t block_number) { |
| 541 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 542 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 543 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 544 | if (p_msg != NULL) { |
| 545 | /* Fill in tNFA_RW_OPERATION struct */ |
| 546 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 547 | p_msg->op = NFA_RW_OP_T1T_READ8; |
| 548 | p_msg->params.t1t_write.block_number = block_number; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 549 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 550 | nfa_sys_sendmsg(p_msg); |
| 551 | return (NFA_STATUS_OK); |
| 552 | } |
| 553 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | /******************************************************************************* |
| 557 | ** |
| 558 | ** Function NFA_RwT1tWrite8 |
| 559 | ** |
| 560 | ** Description: |
| 561 | ** Send a WRITE8_E / WRITE8_NE command to the activated Type 1 tag. |
| 562 | ** |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 563 | ** Data is returned to the application using the NFA_DATA_EVT. When the |
| 564 | ** read operation has completed, or if an error occurs, the app will be |
| 565 | ** notified with NFA_READ_CPLT_EVT. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 566 | ** |
| 567 | ** Returns: |
| 568 | ** NFA_STATUS_OK if successfully initiated |
| 569 | ** NFA_STATUS_FAILED otherwise |
| 570 | ** |
| 571 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 572 | tNFA_STATUS NFA_RwT1tWrite8(uint8_t block_number, uint8_t* p_data, |
| 573 | bool b_erase) { |
| 574 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 575 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 576 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 577 | if (p_msg != NULL) { |
| 578 | /* Fill in tNFA_RW_OPERATION struct */ |
| 579 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 580 | p_msg->params.t1t_write.b_erase = b_erase; |
| 581 | p_msg->op = NFA_RW_OP_T1T_WRITE8; |
| 582 | p_msg->params.t1t_write.block_number = block_number; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 583 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 584 | memcpy(p_msg->params.t1t_write.p_block_data, p_data, 8); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 585 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 586 | nfa_sys_sendmsg(p_msg); |
| 587 | return (NFA_STATUS_OK); |
| 588 | } |
| 589 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 590 | } |
| 591 | |
| 592 | /******************************************************************************* |
| 593 | ** |
| 594 | ** Function NFA_RwT2tRead |
| 595 | ** |
| 596 | ** Description: |
| 597 | ** Send a READ command to the activated Type 2 tag. |
| 598 | ** |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 599 | ** Data is returned to the application using the NFA_DATA_EVT. When the |
| 600 | ** read operation has completed, or if an error occurs, the app will be |
| 601 | ** notified with NFA_READ_CPLT_EVT. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 602 | ** |
| 603 | ** Returns: |
| 604 | ** NFA_STATUS_OK if successfully initiated |
| 605 | ** NFA_STATUS_FAILED otherwise |
| 606 | ** |
| 607 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 608 | tNFA_STATUS NFA_RwT2tRead(uint8_t block_number) { |
| 609 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 610 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 611 | DLOG_IF(INFO, nfc_debug_enabled) |
| 612 | << StringPrintf("Block to read: %d", block_number); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 613 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 614 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 615 | if (p_msg != NULL) { |
| 616 | /* Fill in tNFA_RW_OPERATION struct */ |
| 617 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 618 | p_msg->op = NFA_RW_OP_T2T_READ; |
| 619 | p_msg->params.t2t_read.block_number = block_number; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 620 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 621 | nfa_sys_sendmsg(p_msg); |
| 622 | return (NFA_STATUS_OK); |
| 623 | } |
| 624 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 625 | } |
| 626 | |
| 627 | /******************************************************************************* |
| 628 | ** |
| 629 | ** Function NFA_RwT2tWrite |
| 630 | ** |
| 631 | ** Description: |
| 632 | ** Send an WRITE command to the activated Type 2 tag. |
| 633 | ** |
| 634 | ** When the write operation has completed (or if an error occurs), the |
| 635 | ** app will be notified with NFA_WRITE_CPLT_EVT. |
| 636 | ** |
| 637 | ** Returns: |
| 638 | ** NFA_STATUS_OK if successfully initiated |
| 639 | ** NFA_STATUS_FAILED otherwise |
| 640 | ** |
| 641 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 642 | tNFA_STATUS NFA_RwT2tWrite(uint8_t block_number, uint8_t* p_data) { |
| 643 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 644 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 645 | DLOG_IF(INFO, nfc_debug_enabled) |
| 646 | << StringPrintf("Block to write: %d", block_number); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 647 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 648 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 649 | if (p_msg != NULL) { |
| 650 | /* Fill in tNFA_RW_OPERATION struct */ |
| 651 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 652 | p_msg->op = NFA_RW_OP_T2T_WRITE; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 653 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 654 | p_msg->params.t2t_write.block_number = block_number; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 655 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 656 | memcpy(p_msg->params.t2t_write.p_block_data, p_data, 4); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 657 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 658 | nfa_sys_sendmsg(p_msg); |
| 659 | return (NFA_STATUS_OK); |
| 660 | } |
| 661 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | /******************************************************************************* |
| 665 | ** |
| 666 | ** Function NFA_RwT2tSectorSelect |
| 667 | ** |
| 668 | ** Description: |
| 669 | ** Send SECTOR SELECT command to the activated Type 2 tag. |
| 670 | ** |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 671 | ** When the sector select operation has completed (or if an error occurs), |
| 672 | ** the app will be notified with NFA_SECTOR_SELECT_CPLT_EVT. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 673 | ** |
| 674 | ** Returns: |
| 675 | ** NFA_STATUS_OK if successfully initiated |
| 676 | ** NFA_STATUS_FAILED otherwise |
| 677 | ** |
| 678 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 679 | tNFA_STATUS NFA_RwT2tSectorSelect(uint8_t sector_number) { |
| 680 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 681 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 682 | DLOG_IF(INFO, nfc_debug_enabled) |
| 683 | << StringPrintf("sector to select: %d", sector_number); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 684 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 685 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 686 | if (p_msg != NULL) { |
| 687 | /* Fill in tNFA_RW_OPERATION struct */ |
| 688 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 689 | p_msg->op = NFA_RW_OP_T2T_SECTOR_SELECT; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 690 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 691 | p_msg->params.t2t_sector_select.sector_number = sector_number; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 692 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 693 | nfa_sys_sendmsg(p_msg); |
| 694 | return (NFA_STATUS_OK); |
| 695 | } |
| 696 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 697 | } |
| 698 | |
| 699 | /******************************************************************************* |
| 700 | ** |
| 701 | ** Function NFA_RwT3tRead |
| 702 | ** |
| 703 | ** Description: |
| 704 | ** Send a CHECK (read) command to the activated Type 3 tag. |
| 705 | ** |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 706 | ** Data is returned to the application using the NFA_DATA_EVT. When the |
| 707 | ** read operation has completed, or if an error occurs, the app will be |
| 708 | ** notified with NFA_READ_CPLT_EVT. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 709 | ** |
| 710 | ** Returns: |
| 711 | ** NFA_STATUS_OK if successfully initiated |
| 712 | ** NFA_STATUS_FAILED otherwise |
| 713 | ** |
| 714 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 715 | tNFA_STATUS NFA_RwT3tRead(uint8_t num_blocks, tNFA_T3T_BLOCK_DESC* t3t_blocks) { |
| 716 | tNFA_RW_OPERATION* p_msg; |
| 717 | uint8_t* p_block_desc; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 718 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 719 | DLOG_IF(INFO, nfc_debug_enabled) |
| 720 | << StringPrintf("num_blocks to read: %i", num_blocks); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 721 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 722 | /* Validate parameters */ |
| 723 | if ((num_blocks == 0) || (t3t_blocks == NULL)) |
| 724 | return (NFA_STATUS_INVALID_PARAM); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 725 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 726 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)( |
| 727 | sizeof(tNFA_RW_OPERATION) + (num_blocks * sizeof(tNFA_T3T_BLOCK_DESC)))); |
| 728 | if (p_msg != NULL) { |
| 729 | /* point to area after tNFA_RW_OPERATION */ |
| 730 | p_block_desc = (uint8_t*)(p_msg + 1); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 731 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 732 | /* Fill in tNFA_RW_OPERATION struct */ |
| 733 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 734 | p_msg->op = NFA_RW_OP_T3T_READ; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 735 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 736 | p_msg->params.t3t_read.num_blocks = num_blocks; |
| 737 | p_msg->params.t3t_read.p_block_desc = (tNFA_T3T_BLOCK_DESC*)p_block_desc; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 738 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 739 | /* Copy block descriptor list */ |
| 740 | memcpy(p_block_desc, t3t_blocks, |
| 741 | (num_blocks * sizeof(tNFA_T3T_BLOCK_DESC))); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 742 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 743 | nfa_sys_sendmsg(p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 744 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 745 | return (NFA_STATUS_OK); |
| 746 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 747 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 748 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 749 | } |
| 750 | |
| 751 | /******************************************************************************* |
| 752 | ** |
| 753 | ** Function NFA_RwT3tWrite |
| 754 | ** |
| 755 | ** Description: |
| 756 | ** Send an UPDATE (write) command to the activated Type 3 tag. |
| 757 | ** |
| 758 | ** When the write operation has completed (or if an error occurs), the |
| 759 | ** app will be notified with NFA_WRITE_CPLT_EVT. |
| 760 | ** |
| 761 | ** Returns: |
| 762 | ** NFA_STATUS_OK if successfully initiated |
| 763 | ** NFA_STATUS_FAILED otherwise |
| 764 | ** |
| 765 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 766 | tNFA_STATUS NFA_RwT3tWrite(uint8_t num_blocks, tNFA_T3T_BLOCK_DESC* t3t_blocks, |
| 767 | uint8_t* p_data) { |
| 768 | tNFA_RW_OPERATION* p_msg; |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 769 | uint8_t *p_block_desc, *p_data_area; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 770 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 771 | DLOG_IF(INFO, nfc_debug_enabled) |
| 772 | << StringPrintf("num_blocks to write: %i", num_blocks); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 773 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 774 | /* Validate parameters */ |
| 775 | if ((num_blocks == 0) || (t3t_blocks == NULL) | (p_data == NULL)) |
| 776 | return (NFA_STATUS_INVALID_PARAM); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 777 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 778 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf( |
| 779 | (uint16_t)(sizeof(tNFA_RW_OPERATION) + |
| 780 | (num_blocks * (sizeof(tNFA_T3T_BLOCK_DESC) + 16)))); |
| 781 | if (p_msg != NULL) { |
| 782 | /* point to block descriptor and data areas after tNFA_RW_OPERATION */ |
| 783 | p_block_desc = (uint8_t*)(p_msg + 1); |
| 784 | p_data_area = p_block_desc + (num_blocks * (sizeof(tNFA_T3T_BLOCK_DESC))); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 785 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 786 | /* Fill in tNFA_RW_OPERATION struct */ |
| 787 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 788 | p_msg->op = NFA_RW_OP_T3T_WRITE; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 789 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 790 | p_msg->params.t3t_write.num_blocks = num_blocks; |
| 791 | p_msg->params.t3t_write.p_block_desc = (tNFA_T3T_BLOCK_DESC*)p_block_desc; |
| 792 | p_msg->params.t3t_write.p_block_data = p_data_area; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 793 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 794 | /* Copy block descriptor list */ |
| 795 | memcpy(p_block_desc, t3t_blocks, |
| 796 | (num_blocks * sizeof(tNFA_T3T_BLOCK_DESC))); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 797 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 798 | /* Copy data */ |
| 799 | memcpy(p_data_area, p_data, (num_blocks * 16)); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 800 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 801 | nfa_sys_sendmsg(p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 802 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 803 | return (NFA_STATUS_OK); |
| 804 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 805 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 806 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 807 | } |
| 808 | |
| 809 | /******************************************************************************* |
| 810 | ** |
| 811 | ** Function NFA_RwI93Inventory |
| 812 | ** |
| 813 | ** Description: |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 814 | ** Send Inventory command to the activated ISO T5T tag with/without AFI |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 815 | ** If UID is provided then set UID[0]:MSB, ... UID[7]:LSB |
| 816 | ** |
| 817 | ** When the operation has completed (or if an error occurs), the |
| 818 | ** app will be notified with NFA_I93_CMD_CPLT_EVT. |
| 819 | ** |
| 820 | ** Returns: |
| 821 | ** NFA_STATUS_OK if successfully initiated |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 822 | ** NFA_STATUS_WRONG_PROTOCOL: T5T tag not activated |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 823 | ** NFA_STATUS_FAILED otherwise |
| 824 | ** |
| 825 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 826 | tNFA_STATUS NFA_RwI93Inventory(bool afi_present, uint8_t afi, uint8_t* p_uid) { |
| 827 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 828 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 829 | DLOG_IF(INFO, nfc_debug_enabled) |
| 830 | << StringPrintf("afi_present:%d, AFI: 0x%02X", afi_present, afi); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 831 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 832 | if (nfa_rw_cb.protocol != NFC_PROTOCOL_T5T) { |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 833 | return (NFA_STATUS_WRONG_PROTOCOL); |
| 834 | } |
| 835 | |
| 836 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 837 | if (p_msg != NULL) { |
| 838 | /* Fill in tNFA_RW_OPERATION struct */ |
| 839 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 840 | p_msg->op = NFA_RW_OP_I93_INVENTORY; |
| 841 | |
| 842 | p_msg->params.i93_cmd.afi_present = afi_present; |
| 843 | p_msg->params.i93_cmd.afi = afi; |
| 844 | |
| 845 | if (p_uid) { |
| 846 | p_msg->params.i93_cmd.uid_present = true; |
| 847 | memcpy(p_msg->params.i93_cmd.uid, p_uid, I93_UID_BYTE_LEN); |
| 848 | } else { |
| 849 | p_msg->params.i93_cmd.uid_present = false; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 850 | } |
| 851 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 852 | nfa_sys_sendmsg(p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 853 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 854 | return (NFA_STATUS_OK); |
| 855 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 856 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 857 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 858 | } |
| 859 | |
| 860 | /******************************************************************************* |
| 861 | ** |
| 862 | ** Function NFA_RwI93StayQuiet |
| 863 | ** |
| 864 | ** Description: |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 865 | ** Send Stay Quiet command to the activated T5T tag. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 866 | ** |
| 867 | ** When the operation has completed (or if an error occurs), the |
| 868 | ** app will be notified with NFA_I93_CMD_CPLT_EVT. |
| 869 | ** |
| 870 | ** Returns: |
| 871 | ** NFA_STATUS_OK if successfully initiated |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 872 | ** NFA_STATUS_WRONG_PROTOCOL: T5T tag not activated |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 873 | ** NFA_STATUS_FAILED otherwise |
| 874 | ** |
| 875 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 876 | tNFA_STATUS NFA_RwI93StayQuiet(void) { |
| 877 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 878 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 879 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 880 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 881 | if (nfa_rw_cb.protocol != NFC_PROTOCOL_T5T) { |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 882 | return (NFA_STATUS_WRONG_PROTOCOL); |
| 883 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 884 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 885 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 886 | if (p_msg != NULL) { |
| 887 | /* Fill in tNFA_RW_OPERATION struct */ |
| 888 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 889 | p_msg->op = NFA_RW_OP_I93_STAY_QUIET; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 890 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 891 | nfa_sys_sendmsg(p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 892 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 893 | return (NFA_STATUS_OK); |
| 894 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 895 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 896 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 897 | } |
| 898 | |
| 899 | /******************************************************************************* |
| 900 | ** |
| 901 | ** Function NFA_RwI93ReadSingleBlock |
| 902 | ** |
| 903 | ** Description: |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 904 | ** Send Read Single Block command to the activated T5T tag. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 905 | ** |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 906 | ** Data is returned to the application using the NFA_DATA_EVT. When the |
| 907 | ** read operation has completed, or if an error occurs, the app will be |
| 908 | ** notified with NFA_I93_CMD_CPLT_EVT. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 909 | ** |
| 910 | ** Returns: |
| 911 | ** NFA_STATUS_OK if successfully initiated |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 912 | ** NFA_STATUS_WRONG_PROTOCOL: T5T tag not activated |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 913 | ** NFA_STATUS_FAILED otherwise |
| 914 | ** |
| 915 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 916 | tNFA_STATUS NFA_RwI93ReadSingleBlock(uint8_t block_number) { |
| 917 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 918 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 919 | DLOG_IF(INFO, nfc_debug_enabled) |
| 920 | << StringPrintf("block_number: 0x%02X", block_number); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 921 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 922 | if (nfa_rw_cb.protocol != NFC_PROTOCOL_T5T) { |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 923 | return (NFA_STATUS_WRONG_PROTOCOL); |
| 924 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 925 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 926 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 927 | if (p_msg != NULL) { |
| 928 | /* Fill in tNFA_RW_OPERATION struct */ |
| 929 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 930 | p_msg->op = NFA_RW_OP_I93_READ_SINGLE_BLOCK; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 931 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 932 | p_msg->params.i93_cmd.first_block_number = block_number; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 933 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 934 | nfa_sys_sendmsg(p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 935 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 936 | return (NFA_STATUS_OK); |
| 937 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 938 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 939 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 940 | } |
| 941 | |
| 942 | /******************************************************************************* |
| 943 | ** |
| 944 | ** Function NFA_RwI93WriteSingleBlock |
| 945 | ** |
| 946 | ** Description: |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 947 | ** Send Write Single Block command to the activated T5T tag. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 948 | ** |
| 949 | ** When the write operation has completed (or if an error occurs), the |
| 950 | ** app will be notified with NFA_I93_CMD_CPLT_EVT. |
| 951 | ** |
| 952 | ** Returns: |
| 953 | ** NFA_STATUS_OK if successfully initiated |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 954 | ** NFA_STATUS_WRONG_PROTOCOL: T5T tag not activated |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 955 | ** NFA_STATUS_FAILED otherwise |
| 956 | ** |
| 957 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 958 | tNFA_STATUS NFA_RwI93WriteSingleBlock(uint8_t block_number, uint8_t* p_data) { |
| 959 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 960 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 961 | DLOG_IF(INFO, nfc_debug_enabled) |
| 962 | << StringPrintf("block_number: 0x%02X", block_number); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 963 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 964 | if (nfa_rw_cb.protocol != NFC_PROTOCOL_T5T) { |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 965 | return (NFA_STATUS_WRONG_PROTOCOL); |
| 966 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 967 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 968 | /* we don't know block size of tag */ |
| 969 | if ((nfa_rw_cb.i93_block_size == 0) || (nfa_rw_cb.i93_num_block == 0)) { |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 970 | return (NFA_STATUS_FAILED); |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 971 | } |
| 972 | |
| 973 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf( |
| 974 | (uint16_t)(sizeof(tNFA_RW_OPERATION) + nfa_rw_cb.i93_block_size)); |
| 975 | if (p_msg != NULL) { |
| 976 | /* Fill in tNFA_RW_OPERATION struct */ |
| 977 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 978 | p_msg->op = NFA_RW_OP_I93_WRITE_SINGLE_BLOCK; |
| 979 | |
| 980 | p_msg->params.i93_cmd.first_block_number = block_number; |
| 981 | p_msg->params.i93_cmd.p_data = (uint8_t*)(p_msg + 1); |
| 982 | |
| 983 | memcpy(p_msg->params.i93_cmd.p_data, p_data, nfa_rw_cb.i93_block_size); |
| 984 | |
| 985 | nfa_sys_sendmsg(p_msg); |
| 986 | |
| 987 | return (NFA_STATUS_OK); |
| 988 | } |
| 989 | |
| 990 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 991 | } |
| 992 | |
| 993 | /******************************************************************************* |
| 994 | ** |
| 995 | ** Function NFA_RwI93LockBlock |
| 996 | ** |
| 997 | ** Description: |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 998 | ** Send Lock block command to the activated T5T tag. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 999 | ** |
| 1000 | ** When the operation has completed (or if an error occurs), the |
| 1001 | ** app will be notified with NFA_I93_CMD_CPLT_EVT. |
| 1002 | ** |
| 1003 | ** Returns: |
| 1004 | ** NFA_STATUS_OK if successfully initiated |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1005 | ** NFA_STATUS_WRONG_PROTOCOL: T5T tag not activated |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1006 | ** NFA_STATUS_FAILED otherwise |
| 1007 | ** |
| 1008 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1009 | tNFA_STATUS NFA_RwI93LockBlock(uint8_t block_number) { |
| 1010 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1011 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1012 | DLOG_IF(INFO, nfc_debug_enabled) |
| 1013 | << StringPrintf("block_number: 0x%02X", block_number); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1014 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1015 | if (nfa_rw_cb.protocol != NFC_PROTOCOL_T5T) { |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1016 | return (NFA_STATUS_WRONG_PROTOCOL); |
| 1017 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1018 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1019 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 1020 | if (p_msg != NULL) { |
| 1021 | /* Fill in tNFA_RW_OPERATION struct */ |
| 1022 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 1023 | p_msg->op = NFA_RW_OP_I93_LOCK_BLOCK; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1024 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1025 | p_msg->params.i93_cmd.first_block_number = block_number; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1026 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1027 | nfa_sys_sendmsg(p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1028 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1029 | return (NFA_STATUS_OK); |
| 1030 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1031 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1032 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1033 | } |
| 1034 | |
| 1035 | /******************************************************************************* |
| 1036 | ** |
| 1037 | ** Function NFA_RwI93ReadMultipleBlocks |
| 1038 | ** |
| 1039 | ** Description: |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1040 | ** Send Read Multiple Block command to the activated T5T tag. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1041 | ** |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1042 | ** Data is returned to the application using the NFA_DATA_EVT. When the |
| 1043 | ** read operation has completed, or if an error occurs, the app will be |
| 1044 | ** notified with NFA_I93_CMD_CPLT_EVT. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1045 | ** |
| 1046 | ** Returns: |
| 1047 | ** NFA_STATUS_OK if successfully initiated |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1048 | ** NFA_STATUS_WRONG_PROTOCOL: T5T tag not activated |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1049 | ** NFA_STATUS_FAILED otherwise |
| 1050 | ** |
| 1051 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1052 | tNFA_STATUS NFA_RwI93ReadMultipleBlocks(uint8_t first_block_number, |
| 1053 | uint16_t number_blocks) { |
| 1054 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1055 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1056 | DLOG_IF(INFO, nfc_debug_enabled) |
| 1057 | << StringPrintf("%d, %d", first_block_number, number_blocks); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1058 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1059 | if (nfa_rw_cb.protocol != NFC_PROTOCOL_T5T) { |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1060 | return (NFA_STATUS_WRONG_PROTOCOL); |
| 1061 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1062 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1063 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 1064 | if (p_msg != NULL) { |
| 1065 | /* Fill in tNFA_RW_OPERATION struct */ |
| 1066 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 1067 | p_msg->op = NFA_RW_OP_I93_READ_MULTI_BLOCK; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1068 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1069 | p_msg->params.i93_cmd.first_block_number = first_block_number; |
| 1070 | p_msg->params.i93_cmd.number_blocks = number_blocks; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1071 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1072 | nfa_sys_sendmsg(p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1073 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1074 | return (NFA_STATUS_OK); |
| 1075 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1076 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1077 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1078 | } |
| 1079 | |
| 1080 | /******************************************************************************* |
| 1081 | ** |
| 1082 | ** Function NFA_RwI93WriteMultipleBlocks |
| 1083 | ** |
| 1084 | ** Description: |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1085 | ** Send Write Multiple Block command to the activated T5T tag. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1086 | ** |
| 1087 | ** When the write operation has completed (or if an error occurs), the |
| 1088 | ** app will be notified with NFA_I93_CMD_CPLT_EVT. |
| 1089 | ** |
| 1090 | ** Returns: |
| 1091 | ** NFA_STATUS_OK if successfully initiated |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1092 | ** NFA_STATUS_WRONG_PROTOCOL: T5T tag not activated |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1093 | ** NFA_STATUS_FAILED otherwise |
| 1094 | ** |
| 1095 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1096 | tNFA_STATUS NFA_RwI93WriteMultipleBlocks(uint8_t first_block_number, |
| 1097 | uint16_t number_blocks, |
| 1098 | uint8_t* p_data) { |
| 1099 | tNFA_RW_OPERATION* p_msg; |
| 1100 | uint16_t data_length; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1101 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1102 | DLOG_IF(INFO, nfc_debug_enabled) |
| 1103 | << StringPrintf("%d, %d", first_block_number, number_blocks); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1104 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1105 | if (nfa_rw_cb.protocol != NFC_PROTOCOL_T5T) { |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1106 | return (NFA_STATUS_WRONG_PROTOCOL); |
| 1107 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1108 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1109 | /* we don't know block size of tag */ |
| 1110 | if ((nfa_rw_cb.i93_block_size == 0) || (nfa_rw_cb.i93_num_block == 0)) { |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1111 | return (NFA_STATUS_FAILED); |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1112 | } |
| 1113 | |
| 1114 | data_length = nfa_rw_cb.i93_block_size * number_blocks; |
| 1115 | |
| 1116 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf( |
| 1117 | (uint16_t)(sizeof(tNFA_RW_OPERATION) + data_length)); |
| 1118 | if (p_msg != NULL) { |
| 1119 | /* Fill in tNFA_RW_OPERATION struct */ |
| 1120 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 1121 | p_msg->op = NFA_RW_OP_I93_WRITE_MULTI_BLOCK; |
| 1122 | |
| 1123 | p_msg->params.i93_cmd.first_block_number = first_block_number; |
| 1124 | p_msg->params.i93_cmd.number_blocks = number_blocks; |
| 1125 | p_msg->params.i93_cmd.p_data = (uint8_t*)(p_msg + 1); |
| 1126 | |
| 1127 | memcpy(p_msg->params.i93_cmd.p_data, p_data, data_length); |
| 1128 | |
| 1129 | nfa_sys_sendmsg(p_msg); |
| 1130 | |
| 1131 | return (NFA_STATUS_OK); |
| 1132 | } |
| 1133 | |
| 1134 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1135 | } |
| 1136 | |
| 1137 | /******************************************************************************* |
| 1138 | ** |
| 1139 | ** Function NFA_RwI93Select |
| 1140 | ** |
| 1141 | ** Description: |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1142 | ** Send Select command to the activated T5T tag. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1143 | ** |
| 1144 | ** UID[0]: 0xE0, MSB |
| 1145 | ** UID[1]: IC Mfg Code |
| 1146 | ** ... |
| 1147 | ** UID[7]: LSB |
| 1148 | ** |
| 1149 | ** When the operation has completed (or if an error occurs), the |
| 1150 | ** app will be notified with NFA_I93_CMD_CPLT_EVT. |
| 1151 | ** |
| 1152 | ** Returns: |
| 1153 | ** NFA_STATUS_OK if successfully initiated |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1154 | ** NFA_STATUS_WRONG_PROTOCOL: T5T tag not activated |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1155 | ** NFA_STATUS_FAILED otherwise |
| 1156 | ** |
| 1157 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1158 | tNFA_STATUS NFA_RwI93Select(uint8_t* p_uid) { |
| 1159 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1160 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1161 | DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf( |
| 1162 | "UID: [%02X%02X%02X...]", *(p_uid), *(p_uid + 1), *(p_uid + 2)); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1163 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1164 | if (nfa_rw_cb.protocol != NFC_PROTOCOL_T5T) { |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1165 | return (NFA_STATUS_WRONG_PROTOCOL); |
| 1166 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1167 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1168 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf( |
| 1169 | (uint16_t)(sizeof(tNFA_RW_OPERATION) + I93_UID_BYTE_LEN)); |
| 1170 | if (p_msg != NULL) { |
| 1171 | /* Fill in tNFA_RW_OPERATION struct */ |
| 1172 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 1173 | p_msg->op = NFA_RW_OP_I93_SELECT; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1174 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1175 | p_msg->params.i93_cmd.p_data = (uint8_t*)(p_msg + 1); |
| 1176 | memcpy(p_msg->params.i93_cmd.p_data, p_uid, I93_UID_BYTE_LEN); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1177 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1178 | nfa_sys_sendmsg(p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1179 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1180 | return (NFA_STATUS_OK); |
| 1181 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1182 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1183 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1184 | } |
| 1185 | |
| 1186 | /******************************************************************************* |
| 1187 | ** |
| 1188 | ** Function NFA_RwI93ResetToReady |
| 1189 | ** |
| 1190 | ** Description: |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1191 | ** Send Reset to ready command to the activated T5T tag. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1192 | ** |
| 1193 | ** When the operation has completed (or if an error occurs), the |
| 1194 | ** app will be notified with NFA_I93_CMD_CPLT_EVT. |
| 1195 | ** |
| 1196 | ** Returns: |
| 1197 | ** NFA_STATUS_OK if successfully initiated |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1198 | ** NFA_STATUS_WRONG_PROTOCOL: T5T tag not activated |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1199 | ** NFA_STATUS_FAILED otherwise |
| 1200 | ** |
| 1201 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1202 | tNFA_STATUS NFA_RwI93ResetToReady(void) { |
| 1203 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1204 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1205 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1206 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1207 | if (nfa_rw_cb.protocol != NFC_PROTOCOL_T5T) { |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1208 | return (NFA_STATUS_WRONG_PROTOCOL); |
| 1209 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1210 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1211 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 1212 | if (p_msg != NULL) { |
| 1213 | /* Fill in tNFA_RW_OPERATION struct */ |
| 1214 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 1215 | p_msg->op = NFA_RW_OP_I93_RESET_TO_READY; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1216 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1217 | nfa_sys_sendmsg(p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1218 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1219 | return (NFA_STATUS_OK); |
| 1220 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1221 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1222 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1223 | } |
| 1224 | |
| 1225 | /******************************************************************************* |
| 1226 | ** |
| 1227 | ** Function NFA_RwI93WriteAFI |
| 1228 | ** |
| 1229 | ** Description: |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1230 | ** Send Write AFI command to the activated T5T tag. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1231 | ** |
| 1232 | ** When the operation has completed (or if an error occurs), the |
| 1233 | ** app will be notified with NFA_I93_CMD_CPLT_EVT. |
| 1234 | ** |
| 1235 | ** Returns: |
| 1236 | ** NFA_STATUS_OK if successfully initiated |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1237 | ** NFA_STATUS_WRONG_PROTOCOL: T5T tag not activated |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1238 | ** NFA_STATUS_FAILED otherwise |
| 1239 | ** |
| 1240 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1241 | tNFA_STATUS NFA_RwI93WriteAFI(uint8_t afi) { |
| 1242 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1243 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1244 | DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("AFI: 0x%02X", afi); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1245 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1246 | if (nfa_rw_cb.protocol != NFC_PROTOCOL_T5T) { |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1247 | return (NFA_STATUS_WRONG_PROTOCOL); |
| 1248 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1249 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1250 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 1251 | if (p_msg != NULL) { |
| 1252 | /* Fill in tNFA_RW_OPERATION struct */ |
| 1253 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 1254 | p_msg->op = NFA_RW_OP_I93_WRITE_AFI; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1255 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1256 | p_msg->params.i93_cmd.afi = afi; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1257 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1258 | nfa_sys_sendmsg(p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1259 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1260 | return (NFA_STATUS_OK); |
| 1261 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1262 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1263 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1264 | } |
| 1265 | |
| 1266 | /******************************************************************************* |
| 1267 | ** |
| 1268 | ** Function NFA_RwI93LockAFI |
| 1269 | ** |
| 1270 | ** Description: |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1271 | ** Send Lock AFI command to the activated T5T tag. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1272 | ** |
| 1273 | ** When the operation has completed (or if an error occurs), the |
| 1274 | ** app will be notified with NFA_I93_CMD_CPLT_EVT. |
| 1275 | ** |
| 1276 | ** Returns: |
| 1277 | ** NFA_STATUS_OK if successfully initiated |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1278 | ** NFA_STATUS_WRONG_PROTOCOL: T5T tag not activated |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1279 | ** NFA_STATUS_FAILED otherwise |
| 1280 | ** |
| 1281 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1282 | tNFA_STATUS NFA_RwI93LockAFI(void) { |
| 1283 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1284 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1285 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1286 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1287 | if (nfa_rw_cb.protocol != NFC_PROTOCOL_T5T) { |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1288 | return (NFA_STATUS_WRONG_PROTOCOL); |
| 1289 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1290 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1291 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 1292 | if (p_msg != NULL) { |
| 1293 | /* Fill in tNFA_RW_OPERATION struct */ |
| 1294 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 1295 | p_msg->op = NFA_RW_OP_I93_LOCK_AFI; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1296 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1297 | nfa_sys_sendmsg(p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1298 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1299 | return (NFA_STATUS_OK); |
| 1300 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1301 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1302 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1303 | } |
| 1304 | |
| 1305 | /******************************************************************************* |
| 1306 | ** |
| 1307 | ** Function NFA_RwI93WriteDSFID |
| 1308 | ** |
| 1309 | ** Description: |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1310 | ** Send Write DSFID command to the activated T5T tag. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1311 | ** |
| 1312 | ** When the operation has completed (or if an error occurs), the |
| 1313 | ** app will be notified with NFA_I93_CMD_CPLT_EVT. |
| 1314 | ** |
| 1315 | ** Returns: |
| 1316 | ** NFA_STATUS_OK if successfully initiated |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1317 | ** NFA_STATUS_WRONG_PROTOCOL: T5T tag not activated |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1318 | ** NFA_STATUS_FAILED otherwise |
| 1319 | ** |
| 1320 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1321 | tNFA_STATUS NFA_RwI93WriteDSFID(uint8_t dsfid) { |
| 1322 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1323 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1324 | DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("DSFID: 0x%02X", dsfid); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1325 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1326 | if (nfa_rw_cb.protocol != NFC_PROTOCOL_T5T) { |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1327 | return (NFA_STATUS_WRONG_PROTOCOL); |
| 1328 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1329 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1330 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 1331 | if (p_msg != NULL) { |
| 1332 | /* Fill in tNFA_RW_OPERATION struct */ |
| 1333 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 1334 | p_msg->op = NFA_RW_OP_I93_WRITE_DSFID; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1335 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1336 | p_msg->params.i93_cmd.dsfid = dsfid; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1337 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1338 | nfa_sys_sendmsg(p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1339 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1340 | return (NFA_STATUS_OK); |
| 1341 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1342 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1343 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1344 | } |
| 1345 | |
| 1346 | /******************************************************************************* |
| 1347 | ** |
| 1348 | ** Function NFA_RwI93LockDSFID |
| 1349 | ** |
| 1350 | ** Description: |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1351 | ** Send Lock DSFID command to the activated T5T tag. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1352 | ** |
| 1353 | ** When the operation has completed (or if an error occurs), the |
| 1354 | ** app will be notified with NFA_I93_CMD_CPLT_EVT. |
| 1355 | ** |
| 1356 | ** Returns: |
| 1357 | ** NFA_STATUS_OK if successfully initiated |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1358 | ** NFA_STATUS_WRONG_PROTOCOL: T5T tag not activated |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1359 | ** NFA_STATUS_FAILED otherwise |
| 1360 | ** |
| 1361 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1362 | tNFA_STATUS NFA_RwI93LockDSFID(void) { |
| 1363 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1364 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1365 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1366 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1367 | if (nfa_rw_cb.protocol != NFC_PROTOCOL_T5T) { |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1368 | return (NFA_STATUS_WRONG_PROTOCOL); |
| 1369 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1370 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1371 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 1372 | if (p_msg != NULL) { |
| 1373 | /* Fill in tNFA_RW_OPERATION struct */ |
| 1374 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 1375 | p_msg->op = NFA_RW_OP_I93_LOCK_DSFID; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1376 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1377 | nfa_sys_sendmsg(p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1378 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1379 | return (NFA_STATUS_OK); |
| 1380 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1381 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1382 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1383 | } |
| 1384 | |
| 1385 | /******************************************************************************* |
| 1386 | ** |
| 1387 | ** Function NFA_RwI93GetSysInfo |
| 1388 | ** |
| 1389 | ** Description: |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1390 | ** Send Get system information command to the activated T5T tag. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1391 | ** If UID is provided then set UID[0]:MSB, ... UID[7]:LSB |
| 1392 | ** |
| 1393 | ** When the operation has completed (or if an error occurs), the |
| 1394 | ** app will be notified with NFA_I93_CMD_CPLT_EVT. |
| 1395 | ** |
| 1396 | ** Returns: |
| 1397 | ** NFA_STATUS_OK if successfully initiated |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1398 | ** NFA_STATUS_WRONG_PROTOCOL: T5T tag not activated |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1399 | ** NFA_STATUS_FAILED otherwise |
| 1400 | ** |
| 1401 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1402 | tNFA_STATUS NFA_RwI93GetSysInfo(uint8_t* p_uid) { |
| 1403 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1404 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1405 | DLOG_IF(INFO, nfc_debug_enabled) << __func__; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1406 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1407 | if (nfa_rw_cb.protocol != NFC_PROTOCOL_T5T) { |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1408 | return (NFA_STATUS_WRONG_PROTOCOL); |
| 1409 | } |
| 1410 | |
| 1411 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 1412 | if (p_msg != NULL) { |
| 1413 | /* Fill in tNFA_RW_OPERATION struct */ |
| 1414 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 1415 | p_msg->op = NFA_RW_OP_I93_GET_SYS_INFO; |
| 1416 | |
| 1417 | if (p_uid) { |
| 1418 | p_msg->params.i93_cmd.uid_present = true; |
| 1419 | memcpy(p_msg->params.i93_cmd.uid, p_uid, I93_UID_BYTE_LEN); |
| 1420 | } else { |
| 1421 | p_msg->params.i93_cmd.uid_present = false; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1422 | } |
| 1423 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1424 | nfa_sys_sendmsg(p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1425 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1426 | return (NFA_STATUS_OK); |
| 1427 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1428 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1429 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1430 | } |
| 1431 | |
| 1432 | /******************************************************************************* |
| 1433 | ** |
| 1434 | ** Function NFA_RwI93GetMultiBlockSecurityStatus |
| 1435 | ** |
| 1436 | ** Description: |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1437 | ** Send Get Multiple block security status command to the activated |
| 1438 | ** T5T tag. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1439 | ** |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1440 | ** Data is returned to the application using the NFA_DATA_EVT. When the |
| 1441 | ** read operation has completed, or if an error occurs, the app will be |
| 1442 | ** notified with NFA_I93_CMD_CPLT_EVT. |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1443 | ** |
| 1444 | ** Returns: |
| 1445 | ** NFA_STATUS_OK if successfully initiated |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1446 | ** NFA_STATUS_WRONG_PROTOCOL: T5T tag not activated |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1447 | ** NFA_STATUS_FAILED otherwise |
| 1448 | ** |
| 1449 | *******************************************************************************/ |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1450 | tNFA_STATUS NFA_RwI93GetMultiBlockSecurityStatus(uint8_t first_block_number, |
| 1451 | uint16_t number_blocks) { |
| 1452 | tNFA_RW_OPERATION* p_msg; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1453 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1454 | DLOG_IF(INFO, nfc_debug_enabled) |
| 1455 | << StringPrintf("%d, %d", first_block_number, number_blocks); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1456 | |
nxf24591 | c1cbeab | 2018-02-21 17:32:26 +0530 | [diff] [blame] | 1457 | if (nfa_rw_cb.protocol != NFC_PROTOCOL_T5T) { |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1458 | return (NFA_STATUS_WRONG_PROTOCOL); |
| 1459 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1460 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1461 | p_msg = (tNFA_RW_OPERATION*)GKI_getbuf((uint16_t)(sizeof(tNFA_RW_OPERATION))); |
| 1462 | if (p_msg != NULL) { |
| 1463 | /* Fill in tNFA_RW_OPERATION struct */ |
| 1464 | p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; |
| 1465 | p_msg->op = NFA_RW_OP_I93_GET_MULTI_BLOCK_STATUS; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1466 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1467 | p_msg->params.i93_cmd.first_block_number = first_block_number; |
| 1468 | p_msg->params.i93_cmd.number_blocks = number_blocks; |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1469 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1470 | nfa_sys_sendmsg(p_msg); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1471 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1472 | return (NFA_STATUS_OK); |
| 1473 | } |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1474 | |
nxpandroid | 8f6d053 | 2017-07-12 18:25:30 +0530 | [diff] [blame] | 1475 | return (NFA_STATUS_FAILED); |
nxpandroid | c761165 | 2015-09-23 16:42:05 +0530 | [diff] [blame] | 1476 | } |