Narrowed it down to just the example code producing a hard fault, can anyone else reproduce?
My entire sketch:
// example code
class CoffeeMaker {
public:
CoffeeMaker() {
Particle.function("brew", &CoffeeMaker::brew, this);
}
int brew(String command) {
// do stuff
return 1;
}
};
CoffeeMaker myCoffeeMaker;
// nothing else needed in setup() or loop()
void setup() {
}
void loop() {
}
Placing the Particle.function in the setup function works.
class CoffeeMaker {
public:
CoffeeMaker() {}
void begin() {
Particle.function("brew", &CoffeeMaker::brew, this);
}
int brew(String command) {
// do stuff
Particle.publish("this works");
return 1;
}
};
CoffeeMaker myCoffeeMaker;
// nothing else needed in setup() or loop()
void setup() {
myCoffeeMaker.begin();
}
void loop() {
}
or
class CoffeeMaker {
public:
CoffeeMaker() {
Particle.function("brew", &CoffeeMaker::brew, this);
}
int brew(String command) {
// do stuff
Particle.publish("also works");
return 1;
}
};
void setup() {
CoffeeMaker myCoffeeMaker;
}
void loop() {
}
The first sketch including method works on a v0.7.0 Photon.