summaryrefslogtreecommitdiffstats
path: root/src/phFriNfc_SmtCrdFmt.c
blob: fce302f015f8390658ec3836e5757e7716e1d888 (plain)
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
/*
 * 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_SmtCrdFmt.c
 * \brief This component encapsulates different smart and simple tag formatting functionalities,
 *        for the mapping layer. 
 *
 * Project: NFC-FRI
 *
 * $Date: Mon Dec 13 14:14:13 2010 $
 * $Author: ing02260 $
 * $Revision: 1.9 $
 * $Aliases:  $
 *
 */

#ifndef PH_FRINFC_CARD_FORMAT_DISABLED

#include <phNfcTypes.h>
#include <phFriNfc_OvrHal.h>
#include <phFriNfc_SmtCrdFmt.h>
#ifdef DISABLE_FORMAT
#include <phFriNfc_TopazFormat.h>
#endif /* #ifdef DISABLE_FORMAT */
#include <phFriNfc_MifULFormat.h>
#include <phFriNfc_DesfireFormat.h>
#include <phFriNfc_MifStdFormat.h>
#ifndef PH_FRINFC_FMT_ISO15693_DISABLED
    #include <phFriNfc_ISO15693Format.h>
#endif /* #ifndef PH_FRINFC_FMT_ISO15693_DISABLED */


/*! \ingroup grp_file_attributes
 *  \name NDEF Mapping
 *
 * File: \ref phFriNfc_CardFormatFunctions.c
 *
 */
/*@{*/
// file versions
/*@}*/




void phFriNfc_SmtCrdFmt_HCrHandler(phFriNfc_sNdefSmtCrdFmt_t  *NdefSmtCrdFmt,
                                       NFCSTATUS            Status)
{
    /* set the state back to the Reset_Init state*/
    NdefSmtCrdFmt->State =  PH_FRINFC_SMTCRDFMT_STATE_RESET_INIT;

    /* set the completion routine*/
    NdefSmtCrdFmt->CompletionRoutine[PH_FRINFC_SMTCRDFMT_CR_FORMAT].
        CompletionRoutine(NdefSmtCrdFmt->CompletionRoutine->Context, Status);
}

/*!
 * \brief Used to Reset the context variables , before the actual smart card formatting
 *        procedure.
 *
 */
