Kazushi Mukaiyama / GSwifi

Fork of GSwifi_old by gs fan

Embed: (wiki syntax)

« Back to documentation index

GSwifi Class Reference

GSwifi Class Reference

GSwifi class. More...

#include <GSwifi.h>

Public Member Functions

 GSwifi (PinName p_tx, PinName p_rx, int baud=GS_BAUD)
 default constructor
 GSwifi (PinName p_tx, PinName p_rx, PinName p_cts, PinName p_rts, int baud=GS_BAUD)
 Default constructor (with hardware fllow controll)
int command (const char *cmd, GSRESPONCE res, int timeout=GS_TIMEOUT)
 send command
int cmdResponse (GSRESPONCE res, int ms)
 recv responce
int connect (GSSECURITY sec, const char *ssid, const char *pass, int dhcp=1, int reconnect=0)
 associate infrastructure
int adhock (GSSECURITY sec, const char *ssid, const char *pass, IpAddr ipaddr, IpAddr netmask)
 adhock
int limitedap (GSSECURITY sec, const char *ssid, const char *pass, IpAddr ipaddr, IpAddr netmask, char *dns=NULL)
 limited AP
int disconnect ()
 unassociate
int setAddress ()
 use DHCP
int setAddress (IpAddr ipaddr, IpAddr netmask, IpAddr gateway, IpAddr nameserver)
 use static ip address
int getAddress (IpAddr &ipaddr, IpAddr &netmask, IpAddr &gateway, IpAddr &nameserver)
 get ip address
int getHostByName (const char *name, IpAddr &addr)
 resolv hostname
int getHostByName (Host &host)
 resolv hostname
int setRFPower (int power)
 RF power.
int powerSave (int active, int save)
 power save mode
int standby (int msec)
 standby mode
int wakeup ()
 restore standby
int deepSleep ()
 deep sleep mode
bool isConnected ()
 wifi connected
GSSTATUS getStatus ()
 status
int getRssi ()
 RSSI.
int ntpdate (Host host, int sec=0)
 set NTP server
int setTime (time_t time)
 set system time
time_t getTime ()
 get RTC time
int gpioOut (int port, int out)
 GPIO output.
void poll ()
 main polling
int open (Host &host, GSPROTOCOL pro, onGsReceiveFunc ponGsReceive=NULL)
 tcp/udp client
int listen (int port, GSPROTOCOL pro, onGsReceiveFunc ponGsReceive=NULL)
 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 send (int cid, const char *buf, int len, Host &host)
 send data udp(s)
int recv (int cid, char *buf, int len)
 recv data tcp(s/c), udp(c)
int recv (int cid, char *buf, int len, Host &host)
 recv data udp(s)
bool isConnected (int cid)
 tcp/udp connected
int httpGet (Host &host, const char *uri, const char *user, const char *pwd, int ssl=0, onGsReceiveFunc ponGsReceive=NULL)
 http request (GET method)
int httpPost (Host &host, const char *uri, const char *body, const char *user, const char *pwd, int ssl=0, onGsReceiveFunc ponGsReceive=NULL)
 http request (POST method)
int certAdd (const char *name, const char *cert, int len)
 certificate
int mail (Host &host, const char *to, const char *from, const char *subject, const char *mesg, const char *user=NULL, const char *pwd=NULL)
 send mail (smtp)
int httpd (int port=80)
 start http server
void send_httpd_error (int cid, int err)
 attach uri to dirctory handler
int attach_httpd (const char *uri, const char *dir)
 attach uri to dirctory handler
int attach_httpd (const char *uri, onHttpdCgiFunc ponHttpCgi)
 attach uri to cgi handler
int provisioning (char *user, char *pass)
 Web server.
int setBaud (int baud)
 change baud rate
int base64encode (char *input, int length, char *output, int len)
 base64 encode
int urlencode (char *str, char *buf, int len)
 url encode
int urldecode (char *str, char *buf, int len)
 url decode

Detailed Description

GSwifi class.

Definition at line 135 of file GSwifi.h.


Constructor & Destructor Documentation

GSwifi ( PinName  p_tx,
PinName  p_rx,
int  baud = GS_BAUD 
)

default constructor

Definition at line 19 of file GSwifi.cpp.

