Your light() function with extra newlines removed:
- Code: Select all
void light() {
for(i = 0; i < 100 ; i++) {
pulse = 3000;
digitalWrite(LED, HIGH);
delay(pulse);
digitalWrite(LED, LOW);
}
}
the value: 300 is Milliseconds not seconds so there should be plenty of time for the server to be serviced.
The code that you provided sets the "pulse" variable to 3000 which is taken as milliseconds in the call to delay() - 3000 ms is 3 seconds; you are then looping 100 times in your for loop calling delay(3000) each time. 3 seconds times 100 iterations of the for loop means you are sleeping 300 seconds. Not servicing the WiShield for 300 seconds is going to asplode your app/connectivity.
I just want to return true to the function sendMyPage so the server can keep running.
The light() function returns no value and you are not checking what it is returning so I'm assuming what you meant to say is that that you "want to return true from sendMyPage()".
I tried setting sendMyPage to a char function instead of a boolean but it didn't allow it.
Right, because sendMyPage() is a callback function and the code that calls it is looking for that function to match a specific "signature". If you change the return type of your sendMyPage() function then it won't match the expected signature and your build will fail (or it should fail to build anyway).
when the code gets into light() the function sendMyPage doesn't return anything to WiServer.init(sendMyPage)
The very next statement after your call to light() is "return true;" - the assertion that "sendMyPage doesn't return anything" is incorrect - it clearly returns true in this case. Also it is not correct to say that you are not (or are) returning anything to WiServer.init(sendMyPage); WiServer.init() merely provides WiServer with the address of your callback function (sendMyPage). When sendMyPage() returns it is returning to the location in the WiServer code that called it - not WiServer.init().
and that's why I can't switch to any other function.
I'm not sure what this means but I don't think that it really matters as it is not a correct diagnoses.
Did you try commenting out the light() function as I suggested to see if things started working? The problem here is that you are killing your connection, and therefore your app, by sleeping too long.
I also noticed that you have your "wireless_mode" set to adhoc rather than infrastructure - is this really what you wanted to do?
Greg