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