GSwifi ( PinName  p_tx,
PinName  p_rx,
PinName  p_cts,
PinName  p_rts,
int  baud = GS_BAUD 
)

Default constructor (with hardware fllow controll)

Definition at line 34 of file GSwifi.cpp.


Member Function Documentation

int adhock ( GSSECURITY  sec,
const char *  ssid,
const char *  pass,
IpAddr  ipaddr,
IpAddr  netmask 
)

adhock

Parameters:
secGSSEC_OPEN or GSSEC_WEP
ssidSSID
pass10 or 26 hexadecimal digits
ipaddrmy ip address
netmasksubnet mask
Return values:
0success
-1failure

Definition at line 574 of file GSwifi.cpp.

int attach_httpd ( const char *  uri,
const char *  dir 
)

attach uri to dirctory handler

Definition at line 372 of file GSwifi_httpd.cpp.

int attach_httpd ( const char *  uri,
onHttpdCgiFunc  ponHttpCgi 
)

attach uri to cgi handler

Definition at line 386 of file GSwifi_httpd.cpp.

int base64encode ( char *  input,
int  length,
char *  output,
int  len 
)

base64 encode

Definition at line 1353 of file GSwifi.cpp.

int certAdd ( const char *  name,
const char *  cert,
int  len 
)

certificate

Definition at line 1313 of file GSwifi.cpp.

int close ( int  cid )

close client/server

Definition at line 1072 of file GSwifi.cpp.

int cmdResponse ( GSRESPONCE  res,
int  ms 
)

recv responce

Definition at line 345 of file GSwifi.cpp.

int command ( const char *  cmd,
GSRESPONCE  res,
int  timeout = GS_TIMEOUT 
)

send command

Definition at line 311 of file GSwifi.cpp.

int connect ( GSSECURITY  sec,
const char *  ssid,
const char *  pass,
int  dhcp = 1,
int  reconnect = 0 
)

associate infrastructure

Parameters:
secGSSEC_OPEN, GSSEC_WEP, GSSEC_WPA_PSK, GSSEC_WPA2_PSK, GSSEC_WPS_BUTTON
ssidSSID
passpass phrase
dhcp0:static ip, 1:dhcp
reconnectauto re-connect
Return values:
0success
-1failure

Definition at line 484 of file GSwifi.cpp.

int deepSleep (  )

deep sleep mode

Definition at line 819 of file GSwifi.cpp.

int disconnect (  )

unassociate

Definition at line 677 of file GSwifi.cpp.

int getAddress ( IpAddr ipaddr,
IpAddr netmask,
IpAddr gateway,
IpAddr nameserver 
)

get ip address

Definition at line 724 of file GSwifi.cpp.

int getHostByName ( const char *  name,
IpAddr addr 
)

resolv hostname

Parameters:
namehostname
addrresolved ip address

Definition at line 732 of file GSwifi.cpp.

int getHostByName ( Host host )

resolv hostname

Parameters:
host.namehostname
host.ipaddrresolved ip address

Definition at line 744 of file GSwifi.cpp.

int getRssi (  )

RSSI.

Returns:
RSSI (dBm)

Definition at line 835 of file GSwifi.cpp.

GSSTATUS getStatus (  )

status

Returns:
GSSTATUS

Definition at line 831 of file GSwifi.cpp.

time_t getTime (  )

get RTC time

Returns:
date time (UTC)

Definition at line 874 of file GSwifi.cpp.

int gpioOut ( int  port,
int  out 
)

GPIO output.

Parameters:
port10,11,30,31
out0:set(high), 1:reset(low)

Definition at line 882 of file GSwifi.cpp.

int httpd ( int  port = 80 )

start http server

Parameters:
port

Definition at line 24 of file GSwifi_httpd.cpp.

int httpGet ( Host host,
const char *  uri,
const char *  user,
const char *  pwd,
int  ssl = 0,
onGsReceiveFunc  ponGsReceive = NULL 
)

http request (GET method)

Definition at line 1204 of file GSwifi.cpp.

int httpPost ( Host host,
const char *  uri,
const char *  body,
const char *  user,
const char *  pwd,
int  ssl = 0,
onGsReceiveFunc  ponGsReceive = NULL 
)

http request (POST method)

Definition at line 1254 of file GSwifi.cpp.

bool isConnected ( int  cid )

tcp/udp connected