NFCSTATUS phFriNfc_NdefSmtCrd_Reset(phFriNfc_sNdefSmtCrdFmt_t       *NdefSmtCrdFmt,
                                    void                            *LowerDevice,
                                    phHal_sRemoteDevInformation_t   *psRemoteDevInfo,
                                    phHal_sDevInputParam_t          *psDevInputParam,
                                    uint8_t                         *SendRecvBuffer,
                                    uint16_t                        *SendRecvBuffLen)
{
    NFCSTATUS   result = NFCSTATUS_SUCCESS;
    uint8_t     index;

    if (    (SendRecvBuffLen == NULL) || (NdefSmtCrdFmt == NULL) || (psRemoteDevInfo == NULL) || 
            (SendRecvBuffer == NULL) ||  (LowerDevice == NULL) || 
            (*SendRecvBuffLen == 0) ||  (psDevInputParam == NULL) ||
            (*SendRecvBuffLen < PH_FRINFC_SMTCRDFMT_MAX_SEND_RECV_BUF_SIZE) )
    {
        result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, NFCSTATUS_INVALID_PARAMETER);
    }
    else
    {
        /* Initialise the state to Init */
        NdefSmtCrdFmt->State = PH_FRINFC_SMTCRDFMT_STATE_RESET_INIT;
       
        for(index = 0;index<PH_FRINFC_SMTCRDFMT_CR;index++)
        {
            /* Initialise the NdefMap Completion Routine to Null */
            NdefSmtCrdFmt->CompletionRoutine[index].CompletionRoutine = NULL;
            /* Initialise the NdefMap Completion Routine context to Null  */
            NdefSmtCrdFmt->CompletionRoutine[index].Context = NULL;
        }

        /* Lower Device(Always Overlapped HAL Struct initialised in application
            is registred in NdefMap Lower Device) */
        NdefSmtCrdFmt->LowerDevice = LowerDevice;

        /* Remote Device info received from Manual Device Discovery is registered here */
        NdefSmtCrdFmt->psRemoteDevInfo = psRemoteDevInfo;

        /* Trx Buffer registered */
        NdefSmtCrdFmt->SendRecvBuf = SendRecvBuffer;

        /* Trx Buffer Size */
        NdefSmtCrdFmt->SendRecvLength = SendRecvBuffLen;

        /* Register Transfer Buffer Length */
        NdefSmtCrdFmt->SendLength = 0;

        /* Initialise the Format status flag*/
        NdefSmtCrdFmt->FmtProcStatus = 0;

        /* Reset the Card Type */
        NdefSmtCrdFmt->CardType = 0;

        /* Reset MapCompletion Info*/
        NdefSmtCrdFmt->SmtCrdFmtCompletionInfo.CompletionRoutine = NULL;
        NdefSmtCrdFmt->SmtCrdFmtCompletionInfo.Context = NULL;

#ifndef PH_FRINFC_FMT_TOPAZ_DISABLED
        phFriNfc_Topaz_Reset(NdefSmtCrdFmt);

#endif  /* PH_FRINFC_FMT_TOPAZ_DISABLED */

#ifndef PH_FRINFC_FMT_DESFIRE_DISABLED
        /*Reset Desfire Cap Container elements*/
        phFriNfc_Desfire_Reset(NdefSmtCrdFmt);
#endif  /* PH_FRINFC_FMT_DESFIRE_DISABLED */

#ifndef PH_FRINFC_FMT_MIFARESTD_DISABLED
        /*Reset Mifare Standard Container elements*/
        NdefSmtCrdFmt->AddInfo.MfStdInfo.DevInputParam = psDevInputParam;
        phFriNfc_MfStd_Reset(NdefSmtCrdFmt);
#endif  /* PH_FRINFC_MAP_MIFARESTD_DISABLED */

#ifndef PH_FRINFC_FMT_MIFAREUL_DISABLED
        phFriNfc_MfUL_Reset(NdefSmtCrdFmt);
#endif /* #ifndef PH_FRINFC_FMT_MIFAREUL_DISABLED */

#ifndef PH_FRINFC_FMT_ISO15693_DISABLED
        phFriNfc_ISO15693_FmtReset (NdefSmtCrdFmt);
#endif /* #ifndef PH_FRINFC_FMT_ISO15693_DISABLED */

#ifdef PHFRINFC_OVRHAL_MOCKUP
        /*Reset Desfire Cap Container elements*/
  //      phFriNfc_Mockup_H_Reset(NdefSmtCrdFmt);
#endif  /* PHFRINFC_OVRHAL_MOCKUP */
    
    }
    return (result);

}

/*!
 * \brief Completion Routine initialisation
 *
 */
NFCSTATUS phFriNfc_NdefSmtCrd_SetCR(phFriNfc_sNdefSmtCrdFmt_t     *NdefSmtCrdFmt,
                                    uint8_t                       FunctionID,
                                    pphFriNfc_Cr_t                CompletionRoutine,
                                    void                          *CompletionRoutineContext)
{
    NFCSTATUS   status = NFCSTATUS_SUCCESS;
       
    if ((NdefSmtCrdFmt == NULL) || (FunctionID >= PH_FRINFC_SMTCRDFMT_CR) || 
        (CompletionRoutine == NULL) || (CompletionRoutineContext == NULL))
    {
        status = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, NFCSTATUS_INVALID_PARAMETER);
    }
    else
    {
        /* Register the application callback with the NdefMap Completion Routine */
        NdefSmtCrdFmt->CompletionRoutine[FunctionID].CompletionRoutine = CompletionRoutine;
        
        /* Register the application context with the NdefMap Completion Routine context */
        NdefSmtCrdFmt->CompletionRoutine[FunctionID].Context = CompletionRoutineContext;
    }

    return status;
}

#ifdef FRINFC_READONLY_NDEF

NFCSTATUS
phFriNfc_NdefSmtCrd_ConvertToReadOnly (
    phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt)
{
    NFCSTATUS   result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT,
                                  NFCSTATUS_INVALID_PARAMETER);
    uint8_t     sak = 0;

    if((NdefSmtCrdFmt != NULL)
        && (NdefSmtCrdFmt->CompletionRoutine->CompletionRoutine != NULL)
        && (NdefSmtCrdFmt->CompletionRoutine->Context != NULL))
    {
        sak = NdefSmtCrdFmt->psRemoteDevInfo->RemoteDevInfo.Iso14443A_Info.Sak;
        switch (NdefSmtCrdFmt->psRemoteDevInfo->RemDevType)
        {
            case phHal_eMifare_PICC:
            {
                if (0x00 == sak)
                {
                    result = phFriNfc_MfUL_ConvertToReadOnly (NdefSmtCrdFmt);
                }
                else
                {
                    /* MIFARE classic 1k/4k is not supported */
                    result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT,
                                        NFCSTATUS_INVALID_REMOTE_DEVICE);
                }
                break;
            }

            case phHal_eISO14443_A_PICC:
            {
                result = phFriNfc_Desfire_ConvertToReadOnly (NdefSmtCrdFmt);
                break;
            }

            default :
            {
                /*  Remote device is not recognised.
                Probably not NDEF compliant */
                result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT,
                                    NFCSTATUS_INVALID_REMOTE_DEVICE);
                break;
            }
        }
    }
    return result;
}

