GSwifiInterface library

GSwifiInterface library

/media/uploads/gsfan/gs1011m_2.jpg

about GainSpan Wi-Fi module

Telit

GainSpan社は Telit に変わりました。

Information

With this library, you will be able to add a wireless connectivity to your mbed. This library relies on GS1011 modules from GainSpan. These modules can be found on DIY Sandbox for instance.

The objective of this library is to provide the same API as the EthernetInterface. So all programs using the EthernetInterface are compatible with the GSwifiInterface.

このライブラリは、あなたの mbed にWi-Fi(無線LAN)によるワイヤレス接続を付加します。 GainSpan社の GS1011 モジュール用です。 モジュールはここ(日本向け)で入手することができます。

このライブラリのAPIは EthernetInterface と互換性があり、置き換えることができます。

GainSpan Wi-Fiモジュールが持つ色々な機能を使えるようになりました。

mbed RTOS に対応している・・・はずです。

※ 現在は GS2000(GS2K) シリーズが販売されています。 本ページにも順次加筆していきます。

Software

Import libraryGSwifiInterface

GSwifiInterface library (interface for GainSpan Wi-Fi GS1011 modules) Please see https://mbed.org/users/gsfan/notebook/GSwifiInterface/

LPC1768

    GSwifiInterface gs(p13, p14, p12, P0_22, p20, NC);

    gs.init(); //Use DHCP
      or
    gs.init("192.168.1.123", "255.255.255.0", "192.168.0.1", "192.168.0.2"); //Use Static IP

    gs.connect(GSwifi::SEC_WEP, "SSID", "PASSKEY"));
        :

9600bps以外(ATBコマンドであらかじめ設定)で使用する場合は、GSwifiInterface宣言時の7番目の引数にボーレートを指定してください。

Import library

Public Types

enum WiFiMode

Wi-Fi mode.

More...
enum Security

Wi-Fi security.

More...
enum Protocol

TCP/IP protocol.

More...
enum Type

Client/Server.

More...

Public Member Functions

GSwifiInterface (PinName tx, PinName rx, PinName cts, PinName rts, PinName reset, PinName alarm=NC, int baud=9600)
Constructor.
int init (const char *name=NULL)
Initialize the interface with DHCP.
int init (const char *ip, const char *mask, const char *gateway, const char *name=NULL)
Initialize the interface with a static IP address.
int connect ( Security sec, const char *ssid, const char *phrase, WiFiMode mode=WM_INFRASTRUCTURE)
Connect Bring the interface up, start DHCP if needed.
int disconnect ()
Disconnect Bring the interface down.
char * getMACAddress ()
Get the MAC address of your Ethernet interface.
char * getIPAddress ()
Get the IP address of your Ethernet interface.
char * getGateway ()
Get the Gateway address of your Ethernet interface.
char * getNetworkMask ()
Get the Network mask of your Ethernet interface.
int join ( Security sec, const char *ssid, const char *phrase)
Connect the wifi module to the ssid contained in the constructor.
int adhock ( Security sec, const char *ssid, const char *phrase)
Connect the wifi module to the adhock in the constructor.
int limitedap ( Security sec, const char *ssid, const char *phrase)
Connect the wifi module to the limited AP in the constructor.
bool isConnected ()
Check if a tcp link is active.
bool isConnected (int cid)
tcp/udp connected
int getRssi ()
RSSI.
int powerSave (int active, int save)
power save mode
int setRfPower (int power)
RF power.
int setTime (time_t time)
set system time
time_t getTime ()
get system time
int ntpdate (char *host, int sec=0)
set NTP server
int setGpio (int port, int out)
GPIO output.
int provisioning (char *user, char *pass)
Web server.
int standby (int msec)
standby mode
int deepSleep ()
deep sleep mode
int wakeup ()
restore standby or deep sleep
int getHostByName (const char *host, char *ip)
Resolv hostname.
int open ( Protocol proto, const char *ip, int port, int src=0)
TCP/UDP client.
int listen ( Protocol proto, int port)
TCP/UDP server.
int close (int cid)
close client/server
int send (int cid, const char *buf, int len)
send data tcp(s/c), udp(c)
int recv (int cid, char *buf, int len)
recv data tcp(s/c), udp(c)
int recvfrom (int cid, char *buf, int len, char *ip, int *port)
recv data udp(s)
int readable (int cid)
readable recv data
int sendCommand (const char *cmd, Response res=RES_NULL, int timeout=DEFAULT_WAIT_RESP_TIMEOUT)
Send a command to the wifi module.
int sendData (const char *data, int len, int timeout=DEFAULT_WAIT_RESP_TIMEOUT, const char *cmd=NULL)
Send a command to the wifi module.