Definition at line 1200 of file GSwifi.cpp.

bool isConnected (  )

wifi connected

Definition at line 827 of file GSwifi.cpp.

int limitedap ( GSSECURITY  sec,
const char *  ssid,
const char *  pass,
IpAddr  ipaddr,
IpAddr  netmask,
char *  dns = NULL 
)

limited AP

Parameters:
secGSSEC_OPEN or GSSEC_WEP
ssidSSID
pass10 or 26 hexadecimal digits
ipaddrmy ip address (dhcp start address)
netmasksubnet mask
Return values:
0success
-1failure firmware: s2w-secureweb, s2w-web, s2w-wpsweb

Definition at line 622 of file GSwifi.cpp.

int listen ( int  port,
GSPROTOCOL  pro,
onGsReceiveFunc  ponGsReceive = NULL 
)

tcp/udp server

Returns:
CID, -1:failure

Definition at line 1053 of file GSwifi.cpp.

int mail ( Host host,
const char *  to,
const char *  from,
const char *  subject,
const char *  mesg,
const char *  user = NULL,
const char *  pwd = NULL 
)

send mail (smtp)

Parameters:
hostSMTP server
toTo address
fromFrom address
subjectSubject
mesgMessage
userusername (SMTP Auth)
pwdpassword (SMTP Auth)
Return values:
0success
-1failure

Definition at line 7 of file GSwifi_smtp.cpp.

int ntpdate ( Host  host,
int  sec = 0 
)

set NTP server

Parameters:
hostSNTP server
sectime sync interval, 0:one time

Definition at line 842 of file GSwifi.cpp.

int open ( Host host,
GSPROTOCOL  pro,
onGsReceiveFunc  ponGsReceive = NULL 
)

tcp/udp client

Returns:
CID, -1:failure

Definition at line 1034 of file GSwifi.cpp.

void poll (  )

main polling

Definition at line 978 of file GSwifi.cpp.

int powerSave ( int  active,
int  save 
)

power save mode

Parameters:
activerx radio 0:switched off, 1:always on
savepower save 0:disable, 1:enable

Definition at line 765 of file GSwifi.cpp.

int provisioning ( char *  user,
char *  pass 
)

Web server.

Definition at line 1330 of file GSwifi.cpp.

int recv ( int  cid,
char *  buf,
int  len,
Host host 
)

recv data udp(s)

Returns:
length

Definition at line 1183 of file GSwifi.cpp.

int recv ( int  cid,
char *  buf,
int  len 
)

recv data tcp(s/c), udp(c)

Returns:
length

Definition at line 1167 of file GSwifi.cpp.

int send ( int  cid,
const char *  buf,
int  len,
Host host 
)

send data udp(s)

Definition at line 1125 of file GSwifi.cpp.

int send ( int  cid,
const char *  buf,
int  len 
)

send data tcp(s/c), udp(c)

Definition at line 1084 of file GSwifi.cpp.

void send_httpd_error ( int  cid,
int  err 
)

attach uri to dirctory handler

Definition at line 337 of file GSwifi_httpd.cpp.

int setAddress (  )

use DHCP

Definition at line 691 of file GSwifi.cpp.

int setAddress ( IpAddr  ipaddr,
IpAddr  netmask,
IpAddr  gateway,
IpAddr  nameserver 
)

use static ip address

Definition at line 698 of file GSwifi.cpp.

int setBaud ( int  baud )

change baud rate

Definition at line 1339 of file GSwifi.cpp.

int setRFPower ( int  power )

RF power.

Parameters:
power0(high)-7(low)

Definition at line 756 of file GSwifi.cpp.

int setTime ( time_t  time )

set system time

Parameters:
timedate time (UTC)

Definition at line 863 of file GSwifi.cpp.

int standby ( int  msec )

standby mode

Parameters:
msecwakeup after wakeup after msec or alarm1/2 core off, save to RTC ram

Definition at line 776 of file GSwifi.cpp.

int urldecode ( char *  str,
char *  buf,
int  len 
)

url decode

Definition at line 1407 of file GSwifi.cpp.

int urlencode ( char *  str,
char *  buf,
int  len 
)

url encode

Definition at line 1387 of file GSwifi.cpp.

int wakeup (  )

restore standby

Definition at line 796 of file GSwifi.cpp.