GainSpan Wi-Fi library see: http://mbed.org/users/gsfan/notebook/gainspan_wifi/

Fork of GSwifi_old by gs fan

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GSwifi_net.h Source File

GSwifi_net.h

Go to the documentation of this file.
00001 /**
00002  * Gainspan wi-fi module library for mbed
00003  * Copyright (c) 2012 gsfan
00004  * Released under the MIT License: http://mbed.org/license/mit
00005  */
00006 
00007 /** @file
00008  * @brief Gainspan wi-fi module library for mbed
00009  * GS1011MIC, GS1011MIP, GainSpan WiFi Breakout, etc.
00010  * module configuration: ATB=115200
00011  */
00012 
00013 #ifndef _GSWIFI_NET_H_
00014 #define _GSWIFI_NET_H_
00015 
00016 #include "mbed.h"
00017 #include "host.h"
00018 
00019 #define GS_USE_HTTPD  // use http server
00020 //#define GS_USE_WEBSOCKET  // use websocket (need httpd)
00021 #define GS_USE_SMTP  // use smtp client
00022 #define GS_SYSLOG // log for stdout
00023 
00024 
00025 #ifdef GS_SYSLOG
00026 #define LOG(...) printf("" __VA_ARGS__) 
00027 #else 
00028 #define LOG(...) 
00029 #endif 
00030 
00031 // GSwifi_smtp.cpp
00032 #ifdef GS_USE_SMTP
00033 
00034 #define SMTP_TIMEOUT 15000
00035 
00036 #endif
00037 
00038 
00039 // GSwifi_httpd.cpp
00040 #ifdef GS_USE_HTTPD
00041 
00042 #define HTTPD_TIMEOUT 15000
00043 #define HTTPD_HANDLE 10
00044 
00045 #define HTTPD_BUF_SIZE 200
00046 #define HTTPD_URI_SIZE 100
00047 
00048 #define HTTPD_KEEPALIVE 10 // request count
00049 
00050 enum GSHTTPDMODE {
00051     GSHTTPDMODE_REQUEST,
00052     GSHTTPDMODE_HEAD,
00053     GSHTTPDMODE_SPACE,
00054     GSHTTPDMODE_BODY,
00055     GSHTTPDMODE_ERROR,
00056     GSHTTPDMODE_WEBSOCKET,
00057     GSHTTPDMODE_WEBSOCKET_MASK,
00058     GSHTTPDMODE_WEBSOCKET_BODY,
00059 };
00060 
00061 struct GS_httpd {
00062     GSHTTPDMODE mode;
00063     int type;
00064     char *buf;  // body
00065     int len;  // length of buf
00066     char *uri;
00067     char *file;
00068     char *query;
00069     int length;  // content-length
00070     int keepalive;
00071     Host host;
00072 #ifdef GS_USE_WEBSOCKET
00073     int websocket;
00074     char *websocket_key;
00075     int websocket_flg;
00076     char websocket_mask[4];
00077     int websocket_payload;
00078 #endif
00079 };
00080 
00081 typedef void (*onHttpdCgiFunc)(int cid, GS_httpd *gshttpd);
00082 
00083 struct GS_httpd_handler {
00084     char *uri;
00085     char *dir;
00086     onHttpdCgiFunc onHttpCgi;
00087 };
00088 
00089 #endif
00090 
00091 #endif