create local network

Discussion about any of the included sketches (i.e. WebServer), or user-generated applications.

Re: create local network

Postby GregEigsti » Fri Jan 22, 2010 10:43 am

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
Check out the wiki!
uIP Stack Docs
Compatible Access Point List
WiShield user contrib branch - DNS, DHCP, AP Scanning, bug fixes, etc.
SlackLab.org - My geek projects blog.
User avatar
GregEigsti
 
Posts: 966
Joined: Sun Aug 02, 2009 5:23 pm
Location: Sammamish WA USA (near Seattle)
  • Website

Re: create local network

Postby SirPoonga » Thu Feb 04, 2010 12:27 am

Is there a way to have the webserver automatically server the webpage instead of typing in the ip? Ideally it would be nice to have someone just conenct to the wifi network and open a browser without having to tell the person where to go once connected.

I know this could be done if a wifi router was involved. Grab a router that supports OpenWRT and modify the routing so any web traffic goes to the arduino. However, it would be nice to not have a router to do this.
SirPoonga
 
Posts: 36
Joined: Thu Feb 04, 2010 12:24 am

Re: create local network

Postby domimedia » Wed May 26, 2010 9:06 pm

Hello everybody,

I have a question about iphoneczar's code:

if (strcmp(URL, "/on") == 0) {
light();
return true;
}


as you can see I have a fuction called "light()" and there is a 'for' loop inside of that function. The thing is, it is not returning any value to sendMyPage() because it is a nonstop loop, so I get hanged. How can I make this work.

Regards,

Alex.
domimedia
 
Posts: 9
Joined: Wed May 26, 2010 9:01 pm

Re: create local network

Postby GregEigsti » Wed May 26, 2010 10:20 pm

as you can see I have a fuction called "light()" and there is a 'for' loop inside of that function.

Did you mean to post your code? I looked through the thread and did not find any reference to a light() function. Kinda hard to say what is going on without the code to look at.

Greg
Check out the wiki!
uIP Stack Docs
Compatible Access Point List
WiShield user contrib branch - DNS, DHCP, AP Scanning, bug fixes, etc.
SlackLab.org - My geek projects blog.
User avatar
GregEigsti
 
Posts: 966
Joined: Sun Aug 02, 2009 5:23 pm
Location: Sammamish WA USA (near Seattle)
  • Website

Re: create local network

Postby domimedia » Thu May 27, 2010 7:13 pm

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.
domimedia
 
Posts: 9
Joined: Wed May 26, 2010 9:01 pm

Re: create local network

Postby GregEigsti » Thu May 27, 2010 7:26 pm

I figured as much - glad you confirmed that I am not losing it - well not anymore than I already have ;)

Greg
Check out the wiki!
uIP Stack Docs
Compatible Access Point List
WiShield user contrib branch - DNS, DHCP, AP Scanning, bug fixes, etc.
SlackLab.org - My geek projects blog.
User avatar
GregEigsti
 
Posts: 966
Joined: Sun Aug 02, 2009 5:23 pm
Location: Sammamish WA USA (near Seattle)
  • Website

Re: create local network

Postby rock » Thu May 27, 2010 7:29 pm

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.


Yeah, I don't get it, either. There's nothing in iphoneczar's posts that would warrant a for() loop. I guess we'll just need to wait for your code post.

--
Rock
rock
 
Posts: 5
Joined: Tue May 25, 2010 11:33 pm

Re: create local network

Postby domimedia » Thu May 27, 2010 9:55 pm

Here is the code:

Code: Select all


#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);
       
    }

 
}



domimedia
 
Posts: 9
Joined: Wed May 26, 2010 9:01 pm

Re: create local network

Postby GregEigsti » Fri May 28, 2010 2:06 am

The problem is due to the amount of delay in your light() function. The WiShield must be serviced many times a second and your light() function is keeping the processor from doing anything for 300 seconds. By serviced I mean that you need to call WiServer.server_task() (or WiFi.run() for other app types) many times per second. You are effectively killing your WiFi connection by delaying for 300 seconds. If you comment out the call to the light() function I'll bet things work (assuming that there are not other issues in the code).

The thing is, it is not returning any value to sendMyPage() because it is a nonstop loop, so I get hanged.

You have declared light() as "void light()" which means that it returns void (or no value). I'm not sure why (or if) you expect it to return a vaue - cause it will never return a value as its return type is void. I'm not sure why you say it is a non-stop loop; from the looks of the code it is not capable of getting stuck in a non stop loop - it is a simple for loop that does very little.

Greg
Check out the wiki!
uIP Stack Docs
Compatible Access Point List
WiShield user contrib branch - DNS, DHCP, AP Scanning, bug fixes, etc.
SlackLab.org - My geek projects blog.
User avatar
GregEigsti
 
Posts: 966
Joined: Sun Aug 02, 2009 5:23 pm
Location: Sammamish WA USA (near Seattle)
  • Website

Re: create local network

Postby domimedia » Fri May 28, 2010 8:22 pm

Hello and thank you for replying!

You are effectively killing your WiFi connection by delaying for 300 seconds


the value: 300 is Milliseconds not seconds so there should be plenty of time for the server to be serviced.

I just want to return true to the function sendMyPage so the server can keep running.

I tried setting sendMyPage to a char function instead of a boolean but it didn't allow it.

when the code gets into light() the function sendMyPage doesn't return anything to WiServer.init(sendMyPage); and that's why I can't switch to any other function.

I hope I am being clear.
domimedia
 
Posts: 9
Joined: Wed May 26, 2010 9:01 pm

PreviousNext

Return to Sketches and Applications

Who is online

Users browsing this forum: No registered users and 1 guest