Mistake on this page?
Report an issue in GitHub or email us
NFCCommands.h
1 /*
2  * Copyright (c) 2018 ARM Limited. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  * Licensed under the Apache License, Version 2.0 (the License); you may
5  * 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, WITHOUT
12  * 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 #ifndef _NFCCOMMANDS_H_INCLUDED
18 #define _NFCCOMMANDS_H_INCLUDED
19 
20 #if MBED_CONF_NFCEEPROM
21 #include "NFCProcessEEPROM.h"
22 #else
23 #include "NFCProcessCtrl.h"
24 #endif
25 
26 // see https://support.microsoft.com/en-my/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer
27 #define MAX_URL_LENGTH 2000
28 
29 #ifndef MBED_CONF_NFCEEPROM
30 #define MBED_CONF_NFCEEPROM false
31 #endif
32 
33 
34 /**
35  * \brief adds human-readable traces not needed by the framework, filter is via a switch set_trace_enable()
36  * \param fmt standard printf formatter
37  * \param varargs
38  */
39 void trace_printf(const char *fmt, ...);
40 
41 /**
42  * \brief turns on human readable traces
43  * \param enabled : set to false to disable the extra traces
44  */
45 void set_trace_enable(bool enabled = true);
46 
47 /**
48  * HandleTestCommand turns all the typed-in/serial commands into function calls sent via a eventqueue to the driver
49  * shim/wrapper class.
50  * Methods with cmd_ prefix map to the serial commands, and are building blocks for test cases and scenarios. The
51  * first function a test must call is typically the initnfc command. Commands report back a test verdict, and a
52  * NFC status code. The test verdict is always success unless the command is not allowed. Tests much check the
53  * NFC error code for NFC_OK or zero; this pattern allows us to write negative tests which expect a specific NFC error.
54  *
55  * Handlers are statics because the test framework is not supporting C++
56  */
58 public:
60 
61  /** return and clear the last result code. Type "help getlastnfcerror" for a list of error codes */
62  static int cmd_get_last_nfc_error(int argc, char *argv[]);
63 
64  /** internal function to test getlastnfcerror */
65  static int cmd_set_last_nfc_error(int argc, char *argv[]);
66 
67  /** returns compile time flag if NFC EEPROM was compiled */
68  static int cmd_get_conf_nfceeprom(int argc, char *argv[]);
69 
70  static int cmd_set_trace(int argc, char *argv[]);
71 
72  /** For EEPROM, returns the driver max_ndef value, else returns the app config MBED_CONF_APP_TEST_NDEF_MSG_MAX */
73  static int cmd_get_max_ndef(int argc, char *argv[]);
74 
75  /** Init must be called before invoking any other calls, obtains a driver reference and initializes driver */
76  static int cmd_init_nfc(int argc, char *argv[]);
77  /** write a smartposter url, 'Sp' NDEF to the target */
78  static int cmd_set_smartposter(int argc, char *argv[]);
79  /** erases the EEPROM if present */
80  static int cmd_erase(int argc, char *argv[]);
81 
82  /** Returns a CSV list of protocols supported */
83  static int cmd_get_supported_rf_protocols(int argc, char *argv[]);
84  /** Sets the protocols supported (unimplemented) */
85  static int cmd_configure_rf_protocols(int argc, char *argv[]);
86  /** starts the NFC discovery loop if controller, has no effect on EEPROM */
87  static int cmd_start_discovery(int argc, char *argv[]);
88  /** stops the NFC discovery loop if controller */
89  static int cmd_stop_discovery(int argc, char *argv[]);
90 
91  /** read raw EEPROM contents, reads a buffer if a controller is used */
92  static int cmd_read_message(int argc, char *argv[]);
93  /** write a text 'T' NDEF message to the target */
94  static int cmd_write_long_ndef_message(int argc, char *argv[]);
95 
96 private:
97  /** set corresponding mask bit on in referenced structure, return false if the supplied string cannot parse */
98  static bool set_protocol_target(mbed::nfc::nfc_rf_protocols_bitmask_t &bitmask, const char *protocolName);
99  static NFCTestShim *new_testshim();
100  static void nfc_routine();
101 
102  static events::EventQueue _nfcQueue;
103 };
104 
105 
106 // un-implemented or sparse support in drivers, so not covered
107 int cmd_is_iso7816_supported(int argc, char *argv[]);
108 int cmd_add_iso7816_application(int argc, char *argv[]);
109 int cmd_set_tagtype(int argc, char *argv[]);
110 int cmd_get_tagtype(int argc, char *argv[]);
111 
112 #endif // _NFCCOMMANDS_H_INCLUDED
static int cmd_stop_discovery(int argc, char *argv[])
stops the NFC discovery loop if controller
static int cmd_erase(int argc, char *argv[])
erases the EEPROM if present
static int cmd_set_last_nfc_error(int argc, char *argv[])
internal function to test getlastnfcerror
EventQueue.
Definition: EventQueue.h:60
static int cmd_start_discovery(int argc, char *argv[])
starts the NFC discovery loop if controller, has no effect on EEPROM
static int cmd_configure_rf_protocols(int argc, char *argv[])
Sets the protocols supported (unimplemented)
static int cmd_get_supported_rf_protocols(int argc, char *argv[])
Returns a CSV list of protocols supported.
static int cmd_init_nfc(int argc, char *argv[])
Init must be called before invoking any other calls, obtains a driver reference and initializes drive...
static int cmd_read_message(int argc, char *argv[])
read raw EEPROM contents, reads a buffer if a controller is used
static int cmd_set_smartposter(int argc, char *argv[])
write a smartposter url, 'Sp' NDEF to the target
HandleTestCommand turns all the typed-in/serial commands into function calls sent via a eventqueue to...
Definition: NFCCommands.h:57
Test app driver wrapper.
Definition: NFCTestShim.h:35
static int cmd_write_long_ndef_message(int argc, char *argv[])
write a text 'T' NDEF message to the target
static int cmd_get_max_ndef(int argc, char *argv[])
For EEPROM, returns the driver max_ndef value, else returns the app config MBED_CONF_APP_TEST_NDEF_MS...
static int cmd_get_conf_nfceeprom(int argc, char *argv[])
returns compile time flag if NFC EEPROM was compiled
static int cmd_get_last_nfc_error(int argc, char *argv[])
return and clear the last result code.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.