Skip to content
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

[NFC] Context parameter is missing and NFC.update() will remove callback #1818

Merged
merged 1 commit into from Jun 14, 2019

Conversation

@YutingYou
Copy link
Contributor

commented Jun 11, 2019

Problem

Context parameter is missing and NFC.update() will remove callback

Steps to Test

Flash the example, use Serial to observe the log to see whether the callback is called and whether the context value is right.

Example App

#include "application.h"

SYSTEM_MODE(MANUAL);

Serial1LogHandler logHandler(115200, LOG_LEVEL_ALL, {{"app", LOG_LEVEL_ALL}});

void nfc_event_callback(nfc_event_type_t type, nfc_event_t* event, void* context) {
    switch (type) {
        case NFC_EVENT_FIELD_ON: {
            Serial.printf("on, context: %d\r\n", *reinterpret_cast<int*>(context));
            break;
        };
        case NFC_EVENT_FIELD_OFF: {
            Serial.printf("off, context: %d\r\n", *reinterpret_cast<int*>(context));
            break;
        };
        default:
            break;
    }
}

void setup(void) {
    Serial.begin();
    static int context = 123;
    void *p = &context;
    NFC.setText("Hello Particle!", "en");
    NFC.on(nfc_event_callback, p);
    NFC.update();
}

void loop() {

}

References

[CH34412]


Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA (Info here)
  • Problem and Solution clearly stated
  • Run unit/integration/application tests on device
  • Added documentation
  • Added to CHANGELOG.md after merging (add links to docs and issues)

  • [bugfix] [NFC] Context parameter is missing and NFC.update() will remove callback #1818

@YutingYou YutingYou requested a review from avtolstoy Jun 11, 2019

@avtolstoy avtolstoy added this to the 1.3.0-beta.1 milestone Jun 11, 2019

@technobly technobly modified the milestones: 1.3.0-beta.1, 1.3.0-rc.1 Jun 13, 2019

@YutingYou YutingYou force-pushed the fix/nfc-context-parameter branch from 464967e to 3bccced Jun 14, 2019

@YutingYou YutingYou force-pushed the fix/nfc-context-parameter branch from 3bccced to 7a68068 Jun 14, 2019

@YutingYou YutingYou merged commit 1b049aa into develop Jun 14, 2019

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@YutingYou YutingYou deleted the fix/nfc-context-parameter branch Jun 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.