Mbed Cloud example program for workshop in W27 2018.

Dependencies:   MMA7660 LM75B

Embed: (wiki syntax)

« Back to documentation index

WizFi310 Class Reference

WizFi310 Class Reference

WizFi310Interface class. More...

#include <WizFi310.h>

Public Member Functions

const char * get_firmware_version (void)
 Check firmware version of WizFi310.
bool startup (int mode)
 Startup the WizFi310.
bool reset (void)
 Reset WizFi310.
bool dhcp (bool enabled)
 Enable/Disable DHCP.
bool connect (const char *ap, const char *passPhrase, const char *sec)
 Connect WizFi310 to AP.
bool disconnect (void)
 Disconnect WizFi310 from AP.
const char * getIPAddress (void)
 Get the IP address of WizFi310.
const char * getMACAddress (void)
 Get the MAC address of WizFi310.
const char * getGateway ()
 Get the local gateway.
const char * getNetmask ()
 Get the local network mask.
bool isConnected (void)
 Check if WizFi310 is conenected.
int scan (WiFiAccessPoint *res, unsigned limit)
 Scan for available networks.
bool dns_lookup (const char *name, char *ip)
 Perform a dns query.
bool open (const char *type, int id, const char *addr, int port)
 Open a socketed connection.
bool send (int id, const void *data, uint32_t amount)
 Sends data to an open socket.
int32_t recv (int id, void *data, uint32_t amount)
 Receives data from an open socket.
bool close (int id)
 Closes a socket.
void setTimeout (uint32_t timeout_ms)
 Allows timeout to be changed between commands.
bool readable ()
 Checks if data is available.
bool writeable ()
 Checks if data can be written.
void attach (Callback< void()> func)
 Attach a function to call whenever network state has changed.
template<typename T , typename M >
void attach (T *obj, M method)
 Attach a function to call whenever network state has changed.

Detailed Description

WizFi310Interface class.

This is an interface to a WizFi310Interface radio.

Definition at line 44 of file WizFi310.h.


Member Function Documentation

void attach ( Callback< void()>  func )

Attach a function to call whenever network state has changed.

Parameters:
funcA pointer to a void function, or 0 to set as none

Definition at line 397 of file WizFi310.cpp.

void attach ( T *  obj,
method 
)

Attach a function to call whenever network state has changed.

Parameters:
objpointer to the object to call the member function on
methodpointer to the member function to call

Definition at line 224 of file WizFi310.h.

bool close ( int  id )

Closes a socket.

Parameters:
idid of socket to close, valid only 0-4
Returns:
true only if socket is closed successfully

Definition at line 365 of file WizFi310.cpp.

bool connect ( const char *  ap,
const char *  passPhrase,
const char *  sec 
)

Connect WizFi310 to AP.

Parameters:
apthe name of the AP
passPhrasethe password of AP
securitytype of AP
Returns:
true only if WizFi310 is connected successfully

Definition at line 120 of file WizFi310.cpp.

bool dhcp ( bool  enabled )

Enable/Disable DHCP.

Parameters:
enabledDHCP enabled when true
Returns:
true only if WizFi310 enables/disables DHCP successfully

Definition at line 114 of file WizFi310.cpp.

bool disconnect ( void   )

Disconnect WizFi310 from AP.

Returns:
true only if WizFi310 is disconnected successfully

Definition at line 160 of file WizFi310.cpp.

bool dns_lookup ( const char *  name,
char *  ip 
)

Perform a dns query.

Parameters:
nameHostname to resolve
ipBuffer to store IP address
Returns:
0 true on success, false on failure

Definition at line 267 of file WizFi310.cpp.

const char * get_firmware_version ( void   )

Check firmware version of WizFi310.

Returns:
character array firmware version or 0 if firmware query command gives outdated response

Definition at line 71 of file WizFi310.cpp.

const char * getGateway ( void   )

Get the local gateway.

Returns:
Null-terminated representation of the local gateway or null if no network mask has been recieved

Definition at line 188 of file WizFi310.cpp.

const char * getIPAddress ( void   )

Get the IP address of WizFi310.

Returns:
null-teriminated IP address or null if no IP address is assigned

Definition at line 165 of file WizFi310.cpp.

const char * getMACAddress ( void   )

Get the MAC address of WizFi310.

Returns:
null-terminated MAC address or null if no MAC address is assigned

Definition at line 177 of file WizFi310.cpp.

const char * getNetmask ( void   )

Get the local network mask.

Returns:
Null-terminated representation of the local network mask or null if no network mask has been recieved

Definition at line 193 of file WizFi310.cpp.

bool isConnected ( void   )

Check if WizFi310 is conenected.

Returns:
true only if the chip has an IP address

Definition at line 213 of file WizFi310.cpp.

bool open ( const char *  type,
int  id,
const char *  addr,
int  port 
)

Open a socketed connection.

Parameters:
typethe type of socket to open "UDP" or "TCP"
idid to give the new socket, valid 0-4
portport to open connection with
addrthe IP address of the destination
Returns:
true only if socket opened successfully

Definition at line 245 of file WizFi310.cpp.

bool readable ( void   )

Checks if data is available.

Definition at line 387 of file WizFi310.cpp.

int32_t recv ( int  id,
void *  data,
uint32_t  amount 
)

Receives data from an open socket.

Parameters:
idid to receive from
dataplaceholder for returned information
amountnumber of bytes to be received
Returns:
the number of bytes received

Definition at line 329 of file WizFi310.cpp.

bool reset ( void   )

Reset WizFi310.

Returns:
true only if WizFi310 resets successfully

Definition at line 100 of file WizFi310.cpp.

int scan ( WiFiAccessPoint *  res,
unsigned  limit 
)

Scan for available networks.

Parameters:
apPointer to allocated array to store discovered AP
limitSize of allocated res array, or 0 to only count available AP
Returns:
Number of entries in res, or if count was 0 number of available networks, negative on error see nsapi_error

Definition at line 218 of file WizFi310.cpp.

bool send ( int  id,
const void *  data,
uint32_t  amount 
)

Sends data to an open socket.

Parameters:
idid of socket to send to
datadata to be sent
amountamount of data to be sent - max 1024
Returns:
true only if data sent successfully

Definition at line 272 of file WizFi310.cpp.

void setTimeout ( uint32_t  timeout_ms )

Allows timeout to be changed between commands.

Parameters:
timeout_mstimeout of the connection

Definition at line 381 of file WizFi310.cpp.

bool startup ( int  mode )

Startup the WizFi310.

Parameters:
modemode of WIFI 0-client, 1-host
Returns:
true only if WizFi310 was setup correctly

Definition at line 87 of file WizFi310.cpp.

bool writeable ( void   )

Checks if data can be written.

Definition at line 392 of file WizFi310.cpp.