Use SharedPtr class for detected endpoints

pull/7822/head
Donatien Garnier 2018-08-14 12:09:34 +01:00
parent d5201f00e4
commit db2cdf0b02
3 changed files with 11 additions and 4 deletions

View File

@ -19,6 +19,7 @@
#include <stdint.h>
#include "events/EventQueue.h"
#include "platform/SharedPtr.h"
#include "NFCDefinitions.h"
@ -71,13 +72,13 @@ namespace nfc {
* A remote initiator was discovered (the local controller is in target mode).
* @param[in] the NFCRemoteInitiator instance
*/
virtual void on_nfc_initiator_discovered(const NFCRemoteInitiator& nfc_initiator) {}
virtual void on_nfc_initiator_discovered(const SharedPtr<NFCRemoteInitiator>& nfc_initiator) {}
/**
* A remote target was discovered (the local controller is in initiator mode).
* @param[in] the NFCRemoteTarget instance
*/
virtual void on_nfc_target_discovered(const NFCRemoteTarget& nfc_target) {}
virtual void on_nfc_target_discovered(const SharedPtr<NFCRemoteTarget>& nfc_target) {}
};
/**

View File

@ -39,6 +39,8 @@ namespace nfc {
*/
class Type4RemoteInitiator : public NFCRemoteInitiator, public ISO7816App, public NFCNDEFCapable {
private:
Type4RemoteInitiator(nfc_transceiver_t* transceiver);
// NFCNDEFCapable implementation
virtual bool is_ndef_supported() const;

View File

@ -16,6 +16,7 @@
#include "NFCController.h"
#include "NFCControllerDriver.h"
#include "Type4RemoteInitiator.h"
#include "stack/transceiver/transceiver.h"
@ -118,7 +119,10 @@ 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 ) {
SharedPtr ptr =
SharedPtr<Type4RemoteInitiator> type4_remote_initiator( new Type4RemoteInitiator(_transceiver) );
if( _delegate != NULL ) {
_delegate->on_nfc_initiator_discovered(type4_remote_initiator);
}
}
}
}