leo hendrickson / Mbed OS example-Ethernet-mbed-Cloud-connect
Embed: (wiki syntax)

« Back to documentation index

WizFi310 Class Reference

WizFi310 Class Reference

WizFi310Interface class. More...

#include <WizFi310.h>

Public Member Functions

 WizFi310 (PinName tx, PinName rx, PinName rtx=NC, PinName cts=NC, PinName rst=NC)
 Creates a new WizFir310 driver.
const char * get_firmware_version (void)
 Check firmware version of WizFi310.
bool dhcp (bool enabled)
 Enable/Disable DHCP.
void attach (Callback< void(nsapi_connection_status_t)> status_change_cb)
 Attach a callback that will be invoked when the status changes.
nsapi_error_t connect (const char *ap, const char *passPhrase, const char *sec)
 Connect WizFi310 to AP.
nsapi_connection_status_t status () const
 Returns the current connection status.
nsapi_error_t disconnect ()
 Disconnect WizFi310 from AP.
nsapi_error_t scan (Callback< void(nsapi_wifi_ap_t *)> ap_cb)
int open (const char *type, const char *addr, int port, Callback< void(void *, socket_event_t, socket_event_data_t &)> callback, void *data)
 Open a socketed connection.
int send (int id, const void *data, uint32_t amount)
 Sends data to an open socket.
void close (int id)
 Closes a socket.

Detailed Description

WizFi310Interface class.

This is an interface to a WizFi310Interface radio.

Definition at line 54 of file WizFi310.h.


Constructor & Destructor Documentation

WizFi310 ( PinName  tx,
PinName  rx,
PinName  rtx = NC,
PinName  cts = NC,
PinName  rst = NC 
)

Creates a new WizFir310 driver.

Parameters:
txTx pin name.
rxRx pin name.
rtsRts pin name.
ctsCts pin name.
rstRst pin name.

Definition at line 105 of file WizFi310.cpp.


Member Function Documentation

void attach ( Callback< void(nsapi_connection_status_t)>  status_change_cb )

Attach a callback that will be invoked when the status changes.

Definition at line 136 of file WizFi310.cpp.

void close ( int  id )

Closes a socket.

Note:
This is non-blocking.
Parameters:
idid of socket to close, valid only 0-4
Returns:
true only if socket is closed successfully

Definition at line 289 of file WizFi310.cpp.

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

Connect WizFi310 to AP.

Note:
This is blocking.
Parameters:
apthe name of the AP
passPhrasethe password of AP
securitytype of AP
Returns:
see nsapi_error_t

Definition at line 171 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 141 of file WizFi310.cpp.

nsapi_error_t disconnect ( void   )

Disconnect WizFi310 from AP.

Returns:
see nsapi_error_t.

Definition at line 208 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
Warning:
This is only valid once the device is ready.
int open ( const char *  type,
const char *  addr,
int  port,
Callback< void(void *, socket_event_t, socket_event_data_t &)>  callback,
void *  data 
)

Open a socketed connection.

Note:
This is non-blocking.
Parameters:
typethe type of socket to open "UDP" or "TCP"
portport to open connection with
addrthe IP address of the destination
callbackFunction to call on state change
dataArgument to pass to callback
Note:
The callback is always called from the global event queue thread.
Returns:

Definition at line 223 of file WizFi310.cpp.

nsapi_error_t scan ( Callback< void(nsapi_wifi_ap_t *)>  ap_cb )
Parameters:
ap_cbCalled for each access point found. Last ap is NULL.
Returns:
IN_PROGRESS or WOULD_BLOCK.

Definition at line 148 of file WizFi310.cpp.

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

Sends data to an open socket.

Note:
This is non-blocking.
Parameters:
idid of socket to send to
datadata to be sent
amountamount of data to be sent
Returns:

Definition at line 260 of file WizFi310.cpp.

nsapi_connection_status_t status (  ) const

Returns the current connection status.

Returns:
Current connection status.

Definition at line 125 of file WizFi310.h.