mirror of https://github.com/ARMmbed/mbed-os.git
astyle,comments,removed headers, fixed get_rf_protocols,copyright headers
parent
aa1e9acdb1
commit
260e6d1c8f
|
@ -37,76 +37,91 @@ using mbed::nfc::ndef::common::URI;
|
|||
// todo: this class probably needs to be in the nfc module itself
|
||||
|
||||
namespace {
|
||||
static RecordType smart_poster_record_type() {
|
||||
static RecordType smart_poster_record_type()
|
||||
{
|
||||
return RecordType(RecordType::well_known_type, span_from_cstr("Sp"));
|
||||
}
|
||||
|
||||
static RecordType action_record_type() {
|
||||
static RecordType action_record_type()
|
||||
{
|
||||
return RecordType(RecordType::well_known_type, span_from_cstr("act"));
|
||||
}
|
||||
|
||||
static RecordType size_record_type() {
|
||||
static RecordType size_record_type()
|
||||
{
|
||||
return RecordType(RecordType::well_known_type, span_from_cstr("s"));
|
||||
}
|
||||
|
||||
static RecordType type_record_type() {
|
||||
static RecordType type_record_type()
|
||||
{
|
||||
return RecordType(RecordType::well_known_type, span_from_cstr("T"));
|
||||
}
|
||||
|
||||
static size_t compute_record_size(const RecordType& type,
|
||||
const RecordPayload& payload) {
|
||||
static size_t compute_record_size(const RecordType &type,
|
||||
const RecordPayload &payload)
|
||||
{
|
||||
return MessageBuilder::compute_record_size(
|
||||
Record(type, payload, RecordID(), false, false));
|
||||
Record(type, payload, RecordID(), false, false));
|
||||
}
|
||||
|
||||
} // end of anonymous namespace
|
||||
|
||||
SmartPoster::SmartPoster(const URI &uri) :
|
||||
_uri(uri), _action(), _resource_size(0), _action_set(false), _resource_size_set(
|
||||
false) {
|
||||
_uri(uri), _action(), _resource_size(0), _action_set(false), _resource_size_set(
|
||||
false)
|
||||
{
|
||||
}
|
||||
|
||||
void SmartPoster::set_title(const Text &text) {
|
||||
void SmartPoster::set_title(const Text &text)
|
||||
{
|
||||
_title = text;
|
||||
}
|
||||
|
||||
void SmartPoster::set_icon(const Mime &icon) {
|
||||
void SmartPoster::set_icon(const Mime &icon)
|
||||
{
|
||||
_icon = icon;
|
||||
}
|
||||
|
||||
void SmartPoster::set_action(action_t action) {
|
||||
void SmartPoster::set_action(action_t action)
|
||||
{
|
||||
_action = action;
|
||||
_action_set = true;
|
||||
}
|
||||
|
||||
void SmartPoster::set_resource_size(uint32_t size) {
|
||||
void SmartPoster::set_resource_size(uint32_t size)
|
||||
{
|
||||
_resource_size = size;
|
||||
_resource_size_set = true;
|
||||
}
|
||||
|
||||
void SmartPoster::set_resource_type(Span<const uint8_t> &type) {
|
||||
void SmartPoster::set_resource_type(Span<const uint8_t> &type)
|
||||
{
|
||||
_type.set_text(Text::UTF8, Span<const uint8_t>(), type);
|
||||
}
|
||||
|
||||
bool SmartPoster::append_record(MessageBuilder &ndef_builder,
|
||||
bool is_last_record) const {
|
||||
bool is_last_record) const
|
||||
{
|
||||
if (_uri.get_uri_field().empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
struct PayloadBuilder: MessageBuilder::PayloadBuilder {
|
||||
PayloadBuilder(const SmartPoster &sp) :
|
||||
sp(sp) {
|
||||
sp(sp)
|
||||
{
|
||||
}
|
||||
|
||||
virtual size_t size() const {
|
||||
virtual size_t size() const
|
||||
{
|
||||
return sp.get_uri_record_size() + sp.get_title_record_size()
|
||||
+ sp.get_icon_record_size() + sp.get_action_record_size()
|
||||
+ sp.get_resource_size_record_size()
|
||||
+ sp.get_type_record_size();
|
||||
+ sp.get_icon_record_size() + sp.get_action_record_size()
|
||||
+ sp.get_resource_size_record_size()
|
||||
+ sp.get_type_record_size();
|
||||
}
|
||||
|
||||
virtual void build(const Span<uint8_t> &buffer) const {
|
||||
virtual void build(const Span<uint8_t> &buffer) const
|
||||
{
|
||||
MessageBuilder smart_poster_builder(buffer);
|
||||
sp.append_title(smart_poster_builder);
|
||||
sp.append_icon(smart_poster_builder);
|
||||
|
@ -120,26 +135,30 @@ bool SmartPoster::append_record(MessageBuilder &ndef_builder,
|
|||
};
|
||||
|
||||
bool result = ndef_builder.append_record(smart_poster_record_type(),
|
||||
PayloadBuilder(*this), is_last_record);
|
||||
PayloadBuilder(*this), is_last_record);
|
||||
return result;
|
||||
}
|
||||
|
||||
void SmartPoster::append_uri(MessageBuilder& builder) const {
|
||||
void SmartPoster::append_uri(MessageBuilder &builder) const
|
||||
{
|
||||
_uri.append_as_record(builder, true);
|
||||
}
|
||||
|
||||
size_t SmartPoster::get_uri_record_size() const {
|
||||
size_t SmartPoster::get_uri_record_size() const
|
||||
{
|
||||
return _uri.get_record_size();
|
||||
}
|
||||
|
||||
void SmartPoster::append_title(MessageBuilder& builder) const {
|
||||
void SmartPoster::append_title(MessageBuilder &builder) const
|
||||
{
|
||||
if (_title.get_text().empty()) {
|
||||
return;
|
||||
}
|
||||
_title.append_as_record(builder);
|
||||
}
|
||||
|
||||
size_t SmartPoster::get_title_record_size() const {
|
||||
size_t SmartPoster::get_title_record_size() const
|
||||
{
|
||||
if (_title.get_text().empty()) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -147,14 +166,16 @@ size_t SmartPoster::get_title_record_size() const {
|
|||
return _title.get_record_size();
|
||||
}
|
||||
|
||||
void SmartPoster::append_icon(MessageBuilder& builder) const {
|
||||
void SmartPoster::append_icon(MessageBuilder &builder) const
|
||||
{
|
||||
if (_icon.get_mime_content().empty()) {
|
||||
return;
|
||||
}
|
||||
_icon.append_as_record(builder);
|
||||
}
|
||||
|
||||
size_t SmartPoster::get_icon_record_size() const {
|
||||
size_t SmartPoster::get_icon_record_size() const
|
||||
{
|
||||
if (_icon.get_mime_content().empty()) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -162,7 +183,8 @@ size_t SmartPoster::get_icon_record_size() const {
|
|||
return _icon.get_record_size();
|
||||
}
|
||||
|
||||
void SmartPoster::append_action(MessageBuilder& builder) const {
|
||||
void SmartPoster::append_action(MessageBuilder &builder) const
|
||||
{
|
||||
if (!_action_set) {
|
||||
return;
|
||||
}
|
||||
|
@ -171,7 +193,8 @@ void SmartPoster::append_action(MessageBuilder& builder) const {
|
|||
builder.append_record(action_record_type(), action_value);
|
||||
}
|
||||
|
||||
size_t SmartPoster::get_action_record_size() const {
|
||||
size_t SmartPoster::get_action_record_size() const
|
||||
{
|
||||
if (!_action_set) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -181,7 +204,8 @@ size_t SmartPoster::get_action_record_size() const {
|
|||
return compute_record_size(action_record_type(), action_value);
|
||||
}
|
||||
|
||||
void SmartPoster::append_resource_size(MessageBuilder& builder) const {
|
||||
void SmartPoster::append_resource_size(MessageBuilder &builder) const
|
||||
{
|
||||
if (!_resource_size_set) {
|
||||
return;
|
||||
}
|
||||
|
@ -192,7 +216,8 @@ void SmartPoster::append_resource_size(MessageBuilder& builder) const {
|
|||
builder.append_record(size_record_type(), value);
|
||||
}
|
||||
|
||||
size_t SmartPoster::get_resource_size_record_size() const {
|
||||
size_t SmartPoster::get_resource_size_record_size() const
|
||||
{
|
||||
if (!_resource_size_set) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -202,7 +227,8 @@ size_t SmartPoster::get_resource_size_record_size() const {
|
|||
return compute_record_size(size_record_type(), value);
|
||||
}
|
||||
|
||||
void SmartPoster::append_type(MessageBuilder& builder) const {
|
||||
void SmartPoster::append_type(MessageBuilder &builder) const
|
||||
{
|
||||
if (_type.get_text().empty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -210,7 +236,8 @@ void SmartPoster::append_type(MessageBuilder& builder) const {
|
|||
builder.append_record(type_record_type(), _type.get_text());
|
||||
}
|
||||
|
||||
size_t SmartPoster::get_type_record_size() const {
|
||||
size_t SmartPoster::get_type_record_size() const
|
||||
{
|
||||
if (_type.get_text().empty()) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -132,8 +132,8 @@ private:
|
|||
uint32_t _resource_size;
|
||||
Text _type;
|
||||
|
||||
bool _action_set :1;
|
||||
bool _resource_size_set :1;
|
||||
bool _action_set : 1;
|
||||
bool _resource_size_set : 1;
|
||||
};
|
||||
|
||||
#endif /* SMARTPOSTER_H_ */
|
||||
|
|
|
@ -18,14 +18,12 @@
|
|||
#include <stdarg.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdlib.h>
|
||||
#include "mbed.h"
|
||||
#include <stdlib.h>
|
||||
#include "platform/Span.h"
|
||||
#include "mbed_events.h"
|
||||
#include "mbed-client-cli/ns_cmdline.h"
|
||||
#include "NFCEEPROMDriver.h"
|
||||
#include "nfctestshim.h"
|
||||
#include "nfccommands.h"
|
||||
#include "smartposter.h"
|
||||
#include "nfcTestShim.h"
|
||||
#include "nfcCommands.h"
|
||||
|
||||
#if MBED_CONF_NFCEEPROM
|
||||
using mbed::nfc::NFCEEPROM;
|
||||
|
@ -35,63 +33,51 @@ using mbed::nfc::NFCEEPROMDriver;
|
|||
#warning [NOT_SUPPORTED] NFC not supported for this target
|
||||
#endif
|
||||
|
||||
#include "nfc/controllers/PN512Driver.h"
|
||||
#include "nfc/controllers/PN512SPITransportDriver.h"
|
||||
|
||||
#include "nfc/NFCRemoteInitiator.h"
|
||||
#include "nfc/NFCController.h"
|
||||
|
||||
using mbed::nfc::NFCRemoteInitiator;
|
||||
using mbed::nfc::NFCController;
|
||||
using mbed::nfc::nfc_rf_protocols_bitmask_t;
|
||||
#endif // MBED_CONF_NFCEEPROM
|
||||
|
||||
using mbed::Span;
|
||||
using mbed::nfc::ndef::MessageBuilder;
|
||||
using mbed::nfc::ndef::common::Text;
|
||||
using mbed::nfc::ndef::common::URI;
|
||||
using mbed::nfc::ndef::common::span_from_cstr;
|
||||
|
||||
|
||||
void wrap_printf(const char *f, va_list a) {
|
||||
void wrap_printf(const char *f, va_list a)
|
||||
{
|
||||
vprintf(f, a);
|
||||
}
|
||||
|
||||
const char *errorcodes = // descriptions from nfc/stack/nfc_errors.h
|
||||
" 0 NFC_OK \n"
|
||||
" 1 NFC_ERR_UNKNOWN\n"
|
||||
" 2 NFC_ERR_LENGTH \n"
|
||||
" 3 NFC_ERR_NOT_FOUND\n"
|
||||
" 4 NFC_ERR_UNSUPPORTED\n"
|
||||
" 5 NFC_ERR_PARAMS \n"
|
||||
" 6 NFC_ERR_BUFFER_TOO_SMALL\n"
|
||||
" 7 NFC_ERR_TIMEOUT\n"
|
||||
" 8 NFC_ERR_CRC\n"
|
||||
" 9 NFC_ERR_NOPEER \n"
|
||||
"10 NFC_ERR_PARITY \n"
|
||||
"11 NFC_ERR_FIELD\n"
|
||||
"12 NFC_ERR_COLLISION\n"
|
||||
"13 NFC_ERR_WRONG_COMM \n"
|
||||
"14 NFC_ERR_PROTOCOL \n"
|
||||
"15 NFC_ERR_BUSY \n"
|
||||
"16 NFC_ERR_CONTROLLER \n"
|
||||
"17 NFC_ERR_HALTED \n"
|
||||
"18 NFC_ERR_MAC\n"
|
||||
"19 NFC_ERR_UNDERFLOW\n"
|
||||
"20 NFC_ERR_DISCONNECTED \n"
|
||||
"21 NFC_ERR_ABORTED\n";
|
||||
" 0 NFC_OK \n"
|
||||
" 1 NFC_ERR_UNKNOWN\n"
|
||||
" 2 NFC_ERR_LENGTH \n"
|
||||
" 3 NFC_ERR_NOT_FOUND\n"
|
||||
" 4 NFC_ERR_UNSUPPORTED\n"
|
||||
" 5 NFC_ERR_PARAMS \n"
|
||||
" 6 NFC_ERR_BUFFER_TOO_SMALL\n"
|
||||
" 7 NFC_ERR_TIMEOUT\n"
|
||||
" 8 NFC_ERR_CRC\n"
|
||||
" 9 NFC_ERR_NOPEER \n"
|
||||
"10 NFC_ERR_PARITY \n"
|
||||
"11 NFC_ERR_FIELD\n"
|
||||
"12 NFC_ERR_COLLISION\n"
|
||||
"13 NFC_ERR_WRONG_COMM \n"
|
||||
"14 NFC_ERR_PROTOCOL \n"
|
||||
"15 NFC_ERR_BUSY \n"
|
||||
"16 NFC_ERR_CONTROLLER \n"
|
||||
"17 NFC_ERR_HALTED \n"
|
||||
"18 NFC_ERR_MAC\n"
|
||||
"19 NFC_ERR_UNDERFLOW\n"
|
||||
"20 NFC_ERR_DISCONNECTED \n"
|
||||
"21 NFC_ERR_ABORTED\n";
|
||||
|
||||
// for easy manual UI interaction
|
||||
int seteasy(int argc, char *argv[]) {
|
||||
int seteasy(int argc, char *argv[])
|
||||
{
|
||||
const char msg[][20] =
|
||||
{ "echo off", "set --retcode true", "set --vt100 off" };
|
||||
{ "echo off", "set --retcode true", "set --vt100 off" };
|
||||
for (size_t i = 0; i < (sizeof(msg) / sizeof(msg[0])); i++) {
|
||||
cmd_exe((char*) msg[i]);
|
||||
cmd_exe((char *) msg[i]);
|
||||
}
|
||||
return (CMDLINE_RETCODE_SUCCESS);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
cmd_init(&wrap_printf);
|
||||
cmd_add("getlastnfcerror", HandleTestCommand::cmd_get_last_nfc_error,
|
||||
"last NFC error code", errorcodes);
|
||||
|
|
|
@ -16,40 +16,46 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdlib.h>
|
||||
#include "mbed.h"
|
||||
#include "mbed_events.h"
|
||||
#include "mbed-client-cli/ns_cmdline.h"
|
||||
#include "rtos\Thread.h"
|
||||
#include "nfcTestShim.h"
|
||||
#include "nfcCommands.h"
|
||||
|
||||
#include "nfctestshim.h"
|
||||
|
||||
#include "nfccommands.h"
|
||||
#if MBED_CONF_NFCEEPROM
|
||||
#include "NFCEEPROMDriver.h"
|
||||
#include "nfcProcessEeprom.h"
|
||||
#endif
|
||||
|
||||
events::EventQueue nfcQueue;
|
||||
Thread nfcThread;
|
||||
NFCTestShim * pNFC_Test_Shim = NULL;
|
||||
rtos::Thread nfcThread;
|
||||
NFCTestShim *pNFC_Test_Shim = NULL;
|
||||
|
||||
NFCTestShim* new_testshim() {
|
||||
NFCTestShim *new_testshim()
|
||||
{
|
||||
#if MBED_CONF_NFCEEPROM
|
||||
mbed::nfc::NFCEEPROMDriver& eeprom_driver = get_eeprom_driver(nfcQueue);
|
||||
mbed::nfc::NFCEEPROMDriver &eeprom_driver = get_eeprom_driver(nfcQueue);
|
||||
|
||||
return ( (NFCTestShim *)(new NFCProcessEEPROM(nfcQueue, eeprom_driver)) );
|
||||
return ((NFCTestShim *)(new NFCProcessEEPROM(nfcQueue, eeprom_driver)));
|
||||
#else
|
||||
return ((NFCTestShim *) (new NFCProcessController(nfcQueue)));
|
||||
return ((NFCTestShim *)(new NFCProcessController(nfcQueue)));
|
||||
#endif // EEPROM
|
||||
|
||||
}
|
||||
|
||||
void nfcRoutine() {
|
||||
void nfcRoutine()
|
||||
{
|
||||
nfcQueue.dispatch_forever();
|
||||
}
|
||||
|
||||
HandleTestCommand::HandleTestCommand() {
|
||||
osStatus status = nfcThread.start(callback(&nfcRoutine));
|
||||
HandleTestCommand::HandleTestCommand()
|
||||
{
|
||||
osStatus status = nfcThread.start(mbed::callback(&nfcRoutine));
|
||||
MBED_ASSERT(status == osOK);
|
||||
}
|
||||
|
||||
int HandleTestCommand::cmd_set_last_nfc_error(int argc, char *argv[]) {
|
||||
int HandleTestCommand::cmd_set_last_nfc_error(int argc, char *argv[])
|
||||
{
|
||||
if (argc <= 1) {
|
||||
cmd_printf("setlastnfcerror() invalid parameter(s)\r\n");
|
||||
return (CMDLINE_RETCODE_INVALID_PARAMETERS);
|
||||
|
@ -60,7 +66,8 @@ int HandleTestCommand::cmd_set_last_nfc_error(int argc, char *argv[]) {
|
|||
return (CMDLINE_RETCODE_EXCUTING_CONTINUE);
|
||||
}
|
||||
|
||||
int HandleTestCommand::cmd_init_nfc(int argc, char *argv[]) {
|
||||
int HandleTestCommand::cmd_init_nfc(int argc, char *argv[])
|
||||
{
|
||||
|
||||
if (pNFC_Test_Shim) {
|
||||
cmd_printf("WARN init called again!\r\n"); // only legal here, if eeprom driver stops talking
|
||||
|
@ -71,39 +78,42 @@ int HandleTestCommand::cmd_init_nfc(int argc, char *argv[]) {
|
|||
return (CMDLINE_RETCODE_EXCUTING_CONTINUE);
|
||||
}
|
||||
|
||||
int HandleTestCommand::cmd_read_message(int argc, char *argv[]) {
|
||||
int HandleTestCommand::cmd_read_message(int argc, char *argv[])
|
||||
{
|
||||
nfcQueue.call(pNFC_Test_Shim, &NFCTestShim::cmd_read_nfceeprom);
|
||||
|
||||
return (CMDLINE_RETCODE_EXCUTING_CONTINUE);
|
||||
}
|
||||
|
||||
int HandleTestCommand::cmd_set_smartposter(int argc, char *argv[]) {
|
||||
int HandleTestCommand::cmd_set_smartposter(int argc, char *argv[])
|
||||
{
|
||||
if (argc <= 1) {
|
||||
cmd_printf("setlastnfcerror() invalid parameter(s)\r\n");
|
||||
return (CMDLINE_RETCODE_INVALID_PARAMETERS);
|
||||
} else {
|
||||
// parse arg and queue it up
|
||||
char * uri = (char*) malloc(strlen(argv[1]) + 1);
|
||||
char *uri = (char *) malloc(strlen(argv[1]) + 1);
|
||||
if (uri) {
|
||||
strcpy(uri, argv[1]);
|
||||
nfcQueue.call(pNFC_Test_Shim, &NFCTestShim::cmd_set_smartposter,
|
||||
uri); // called thread must free
|
||||
}
|
||||
else {
|
||||
uri); // called thread must free
|
||||
} else {
|
||||
cmd_printf("WARN out of memory!\r\n");
|
||||
return (CMDLINE_RETCODE_FAIL);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (CMDLINE_RETCODE_EXCUTING_CONTINUE);
|
||||
}
|
||||
|
||||
// todo: jira IOTPAN-295
|
||||
int HandleTestCommand::cmd_erase(int argc, char *argv[]) {
|
||||
int HandleTestCommand::cmd_erase(int argc, char *argv[])
|
||||
{
|
||||
nfcQueue.call(pNFC_Test_Shim, &NFCTestShim::cmd_erase);
|
||||
return (CMDLINE_RETCODE_EXCUTING_CONTINUE);
|
||||
}
|
||||
|
||||
int HandleTestCommand::cmd_write_long_ndef_message(int argc, char *argv[]) {
|
||||
int HandleTestCommand::cmd_write_long_ndef_message(int argc, char *argv[])
|
||||
{
|
||||
size_t length, idx, sourceLength;
|
||||
static const char alphabet[] = "thequickbrownfoxjumpedoverthelazydog";
|
||||
char *data;
|
||||
|
@ -120,8 +130,8 @@ int HandleTestCommand::cmd_write_long_ndef_message(int argc, char *argv[]) {
|
|||
cmd_printf("Cannot convert value to int\r\n");
|
||||
return (CMDLINE_RETCODE_INVALID_PARAMETERS);
|
||||
}
|
||||
data = (char*) malloc(length + 1);
|
||||
if (!data) {
|
||||
data = (char *) malloc(length + 1);
|
||||
if (!data) {
|
||||
cmd_printf("WARN out of memory!\r\n");
|
||||
return (CMDLINE_RETCODE_FAIL);
|
||||
}
|
||||
|
@ -143,7 +153,8 @@ int HandleTestCommand::cmd_write_long_ndef_message(int argc, char *argv[]) {
|
|||
return (CMDLINE_RETCODE_EXCUTING_CONTINUE);
|
||||
}
|
||||
|
||||
int HandleTestCommand::cmd_start_discovery(int argc, char *argv[]) {
|
||||
int HandleTestCommand::cmd_start_discovery(int argc, char *argv[])
|
||||
{
|
||||
if ((argc > 1) && (0 == strcmp(argv[1], "man"))) {
|
||||
cmd_printf("User must restart discovery manually()\r\n");
|
||||
nfcQueue.call(pNFC_Test_Shim, &NFCTestShim::cmd_start_discovery, false);
|
||||
|
@ -154,18 +165,21 @@ int HandleTestCommand::cmd_start_discovery(int argc, char *argv[]) {
|
|||
return (CMDLINE_RETCODE_EXCUTING_CONTINUE);
|
||||
}
|
||||
|
||||
int HandleTestCommand::cmd_stop_discovery(int argc, char *argv[]) {
|
||||
int HandleTestCommand::cmd_stop_discovery(int argc, char *argv[])
|
||||
{
|
||||
nfcQueue.call(pNFC_Test_Shim, &NFCTestShim::cmd_stop_discovery);
|
||||
return (CMDLINE_RETCODE_EXCUTING_CONTINUE);
|
||||
}
|
||||
|
||||
int HandleTestCommand::cmd_get_supported_rf_protocols(int argc, char *argv[]) {
|
||||
int HandleTestCommand::cmd_get_supported_rf_protocols(int argc, char *argv[])
|
||||
{
|
||||
nfcQueue.call(pNFC_Test_Shim, &NFCTestShim::cmd_get_rf_protocols);
|
||||
return (CMDLINE_RETCODE_EXCUTING_CONTINUE);
|
||||
}
|
||||
|
||||
bool HandleTestCommand::set_protocol_target(
|
||||
nfc_rf_protocols_bitmask_t & bitmask, const char *protocolName) {
|
||||
nfc_rf_protocols_bitmask_t &bitmask, const char *protocolName)
|
||||
{
|
||||
bool parsed = false;
|
||||
if (0 == strcmp(protocolName, "t1t")) {
|
||||
parsed = bitmask.target_t1t = true;
|
||||
|
@ -188,7 +202,8 @@ bool HandleTestCommand::set_protocol_target(
|
|||
return (parsed);
|
||||
}
|
||||
|
||||
int HandleTestCommand::cmd_configure_rf_protocols(int argc, char *argv[]) {
|
||||
int HandleTestCommand::cmd_configure_rf_protocols(int argc, char *argv[])
|
||||
{
|
||||
nfc_rf_protocols_bitmask_t protocols = { 0 };
|
||||
|
||||
int argindex = argc;
|
||||
|
@ -200,12 +215,13 @@ int HandleTestCommand::cmd_configure_rf_protocols(int argc, char *argv[]) {
|
|||
argindex--;
|
||||
}
|
||||
nfcQueue.call(pNFC_Test_Shim, &NFCTestShim::cmd_configure_rf_protocols,
|
||||
protocols);
|
||||
protocols);
|
||||
return (CMDLINE_RETCODE_EXCUTING_CONTINUE);
|
||||
}
|
||||
|
||||
// todo: implement
|
||||
int cmd_start_stop_discovery_wait_tag(int argc, char *argv[]) {
|
||||
int cmd_start_stop_discovery_wait_tag(int argc, char *argv[])
|
||||
{
|
||||
|
||||
return (CMDLINE_RETCODE_COMMAND_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
@ -213,19 +229,23 @@ int cmd_start_stop_discovery_wait_tag(int argc, char *argv[]) {
|
|||
/////////////////////////////////////////////////////////////////////
|
||||
// boilerplate only
|
||||
|
||||
int cmd_is_iso7816_supported(int argc, char *argv[]) {
|
||||
int cmd_is_iso7816_supported(int argc, char *argv[])
|
||||
{
|
||||
return (CMDLINE_RETCODE_COMMAND_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
int cmd_add_iso7816_application(int argc, char *argv[]) {
|
||||
int cmd_add_iso7816_application(int argc, char *argv[])
|
||||
{
|
||||
return (CMDLINE_RETCODE_COMMAND_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
int cmd_set_tagtype(int argc, char *argv[]) {
|
||||
int cmd_set_tagtype(int argc, char *argv[])
|
||||
{
|
||||
return (CMDLINE_RETCODE_COMMAND_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
int cmd_get_tagtype(int argc, char *argv[]) {
|
||||
int cmd_get_tagtype(int argc, char *argv[])
|
||||
{
|
||||
return (CMDLINE_RETCODE_COMMAND_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,10 +33,11 @@ public:
|
|||
// start thread and handle queue
|
||||
HandleTestCommand();
|
||||
/* set corresponding mask bit on, return false if the supplied string cannot parse */
|
||||
static bool set_protocol_target(nfc_rf_protocols_bitmask_t & bitmask, const char *protocolName);
|
||||
static bool set_protocol_target(nfc_rf_protocols_bitmask_t &bitmask, const char *protocolName);
|
||||
|
||||
/* return and clear the last result code. Type "help getlastnfcerror" for a list of error codes */
|
||||
static int cmd_get_last_nfc_error(int argc, char *argv[]) {
|
||||
static int cmd_get_last_nfc_error(int argc, char *argv[])
|
||||
{
|
||||
nfcQueue.call(NFCTestShim::cmd_get_last_nfc_error);
|
||||
return (CMDLINE_RETCODE_EXCUTING_CONTINUE);
|
||||
}
|
||||
|
@ -45,7 +46,8 @@ public:
|
|||
static int cmd_set_last_nfc_error(int argc, char *argv[]);
|
||||
|
||||
/* compile time flag */
|
||||
static int cmd_get_conf_nfceeprom(int argc, char *argv[]) {
|
||||
static int cmd_get_conf_nfceeprom(int argc, char *argv[])
|
||||
{
|
||||
nfcQueue.call(NFCTestShim::cmd_get_conf_nfceeprom);
|
||||
return (CMDLINE_RETCODE_EXCUTING_CONTINUE);
|
||||
}
|
||||
|
|
|
@ -25,20 +25,20 @@
|
|||
#include "nfc/ndef/MessageBuilder.h"
|
||||
#include "nfc/ndef/common/URI.h"
|
||||
#include "nfc/ndef/common/util.h"
|
||||
#include "nfctestshim.h"
|
||||
#include "nfcTestShim.h"
|
||||
|
||||
#if MBED_CONF_NFCEEPROM
|
||||
#include "NFCEEPROM.h"
|
||||
#include "EEPROMDriver.h"
|
||||
#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"
|
||||
#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
|
||||
|
||||
|
@ -50,13 +50,12 @@ using mbed::Span;
|
|||
|
||||
#if MBED_CONF_NFCEEPROM
|
||||
|
||||
using mbed::nfc::NFCEEPROM;
|
||||
using mbed::nfc::NFCEEPROMDriver;
|
||||
using mbed::nfc::NFCEEPROM;
|
||||
using mbed::nfc::NFCEEPROMDriver;
|
||||
|
||||
class NFCProcessEEPROM : NFCTestShim , mbed::nfc::NFCEEPROM::Delegate
|
||||
{
|
||||
class NFCProcessEEPROM : NFCTestShim, mbed::nfc::NFCEEPROM::Delegate {
|
||||
public:
|
||||
NFCProcessEEPROM(events::EventQueue& queue, NFCEEPROMDriver& eeprom_driver) ;
|
||||
NFCProcessEEPROM(events::EventQueue &queue, NFCEEPROMDriver &eeprom_driver) ;
|
||||
nfc_err_t init();
|
||||
void queue_write_call();
|
||||
void queue_write_long_call();
|
||||
|
@ -72,7 +71,7 @@ private:
|
|||
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;
|
||||
EventQueue &_queue;
|
||||
};
|
||||
|
||||
#else // NFC Controller
|
||||
|
@ -84,8 +83,14 @@ public:
|
|||
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;};
|
||||
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);
|
||||
|
||||
|
@ -107,7 +112,7 @@ private:
|
|||
mbed::nfc::PN512SPITransportDriver _pn512_transport;
|
||||
mbed::nfc::PN512Driver _pn512_driver;
|
||||
protected:
|
||||
EventQueue& _queue;
|
||||
EventQueue &_queue;
|
||||
private:
|
||||
NFCController _nfc_controller;
|
||||
SharedPtr<NFCRemoteInitiator> _nfc_remote_initiator;
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include <stdarg.h>
|
||||
#include <cstring>
|
||||
#include <string.h>
|
||||
#include "mbed.h"
|
||||
#include "mbed_events.h"
|
||||
#include "mbed-client-cli/ns_cmdline.h"
|
||||
|
||||
|
@ -50,10 +49,11 @@ using mbed::nfc::NFCController;
|
|||
//class NFCProcessController : NFCRemoteInitiator::Delegate, NFCController::Delegate {
|
||||
|
||||
NFCProcessController::NFCProcessController(events::EventQueue &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) {
|
||||
// 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)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,7 +62,8 @@ NFCProcessController::NFCProcessController(events::EventQueue &queue) :
|
|||
* @return NFC_OK in case of success or a meaningful error code in case of
|
||||
* failure.
|
||||
*/
|
||||
nfc_err_t NFCProcessController::init() {
|
||||
nfc_err_t NFCProcessController::init()
|
||||
{
|
||||
cmd_printf("init()\r\n");
|
||||
|
||||
// register callbacks
|
||||
|
@ -76,7 +77,8 @@ nfc_err_t NFCProcessController::init() {
|
|||
* @return NFC_OK in case of success or a meaningful error code in case of
|
||||
* failure.
|
||||
*/
|
||||
nfc_err_t NFCProcessController::start_discovery() {
|
||||
nfc_err_t NFCProcessController::start_discovery()
|
||||
{
|
||||
cmd_printf("start_discovery()\r\n");
|
||||
|
||||
return _nfc_controller.start_discovery();
|
||||
|
@ -88,31 +90,37 @@ nfc_err_t NFCProcessController::start_discovery() {
|
|||
* @return NFC_OK in case of success or a meaningful error code in case of
|
||||
* failure.
|
||||
*/
|
||||
nfc_err_t NFCProcessController::stop_discovery() {
|
||||
nfc_err_t NFCProcessController::stop_discovery()
|
||||
{
|
||||
cmd_printf("stop_discovery()\r\n");
|
||||
return _nfc_controller.cancel_discovery();
|
||||
}
|
||||
|
||||
nfc_rf_protocols_bitmask_t NFCProcessController::get_rf_protocols() {
|
||||
nfc_rf_protocols_bitmask_t NFCProcessController::get_rf_protocols()
|
||||
{
|
||||
cmd_printf("get_supported_rf_protocols()\r\n");
|
||||
return _nfc_controller.get_supported_rf_protocols();
|
||||
}
|
||||
|
||||
nfc_err_t NFCProcessController::set_rf_protocols(
|
||||
nfc_rf_protocols_bitmask_t protocols) {
|
||||
nfc_rf_protocols_bitmask_t protocols)
|
||||
{
|
||||
cmd_printf("configure_rf_protocols()\r\n");
|
||||
|
||||
return _nfc_controller.configure_rf_protocols(protocols);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* Implementation of NFCRemoteInitiator::Delegate
|
||||
*/
|
||||
void NFCProcessController::on_connected() {
|
||||
void NFCProcessController::on_connected()
|
||||
{
|
||||
cmd_printf("on_connected()\r\n");
|
||||
}
|
||||
|
||||
void NFCProcessController::on_disconnected() {
|
||||
void NFCProcessController::on_disconnected()
|
||||
{
|
||||
cmd_printf("on_disconnected()\r\n");
|
||||
|
||||
// reset the state of the remote initiator
|
||||
|
@ -124,7 +132,8 @@ void NFCProcessController::on_disconnected() {
|
|||
}
|
||||
|
||||
void NFCProcessController::parse_ndef_message(
|
||||
const Span<const uint8_t> &buffer) {
|
||||
const Span<const uint8_t> &buffer)
|
||||
{
|
||||
size_t len = buffer.size();
|
||||
// copy remotely written message into our dummy buffer
|
||||
if (len <= sizeof(_ndef_write_buffer)) {
|
||||
|
@ -136,9 +145,10 @@ void NFCProcessController::parse_ndef_message(
|
|||
}
|
||||
}
|
||||
|
||||
size_t NFCProcessController::build_ndef_message(const Span<uint8_t> &buffer) {
|
||||
size_t NFCProcessController::build_ndef_message(const Span<uint8_t> &buffer)
|
||||
{
|
||||
cmd_printf("Copying message %d bytes to query buffer\r\n",
|
||||
_ndef_write_buffer_used);
|
||||
_ndef_write_buffer_used);
|
||||
memcpy(buffer.data(), _ndef_write_buffer, _ndef_write_buffer_used);
|
||||
for (size_t k = 0; k < _ndef_write_buffer_used; k++) {
|
||||
cmd_printf("%02x ", buffer[k]);
|
||||
|
@ -147,22 +157,24 @@ size_t NFCProcessController::build_ndef_message(const Span<uint8_t> &buffer) {
|
|||
}
|
||||
|
||||
const char *NFCProcessController::str_discovery_terminated_reason(
|
||||
nfc_discovery_terminated_reason_t reason) {
|
||||
static const char* reasons[4] = { "completed", "cancelled", "rf error"};
|
||||
nfc_discovery_terminated_reason_t reason)
|
||||
{
|
||||
static const char *reasons[4] = { "completed", "cancelled", "rf error"};
|
||||
switch (reason) {
|
||||
case nfc_discovery_terminated_completed :
|
||||
case nfc_discovery_terminated_canceled:
|
||||
case nfc_discovery_terminated_rf_error:
|
||||
return reasons[reason];
|
||||
case nfc_discovery_terminated_completed :
|
||||
case nfc_discovery_terminated_canceled:
|
||||
case nfc_discovery_terminated_rf_error:
|
||||
return reasons[reason];
|
||||
}
|
||||
return "unexpected!";
|
||||
}
|
||||
|
||||
|
||||
void NFCProcessController::on_discovery_terminated(
|
||||
nfc_discovery_terminated_reason_t reason) {
|
||||
nfc_discovery_terminated_reason_t reason)
|
||||
{
|
||||
cmd_printf("on_discovery_terminated(%s)\r\n",
|
||||
str_discovery_terminated_reason(reason));
|
||||
str_discovery_terminated_reason(reason));
|
||||
if (reason != nfc_discovery_terminated_completed
|
||||
&& this->_discovery_restart) {
|
||||
start_discovery();
|
||||
|
@ -170,7 +182,8 @@ void NFCProcessController::on_discovery_terminated(
|
|||
}
|
||||
|
||||
void NFCProcessController::on_nfc_initiator_discovered(
|
||||
const SharedPtr<NFCRemoteInitiator> &nfc_initiator) {
|
||||
const SharedPtr<NFCRemoteInitiator> &nfc_initiator)
|
||||
{
|
||||
cmd_printf("on_nfc_initiator_discovered()\r\n");
|
||||
|
||||
// setup the local remote initiator
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "mbed_events.h"
|
||||
#include "nfc/ndef/MessageBuilder.h"
|
||||
#include "nfc/ndef/common/URI.h"
|
||||
#include "nfc/ndef/common/util.h"
|
||||
#include "nfctestshim.h"
|
||||
#include "nfcTestShim.h"
|
||||
|
||||
#if !MBED_CONF_NFCEEPROM
|
||||
|
||||
|
@ -39,6 +39,8 @@
|
|||
#include "nfc/ndef/common/util.h"
|
||||
|
||||
|
||||
using mbed::nfc::NFCRemoteInitiator;
|
||||
using mbed::nfc::NFCController;
|
||||
using mbed::nfc::ndef::MessageBuilder;
|
||||
using mbed::nfc::ndef::common::URI;
|
||||
using mbed::nfc::ndef::common::span_from_cstr;
|
||||
|
@ -47,8 +49,8 @@ using mbed::Span;
|
|||
|
||||
|
||||
class NFCProcessController: NFCTestShim,
|
||||
NFCRemoteInitiator::Delegate,
|
||||
NFCController::Delegate {
|
||||
NFCRemoteInitiator::Delegate,
|
||||
NFCController::Delegate {
|
||||
public:
|
||||
NFCProcessController(events::EventQueue &queue);
|
||||
|
||||
|
@ -61,7 +63,7 @@ public:
|
|||
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);
|
||||
nfc_discovery_terminated_reason_t reason);
|
||||
|
||||
private:
|
||||
// these events are handled, to restart discovery
|
||||
|
@ -74,11 +76,11 @@ private:
|
|||
/**
|
||||
* Implementation of NFCController::Delegate */
|
||||
virtual void on_discovery_terminated(
|
||||
nfc_discovery_terminated_reason_t reason);
|
||||
nfc_discovery_terminated_reason_t reason);
|
||||
/**
|
||||
* Implementation of NFCController::Delegate */
|
||||
virtual void on_nfc_initiator_discovered(
|
||||
const SharedPtr<NFCRemoteInitiator> &nfc_initiator);
|
||||
const SharedPtr<NFCRemoteInitiator> &nfc_initiator);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -86,7 +88,7 @@ private:
|
|||
mbed::nfc::PN512SPITransportDriver _pn512_transport;
|
||||
mbed::nfc::PN512Driver _pn512_driver;
|
||||
protected:
|
||||
EventQueue& _queue;
|
||||
EventQueue &_queue;
|
||||
private:
|
||||
NFCController _nfc_controller;
|
||||
SharedPtr<NFCRemoteInitiator> _nfc_remote_initiator;
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include <stdarg.h>
|
||||
#include <cstring>
|
||||
#include <string.h>
|
||||
#include "mbed.h"
|
||||
#include "mbed_events.h"
|
||||
#include "mbed-client-cli/ns_cmdline.h"
|
||||
|
||||
|
@ -45,12 +44,13 @@ using mbed::nfc::ndef::common::Text;
|
|||
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)
|
||||
NFCProcessEEPROM::NFCProcessEEPROM(events::EventQueue &queue, NFCEEPROMDriver &eeprom_driver) :
|
||||
_eeprom(&eeprom_driver, &queue, _ndef_buffer),
|
||||
_queue(queue)
|
||||
{}
|
||||
|
||||
nfc_err_t NFCProcessEEPROM::init() {
|
||||
nfc_err_t NFCProcessEEPROM::init()
|
||||
{
|
||||
nfc_err_t err = _eeprom.initialize();
|
||||
if (err != NFC_OK) {
|
||||
cmd_printf("NFCProcessEEPROM::init() (error: %d)!\r\n", err);
|
||||
|
@ -59,25 +59,29 @@ nfc_err_t NFCProcessEEPROM::init() {
|
|||
cmd_printf("NFCProcessEEPROM::init() OK\r\n");
|
||||
}
|
||||
_eeprom.set_delegate(this);
|
||||
return(err);
|
||||
return (err);
|
||||
}
|
||||
|
||||
void NFCProcessEEPROM::queue_write_call() {
|
||||
void NFCProcessEEPROM::queue_write_call()
|
||||
{
|
||||
cmd_printf("NFCProcessEEPROM::queue_write_call() entry\r\n");
|
||||
_queue.call(&_eeprom, &NFCEEPROM::write_ndef_message);
|
||||
}
|
||||
|
||||
void NFCProcessEEPROM::queue_read_call() {
|
||||
void NFCProcessEEPROM::queue_read_call()
|
||||
{
|
||||
cmd_printf("NFCProcessEEPROM::queue_read_call() entry\r\n");
|
||||
_queue.call(&_eeprom, &NFCEEPROM::read_ndef_message);
|
||||
}
|
||||
|
||||
void NFCProcessEEPROM::queue_erase_call() {
|
||||
void NFCProcessEEPROM::queue_erase_call()
|
||||
{
|
||||
cmd_printf("NFCProcessEEPROM::queue_erase_call() entry\r\n");
|
||||
_queue.call(&_eeprom, &NFCEEPROM::erase_ndef_message);
|
||||
}
|
||||
|
||||
void NFCProcessEEPROM::on_ndef_message_written(nfc_err_t result) {
|
||||
void NFCProcessEEPROM::on_ndef_message_written(nfc_err_t result)
|
||||
{
|
||||
// todo: de-duplicate this code
|
||||
set_last_nfc_error(result);
|
||||
if (result == NFC_OK) {
|
||||
|
@ -89,7 +93,8 @@ void NFCProcessEEPROM::on_ndef_message_written(nfc_err_t result) {
|
|||
cmd_ready(CMDLINE_RETCODE_SUCCESS);
|
||||
}
|
||||
|
||||
void NFCProcessEEPROM::on_ndef_message_read(nfc_err_t result) {
|
||||
void NFCProcessEEPROM::on_ndef_message_read(nfc_err_t result)
|
||||
{
|
||||
set_last_nfc_error(result);
|
||||
if (result == NFC_OK) {
|
||||
cmd_printf("message read successfully\r\n");
|
||||
|
@ -113,17 +118,19 @@ void NFCProcessEEPROM::on_ndef_message_erased(nfc_err_t result)
|
|||
cmd_ready(CMDLINE_RETCODE_SUCCESS);
|
||||
}
|
||||
|
||||
void NFCProcessEEPROM::parse_ndef_message(const Span<const uint8_t> &buffer) {
|
||||
void NFCProcessEEPROM::parse_ndef_message(const Span<const uint8_t> &buffer)
|
||||
{
|
||||
cmd_printf("Received an ndef message of size %d\r\n", buffer.size());
|
||||
print_ndef_message(buffer, buffer.size());
|
||||
}
|
||||
|
||||
size_t NFCProcessEEPROM::build_ndef_message(const Span<uint8_t> &buffer) {
|
||||
size_t NFCProcessEEPROM::build_ndef_message(const Span<uint8_t> &buffer)
|
||||
{
|
||||
cmd_printf("Copying ndef message %d bytes into buffer\r\n", _ndef_write_buffer_used);
|
||||
// make a copy into our buffer
|
||||
memcpy(buffer.data(), _ndef_write_buffer, _ndef_write_buffer_used);
|
||||
for (size_t k=0; k<_ndef_write_buffer_used; k++ ) {
|
||||
cmd_printf("%02x ", buffer[k] );
|
||||
for (size_t k = 0; k < _ndef_write_buffer_used; k++) {
|
||||
cmd_printf("%02x ", buffer[k]);
|
||||
}
|
||||
return _ndef_write_buffer_used;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "nfc/ndef/MessageBuilder.h"
|
||||
#include "nfc/ndef/common/URI.h"
|
||||
#include "nfc/ndef/common/util.h"
|
||||
#include "nfctestshim.h"
|
||||
#include "nfcTestShim.h"
|
||||
|
||||
#if MBED_CONF_NFCEEPROM
|
||||
#include "NFCEEPROM.h"
|
||||
|
@ -43,10 +43,9 @@ using mbed::Span;
|
|||
using mbed::nfc::NFCEEPROM;
|
||||
using mbed::nfc::NFCEEPROMDriver;
|
||||
|
||||
class NFCProcessEEPROM : NFCTestShim , mbed::nfc::NFCEEPROM::Delegate
|
||||
{
|
||||
class NFCProcessEEPROM : NFCTestShim, mbed::nfc::NFCEEPROM::Delegate {
|
||||
public:
|
||||
NFCProcessEEPROM(events::EventQueue& queue, NFCEEPROMDriver& eeprom_driver);
|
||||
NFCProcessEEPROM(events::EventQueue &queue, NFCEEPROMDriver &eeprom_driver);
|
||||
nfc_err_t init();
|
||||
void queue_write_call();
|
||||
void queue_write_long_call();
|
||||
|
@ -61,7 +60,7 @@ private:
|
|||
virtual void on_ndef_message_erased(nfc_err_t result);
|
||||
private:
|
||||
NFCEEPROM _eeprom;
|
||||
EventQueue& _queue;
|
||||
events::EventQueue &_queue;
|
||||
};
|
||||
|
||||
#endif // eeprom
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include <stdarg.h>
|
||||
#include <cstring>
|
||||
#include <string.h>
|
||||
#include "mbed.h"
|
||||
#include "mbed-client-cli/ns_cmdline.h"
|
||||
#include "nfc/ndef/common/Text.h"
|
||||
#include "nfc/ndef/common/URI.h"
|
||||
|
@ -28,7 +27,7 @@
|
|||
|
||||
#include "NFCEEPROMDriver.h"
|
||||
#include "nfcCommands.h"
|
||||
#include "nfctestshim.h"
|
||||
#include "nfcTestShim.h"
|
||||
#include "SmartPoster.h"
|
||||
|
||||
using mbed::Span;
|
||||
|
@ -40,44 +39,54 @@ using mbed::nfc::ndef::common::URI;
|
|||
using mbed::nfc::nfc_rf_protocols_bitmask_t;
|
||||
|
||||
// statics
|
||||
char NFCTestShim::long_string[0x2000];
|
||||
namespace {
|
||||
char long_string[0x2000];
|
||||
|
||||
int NFCTestShim::last_nfc_error = 0;
|
||||
int last_nfc_error = 0;
|
||||
#if MBED_CONF_NFCEEPROM
|
||||
int NFCTestShim::using_eeprom = true;
|
||||
int using_eeprom = true;
|
||||
#else
|
||||
int NFCTestShim::using_eeprom = false;
|
||||
int using_eeprom = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
NFCTestShim::NFCTestShim() :
|
||||
_ndef_write_buffer_used(0), ndef_poster_message(_ndef_write_buffer), _discovery_restart(
|
||||
true) // on disconnect, will restart discovery
|
||||
_ndef_write_buffer_used(0), ndef_poster_message(_ndef_write_buffer),
|
||||
_discovery_restart(true) // on disconnect, will restart discovery
|
||||
{
|
||||
}
|
||||
|
||||
// The last failed NFC API call status, gets cleared upon reading it.
|
||||
void NFCTestShim::get_last_nfc_error() {
|
||||
int last = last_nfc_error;
|
||||
last_nfc_error = 0;
|
||||
// return data to the plugin framework
|
||||
/** \brief The last failed NFC API call status, gets cleared upon reading it.
|
||||
* \return void The NFC error is set asyncronously by sending text back over serial
|
||||
*/
|
||||
void NFCTestShim::get_last_nfc_error()
|
||||
{
|
||||
int last = ::last_nfc_error;
|
||||
::last_nfc_error = 0;
|
||||
// return data as text to the plugin framework
|
||||
cmd_printf("{{lastnfcerror=%d}}\r\n", last);
|
||||
cmd_ready(CMDLINE_RETCODE_SUCCESS);
|
||||
}
|
||||
|
||||
void NFCTestShim::set_last_nfc_error(int err) {
|
||||
last_nfc_error = err;
|
||||
cmd_printf("\r\n{{lastnfcerror=%d}}\r\n", last_nfc_error);
|
||||
void NFCTestShim::set_last_nfc_error(int err)
|
||||
{
|
||||
::last_nfc_error = err;
|
||||
cmd_printf("\r\n{{lastnfcerror=%d}}\r\n", ::last_nfc_error);
|
||||
}
|
||||
|
||||
// if an NFC EEPROM driver is configured
|
||||
void NFCTestShim::get_conf_nfceeprom() {
|
||||
void NFCTestShim::get_conf_nfceeprom()
|
||||
{
|
||||
set_last_nfc_error(NFC_OK);
|
||||
cmd_printf("{{iseeprom=%s}}\r\n", (using_eeprom ? "true" : "false"));
|
||||
// return data as text to the plugin framework
|
||||
cmd_printf("{{iseeprom=%s}}\r\n", (::using_eeprom ? "true" : "false"));
|
||||
cmd_ready(CMDLINE_RETCODE_SUCCESS);
|
||||
}
|
||||
|
||||
void NFCTestShim::print_ndef_message(const Span<const uint8_t> &buffer,
|
||||
size_t length) {
|
||||
size_t length)
|
||||
{
|
||||
// return data as text to the plugin framework
|
||||
cmd_printf("{{nfcmessage=");
|
||||
for (size_t k = 0; k < length; k++) {
|
||||
cmd_printf("%02x ", buffer.data()[k]);
|
||||
|
@ -85,7 +94,8 @@ void NFCTestShim::print_ndef_message(const Span<const uint8_t> &buffer,
|
|||
cmd_printf("}}\r\n");
|
||||
}
|
||||
|
||||
void NFCTestShim::cmd_init() {
|
||||
void NFCTestShim::cmd_init()
|
||||
{
|
||||
nfc_err_t ret = init();
|
||||
set_last_nfc_error(ret);
|
||||
|
||||
|
@ -96,20 +106,16 @@ void NFCTestShim::cmd_init() {
|
|||
}
|
||||
}
|
||||
|
||||
void NFCTestShim::cmd_get_rf_protocols() {
|
||||
void NFCTestShim::cmd_get_rf_protocols()
|
||||
{
|
||||
#if MBED_CONF_NFCEEPROM
|
||||
cmd_printf("EEPROM cannot get protocol()\r\n");
|
||||
set_last_nfc_error(NFC_ERR_UNSUPPORTED);
|
||||
cmd_ready(CMDLINE_RETCODE_INVALID_PARAMETERS);
|
||||
|
||||
#else
|
||||
nfc_rf_protocols_bitmask_t protocols =
|
||||
((NFCProcessController*) this)->get_rf_protocols();
|
||||
protocols.target_t1t = true;
|
||||
protocols.target_t2t = true;
|
||||
protocols.target_t3t = true;
|
||||
protocols.target_t5t = true;
|
||||
protocols.target_nfc_dep = true;
|
||||
nfc_rf_protocols_bitmask_t protocols = get_rf_protocols();
|
||||
|
||||
static char strSupported[7 * 6 + 1] = "";
|
||||
if (protocols.target_t1t) {
|
||||
strcat(strSupported, "t1t,");
|
||||
|
@ -132,6 +138,7 @@ void NFCTestShim::cmd_get_rf_protocols() {
|
|||
if (strlen(strSupported)) {
|
||||
strSupported[strlen(strSupported) - 1] = '\0'; // strip trailing comma
|
||||
}
|
||||
// return data as text to the plugin framework
|
||||
cmd_printf("{{protocols=%s}}", strSupported);
|
||||
set_last_nfc_error(NFC_OK);
|
||||
cmd_ready(CMDLINE_RETCODE_SUCCESS);
|
||||
|
@ -139,14 +146,15 @@ void NFCTestShim::cmd_get_rf_protocols() {
|
|||
}
|
||||
|
||||
void NFCTestShim::cmd_configure_rf_protocols(
|
||||
nfc_rf_protocols_bitmask_t protocols) {
|
||||
nfc_rf_protocols_bitmask_t protocols)
|
||||
{
|
||||
#if MBED_CONF_NFCEEPROM
|
||||
cmd_printf("EEPROM cannot set protocol()\r\n");
|
||||
set_last_nfc_error(NFC_ERR_UNSUPPORTED);
|
||||
cmd_ready(CMDLINE_RETCODE_INVALID_PARAMETERS);
|
||||
#else
|
||||
|
||||
nfc_err_t err = ((NFCProcessController*) this)->set_rf_protocols(protocols);
|
||||
nfc_err_t err = set_rf_protocols(protocols);
|
||||
set_last_nfc_error(err);
|
||||
if (NFC_OK != err) {
|
||||
cmd_ready(CMDLINE_RETCODE_FAIL);
|
||||
|
@ -156,11 +164,15 @@ void NFCTestShim::cmd_configure_rf_protocols(
|
|||
#endif
|
||||
}
|
||||
|
||||
// RETURNS: ICETEA error code asynchronously NFC error is set
|
||||
// {{bytes=XX XX XX XX.. }} are returned
|
||||
void NFCTestShim::cmd_read_nfceeprom() {
|
||||
/** \brief Copy data from the Controller buffer, or if EEPROM will initiate a read of the
|
||||
* eeprom contents which get dumped as a string {{bytes=XX XX XX XX.. }} and parsed by
|
||||
* the framework
|
||||
* \return void An ICETEA error code and NFC error is set asyncronously
|
||||
*/
|
||||
void NFCTestShim::cmd_read_nfceeprom()
|
||||
{
|
||||
#if MBED_CONF_NFCEEPROM
|
||||
((NFCProcessEEPROM*)this)->queue_read_call();
|
||||
((NFCProcessEEPROM *)this)->queue_read_call();
|
||||
cmd_printf("NFCTestShim::read_nfceeprom() exit\r\n");
|
||||
|
||||
#else
|
||||
|
@ -173,35 +185,41 @@ void NFCTestShim::cmd_read_nfceeprom() {
|
|||
#endif
|
||||
}
|
||||
|
||||
void NFCTestShim::cmd_erase() {
|
||||
void NFCTestShim::cmd_erase()
|
||||
{
|
||||
|
||||
#if MBED_CONF_NFCEEPROM
|
||||
((NFCProcessEEPROM*)this)->queue_erase_call();
|
||||
((NFCProcessEEPROM *)this)->queue_erase_call();
|
||||
|
||||
#else
|
||||
cmd_printf("erase %d bytes, last msg\r\n",
|
||||
(sizeof(_ndef_write_buffer) / sizeof(uint8_t)));
|
||||
sizeof(_ndef_write_buffer));
|
||||
_ndef_write_buffer_used = 0;
|
||||
memset(_ndef_write_buffer, 0, sizeof(_ndef_write_buffer) / sizeof(uint8_t));
|
||||
memset(_ndef_write_buffer, 0, sizeof(_ndef_write_buffer));
|
||||
set_last_nfc_error(NFC_OK); // effectively a no-op
|
||||
cmd_ready(CMDLINE_RETCODE_SUCCESS);
|
||||
#endif
|
||||
}
|
||||
|
||||
// populate buffer with really long message - length checks to be done by driver only
|
||||
void NFCTestShim::cmd_write_long(char *data) {
|
||||
/** \brief Writes a Text T record buffer with really long message - length checks to be done by driver only.
|
||||
* If an NFC controller, no write to the chip happens, we copy the data into a Controller buffer
|
||||
* \param uri This method must free the passed in pointer
|
||||
* \return void An ICETEA error code and NFC error is set asyncronously
|
||||
*/
|
||||
void NFCTestShim::cmd_write_long(char *data)
|
||||
{
|
||||
MessageBuilder builder(ndef_poster_message);
|
||||
|
||||
strcpy(NFCTestShim::long_string, data); //max_ndef - header - overheads
|
||||
strcpy(::long_string, data); //max_ndef - header - overheads
|
||||
Text text(Text::UTF8, span_from_cstr("en-US"),
|
||||
span_from_cstr((const char*) (NFCTestShim::long_string)));
|
||||
span_from_cstr((const char *)(::long_string)));
|
||||
|
||||
text.append_as_record(builder, true);
|
||||
_ndef_write_buffer_used = builder.get_message().size();
|
||||
cmd_printf("Composed NDEF message %d bytes\r\n", _ndef_write_buffer_used);
|
||||
|
||||
#if MBED_CONF_NFCEEPROM
|
||||
((NFCProcessEEPROM*)this)->queue_write_call();
|
||||
((NFCProcessEEPROM *)this)->queue_write_call();
|
||||
#else
|
||||
// not on a wire, so the caller will store the message in a buffer
|
||||
set_last_nfc_error(NFC_OK);
|
||||
|
@ -212,29 +230,31 @@ void NFCTestShim::cmd_write_long(char *data) {
|
|||
free(data);
|
||||
}
|
||||
|
||||
// PARAM: uri - this method must free the passed pointer
|
||||
// RETURNS: ICETEA error code asynchronously NFC error is set
|
||||
// An interesting side use case would be to prompt to install an app from the appstore using the tag
|
||||
void NFCTestShim::cmd_set_smartposter(char *cmdUri) {
|
||||
/** \brief Write a URI Use case would be to prompt to install an app from the appstore using the tag
|
||||
* \param uri This method must free the passed in pointer
|
||||
* \return void An ICETEA error code and NFC error is set asyncronously
|
||||
*/
|
||||
void NFCTestShim::cmd_set_smartposter(char *cmdUri)
|
||||
{
|
||||
MessageBuilder builder(ndef_poster_message);
|
||||
|
||||
uint8_t smart_poster_buffer[1024];
|
||||
MessageBuilder smart_poster_builder(smart_poster_buffer);
|
||||
|
||||
char* urlbegin = strstr(cmdUri, ".");
|
||||
char *urlbegin = strstr(cmdUri, ".");
|
||||
urlbegin++;
|
||||
URI uri(URI::HTTPS_WWW, span_from_cstr(urlbegin));
|
||||
uri.append_as_record(smart_poster_builder, true);
|
||||
|
||||
builder.append_record(
|
||||
RecordType(RecordType::well_known_type, span_from_cstr("Sp")),
|
||||
smart_poster_builder.get_message(), true);
|
||||
RecordType(RecordType::well_known_type, span_from_cstr("Sp")),
|
||||
smart_poster_builder.get_message(), true);
|
||||
|
||||
_ndef_write_buffer_used = builder.get_message().size();
|
||||
cmd_printf("Composed NDEF message %d bytes\r\n", _ndef_write_buffer_used);
|
||||
|
||||
#if MBED_CONF_NFCEEPROM
|
||||
((NFCProcessEEPROM*)this)->queue_write_call();
|
||||
((NFCProcessEEPROM *)this)->queue_write_call();
|
||||
#else
|
||||
// not on a wire, so the call just stores the message in a buffer
|
||||
set_last_nfc_error(NFC_OK);
|
||||
|
@ -245,7 +265,8 @@ void NFCTestShim::cmd_set_smartposter(char *cmdUri) {
|
|||
}
|
||||
|
||||
// disabled in EEPROMs, overridden if controller present
|
||||
void NFCTestShim::cmd_start_discovery(bool manual) {
|
||||
void NFCTestShim::cmd_start_discovery(bool manual)
|
||||
{
|
||||
#if MBED_CONF_NFCEEPROM
|
||||
cmd_printf("EEPROM cannot start_discovery()\r\n");
|
||||
set_last_nfc_error(NFC_ERR_UNSUPPORTED);
|
||||
|
@ -253,18 +274,18 @@ void NFCTestShim::cmd_start_discovery(bool manual) {
|
|||
|
||||
#else
|
||||
|
||||
// todo: remove hard coded
|
||||
// todo: Jira logged. remove hard coded protocol
|
||||
nfc_rf_protocols_bitmask_t protocols = { 0 };
|
||||
protocols.target_iso_dep = 1;
|
||||
|
||||
nfc_err_t err = ((NFCProcessController*) this)->set_rf_protocols(protocols);
|
||||
nfc_err_t err = set_rf_protocols(protocols);
|
||||
|
||||
if (manual) {
|
||||
this->set_discovery_restart_manual();
|
||||
set_discovery_restart_manual();
|
||||
} else {
|
||||
this->set_discovery_restart_auto();
|
||||
set_discovery_restart_auto();
|
||||
}
|
||||
err = this->start_discovery();
|
||||
err = start_discovery();
|
||||
set_last_nfc_error(err);
|
||||
if (NFC_OK != err) {
|
||||
cmd_ready(CMDLINE_RETCODE_FAIL);
|
||||
|
@ -275,14 +296,15 @@ void NFCTestShim::cmd_start_discovery(bool manual) {
|
|||
}
|
||||
|
||||
// disabled in EEPROMs, overridden if controller present
|
||||
void NFCTestShim::cmd_stop_discovery() {
|
||||
void NFCTestShim::cmd_stop_discovery()
|
||||
{
|
||||
|
||||
#if MBED_CONF_NFCEEPROM
|
||||
cmd_printf("EEPROM cannot stop_discovery()\r\n");
|
||||
set_last_nfc_error(NFC_ERR_UNSUPPORTED);
|
||||
cmd_ready(CMDLINE_RETCODE_INVALID_PARAMETERS);
|
||||
#else
|
||||
nfc_err_t err = this->stop_discovery();
|
||||
nfc_err_t err = stop_discovery();
|
||||
set_last_nfc_error(err);
|
||||
if (NFC_OK != err) {
|
||||
cmd_ready(CMDLINE_RETCODE_FAIL);
|
||||
|
|
|
@ -26,62 +26,36 @@
|
|||
#include "nfc/ndef/MessageBuilder.h"
|
||||
#include "nfc/ndef/common/URI.h"
|
||||
#include "nfc/ndef/common/util.h"
|
||||
#include "nfc/nfcdefinitions.h"
|
||||
#include "nfc/NFCDefinitions.h"
|
||||
|
||||
// all targets that have an EEPROM
|
||||
#if MBED_CONF_NFCEEPROM
|
||||
#define TEST_NFCEEPROM_TARGET
|
||||
#endif
|
||||
|
||||
// all targets that have a controller
|
||||
#if defined (TARGET_PN512)
|
||||
#define TEST_NFCCONTRL_TARGET
|
||||
#endif
|
||||
|
||||
#if MBED_CONF_NFCEEPROM
|
||||
#include "NFCEEPROM.h"
|
||||
#include "EEPROMDriver.h"
|
||||
|
||||
#else
|
||||
#ifdef TARGET_PN512
|
||||
#include "nfc/controllers/PN512Driver.h"
|
||||
#include "nfc/controllers/PN512SPITransportDriver.h"
|
||||
#endif
|
||||
#include "nfc/NFCRemoteInitiator.h"
|
||||
#include "nfc/NFCController.h"
|
||||
|
||||
using mbed::Span;
|
||||
using mbed::nfc::NFCRemoteInitiator;
|
||||
using mbed::nfc::NFCController;
|
||||
#endif // TEST_EEPROM_TARGET
|
||||
|
||||
using mbed::nfc::ndef::MessageBuilder;
|
||||
using mbed::nfc::ndef::common::URI;
|
||||
using mbed::nfc::ndef::common::span_from_cstr;
|
||||
using mbed::nfc::nfc_rf_protocols_bitmask_t;
|
||||
|
||||
class NFCTestShim {
|
||||
public:
|
||||
NFCTestShim();
|
||||
|
||||
static void cmd_get_last_nfc_error() {
|
||||
static void cmd_get_last_nfc_error()
|
||||
{
|
||||
get_last_nfc_error();
|
||||
}
|
||||
;
|
||||
static void cmd_set_last_nfc_error(int err) {
|
||||
static void cmd_set_last_nfc_error(int err)
|
||||
{
|
||||
set_last_nfc_error(err);
|
||||
cmd_ready (CMDLINE_RETCODE_SUCCESS);
|
||||
cmd_ready(CMDLINE_RETCODE_SUCCESS);
|
||||
}
|
||||
;
|
||||
static void cmd_get_conf_nfceeprom() {
|
||||
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();
|
||||
static void print_ndef_message(const Span<const uint8_t> &buffer,
|
||||
size_t length);
|
||||
static void print_ndef_message(const mbed::Span<const uint8_t> &buffer,
|
||||
size_t length);
|
||||
|
||||
void cmd_init();
|
||||
virtual nfc_err_t init() = 0;
|
||||
|
@ -97,32 +71,42 @@ public:
|
|||
|
||||
protected:
|
||||
// implement/declare EEPROM and Controller model underlying common BH and delegate specializations
|
||||
virtual nfc_err_t set_rf_protocols(nfc_rf_protocols_bitmask_t protocols) {return NFC_ERR_UNSUPPORTED ;};
|
||||
virtual nfc_err_t start_discovery() {return NFC_ERR_UNSUPPORTED ;};
|
||||
virtual nfc_err_t stop_discovery() {return NFC_ERR_UNSUPPORTED ;};
|
||||
void set_discovery_restart_auto() {
|
||||
virtual nfc_err_t set_rf_protocols(nfc_rf_protocols_bitmask_t protocols)
|
||||
{
|
||||
return NFC_ERR_UNSUPPORTED ;
|
||||
};
|
||||
virtual nfc_rf_protocols_bitmask_t get_rf_protocols()
|
||||
{
|
||||
|
||||
};
|
||||
virtual nfc_err_t start_discovery()
|
||||
{
|
||||
return NFC_ERR_UNSUPPORTED ;
|
||||
};
|
||||
virtual nfc_err_t stop_discovery()
|
||||
{
|
||||
return NFC_ERR_UNSUPPORTED ;
|
||||
};
|
||||
void set_discovery_restart_auto()
|
||||
{
|
||||
_discovery_restart = true;
|
||||
};
|
||||
void set_discovery_restart_manual() {
|
||||
void set_discovery_restart_manual()
|
||||
{
|
||||
_discovery_restart = false;
|
||||
};
|
||||
|
||||
|
||||
protected:
|
||||
size_t _ndef_write_buffer_used;
|
||||
Span<uint8_t> ndef_poster_message; // message to build and send
|
||||
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;
|
||||
|
||||
private:
|
||||
static int last_nfc_error;
|
||||
|
||||
static int using_eeprom;
|
||||
static char long_string[0x2000];
|
||||
};
|
||||
|
||||
// forward declare single instance
|
||||
extern NFCTestShim * pNFC_Test_Shim;
|
||||
extern NFCTestShim *pNFC_Test_Shim;
|
||||
|
||||
#endif // _NFCTESTSHIM_H_INCLUDED
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "mbed.h"
|
||||
#include "platform/FileHandle.h"
|
||||
#include "drivers/UARTSerial.h"
|
||||
|
||||
/**
|
||||
* Macros for setting console flow control.
|
||||
|
@ -29,15 +30,16 @@
|
|||
|
||||
#define SERIAL_CONSOLE_BAUD_RATE 115200
|
||||
|
||||
FileHandle *mbed::mbed_override_console(int) {
|
||||
static UARTSerial console(STDIO_UART_TX, STDIO_UART_RX,
|
||||
SERIAL_CONSOLE_BAUD_RATE);
|
||||
mbed::FileHandle *mbed::mbed_override_console(int)
|
||||
{
|
||||
static mbed::UARTSerial console(STDIO_UART_TX, STDIO_UART_RX,
|
||||
SERIAL_CONSOLE_BAUD_RATE);
|
||||
#if CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTS
|
||||
console.set_flow_control(SerialBase::RTS, STDIO_UART_RTS, NC);
|
||||
mbed::console.set_flow_control(SerialBase::RTS, STDIO_UART_RTS, NC);
|
||||
#elif CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_CTS
|
||||
console.set_flow_control(SerialBase::CTS, NC, STDIO_UART_CTS);
|
||||
mbed::console.set_flow_control(SerialBase::CTS, NC, STDIO_UART_CTS);
|
||||
#elif CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTSCTS
|
||||
console.set_flow_control(SerialBase::RTSCTS, STDIO_UART_RTS, STDIO_UART_CTS);
|
||||
mbed::console.set_flow_control(SerialBase::RTSCTS, STDIO_UART_RTS, STDIO_UART_CTS);
|
||||
#endif
|
||||
return &console;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
"""
|
||||
Copyright 2018 ARM Limited
|
||||
Copyright (c) 2017, Arm Limited and affiliates.
|
||||
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
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
"""
|
||||
Copyright 2018 ARM Limited
|
||||
Copyright (c) 2017, Arm Limited and affiliates.
|
||||
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
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
"""
|
||||
Copyright (c) 2017, Arm Limited and affiliates.
|
||||
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.
|
||||
"""
|
||||
|
||||
import nfc
|
||||
from enum import Enum
|
||||
import logging
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
"""
|
||||
Copyright 2018 ARM Limited
|
||||
Copyright (c) 2017, Arm Limited and affiliates.
|
||||
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
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
"""
|
||||
Copyright 2018 ARM Limited
|
||||
Copyright (c) 2017, Arm Limited and affiliates.
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue