I’m very new at this and trying to build a function on a particle photon. I can’t seem to figure out how to resolve this error. Research has me thinking that it has to do with needing to pass a string to the function, but even when I add a string the “signal” variable still throws the error.
These are the errors:
../wiring/inc/spark_wiring_cloud.h:193:39: invalid conversion from 'int (*)(signal*)' to 'int (*)(String)' [-fpermissive]
../wiring/inc/spark_wiring_cloud.h:196:17: initializing argument 2 of 'static bool CloudClass::_function(const char*, int (*)(String))' [-fpermissive]
This is the code:
const int TX_PIN = 3; // Particle photon pin 3
typedef struct {
boolean power;
int duration; // micro seconds
} signal;
const signal SHORT_ON { true, 400 };
const signal SHORT_OFF { false, 500 };
const signal LONG_ON { true, 850 };
const signal LONG_OFF { false, 950 };
const int REST = 10000;
const char* host = "fancontrol";
signal sig_preamble [] { // 50 items total
SHORT_ON, LONG_OFF, SHORT_ON, LONG_OFF, SHORT_ON, LONG_OFF, SHORT_ON, LONG_OFF,
SHORT_ON, LONG_OFF, SHORT_ON, LONG_OFF, SHORT_ON, LONG_OFF, SHORT_ON, LONG_OFF,
SHORT_ON, LONG_OFF, SHORT_ON, LONG_OFF, SHORT_ON, LONG_OFF, SHORT_ON, LONG_OFF,
SHORT_ON, LONG_OFF, SHORT_ON, LONG_OFF, SHORT_ON, LONG_OFF, SHORT_ON, LONG_OFF
};
signal sig_power [] {
SHORT_ON, SHORT_OFF,
LONG_ON, SHORT_OFF,
LONG_ON, SHORT_OFF,
LONG_ON, SHORT_OFF,
LONG_ON, LONG_OFF,
SHORT_ON, LONG_OFF,
SHORT_ON, SHORT_OFF,
LONG_ON, LONG_OFF
};
signal sig_1 [] {
SHORT_ON, LONG_OFF,
SHORT_ON, SHORT_OFF,
LONG_ON, SHORT_OFF,
LONG_ON, SHORT_OFF,
LONG_ON, LONG_OFF,
SHORT_ON, LONG_OFF,
SHORT_ON, SHORT_OFF,
LONG_ON, LONG_OFF
};
signal sig_2 [] {
SHORT_ON, SHORT_OFF,
LONG_ON, LONG_OFF,
SHORT_ON, SHORT_OFF,
LONG_ON, SHORT_OFF,
LONG_ON, LONG_OFF,
SHORT_ON, LONG_OFF,
SHORT_ON, SHORT_OFF,
LONG_ON, LONG_OFF
};
signal sig_3 [] {
SHORT_ON, LONG_OFF,
SHORT_ON, LONG_OFF,
SHORT_ON, SHORT_OFF,
LONG_ON, SHORT_OFF,
LONG_ON, LONG_OFF,
SHORT_ON, LONG_OFF,
SHORT_ON, SHORT_OFF,
LONG_ON, LONG_OFF
};
int doIT(signal array[16]) {
Serial.println("Doing transmission...");
for (int burst = 1; burst <= 6; burst++) {
for (int pre = 0; pre < 32; ++pre) { // Preamble
digitalWrite(TX_PIN, sig_preamble[pre].power);
delayMicroseconds (sig_preamble[pre].duration);
}
for (int idx = 0; idx < 16; ++idx ) { // payload
digitalWrite(TX_PIN, array[idx].power);
delayMicroseconds( array[idx].duration );
}
digitalWrite(TX_PIN, SHORT_ON.power); // postamble - is that a word?
delayMicroseconds(SHORT_ON.duration);
digitalWrite(TX_PIN, SHORT_OFF.power);
delayMicroseconds(REST); // rest between bursts
return 1;
}
}
void loop() {
}
void setup() {
Particle.function("doTrans", doIT);
}