Particle function called and connected, but no action on Interenet Button

I have been trying to get my Internet Button to light the back LED after I send a POST request using the REST Easy API client Ad-On for Firefox. The client shows that it connects with the Internet button and returns all values that I’ve set in my if statement, but the action of lighting the LED is not occurring, can anyone tell me what’s wrong? My code, the URL I am using, and the response of the REST Easy API client are below. I hope it’s something obvious that I just overlooked.

Code:

#include "InternetButton/InternetButton.h"

InternetButton b = InternetButton();
int request(String command);

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

void loop() 
{

}

// this function automagically gets called upon a matching POST request
int request(String command)
{
  if(command == ""){
      
    b.ledOn(6,255,0,0);
    delay(3000);
    b.ledOff(6);
    
    return 25;
  }
  else return -1;
    }

URL: https://api.particle.io/v1/devices/my-device-id-here/request?access_token=my-access-token-here

Rest Easy API client response:

You need to call b.begin() in setup()
(as shown in all the library examples)

You should also not use delay(3000) in a function callback.

2 Likes

Yeah, that was it; it works now. I had a feeling it was something that simple that I overlooked. Thank you, I’m kind of a novice here.

1 Like