fsdata.c File Reference

#include <compiler.h>
#include "board.h"
#include "gpio.h"
#include "adc.h"
#include "lwip/stats.h"
#include "lwip/init.h"
#include "lwip/netif.h"
#include "fsdata_file.h"
#include "util.h"
#include "wl_util.h"
#include "hdwireless_gif.h"

Go to the source code of this file.

Defines

#define FS_ROOT   &file_index_html

Functions

void document_404_html_cb (const char **buf, int *len)
void document_image_gif_cb (const char **buf, int *len)
void document_index_html_cb (const char **buf, int *len)
static char * get_adc (void)
static char * get_rx (void)
static char * get_tx (void)
static int html_add_button (char *buf, int len, char *id, char *value)
static int html_add_row (char *buf, int len, char *name, const char *data)
void query_led0_cb (const char **buf, int *len)
void query_led1_cb (const char **buf, int *len)
void query_led2_cb (const char **buf, int *len)
void query_led3_cb (const char **buf, int *len)

Variables

struct fsdata_file file_404_html
struct fsdata_file file_image_gif
struct fsdata_file file_index_html
struct fsdata_file file_led0
struct fsdata_file file_led1
struct fsdata_file file_led2
struct fsdata_file file_led3


Define Documentation

#define FS_ROOT   &file_index_html

Definition at line 322 of file fsdata.c.

Referenced by fs_open().


Function Documentation

void document_404_html_cb ( const char **  buf,
int *  len 
)

Definition at line 122 of file fsdata.c.

00123 {
00124     static const char *rsp = 
00125         "HTTP/1.0 404 File not found\n"
00126         "Server: lwIP\n"
00127         "Content-type: text/html\n\n"
00128         "<html>"
00129         "<head><title>802.11 WiFi on Atmel UC3A3256</title></head>"
00130         "<body bgcolor=\"white\" text=\"black\">"
00131         "<table width=\"100%\">"
00132         "<tr valign=\"top\"><td width=\"80\">"
00133         "<a href=\"http://www.atmel.com/\"><img src=\"image.gif\""
00134         "border=\"0\" alt=\"logo\" title=\"logo\"></a>"
00135         "</td><td width=\"500\">"
00136         "<h2>802.11 WiFi on Atmel UC3A3256</h2>"
00137         "<h3>404 - Page not found</h3>"
00138         "<p>"
00139         "Sorry, the page you are requesting was not found on this"
00140         "server."
00141         "</p></td><td>&nbsp;</td></tr></table></body></html>";
00142 
00143     *buf = rsp;
00144         *len = strlen(rsp);
00145 }

void document_image_gif_cb ( const char **  buf,
int *  len 
)

Definition at line 111 of file fsdata.c.

References hdwireless_gif.

00112 {
00113     *buf = hdwireless_gif;
00114         *len = sizeof(hdwireless_gif);
00115 }

void document_index_html_cb ( const char **  buf,
int *  len 
)

Definition at line 152 of file fsdata.c.

References get_adc(), get_rx(), get_tx(), html_add_button(), html_add_row(), ip2str(), and mac2str().

Referenced by query_led0_cb(), query_led1_cb(), query_led2_cb(), and query_led3_cb().

00153 {
00154         static char rsp[1500];
00155         int pos = 0;
00156         
00157         pos += sniprintf(rsp + pos, sizeof(rsp) - pos,
00158                          "HTTP/1.0 200 OK\n"
00159                          "Server: lwIP\n"
00160                          "Content-type: text/html\n\n"
00161                          "<html>"
00162                          "<head><title>802.11bg WiFi on Atmel UC3%s</title>"
00163                          "</head>"
00164                          "</html>"
00165                          "<body bgcolor=\"white\" text=\"black\">"
00166                          "<table width=\"100%%\">"
00167                          "<tr valign=\"top\"><td width=\"80\">"
00168                          "<a href=\"index.html\">"
00169                          "<img src=\"image.gif\" border=\"0\" alt=\"logo\""
00170                          "title=\"logo\"></a>" 
00171                          "</td>"
00172                          "<td width=\"500\">"
00173                          "<h2>802.11bg WiFi on Atmel UC3%s</h2>"
00174                          "<p>"
00175                          "The web page you are watching was served by Atmel "
00176                          "UC3%s, using the H&D Wireless 802.11bg Wi-Fi SIP "
00177                          "solution. The web server is running on top of the "
00178                          "lightweight TCP/IP stack, "
00179                          "<a href=\"http://www.sics.se/~adam/lwip/\">lwIP</a>."
00180                          "</p><hr><table>",
00181 #if BOARD == EVK1104
00182              "A3256", "A3256", "A3256");
00183 #elif BOARD == EVK1105 || BOARD == EVK1100
00184                      "A0512", "A0512", "A0512");
00185 #elif BOARD == EVK1101
00186                         "B0256", "B0256", "B0256");
00187 #else
00188 #error
00189 #endif
00190 
00191 
00192         pos += html_add_row(rsp + pos, sizeof(rsp) - pos,
00193                 "IP Address", ip2str(netif_default->ip_addr));
00194         pos += html_add_row(rsp + pos, sizeof(rsp) - pos,
00195                 "MAC Address", mac2str(netif_default->hwaddr));
00196         pos += html_add_row(rsp + pos, sizeof(rsp) - pos,
00197                 "TX packets", get_tx());
00198         pos += html_add_row(rsp + pos, sizeof(rsp) - pos,
00199                 "RX packets", get_rx());
00200         pos += html_add_row(rsp + pos, sizeof(rsp) - pos,
00201 #if BOARD == EVK1104 || BOARD == EVK1101
00202                 "Light sensor ADC value",
00203 #elif BOARD == EVK1105 || BOARD == EVK1100
00204                 "ADC value",
00205 #else
00206 #error
00207 #endif
00208                             get_adc());
00209 
00210         pos += sniprintf(rsp + pos, sizeof(rsp) - pos,
00211                         "<tr><td><form method=\"get\">"
00212                         "<input type=\"submit\" value=\"Refresh\"/>"
00213                         "</form></td></tr>");
00214         
00215         
00216         pos += sniprintf(rsp + pos, sizeof(rsp) - pos,
00217                         "</table><br>");
00218         pos += sniprintf(rsp + pos, sizeof(rsp) - pos, "<form id=\"form\""
00219                         "name=\"form\" method=\"get\" action=\"index.html\">"
00220                         "<fieldset style=\"width: 300;\">"
00221                         "<legend>LED control</legend>");
00222         pos += html_add_button(rsp + pos, sizeof(rsp) - pos, "toggle", "LED0");
00223         pos += html_add_button(rsp + pos, sizeof(rsp) - pos, "toggle", "LED1");
00224         pos += html_add_button(rsp + pos, sizeof(rsp) - pos, "toggle", "LED2");
00225         pos += html_add_button(rsp + pos, sizeof(rsp) - pos, "toggle", "LED3");
00226         pos += sniprintf(rsp + pos, sizeof(rsp) - pos, "</fieldset></form>");
00227         
00228         pos += sniprintf(rsp + pos, sizeof(rsp) - pos, "</td>"
00229                         "<td>&nbsp;</td></tr></table></body></html>");
00230         
00231         *buf = rsp;
00232         *len = pos;
00233 }