Configuration

GSwifi_conf.h

#define CFG_ENABLE_RTOS
//#define CFG_ENABLE_HTTPD
//#define CFG_ENABLE_WEBSOCKET
//#define CFG_ENABLE_SMTP
//#define CFG_UART_DIRECT

mbed RTOS を使用したくない場合は #undef CFG_ENABLE_RTOS してください。
RAM容量の少ないCPUを使う場合や、HTTPD, WEBSOCKET, SMTP 等の機能を有効にする場合、 RTOS を使用しないほうが安定すると思います。

DISABLE_RTOS

    GSwifi gs(p13, p14, p12, P0_22, p20, NC);

    gs.setAddress(); //Use DHCP
    gs.setAddress("192.168.1.123", "255.255.255.0", "192.168.0.1", "192.168.0.2"); //Use Static IP
    gs.setSsid(GSwifi::SEC_WPA_PSK, "SSID", "PASSKEY");

    gs.join();
        :

Hardware

GS1011 pin+++Mbed pin
VBATTVOUT
DC_DC_OUTVDDIO
GNDGND
UART0_RXSerial TX
UART0_TXSerial RX
RESETany DigitalOut

RTS/CTSも接続することをおすすめします。

対応CPUフロー制御
mbed LPC1768RTS/CTS or GPIO
mbed LPC11U24RTS/CTS or GPIO
EA LPC4088RTS/CTS or GPIO
FRDM KL25ZGPIO
LPC800-MAXGPIO

ボーレートは 9600bps(デフォルト)に設定してください。
9600bps以外(ATBコマンドであらかじめ設定)で使用する場合は、宣言時の引数にボーレートを指定してください。

UART & SPI (GS2000)

コマンドをUART、データストリームをSPIとすれば、CPU=モジュール間のインターフェースが10Mbpsと高速になる。

ファームウェアは SDK BUILDER にて構成し、GS2000モジュールへ書き込んでおく。

GS2000→CPUのデータストリームは、WAKEピンのHighを検出して、ダミーデータ(0xf5)を送ることにより取得できる。
CPU→GS2000のデータストリームは、WAKEピンがLowのときにデータを送る。
データの書式は、UARTのときと同じ。

Hello World

TCP Echo Server

Import programGSwifiInterface_TCPEchoServer

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

TCP Echo Client

Import programGSwifiInterface_TCPEchoClient

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

UDP Echo Server

Import programGSwifiInterface_UDPEchoServer

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

UDP Echo Client

Import programGSwifiInterface_UDPEchoClient

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

WebSocket Client

Import programGSwifiInterface_WebSocket

WebSocket Client for GSwifiInterface library Please see: http://mbed.org/users/gsfan/notebook/GSwifiInterface/

参考:Mbed Websocket Server について

HTTP Server

MQTT Client

Import programGSwifiInterface_HelloMQTT

Sample MQTT program - simple send and receive (MQ Telemetry Transport) for GainSpan Wi-Fi module

More details


1 comment on GSwifiInterface library:

11 Feb 2016

Does it support GS2100MIP / GS2011MIZ Wi-Fi Shields?

Please log in to post comments.