Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: X_NUCLEO_IKS01A1 mbed FP MQTTPacket DnsQuery ATParser
SpwfSAInterface Class Reference
SpwfSAInterface class Implementation of the NetworkStack for the SPWF Device. More...
#include <SpwfInterface.h>
Inherits NetworkStack, and WiFiInterface.
Public Member Functions | |
| SpwfSAInterface (PinName tx, PinName rx, bool debug) | |
| SpwfSAInterface constructor. | |
| virtual | ~SpwfSAInterface () |
| SpwfSAInterface destructor. | |
| virtual int | connect (const char *ssid, const char *pass, nsapi_security_t security=NSAPI_SECURITY_NONE) |
| network connect connects to Access Point | |
| virtual int | disconnect () |
| network disconnect disconnects from Access Point | |
| virtual const char * | get_mac_address () |
| Get the MAC address. | |
| void | debug (const char *string) |
| utility debug function for printing to serial terminal | |
| virtual const char * | get_ip_address () |
| Get the local IP address. | |
| virtual int | gethostbyname (SocketAddress *address, const char *host) |
| Translates a hostname to an IP address. | |
Protected Member Functions | |
| virtual int | socket_open (void **handle, nsapi_protocol_t proto) |
| open a socket handle | |
| virtual int | socket_close (void *handle) |
| close a socket | |
| virtual int | socket_bind (void *handle, const SocketAddress &address) |
| bind to a port number and address | |
| virtual int | socket_listen (void *handle, int backlog) |
| start listening on a port and address | |
| virtual int | socket_connect (void *handle, const SocketAddress &address) |
| connect to a remote socket | |
| virtual int | socket_accept (void **handle, void *server) |
| accept connections from remote sockets | |
| virtual int | socket_send (void *handle, const void *data, unsigned size) |
| write to a socket | |
| virtual int | socket_recv (void *handle, void *data, unsigned size) |
| receive data on a socket | |
| virtual int | socket_sendto (void *handle, const SocketAddress &address, const void *data, unsigned size) |
| send data to a udp socket | |
| virtual int | socket_recvfrom (void *handle, SocketAddress *address, void *buffer, unsigned size) |
| receive data on a udp socket | |
| virtual void | socket_attach (void *handle, void(*callback)(void *), void *data) |
| attach function/callback to the socket Not used | |
| virtual int | setsockopt (void *handle, int level, int optname, const void *optval, unsigned optlen) |
| Set the socket options Not used. | |
| virtual int | getsockopt (void *handle, int level, int optname, void *optval, unsigned *optlen) |
| Get the socket options Not used. | |
Friends | |
| class | Socket |
| class | UDPSocket |
| class | TCPSocket |
| class | TCPServer |
Detailed Description
SpwfSAInterface class Implementation of the NetworkStack for the SPWF Device.
Definition at line 48 of file SpwfInterface.h.
Constructor & Destructor Documentation
| SpwfSAInterface | ( | PinName | tx, |
| PinName | rx, | ||
| bool | debug | ||
| ) |
SpwfSAInterface constructor.
- Parameters:
-
tx,: Pin USART TX rx: Pin USART RX rst: reset pin for Spwf module wkup: reset pin for Spwf module rts: Pin USART RTS debug : not used
- Return values:
-
none
Definition at line 65 of file SpwfInterface.cpp.
| ~SpwfSAInterface | ( | ) | [virtual] |
SpwfSAInterface destructor.
- Parameters:
-
none
- Return values:
-
none
Definition at line 86 of file SpwfInterface.cpp.
Member Function Documentation
| int connect | ( | const char * | ap, |
| const char * | pass_phrase, | ||
| nsapi_security_t | security = NSAPI_SECURITY_NONE |
||
| ) | [virtual] |
network connect connects to Access Point
- Parameters:
-
ap,: Access Point (AP) Name String pass_phrase: Password String for AP security: type of NSAPI security supported
- Return values:
-
NSAPI Error Type
Implements WiFiInterface.
Definition at line 113 of file SpwfInterface.cpp.
| void debug | ( | const char * | string ) |
utility debug function for printing to serial terminal
- Parameters:
-
string,: Pointer to data
- Return values:
-
none
Definition at line 419 of file SpwfInterface.cpp.
| int disconnect | ( | void | ) | [virtual] |
network disconnect disconnects from Access Point
- Parameters:
-
none
- Return values:
-
NSAPI Error Type
Implements WiFiInterface.
Definition at line 152 of file SpwfInterface.cpp.
| const char * get_ip_address | ( | ) | [virtual] |
Get the local IP address.
- Parameters:
-
none
- Return values:
-
Null-terminated representation of the local IP address or null if not yet connected
Implements NetworkStack.
Definition at line 163 of file SpwfInterface.cpp.
| const char * get_mac_address | ( | ) | [virtual] |
Get the MAC address.
- Parameters:
-
none
- Return values:
-
Null-terminated representation of the MAC address or null if not yet connected
Implements WiFiInterface.
Definition at line 174 of file SpwfInterface.cpp.
| int gethostbyname | ( | SocketAddress * | address, |
| const char * | host | ||
| ) | [virtual, inherited] |
Translates a hostname to an IP address.
The hostname may be either a domain name or an IP address. If the hostname is an IP address, no network transactions will be performed.
If no stack-specific DNS resolution is provided, the hostname will be resolve using a UDP socket on the stack.
- Parameters:
-
address Destination for the host SocketAddress host Hostname to resolve
- Returns:
- 0 on success, negative error code on failure
Definition at line 20 of file NetworkStack.cpp.
| int getsockopt | ( | void * | handle, |
| int | level, | ||
| int | optname, | ||
| void * | optval, | ||
| unsigned * | optlen | ||
| ) | [protected, virtual] |
Get the socket options Not used.
- Parameters:
-
handle,: Pointer to handle level: SOL_SOCKET optname: option name optval: pointer to option value optlen: pointer to option length
- Return values:
-
NSAPI Error Type
Reimplemented from NetworkStack.
Definition at line 461 of file SpwfInterface.cpp.
| int setsockopt | ( | void * | handle, |
| int | level, | ||
| int | optname, | ||
| const void * | optval, | ||
| unsigned | optlen | ||
| ) | [protected, virtual] |
Set the socket options Not used.
- Parameters:
-
handle,: Pointer to handle level: SOL_SOCKET optname: option name optval: pointer to option value optlen: option length
- Return values:
-
NSAPI Error Type
< Allow bind to reuse local addresses
< Enables sending of keepalive messages
< Keeps close from returning until queues empty
< Sets send buffer size
< Sets recv buffer size
Reimplemented from NetworkStack.
Definition at line 434 of file SpwfInterface.cpp.
| int socket_accept | ( | void ** | handle, |
| void * | server | ||
| ) | [protected, virtual] |
accept connections from remote sockets
- Parameters:
-
handle,: Pointer to handle of client socket (connecting) proto: handle of server socket which will accept connections
- Return values:
-
NSAPI Error Type
Implements NetworkStack.
Definition at line 282 of file SpwfInterface.cpp.
| void socket_attach | ( | void * | handle, |
| void(*)(void *) | callback, | ||
| void * | data | ||
| ) | [protected, virtual] |
attach function/callback to the socket Not used
- Parameters:
-
handle,: Pointer to handle callback: callback function pointer data: pointer to data
- Return values:
-
none
Implements NetworkStack.
Definition at line 409 of file SpwfInterface.cpp.
| int socket_bind | ( | void * | handle, |
| const SocketAddress & | address | ||
| ) | [protected, virtual] |
bind to a port number and address
- Parameters:
-
handle,: Pointer to socket handle proto: address to bind to
- Return values:
-
NSAPI Error Type
Implements NetworkStack.
Definition at line 258 of file SpwfInterface.cpp.
| int socket_close | ( | void * | handle ) | [protected, virtual] |
close a socket
- Parameters:
-
handle,: Pointer to handle
- Return values:
-
NSAPI Error Type
Implements NetworkStack.
Definition at line 292 of file SpwfInterface.cpp.
| int socket_connect | ( | void * | handle, |
| const SocketAddress & | addr | ||
| ) | [protected, virtual] |
connect to a remote socket
- Parameters:
-
handle,: Pointer to socket handle addr: Address to connect to
- Return values:
-
NSAPI Error Type
Implements NetworkStack.
Definition at line 208 of file SpwfInterface.cpp.
| int socket_listen | ( | void * | handle, |
| int | backlog | ||
| ) | [protected, virtual] |
start listening on a port and address
- Parameters:
-
handle,: Pointer to handle backlog: not used (always value is 1)
- Return values:
-
NSAPI Error Type
Implements NetworkStack.
Definition at line 271 of file SpwfInterface.cpp.
| int socket_open | ( | void ** | handle, |
| nsapi_protocol_t | proto | ||
| ) | [protected, virtual] |
open a socket handle
- Parameters:
-
handle,: Pointer to handle proto: TCP/UDP protocol
- Return values:
-
NSAPI Error Type
Implements NetworkStack.
Definition at line 185 of file SpwfInterface.cpp.
| int socket_recv | ( | void * | handle, |
| void * | data, | ||
| unsigned | size | ||
| ) | [protected, virtual] |
receive data on a socket
- Parameters:
-
handle,: Pointer to handle data: pointer to data size: size of data
- Return values:
-
no of bytes read
Implements NetworkStack.
Definition at line 349 of file SpwfInterface.cpp.
| int socket_recvfrom | ( | void * | handle, |
| SocketAddress * | addr, | ||
| void * | data, | ||
| unsigned | size | ||
| ) | [protected, virtual] |
receive data on a udp socket
- Parameters:
-
handle,: Pointer to handle addr: address of udp socket data: pointer to data size: size of data
- Return values:
-
no of bytes read
Implements NetworkStack.
Definition at line 395 of file SpwfInterface.cpp.
| int socket_send | ( | void * | handle, |
| const void * | data, | ||
| unsigned | size | ||
| ) | [protected, virtual] |
write to a socket
- Parameters:
-
handle,: Pointer to handle data: pointer to data size: size of data
- Return values:
-
no of bytes sent
Implements NetworkStack.
Definition at line 319 of file SpwfInterface.cpp.
| int socket_sendto | ( | void * | handle, |
| const SocketAddress & | addr, | ||
| const void * | data, | ||
| unsigned | size | ||
| ) | [protected, virtual] |
send data to a udp socket
- Parameters:
-
handle,: Pointer to handle addr: address of udp socket data: pointer to data size: size of data
- Return values:
-
no of bytes sent
Implements NetworkStack.
Definition at line 374 of file SpwfInterface.cpp.
Generated on Wed Jul 13 2022 20:28:49 by
1.7.2