regLocPubCallback executing only once

Hello, I’m using the Particle Tracker One device and I’m using the tracker-edge firmware (v18). I tried to setup a regLocPubCallback like this:

int publishCallback(CloudServiceStatus status,
                    JSONValue * rsp_root,
                    const char * req_event,
                    const void *context);

void setup()
{
    Tracker::instance().init();
    Tracker::instance().location.regLocPubCallback(publishCallback);
}

void loop()
{
    Tracker::instance().loop();
}

int publishCallback(CloudServiceStatus status,
                    JSONValue * rsp_root,
                    const char * req_event,
                    const void *context) {
    Log.info("==== Publish callback executed ====");
    return 0;
}

My problem is that this callback is executed only once, at the first publish. I’d like it to run for all location publishes. Am I missing something? I tried with the regLocGenCallback and I don’t have that issue.

Thanks in advance.

It appears that the regLocPubCallback is a single-use callback so you need to initialize it on every publish if you want to use it. I think you could do so from the regLocGenCallback.

Thanks ! Working great registering the callback on each location generation event.

1 Like