Mistake on this page?
Report an issue in GitHub or email us
NFCTestShim.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 _NFCTESTSHIM_H_INCLUDED
18 #define _NFCTESTSHIM_H_INCLUDED
19 
20 #include <string>
21 #include <vector>
22 #include <stdio.h>
23 #include <stdarg.h>
24 
25 #include "mbed_config.h"
26 #include "nfc/ndef/MessageBuilder.h"
27 #include "nfc/ndef/common/URI.h"
28 #include "nfc/ndef/common/util.h"
29 #include "nfc/NFCDefinitions.h"
30 
31 /**
32  * Test app driver wrapper. This is a base class containing shared EEPROM and Controller test data + logic.
33  * Variations for the 2 different kinds of driver supported are delegated to derived classes.
34  */
35 class NFCTestShim {
36 public:
38 
39  static void cmd_get_last_nfc_error();
40  static void cmd_set_last_nfc_error(int err);
41  static void cmd_get_conf_nfceeprom();
42  /**
43  * For an EEPROM, this queries and responds with the flash size,
44  * For a Controller, responds with the config macro TEST_NDEF_MSG_MAX
45  */
46  virtual void cmd_get_max_ndef() = 0;
47 
48  static void get_last_nfc_error();
49  static void set_last_nfc_error(int err);
50  static void get_conf_nfceeprom();
51  static void print_ndef_message(const mbed::Span<const uint8_t> &buffer,
52  size_t length);
53  static mbed::nfc::ndef::common::URI::uri_identifier_code_t get_ndef_record_type(char const *url);
54  static char const *get_ndef_record_type_prefix(mbed::nfc::ndef::common::URI::uri_identifier_code_t id);
55 
56  void cmd_init();
57 
58  void cmd_set_smartposter(char *cmdUri);
59  void cmd_erase();
60  void cmd_write_long(char *text_string);
61  void cmd_read_nfc_contents();
62  void cmd_start_discovery(bool manual = false);
63  void cmd_stop_discovery();
64  void cmd_configure_rf_protocols(mbed::nfc::nfc_rf_protocols_bitmask_t protocols);
65  void cmd_get_rf_protocols();
66 
67 protected:
68  // implement/declare EEPROM and Controller model underlying common BH and delegate specializations
69  virtual nfc_err_t init() = 0;
70  virtual nfc_err_t set_rf_protocols(mbed::nfc::nfc_rf_protocols_bitmask_t protocols)
71  {
72  return NFC_ERR_UNSUPPORTED ;
73  };
74  virtual mbed::nfc::nfc_rf_protocols_bitmask_t get_rf_protocols()
75  {
77  memset((void *)&none, 0, sizeof(none));
78  return none;
79  };
80  virtual nfc_err_t start_discovery()
81  {
82  return NFC_ERR_UNSUPPORTED ;
83  };
84  virtual nfc_err_t stop_discovery()
85  {
86  return NFC_ERR_UNSUPPORTED ;
87  };
88  void set_discovery_restart_auto()
89  {
90  _discovery_restart = true;
91  };
92  void set_discovery_restart_manual()
93  {
94  _discovery_restart = false;
95  };
96 
97 protected:
98  size_t _ndef_write_buffer_used;
99  mbed::Span<uint8_t> _ndef_poster_message; // message to build and send
100  uint8_t _ndef_write_buffer[MBED_CONF_APP_TEST_NDEF_MSG_MAX]; // if this buffer is smaller than the EEPROM, the driver may crash see IOTPAN-297
101  uint8_t _ndef_buffer[MBED_CONF_APP_TEST_NDEF_MSG_MAX]; // driver I/O buffer
102  bool _discovery_restart; // default true, restart discovery loop again on remote disconnect
103  events::EventQueue &_queue;
104 private:
105  static int last_nfc_error;
106 };
107 
108 // forward declare single instance
109 extern NFCTestShim *pNFC_Test_Shim;
110 
111 #endif // _NFCTESTSHIM_H_INCLUDED
EventQueue.
Definition: EventQueue.h:60
virtual void cmd_get_max_ndef()=0
For an EEPROM, this queries and responds with the flash size, For a Controller, responds with the con...
Test app driver wrapper.
Definition: NFCTestShim.h:35
uri_identifier_code_t
Identifier codes.
Definition: URI.h:46
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.