// System includes
#include <ESP8266WiFi.h>
bool ledState = HIGH;
//void blinkTimerCallback(void *pArg) {
// ledState = !ledState;
// writeLed(ledState);
//}
//void writeLed(bool ledState) {
//}
os_timer_t blinkTimer;
// A struct to hold all info of a crop.
struct Crop {
uint8_t id;
char crop[32];
char description[512];
uint8_t darkDays; // The number of days the tray remains dark.
uint8_t totalDays; // The number of days the program is to run.
uint16_t wateringFrequency; // The interval between two mistings in minutes.
};
Crop getCropData(uint8_t id) {
Crop crop;
return crop;
}
void setup() {
}
Uncommenting either the blinkTimerCallback or writeLed function will cause this error:
sketch_jan11a:25:1: error: 'Crop' does not name a type
Crop getCropData(uint8_t id) {
^
/home/wouter/Arduino/sketch_jan11a/sketch_jan11a.ino: In function 'void blinkTimerCallback(void*)':
sketch_jan11a:7:20: error: 'writeLed' was not declared in this scope
writeLed(ledState);
^
exit status 1
'Crop' does not name a type
Moving those two functions down (to under the getCropData function) also makes the code compile.
The question is of course: why? (this is just one of several seemingly similar issues that I'm running into at the moment: code that used to compile fine, now won't compile any more).
Arduino IDE 1.8.8
Board type: NodeMCU 1.0 (ESP-12 module)
Could be another case of things being messed up by Arduino's "helpful" auto-prototype generation. The solution (as always) is to supply proper prototypes yourself:
#include <ESP8266WiFi.h>
struct Crop;
void writeLed(bool ledState);
Crop getCropData(uint8_t id);
bool ledState = HIGH;
void blinkTimerCallback(void *pArg) {
ledState = !ledState;
writeLed(ledState);
}
void writeLed(bool ledState) {
}
//os_timer_t blinkTimer;
// A struct to hold all info of a crop.
struct Crop {
uint8_t id;
char crop[32];
char description[512];
uint8_t darkDays; // The number of days the tray remains dark.
uint8_t totalDays; // The number of days the program is to run.
uint16_t wateringFrequency; // The interval between two mistings in minutes.
};
Crop getCropData(uint8_t id) {
Crop crop;
return crop;
}
void setup() {
}
void loop() {}
BTW, this is commented out:
os_timer_t blinkTimer;
because your code doesn't define 'os_timer_t' anywhere.
It's compiling - mostly. The ArduinoJSON library is another issue I started to run into as well - functions from that library are not recognised, also in code that used to compile just fine. Just driving me crazy.
gfvalvo:
BTW, this is commented out:
os_timer_t blinkTimer;
because your code doesn't define 'os_timer_t' anywhere.