Problems with long HTML code on WiServer

Discussion about the upcoming YellowJacket (WiFi+Arduino mini).

Problems with long HTML code on WiServer

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

Why is this not working? :(

Code: Select all
/*
* A simple sketch that uses WiServer to serve a web page
*/


#include <WiServer.h>

#define WIRELESS_MODE_INFRA   1
#define WIRELESS_MODE_ADHOC   2

// Wireless configuration parameters ----------------------------------------
unsigned char local_ip[] = {10,1,10,115};   // IP address of WiShield
unsigned char gateway_ip[] = {10,1,10,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 = {"testing"};      // max 32 bytes

unsigned char security_type = 3;   // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2

// WPA/WPA2 passphrase
const prog_char security_passphrase[] PROGMEM = {"a01b02c03d"};   // 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 ssid_len;
unsigned char security_passphrase_len;
// End of wireless configuration parameters ----------------------------------------


// This is our page serving function that generates web pages
boolean sendMyPage(char* URL) {
 
    // Check if the requested URL matches "/"
    if (strcmp(URL, "/") == 0) {
        // Use WiServer's print and println functions to write out the page content

        WiServer.print("<html><head><script language='javascript' src='http://www.website.com/wifi/ra.js'></script>");
        WiServer.print("<link href='http://www.website.com/wifi/ra.css' rel='stylesheet' type='text/css'></head><body onLoad='t();'>");
        WiServer.print("<table><tr><td colspan=4 align=center><img src='http://www.website.com/images/ra.jpg'></td></tr><tr>");
        WiServer.print("<td background='http://www.website.com/images/t1.jpg' align=center><div id=T1 class=style1></div></td>");
        WiServer.print("<td background='http://www.website.com/images/t2.jpg' align=center><div id=T2 class=style1></div></td>");
        WiServer.print("<td background='http://www.website.com/images/t3.jpg' align=center><div id=T3 class=style1></div></td>");
        WiServer.print("<td background='http://www.website.com/images/ph.jpg' align=center><div id=PH class=style1></div></td>");
        WiServer.print("</tr><tr><td height='184' colspan=4 align=center><table width='500'><tr><td height='184' background='");
        WiServer.print("http://www.website.com/images/panel.jpg'><table width='400' class='style3'><tr class='style2'>");
        WiServer.print("<td><div id='l1'></div></td><td><div id='l2'></div></td><td><div id='l3'></div></td><td><div id='l4'></div></td>");
        WiServer.print("<td><div id='l5'></div></td><td><div id='l6'></div></td><td><div id='l7'></div></td><td><div id='l8'></div></td>");
        WiServer.print("</tr><tr class='style2'>");
        WiServer.print("<td><div id='s1'><img src='http://www.website.com/images/spacer.gif' width=41 height=85 border='0' usemap='#s1Map'></div></td>");
        WiServer.print("<td><div id='s2'><img src='http://www.website.com/images/spacer.gif' width=41 height=85 border='0' usemap='#s2Map'></div></td>");
        WiServer.print("<td><div id='s3'><img src='http://www.website.com/images/spacer.gif' width=41 height=85 border='0' usemap='#s3Map'></div></td>");
        WiServer.print("<td><div id='s4'><img src='http://www.website.com/images/spacer.gif' width=41 height=85 border='0' usemap='#s4Map'></div></td>");
        WiServer.print("<td><div id='s5'><img src='http://www.website.com/images/spacer.gif' width=41 height=85 border='0' usemap='#s5Map'></div></td>");
        WiServer.print("<td><div id='s6'><img src='http://www.website.com/images/spacer.gif' width=41 height=85 border='0' usemap='#s6Map'></div></td>");
        WiServer.print("<td><div id='s7'><img src='http://www.website.com/images/spacer.gif' width=41 height=85 border='0' usemap='#s7Map'></div></td>");
        WiServer.print("<td><div id='s8'><img src='http://www.website.com/images/spacer.gif' width=41 height=85 border='0' usemap='#s8Map'></div></td>");
        WiServer.print("</tr></table></td></tr><tr><td><div id='temp'><H1>Please Wait... Loading...</H1></div></td></tr></table></td></tr></table>");
        WiServer.print("<map name='s1Map'><area shape='rect' coords='0,0,41,15' href=\"javascript:r('11');\"><area shape='rect' coords='0,33,41,53' ");
        WiServer.print("href=\"javascript:r('10');\"><area shape='rect' coords='0,70,41,85' href=\"javascript:r('12');\"></map>");
        WiServer.print("<map name='s2Map'><area shape='rect' coords='0,0,41,15' href=\"javascript:r('21');\"><area shape='rect' coords='0,33,41,53' ");
        WiServer.print("href=\"javascript:r('20');\"><area shape='rect' coords='0,70,41,85' href=\"javascript:r('22');\"></map>");
        WiServer.print("<map name='s3Map'><area shape='rect' coords='0,0,41,15' href=\"javascript:r('31');\"><area shape='rect' coords='0,33,41,53' ");
        WiServer.print("href=\"javascript:r('30');\"><area shape='rect' coords='0,70,41,85' href=\"javascript:r('32');\"></map>");
        WiServer.print("<map name='s4Map'><area shape='rect' coords='0,0,41,15' href=\"javascript:r('41');\"><area shape='rect' coords='0,33,41,53' ");
        WiServer.print("href=\"javascript:r('40');\"><area shape='rect' coords='0,70,41,85' href=\"javascript:r('42');\"></map>");
        WiServer.print("<map name='s5Map'><area shape='rect' coords='0,0,41,15' href=\"javascript:r('51');\"><area shape='rect' coords='0,33,41,53' ");
        WiServer.print("href=\"javascript:r('50');\"><area shape='rect' coords='0,70,41,85' href=\"javascript:r('52');\"></map>");
        WiServer.print("<map name='s6Map'><area shape='rect' coords='0,0,41,15' href=\"javascript:r('61');\"><area shape='rect' coords='0,33,41,53' ");
        WiServer.print("href=\"javascript:r('60');\"><area shape='rect' coords='0,70,41,85' href=\"javascript:r('62');\"></map>");
        WiServer.print("<map name='s7Map'><area shape='rect' coords='0,0,41,15' href=\"javascript:r('71');\"><area shape='rect' coords='0,33,41,53' ");
        WiServer.print("href=\"javascript:r('70');\"><area shape='rect' coords='0,70,41,85' href=\"javascript:r('72');\"></map>");
        WiServer.print("<map name='s8Map'><area shape='rect' coords='0,0,41,15' href=\"javascript:r('81');\"><area shape='rect' coords='0,33,41,53' ");
        WiServer.print("href=\"javascript:r('80');\"><area shape='rect' coords='0,70,41,85' href=\"javascript:r('82');\"></map>");
        WiServer.print("</body></html>");

       
        // URL was recognized
        return true;
    }
    // URL not found
    return false;
}


void setup() {
  // Initialize WiServer and have it use the sendMyPage function to serve pages
  WiServer.init(sendMyPage);
 
  // Enable Serial output and ask WiServer to generate log messages (optional)
  Serial.begin(57600);
  WiServer.enableVerboseMode(true);
}

void loop(){

  // Run WiServer
  WiServer.server_task();

  delay(10);
}

newhobby
 
Posts: 2
Joined: Fri May 28, 2010 8:19 pm

Re: Problems with long HTML code on WiServer

Postby GregEigsti » Fri May 28, 2010 11:30 pm

What troubleshooting steps have you taken?
Do the unmodified example sketches work for you (unmodified except for network specifics)?
Which unmodified example sketches have you tried and which ones work / don't work?
Is your access point on the list of known working (or known not working) access points?

Maybe you could describe the symptoms that you are having?

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: 1067
Joined: Sun Aug 02, 2009 5:23 pm
Location: Sammamish WA USA (near Seattle)
  • Website

Re: Problems with long HTML code on WiServer

Postby newhobby » Sat May 29, 2010 9:09 am

Hi Greg,

I'm sorry and I should've explained myself better.
Anyway, the example sketch for WiServer works just fine, but the below code doesn't.
I'm guessing is because I'm using the inheritance of print, which is exhausting the RAM. Just wild guess, though.
I'm going to try print_P and see what happens.

Roberto.
newhobby
 
Posts: 2
Joined: Fri May 28, 2010 8:19 pm

Re: Problems with long HTML code on WiServer

Postby GregEigsti » Sat May 29, 2010 9:44 am

I'm going to try print_P and see what happens.

I actually played with your code last night, moved everything into PROGMEM and it still would not work (for me). At that time I did not know that WiServer had a print_P function and was doing things the hard way (which is error prone and likely introduced the problem on my end). I did find that your code is too long; that is once I removed some of your data (and therefore your RAM use) it seemed happier.

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: 1067
Joined: Sun Aug 02, 2009 5:23 pm
Location: Sammamish WA USA (near Seattle)
  • Website

Re: Problems with long HTML code on WiServer

Postby GregEigsti » Sat May 29, 2010 9:50 am

Yep, print_P made it all work for me (and my set of data is purposefully much larger than your set).

Edit - Check out this thread for more better info.

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: 1067
Joined: Sun Aug 02, 2009 5:23 pm
Location: Sammamish WA USA (near Seattle)
  • Website


Return to YellowJacket

Who is online

Users browsing this forum: No registered users and 2 guests