static char* get_adc ( void   )  [static]

Definition at line 47 of file fsdata.c.

Referenced by document_index_html_cb().

00048 {
00049         volatile avr32_adc_t *adc = &AVR32_ADC;
00050         static char buf[8];
00051         signed short val;
00052         adc_start(adc);
00053         val = adc_get_value(adc, 0);
00054         
00055         sniprintf(buf, sizeof(buf), "%d", val);
00056         return buf;
00057 }

static char* get_rx ( void   )  [static]

Definition at line 76 of file fsdata.c.

Referenced by document_index_html_cb().

00077 {
00078         static char buf[8];
00079         sniprintf(buf, sizeof(buf), "%d", lwip_stats.link.recv);
00080         return buf;
00081 }

static char* get_tx ( void   )  [static]

Definition at line 64 of file fsdata.c.

Referenced by document_index_html_cb().

00065 {
00066         static char buf[8];
00067         sniprintf(buf, sizeof(buf), "%d", lwip_stats.link.xmit);
00068         return buf;
00069 }

static int html_add_button ( char *  buf,
int  len,
char *  id,
char *  value 
) [static]

Definition at line 99 of file fsdata.c.

Referenced by document_index_html_cb().

00100 {
00101         return sniprintf(buf, len, "<input type=\"submit\" name=\"%s\" "
00102              "value=\"%s\"/>&nbsp&nbsp",
00103              id, value);
00104 }

static int html_add_row ( char *  buf,
int  len,
char *  name,
const char *  data 
) [static]

Definition at line 88 of file fsdata.c.

Referenced by document_index_html_cb().

00089 {
00090         return sniprintf(buf, len, "<tr><td>%s: </td><td><b>%s</b></td></tr>",
00091                         name, data);
00092 }

void query_led0_cb ( const char **  buf,
int *  len 
)

Definition at line 240 of file fsdata.c.

References document_index_html_cb().

00241 {
00242         document_index_html_cb(buf, len);
00243         LED_Toggle(LED0);
00244 }

void query_led1_cb ( const char **  buf,
int *  len 
)

Definition at line 251 of file fsdata.c.

References document_index_html_cb().

00252 {
00253         document_index_html_cb(buf, len);
00254         LED_Toggle(LED1);
00255 }

void query_led2_cb ( const char **  buf,
int *  len 
)

Definition at line 262 of file fsdata.c.

References document_index_html_cb().

00263 {
00264         document_index_html_cb(buf, len);
00265         LED_Toggle(LED2);
00266 }

void query_led3_cb ( const char **  buf,
int *  len 
)

Definition at line 273 of file fsdata.c.

References document_index_html_cb().

00274 {
00275         document_index_html_cb(buf, len);
00276         LED_Toggle(LED3);
00277 }


Variable Documentation

Initial value:

 {
    "/404.html",
    document_404_html_cb,
    &file_image_gif,
}

Definition at line 310 of file fsdata.c.

Initial value:

 {
    "/image.gif",
    document_image_gif_cb,
    &file_led0,
}

Definition at line 304 of file fsdata.c.

Initial value:

 {
    "/index.html",
    document_index_html_cb,
    &file_404_html,
}

Definition at line 316 of file fsdata.c.

Initial value:

 {
    "/index.html?toggle=LED0",
    query_led0_cb,
    &file_led1,
}

Definition at line 298 of file fsdata.c.

Initial value:

 {
    "/index.html?toggle=LED1",
    query_led1_cb,
    &file_led2,
}

Definition at line 292 of file fsdata.c.

Initial value:

 {
    "/index.html?toggle=LED2",
    query_led2_cb,
    &file_led3,
}

Definition at line 286 of file fsdata.c.

Initial value:

 {
    "/index.html?toggle=LED3",
    query_led3_cb,
    NULL
}

Definition at line 280 of file fsdata.c.


Generated on Fri Feb 19 02:24:07 2010 for AVR32 - H&D by  doxygen 1.5.5