Nick Pelly | 5d9927b | 2010-09-23 12:47:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 NXP Semiconductors |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /** |
| 18 | * \file phFriNfc_NdefReg.h |
| 19 | * \brief NFC Ndef Registration / Listening. |
| 20 | * |
| 21 | * Project: NFC-FRI |
| 22 | * |
| 23 | * $Date: Fri Oct 5 10:10:07 2007 $ |
| 24 | * $Author: frq05303 $ |
| 25 | * $Revision: 1.1 $ |
| 26 | * $Aliases: NFC_FRI1.1_WK826_PREP1,NFC_FRI1.1_WK826_R1,NFC_FRI1.1_WK826_R2,NFC_FRI1.1_WK830_PREP1,NFC_FRI1.1_WK830_PREP2,NFC_FRI1.1_WK830_R5_1,NFC_FRI1.1_WK830_R5_2,NFC_FRI1.1_WK830_R5_3,NFC_FRI1.1_WK832_PREP1,NFC_FRI1.1_WK832_PRE2,NFC_FRI1.1_WK832_PREP2,NFC_FRI1.1_WK832_PREP3,NFC_FRI1.1_WK832_R5_1,NFC_FRI1.1_WK832_R6_1,NFC_FRI1.1_WK834_PREP1,NFC_FRI1.1_WK834_PREP2,NFC_FRI1.1_WK834_R7_1,NFC_FRI1.1_WK836_PREP1,NFC_FRI1.1_WK836_R8_1,NFC_FRI1.1_WK838_PREP1,NFC_FRI1.1_WK838_R9_PREP2,NFC_FRI1.1_WK838_R9_1,NFC_FRI1.1_WK840_R10_PREP1,NFC_FRI1.1_WK840_R10_1,NFC_FRI1.1_WK842_R11_PREP1,NFC_FRI1.1_WK842_R11_PREP2,NFC_FRI1.1_WK842_R11_1,NFC_FRI1.1_WK844_PREP1,NFC_FRI1.1_WK844_R12_1,NFC_FRI1.1_WK846_PREP1,NFC_FRI1.1_WK846_R13_1,NFC_FRI1.1_WK848_PREP1,NFC_FRI1.1_WK848_R14_1,NFC_FRI1.1_WK850_PACK1,NFC_FRI1.1_WK851_PREP1,NFC_FRI1.1_WK850_R15_1,NFC_FRI1.1_WK902_PREP1,NFC_FRI1.1_WK902_R16_1,NFC_FRI1.1_WK904_PREP1,NFC_FRI1.1_WK904_R17_1,NFC_FRI1.1_WK906_R18_1,NFC_FRI1.1_WK908_PREP1,NFC_FRI1.1_WK908_R19_1,NFC_FRI1.1_WK910_PREP1,NFC_FRI1.1_WK910_R20_1,NFC_FRI1.1_WK912_PREP1,NFC_FRI1.1_WK912_R21_1,NFC_FRI1.1_WK914_PREP1,NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $ |
| 27 | * |
| 28 | */ |
| 29 | |
| 30 | #ifndef PHFRINFC_NDEFREG_H |
| 31 | #define PHFRINFC_NDEFREG_H |
| 32 | |
| 33 | #ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */ |
| 34 | |
| 35 | /** |
| 36 | * \name NDEF Registry and Listening |
| 37 | * |
| 38 | */ |
| 39 | /*@{*/ |
| 40 | #define PH_FRINFC_NDEFREG_FILEREVISION "$Revision: 1.1 $" /** \ingroup grp_file_attributes */ |
| 41 | #define PH_FRINFC_NDEFREG_FILEALIASES "$Aliases: NFC_FRI1.1_WK826_PREP1,NFC_FRI1.1_WK826_R1,NFC_FRI1.1_WK826_R2,NFC_FRI1.1_WK830_PREP1,NFC_FRI1.1_WK830_PREP2,NFC_FRI1.1_WK830_R5_1,NFC_FRI1.1_WK830_R5_2,NFC_FRI1.1_WK830_R5_3,NFC_FRI1.1_WK832_PREP1,NFC_FRI1.1_WK832_PRE2,NFC_FRI1.1_WK832_PREP2,NFC_FRI1.1_WK832_PREP3,NFC_FRI1.1_WK832_R5_1,NFC_FRI1.1_WK832_R6_1,NFC_FRI1.1_WK834_PREP1,NFC_FRI1.1_WK834_PREP2,NFC_FRI1.1_WK834_R7_1,NFC_FRI1.1_WK836_PREP1,NFC_FRI1.1_WK836_R8_1,NFC_FRI1.1_WK838_PREP1,NFC_FRI1.1_WK838_R9_PREP2,NFC_FRI1.1_WK838_R9_1,NFC_FRI1.1_WK840_R10_PREP1,NFC_FRI1.1_WK840_R10_1,NFC_FRI1.1_WK842_R11_PREP1,NFC_FRI1.1_WK842_R11_PREP2,NFC_FRI1.1_WK842_R11_1,NFC_FRI1.1_WK844_PREP1,NFC_FRI1.1_WK844_R12_1,NFC_FRI1.1_WK846_PREP1,NFC_FRI1.1_WK846_R13_1,NFC_FRI1.1_WK848_PREP1,NFC_FRI1.1_WK848_R14_1,NFC_FRI1.1_WK850_PACK1,NFC_FRI1.1_WK851_PREP1,NFC_FRI1.1_WK850_R15_1,NFC_FRI1.1_WK902_PREP1,NFC_FRI1.1_WK902_R16_1,NFC_FRI1.1_WK904_PREP1,NFC_FRI1.1_WK904_R17_1,NFC_FRI1.1_WK906_R18_1,NFC_FRI1.1_WK908_PREP1,NFC_FRI1.1_WK908_R19_1,NFC_FRI1.1_WK910_PREP1,NFC_FRI1.1_WK910_R20_1,NFC_FRI1.1_WK912_PREP1,NFC_FRI1.1_WK912_R21_1,NFC_FRI1.1_WK914_PREP1,NFC_FRI1.1_WK914_R22_1,NFC_FRI1.1_WK914_R22_2,NFC_FRI1.1_WK916_R23_1,NFC_FRI1.1_WK918_R24_1,NFC_FRI1.1_WK920_PREP1,NFC_FRI1.1_WK920_R25_1,NFC_FRI1.1_WK922_PREP1,NFC_FRI1.1_WK922_R26_1,NFC_FRI1.1_WK924_PREP1,NFC_FRI1.1_WK924_R27_1,NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $" /** \ingroup grp_file_attributes */ |
| 42 | /*@}*/ |
| 43 | #include <phFriNfc_NdefRecord.h> |
| 44 | |
| 45 | #endif /* Exclude from test fw */ |
| 46 | |
| 47 | /* |
| 48 | * NDEF Registration And Listening - States of the Finite State machine |
| 49 | * |
| 50 | */ |
| 51 | #define PH_FRINFC_NDEFREG_STATE_INIT 0 /**< \internal Init state. The start-up state */ |
| 52 | #define PH_FRINFC_NDEFREG_STATE_DIS_PKT 1 /**< \internal Dispatch Packet is in progress */ |
| 53 | #define PH_FRINFC_NDEFREG_STATE_DIS_RCD 2 /**< \internal Dispatch Record is in progress */ |
| 54 | |
| 55 | /* |
| 56 | * NDEF Registration And Listening internal definitions |
| 57 | */ |
| 58 | #define PH_FRINFC_NDEFRECORD_TNF_MASK 0x07 /**< \internal */ |
| 59 | #define PH_FRINFC_NDEFREG_CH_FLG_ARR_INDEX 50 /**< \internal */ |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | /** \defgroup grp_fri_nfc_ndef_reg NDEF Registry |
| 65 | * |
| 66 | * This component implements the NDEF Registration and Listening functionality. |
| 67 | */ |
| 68 | /*@{*/ |
| 69 | |
| 70 | /* |
| 71 | * \name NDEF Registration And Listening callback and node definitions |
| 72 | * |
| 73 | * \ref PH_FRINFC_NDEFREG_MAX_RTD_REGISTERED is the maximum number of RTDs |
| 74 | * that can be registered in a node.\n |
| 75 | * \ref PH_FRINFC_NDEFREG_MAX_RTD is the maximum number of Records that can |
| 76 | * be present in a single callback function. |
| 77 | */ |
| 78 | /*@{*/ |
| 79 | #define PH_FRINFC_NDEFREG_MAX_RTD_REGISTERED 64 /**< Maximum number of RTDs per node */ |
| 80 | #define PH_FRINFC_NDEFREG_MAX_RTD 8 /**< Maximum number of RTDs per callback function. */ |
| 81 | /*@}*/ |
| 82 | |
| 83 | /** |
| 84 | * \brief NDEF Callback |
| 85 | * |
| 86 | * \copydoc page_reg |
| 87 | * |
| 88 | * Upon reception of a NDEF record the component calls into the function registered as a listener |
| 89 | * for a NDEF type. The function must be compatible to the declaration of the pointer described in |
| 90 | * this section. |
| 91 | * |
| 92 | * \par Parameter |
| 93 | * The underlying type of the callback parameter (void pointer) is \ref phFriNfc_NdefReg_CbParam_t . |
| 94 | * |
| 95 | * \note On systems, requiring non-blocking operation, the user-defined callback function must not block, |
| 96 | * but just deliver the data and return immediately. In this case the CB must make a copy of the |
| 97 | * parameter structure (\ref phFriNfc_NdefReg_CbParam_t) and store it within the environment of the |
| 98 | * registered listener. A copy is needed because once the CB returns the values behind the parameter |
| 99 | * pointer become invalid. We observe the following rules: |
| 100 | * - This component does not rely on lower layers (e.g. HAL), therefore it doesn't need to handle |
| 101 | * completion routines. |
| 102 | * - This library gets a NDEF message and extracts the records using the NDEF Record (Tools) Library. |
| 103 | * - Alternatively, this component can process pre-extracted NDEF records. |
| 104 | * - This library only handles TOP level records, cascaded content is ignored. |
| 105 | * - Functions do not block: The \ref phFriNfc_NdefReg_Process "Process" function needs to be called |
| 106 | * periodically until completion. |
| 107 | * . |
| 108 | */ |
| 109 | typedef void(*pphFriNfc_NdefReg_Cb_t)(void*); |
| 110 | |
| 111 | |
| 112 | /** |
| 113 | * \brief Callback Parameter. This parameter is provided to the CB function that serves |
| 114 | * as the notifier for services/applicatioon/software components registered for a specific |
| 115 | * NDEF Type. |
| 116 | * |
| 117 | * All information required to perform the \ref pphFriNfc_Cr_t "callback" operation is contained |
| 118 | * within the structure. The members of the structure may only be read, changing them is not allowed. |
| 119 | * |
| 120 | * |
| 121 | */ |
| 122 | typedef struct phFriNfc_NdefReg_CbParam |
| 123 | { |
| 124 | /** |
| 125 | * Number of array Positions. Each array position carries data from a NDEF Record. The maximum |
| 126 | * number is \ref PH_FRINFC_NDEFREG_MAX_RTD . |
| 127 | */ |
| 128 | uint8_t Count; |
| 129 | |
| 130 | /** |
| 131 | * The records that matched with the registred RTDs for this callback. |
| 132 | * The number of records here will be equal to the first parameter Count. |
| 133 | */ |
| 134 | phFriNfc_NdefRecord_t Records[PH_FRINFC_NDEFREG_MAX_RTD]; |
| 135 | |
| 136 | /** Indicates whether a record is chunked or not. */ |
| 137 | uint8_t Chunked[PH_FRINFC_NDEFREG_MAX_RTD]; |
| 138 | |
| 139 | /** Pointer to the raw record. */ |
| 140 | uint8_t *RawRecord[PH_FRINFC_NDEFREG_MAX_RTD]; |
| 141 | |
| 142 | /** Size of the raw record */ |
| 143 | uint32_t RawRecordSize[PH_FRINFC_NDEFREG_MAX_RTD]; |
| 144 | |
| 145 | /** Pointer for usage by the registering entity. The software component that registers for |
| 146 | a specific RTD can specify this \b context pointer. With the help of the pointer |
| 147 | the component is able to resolve its own address, context or object, respectively.\n |
| 148 | \b Example: \ref grp_fri_nfc_ndef_reg "This SW component" is embedded into a C++ system |
| 149 | that has one object registered for a certain RTD. \ref grp_fri_nfc_ndef_reg "This library" |
| 150 | itself is written in C and therefore it requires a pure "C" callback that can be provided by |
| 151 | C++ through a \b static member function. The registering C++ object will consequently set the |
| 152 | \ref phFriNfc_NdefReg_CbParam_t::CbContext pointer to its \c this pointer. When the static |
| 153 | member function of the C++ class is called it immediately knows the instance and can |
| 154 | call into one of the C++ instance members again (\ref phFriNfc_NdefReg_CbParam_t::CbContext |
| 155 | needs to be casted back to the original C++ class type). |
| 156 | */ |
| 157 | void *CbContext; |
| 158 | } phFriNfc_NdefReg_CbParam_t; |
| 159 | |
| 160 | |
| 161 | |
| 162 | /** |
| 163 | * \brief Registration of a Callback - Parameter Structure |
| 164 | * |
| 165 | * This structure is used by the registering software. The registering listener has to \b initialise |
| 166 | * \b all \b members of the structure that are \b not \b internal. Members for \b internal use \b must |
| 167 | * \b not be set by the registering entity. Used by \ref phFriNfc_NdefReg_CbParam_t . |
| 168 | * |
| 169 | */ |
| 170 | typedef struct phFriNfc_NdefReg_Cb |
| 171 | { |
| 172 | /** |
| 173 | * Number of array Positions. Each array position carries data specifying a RTD. The maximum number |
| 174 | * is \ref PH_FRINFC_NDEFREG_MAX_RTD . |
| 175 | * |
| 176 | * \li Needs to be set by the registering entity. |
| 177 | */ |
| 178 | uint8_t NumberOfRTDs; |
| 179 | /** |
| 180 | * The Type Name Format, according to the NDEF specification, see the NDEF Record (Tools) component. |
| 181 | * |
| 182 | * \li Needs to be set by the registering entity. |
| 183 | */ |
| 184 | uint8_t Tnf[PH_FRINFC_NDEFREG_MAX_RTD_REGISTERED]; |
| 185 | |
| 186 | /** |
| 187 | * Array of pointers to the individual RTD buffers. |
| 188 | * |
| 189 | * \li Needs to be set by the registering entity. |
| 190 | */ |
| 191 | uint8_t *NdefType[PH_FRINFC_NDEFREG_MAX_RTD_REGISTERED]; |
| 192 | |
| 193 | /** |
| 194 | * Array of length indicators of the RTD buffers. |
| 195 | * |
| 196 | * \li Needs to be set by the registering entity. |
| 197 | */ |
| 198 | uint8_t NdeftypeLength[PH_FRINFC_NDEFREG_MAX_RTD_REGISTERED]; |
| 199 | |
| 200 | /** |
| 201 | * Function pointer to the C-style function within the registering entity. |
| 202 | * |
| 203 | * \li Needs to be set by the registering entity. |
| 204 | */ |
| 205 | pphFriNfc_NdefReg_Cb_t NdefCallback; |
| 206 | |
| 207 | /** |
| 208 | * Context pointer of the registering entity (see \ref phFriNfc_NdefReg_CbParam_t). |
| 209 | * |
| 210 | * \li Needs to be set by the registering entity. |
| 211 | */ |
| 212 | void *CbContext; |
| 213 | |
| 214 | /** \internal |
| 215 | * This member is required by the library to link to the previous registered item. In case of the |
| 216 | * first item this member is NULL. |
| 217 | */ |
| 218 | struct phFriNfc_NdefReg_Cb *Previous; |
| 219 | /** \internal |
| 220 | * This member is required by the library to link to the next registered item. In case of the |
| 221 | * last item this member is NULL. |
| 222 | */ |
| 223 | struct phFriNfc_NdefReg_Cb *Next; |
| 224 | } phFriNfc_NdefReg_Cb_t; |
| 225 | |
| 226 | |
| 227 | /** |
| 228 | * \brief NFC NDEF Registry Compound |
| 229 | * |
| 230 | * The NDEF Registry Compound. This is the context structure of the NDEF Registry and |
| 231 | * Listener. |
| 232 | * |
| 233 | */ |
| 234 | typedef struct phFriNfc_NdefReg |
| 235 | { |
| 236 | phFriNfc_NdefReg_Cb_t *NdefTypeList; /**< \internal List of Callback Structures (Listeners). */ |
| 237 | uint8_t *NdefData; /**< \internal Data to process. */ |
| 238 | uint32_t NdefDataLength; /**< \internal Length of the NDEF data. */ |
| 239 | uint8_t State; /**< \internal The state of the library. */ |
| 240 | uint8_t **NdefTypes; /**< \internal */ |
| 241 | |
| 242 | phFriNfc_NdefRecord_t *RecordsExtracted; /**< \internal */ |
| 243 | |
| 244 | phFriNfc_NdefReg_CbParam_t *CbParam; /**< \internal */ |
| 245 | |
| 246 | /* Harsha: Fix for 0000252: [JF] Buffer overshoot in phFriNfc_NdefRecord_GetRecords */ |
| 247 | uint8_t *IsChunked; /**< \internal Array of chunked flags */ |
| 248 | |
| 249 | /* Harsha: Fix for 0000252: [JF] Buffer overshoot |
| 250 | in phFriNfc_NdefRecord_GetRecords */ |
| 251 | uint32_t NumberOfRecords; /**< \internal Space available in NdefTypes |
| 252 | and IsChunked arrays */ |
| 253 | |
| 254 | /* Harsha: Fix for 0000243: [JF] phFriNfc_NdefReg_Process |
| 255 | won't parse correctly chunked records */ |
| 256 | /* Used to remember the last valid TNF */ |
| 257 | uint8_t validPreviousTnf; /**< \internal The last valid TNF that we had. */ |
| 258 | |
| 259 | uint32_t NumberOfNdefTypes;/**< \internal */ |
| 260 | |
| 261 | uint32_t RecordIndex; /**< \internal */ |
| 262 | |
| 263 | uint32_t RtdIndex; /**< \internal */ |
| 264 | |
| 265 | /* This flag is used to remember whether we have found a |
| 266 | TNF which matches with the Registered RTD */ |
| 267 | uint8_t MainTnfFound; /**< \internal */ |
| 268 | |
| 269 | /* This flag is used to tell whether the present record |
| 270 | being processed is newly extracted */ |
| 271 | uint8_t newRecordextracted;/**< \internal */ |
| 272 | |
| 273 | }phFriNfc_NdefReg_t; |
| 274 | |
| 275 | |
| 276 | #ifndef PH_FRINFC_EXCLUDE_FROM_TESTFW /* */ |
| 277 | |
| 278 | /** |
| 279 | * \brief Ndef Registry \b Reset function |
| 280 | * |
| 281 | * \copydoc page_reg |
| 282 | * |
| 283 | * Resets the component instance to the initial state and lets the component forget about |
| 284 | * the list of registered items. Does basic initialisation. |
| 285 | * |
| 286 | * \param[in] NdefReg Pointer to a valid or uninitialised instance of \ref phFriNfc_NdefReg_t . |
| 287 | * |
| 288 | * \param[in] NdefTypesarray Array of pointers to individual NDEF Types. Later used to store |
| 289 | * the NdefTypes |
| 290 | * |
| 291 | * \param[in] RecordsExtracted Pointer to an uninitialised instance of the NDEF Record structure |
| 292 | * that is later used to retrieve the record information. |
| 293 | * |
| 294 | * \param[in] CbParam Pointer to an un-initialised instance of \ref phFriNfc_NdefReg_CbParam_t |
| 295 | * structure, which is later used to store the callback parameters. |
| 296 | * |
| 297 | * \param[in] ChunkedRecordsarray Pointer to an array of bytes. Later used to store the |
| 298 | * Chunked record flags. |
| 299 | * |
| 300 | * \param[in] NumberOfRecords The number of members in the arrays NdefTypesarray and ChunkedRecordsarray. |
| 301 | * |
| 302 | * \retval NFCSTATUS_SUCCESS The operation has been successful. |
| 303 | * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. |
| 304 | * |
| 305 | * \note This function has to be called at the beginning, after creating an instance of |
| 306 | * \ref phFriNfc_NdefReg_t . |
| 307 | */ |
| 308 | NFCSTATUS phFriNfc_NdefReg_Reset(phFriNfc_NdefReg_t *NdefReg, |
| 309 | uint8_t **NdefTypesarray, |
| 310 | phFriNfc_NdefRecord_t *RecordsExtracted, |
| 311 | phFriNfc_NdefReg_CbParam_t *CbParam, |
| 312 | uint8_t *ChunkedRecordsarray, |
| 313 | uint32_t NumberOfRecords); |
| 314 | |
| 315 | |
| 316 | /** |
| 317 | * \brief Ndef Registry \b Add \b Callback function |
| 318 | * |
| 319 | * \copydoc page_reg |
| 320 | * |
| 321 | * Adds an NDEF type listener to the (internal) list of listeners: |
| 322 | * The registering caller or embedding SW must create an instance of \ref phFriNfc_NdefReg_Cb_t and |
| 323 | * hand the reference over to this function. The library does no allocation of memory. |
| 324 | * |
| 325 | * \param[in] NdefReg Pointer to an initialised instance of \ref phFriNfc_NdefReg_t that holds the |
| 326 | * context of the current component instance. |
| 327 | * |
| 328 | * \param[in] NdefCb Pointer to a caller-initialised structure describing the context of a Listener |
| 329 | * that requests its registration. |
| 330 | * |
| 331 | * \retval NFCSTATUS_SUCCESS The operation has been successful. |
| 332 | * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function |
| 333 | * is invalid. or Number of RTDs in NdefCb |
| 334 | * Structure is greater than |
| 335 | * PH_FRINFC_NDEFREG_MAX_RTD_REGISTERED |
| 336 | * |
| 337 | * \note This function returns once the listener is registered successfully or an error occurs. |
| 338 | */ |
| 339 | NFCSTATUS phFriNfc_NdefReg_AddCb(phFriNfc_NdefReg_t *NdefReg, |
| 340 | phFriNfc_NdefReg_Cb_t *NdefCb); |
| 341 | |
| 342 | |
| 343 | /** |
| 344 | * \brief NDEF Registry \b Remove \b Callback function |
| 345 | * |
| 346 | * \copydoc page_reg |
| 347 | * |
| 348 | * Removes a specific listener from the list: The element to remove is specified by its address. |
| 349 | * As the library does no de-allocation the caller of this function needs to take care of the |
| 350 | * correct disposal of the removed \ref phFriNfc_NdefReg_Cb_t instance once this function returns |
| 351 | * successfully. |
| 352 | * |
| 353 | * \param[in] NdefReg Pointer to an initialised instance of \ref phFriNfc_NdefReg_t that holds the |
| 354 | * context of this component. |
| 355 | * |
| 356 | * \param[in] NdefCb Pointer to a caller-initialised structure describing the context of a Listener |
| 357 | * that requests its un-registration. |
| 358 | * |
| 359 | * \retval NFCSTATUS_SUCCESS The operation has been successful. |
| 360 | * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. |
| 361 | * \retval NFCSTATUS_NODE_NOT_FOUND If the internal list is NULL or a list node is not found. |
| 362 | * |
| 363 | * \note This function returns once the listener is removed successfully or an error occurs. |
| 364 | */ |
| 365 | NFCSTATUS phFriNfc_NdefReg_RmCb(phFriNfc_NdefReg_t *NdefReg, |
| 366 | phFriNfc_NdefReg_Cb_t *NdefCb); |
| 367 | |
| 368 | |
| 369 | |
| 370 | /** |
| 371 | * \brief NDEF Registry \b Dispatch \b Packet function |
| 372 | * |
| 373 | * \copydoc page_reg |
| 374 | * |
| 375 | * The entry point for NDEF \b PACKETS retrieved from the Peer (Remote) Device: |
| 376 | * The function performs a reset of the state. It starts the action (state machine). For actual |
| 377 | * processing a periodic call of \ref phFriNfc_NdefReg_Process has to be done. This |
| 378 | * function parses the Message, isolates the record, looks for a match with the registered |
| 379 | * RTDs and if a match is found, it calls the related callback. This procedure is done for each |
| 380 | * record in the Message |
| 381 | * |
| 382 | * \param[in] NdefReg Pointer to an initialised instance of \ref phFriNfc_NdefReg_t that holds the |
| 383 | * context of this component. |
| 384 | * |
| 385 | * \param[in] PacketData Pointer to a NDEF Packet that has been received. |
| 386 | * |
| 387 | * \param[in] PacketDataLength Length of the NDEF packet to process. |
| 388 | * |
| 389 | * \retval NFCSTATUS_SUCCESS The operation has been successfully initiated. |
| 390 | * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. |
| 391 | * |
| 392 | * \note This function returns once the operation is initiated or an error occurs. |
| 393 | * |
| 394 | */ |
| 395 | NFCSTATUS phFriNfc_NdefReg_DispatchPacket(phFriNfc_NdefReg_t *NdefReg, |
| 396 | uint8_t *PacketData, |
| 397 | uint16_t PacketDataLength); |
| 398 | |
| 399 | |
| 400 | /** |
| 401 | * \brief NDEF Registry \b Dispatch \b Record function |
| 402 | * |
| 403 | * \copydoc page_reg |
| 404 | * |
| 405 | * The entry point for NDEF \b RECORDS retrieved from the Peer (Remote) Device: |
| 406 | * The function performs a reset of the state. It starts the action (state machine). For actual |
| 407 | * processing a periodic call of \ref phFriNfc_NdefReg_Process has to be done. This |
| 408 | * function compares the given record with the registered RTDs and if a match is found it calls |
| 409 | * the related callback. |
| 410 | * |
| 411 | * \param[in] NdefReg Pointer to an initialised instance of \ref phFriNfc_NdefReg_t that holds the |
| 412 | * context of this component. |
| 413 | * |
| 414 | * \param[in] RecordsExtracted Pointer to a NDEF Record that has been received. |
| 415 | * |
| 416 | * \retval NFCSTATUS_SUCCESS The operation has been successfully initiated. |
| 417 | * \retval NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. |
| 418 | * |
| 419 | * \note This function returns once the process is initiated or an error occurs. |
| 420 | */ |
| 421 | NFCSTATUS phFriNfc_NdefReg_DispatchRecord(phFriNfc_NdefReg_t *NdefReg, |
| 422 | phFriNfc_NdefRecord_t *RecordsExtracted); |
| 423 | |
| 424 | |
| 425 | /** |
| 426 | * \brief NDEF Registry \b Process function |
| 427 | * |
| 428 | * \copydoc page_reg |
| 429 | * |
| 430 | * Processing function, needed to avoid long blocking and to give control to other parts of the software |
| 431 | * between the internal dispatching of data. |
| 432 | * The function needs to be called during processing, within a message loop or a simple loop until its |
| 433 | * return value tells that it has finished. No State reset is performed during operation. |
| 434 | * |
| 435 | * \param NdefReg Pointer to a valid instance of the \ref phFriNfc_NdefReg_t structure describing |
| 436 | * the component context. |
| 437 | * |
| 438 | * \param Status Pointer to a variable receiving the final result of the NDEF data processing operation. |
| 439 | * There are the following values: |
| 440 | * \li NFCSTATUS_SUCCESS The operation has been successful. |
| 441 | * \li NFCSTATUS_INVALID_PARAMETER At least one parameter of the function is invalid. |
| 442 | * \li NFCSTATUS_NODE_NOT_FOUND If the List is NULL or Node is not found. |
| 443 | * \li NFCSTATUS_INVALID_DEVICE_REQUEST State other than the specified in the File. |
| 444 | * |
| 445 | * \retval FALSE Processing has finished, no more function call is needed. |
| 446 | * \retval TRUE Processing is ongoing, the function must be called again. |
| 447 | */ |
| 448 | uint8_t phFriNfc_NdefReg_Process(phFriNfc_NdefReg_t *NdefReg, |
| 449 | NFCSTATUS *Status); |
| 450 | |
| 451 | /*@}*/ /* defgroup */ |
| 452 | |
| 453 | #endif /* PH_FRINFC_EXCLUDE_FROM_TESTFW */ |
| 454 | |
| 455 | #endif /* PHFRINFCNDEFREG_H */ |
| 456 | |