mirror of https://github.com/ARMmbed/mbed-os.git
SPDX updated, review refactoring, doc errors
parent
260e6d1c8f
commit
fa29270b2e
|
|
@ -1,19 +1,19 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2018-2018 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
/* Copyright (c) 2018 ARM Limited. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "SmartPoster.h"
|
||||
|
||||
#include "nfc/ndef/common/Text.h"
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2018-2018 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
/* Copyright (c) 2018 ARM Limited. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -75,7 +75,19 @@ int seteasy(int argc, char *argv[])
|
|||
}
|
||||
return (CMDLINE_RETCODE_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* This test app can be used standalone interactively with at 115200 baud terminal. It is designed to work with the
|
||||
* IceTea test framework https://os.mbed.com/docs/latest/tools/icetea-testing-applications.html . This app does
|
||||
* not run test cases, it wraps functions in the API in ways that let us test multiple cases and scenarios.
|
||||
* Test commands are routed in the CommandHandler class to an eventqueue, so it interfaces to the driver
|
||||
* on a separate driver thread, which means test functions complete asynchronously.
|
||||
* The driver is only called in a thread in the shim or wrapper class called NFCTestShim, which handles driver
|
||||
* callbacks and completes the async part of a test function. NFCTestShim has specializations for NFC controllers
|
||||
* and EEPROMS. The classes NFCProcessController and NFCProcessEEPROM respectively implement the needed specialization.
|
||||
*
|
||||
* If using an NFC EEPROM, an extra library is needed. Please see the documentation in the README.MD for instructions
|
||||
* on how to modify this test for new drivers/targets, and the steps to run this test suite.
|
||||
*/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
cmd_init(&wrap_printf);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,14 @@ extern events::EventQueue nfcQueue;
|
|||
// see https://support.microsoft.com/en-my/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer
|
||||
#define MAX_URL_LENGTH 2000
|
||||
|
||||
/**
|
||||
* HandleTestCommand turns all the typed-in/serial commands into function calls sent via a eventqueue to the driver
|
||||
* shim/wrapper class. Most application level code that is agnostic of EEPROM/controller drivers lives in this class.
|
||||
* Methods with cmd_ prefix map to the serial commands, and are building blocks for test cases and scenarios. The
|
||||
* first function a test must call is typically the initnfc command. Commands report back a test verdict, and a
|
||||
* NFC status code. The test verdict is always success unless the command is not allowed. Tests much check the
|
||||
* NFC error code for NFC_OK or zero; this pattern allows us to write negative tests which expect a specific NFC error.
|
||||
*/
|
||||
class HandleTestCommand {
|
||||
public:
|
||||
// start thread and handle queue
|
||||
|
|
|
|||
|
|
@ -1,123 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018 ARM Limited. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _NFCPROCESS_H_INCLUDED
|
||||
#define _NFCPROCESS_H_INCLUDED
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "nfc/ndef/MessageBuilder.h"
|
||||
#include "nfc/ndef/common/URI.h"
|
||||
#include "nfc/ndef/common/util.h"
|
||||
#include "nfcTestShim.h"
|
||||
|
||||
#if MBED_CONF_NFCEEPROM
|
||||
#include "NFCEEPROM.h"
|
||||
#include "EEPROMDriver.h"
|
||||
#else
|
||||
#include "nfc/nfcdefinitions.h"
|
||||
#ifdef TARGET_PN512
|
||||
#include "nfc/controllers/PN512Driver.h"
|
||||
#include "nfc/controllers/PN512SPITransportDriver.h"
|
||||
#endif
|
||||
#include "nfc/NFCRemoteInitiator.h"
|
||||
#include "nfc/NFCController.h"
|
||||
#include "nfc/ndef/common/util.h"
|
||||
|
||||
#endif // MBED_CONF_NFCEEPROM
|
||||
|
||||
using mbed::nfc::ndef::MessageBuilder;
|
||||
using mbed::nfc::ndef::common::URI;
|
||||
using mbed::nfc::ndef::common::span_from_cstr;
|
||||
using mbed::Span;
|
||||
|
||||
|
||||
#if MBED_CONF_NFCEEPROM
|
||||
|
||||
using mbed::nfc::NFCEEPROM;
|
||||
using mbed::nfc::NFCEEPROMDriver;
|
||||
|
||||
class NFCProcessEEPROM : NFCTestShim, mbed::nfc::NFCEEPROM::Delegate {
|
||||
public:
|
||||
NFCProcessEEPROM(events::EventQueue &queue, NFCEEPROMDriver &eeprom_driver) ;
|
||||
nfc_err_t init();
|
||||
void queue_write_call();
|
||||
void queue_write_long_call();
|
||||
void queue_read_call();
|
||||
void queue_erase_call();
|
||||
|
||||
private:
|
||||
virtual void on_ndef_message_written(nfc_err_t result);
|
||||
virtual void on_ndef_message_read(nfc_err_t result);
|
||||
virtual void parse_ndef_message(const Span<const uint8_t> &buffer);
|
||||
virtual size_t build_ndef_message(const Span<uint8_t> &buffer);
|
||||
virtual void on_ndef_message_erased(nfc_err_t result);
|
||||
private:
|
||||
uint8_t _ndef_buffer[0x2000]; // if this buffer is smaller than the EEPROM, the driver may crash see IOTPAN-297
|
||||
NFCEEPROM _eeprom;
|
||||
EventQueue &_queue;
|
||||
};
|
||||
|
||||
#else // NFC Controller
|
||||
|
||||
class NFCProcessController : NFCTestShim, NFCRemoteInitiator::Delegate, NFCController::Delegate {
|
||||
public:
|
||||
NFCProcessController(events::EventQueue &queue);
|
||||
|
||||
nfc_err_t init();
|
||||
nfc_err_t start_discovery();
|
||||
nfc_err_t stop_discovery();
|
||||
void set_discovery_restart_auto()
|
||||
{
|
||||
_discovery_restart = true;
|
||||
};
|
||||
void set_discovery_restart_manual()
|
||||
{
|
||||
_discovery_restart = false;
|
||||
};
|
||||
nfc_rf_protocols_bitmask_t get_rf_protocols();
|
||||
nfc_err_t set_rf_protocols(nfc_rf_protocols_bitmask_t protocols);
|
||||
|
||||
virtual void parse_ndef_message(const Span<const uint8_t> &buffer);
|
||||
virtual size_t build_ndef_message(const Span<uint8_t> &buffer);
|
||||
const char *str_discovery_terminated_reason(nfc_discovery_terminated_reason_t reason);
|
||||
|
||||
|
||||
private:
|
||||
// these events are handled, to restart discovery
|
||||
virtual void on_connected();
|
||||
virtual void on_disconnected();
|
||||
virtual void on_discovery_terminated(nfc_discovery_terminated_reason_t reason);
|
||||
virtual void on_nfc_initiator_discovered(const SharedPtr<NFCRemoteInitiator> &nfc_initiator);
|
||||
|
||||
private:
|
||||
bool _discovery_restart;
|
||||
uint8_t _ndef_buffer[1024];
|
||||
mbed::nfc::PN512SPITransportDriver _pn512_transport;
|
||||
mbed::nfc::PN512Driver _pn512_driver;
|
||||
protected:
|
||||
EventQueue &_queue;
|
||||
private:
|
||||
NFCController _nfc_controller;
|
||||
SharedPtr<NFCRemoteInitiator> _nfc_remote_initiator;
|
||||
};
|
||||
#endif // TARGET_M24SR / else TARGET_PN512
|
||||
|
||||
|
||||
#endif // _NFCPROCESS_H_INCLUDED
|
||||
|
|
@ -49,10 +49,11 @@ using mbed::nfc::NFCController;
|
|||
//class NFCProcessController : NFCRemoteInitiator::Delegate, NFCController::Delegate {
|
||||
|
||||
NFCProcessController::NFCProcessController(events::EventQueue &queue) :
|
||||
NFCTestShim(queue),
|
||||
// pins: mosi, miso, sclk, ssel, irq, rst
|
||||
_pn512_transport(D11, D12, D13, D10, A1, A0), _pn512_driver(
|
||||
&_pn512_transport), _queue(queue), _nfc_controller(
|
||||
&_pn512_driver, &queue, _ndef_buffer)
|
||||
&_pn512_transport),
|
||||
_nfc_controller(&_pn512_driver, &queue, _ndef_buffer)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,10 @@ using mbed::nfc::ndef::common::span_from_cstr;
|
|||
using mbed::Span;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Wrapper class handles calls and callbacks for NFC controller drivers. Note, that users must call "start"
|
||||
* in order to start the discovery loop for controllers. An internal buffer stores the NFC message and records.
|
||||
*/
|
||||
class NFCProcessController: NFCTestShim,
|
||||
NFCRemoteInitiator::Delegate,
|
||||
NFCController::Delegate {
|
||||
|
|
@ -83,13 +86,8 @@ private:
|
|||
const SharedPtr<NFCRemoteInitiator> &nfc_initiator);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
mbed::nfc::PN512SPITransportDriver _pn512_transport;
|
||||
mbed::nfc::PN512Driver _pn512_driver;
|
||||
protected:
|
||||
EventQueue &_queue;
|
||||
private:
|
||||
NFCController _nfc_controller;
|
||||
SharedPtr<NFCRemoteInitiator> _nfc_remote_initiator;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -45,8 +45,7 @@ using mbed::nfc::ndef::common::URI;
|
|||
|
||||
// implements : mbed::nfc::NFCEEPROM::Delegate
|
||||
NFCProcessEEPROM::NFCProcessEEPROM(events::EventQueue &queue, NFCEEPROMDriver &eeprom_driver) :
|
||||
_eeprom(&eeprom_driver, &queue, _ndef_buffer),
|
||||
_queue(queue)
|
||||
NFCTestShim(queue), _eeprom(&eeprom_driver, &queue, _ndef_buffer)
|
||||
{}
|
||||
|
||||
nfc_err_t NFCProcessEEPROM::init()
|
||||
|
|
|
|||
|
|
@ -31,18 +31,16 @@
|
|||
#include "NFCEEPROM.h"
|
||||
#include "EEPROMDriver.h"
|
||||
|
||||
#endif // MBED_CONF_NFCEEPROM
|
||||
|
||||
using mbed::nfc::ndef::MessageBuilder;
|
||||
using mbed::nfc::ndef::common::URI;
|
||||
using mbed::nfc::ndef::common::span_from_cstr;
|
||||
using mbed::Span;
|
||||
|
||||
#if MBED_CONF_NFCEEPROM
|
||||
|
||||
using mbed::nfc::NFCEEPROM;
|
||||
using mbed::nfc::NFCEEPROMDriver;
|
||||
|
||||
/**
|
||||
* Wrapper class handles events specific to the EEPROM driver.
|
||||
*/
|
||||
class NFCProcessEEPROM : NFCTestShim, mbed::nfc::NFCEEPROM::Delegate {
|
||||
public:
|
||||
NFCProcessEEPROM(events::EventQueue &queue, NFCEEPROMDriver &eeprom_driver);
|
||||
|
|
@ -60,7 +58,6 @@ private:
|
|||
virtual void on_ndef_message_erased(nfc_err_t result);
|
||||
private:
|
||||
NFCEEPROM _eeprom;
|
||||
events::EventQueue &_queue;
|
||||
};
|
||||
|
||||
#endif // eeprom
|
||||
|
|
|
|||
|
|
@ -50,9 +50,10 @@ int using_eeprom = false;
|
|||
#endif
|
||||
}
|
||||
|
||||
NFCTestShim::NFCTestShim() :
|
||||
NFCTestShim::NFCTestShim(events::EventQueue &queue) :
|
||||
_ndef_write_buffer_used(0), ndef_poster_message(_ndef_write_buffer),
|
||||
_discovery_restart(true) // on disconnect, will restart discovery
|
||||
_discovery_restart(true), // on disconnect, will restart discovery
|
||||
_queue(queue)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,24 +33,21 @@ using mbed::nfc::nfc_rf_protocols_bitmask_t;
|
|||
|
||||
class NFCTestShim {
|
||||
public:
|
||||
NFCTestShim();
|
||||
NFCTestShim(events::EventQueue &queue);
|
||||
|
||||
static void cmd_get_last_nfc_error()
|
||||
{
|
||||
get_last_nfc_error();
|
||||
}
|
||||
;
|
||||
};
|
||||
static void cmd_set_last_nfc_error(int err)
|
||||
{
|
||||
set_last_nfc_error(err);
|
||||
cmd_ready(CMDLINE_RETCODE_SUCCESS);
|
||||
}
|
||||
;
|
||||
};
|
||||
static void cmd_get_conf_nfceeprom()
|
||||
{
|
||||
get_conf_nfceeprom();
|
||||
}
|
||||
;
|
||||
};
|
||||
static void get_last_nfc_error();
|
||||
static void set_last_nfc_error(int err);
|
||||
static void get_conf_nfceeprom();
|
||||
|
|
@ -77,7 +74,8 @@ protected:
|
|||
};
|
||||
virtual nfc_rf_protocols_bitmask_t get_rf_protocols()
|
||||
{
|
||||
|
||||
nfc_rf_protocols_bitmask_t none;
|
||||
return none;
|
||||
};
|
||||
virtual nfc_err_t start_discovery()
|
||||
{
|
||||
|
|
@ -96,13 +94,13 @@ protected:
|
|||
_discovery_restart = false;
|
||||
};
|
||||
|
||||
|
||||
protected:
|
||||
size_t _ndef_write_buffer_used;
|
||||
mbed::Span<uint8_t> ndef_poster_message; // message to build and send
|
||||
uint8_t _ndef_write_buffer[0x2000]; // if this buffer is smaller than the EEPROM, the driver may crash see IOTPAN-297
|
||||
uint8_t _ndef_buffer[0x2000]; // driver buffer
|
||||
bool _discovery_restart;
|
||||
uint8_t _ndef_buffer[0x2000]; // driver I/O buffer
|
||||
bool _discovery_restart; // default true, restart discovery loop again on remote disconnect
|
||||
events::EventQueue &_queue;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
# NFC tests.
|
||||
Internal document.
|
||||
|
||||
A CI test suite for NFC component. These tests validate card mbed emulation cases. The key use case is a NFC smart poster supporting comissioning workflow.
|
||||
A CI test suite for NFC component. These tests validate card mbed emulation cases. The key use case is an NFC smart poster supporting comissioning workflow.
|
||||
The SUT (system under test) is the NFC target. Tests exercise the framework and NDEF transactions when a NFC controller driver is used, or when the stack is configured for an NFC EEPROM chip in the system integration.
|
||||
|
||||
This project is called CreamScone, which is an ice tea framework based cli-driven python test.
|
||||
|
||||
<!-- TOC -->
|
||||
- [NFC tests . CONFIDENTIAL](#nfc-tests-confidential)
|
||||
|
||||
- [NFC tests.](#nfc-tests)
|
||||
- [Overview](#overview)
|
||||
- [NFC System Testing high level design](#nfc-system-testing-high-level-design)
|
||||
- [Low level design](#low-level-design)
|
||||
|
|
@ -15,10 +15,10 @@ This project is called CreamScone, which is an ice tea framework based cli-drive
|
|||
- [Test cases](#test-cases)
|
||||
- [cli commands](#cli-commands)
|
||||
- [How to](#how-to)
|
||||
- [Alternate NFC drivers note:](#alternate-nfc-drivers-note:)
|
||||
- [Running the tests](#running-the-tests)
|
||||
<!-- TOC -->
|
||||
- [Alternate NFC drivers note:](#alternate-nfc-drivers-note)
|
||||
|
||||
<!-- /TOC -->
|
||||
|
||||
# Overview
|
||||
A set of tests run in CI, which can provide:
|
||||
|
|
@ -29,7 +29,7 @@ A set of tests run in CI, which can provide:
|
|||
|
||||
A [Ice-tea](https://github.com/ARMmbed/mbed-os-5-docs/blob/development/docs/tools/testing/testing_icetea.md) based test suite. In it's simplest form, the suite merely drives API's for the NFC tag reader/writer, and validates a tag simulation running on an idle target, allows test cases in discovery, connection and read/write NDEF records.
|
||||
|
||||
In order to mitigate the costs associated with system testing, use existing frameworks or parts and make it easy to test each individually. The [nfcpy](https://nfcpy.readthedocs.io/) Python library is used as the core of the *CreamScone* component which uses a PN53* device [SCL3711 usb reader](https://www.identiv.com/products/smart-card-readers/rfid-nfc-contactless/scl3711/) over USB to read the mbed simulated tag. This library is used to drive host interactions because it is portable (windows/GNULinux.) Remote NFC interactions will raise events in the mbed application. Connection and read/write events which get handled in user application on the target get wired up to asyncronously return responses and the data values (NDEF messages) to the ice tea framework. These events and data are thus tested/checked in the code (python) running on host. The target test app wraps the API, allowing many new test-scenarios to be written purely in Python.
|
||||
In order to mitigate the costs associated with system testing, use existing frameworks or parts and make it easy to test each individually. The [nfcpy](https://nfcpy.readthedocs.io/) Python library is used as the core of the *CreamScone* component which uses a PN53* device [SCL3711 usb reader](https://www.identiv.com/products/smart-card-readers/rfid-nfc-contactless/scl3711/) over USB to read the mbed simulated tag. This library is used to drive host interactions because it is portable (windows/GNULinux.) Remote NFC interactions will raise events in the mbed application. Connection and read/write events which get handled in user application on the target get wired up to asynchronously return responses and the data values (NDEF messages) to the ice tea framework. These events and data are thus tested/checked in the code (python) running on host. The target test app wraps the API, allowing many new test-scenarios to be written purely in Python.
|
||||
|
||||
**NFC compliance**
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ This suite only assists in NFC forum compliance. Developers must self certify us
|
|||
|
||||
**Mobiles and inter-op**
|
||||
|
||||
(Unimplemented) Describe test procedures using a mobile phone app for Android and for IOS.
|
||||
Not in scope. Test procedures using a mobile phone app for Android and for IOS were not in scope for this test suite.
|
||||
|
||||

|
||||
|
||||
|
|
@ -46,7 +46,7 @@ Because the comissioning workflow application quality is the end goal, the NFC s
|
|||
|
||||
|
||||
# NFC System Testing high level design
|
||||
Mitigate risks identified, to the product from an internal view to supporting releases, and from customer development and production risks. In summary:
|
||||
Mitigate risks identified, to the product from an internal view to supporting releases. Help customers develop a driver or a design, and reduce their production risks. In summary:
|
||||
- Architecture risks and Api breaks
|
||||
- Partner cannot NFC forum Certify
|
||||
- Partner driver has bugs
|
||||
|
|
@ -54,9 +54,9 @@ Mitigate risks identified, to the product from an internal view to supporting re
|
|||
- Arm mbed provided driver or HAL has bugs
|
||||
- Security vulnerabilities
|
||||
|
||||
In precis, “Empower engineers to efficiently ship quality code with confidence.”
|
||||
In short, “Empower engineers to efficiently ship quality code with confidence.”
|
||||
|
||||
**Design requirements:**
|
||||
**Design requirements: **
|
||||
- Identify and use tools to allow running in CI system, on many targets/configurations
|
||||
- Be portable (can run in the CI system) using NFC explorer boards in lab for correctly co-located targets.
|
||||
- Be able to set up and run locally in development
|
||||
|
|
@ -70,18 +70,18 @@ Commandline (serial port) driven app [ice_device.py](TEST_APPS\testcases\nfc\ice
|
|||
|
||||
An icetea plugin [nfc_test_parsers.py](TEST_APPS\icetea_plugins\nfc_test_parsers.py)
|
||||
|
||||
MbedOS cli test app [main.cpp](TEST_APPS\device\nfcapp\main.cpp). The CLI commands return results asyncronously for most commands which get passed to and handled on a driver thread.
|
||||
MbedOS cli test app [main.cpp](TEST_APPS\device\nfcapp\main.cpp). The CLI commands return results asynchronously for most commands which get passed to and handled on a driver thread.
|
||||
|
||||
The SUT target is rebooted between tests, since test modify the target hardware state.
|
||||
|
||||
**Future:** A complete inter-op ready design expands to also include a switch-box to allow the reader to connect to NFC enabled targets nearby using flying cables and a sticky-back antenna. The switch allows selecting either alternative tags, or NFC peers. The switch can be controlled using GPIO either driven from spare IO pins on the target DUT itself (preferred option), or perhaps from a Raspberry pi.
|
||||
**Future: ** A complete inter-op ready design expands to also include a switch-box to allow the reader to connect to NFC enabled targets nearby using flying cables and a sticky-back antenna. The switch allows selecting either alternative tags, or NFC peers. The switch can be controlled using GPIO either driven from spare IO pins on the target DUT itself (preferred option), or perhaps from a Raspberry pi.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
|
||||
**Reference:**
|
||||
**Reference: **
|
||||
|
||||
https://github.com/ARMmbed/mbed-os/blob/master/docs/design-documents/nfc/nfc_design.md
|
||||
|
||||
|
|
@ -153,6 +153,7 @@ writelong fill entire FILE with pattern
|
|||
Note: Most commands also return a NFC status value (type "getlastnfcerror help" in console) which allow us to build negative test cases.
|
||||
Note: Some commands only apply to NFC controllers, these commands fail with the appropriate not-supported code NFC_ERR_UNSUPPORTED and additionally return -2 error code to ice-tea.
|
||||
|
||||
|
||||
**unimplemented CLI commands**
|
||||
commands that were not implemented in the test app
|
||||
- set/get tag type
|
||||
|
|
@ -225,11 +226,38 @@ If using the Explorer Shield or PN512 driver mbed_app.json will add
|
|||
}
|
||||
...
|
||||
```
|
||||
## Alternate NFC drivers note:
|
||||
|
||||
Please see the example json file .\TEST_APPS\testcases\nfc\mbed_app.json . The test does not check that you have any needed shield installed, so if it "hangs" at the point the "initnfc" command is used, the driver or shield may be the fault. The test assumes that MBED_CONF_NFCEEPROM is set to 1, if not it assumes that a controller driver is in use. To add support for other then PN512 and M24SR, it is required to add the support.
|
||||
## Running the tests
|
||||
1. Wire an [explorer shield](https://cpc.farnell.com/nxp/explore-nfc/add-on-board-nfc-for-raspberry/dp/SC13404) up to and compile the target application.
|
||||
2. Flash the binary to target and verify that it responds with an _`action NDEF record http://www.mbed.com`_ by using a mobile phone to scan over the antenna.
|
||||
3. Install python (2.7) and install the nfcpy library, [see](https://nfcpy.readthedocs.io/en/latest/topics/get-started.html) . NFC reader can be connected to a serial port, or more commonly a USB dongle. Verify the dongle is functioning.
|
||||
4. Place the scanner near the explorer shield. Run various test program commands like so:
|
||||
- python ice_device -command describe
|
||||
|
||||
If the driver you add is for Eeprom, open nfccommands.cpp and find the code and modify line as shown +++
|
||||
**run the suite**
|
||||
In a working folder, run
|
||||
|
||||
`git clone https://github.com/ARMmbed/mbed-os.git`
|
||||
|
||||
|
||||
If using the EEPROM driver, ( ST Discovery and the M24SR driver), you need the driver:
|
||||
`git clone https://github.com/ARMmbed/mbed-nfc-m24sr.git'
|
||||
|
||||
|
||||
And copy the files into your mbed root:
|
||||
`xcopy ..\mbed-nfc-m24sr\*.* .\eeprom_driver\'
|
||||
|
||||
To run the End2End tests, type:
|
||||
`mbed test --icetea -n test_nfce2e`
|
||||
|
||||
To run only the standalone (readerless tests if you do not have a card reader), type:
|
||||
`mbed test --icetea -n test_nfc_eeprom,test_nfc_error_codes,test_nfc_setsmartposter,test_nfc_erase,test_nfc_write_long`
|
||||
|
||||
# Alternate NFC drivers note:
|
||||
|
||||
Please see the example json file .\TEST_APPS\testcases\nfc\mbed_app.json . The test does not check that you have any needed shield installed, so if it "hangs" at the point the "initnfc" command is used, the driver or shield may be the fault. The test assumes that MBED_CONF_NFCEEPROM is set to 1, if not it assumes that a NFC Controller driver is in use. To test drivers other than PN512 and M24SR, it is required to make test code changes that reference the driver. The driver can be instantiated once only.
|
||||
|
||||
If the new driver you add is for Eeprom, open nfccommands.cpp and find the code and modify line as shown +++
|
||||
```
|
||||
NFCTestShim* new_testshim() {
|
||||
#if MBED_CONF_NFCEEPROM
|
||||
|
|
@ -243,7 +271,7 @@ NFCTestShim* new_testshim() {
|
|||
#endif // EEPROM
|
||||
```
|
||||
|
||||
If the driver you add is a controller driver, open nfcProcessCtrl.cpp and find the code
|
||||
If the driver you add is a Controller driver, open nfcProcessCtrl.cpp and find the code
|
||||
```
|
||||
NFCProcessController::NFCProcessController(events::EventQueue &queue) :
|
||||
// pins: mosi, miso, sclk, ssel, irq, rst
|
||||
|
|
@ -252,46 +280,14 @@ NFCProcessController::NFCProcessController(events::EventQueue &queue) :
|
|||
&_pn512_driver, &queue, _ndef_buffer) {
|
||||
}
|
||||
```
|
||||
1. You will want to replace with a reference to the desired controller driver. Likewise this is where pinout hanges if using a supplied controller driver have to be made.
|
||||
2. Search for occurences of guard macro #ifdef TARGET_PN512 , and add guard code for your specific controller driver.
|
||||
1. You will want to replace this and reference the desired controller driver. Likewise, this code is where pinout changes have to be made if using the supplied Controller driver.
|
||||
2. Search for occurences of guard macros `#ifdef TARGET_PN512` , and `#endif`. Add a new guard macro and code for your specific controller driver at the same point.
|
||||
|
||||
## Running the tests
|
||||
1. Wire an [explorer shield](https://cpc.farnell.com/nxp/explore-nfc/add-on-board-nfc-for-raspberry/dp/SC13404) up to and compile the target application.
|
||||
2. Provision the target, and verify that it responds with an _`action NDEF record http://www.mbed.com`_ by using a mobile phone to scan over the antenna.
|
||||
3. Install python (2.7) and install the nfcpy library, [see](https://nfcpy.readthedocs.io/en/latest/topics/get-started.html) . NFC reader can be connected to a serial port, or more commonly a USB dongle. Verify the dongle is functioning.
|
||||
4. Place the scanner near the explorer shield. Run various test program commands like so:
|
||||
- python ice_device -command describe
|
||||
|
||||
**run the suite**
|
||||
In a working folder, run
|
||||
|
||||
`git clone https://github.com/ARMmbed/mbed-os.git`
|
||||
|
||||
|
||||
|
||||
If using discovery and the M24SR driver, you need to:
|
||||
`git clone https://github.com/ARMmbed/mbed-nfc-m24sr.git'
|
||||
|
||||
|
||||
And copy the files something like this:
|
||||
`xcopy ..\mbed-nfc-m24sr\*.* .\eeprom_driver\'
|
||||
|
||||
To run the End2End tests, type:
|
||||
`mbed test --icetea -n test_nfce2e`
|
||||
|
||||
To run only the standalone (readerless tests if you do not have a card reader), type:
|
||||
`mbed test --icetea -n test_nfc_eeprom,test_nfc_error_codes,test_nfc_setsmartposter,test_nfc_erase,test_nfc_write_long`
|
||||
|
||||
**Using the app standalone**
|
||||
|
||||
The target app can accept commandline inputs over serial.
|
||||
```
|
||||
mbed sterm --baudrate 115200
|
||||
```
|
||||
|
||||
Note: If the target uses an EEPROM, it need not be powered/running, to be read, mbedOS is not running at that point.
|
||||
|
||||
**Device API error codes**
|
||||
|
||||
You can issue the command "getlastnfcerror help" to see a list of error codes that are returned by most commands.
|
||||
```
|
||||
#define NFC_OK 0 ///< No error
|
||||
|
|
|
|||
Loading…
Reference in New Issue