Two ?'s re: ESP8266WebServer & structs
Posted: Sat Jan 09, 2016 12:45 pm
I'm new to C/C++, so please bear with me. I've been able to mashup a mostly working web server sketch, with 2 notable exceptions - and those are my questions:
Question#1: Wondering if anyone knows if its possible to have the usual
call a method that needs parameters, and if so, how? I haven't seen any examples anywhere, and don't know what this should look like.
While the following won't/doesn't work, I have no idea how to proceed further - can anyone shed some light on what to google or learn about?
Question #2 is kind of related to the above, and is more about structs - how would I define a global struct that I could pass around so it can be modified in the methods/functions that get called in this type of scenario? Is this the way to define the struct? The code below is quick pseudocode - I'm just trying to get my thoughts across-
Question#1: Wondering if anyone knows if its possible to have the usual
Code: Select all
server.on("/", someMethodName);
call a method that needs parameters, and if so, how? I haven't seen any examples anywhere, and don't know what this should look like.
While the following won't/doesn't work, I have no idea how to proceed further - can anyone shed some light on what to google or learn about?
Code: Select all
server.on("/", myMethodNameThatNeedsAParameter(myStructIWantedToPass));
Question #2 is kind of related to the above, and is more about structs - how would I define a global struct that I could pass around so it can be modified in the methods/functions that get called in this type of scenario? Is this the way to define the struct? The code below is quick pseudocode - I'm just trying to get my thoughts across-
Code: Select all
#include <ESP8266WebServer.h>
typedef struct Setting {
bool configured;
};
Setting someGlobalSetting; //is this how to do this here? this would be global scope for the whole sketch?
void setup(){
someGlobalSetting.configured = true;
//other misc code...
}
void loop(){
if (someGlobalSetting.configured){
...do something useful
}