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

Dependents:   GSwifi_httpd GSwifi_websocket GSwifi_tcpclient GSwifi_tcpserver ... more

Fork of GSwifi by gs fan

GainSpan Wi-Fi library

The GS1011 is an ultra low power 802.11b wireless module from GainSpan.

see: http://mbed.org/users/gsfan/notebook/gainspan_wifi/

/media/uploads/gsfan/gs_im_002.jpg /media/uploads/gsfan/gs1011m_2.jpg

ゲインスパン Wi-Fi モジュール ライブラリ

ゲインスパン社の低電力 Wi-Fiモジュール(無線LAN) GS1011 シリーズ用のライブラリです。

解説: http://mbed.org/users/gsfan/notebook/gainspan_wifi/

GSwifi_net.h

Committer:
gsfan
Date:
2013-02-11
Revision:
25:f6e5622d2930
Parent:
24:5c350ae2e703

File content as of revision 25:f6e5622d2930:

/* Copyright (C) 2013 gsfan, MIT License
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
 * and associated documentation files (the "Software"), to deal in the Software without restriction,
 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
/** @file
 * @brief Gainspan wi-fi module library for mbed
 * GS1011MIC, GS1011MIP, GainSpan WiFi Breakout, etc.
 */

#ifndef _GSWIFI_NET_H_
#define _GSWIFI_NET_H_

#include "mbed.h"
#include "host.h"

#define GS_USE_HTTPD  // use http server
//#define GS_USE_WEBSOCKET  // use websocket (need httpd)
#define GS_USE_SMTP  // use smtp client
#define GS_SYSLOG // log for stdout


#ifdef GS_SYSLOG
#define LOG(...) printf("" __VA_ARGS__) 
#else 
#define LOG(...) 
#endif 

// GSwifi_smtp.cpp
#ifdef GS_USE_SMTP

#define SMTP_TIMEOUT 15000

#endif


// GSwifi_httpd.cpp
#ifdef GS_USE_HTTPD

#define HTTPD_TIMEOUT 15000
#define HTTPD_HANDLE 10

#define HTTPD_BUF_SIZE 200
#define HTTPD_URI_SIZE 100

#define HTTPD_KEEPALIVE 10 // request count

enum GSHTTPDMODE {
    GSHTTPDMODE_REQUEST,
    GSHTTPDMODE_HEAD,
    GSHTTPDMODE_SPACE,
    GSHTTPDMODE_BODY,
    GSHTTPDMODE_ERROR,
    GSHTTPDMODE_WEBSOCKET,
    GSHTTPDMODE_WEBSOCKET_MASK,
    GSHTTPDMODE_WEBSOCKET_BODY,
};

struct GS_httpd {
    GSHTTPDMODE mode;
    int type;
    char *buf;  // body
    int len;  // length of buf
    char *uri;
    char *file;
    char *query;
    int length;  // content-length
    int keepalive;
    Host host;
#ifdef GS_USE_WEBSOCKET
    int websocket;
    char *websocket_key;
    int websocket_flg;
    char websocket_mask[4];
    int websocket_payload;
#endif
};

typedef void (*onHttpdCgiFunc)(int cid, GS_httpd *gshttpd);

struct GS_httpd_handler {
    char *uri;
    char *dir;
    onHttpdCgiFunc onHttpCgi;
};

#endif

#endif