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)

GSwifiInterface.cpp

Committer:
gsfan
Date:
2013-10-31
Revision:
8:64184a968e3b
Parent:
5:78943b3945b5
Child:
11:71d67fea5ace

File content as of revision 8:64184a968e3b:

/* Copyright (C) 2013 gsfan, MIT License
 *  port to the GainSpan Wi-FI module GS1011
 */

#include "GSwifiInterface.h"

GSwifiInterface::GSwifiInterface( PinName tx, PinName rx, PinName cts, PinName rts, PinName reset, PinName alarm, int baud) :
    GSwifi(tx, rx, cts, rts, reset, alarm, baud)
{
}

int GSwifiInterface::init(const char* name)
{
    _state.dhcp = true;
    strncpy(_state.name, name, sizeof(_state.name));

    return 0;
}

int GSwifiInterface::init(const char* ip, const char* mask, const char* gateway, const char* name)
{
    _state.dhcp = false;
    strncpy(_state.ip, ip, sizeof(_state.ip));
    strncpy(_state.netmask, mask, sizeof(_state.netmask));
    strncpy(_state.gateway, gateway, sizeof(_state.gateway));
    strncpy(_state.name, name, sizeof(_state.name));

    return 0;
}

int GSwifiInterface::connect(Security sec, const char* ssid, const char* phrase, WiFiMode mode)
{
    switch (mode) {
    case WM_INFRASTRUCTURE:
        return join(sec, ssid, phrase);
    case WM_ADHOCK:
        return adhock(sec, ssid, phrase);
    case WM_LIMITEDAP:
        return limitedap(sec, ssid, phrase);
    }
    return -1;
}

int GSwifiInterface::disconnect()
{
    return GSwifi::disconnect();
}

char * GSwifiInterface::getMACAddress()
{
    return _state.mac;
}

char * GSwifiInterface::getIPAddress()
{
    return _state.ip;
}

char * GSwifiInterface::getGateway()
{
    return _state.gateway;
}

char * GSwifiInterface::getNetworkMask()
{
    return _state.netmask;
}