/usr/include/android-22/libnfc-nxp/phFriNfc_NdefMap.h is in android-headers-22 23-0ubuntu4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 | /*
* Copyright (C) 2010 NXP Semiconductors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* \file phFriNfc_NdefMap.h
* \brief NFC Ndef Mapping For Different Smart Cards.
*
* Project: NFC-FRI
*
* $Date: Mon Dec 13 14:14:14 2010 $
* $Author: ing02260 $
* $Revision: 1.25 $
* $Aliases: $
*
*/
#ifndef PHFRINFC_NDEFMAP_H
#define PHFRINFC_NDEFMAP_H
/*include files*/
#include <phNfcTypes.h>
#include <phNfcStatus.h>
#include <phFriNfc.h>
#ifdef PH_HAL4_ENABLE
#include <phHal4Nfc.h>
#else
#include <phHalNfc.h>
#endif
#include <phFriNfc_OvrHal.h>
#ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */
/**
* \name NDEF Mapping
*
* File: \ref phFriNfc_NdefMap.h
*
*/
/*@{*/
#define PH_FRINFC_NDEFMAP_FILEREVISION "$Revision: 1.25 $" /**< \ingroup grp_file_attributes */
#define PH_FRINFC_NDEFMAP_FILEALIASES "$Aliases: $" /**< \ingroup grp_file_attributes */
/*@}*/
#endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */
/** \defgroup grp_fri_nfc_ndef_map NDEF Mapping Component
*
* This component implements the read/write/check NDEF functions for remote devices.
* NDEF data, as defined by the NFC Forum NDEF specification are written to or read from
* a remote device that can be a smart- or memory card. \n\n
* Please notice that the NDEF mapping command sequence must
* be \b contiguous (after correct initialisation): \n
* \b Examples:
* - Checking and Reading
* - \ref phFriNfc_NdefMap_ChkNdef
* - \ref phFriNfc_NdefMap_RdNdef
* .
* - Checking and Writing
* - \ref phFriNfc_NdefMap_ChkNdef
* - \ref phFriNfc_NdefMap_WrNdef
* .
* - Checking, Reading and Writing
* - \ref phFriNfc_NdefMap_ChkNdef
* - \ref phFriNfc_NdefMap_RdNdef
* - \ref phFriNfc_NdefMap_WrNdef
* .
* .
* There must be \b no \b other FRI or HAL call between these mapping commands. Exceptions to this
* rule are specific to the NDEF mapping of certain card / remote device types and separately noted,
* typically for true multi-activation capable devices.
*
*/
/**
* \name NDEF Mapping - specifies the different card types
* These are the only recognised card types in this version.
*
*/
/*@{*/
#define DESFIRE_EV1
#define PH_FRINFC_NDEFMAP_MIFARE_UL_CARD 1 /**< \internal Mifare UL */
#define PH_FRINFC_NDEFMAP_ISO14443_4A_CARD 2 /**< \internal Iso 14443-4A */
#define PH_FRINFC_NDEFMAP_MIFARE_STD_1K_CARD 3 /**< \internal Mifare Standard */
#define PH_FRINFC_NDEFMAP_MIFARE_STD_4K_CARD 4 /**< \internal Mifare Standard */
#define PH_FRINFC_NDEFMAP_FELICA_SMART_CARD 5 /**< \internal Felica Smart Tag */
#define PH_FRINFC_NDEFMAP_TOPAZ_CARD 7 /**< \internal Felica Smart Tag */
#define PH_FRINFC_NDEFMAP_TOPAZ_DYNAMIC_CARD 8 /**< \internal Felica Smart Tag */
#ifdef DESFIRE_EV1
#define PH_FRINFC_NDEFMAP_ISO14443_4A_CARD_EV1 9 /**< \internal Iso 14443-4A EV1 */
#endif /* #ifdef DESFIRE_EV1 */
#define PH_FRINFC_NDEFMAP_ISO15693_CARD 10 /**< \internal ISO 15693 */
#ifdef PH_NDEF_MIFARE_ULC
#define PH_FRINFC_NDEFMAP_MIFARE_ULC_CARD 8 /**< \internal Mifare UL */
#endif /* #ifdef PH_NDEF_MIFARE_ULC */
#define PH_FRINFC_NDEFMAP_EMPTY_NDEF_MSG {0xD0, 0x00, 0x00} /**< \internal Empty ndef message */
#ifdef PHFRINFC_OVRHAL_MOCKUP /* */
#define PH_FRINFC_NDEFMAP_MOCKUP_CARD 6 /**< \internal Mocup*/
#endif /* PHFRINFC_OVRHAL_MOCKUP */
/* Enum reperesents the different card state*/
typedef enum
{
PH_NDEFMAP_CARD_STATE_INITIALIZED,
PH_NDEFMAP_CARD_STATE_READ_ONLY,
PH_NDEFMAP_CARD_STATE_READ_WRITE,
PH_NDEFMAP_CARD_STATE_INVALID
}phNDEF_CARD_STATE;
/*@}*/
#ifndef PH_FRINFC_MAP_MIFARESTD_DISABLED
/**
* \name NDEF Mapping - specifies the Compliant Blocks in the Mifare 1k and 4k card types
*
*/
/*@{*/
#define PH_FRINFC_NDEFMAP_MIFARESTD_1KNDEF_COMPBLOCK 45 /**< \internal Total Ndef Compliant blocks Mifare 1k */
#define PH_FRINFC_NDEFMAP_MIFARESTD_4KNDEF_COMPBLOCK 210 /**< \internal Total Ndef Compliant blocks Mifare 4k */
#define PH_FRINFC_NDEFMAP_MIFARESTD_RDWR_SIZE 16 /**< \internal Bytes read/write for one read/write operation*/
#define PH_FRINFC_NDEFMAP_MIFARESTD_TOTALNO_BLK 40 /**< \internal Total number of sectors in Mifare 4k */
#define PH_FRINFC_NDEFMAP_MIFARESTD_ST15_BYTES 15 /**< \internal To store 15 bytes after reading a block */
/*@}*/
#endif /* PH_FRINFC_MAP_MIFARESTD_DISABLED */
#ifndef PH_FRINFC_MAP_TOPAZ_DISABLED
/**
* \name NDEF Mapping - specifies the Compliant Blocks in the Mifare 1k and 4k card types
*
*/
/*@{*/
#define PH_FRINFC_NDEFMAP_TOPAZ_MAX_SIZE 256 /**< \internal Total Memory size = 96 bytes (newer version have mode) */
#define PH_FRINFC_NDEFMAP_TOPAZ_UID_SIZE 0x04 /**< \internal UID size returned by READID command = 4 bytes */
/*@}*/
#endif /* PH_FRINFC_MAP_TOPAZ_DISABLED */
#ifndef PH_FRINFC_MAP_FELICA_DISABLED
/* Felica Mapping - Constants */
#define PH_FRINFC_NDEFMAP_FELICA_BLOCK_SIZE 16
#define PH_FRINFC_NDEFMAP_FELICA_ATTR_NDEF_DATA_LEN 3
#define PH_FRINFC_NDEFMAP_FELICA_MANUF_ID_DATA_LEN 8
#endif /* PH_FRINFC_MAP_FELICA_DISABLED */
/* MifareUL/Type2 specific constants*/
#ifndef PH_FRINFC_MAP_MIFAREUL_DISABLED
#ifdef PH_NDEF_MIFARE_ULC
#define PH_FRINFC_NDEFMAP_MFUL_64BYTES_BUF 2048 /**< \internal To store 2048 bytes after reading entire card */
#else
#define PH_FRINFC_NDEFMAP_MFUL_64BYTES_BUF 64 /**< \internal To store 64 bytes after reading entire card */
#endif /*#ifdef PH_NDEF_MIFARE_ULC */
#define PH_FRINFC_NDEFMAP_MFUL_4BYTES_BUF 4 /**< \internal To store 4 bytes after write */
#endif /*#ifndef PH_FRINFC_MAP_MIFAREUL_DISABLED*/
#ifdef PHFRINFC_OVRHAL_MOCKUP /* */
#define PH_FRINFC_NDEFMAP_MOCKUP_4096BYTES_BUF 4096 /**< \internal To store 4 bytes after write */
#endif /*#ifndef PH_FRINFC_MAP_MOCKUP_DISABLED*/
/**
* \name Completion Routine Indices
*
* These are the indices of the completion routine pointers within the component context.
* Completion routines belong to upper components.
*
*/
/*@{*/
/** \ingroup grp_fri_nfc_ndef_map
* Completion Routine Index for \ref phFriNfc_NdefMap_ChkNdef */
#define PH_FRINFC_NDEFMAP_CR_CHK_NDEF 0 /* */
/** \ingroup grp_fri_nfc_ndef_map
* Completion Routine Index for \ref phFriNfc_NdefMap_RdNdef */
#define PH_FRINFC_NDEFMAP_CR_RD_NDEF 1 /* */
/** \ingroup grp_fri_nfc_ndef_map
* Completion Routine Index for \ref phFriNfc_NdefMap_WrNdef */
#define PH_FRINFC_NDEFMAP_CR_WR_NDEF 2 /* */
/** \ingroup grp_fri_nfc_ndef_map
* Completion Routine Index for \ref phFriNfc_NdefMap_EraseNdef */
#define PH_FRINFC_NDEFMAP_CR_ERASE_NDEF 3 /* */
/** \ingroup grp_fri_nfc_ndef_map Completion
* Routine Index for Unknown States/Operations */
#define PH_FRINFC_NDEFMAP_CR_INVALID_OPE 4 /* */
/** \ingroup grp_fri_nfc_ndef_map
* Number of completion routines that have to be initialised */
#define PH_FRINFC_NDEFMAP_CR 5 /* */
/*@}*/
/**
* \name File Offset Attributes
*
* Following values are used to determine the offset value for Read/Write. This specifies whether
* the Read/Write operation needs to be restarted/continued from the last offset set.
*
*/
/*@{*/
/** \ingroup grp_fri_nfc_ndef_map
* Read/Write operation shall start from the last offset set */
#define PH_FRINFC_NDEFMAP_SEEK_CUR 0 /* */
/** \ingroup grp_fri_nfc_ndef_map
* Read/Write operation shall start from the begining of the file/card */
#define PH_FRINFC_NDEFMAP_SEEK_BEGIN 1 /* */
/*@}*/
/**
* \name Buffer Size Definitions
*
*/
/*@{*/
/** \ingroup grp_fri_nfc_ndef_map Minimum size of the TRX buffer required */
#define PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE 252 /* */
/** \internal The size of s MIFARE block */
#define PH_FRINFC_NDEFMAP_MF_READ_BLOCK_SIZE 16 /* */
#ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */
#ifndef PH_FRINFC_MAP_ISO15693_DISABLED
#define ISO15693_MAX_DATA_TO_STORE 0x04U
typedef struct phFriNfc_ISO15693Cont
{
/**< \internal block number that is executed */
uint16_t current_block;
/**< \internal The state of the operation */
uint8_t state;
/**< \internal Completion routine index */
uint8_t cr_index;
/**< \internal Execution sequence */
uint8_t ndef_seq;
/**< \internal NDEF TLV size */
uint16_t actual_ndef_size;
/**< \internal NDEF TLV size */
uint16_t max_data_size;
/**< \internal NDEF TLV TYPE block number */
uint16_t ndef_tlv_type_blk;
/**< \internal NDEF TLV TYPE byte number in the
"ndef_tlv_type_blk" */
uint8_t ndef_tlv_type_byte;
/**< \internal Store the remaining bytes that can be used for
READ with continue option */
uint8_t store_read_data[ISO15693_MAX_DATA_TO_STORE];
uint8_t store_length;
/**< \internal Remaining size that can be read */
uint16_t remaining_size_to_read;
uint8_t read_capabilities;
}phFriNfc_ISO15693Cont_t;
#endif /* #ifndef PH_FRINFC_MAP_ISO15693_DISABLED */
#ifndef PH_FRINFC_MAP_FELICA_DISABLED
/**
* \ingroup grp_fri_nfc_ndef_map
* \brief Felica Basic structure which details the different vaiables
* used for Reading/writing.
*
*/
typedef struct phFriNfc_Felica
{
/**< Current block being read or written*/
uint8_t CurBlockNo;
/**< No. Of Written*/
uint8_t NoBlocksWritten;
/**< Following are different variables used for write operation*/
uint8_t Wr_BytesRemained; /* No of bytes to pad*/
/**< Buffer to store odd number of block data */
uint8_t Wr_RemainedBytesBuff[PH_FRINFC_NDEFMAP_FELICA_BLOCK_SIZE];
/**< Following are different variables used for read operation*/
uint8_t Rd_NoBytesToCopy; /*specifies the extra number of read bytes */
/**< stores extra read data bytes*/
uint8_t Rd_BytesToCopyBuff[PH_FRINFC_NDEFMAP_FELICA_BLOCK_SIZE];
/**< Flag determines Intermediate Copy Operation*/
uint8_t IntermediateCpyFlag;
/**< Stores Intermediate Copy data len*/
uint8_t IntermediateCpyLen;
/**< Flag specifies Pad Byte Information*/
uint8_t PadByteFlag;
/**< Flag specifies Intermediate WR Information*/
uint8_t IntermediateWrFlag;
/**< Flag specifies Intermediate Rd Information*/
uint8_t IntermediateRdFlag;
/**< Flag specifies Last Block Reached Information*/
uint8_t LastBlkReachedFlag;
/**< Specifies how many bytes read from the card*/
uint16_t CurrBytesRead;
/**< Flag specifies EOF card reached Information*/
uint8_t EofCardReachedFlag;
/**< Flag specifies different Operation Types*/
uint8_t OpFlag;
/**< Specifies Offset*/
uint8_t Offset;
/**< Specifies TrxLen Information*/
uint16_t TrxLen;
}phFriNfc_Felica_t;
/**
* \ingroup grp_fri_nfc_ndef_map
* \brief Felica structure which details the different vaiables
* used to store the poll related information.
*
*/
typedef struct phFriNfc_Felica_PollDetails
{
phHal_sDevInputParam_t *DevInputParam;
#ifndef PH_HAL4_ENABLE
phHal_eOpModes_t *OpMode;
#endif
/**< Temporary place holder to the Remote Device
Information, required to store the Felica
session opened information. */
phHal_sRemoteDevInformation_t psTempRemoteDevInfo;
}phFriNfc_Felica_PollDetails_t;
/**
* \ingroup grp_fri_nfc_ndef_map
* \brief Felica structure which details the attribute related information.
*
*/
typedef struct phFriNfc_Felica_AttrInfo
{
/** Version of the Ndefmap document*/
uint8_t Version;
/** Nbr for check cmd*/
uint8_t Nbr;
/** Nbw for update cmd*/
uint8_t Nbw;
/** Maximum number of blocks to store Ndef data*/
uint16_t Nmaxb;
/** Flag to indicate the status of the write operation*/
uint8_t WriteFlag;
/** Flag to indicate the status of the read/write operation*/
uint8_t RdWrFlag;
/** Represents the length of Ndef data : 3 bytes*/
uint8_t LenBytes[PH_FRINFC_NDEFMAP_FELICA_ATTR_NDEF_DATA_LEN];
/** Specifies the ERASE NDEF Message Operation */
uint8_t EraseMsgFlag;
}phFriNfc_Felica_AttrInfo_t;
/**
* \ingroup grp_fri_nfc_ndef_map
* \brief Felica structure which details the different vaiables
* used to store the Card Manufacturer details.
*/
typedef struct phFriNfc_Felica_ManufDetails
{
/** Manufacture identifier*/
uint8_t ManufID[PH_FRINFC_NDEFMAP_FELICA_MANUF_ID_DATA_LEN];
/** Manufacture Parameters*/
uint8_t ManufParameter[PH_FRINFC_NDEFMAP_FELICA_MANUF_ID_DATA_LEN];
}phFriNfc_Felica_ManufDetails_t;
#endif /* PH_FRINFC_MAP_FELICA_DISABLED */
#ifndef PH_FRINFC_MAP_MIFARESTD_DISABLED
typedef struct phFriNfc_MifareStdCont
{
/** Device input parameter for poll and connect after failed authentication */
phHal_sDevInputParam_t *DevInputParam;
/** to store bytes that will be used in the
next write/read operation, if any */
uint8_t internalBuf[PH_FRINFC_NDEFMAP_MIFARESTD_ST15_BYTES];
/** to Store the length of the internalBuf */
uint16_t internalLength;
/** holds the block number which is presently been used */
uint8_t currentBlock;
/** the number of Ndef Compliant blocks written/read */
uint8_t NdefBlocks;
/** Total Number of Ndef Complaint Blocks */
uint16_t NoOfNdefCompBlocks;
/** used in write ndef, to know that internal bytes
are accessed */
uint8_t internalBufFlag;
/** used in write ndef, to know that last 16 bytes
are used to write*/
uint8_t RemainingBufFlag;
/** indicates that Read has reached the end of the
card */
uint8_t ReadWriteCompleteFlag;
/** indicates that Read has reached the end of the
card */
uint8_t ReadCompleteFlag;
/** indicates that Write is possible or not */
uint8_t WriteFlag;
/** indicates that Write is possible or not */
uint8_t ReadFlag;
/** indicates that Write is possible or not */
uint8_t RdBeforeWrFlag;
/** Authentication Flag indicating that a particular
sector is authenticated or not */
uint8_t AuthDone;
/** to store the last Sector ID in Check Ndef */
uint8_t SectorIndex;
/** to read the access bits of each sector */
uint8_t ReadAcsBitFlag;
/** Flag to check if Acs bit was written in this call */
uint8_t WriteAcsBitFlag;
/** Buffer to store 16 bytes */
uint8_t Buffer[PH_FRINFC_NDEFMAP_MIFARESTD_RDWR_SIZE];
/** to store the AIDs of Mifare 1k or 4k */
uint8_t aid[PH_FRINFC_NDEFMAP_MIFARESTD_TOTALNO_BLK];
/** flag to write with offset begin */
uint8_t WrNdefFlag;
/** flag to read with offset begin */
uint8_t ReadNdefFlag;
/** flag to check with offset begin */
uint8_t ChkNdefFlag;
/** To store the remaining size of the Mifare 1k or 4k card */
uint16_t remainingSize;
/** To update the remaining size when writing to the Mifare 1k or 4k card */
uint8_t remSizeUpdFlag;
/** The flag is to know that there is a different AID apart from
NFC forum sector AID */
uint16_t aidCompleteFlag;
/** The flag is to know that there is a a NFC forum sector exists
in the card */
uint16_t NFCforumSectFlag;
/** The flag is to know that the particular sector is a proprietary
NFC forum sector */
uint16_t ProprforumSectFlag;
/** The flag is set after reading the MAD sectors */
uint16_t ChkNdefCompleteFlag;
/** Flag to store the current block */
uint8_t TempBlockNo;
/** Completion routine index */
uint8_t CRIndex;
/** Bytes remaining to write for one write procedure */
uint16_t WrLength;
/** Flag to read after write */
uint8_t RdAfterWrFlag;
/** Flag to say that poll is required before write ndef (authentication) */
uint8_t PollFlag;
/** Flag is to know that this is first time the read has been called. This
is required when read is called after write (especially for the card formatted
with the 2nd configuration) */
uint8_t FirstReadFlag;
/** Flag is to know that this is first time the write has been called. This
is required when the card formatted with the 3rd configuration */
uint8_t FirstWriteFlag;
/** Indicates the sector trailor id for which the convert
to read only is currently in progress*/
uint8_t ReadOnlySectorIndex;
/** Indicates the total number of sectors on the card */
uint8_t TotalNoSectors;
/** Indicates the block number of the sector trailor on the card */
uint8_t SectorTrailerBlockNo;
/** Secret key B to given by the application */
uint8_t UserScrtKeyB[6];
}phFriNfc_MifareStdCont_t;
/*@}*/
#endif /* PH_FRINFC_MAP_MIFARESTD_DISABLED */
#ifndef PH_FRINFC_MAP_DESFIRE_DISABLED
/**
* \ingroup grp_fri_nfc_ndef_map
* \brief Capability Container.
*
* The Capability Container structure required for smart card operations.
*
*/
typedef struct phFriNfc_DesfireCapCont
{
uint16_t DesfVersion; /**< \internal Desfire Version . */
uint16_t NdefMsgFid; /**< \internal Ndef Message file pointer*/
uint16_t NdefFileSize; /**< \internal Holds Desfire File Size */
uint8_t ReadAccess; /**< \internal Read Access Information. */
uint8_t WriteAccess; /**< \internal Write Access Information. */
uint16_t MaxRespSize; /**< \internal Maximum expected response size. */
uint16_t MaxCmdSize; /**< \internal Maximum command size. */
uint16_t NdefDataLen; /**< \internal Holds actual NDEF Data Len.*/
uint8_t IsNlenPresentFlag; /**< \internal specifies NLEN presence .*/
uint8_t SkipNlenBytesFlag; /**< \internal sets on presence of NLEN.*/
} phFriNfc_DesfireCapCont_t;
#endif /* PH_FRINFC_MAP_DESFIRE_DISABLED */
#ifndef PH_FRINFC_MAP_MIFAREUL_DISABLED
/**
* \ingroup grp_fri_nfc_ndef_map
* \brief Mifare UL Basic structure which details the different vaiables
* used for Reading/writing.
*
*/
typedef struct phFriNfc_MifareULCont
{
/** to store bytes that will be used in the
next write/read operation, if any */
uint8_t InternalBuf[PH_FRINFC_NDEFMAP_MFUL_4BYTES_BUF];
/** to Store the length of the internalBuf */
uint16_t InternalLength;
/** holds the sector number which is presently been used */
uint8_t CurrentSector;
/** holds the block number which is presently been used */
uint8_t CurrentBlock;
/** to know the completion routine */
uint8_t CRindex;
/** This stores the free memory size left in the card */
uint16_t RemainingSize;
/** Copy all the data(including non NDEF TLVs) from the card */
uint8_t ReadBuf[PH_FRINFC_NDEFMAP_MFUL_64BYTES_BUF];
/** index of the above buffer */
uint16_t ReadBufIndex;
/** This variable stores the index of the "ReadBuf" from which actual
data has to be copied into the user buffer */
uint16_t ByteNumber;
/** indicates that read/write has reached the end of the
card */
uint8_t ReadWriteCompleteFlag;
/** Buffer to store 4 bytes of data which is written to a block */
uint8_t Buffer[PH_FRINFC_NDEFMAP_MFUL_4BYTES_BUF];
}phFriNfc_MifareULCont_t;
#endif /* PH_FRINFC_MAP_MIFAREUL_DISABLED */
#ifdef PHFRINFC_OVRHAL_MOCKUP /* */
/**
* \ingroup grp_fri_nfc_ndef_map
* \brief Mifare UL Basic structure which details the different vaiables
* used for Reading/writing.
*
*/
typedef struct phFriNfc_MockupCont
{
/** to store bytes that will be used in the
next write/read operation, if any */
uint8_t *NdefData;
/** to Store the length of the internalBuf */
uint32_t NdefActualSize;
/** to Store the length of the internalBuf */
uint32_t NdefMaxSize;
/** to Store the length of the internalBuf */
uint32_t CardSize;
/** holds the block number which is presently been used */
uint32_t CurrentBlock;
} phFriNfc_MockupCont_t;
#endif /* PHFRINFC_OVRHAL_MOCKUP */
#endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */
/**
* \ingroup grp_fri_nfc_ndef_map
* \brief NDEF TLV structure which details the different vaiables
* used for TLV.
*
*/
typedef struct phFriNfc_NDEFTLVCont
{
/** Flag is to know that the TLV Type Found */
uint8_t NdefTLVFoundFlag;
/** Sector number of the next/present available TLV */
uint8_t NdefTLVSector;
/** Following two variables are used to store the
T byte and the Block number in which the T is
found in Tag */
/** Byte number of the next/present available TLV */
uint16_t NdefTLVByte;
/** Block number of the next/present available TLV */
uint8_t NdefTLVBlock;
/** Authentication flag for NDEF TLV Block */
uint8_t NdefTLVAuthFlag;
/** if the 16th byte of the last read is type (T) of TLV
and next read contains length (L) bytes of TLV. This flag
is set when the type (T) of TLV is found in the last read */
uint8_t TcheckedinTLVFlag;
/** if the 16th byte of the last read is Length (L) of TLV
and next read contains length (L) bytes of TLV. This flag
is set when the Length (L) of TLV is found in the last read */
uint8_t LcheckedinTLVFlag;
/** This flag is set, if Terminator TLV is already written
and next read contains value (V) bytes of TLV. This flag
is set when the value (V) of TLV is found in the last read */
uint8_t SetTermTLVFlag;
/** To know the number of Length (L) field is present in the
next block */
uint8_t NoLbytesinTLV;
/** The value of 3 bytes length(L) field in TLV. In 3 bytes
length field, 2 bytes are in one block and other 1 byte
is in the next block. To store the former block length
field value, this variable is used */
uint16_t prevLenByteValue;
/** The value of length(L) field in TLV. */
uint16_t BytesRemainLinTLV;
/** Actual size to read and write. This will be always equal to the
length (L) of TLV as there is only one NDEF TLV . */
uint16_t ActualSize;
/** Flag is to write the length (L) field of the TLV */
uint8_t WrLenFlag;
/** Flag is to write the length (L) field of the TLV */
uint16_t NULLTLVCount;
/** Buffer to store 4 bytes of data which is written to a block */
uint8_t NdefTLVBuffer[PH_FRINFC_NDEFMAP_MFUL_4BYTES_BUF];
/** Buffer to store 4 bytes of data which is written to a next block */
uint8_t NdefTLVBuffer1[PH_FRINFC_NDEFMAP_MFUL_4BYTES_BUF];
}phFriNfc_NDEFTLVCont_t;
/**
* \ingroup grp_fri_nfc_ndef_map
* \brief Lock Control TLV structure which stores the Position,
* Size and PageCntrl details.
*/
typedef struct phFriNfc_LockCntrlTLVCont
{
/** Specifies the Byte Position of the lock cntrl tlv
in the card memory*/
uint16_t ByteAddr;
/** Specifies the Size of the lock area in terms of
bits/bytes*/
uint16_t Size;
/** Specifies the Bytes per Page*/
uint8_t BytesPerPage;
/** Specifies the BytesLockedPerLockBit */
uint8_t BytesLockedPerLockBit;
/** Specifies the index of Lock cntrl TLV*/
uint8_t LockTlvBuffIdx;
/** Store the content of Lock cntrl TLV*/
uint8_t LockTlvBuff[8];
/** Specifies the Block number Lock cntrl TLV*/
uint16_t BlkNum;
/** Specifies the Byte Number position of Lock cntrl TLV*/
uint16_t ByteNum;
}phFriNfc_LockCntrlTLVCont_t;
/**
* \ingroup grp_fri_nfc_ndef_map
* \brief Memeory Control TLV structure which stores the Position,
* Size and PageCntrl details of the reserved byte area.
*/
typedef struct phFriNfc_ResMemCntrlTLVCont
{
/** Specifies the Byte Position of the lock cntrl tlv
in the card memory*/
uint16_t ByteAddr;
/** Specifies the Size of the lock area in terms of
bits/bytes*/
uint16_t Size;
/** Store the content of Memory cntrl TLV*/
uint8_t MemCntrlTlvBuff[8];
/** Specifies the Bytes per Page*/
uint8_t BytesPerPage;
/** Specifies the index of Mem cntrl TLV*/
uint8_t MemTlvBuffIdx;
/** Specifies the Block number Lock cntrl TLV*/
uint16_t BlkNum;
/** Specifies the Byte Number position of Lock cntrl TLV*/
uint16_t ByteNum;
}phFriNfc_ResMemCntrlTLVCont_t;
#if !(defined(PH_FRINFC_MAP_TOPAZ_DISABLED ) || defined (PH_FRINFC_MAP_TOPAZ_DYNAMIC_DISABLED ))
/**
* \ingroup grp_fri_nfc_ndef_map
* \brief Topaz container structure which details the different vaiables
* used for Topaz card mapping.
*
*/
typedef struct phFriNfc_TopazCont
{
/** This stores the free memory size left in the card. In case of topaz,
this is updated only during check ndef */
uint16_t RemainingSize;
/** Stores the current block number */
uint8_t CurrentBlock;
/** Stores the current block number */
uint8_t ByteNumber;
/** To know the completion routine call */
uint8_t CRIndex;
uint8_t ReadWriteCompleteFlag;
/** This state is used for write */
uint8_t InternalState;
/** This state is used for write */
uint8_t SkipLockBlkFlag;
/** To store the UID */
uint8_t UID[PH_FRINFC_NDEFMAP_TOPAZ_UID_SIZE];
/** To CC bytes length */
uint8_t CCByteBuf[4];
/** Store the Buffer Index */
uint16_t Cur_RW_Index;
/* No of bytes read or write*/
uint16_t ByteRWFrmCard;
/* Cuurent Segment */
uint8_t CurrentSeg;
/** Store the read bytes */
uint8_t ReadBuffer[PH_FRINFC_NDEFMAP_TOPAZ_MAX_SIZE];
/** Size to know the exact data filled in the ReadBuffer. Useful, when the
offset = PH_FRINFC_NDEFMAP_SEEK_CUR */
uint8_t ReadBufferSize;
/** NDEF TLV byte address, This stores the byte address of
TYPE field of the TLV */
uint16_t NdefTLVByteAddress;
/** Expected sequence */
uint8_t ExpectedSeq;
/** Write sequence */
uint8_t WriteSeq;
/** Actual NDEF message size */
uint16_t ActualNDEFMsgSize;
/** NDEF Read Write size in the card, this excludes lock and reserved bytes,
mentioned in the LOCK and MEMORY control TLVs */
uint16_t NDEFRWSize;
/** Remaining read size in the card, after reading the card.
User has asked for the data less than " ActualNDEFMsgSize ",
then remaining read bytes are stored in this variable.
If the next read is with offset = PH_FRINFC_NDEFMAP_SEEK_CUR,
then this variable is used.
*/
uint16_t RemainingReadSize;
#ifdef FRINFC_READONLY_NDEF
uint8_t read_only_seq;
uint8_t lock_bytes_written;
#endif /* #ifdef FRINFC_READONLY_NDEF */
}phFriNfc_TopazCont_t;
#endif /* PH_FRINFC_MAP_TOPAZ_DISABLED */
/**
* \ingroup grp_fri_nfc_ndef_map
* \brief NFC NDEF Mapping Component Context Structure
*
* This structure is used to store the current context information of the instance.
*
*/
typedef struct phFriNfc_NdefMap
{
/**< \internal The state of the operation. */
uint8_t State;
/**< \internal Completion Routine Context. */
phFriNfc_CplRt_t CompletionRoutine[PH_FRINFC_NDEFMAP_CR];
/**< \internal Pointer to the lower (HAL) instance. */
void *LowerDevice;
/**<\internal Holds the device additional informations*/
phHal_sDepAdditionalInfo_t psDepAdditionalInfo;
/**<\internal Holds the completion routine informations of the Map Layer*/
phFriNfc_CplRt_t MapCompletionInfo;
/**< \internal Pointer to the Remote Device Information */
phHal_sRemoteDevInformation_t *psRemoteDevInfo;
/**<\internal Holds the Command Type(read/write)*/
phHal_uCmdList_t Cmd;
/**< \internal Pointer to a temporary buffer. Could be
used for read/write purposes */
uint8_t *ApduBuffer;
/**< \internal Size allocated to the ApduBuffer. */
uint32_t ApduBufferSize;
/**< \internal Index to the APDU Buffer. Used for internal calculations */
uint16_t ApduBuffIndex;
/**< \internal Pointer to the user-provided Data Size to be written trough WrNdef function. */
uint32_t *WrNdefPacketLength;
/**< \internal Holds the length of the received data. */
uint16_t *SendRecvLength;
/**<\internal Holds the ack of some intial commands*/
uint8_t *SendRecvBuf;
/**< \internal Holds the length of the data to be sent. */
uint16_t SendLength;
/**< \internal Data Byte Count, which gives the offset to the integration.*/
uint16_t *DataCount;
/**< \ internal Holds the previous operation on the card*/
uint8_t PrevOperation;
/**< \ internal Holds the previous state on the card*/
uint8_t PrevState;
/**< \internal Stores the type of the smart card. */
uint8_t CardType;
/**< \internal Stores the card state. */
uint8_t CardState;
/**< \internal Stores the memory size of the card */
uint16_t CardMemSize;
/**<\internal to Store the page offset on the mifare ul card*/
uint8_t Offset;
/** \internal specifies the desfire operation to be performed*/
uint8_t DespOpFlag;
/** \internal Used to remeber how many bytes were written, to update
the dataCount and the BufferIndex */
uint16_t NumOfBytesWritten;
/**\internal used to remember number of L byte Remaining to be written */
uint16_t NumOfLReminWrite;
/** \internal Pointer Used to remeber and return how many bytes were read,
to update the PacketDataLength in case of Read operation */
/* Fix for 0000238: [gk] MAP: Number of bytes actually read out is
not returned. */
uint32_t *NumOfBytesRead;
/** \internal Flag used to tell the process function that WRITE has
requested for an internal READ.*/
uint8_t ReadingForWriteOperation;
/** \internal Buffer of 5 bytes used for the write operation for the
Mifare UL card.*/
uint8_t BufferForWriteOp[5];
/** \internal Temporary Receive Length to update the Receive Length
when every time the Overlapped HAL is called. */
uint16_t TempReceiveLength;
uint8_t NoOfDevices ;
/** \internal stores operating mode type of the felica smart tag */
/* phHal_eOpModes_t OpModeType[2]; */
/** \internal stores the type of the TLV found */
uint8_t TLVFoundFlag;
/** \internal stores the TLV structure related informations */
phFriNfc_NDEFTLVCont_t TLVStruct;
/** \internal stores the Lock Contrl Tlv related informations */
phFriNfc_LockCntrlTLVCont_t LockTlv;
/** \internal stores the Mem Contrl Tlv related informations */
phFriNfc_ResMemCntrlTLVCont_t MemTlv;
/** Capabilitity Containers: */
#ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */
/** \internal Desfire capability Container Structure. */
#ifndef PH_FRINFC_MAP_DESFIRE_DISABLED
phFriNfc_DesfireCapCont_t DesfireCapContainer;
#endif /* PH_FRINFC_MAP_DESFIRE_DISABLED */
#ifndef PH_FRINFC_MAP_MIFARESTD_DISABLED
/** \internal Pointer to the Mifare Standard capability Container Structure. */
phFriNfc_MifareStdCont_t StdMifareContainer;
#endif /* PH_FRINFC_MAP_MIFARESTD_DISABLED */
#ifndef PH_FRINFC_MAP_FELICA_DISABLED
/** \internal Following are the Felica Smart tag related strucutre & variables */
phFriNfc_Felica_t Felica;
/** \internal Struture Stores the dev i/p , opmode informations of smart tag */
phFriNfc_Felica_PollDetails_t FelicaPollDetails;
/** \internal Struture Stores the different attribute informations of smart tag */
phFriNfc_Felica_AttrInfo_t FelicaAttrInfo;
/** \internal Struture Stores the PMm,IDm informations of smart tag */
phFriNfc_Felica_ManufDetails_t FelicaManufDetails;
#endif /* PH_FRINFC_MAP_FELICA_DISABLED */
#ifndef PH_FRINFC_MAP_MIFAREUL_DISABLED
/** \internal Mifare UL capability container structure. */
phFriNfc_MifareULCont_t MifareULContainer;
#endif /* PH_FRINFC_MAP_MIFAREUL_DISABLED */
#ifndef PH_FRINFC_MAP_TOPAZ_DISABLED
/** \internal Mifare UL capability container structure. */
phFriNfc_TopazCont_t TopazContainer;
#endif /* PH_FRINFC_MAP_TOPAZ_DISABLED */
#ifndef PH_FRINFC_MAP_ISO15693_DISABLED
phFriNfc_ISO15693Cont_t ISO15693Container;
#endif /* #ifndef PH_FRINFC_MAP_ISO15693_DISABLED */
#ifdef PHFRINFC_OVRHAL_MOCKUP
phFriNfc_MockupCont_t MochupContainer;
#endif /* PHFRINFC_OVRHAL_MOCKUP */
#endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */
} phFriNfc_NdefMap_t;
#ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */
/**
* \ingroup grp_fri_nfc_ndef_map
*
* \brief Ndef Mapping \b Reset function
*
* \copydoc page_reg Resets the component instance to the initial state and initialises the
* internal variables.
*
* \param[in] NdefMap is a Pointer to a valid and initialised or uninitialised instance
* of \ref phFriNfc_NdefMap_t .
* \param[in] LowerDevice Overlapped HAL reference, pointing at a valid instance of this
* underlying component.
* \param[in] psRemoteDevInfo Points to the Remote Device Information structure encapsulating
* the information about the device (Smart card, NFC device) to access.
* \param[in] psDevInputParam The Device input parameter, as used for the HAL POLL function.
* This parameter is needed by the component in special cases, when an internal call
* to POLL is required again, such as for FeliCa. The storage of the structure behind
* the pointer must be retained by the calling software. The component itself only
* keeps the reference. No change is applied to the structure's content.
* \param[in] TrxBuffer Pointer to an internally used buffer. The buffer has to be allocated by
* the integrating software (not done by the component). The purpose of
* this storage is to serve as an intermediate buffer for data frame
* composition and analysis.
* The size shall be at least \ref PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE .
* \param[in] TrxBufferSize The size of TrxBuffer:
* The size shall be at least \ref PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE .
* \param[in] ReceiveBuffer Pointer to a buffer that the component uses internally use to
* store the data received from the lower component.
* The size shall be at least \ref PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE .
* \param[in] ReceiveLength The size of ReceiveBuffer. This specifies the actual length
* of the data received from the lower component.
* The size shall be at least \ref PH_FRINFC_NDEFMAP_MAX_SEND_RECV_BUF_SIZE .
* \param[in] DataCount Specifies the offset count during read/write operations. This can be
* used by the integrating software to know about the total number of bytes read/written
* from/to the card. The caller shall set the value behind the pointer to zero
* before calling this function.
*
* \retval NFCSTATUS_SUCCESS Operation successful.
* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid.
*
* \note The DataCount variable is internally updated by the module and must not be changed by the
* embedding software.
* \note This function has to be called at the beginning, after creating an instance of
* \ref phFriNfc_NdefMap_t . Use this function to reset the instance and/or to switch
* to a different underlying device (different NFC device or device mode).
*/
NFCSTATUS phFriNfc_NdefMap_Reset(phFriNfc_NdefMap_t *NdefMap,
void *LowerDevice,
phHal_sRemoteDevInformation_t *psRemoteDevInfo,
phHal_sDevInputParam_t *psDevInputParam,
uint8_t *TrxBuffer,
uint16_t TrxBufferSize,
uint8_t *ReceiveBuffer,
uint16_t *ReceiveLength,
uint16_t *DataCount);
/**
* \ingroup grp_fri_nfc_ndef_map
*
* \brief Ndef Mapping \b Set \b Completion \b Routine function
*
* \copydoc page_reg Setting of the Completion Routine.
*
* This function sets the Completion Routine for the specified function ID:\n
* The completion routine is a function of an upper layer in the stack that needs to be notified
* when the current instance has completed an I/O operation and data and/or an I/O status value
* is available. The list of valid function IDs can be found under the section
* "Completion Routine Indices", like e.g. \ref PH_FRINFC_NDEFMAP_CR_CHK_NDEF.
*
* \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure
* serving as the component context.
* \param[in] FunctionID ID of the component API function to set a with a completion routine for.
* A valid routine has to be assigned for each function ID.
* Use the "Completion Routine Indices", such as \ref PH_FRINFC_NDEFMAP_CR_CHK_NDEF .
* \param[in] CompletionRoutine Pointer to a completion routine (part of a component of the upper layer)
* to be called when the non-blocking opertaion has finished.
* \param[in] CompletionRoutineContext Pointer to the context of the (upper) component where the
* particular completion routine is located.
*
* \retval NFCSTATUS_SUCCESS Operation successful.
* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid.
*
* \note This function has to be called after \ref phFriNfc_NdefMap_Reset .
*/
NFCSTATUS phFriNfc_NdefMap_SetCompletionRoutine(phFriNfc_NdefMap_t *NdefMap,
uint8_t FunctionID,
pphFriNfc_Cr_t CompletionRoutine,
void *CompletionRoutineContext);
/**
* \ingroup grp_fri_nfc_ndef_map
*
* \brief Ndef Mapping \b Read \b Ndef function
*
* \copydoc page_ovr Initiates Reading of NDEF information from the Remote Device.
*
* The function initiates the reading of NDEF information from a Remote Device.
* It performs a reset of the state and restarts the state machine.
*
* \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t
* component context structure.
* \param[in,out] PacketData Pointer to a location that shall receive the NDEF Packet.
* \param[in,out] PacketDataLength Pointer to a variable that shall receive the length of the NDEF packet.
* The caller has to provide the maximum length, the function fills
* in the actual number of bytes received.
* \param[in] Offset Indicates whether the read operation shall start from the begining of the
* file/card storage \b or continue from the last offset. The last Offset set is stored
* within a context (Data Count) variable (must not be modified by the integration).
* If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall
* start reading from the last offset set (continue where it has stopped before).
* If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start reading
* from the begining of the card (restarted)
*
* \retval NFCSTATUS_PENDING The action has been successfully triggered.
* \retval NFCSTATUS_SUCCESS Operation Successful.
*
* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid.
* \retval NFCSTATUS_INVALID_REMOTE_DEVICE Card Type is unsupported.
* \retval NFCSTATUS_EOF_CARD_REACHED No Space in the File to read.
* \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected
* meanwhile.
* \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request.
* \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small.
* \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period.
*
*/
NFCSTATUS phFriNfc_NdefMap_RdNdef(phFriNfc_NdefMap_t *NdefMap,
uint8_t *PacketData,
uint32_t *PacketDataLength,
uint8_t Offset);
/**
* \ingroup grp_fri_nfc_ndef_map
*
* \brief Ndef Mapping \b Check \b Ndef function
*
* \copydoc page_ovr Initiates Writing of NDEF information to the Remote Device.
*
* The function initiates the writing of NDEF information to a Remote Device.
* It performs a reset of the state and starts the action (state machine).
* A periodic call of the \ref phFriNfc_NdefMap_Process has to be done once the action
* has been triggered.
*
* \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t
* component context structure.
* \param[in] PacketData Pointer to a location that holds the prepared NDEF Packet.
* \param[in,out] PacketDataLength Pointer to a variable that shall specify the length of the prepared NDEF packet.
* The caller has to provide the length, the function fills
* in the actual number of bytes received.
* \param[in] Offset Indicates whether the write operation shall start from the begining of the
* file/card storage \b or continue from the last offset. The last Offset set is stored
* within a context (Data Count) variable (must not be modified by the integration).
* If the caller sets the value to \ref PH_FRINFC_NDEFMAP_SEEK_CUR, the component shall
* start writing from the last offset set (continue where it has stopped before).
* If set to \ref PH_FRINFC_NDEFMAP_SEEK_BEGIN, the component shall start writing
* from the begining of the card (restarted)
*
* \retval NFCSTATUS_PENDING The action has been successfully triggered.
* \retval NFCSTATUS_SUCCESS Operation Successful.
*
* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid.
* \retval NFCSTATUS_INVALID_REMOTE_DEVICE Card Type is unsupported.
* \retval NFCSTATUS_EOF_CARD_REACHED No Space in the File to write.
* \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected
* meanwhile.
* \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request.
* \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small.
* \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period.
*
*/
extern NFCSTATUS phFriNfc_NdefMap_WrNdef(phFriNfc_NdefMap_t *NdefMap,
uint8_t *PacketData,
uint32_t *PacketDataLength,
uint8_t Offset);
/**
* \ingroup grp_fri_nfc_ndef_map
*
* \brief Ndef Mapping \b Check \b NDEF function
*
* \copydoc page_ovr Check whether a particular Remote Device is NDEF compliant.
*
* \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t
* component context structure.
*
* \retval NFCSTATUS_PENDING The action has been successfully triggered.
* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid.
* \retval NFCSTATUS_INVALID_REMOTE_DEVICE Card Type is unsupported.
* \retval NFCSTATUS_INVALID_PARAMETER Completion Routine is NULL.
* \retval NFCSTATUS_INVALID_REMOTE_DEVICE OpModes invalid.
* \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected
* meanwhile.
* \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request.
* \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small.
* \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period.
*
*/
NFCSTATUS phFriNfc_NdefMap_ChkNdef(phFriNfc_NdefMap_t *NdefMap);
#ifdef FRINFC_READONLY_NDEF
/*!
* \ingroup grp_fri_smart_card_formatting
*
* \brief Initiates the conversion of the already NDEF formatted tag to READ ONLY.
*
* \copydoc page_ovr The function initiates the conversion of the already NDEF formatted
* tag to READ ONLY.After this formation, remote card would be properly Ndef Compliant and READ ONLY.
* Depending upon the different card type, this function handles formatting procedure.
* This function supports only for the TOPAZ tags.
*
* \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t structure describing
* the component context.
* \retval NFCSTATUS_PENDING The action has been successfully triggered.
* \retval Other values An error has occurred.
*
*/
NFCSTATUS
phFriNfc_NdefMap_ConvertToReadOnly (
phFriNfc_NdefMap_t *NdefMap);
#endif /* #ifdef FRINFC_READONLY_NDEF */
/**
* \ingroup grp_fri_nfc_ndef_map
*
* \brief Ndef Mapping \b Erase \b NDEF function
*
* \copydoc page_ovr find the position of the existing NDEF TLV and overwrite with \b empty NDEF
* message \b at that position.
*
* \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t
* component context structure.
*
* \retval NFCSTATUS_PENDING The action has been successfully triggered.
* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid.
* \retval NFCSTATUS_INVALID_REMOTE_DEVICE Card Type is unsupported.
* \retval NFCSTATUS_INVALID_PARAMETER Completion Routine is NULL.
* \retval NFCSTATUS_INVALID_REMOTE_DEVICE OpModes invalid.
* \retval NFCSTATUS_INVALID_DEVICE The device has not been opened or has been disconnected
* meanwhile.
* \retval NFCSTATUS_CMD_ABORTED The caller/driver has aborted the request.
* \retval NFCSTATUS_BUFFER_TOO_SMALL The buffer provided by the caller is too small.
* \retval NFCSTATUS_RF_TIMEOUT No data has been received within the TIMEOUT period.
*
*/
NFCSTATUS phFriNfc_NdefMap_EraseNdef(phFriNfc_NdefMap_t *NdefMap);
/**
* \ingroup grp_fri_nfc_ndef_map
*
* \brief Ndef Mapping \b Get Container size function
*
* \copydoc page_ovr Returns the size of the NDEF data that the card can hold to the caller.
*
* \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t
* component context structure.
*
* \param[out] size Pointer to a uint32_t variable, which receives the size of the NDEF data
*
* \retval NFCSTATUS_SUCCESS The size has been successfully calculated.
* \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid.
* \retval NFCSTATUS_INVALID_REMOTE_DEVICE Card Type is unsupported.
*
*/
NFCSTATUS phFriNfc_NdefMap_GetContainerSize(const phFriNfc_NdefMap_t *NdefMap,uint32_t *maxSize, uint32_t *actualSize);
/**
* \ingroup grp_fri_nfc_ndef_map
*
* \brief Ndef Mapping \b Completion \b Routine or \b Process function
*
* \copydoc page_cb Completion Routine: This function is called by the lower layer (OVR HAL)
* when an I/O operation has finished. The internal state machine decides
* whether to call into the lower device again or to complete the process
* by calling into the upper layer's completion routine, stored within this
* component's context (\ref phFriNfc_NdefMap_t).
*
* The function call scheme is according to \ref grp_interact. No State reset is performed during
* operation.
*
* \param[in] Context The context of the current (not the lower/upper) instance, as set by the lower,
* calling layer, upon its completion.
* \param[in] Status The completion status of the lower layer (to be handled by the implementation of
* the state machine of this function like a regular return value of an internally
* called function).
*
* \note For general information about the completion routine interface please see \ref pphFriNfc_Cr_t . * The Different Status Values are as follows
*
*/
void phFriNfc_NdefMap_Process(void *Context,
NFCSTATUS Status);
/**
* \ingroup grp_fri_nfc_ndef_map
*
* \brief Ndef Mapping \b Check And Parse TLV Structure \b NDEF function
*
* \copydoc page_ovr Checks the presence of a valid TLV's(NDEF/Propritery).
*
* \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t
* component context structure.
*
* \retval NFCSTATUS_INVALID_FORMAT No valid TLV Found.
* \retval NFCSTATUS_SUCCESS Operation Successful.
*
*/
NFCSTATUS phFriNfc_ChkAndParseTLV(phFriNfc_NdefMap_t *NdefMap);
#ifdef PHFRINFC_OVRHAL_MOCKUP /* */
/**
* \ingroup grp_fri_nfc_ndef_map
*
* \brief Set data NDEF in mockup mode
*
* \param[in] NdefMap Pointer to a valid instance of the \ref phFriNfc_NdefMap_t component context structure.
* \param[in] NdefData Pointer to card mockup data
* \param[in] NdefActualSize The actual data length
* \param[in] NdefMaxSize The max data length
* \param[in] NdefCardSize The total card size
*
* \retval NFCSTATUS_SUCCESS The operation is ok.
*
*/
NFCSTATUS phFriNfc_NdefMap_MockupCardSetter(phFriNfc_NdefMap_t *NdefMap, uint8_t *NdefData, uint32_t NdefActualSize, uint32_t NdefMaxSize, uint32_t CardSize);
NFCSTATUS phFriNfc_NdefMap_MockupNDefModeEn(uint8_t *pNdefCompliancy, uint8_t *pCardType, uint8_t Enable);
#endif /*#ifndef PH_FRINFC_MAP_MOCKUP_DISABLED*/
/**
* \internal
* \name States of the FSM.
*
*/
/*@{*/
#define PH_FRINFC_NDEFMAP_STATE_RESET_INIT 0 /**< \internal Initial state */
#define PH_FRINFC_NDEFMAP_STATE_CR_REGISTERED 1 /**< \internal CR has been registered */
#define PH_FRINFC_NDEFMAP_STATE_EOF_CARD 2 /**< \internal EOF card reached */
/*@}*/
/* Following values specify the previous operation on the card. This value is assigned to
the context structure variable: PrevOperation. */
/**< Previous operation is check*/
#define PH_FRINFC_NDEFMAP_CHECK_OPE 1
/**< Previous operation is read*/
#define PH_FRINFC_NDEFMAP_READ_OPE 2
/**< Previous operation is write */
#define PH_FRINFC_NDEFMAP_WRITE_OPE 3
/**< Previous operation is Actual size */
#define PH_FRINFC_NDEFMAP_GET_ACTSIZE_OPE 4
/* This flag is set when there is a need of write operation on the odd positions
ex: 35,5 etc. This is used with MfUlOp Flag */
#define PH_FRINFC_MFUL_INTERNAL_READ 3 /**< \internal Read/Write control*/
#endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */
#endif /* PHFRINFC_NDEFMAP_H */
|