#endif /* #ifdef FRINFC_READONLY_NDEF */


/*!
 * \brief Used to format the different smart cards.
 *
 */
NFCSTATUS phFriNfc_NdefSmtCrd_Format( phFriNfc_sNdefSmtCrdFmt_t *NdefSmtCrdFmt, const uint8_t *ScrtKeyB )
{
    /* Component ID needs to be changed */
    NFCSTATUS   Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, 
                                    NFCSTATUS_INVALID_PARAMETER);
    uint8_t     sak = 0;
    
    /* Check for the correct context structure */
    if((NdefSmtCrdFmt != NULL) &&  
        (NdefSmtCrdFmt->CompletionRoutine->CompletionRoutine != NULL) && 
        (NdefSmtCrdFmt->CompletionRoutine->Context != NULL))
    {
#ifdef PH_HAL4_ENABLE
        /* SAK (Select response) */
        sak = NdefSmtCrdFmt->psRemoteDevInfo->RemoteDevInfo.Iso14443A_Info.Sak;

        /* Depending on the Opmodes, call the respective card functions */
        switch ( NdefSmtCrdFmt->psRemoteDevInfo->RemDevType )
#else
        /* SAK (Select response) */
        sak = NdefSmtCrdFmt->psRemoteDevInfo->RemoteDevInfo.CardInfo106.
                Startup106.SelRes;

        /* Depending on the Opmodes, call the respective card functions */
        switch ( NdefSmtCrdFmt->psRemoteDevInfo->OpMode )
#endif /* #ifdef PH_HAL4_ENABLE */
        {
#ifdef PH_HAL4_ENABLE
            case phHal_eMifare_PICC :
#else
            case phHal_eOpModesMifare :
#endif /* #ifdef PH_HAL4_ENABLE */
                /*  Remote device is Mifare card . Check for Mifare
                NDEF compliance */
                if(0x00 == sak) 
                {
#ifndef PH_FRINFC_FMT_MIFAREUL_DISABLED
                    /*  The SAK/Sel_Res says the card is of the type
                        Mifare UL */
                   NdefSmtCrdFmt->CardType = PH_FRINFC_SMTCRDFMT_MIFARE_UL_CARD;
					if (NdefSmtCrdFmt->psRemoteDevInfo->RemoteDevInfo.Iso14443A_Info.UidLength == 7 &&
						NdefSmtCrdFmt->psRemoteDevInfo->RemoteDevInfo.Iso14443A_Info.Uid[0] == 0x04)
					{
						
	                    Result = phFriNfc_MfUL_Format( NdefSmtCrdFmt);
					}
					else
					{
						Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, 
                                    NFCSTATUS_INVALID_REMOTE_DEVICE);
					}
#else
                    Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, 
                                    NFCSTATUS_INVALID_REMOTE_DEVICE);
#endif /* #ifndef PH_FRINFC_FMT_MIFAREUL_DISABLED */
                }
                else if((0x08 == (sak & 0x18)) || 
                        (0x18 == (sak & 0x18)) ||
                        (0x01 == sak))
                {
#ifndef PH_FRINFC_FMT_MIFARESTD_DISABLED
                    NdefSmtCrdFmt->CardType = (uint8_t)
                        (((sak & 0x18) == 0x08)?
                        PH_FRINFC_SMTCRDFMT_MFSTD_1K_CRD:
                        PH_FRINFC_SMTCRDFMT_MFSTD_4K_CRD);

                    /*  The SAK/Sel_Res says the card is of the type
                        Mifare standard */
                    Result = phFriNfc_MfStd_Format( NdefSmtCrdFmt, ScrtKeyB);
#else
                    Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, 
                                    NFCSTATUS_INVALID_REMOTE_DEVICE);
