I LOVE this shield. It's going to open up a whole raft of possibilities...
Yup!
Glad you got it working and thanks for posting the sample!
Greg
I LOVE this shield. It's going to open up a whole raft of possibilities...
as you can see I have a fuction called "light()" and there is a 'for' loop inside of that function.
domimedia wrote:Thanks for replying Greg!
The code is the same iphoneczar published I just changed the digitalWrite(ledPin, HIGH); for a function that has a 'for' loop. It seems that the code gets stuck inside of the perpetual loop and is not returning anything the the function sendMyPage()
Sorry I can't post the code right now, I'm not home.
#include <WiServer.h>
#define WIRELESS_MODE_INFRA 1
#define WIRELESS_MODE_ADHOC 2
int LED = 4;
int pulse = 500;
int i = 0;
// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {192,168,1,152}; // IP address of WiShield
unsigned char gateway_ip[] = {192,168,1,1}; // router or gateway IP address
unsigned char subnet_mask[] = {255,255,255,0}; // subnet mask for the local network
const prog_char ssid[] PROGMEM = {"ASYNCLABS"}; // max 32 bytes
unsigned char security_type = 0; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2
// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"1234567"}; // max 64 characters
// WEP 128-bit keys
// sample HEX keys
prog_uchar wep_keys[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, // Key 0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Key 2
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Key 3
};
// setup the wireless mode
// infrastructure - connect to AP
// adhoc - connect to another WiFi device
//unsigned char wireless_mode = WIRELESS_MODE_INFRA;
unsigned char wireless_mode = WIRELESS_MODE_ADHOC;
unsigned char ssid_len;
unsigned char security_passphrase_len;
// End of wireless configuration parameters ----------------------------------------
boolean sendMyPage(char* URL) {
// Check if the requested URL matches "/"
if (strcmp(URL, "/LIGHT") == 0) {
light();
return true;
}
return false;
}
void setup() {
pinMode(LED, OUTPUT);
WiServer.init(sendMyPage);
Serial.begin(57600);
WiServer.enableVerboseMode(true);
}
void loop(){
WiServer.server_task();
delay(10);
}
void light() {
for(i = 0; i < 100 ; i++) {
pulse = 3000;
digitalWrite(LED, HIGH);
delay(pulse);
digitalWrite(LED, LOW);
}
}
The thing is, it is not returning any value to sendMyPage() because it is a nonstop loop, so I get hanged.
You are effectively killing your WiFi connection by delaying for 300 seconds
Return to Sketches and Applications
Users browsing this forum: No registered users and 1 guest