Photon firmware has double variable.
I can read it from CLI particle get OK.
But from example app of IOS Clos SDK, modified for my variable, nothing seems to happen when I call [myPhoton getVariable …
…the ‘completion:’ doesn’t seem to fire.
I run on iPhone6+, and do the example app’s “Login” ok and then “Test sequence”.
Here’s the FW code and the iOS code:
IOS…
printf("\n reading a variable" );
[myPhoton getVariable:@"button_press" completion:^(id result, NSError *error) {
if (!error)
{
NSNumber* button_press = (NSNumber* )result;
NSLog(@"button_press is #%f ",button_press.doubleValue);
}
else
{
NSLog(@"Failed reading button_press from Photon device");
}
}];
FIRMWARE…
#include "InternetButton/InternetButton.h"
/* How about we make this interactive? */
InternetButton b = InternetButton();
double button_press = 0; // none
void setup() {
// Tell b to get everything ready to go
// Use b.begin(1); if you have the original SparkButton, which does not have a buzzer or a plastic enclosure
// to use, just add a '1' between the parentheses in the code below.
b.begin();
b.setBrightness(50);
Serial.begin(9600);
Serial.println("Hello World! 2016-08-19a");
}
void loop(){
// When you click the second button (at the 3 o'clock position) let's turn that LED on
if(b.buttonOn(1))
{
button_press = 1;
Particle.variable( "button_press", button_press );
b.ledOn(1, 255, 0, 0);
b.ledOn(11, 255, 0, 0);
Serial.println("button_press = 1");
}
else if(b.buttonOn( 2 ))
{
button_press = 2;
Particle.variable( "button_press", button_press );
b.ledOn(2, 0, 255, 0);
b.ledOn(3, 0, 255, 0);
b.ledOn(4, 0, 255, 0);
Serial.println("button_press = 2");
}
else if(b.buttonOn(3))
{
button_press = 3;
Particle.variable( "button_press", button_press );
b.ledOn(5, 0, 0, 255);
b.ledOn(6, 0, 0, 255);
b.ledOn(7, 0, 0, 255);
Serial.println("button_press = 3");
}
else if(b.buttonOn( 4 ))
{
button_press = 4;
Particle.variable( "button_press", button_press );
b.ledOn(8, 255, 255, 0);
b.ledOn(9, 255, 255, 0);
b.ledOn(10, 255, 255, 0);
Serial.println("button_press = 4");
}
// And if the button's not on, then the LED should be off
else {
button_press = 0;
Particle.variable( "button_press", button_press );
b.ledOff(1);
b.ledOff(2);
b.ledOff(3);
b.ledOff(4);
b.ledOff(5);
b.ledOff(6);
b.ledOff(7);
b.ledOff(8);
b.ledOff(9);
b.ledOff(10);
b.ledOff(11);
}
/* Much like the LEDs, there are also functions to check if all the buttons are on- b.allButtonsOn()
or if all the buttons are off- b.allButtonsOff() */
}