#endif /* #ifndef PH_FRINFC_FMT_MIFARESTD_DISABLED */
                }
                else
                {
                    /*  Invalid Mifare card, as the remote device 
                        info - opmode says its a Mifare card but, 
                        The SAK/Sel_Res is wrong */
                    Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, 
                                        NFCSTATUS_INVALID_REMOTE_DEVICE);
                }
            break;
#ifdef PH_HAL4_ENABLE
            case phHal_eISO14443_A_PICC :
#else
            case phHal_eOpModesISO14443_4A :
#endif /* #ifdef PH_HAL4_ENABLE */
                /*  Remote device is Desfire card . Check for Desfire
                NDEF compliancy */
                 if(0x20 == (sak & 0xFF))
                {
#ifndef PH_FRINFC_FMT_DESFIRE_DISABLED
                    NdefSmtCrdFmt->CardType = PH_FRINFC_SMTCRDFMT_ISO14443_4A_CARD;
                    /*  The SAK/Sel_Res says the card is of the type
                        ISO14443_4A */
                    
                    Result = phFriNfc_Desfire_Format(NdefSmtCrdFmt);
#else
                    Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, 
                                        NFCSTATUS_INVALID_REMOTE_DEVICE);
#endif /* #ifndef PH_FRINFC_FMT_DESFIRE_DISABLED */
                }
                else
                {
                    /*  Invalid Desfire card, as the remote device 
                        info - opmode says its a desfire card but, 
                        The SAK/Sel_Res is wrong */
                    Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, 
                                        NFCSTATUS_INVALID_REMOTE_DEVICE);
                }
            break;
#ifdef PH_HAL4_ENABLE
            case phHal_eJewel_PICC :
#else
            case phHal_eOpModesJewel :
#endif /* #ifdef PH_HAL4_ENABLE */
                /*  Remote device is Topaz card . Check for Topaz
                NDEF compliancy */
                if(0xC2 == sak)
                {
#ifndef PH_FRINFC_FMT_TOPAZ_DISABLED
                    NdefSmtCrdFmt->CardType = PH_FRINFC_SMTCRDFMT_TOPAZ_CARD;
                    /*  The SAK/Sel_Res says the card is of the type
                        ISO14443_4A */
                    Result = phFriNfc_Topaz_Format(NdefSmtCrdFmt);
#else
                    Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, 
                                        NFCSTATUS_INVALID_REMOTE_DEVICE);
#endif /* #ifndef PH_FRINFC_FMT_TOPAZ_DISABLED */
                    
                }
                else
                {
                    /*  Invalid Topaz card, as the remote device 
                        info - opmode says its a desfire card but, 
                        The SAK/Sel_Res is wrong */
                    Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, 
                                        NFCSTATUS_INVALID_REMOTE_DEVICE);
                }
            break;

#ifdef PHFRINFC_OVRHAL_MOCKUP
            case phHal_eOpModesMockup :
                    /*Set the OpMode Ttype Flag*/
                    NdefSmtCrdFmt->OpModeType[0] = phHal_eOpModesMockup;
                    NdefSmtCrdFmt->OpModeType[1] = phHal_eOpModesArrayTerminator;
                    //Result = phFriNfc_Mockup_ChkNdef(NdefSmtCrdFmt);
            break;
#endif  /* PHFRINFC_OVRHAL_MOCKUP */

#ifndef PH_FRINFC_FMT_ISO15693_DISABLED
            case phHal_eISO15693_PICC:
            {
                Result = phFriNfc_ISO15693_Format (NdefSmtCrdFmt);
                break;
            }
#endif /* #ifndef PH_FRINFC_FMT_ISO15693_DISABLED */
            default :
                /*  Remote device is not recognised.
                Probably not NDEF compliant */
                Result = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT,
                                    NFCSTATUS_INVALID_REMOTE_DEVICE);
            break;
        }
    }
    return Result;
}
/*!
 * \brief Handles different request and responses from the integration layer.
 *
 */
