Tracker One - Default "cmd" Function / {“cmd”:“get_loc”}

Defaulft “cmd” Function with {“cmd”:“get_loc”}

I really like the output that I get when using {“cmd”:“get_loc”}
Is there any way to trigger this event outside that “cmd” Function?
I would like it to be triggered by an event, a sensor value like speed, etc.

Thank you :stuck_out_tongue:

#include "Particle.h"
#include "tracker_config.h"
#include "tracker.h"

SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(SEMI_AUTOMATIC);

PRODUCT_ID(TRACKER_PRODUCT_ID);
PRODUCT_VERSION(TRACKER_PRODUCT_VERSION);


SerialLogHandler logHandler(115200, LOG_LEVEL_TRACE, {
                                                         {"app.gps.nmea", LOG_LEVEL_INFO},
                                                         {"app.gps.ubx", LOG_LEVEL_INFO},
                                                         {"ncp.at", LOG_LEVEL_INFO},
                                                         {"net.ppp.client", LOG_LEVEL_INFO},
                                                     });

int ControlPanel(String command);

void setup()
{
    Particle.function("ControlPanel", ControlPanel);
    Particle.connect();
}

void loop() {}

int ControlPanel(String command)
{

    if (command == "info_center")
    {
        // I WOULD LIKE TO USE THAT {"cmd":"get_loc"}
        // TO TRIGGER "loc" Event to obtain JSON file
        return 1;
    }
    else
        return -1;
}

Yes:

TrackerLocation::instance().triggerLocPub();

There are two optional parameters to triggerLocPub():

int triggerLocPub(Trigger type = Trigger::NORMAL, const char *s = "user")

The other Trigger option is Trigger::IMMEDIATE. The string is a short text string to describe the reason.

Thank you rickkas7, I got it to work :partying_face:

#include "Particle.h"
#include "tracker_config.h"
#include "tracker.h"

SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(SEMI_AUTOMATIC);

PRODUCT_ID(TRACKER_PRODUCT_ID);
PRODUCT_VERSION(TRACKER_PRODUCT_VERSION);


SerialLogHandler logHandler(115200, LOG_LEVEL_TRACE, {
                                                         {"app.gps.nmea", LOG_LEVEL_INFO},
                                                         {"app.gps.ubx", LOG_LEVEL_INFO},
                                                         {"ncp.at", LOG_LEVEL_INFO},
                                                         {"net.ppp.client", LOG_LEVEL_INFO},
                                                     });

int ControlPanel(String command);

void setup()
{
    Particle.function("ControlPanel", ControlPanel);
    Particle.connect();
}

void loop() {}

int ControlPanel(String command)
{

    if (command == "info_center")
    {
       TrackerLocation::instance().triggerLocPub(Trigger::IMMEDIATE);
        return 1;
    }
    else
        return -1;
}
1 Like