I trying to serve a list of files and associated data from an SD card. I'd like to pass the WebServer instance from my webduino command to a subroutine, but I'm having trouble figuring out how to do this. Notional code for what I'm trying to do...
void helloCmd(WebServer &server, WebServer::ConnectionType type, char *, bool) // This command is registered with webserver
{
server.print("some html here");
listfiles(server, [other parms]); //<- call to listfiles routine where I want to pass the server insance of WebServer
server.print("more html here");
}
void listfiles(WebServer &server, [other parms]);
{
various SD commands and html writes;
server.print(filename);
server.print(filedate);
server.print(filesize);
}
I've tried what little I know and even the things I could make up to either create a new instance of WebServer or a pointer to the existing instance when I pass it. Can't get anything to work. I've thought about making m_client public in webserver.h and trying to pass it, but I want to edit webser.h as little as possible.
Anybody know how to do this. It would make my code much simpler and more effieicent if I coud create subroutines and call them from each webduino web page command.
Thanks,