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

Dependents:   GSwifiInterface_HelloWorld GSwifiInterface_HelloServo GSwifiInterface_UDPEchoServer GSwifiInterface_UDPEchoClient ... more

Fork of WiflyInterface by mbed official

GainSpan Wi-Fi library

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

mbed RTOS supported.

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

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

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

mbed RTOS に対応しています。(mbed2.0)

WiflyInterface.cpp

Committer:
samux
Date:
2012-08-24
Revision:
1:fb4494783863

File content as of revision 1:fb4494783863:

#include "WiflyInterface.h"

WiflyInterface::WiflyInterface( PinName tx, PinName rx, PinName reset, PinName tcp_status,
                                const char * ssid, const char * phrase, Security sec) :
    Wifly(tx, rx, reset, tcp_status, ssid, phrase, sec)
{
    ip_set = false;
}

int WiflyInterface::init()
{
    state.dhcp = true;
    reset();
    return 0;
}

int WiflyInterface::init(const char* ip, const char* mask, const char* gateway)
{
    state.dhcp = false;
    this->ip = ip;
    strcpy(ip_string, ip);
    ip_set = true;
    this->netmask = mask;
    this->gateway = gateway;
    reset();

    return 0;
}

int WiflyInterface::connect()
{
    return join();
}

int WiflyInterface::disconnect()
{
    return Wifly::disconnect();
}

char * WiflyInterface::getIPAddress()
{
    char * match = 0;
    if (!ip_set) {
        if (!sendCommand("get ip a\r", NULL, ip_string))
            return NULL;
        exit();
        flush();
        match = strstr(ip_string, "<");
        if (match != NULL) {
            *match = '\0';
        }
        if (strlen(ip_string) < 6) {
            match = strstr(ip_string, ">");
            if (match != NULL) {
                int len = strlen(match + 1);
                memcpy(ip_string, match + 1, len);
            }
        }
        ip_set = true;
    }
    return ip_string;
}