X-NUCLEO-IDW01M1 Wi-Fi expansion board mbed OS 2 ("Classic") library. mbed OS 5 library also available (see below).
Dependencies: SPWF01SA
Dependents: SpwfInterface_NSAPI_Testsv2 Nucleo_read_a0_thingspace Nucleo_read_a0_thingspace_mems Cayenne-X-NUCLEO-IDW01M1 ... more
Fork of X_NUCLEO_IDW01M1v2 by
Introduction
X_NUCLEO_IDW01M1 is a mbed library for the Wi-Fi expansion board X-NUCLEO-IDW01M1 compatible with STM32 Nucleo.
The software can be used for building Wi-Fi applications with the SPWF01SA module. It is an implementation of the NetworkSocketAPI library from mbed OS 2 ("Classic").
mbed OS 5 library can instead be found at this link.
Firmware Library
The X_NUCLEO_IDW01M1 library comes with a sample application (HelloWorld_IDW01M1v2) and a NSAPI test suite application (SpwfInterface_NSAPI_Testsv2).
This library is only supported on NUCLEO platforms and any platforms with Arduino connector. However connection to arduino needs to be done manually using 4 wires for Vdd, Gnd, Rx and Tx. Example applications have more specific details on exact connections to be used.
The features of the library are :
- Supports mbed OS 2 ("Classic") NetworkSocketAPI
- Supports both client sockets
- Configuration of USART pins to be used
Class SpwfSAInterface is intended to represent the X-NUCLEO-IDW01M1 expansion board with the SPWF module.
The expansion board is basically featuring the component:
- a SPWF01SA Serial-to-Wi-Fi module
Example Applications
NSAPI Test Suite
Revision 1:fd7b3df18dd7, committed 2016-07-05
- Comitter:
- mridup
- Date:
- Tue Jul 05 11:03:15 2016 +0000
- Parent:
- 0:907910bfb0b5
- Child:
- 2:610672ed2e9f
- Commit message:
- remove compiler errors and fixing code
Changed in this revision
| SpwfInterface.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/SpwfInterface.cpp Tue Jul 05 09:36:47 2016 +0000
+++ b/SpwfInterface.cpp Tue Jul 05 11:03:15 2016 +0000
@@ -88,7 +88,11 @@
int SpwfSAInterface::init(void)
{
_spwf.setTimeout(SPWF_MISC_TIMEOUT);
- return (_spwf.startup(0));
+ if(_spwf.startup(0)) {
+ isInitialized=true;
+ return true;
+ }
+ else return NSAPI_ERROR_DEVICE_ERROR;
}
/**
@@ -108,9 +112,8 @@
//initialize the device before connecting
if(!isInitialized)
{
- if(init()==0)
- isInitialized=true;
- else return NSAPI_ERROR_DEVICE_ERROR;
+ if(!init())
+ return NSAPI_ERROR_DEVICE_ERROR;
}
_spwf.setTimeout(SPWF_CONNECT_TIMEOUT);
@@ -204,7 +207,9 @@
const char *proto = (socket->proto == NSAPI_UDP) ? "u" : "t";//"s" for secure socket?
- _spwf.open(proto, &sock_id, addr.get_ip_address(), addr.get_port());//sock ID is allocated NOW
+ if (!_spwf.open(proto, &sock_id, addr.get_ip_address(), addr.get_port())) {;//sock ID is allocated NOW
+ return NSAPI_ERROR_DEVICE_ERROR;
+ }
//TODO: Maintain a socket table to map socket ID to host & port
//TODO: lookup on client table to see if already socket is allocated to same host/port
@@ -270,20 +275,13 @@
if(socket->id!=-1)
{
- if(socket->id==SERVER_SOCKET_NO)
- {
- //if (_spwf.socket_server_close()==-1) {
- //err = NSAPI_ERROR_DEVICE_ERROR;
- //}
- isListening = false;
+ if (_spwf.close(socket->id)) {
+ if(socket->id==SERVER_SOCKET_NO)
+ isListening = false;
+ else
+ _ids[socket->id] = false;
}
- else
- {
- //if (_spwf.socket_client_close(socket->id)==-1) {
- //err = NSAPI_ERROR_DEVICE_ERROR;
- //}
- _ids[socket->id] = false;
- }
+ else err = NSAPI_ERROR_DEVICE_ERROR;
}
delete socket;
@@ -302,17 +300,17 @@
struct spwf_socket *socket = (struct spwf_socket *)handle;
int err;
- if(socket->id==SERVER_SOCKET_NO)
+ /*if(socket->id==SERVER_SOCKET_NO)
{
if(socket->server_port==-1 || !isListening)
return NSAPI_ERROR_NO_SOCKET; //server socket not bound or not listening
- //err = _spwf.socket_server_write((uint16_t)size, (char*)data);
+ err = _spwf.socket_server_write((uint16_t)size, (char*)data);
}
else
- {
- //err = _spwf.socket_client_write((uint8_t)socket->id, (uint16_t)size, (char*)data);
- }
+ {*/
+ err = _spwf.send(socket->id, (char*)data, (uint32_t)size);
+ //}
return err;
}
@@ -332,10 +330,10 @@
_spwf.setTimeout(SPWF_RECV_TIMEOUT);
//CHECK:Receive for both Client and Server Sockets same?
- //recv = _spwf.socket_client_recv((uint8_t)socket->id, (uint16_t)size, (char*)data);
- //if (recv < 0) {
- //return NSAPI_ERROR_WOULD_BLOCK;
- //}
+ recv = _spwf.recv(socket->id, (char*)data, (uint32_t)size);
+ if (recv < 0) {
+ return NSAPI_ERROR_WOULD_BLOCK;
+ }
return recv;
}

X-NUCLEO-IDW01M1 Wi-Fi expansion board