Skip to content

Commit 71f7156

Browse files
author
Donatien Garnier
committed
Fix a bunch of compilation issues, thanks @pan-
1 parent 04a7962 commit 71f7156

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+275
-153
lines changed

features/nfc/controllers/PN512TransportDriver.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,22 @@ class PN512TransportDriver {
3535
/**
3636
* Called when the PN512 asserts the interrupt line
3737
*/
38-
void on_hw_interrupt();
38+
virtual void on_hw_interrupt() {}
39+
40+
protected:
41+
~Delegate() {}
3942
};
4043

4144
/**
4245
* Create a PN512TransportDriver instance
4346
*/
4447
PN512TransportDriver();
4548

49+
/**
50+
* PN512TransportDriver destructor.
51+
*/
52+
virtual ~PN512TransportDriver();
53+
4654
/**
4755
* Initialize transport driver and perform a chip reset
4856
*/

features/nfc/nfc/ISO7816App.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Type4RemoteInitiator;
3636
* This base class represents an ISO7816-4 application.
3737
*/
3838
class ISO7816App {
39+
public:
3940
/**
4041
* This class describes an ISO7816-4 exchange (Command/Response).
4142
*/
@@ -91,7 +92,12 @@ class ISO7816App {
9192
/**
9293
* Construct ISO7816 app instance
9394
*/
94-
ISO7816App();
95+
ISO7816App() {}
96+
97+
/**
98+
* ISO7816App destructor
99+
*/
100+
virtual ~ISO7816App();
95101

96102
private:
97103
friend class Type4RemoteInitiator;

features/nfc/nfc/NFCController.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ class NFCController : private NFCControllerDriver::Delegate {
8080
* @param[in] the NFCRemoteTarget instance
8181
*/
8282
virtual void on_nfc_target_discovered(const SharedPtr<NFCRemoteTarget> &nfc_target) {}
83+
84+
protected:
85+
~Delegate() { }
8386
};
8487

8588
/**

features/nfc/nfc/NFCControllerDriver.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include "stack/nfc_errors.h"
2424
#include "stack/transceiver/transceiver.h"
25-
#include "stack/platform/scheduler.h"
25+
#include "stack/platform/nfc_scheduler.h"
2626

2727
namespace mbed {
2828
namespace nfc {
@@ -37,11 +37,17 @@ namespace nfc {
3737
* Implementers need to derive from this class and implement its methods.
3838
*/
3939
class NFCControllerDriver {
40+
public:
4041
/**
4142
* Instantiate a NFCControllerDriver
4243
*/
4344
NFCControllerDriver();
4445

46+
/**
47+
* NFCControllerDriver destructor
48+
*/
49+
virtual ~NFCControllerDriver();
50+
4551
/**
4652
* The NFCControllerDriver delegate
4753
*/
@@ -50,6 +56,9 @@ class NFCControllerDriver {
5056
* Called when the controller asserts the interrupt line
5157
*/
5258
virtual void on_hw_interrupt() {}
59+
60+
protected:
61+
virtual ~Delegate() {}
5362
};
5463

5564
/**

features/nfc/nfc/NFCEEPROM.h

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define MBED_NFC_EEPROM_H
1919

2020
#include <stdint.h>
21+
#include "events/EventQueue.h"
2122

2223
#include "NFCDefinitions.h"
2324
#include "NFCTarget.h"
@@ -58,6 +59,29 @@ class NFCEEPROM : public NFCTarget, public NFCEEPROMDriver::Delegate {
5859
* The NFCEEPROM delegate. Users of the NFCEEPROM class need to implement this delegate's methods to receive events.
5960
*/
6061
struct Delegate : NFCTarget::Delegate {
62+
/**
63+
* The NDEF message erasing request completed.
64+
*
65+
* @param[in] result NFC_OK or an error code on failure
66+
*/
67+
virtual void on_ndef_message_erased(nfc_err_t result) {}
68+
69+
/**
70+
* The NDEF message writing request completed.
71+
*
72+
* @param[in] result NFC_OK or an error code on failure
73+
*/
74+
virtual void on_ndef_message_written(nfc_err_t result) {}
75+
76+
/**
77+
* The NDEF message reading request completed.
78+
*
79+
* @param[in] result NFC_OK or an error code on failure
80+
*/
81+
virtual void on_ndef_message_read(nfc_err_t result) {}
82+
83+
protected:
84+
~Delegate() {}
6185
};
6286

6387
/**
@@ -96,15 +120,15 @@ class NFCEEPROM : public NFCTarget, public NFCEEPROMDriver::Delegate {
96120
void continue_read();
97121
void continue_erase();
98122

99-
enum class nfc_eeprom_operation_t {
123+
enum nfc_eeprom_operation_t {
100124
nfc_eeprom_idle,
101125

102126
nfc_eeprom_write_start_session,
103127
nfc_eeprom_write_write_bytes,
104128
nfc_eeprom_write_write_size,
105129
nfc_eeprom_write_end_session,
106130

107-
nfc_eeprom_write_start_session,
131+
nfc_eeprom_read_start_session,
108132
nfc_eeprom_read_read_size,
109133
nfc_eeprom_read_read_bytes,
110134
nfc_eeprom_read_end_session,
@@ -119,7 +143,7 @@ class NFCEEPROM : public NFCTarget, public NFCEEPROMDriver::Delegate {
119143
bool _initialized;
120144

121145
nfc_eeprom_operation_t _current_op;
122-
buffer_t _ndef_buffer_reader;
146+
ac_buffer_t _ndef_buffer_reader;
123147
size_t _ndef_buffer_read_sz;
124148
uint32_t _eeprom_address;
125149
nfc_err_t _operation_result;

features/nfc/nfc/NFCEEPROMDriver.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ class NFCEEPROMDriver {
4242
*/
4343
NFCEEPROMDriver();
4444

45+
/**
46+
* NFCEEPROM driver destructor.
47+
*/
48+
virtual ~NFCEEPROMDriver();
49+
4550
/**
4651
* The NFCEEPROMDriver delegate.
4752
* Methods in this class are called by the driver on completion of long-running operations.
@@ -96,6 +101,9 @@ class NFCEEPROMDriver {
96101
* @param[in] count number of bytes actually erased
97102
*/
98103
virtual void on_bytes_erased(size_t count) = 0;
104+
105+
protected:
106+
~Delegate() {}
99107
};
100108

101109
/**

features/nfc/nfc/NFCNDEFCapable.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ class NFCNDEFCapable {
7171
{
7272
return 0;
7373
}
74+
75+
protected:
76+
~Delegate() {}
7477
};
7578

7679
/**
@@ -104,10 +107,10 @@ class NFCNDEFCapable {
104107

105108
private:
106109
// Callbacks from NDEF stack
107-
static nfc_err_t s_ndef_encode(ndef_msg_t *pTag, buffer_builder_t *pBufferBldr, void *pUserData);
108-
static nfc_err_t s_ndef_decode(ndef_msg_t *pTag, buffer_t *pBuffer, void *pUserData);
109-
nfc_err_t ndef_encode(buffer_builder_t *pBufferBldr);
110-
nfc_err_t ndef_decode(buffer_t *pBuffer);
110+
static nfc_err_t s_ndef_encode(ndef_msg_t *pTag, ac_buffer_builder_t *pBufferBldr, void *pUserData);
111+
static nfc_err_t s_ndef_decode(ndef_msg_t *pTag, ac_buffer_t *pBuffer, void *pUserData);
112+
nfc_err_t ndef_encode(ac_buffer_builder_t *pBufferBldr);
113+
nfc_err_t ndef_decode(ac_buffer_t *pBuffer);
111114

112115

113116
Delegate *_delegate;

features/nfc/nfc/NFCRemoteEndpoint.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ class NFCController;
3737
*/
3838
class NFCRemoteEndpoint {
3939
public:
40-
NFCRemoteEndpoint();
40+
/**
41+
* Create a NFCRemoteEndpointinstance
42+
* @param[in] controller the NFCController instance that detected this endpoint
43+
*/
44+
NFCRemoteEndpoint(NFCController *controller);
45+
46+
virtual ~NFCRemoteEndpoint();
4147

4248
/**
4349
* The NFCRemoteEndpoint base delegate.
@@ -46,12 +52,15 @@ class NFCRemoteEndpoint {
4652
/**
4753
* This method is called when the endpoint is connected
4854
*/
49-
virtual void on_connected() {};
55+
virtual void on_connected() {}
5056

5157
/**
5258
* This method is called when the endpoint is lost (air interface link disconnnected)
5359
*/
54-
virtual void on_disconnected() {};
60+
virtual void on_disconnected() {}
61+
62+
protected:
63+
~Delegate() {}
5564
};
5665

5766
/**

features/nfc/nfc/NFCRemoteInitiator.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,19 @@ class NFCRemoteInitiator : public NFCRemoteEndpoint, public NFCNDEFCapable {
4242
public:
4343
/**
4444
* Create a NFCRemoteInitiator.
45+
* @param[in] controller the NFCController instance that detected this endpoint
4546
* @param[in] buffer a bytes array used to store NDEF messages
4647
* @param[in] buffer_size the array size in bytes
4748
*/
48-
NFCRemoteInitiator(uint8_t *buffer, size_t buffer_size);
49+
NFCRemoteInitiator(NFCController *controller, uint8_t *buffer, size_t buffer_size);
4950
virtual ~NFCRemoteInitiator();
5051

5152
/**
5253
* The NFCRemoteInitiator delegate. Users of the NFCRemoteInitiator class need to implement this delegate's methods to receive events.
5354
*/
54-
struct Delegate : NFCEndpoint::Delegate, NFCNDEFCapable::Delegate {
55-
55+
struct Delegate : NFCRemoteEndpoint::Delegate, NFCNDEFCapable::Delegate {
56+
protected:
57+
~Delegate() {}
5658
};
5759

5860
/**

features/nfc/nfc/NFCTarget.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ class NFCTarget : public NFCNDEFCapable {
4545
* @param[in] buffer_size the array size in bytes
4646
*/
4747
NFCTarget(uint8_t *buffer, size_t buffer_size);
48+
49+
/**
50+
* NFCTarget destructor
51+
*/
4852
virtual ~NFCTarget();
4953

5054
struct Delegate {
@@ -68,6 +72,9 @@ class NFCTarget : public NFCNDEFCapable {
6872
* @param[in] result NFC_OK or an error code on failure
6973
*/
7074
virtual void on_ndef_message_read(nfc_err_t result) {}
75+
76+
protected:
77+
~Delegate() {}
7178
};
7279

7380
/**

features/nfc/nfc/Type4RemoteInitiator.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,16 @@ class Type4RemoteInitiator : public NFCRemoteInitiator {
4848
*/
4949
Type4RemoteInitiator(NFCController *controller, uint8_t *buffer, size_t buffer_size);
5050

51+
/**
52+
* Type4RemoteInitiator destructor.
53+
*/
54+
virtual ~Type4RemoteInitiator();
55+
5156
// NFCRemoteEndpoint implementation
5257
virtual nfc_err_t connect();
5358
virtual nfc_err_t disconnect();
54-
virtual bool is_connected();
55-
virtual bool is_disconnected();
59+
virtual bool is_connected() const;
60+
virtual bool is_disconnected() const;
5661
virtual nfc_rf_protocols_bitmask_t rf_protocols();
5762

5863
// NFCRemoteInitiator implementation

features/nfc/source/controllers/PN512Driver.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
*/
1616

1717
#include "PN512Driver.h"
18+
#include "nfc/stack/platform/nfc_debug.h"
19+
20+
using namespace mbed;
21+
using namespace mbed::nfc;
1822

1923
PN512Driver::PN512Driver(PN512TransportDriver *transport_driver) : NFCControllerDriver(), _transport_driver(transport_driver)
2024
{
@@ -26,14 +30,14 @@ nfc_transceiver_t *PN512Driver::initialize(nfc_scheduler_timer_t *scheduler_time
2630
// Initialize transport
2731
_transport_driver->initialize();
2832

29-
nfc_err_t ret = pn512_init(&pn512, _transport_driver->get_transport(), scheduler_timer);
33+
nfc_err_t ret = pn512_init(&_pn512, _transport_driver->get_transport(), scheduler_timer);
3034
if (ret != NFC_OK) {
3135
NFC_ERR("PN512 init error (%d)", ret);
3236
return NULL;
3337
}
3438
NFC_DBG("PN512 Initialized");
3539

36-
return pn512_get_transceiver(&pn512);
40+
return pn512_get_transceiver(&_pn512);
3741
}
3842

3943
void PN512Driver::get_supported_nfc_techs(nfc_tech_t *initiator, nfc_tech_t *target) const

features/nfc/source/controllers/PN512SPITransportDriver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
using namespace mbed;
2323
using namespace mbed::nfc;
2424

25-
PN512SPITransportDriver::PN512SPITransportDriver(PinName mosi, PinName miso, PinName sclk, PinName ssel, PinName irq, PinName rst)) :
25+
PN512SPITransportDriver::PN512SPITransportDriver(PinName mosi, PinName miso, PinName sclk, PinName ssel, PinName irq, PinName rst) :
2626
_spi(mosi, miso, sclk),
2727
_ssel(ssel, 1),
2828
_irq(irq, PullNone),
@@ -70,7 +70,7 @@ void PN512SPITransportDriver::transport_write(uint8_t address, const uint8_t *ou
7070
address = (address << 1) | 0x00;
7171
_ssel = 0;
7272
_spi.write(address); // First write address byte
73-
_spi.write(outBuf, outLen, NULL, 0); // Ignore read bytes
73+
_spi.write((const char *) outBuf, outLen, (char *) NULL, 0); // Ignore read bytes
7474
_ssel = 1;
7575
}
7676

@@ -93,7 +93,7 @@ void PN512SPITransportDriver::transport_read(uint8_t address, uint8_t *inBuf, si
9393

9494
_ssel = 0;
9595
_spi.write(address); // First write address byte
96-
_spi.write(inBuf, inLen, inBuf, inLen);
96+
_spi.write((const char *) inBuf, inLen, (char *) inBuf, inLen);
9797
_ssel = 1;
9898
}
9999

features/nfc/source/controllers/PN512TransportDriver.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ PN512TransportDriver::PN512TransportDriver() : _delegate(NULL)
2424

2525
}
2626

27+
PN512TransportDriver::~PN512TransportDriver()
28+
{
29+
30+
}
31+
2732
void PN512TransportDriver::set_delegate(Delegate *delegate)
2833
{
2934
_delegate = delegate;

0 commit comments

Comments
 (0)