mirror of https://github.com/ARMmbed/mbed-os.git
Fix compilation issues in NFC framework
parent
2568725d47
commit
3f31a95a76
|
|
@ -85,7 +85,7 @@ void ac_buffer_builder_init(ac_buffer_builder_t *pBuilder, uint8_t *data, size_t
|
|||
/** Initialize ac_buffer builder from underlying ac_buffer
|
||||
* \param pBuilder ac_buffer builder to init
|
||||
*/
|
||||
void ac_buffer_builder_from_ac_buffer(ac_buffer_builder_t *pBuilder);
|
||||
void ac_buffer_builder_from_buffer(ac_buffer_builder_t *pBuilder);
|
||||
|
||||
/** Reset ac_buffer builder
|
||||
* \param pBuilder ac_buffer builder to reset
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ void ac_buffer_builder_init(ac_buffer_builder_t *pBuilder, uint8_t *data, size_t
|
|||
ac_buffer_init(&pBuilder->ac_buffer, data, 0);
|
||||
}
|
||||
|
||||
void ac_buffer_builder_from_ac_buffer(ac_buffer_builder_t *pBuilder)
|
||||
void ac_buffer_builder_from_buffer(ac_buffer_builder_t *pBuilder)
|
||||
{
|
||||
pBuilder->data = (uint8_t *)pBuilder->ac_buffer.data;
|
||||
pBuilder->size = pBuilder->ac_buffer.size;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,11 @@
|
|||
#include "nfc/NFCControllerDriver.h"
|
||||
#include "PN512TransportDriver.h"
|
||||
|
||||
#include "nfc/acore/acore/ac_buffer.h"
|
||||
#include "nfc/acore/acore/ac_buffer_reader.h"
|
||||
#include "nfc/acore/acore/ac_buffer_builder.h"
|
||||
#include "nfc/stack/transceiver/pn512/pn512.h"
|
||||
|
||||
namespace mbed {
|
||||
namespace nfc {
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@
|
|||
#include "platform/nfc_transport.h"
|
||||
#include "PN512TransportDriver.h"
|
||||
|
||||
#include "drivers/SPI.h"
|
||||
#include "drivers/DigitalOut.h"
|
||||
#include "drivers/InterruptIn.h"
|
||||
|
||||
namespace mbed {
|
||||
namespace nfc {
|
||||
|
|
@ -33,7 +36,7 @@ public:
|
|||
|
||||
private:
|
||||
virtual void initialize();
|
||||
virtual nfc_transport_t *get_transport() const;
|
||||
virtual nfc_transport_t *get_transport();
|
||||
|
||||
void transport_write(uint8_t address, const uint8_t *outBuf, size_t outLen);
|
||||
void transport_read(uint8_t address, uint8_t *inBuf, size_t inLen);
|
||||
|
|
@ -43,10 +46,10 @@ private:
|
|||
static void s_transport_read(uint8_t address, uint8_t *inBuf, size_t inLen, void *pUser);
|
||||
|
||||
nfc_transport_t _nfc_transport;
|
||||
SPI _spi;
|
||||
DigitalOut _ssel;
|
||||
InterruptIn _irq;
|
||||
DigitalOut _rst;
|
||||
mbed::SPI _spi;
|
||||
mbed::DigitalOut _ssel;
|
||||
mbed::InterruptIn _irq;
|
||||
mbed::DigitalOut _rst;
|
||||
};
|
||||
|
||||
} // namespace nfc
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public:
|
|||
*
|
||||
* @return a pointer to a nfc_transport_t struct
|
||||
*/
|
||||
virtual nfc_transport_t *get_transport() const = 0;
|
||||
virtual nfc_transport_t *get_transport() = 0;
|
||||
|
||||
/**
|
||||
* Set this instance's delegate
|
||||
|
|
|
|||
|
|
@ -22,6 +22,11 @@
|
|||
|
||||
#include "NFCDefinitions.h"
|
||||
|
||||
#include "nfc/acore/acore/ac_buffer.h"
|
||||
#include "nfc/acore/acore/ac_buffer_reader.h"
|
||||
#include "nfc/acore/acore/ac_buffer_builder.h"
|
||||
#include "nfc/stack/tech/iso7816/iso7816_app.h"
|
||||
|
||||
namespace mbed {
|
||||
namespace nfc {
|
||||
|
||||
|
|
@ -128,7 +133,7 @@ private:
|
|||
*/
|
||||
virtual void on_exchange(Exchange *exchange) = 0;
|
||||
|
||||
nfc_tech_iso7816_app_t iso7816_app;
|
||||
nfc_tech_iso7816_app_t _iso7816_app;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
#include <stdint.h>
|
||||
#include "events/EventQueue.h"
|
||||
#include "platform/SharedPtr.h"
|
||||
#include "drivers/Timer.h"
|
||||
#include "drivers/Timeout.h"
|
||||
|
||||
#include "NFCDefinitions.h"
|
||||
#include "NFCControllerDriver.h"
|
||||
|
|
|
|||
|
|
@ -139,6 +139,7 @@ private:
|
|||
nfc_eeprom_erase_end_session
|
||||
};
|
||||
|
||||
Delegate *_delegate;
|
||||
NFCEEPROMDriver *_driver;
|
||||
bool _initialized;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
#include "NFCTarget.h"
|
||||
#include "NFCEEPROMDriver.h"
|
||||
|
||||
#include "events/EventQueue.h"
|
||||
|
||||
namespace mbed {
|
||||
namespace nfc {
|
||||
|
||||
|
|
@ -118,7 +120,7 @@ public:
|
|||
*
|
||||
* @param[in] queue the queue instance to use
|
||||
*/
|
||||
void set_event_queue(EventQueue *queue);
|
||||
void set_event_queue(events::EventQueue *queue);
|
||||
|
||||
/**
|
||||
* Reset and initialize the EEPROM.
|
||||
|
|
@ -188,11 +190,11 @@ public:
|
|||
|
||||
protected:
|
||||
Delegate *delegate();
|
||||
EventQueue *event_queue();
|
||||
events::EventQueue *event_queue();
|
||||
|
||||
private:
|
||||
Delegate *_delegate;
|
||||
EventQueue *_event_queue;
|
||||
events::EventQueue *_event_queue;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,6 +21,11 @@
|
|||
|
||||
#include "NFCDefinitions.h"
|
||||
|
||||
#include "nfc/stack/ndef/ndef.h"
|
||||
#include "nfc/acore/acore/ac_buffer.h"
|
||||
#include "nfc/acore/acore/ac_buffer_reader.h"
|
||||
#include "nfc/acore/acore/ac_buffer_builder.h"
|
||||
|
||||
namespace mbed {
|
||||
namespace nfc {
|
||||
|
||||
|
|
|
|||
|
|
@ -99,12 +99,27 @@ protected:
|
|||
/**
|
||||
* Mark endpoint as connected
|
||||
*/
|
||||
void connected();
|
||||
virtual void connected() = 0;
|
||||
|
||||
/**
|
||||
* Mark endpoint as disconnected
|
||||
*/
|
||||
void disconnected();
|
||||
virtual void disconnected() = 0;
|
||||
|
||||
/**
|
||||
* Retrieve NFCController instance
|
||||
* @return a pointer to the NFController instance that created this endpoint.
|
||||
*/
|
||||
NFCController *nfc_controller();
|
||||
|
||||
/**
|
||||
* Retrieve NFCController instance
|
||||
* @return a pointer to the NFController instance that created this endpoint.
|
||||
*/
|
||||
const NFCController *nfc_controller() const;
|
||||
|
||||
private:
|
||||
NFCController *_controller;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include "NFCDefinitions.h"
|
||||
#include "NFCRemoteEndpoint.h"
|
||||
#include "NFCNDEFCapable.h"
|
||||
#include "ISO7816App.h"
|
||||
|
||||
namespace mbed {
|
||||
namespace nfc {
|
||||
|
|
@ -62,7 +63,7 @@ public:
|
|||
*
|
||||
* @oaram[in] delegate the delegate instance to use
|
||||
*/
|
||||
void set_remote_initiator_delegate(Delegate *delegate);
|
||||
void set_delegate(Delegate *delegate);
|
||||
|
||||
/**
|
||||
* Retrieve the NFC tag type exposed by the controller to communicate with the initiator.
|
||||
|
|
@ -85,6 +86,10 @@ public:
|
|||
*/
|
||||
virtual void add_iso7816_application(ISO7816App *application) = 0;
|
||||
|
||||
protected:
|
||||
virtual void connected();
|
||||
virtual void disconnected();
|
||||
|
||||
private:
|
||||
Delegate *_delegate;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#include "NFCDefinitions.h"
|
||||
#include "NFCEndpoint.h"
|
||||
#include "NFCNDEFCapable.h"
|
||||
|
||||
namespace mbed {
|
||||
|
|
@ -51,7 +50,7 @@ public:
|
|||
*/
|
||||
virtual ~NFCTarget();
|
||||
|
||||
struct Delegate {
|
||||
struct Delegate : NFCNDEFCapable::Delegate {
|
||||
/**
|
||||
* The NDEF message erasing request completed.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -24,7 +24,10 @@
|
|||
#include "NFCNDEFCapable.h"
|
||||
#include "NFCRemoteInitiator.h"
|
||||
|
||||
#include "acore/ac_buffer.h"
|
||||
#include "nfc/acore/acore/ac_buffer.h"
|
||||
#include "nfc/acore/acore/ac_buffer_reader.h"
|
||||
#include "nfc/acore/acore/ac_buffer_builder.h"
|
||||
#include "nfc/stack/tech/type4/type4_target.h"
|
||||
|
||||
namespace mbed {
|
||||
namespace nfc {
|
||||
|
|
@ -38,7 +41,7 @@ namespace nfc {
|
|||
* This class is an implementation of the Type 4 tag application.
|
||||
*/
|
||||
class Type4RemoteInitiator : public NFCRemoteInitiator {
|
||||
private:
|
||||
public:
|
||||
/**
|
||||
* Create a Type4RemoteInitiator.
|
||||
*
|
||||
|
|
@ -72,7 +75,6 @@ private:
|
|||
void disconnected_callback(bool deselected);
|
||||
static void s_disconnected_callback(nfc_tech_iso7816_t *pIso7816, bool deselected, void *pUserData);
|
||||
|
||||
NFCController *_controller;
|
||||
bool _is_connected;
|
||||
bool _is_disconnected;
|
||||
nfc_tech_iso7816_t _iso7816;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
|
||||
#include "PN512Driver.h"
|
||||
|
||||
#include "nfc/stack/platform/nfc_debug.h"
|
||||
|
||||
using namespace mbed;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ PN512SPITransportDriver::PN512SPITransportDriver(PinName mosi, PinName miso, Pin
|
|||
_spi.format(8, 0);
|
||||
|
||||
// The PN512 supports SPI clock frequencies up to 10MHz, so use this if we can
|
||||
_spi.frequency(10E6UL);
|
||||
_spi.frequency(10000000UL);
|
||||
|
||||
// Initialize NFC transport
|
||||
nfc_transport_init(&_nfc_transport, &PN512SPITransportDriver::s_transport_write, &PN512SPITransportDriver::s_transport_read, this);
|
||||
|
|
@ -42,7 +42,7 @@ PN512SPITransportDriver::PN512SPITransportDriver(PinName mosi, PinName miso, Pin
|
|||
void PN512SPITransportDriver::initialize()
|
||||
{
|
||||
// Deactivate IRQ
|
||||
_irq.rise(callback(NULL));
|
||||
_irq.rise(callback<void>());
|
||||
|
||||
// Assert reset pin
|
||||
// According to the datasheet, it needs to be asserted for at least 100ns
|
||||
|
|
@ -55,7 +55,7 @@ void PN512SPITransportDriver::initialize()
|
|||
_irq.rise(callback(this, &PN512SPITransportDriver::hw_interrupt));
|
||||
}
|
||||
|
||||
nfc_transport_t *PN512SPITransportDriver::get_transport() const
|
||||
nfc_transport_t *PN512SPITransportDriver::get_transport()
|
||||
{
|
||||
return &_nfc_transport;
|
||||
}
|
||||
|
|
@ -98,13 +98,13 @@ void PN512SPITransportDriver::transport_read(uint8_t address, uint8_t *inBuf, si
|
|||
}
|
||||
|
||||
// Callbacks from munfc
|
||||
static void PN512SPITransportDriver::s_transport_write(uint8_t address, const uint8_t *outBuf, size_t outLen, void *pUser)
|
||||
void PN512SPITransportDriver::s_transport_write(uint8_t address, const uint8_t *outBuf, size_t outLen, void *pUser)
|
||||
{
|
||||
PN512SPITransportDriver *self = (PN512SPITransportDriver *)pUser;
|
||||
self->transport_write(address, outBuf, outLen);
|
||||
}
|
||||
|
||||
static void PN512SPITransportDriver::s_transport_read(uint8_t address, uint8_t *inBuf, size_t inLen, void *pUser)
|
||||
void PN512SPITransportDriver::s_transport_read(uint8_t address, uint8_t *inBuf, size_t inLen, void *pUser)
|
||||
{
|
||||
PN512SPITransportDriver *self = (PN512SPITransportDriver *)pUser;
|
||||
self->transport_read(address, inBuf, inLen);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ nfc_err_t NFCController::initialize()
|
|||
_scheduler = transceiver_get_scheduler(_transceiver);
|
||||
|
||||
// Run scheduler for the first time
|
||||
_queue->call(this, NFCController::scheduler_process, false);
|
||||
_queue->call(this, &NFCController::scheduler_process, false);
|
||||
|
||||
return NFC_OK;
|
||||
}
|
||||
|
|
@ -143,7 +143,7 @@ void NFCController::polling_callback(nfc_err_t ret)
|
|||
if (!transceiver_is_initiator_mode(_transceiver)) {
|
||||
nfc_tech_t active_tech = transceiver_get_active_techs(_transceiver);
|
||||
if (active_tech.nfc_iso_dep_a || active_tech.nfc_iso_dep_b) {
|
||||
Type4RemoteInitiator type4_remote_initiator_ptr = new (std::nothrow) Type4RemoteInitiator(_transceiver, _ndef_buffer, _ndef_buffer_sz);
|
||||
Type4RemoteInitiator *type4_remote_initiator_ptr = new (std::nothrow) Type4RemoteInitiator(this, _ndef_buffer, _ndef_buffer_sz);
|
||||
if (type4_remote_initiator_ptr == NULL) {
|
||||
// No memory :(
|
||||
SharedPtr<NFCRemoteInitiator> type4_remote_initiator(type4_remote_initiator_ptr);
|
||||
|
|
@ -156,19 +156,19 @@ void NFCController::polling_callback(nfc_err_t ret)
|
|||
}
|
||||
|
||||
if (_delegate != NULL) {
|
||||
NFCController::Delegate::nfc_discovery_terminated_reason_t reason;
|
||||
Delegate::nfc_discovery_terminated_reason_t reason;
|
||||
|
||||
// Map reason
|
||||
switch (ret) {
|
||||
case NFC_OK:
|
||||
reason = nfc_discovery_terminated_completed;
|
||||
reason = Delegate::nfc_discovery_terminated_completed;
|
||||
break;
|
||||
case NFC_ERR_ABORTED:
|
||||
reason = nfc_discovery_terminated_canceled;
|
||||
reason = Delegate::nfc_discovery_terminated_canceled;
|
||||
break;
|
||||
default:
|
||||
// Any other error code means there was an error during the discovery process
|
||||
reason = nfc_discovery_terminated_rf_error;
|
||||
reason = Delegate::nfc_discovery_terminated_rf_error;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -190,16 +190,16 @@ void NFCController::on_hw_interrupt()
|
|||
{
|
||||
// Run scheduler - this is called in interrupt context
|
||||
_timeout.detach(); // Cancel timeout - if it triggers anyways, it's ok
|
||||
_queue->call(this, NFCController::scheduler_process, true);
|
||||
_queue->call(this, &NFCController::scheduler_process, true);
|
||||
}
|
||||
|
||||
void NFCController::on_timeout()
|
||||
{
|
||||
// Run scheduler - this is called in interrupt context
|
||||
_queue->call(this, NFCController::scheduler_process, false);
|
||||
_queue->call(this, &NFCController::scheduler_process, false);
|
||||
}
|
||||
|
||||
static void NFCController::s_polling_callback(nfc_transceiver_t *pTransceiver, nfc_err_t ret, void *pUserData)
|
||||
void NFCController::s_polling_callback(nfc_transceiver_t *pTransceiver, nfc_err_t ret, void *pUserData)
|
||||
{
|
||||
NFCController *self = (NFCController *) pUserData;
|
||||
self->polling_callback(ret);
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@
|
|||
using namespace mbed;
|
||||
using namespace mbed::nfc;
|
||||
|
||||
NFCEEPROM(NFCEEPROMDriver *driver, events::EventQueue *queue, uint8_t *ndef_buffer, size_t ndef_buffer_sz) : NFCTarget(ndef_buffer, ndef_buffer_sz)
|
||||
_driver(driver), _initialized(false), _current_op(nfc_eeprom_idle), _ndef_buffer_read_sz(0), _eeprom_address(0), _operation_result(NFC_ERR_UNKNOWN)
|
||||
NFCEEPROM::NFCEEPROM(NFCEEPROMDriver *driver, events::EventQueue *queue, uint8_t *ndef_buffer, size_t ndef_buffer_sz) : NFCTarget(ndef_buffer, ndef_buffer_sz),
|
||||
_delegate(NULL), _driver(driver), _initialized(false), _current_op(nfc_eeprom_idle), _ndef_buffer_read_sz(0), _eeprom_address(0), _operation_result(NFC_ERR_UNKNOWN)
|
||||
{
|
||||
_driver->set_delegate(this);
|
||||
_driver->set_event_queue(queue);
|
||||
|
|
@ -40,6 +40,7 @@ nfc_err_t NFCEEPROM::initialize()
|
|||
void NFCEEPROM::set_delegate(NFCEEPROM::Delegate *delegate)
|
||||
{
|
||||
_delegate = delegate;
|
||||
set_ndef_delegate(delegate);
|
||||
}
|
||||
|
||||
void NFCEEPROM::write_ndef_message()
|
||||
|
|
@ -58,24 +59,24 @@ void NFCEEPROM::write_ndef_message()
|
|||
_current_op = nfc_eeprom_write_start_session;
|
||||
|
||||
// Retrieve reader
|
||||
ac_buffer_dup(&_ndef_buffer_reader, ac_buffer_builder_buffer(ndef_msg_buffer_builder(ndef_message()));
|
||||
ac_buffer_dup(&_ndef_buffer_reader, ac_buffer_builder_buffer(ndef_msg_buffer_builder(ndef_message())));
|
||||
|
||||
// Check that NDEF message is not too big
|
||||
// Check that NDEF message is not too big
|
||||
if (ac_buffer_reader_readable(&_ndef_buffer_reader) > _driver->get_max_size()) {
|
||||
handle_error(NFC_ERR_BUFFER_TOO_SMALL);
|
||||
handle_error(NFC_ERR_BUFFER_TOO_SMALL);
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset EEPROM address
|
||||
_eeprom_address = 0;
|
||||
|
||||
// Go through the steps!
|
||||
_driver->start_session();
|
||||
// Go through the steps!
|
||||
_driver->start_session();
|
||||
|
||||
// 1 - Start session
|
||||
// 2 - Write bytes (can be repeated)
|
||||
// 3 - Set NDEF message size
|
||||
// 4 - End session
|
||||
// 1 - Start session
|
||||
// 2 - Write bytes (can be repeated)
|
||||
// 3 - Set NDEF message size
|
||||
// 4 - End session
|
||||
}
|
||||
|
||||
void NFCEEPROM::read_ndef_message()
|
||||
|
|
@ -155,7 +156,7 @@ void NFCEEPROM::on_session_started(bool success)
|
|||
handle_error(NFC_ERR_CONTROLLER);
|
||||
return;
|
||||
}
|
||||
_current_op = nfc_eeprom_erase_bytes;
|
||||
_current_op = nfc_eeprom_erase_erase_bytes;
|
||||
continue_erase();
|
||||
break;
|
||||
|
||||
|
|
@ -176,7 +177,7 @@ void NFCEEPROM::on_session_ended(bool success)
|
|||
}
|
||||
_current_op = nfc_eeprom_idle;
|
||||
if (_delegate != NULL) {
|
||||
_driver->on_ndef_message_written(_operation_result);
|
||||
_delegate->on_ndef_message_written(_operation_result);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -191,7 +192,7 @@ void NFCEEPROM::on_session_ended(bool success)
|
|||
ndef_msg_decode(ndef_message());
|
||||
|
||||
if (_delegate != NULL) {
|
||||
_driver->on_ndef_message_read(_operation_result);
|
||||
_delegate->on_ndef_message_read(_operation_result);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -202,7 +203,7 @@ void NFCEEPROM::on_session_ended(bool success)
|
|||
}
|
||||
_current_op = nfc_eeprom_idle;
|
||||
if (_delegate != NULL) {
|
||||
_driver->on_ndef_message_erased(_operation_result);
|
||||
_delegate->on_ndef_message_erased(_operation_result);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -216,7 +217,7 @@ void NFCEEPROM::on_session_ended(bool success)
|
|||
void NFCEEPROM::on_bytes_read(size_t count)
|
||||
{
|
||||
switch (_current_op) {
|
||||
case nfc_eeprom_read_read_bytes:
|
||||
case nfc_eeprom_read_read_bytes: {
|
||||
if (count == 0) {
|
||||
handle_error(NFC_ERR_CONTROLLER);
|
||||
return;
|
||||
|
|
@ -230,6 +231,7 @@ void NFCEEPROM::on_bytes_read(size_t count)
|
|||
// Continue reading
|
||||
continue_read();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// Should not happen, state machine is broken or driver is doing something wrong
|
||||
handle_error(NFC_ERR_UNKNOWN);
|
||||
|
|
@ -295,7 +297,7 @@ void NFCEEPROM::on_size_written(bool success)
|
|||
void NFCEEPROM::on_size_read(bool success, size_t size)
|
||||
{
|
||||
switch (_current_op) {
|
||||
case nfc_eeprom_read_read_size:
|
||||
case nfc_eeprom_read_read_size: {
|
||||
if (!success) {
|
||||
handle_error(NFC_ERR_CONTROLLER);
|
||||
return;
|
||||
|
|
@ -322,6 +324,7 @@ void NFCEEPROM::on_size_read(bool success, size_t size)
|
|||
_current_op = nfc_eeprom_read_read_bytes;
|
||||
continue_read();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// Should not happen, state machine is broken or driver is doing something wrong
|
||||
handle_error(NFC_ERR_UNKNOWN);
|
||||
|
|
|
|||
|
|
@ -34,17 +34,17 @@ void NFCEEPROMDriver::set_delegate(Delegate *delegate)
|
|||
_delegate = delegate;
|
||||
}
|
||||
|
||||
void NFCEEPROMDriver::set_event_queue(EventQueue *queue)
|
||||
void NFCEEPROMDriver::set_event_queue(events::EventQueue *queue)
|
||||
{
|
||||
_event_queue = queue;
|
||||
}
|
||||
|
||||
Delegate *NFCEEPROMDriver::delegate()
|
||||
NFCEEPROMDriver::Delegate *NFCEEPROMDriver::delegate()
|
||||
{
|
||||
return _delegate;
|
||||
}
|
||||
|
||||
EventQueue *NFCEEPROMDriver::event_queue()
|
||||
events::EventQueue *NFCEEPROMDriver::event_queue()
|
||||
{
|
||||
return _event_queue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
|
||||
#include "NFCRemoteEndpoint.h"
|
||||
#include "NFCController.h"
|
||||
|
||||
#include "acore/ac_buffer.h"
|
||||
#include "acore/ac_buffer_reader.h"
|
||||
|
|
@ -25,21 +26,16 @@
|
|||
using namespace mbed;
|
||||
using namespace mbed::nfc;
|
||||
|
||||
NFCRemoteEndpoint::NFCRemoteEndpoint(NFCController *controller) : _controller(controller), _is_lost(false)
|
||||
NFCRemoteEndpoint::NFCRemoteEndpoint(NFCController *controller) : _controller(controller)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool NFCRemoteEndpoint::is_lost() const
|
||||
{
|
||||
return _is_lost;
|
||||
}
|
||||
|
||||
nfc_rf_protocols_bitmask_t NFCRemoteEndpoint::rf_protocols()
|
||||
{
|
||||
nfc_rf_protocols_bitmask_t rf_protocols = {0};
|
||||
nfc_tech_t active_tech = transceiver_get_active_techs(_transceiver);
|
||||
if (!transceiver_is_initiator_mode(_transceiver)) {
|
||||
nfc_tech_t active_tech = transceiver_get_active_techs(_controller->transceiver());
|
||||
if (!transceiver_is_initiator_mode(_controller->transceiver())) {
|
||||
// Note: We only support ISO-DEP for now
|
||||
rf_protocols.target_iso_dep = active_tech.nfc_iso_dep_a || active_tech.nfc_iso_dep_b;
|
||||
}
|
||||
|
|
@ -47,12 +43,12 @@ nfc_rf_protocols_bitmask_t NFCRemoteEndpoint::rf_protocols()
|
|||
return rf_protocols;
|
||||
}
|
||||
|
||||
void NFCRemoteEndpoint::set_lost()
|
||||
{
|
||||
_is_lost = true;
|
||||
}
|
||||
|
||||
NFCController *NFCRemoteEndpoint::nfc_controller() const
|
||||
NFCController *NFCRemoteEndpoint::nfc_controller()
|
||||
{
|
||||
return _controller;
|
||||
}
|
||||
|
||||
const NFCController *NFCRemoteEndpoint::nfc_controller() const
|
||||
{
|
||||
return _controller;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,22 @@ NFCRemoteInitiator::~NFCRemoteInitiator()
|
|||
|
||||
}
|
||||
|
||||
void NFCRemoteInitiator::set_remote_initiator_delegate(Delegate *delegate)
|
||||
void NFCRemoteInitiator::set_delegate(Delegate *delegate)
|
||||
{
|
||||
_delegate = delegate;
|
||||
set_ndef_delegate(delegate);
|
||||
}
|
||||
|
||||
void NFCRemoteInitiator::connected()
|
||||
{
|
||||
if (_delegate != NULL) {
|
||||
_delegate->on_connected();
|
||||
}
|
||||
}
|
||||
|
||||
void NFCRemoteInitiator::disconnected()
|
||||
{
|
||||
if (_delegate != NULL) {
|
||||
_delegate->on_disconnected();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
|
||||
#include "Type4RemoteInitiator.h"
|
||||
#include "NFCController.h"
|
||||
|
||||
#include "acore/ac_buffer.h"
|
||||
#include "acore/ac_buffer_reader.h"
|
||||
|
|
@ -29,11 +30,11 @@ using namespace mbed;
|
|||
using namespace mbed::nfc;
|
||||
|
||||
Type4RemoteInitiator::Type4RemoteInitiator(NFCController *controller, uint8_t *buffer, size_t buffer_size) :
|
||||
NFCRemoteInitiator(ndef_buffer, ndef_buffer_sz),
|
||||
_controller(controller), _is_connected(false), _is_disconnected(false), _apps(NULL)
|
||||
NFCRemoteInitiator(controller, buffer, buffer_size),
|
||||
_is_connected(false), _is_disconnected(false)
|
||||
{
|
||||
// Init ISO7816
|
||||
nfc_tech_iso7816_init(&_iso7816, _controller->transceiver(), &Type4RemoteInitiator::s_disconnected_callback, this);
|
||||
nfc_tech_iso7816_init(&_iso7816, nfc_controller()->transceiver(), &Type4RemoteInitiator::s_disconnected_callback, this);
|
||||
|
||||
// Init Type 4 app
|
||||
nfc_tech_type4_target_init(&_type4, &_iso7816, ndef_message());
|
||||
|
|
@ -87,8 +88,8 @@ bool Type4RemoteInitiator::is_disconnected() const
|
|||
nfc_rf_protocols_bitmask_t Type4RemoteInitiator::rf_protocols()
|
||||
{
|
||||
nfc_rf_protocols_bitmask_t rf_protocols = {0};
|
||||
nfc_tech_t active_tech = transceiver_get_active_techs(_transceiver);
|
||||
if (!transceiver_is_initiator_mode(_transceiver)) {
|
||||
nfc_tech_t active_tech = transceiver_get_active_techs(nfc_controller()->transceiver());
|
||||
if (!transceiver_is_initiator_mode(nfc_controller()->transceiver())) {
|
||||
// We only support ISO-DEP
|
||||
rf_protocols.target_iso_dep = active_tech.nfc_iso_dep_a || active_tech.nfc_iso_dep_b;
|
||||
}
|
||||
|
|
@ -96,9 +97,9 @@ nfc_rf_protocols_bitmask_t Type4RemoteInitiator::rf_protocols()
|
|||
return rf_protocols;
|
||||
}
|
||||
|
||||
virtual nfc_tag_type_t Type4RemoteInitiator::nfc_tag_type() const
|
||||
nfc_tag_type_t Type4RemoteInitiator::nfc_tag_type() const
|
||||
{
|
||||
nfc_tech_t active_tech = transceiver_get_active_techs(_transceiver);
|
||||
nfc_tech_t active_tech = transceiver_get_active_techs(nfc_controller()->transceiver());
|
||||
if (active_tech.nfc_iso_dep_a) {
|
||||
return nfc_tag_type_4a;
|
||||
} else { // if(active_tech.nfc_iso_dep_b)
|
||||
|
|
@ -106,17 +107,17 @@ virtual nfc_tag_type_t Type4RemoteInitiator::nfc_tag_type() const
|
|||
}
|
||||
}
|
||||
|
||||
virtual bool Type4RemoteInitiator::is_iso7816_supported() const
|
||||
bool Type4RemoteInitiator::is_iso7816_supported() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void Type4RemoteInitiator::add_iso7816_application(ISO7816App *application)
|
||||
void Type4RemoteInitiator::add_iso7816_application(ISO7816App *application)
|
||||
{
|
||||
nfc_tech_iso7816_add_app(&_iso7816, application->_iso7816_app);
|
||||
nfc_tech_iso7816_add_app(&_iso7816, &application->_iso7816_app);
|
||||
}
|
||||
|
||||
virtual bool Type4RemoteInitiator::is_ndef_supported() const
|
||||
bool Type4RemoteInitiator::is_ndef_supported() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue