I am getting an out of scope error, not sure where I am going wrong.
Code below
#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 },
});
void setup()
{
Tracker::instance().init();
Particle.function("Relay", RelayControl);
pinMode(CAN_PWR, OUTPUT);
digitalWrite(CAN_PWR, LOW);
}
void loop()
{
Tracker::instance().loop();
}
int RelayControl(String command)
{
int state = LOW;
// find out the state of the relay
if(command == "HIGH"){
state = HIGH;
}else if(command == "LOW"){
state = LOW;
}else{
return -1;
}
// write to the appropriate pin
digitalWrite(CAN_PWR, state);
return 1;
}