void phFriNfc_NdefSmtCrd_Process(void        *Context,
                                 NFCSTATUS    Status)
{
    if ( Context != NULL )
    {
        phFriNfc_sNdefSmtCrdFmt_t  *NdefSmtCrdFmt = (phFriNfc_sNdefSmtCrdFmt_t *)Context;
#ifdef PH_HAL4_ENABLE
        switch ( NdefSmtCrdFmt->psRemoteDevInfo->RemDevType )
#else
        switch ( NdefSmtCrdFmt->psRemoteDevInfo->OpMode )
#endif /* #ifdef PH_HAL4_ENABLE */
        {
#ifdef PH_HAL4_ENABLE
            case phHal_eMifare_PICC :
#else
            case  phHal_eOpModesMifare :
#endif /* #ifdef PH_HAL4_ENABLE */
                if((NdefSmtCrdFmt->CardType == PH_FRINFC_SMTCRDFMT_MFSTD_1K_CRD) ||
                    (NdefSmtCrdFmt->CardType == PH_FRINFC_SMTCRDFMT_MFSTD_4K_CRD))
                {
#ifndef PH_FRINFC_FMT_MIFARESTD_DISABLED
                    /*  Remote device is Mifare Standard card */
                    phFriNfc_MfStd_Process(NdefSmtCrdFmt,Status);
                    
#else   /* PH_FRINFC_FMT_MIFARESTD_DISABLED*/
                        Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, 
                                            NFCSTATUS_INVALID_REMOTE_DEVICE);               
#endif  /* PH_FRINFC_FMT_MIFARESTD_DISABLED*/
                }
                else
                {
#ifndef PH_FRINFC_FMT_MIFAREUL_DISABLED
                    /*  Remote device is Mifare UL card */
                    phFriNfc_MfUL_Process(NdefSmtCrdFmt,Status);
#else   /* PH_FRINFC_FMT_MIFAREUL_DISABLED*/
                    Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, 
                                         NFCSTATUS_INVALID_REMOTE_DEVICE);               
#endif  /* PH_FRINFC_FMT_MIFAREUL_DISABLED*/
                }
            break;

#ifdef PH_HAL4_ENABLE
            case phHal_eISO14443_A_PICC :
#else
            case phHal_eOpModesISO14443_4A :
#endif /* #ifdef PH_HAL4_ENABLE */
#ifndef PH_FRINFC_FMT_DESFIRE_DISABLED
                /*  Remote device is Desfire card */
                phFriNfc_Desf_Process(NdefSmtCrdFmt, Status);
#else   /* PH_FRINFC_FMT_DESFIRE_DISABLED*/
                 Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, 
                                            NFCSTATUS_INVALID_REMOTE_DEVICE);               
#endif  /* PH_FRINFC_FMT_DESFIRE_DISABLED*/
            break;
#ifdef PH_HAL4_ENABLE
            case phHal_eJewel_PICC :
#else
            case phHal_eOpModesJewel:
#endif /* #ifdef PH_HAL4_ENABLE */
#ifndef PH_FRINFC_FMT_TOPAZ_DISABLED
                /*  Remote device is Topaz Smart card */
               phFriNfc_Topaz_Process(NdefSmtCrdFmt, Status);
#else   /* PH_FRINFC_FMT_TOPAZ_DISABLED*/
               Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT, 
                                            NFCSTATUS_INVALID_REMOTE_DEVICE);               
#endif  /* PH_FRINFC_FMT_TOPAZ_DISABLED*/
            break;

#ifndef PH_FRINFC_FMT_ISO15693_DISABLED
            case phHal_eISO15693_PICC :
            {
                phFriNfc_ISO15693_FmtProcess (NdefSmtCrdFmt, Status);
                break;
            }
#endif /* #ifndef PH_FRINFC_FMT_ISO15693_DISABLED */

#ifdef PHFRINFC_OVRHAL_MOCKUP
            case phHal_eOpModesMockup:
                /*  Remote device is Desfire card */
                //phFriNfc_Mockup_Process(NdefSmtCrdFmt, Status);     
            break;
#endif  /* PHFRINFC_OVRHAL_MOCKUP*/
            default : 
                /*  Remote device opmode not recognised.
                    Probably not NDEF compliant */
                Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT,
                                    NFCSTATUS_INVALID_REMOTE_DEVICE);
                /* set the state back to the Reset_Init state*/
                NdefSmtCrdFmt->State =  PH_FRINFC_SMTCRDFMT_STATE_RESET_INIT;

                /* set the completion routine*/
                NdefSmtCrdFmt->CompletionRoutine[PH_FRINFC_SMTCRDFMT_CR_INVALID_OPE].
                CompletionRoutine(NdefSmtCrdFmt->CompletionRoutine->Context, Status);
            break;
        }
    }
    else
    {
        Status = PHNFCSTVAL(CID_FRI_NFC_NDEF_SMTCRDFMT,\
                            NFCSTATUS_INVALID_PARAMETER);
        /* The control should not come here. As Context itself is NULL ,
           Can't call the CR*/
    }
}

#endif  /* PH_FRINFC_CARD_FORMAT_DISABLED */