-
Notifications
You must be signed in to change notification settings - Fork 3k
Add initial NFC support to Mbed OS #7822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Wow, you weren't kidding about "by end of week". |
#ifndef NFC_ERRORS_H_ | ||
#define NFC_ERRORS_H_ | ||
|
||
#define NFC_OK 0 ///< No error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, I should use these, let's make them into a SafeEnum so it's nice and type safe
features/nfc/nfc/NFCEEPROMDriver.h
Outdated
|
||
#include <stdint.h> | ||
|
||
#include "NFCDefinitions.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all these headers are redundant (last one tries to include self?)
features/nfc/nfc/NFCEEPROMDriver.h
Outdated
* | ||
* @note this function can be called in interrupt context | ||
*/ | ||
virtual void on_event() = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can make this simpler by handing over the event queue which you already have in the nfc target
See:
ARMmbed/mbed-nfc-m24sr@ec0d191#diff-3856d36332fc549ca6b08cafbfcac790
/** | ||
* The NFCControllerDriver delegate | ||
*/ | ||
struct Delegate { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this struct meant to be private ?
features/nfc/nfc/ISO7816App.h
Outdated
/** | ||
* This base class represents an ISO7816-4 application. | ||
*/ | ||
class ISO7816App { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is completely private, it only has a friend Type4RemoteInitiator
. Is that intended ?
namespace nfc { | ||
|
||
struct PN512TransportDriver; | ||
class PN512Driver : public NFCControllerDriver, private PN512TransportDriver::Delegate { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is PN512TransportDriver
referring to the struct PN512TransportDriver
or to the included class PN512TransportDriver
?
From the ::Delegate
it looks like it is the included class but then what is the use of the struct PN512TransportDriver
line 28 ?
features/nfc/nfc/NFCDefinitions.h
Outdated
namespace nfc { | ||
struct nfc_rf_protocols_bitmask_t | ||
{ | ||
uint8_t initiator_t1t : 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those elements are 1 bit wide, wouldn't that make sense to make them boolean ?
features/nfc/nfc/NFCController.h
Outdated
nfc_err_t cancel_discovery(); | ||
|
||
private: | ||
friend class NFCRemoteEndpoint; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NFCController
does not need to have NFCRemoteEndpoint
as a friend because it's not using any of NFCController
's private member.
features/nfc/nfc/NFCController.h
Outdated
friend class NFCRemoteEndpoint; | ||
friend class NFCRemoteInitiator; | ||
friend class Type4RemoteInitiator; | ||
nfc_transceiver_t* transceiver() const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is :
- private
- non-virtual
- only returning the private member _transceiver.
Type4RemoteInitiator
is a friend so it could also directly access the member.
Or making this method public would allow to remove the need for to be a friend.
features/nfc/nfc/NFCController.h
Outdated
|
||
private: | ||
friend class NFCRemoteEndpoint; | ||
friend class NFCRemoteInitiator; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NFCController
does not need to have NFCRemoteInitiator
as a friend because it's not using any of NFCController
's private member.
Type4RemoteInitiator type4_remote_initiator_ptr = new (std::nothrow) Type4RemoteInitiator(_transceiver, _ndef_buffer, _ndef_buffer_sz); | ||
if( type4_remote_initiator_ptr == NULL ) { | ||
// No memory :( | ||
SharedPtr<Type4RemoteInitiator> type4_remote_initiator( type4_remote_initiator_ptr ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is calling _delegate->on_nfc_initiator_discovered
with a NULL
shared pointer intended ?
*/ | ||
static inline void pn512_hw_write(pn512_t* pPN512, uint8_t addr, uint8_t* buf, size_t len) | ||
{ | ||
nfc_transport_write(((nfc_transceiver_t*)pPN512)->pTransport, addr, buf, len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type of cast are unnecessary and can lead to unexpected error if the structure gets reordered to reduce padding or a new member gets inserted there.
@@ -0,0 +1,34 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file does not contain any code.
bc2c8e7
to
71f7156
Compare
@donatieng Please take a look at the Travis doc test failures. |
Test : FAILUREBuild number : 2701 |
@donatieng Ignore the test result for now. We're looking into an issue that's blocking #7844. Will restart when able to. |
Exporter Build : FAILUREBuild number : 2573 |
Cool. Looks like this only failed because the license server is down. |
Test : SUCCESSBuild number : 2706 |
/morph build |
Build : SUCCESSBuild number : 2962 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 2577 |
/morph test |
Test : FAILUREBuild number : 2713 |
Stopping and restarting. NucleoF401 test failure, but doesn't seem to be related to PR. /morph test |
Test : FAILUREBuild number : 2716 |
/morph test |
Test : FAILUREBuild number : 2721 |
@ARMmbed/mbed-os-ipcore the latest failure (SYNCHRONOUS_DNS_CACHE |
@0xc0170 Some revisions of Nucleo F7 boards have knows issues with ethernet hardware. I'll test this locally to see how often problem occurs. |
You can fetch the binary used for testing/build your own on master to compare results.Thanks for the help, we need to minimize the failures like this these days. |
Cannot repeat locally here with Nucleo F746ZG. Since test is measuring time for DNS requests could be that time values configured to test should be tuned. This error needs to monitored if it happens regularly. Asynchronous DNS tests have had similar test for some time, and I have not heard about failures on it. Nucleo F7 boards with "A" revision of the chip have problems with Ethernet (#6262). Could you check that boards used for Ethernet testing are revision "Z". Using "A" revision can result random failures on Ethernet. |
@studavekar @cmonr Can you verify please |
@mikaleppanen @0xc0170 |
If it becomes too critical, we can revert to a239c5e which is just missing exporter build |
/morph test |
Test : SUCCESSBuild number : 2729 |
Description
This PR adds initial NFC support to mbed OS:
Design document and discussions are held in PR #7426.
This PR depends on
#7815(merged) and#7828(merged).Please do not merge for now, we still need to perform more testing but the PR is feature-complete so ready for code review.
Pull request type