MCUXpresso SDK API Reference Manual  Rev 2.16.000
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
SerialMWM

Overview

Data Structures

struct  mwm_sockaddr_t
 SerialMWM socket address structure. More...
 
struct  mwm_wlan_t
 SerialMWM WLAN structure. More...
 

Initialization

int mwm_init (void)
 Initializes SerialMWM library. More...
 

WLAN API

int mwm_version (char *value, uint32_t val_len)
 Gets SerialMWM firmware version. More...
 
int mwm_upgrade (char *type, char *url)
 Upgrades firmware of Wi-Fi module. More...
 
int mwm_reboot (void)
 Reboots Wi-Fi module. More...
 
int mwm_wlan_fw_version (char *value, uint32_t val_len)
 Gets WLAN firmware version. More...
 
int mwm_wlan_start (void)
 Start WLAN subsystem. More...
 
int mwm_wlan_status (void)
 Gets WLAN status. More...
 
int mwm_wlan_prov (void)
 Resets WLAN module to provisioning mode. More...
 
int mwm_wlan_info (char *ssid, char *ip_addr)
 Gets WLAN information. More...
 
int mwm_wlan_scan (mwm_wlan_t *wlans, uint32_t wlan_count)
 Scans WLAN. More...
 
int mwm_wlan_connect (void)
 Connects to WLAN. More...
 
int mwm_wlan_disconnect (void)
 Disconnects from WLAN. More...
 

Device Configuration API

int mwm_get_param (char *module, char *param, char *value, uint32_t val_len)
 Gets parameter from Wi-Fi module. More...
 
int mwm_set_param (char *module, char *param, char *value)
 Sets parameter from Wi-Fi module. More...
 

Socket API

int mwm_socket (int type)
 Opens socket. More...
 
int mwm_connect (int socket, mwm_sockaddr_t *addr, uint32_t addrlen)
 Opens socket. More...
 
int mwm_send (int socket, void *buf, size_t len)
 Sends data. More...
 
int mwm_sendto (int socket, void *buf, int len, mwm_sockaddr_t *to, int tolen)
 Sends data. More...
 
int mwm_recv_timeout (int socket, void *buf, size_t len, uint32_t timeout_ms)
 Receives data. More...
 
int mwm_recvfrom_timeout (int socket, void *buf, size_t len, uint32_t timeout_ms)
 Receives data. More...
 
int mwm_close (int socket)
 Closes socket. More...
 

Data Structure Documentation

struct mwm_sockaddr_t

Data Fields

char host [64]
 Hostname or IP Address.
 
struct mwm_wlan_t

Function Documentation

int mwm_init ( void  )

This function resets connected Wi-Fi module by reset pin (if supported) and initializes the UART interface for communication with Wi-Fi module.

Return values
-1Error
0Success
int mwm_version ( char *  value,
uint32_t  val_len 
)

This function gets SerialMWM firmware version of the Wi-Fi module.

Parameters
valuePointer to buffer where the version string will be stored
val_lenLength of value buffer
Returns
0 - success, negative number - error
int mwm_upgrade ( char *  type,
char *  url 
)

This function upgrades SerialMWM firmware, WLAN firmware or it can be used to check the upgrade status.

Parameters
typeMWM_UPGRADE_MCU_FW for SerialMWM FW upgrade, MWM_UPGRADE_WLAN_FW for WLAN FW upgrade or MWM_UPGRADE_STATUS to check upgrade status
urlURL of firmware image file for upgrade or NULL in case of upgrade status check
Returns
0 - success, negative number - error
int mwm_reboot ( void  )

This function reboots Wi-Fi module and re-initializes UART interface.

Returns
0 - success, negative number - error
int mwm_wlan_fw_version ( char *  value,
uint32_t  val_len 
)

This function gets WLAN firmware version of the Wi-Fi module.

Parameters
valuePointer to buffer where the version string will be stored
val_lenLength of value buffer
Returns
0 - success, negative number - error
int mwm_wlan_start ( void  )
Returns
0 - success, negative number - error
int mwm_wlan_status ( void  )
Returns
0 - success, negative number - error
int mwm_wlan_prov ( void  )
Returns
0 - success, negative number - error
int mwm_wlan_info ( char *  ssid,
char *  ip_addr 
)

This function gets WLAN information (SSID and IP Address) from the Wi-Fi module.

Parameters
ssidPointer to buffer where the SSID string will be stored
ip_addrPointer to buffer where the IP Address string will be stored
Returns
0 - success, negative number - error
int mwm_wlan_scan ( mwm_wlan_t *  wlans,
uint32_t  wlan_count 
)

This function gets cached scan results and schedules a new scan.

Parameters
wlansPointer to array of mwm_wlan_t where the WLAN struct will be stored
wlan_countLength of wlans array
Returns
0 - success, negative number - error
int mwm_wlan_connect ( void  )

This function attempts to make an explicit connection with the configured WLAN.

Returns
0 - success, negative number - error
int mwm_wlan_disconnect ( void  )

This function disconnects Wi-Fi module from WLAN it is connected to.

Returns
0 - success, negative number - error
int mwm_get_param ( char *  module,
char *  param,
char *  value,
uint32_t  val_len 
)

This function gets parameter from Wi-Fi module.

Parameters
moduleModule of requested parameter, it can be MWM_MOD_PROV, MWM_MOD_WLAN or MWM_MOD_SYSTEM
paramName of requested parameter, it can be MWM_PROV_*, MWM_WLAN_* or MWM_SYS_* based on selected module
valuePointer to buffer where the value of requested parameter will be stored
val_lenLength of value buffer
Returns
0 - success, negative number - error
int mwm_set_param ( char *  module,
char *  param,
char *  value 
)

This function sets parameter of Wi-Fi module.

Parameters
moduleModule whose parameter will be set, it can be MWM_MOD_PROV, MWM_MOD_WLAN or MWM_MOD_SYSTEM
paramName of configured parameter, it can be MWM_PROV_*, MWM_WLAN_* or MWM_SYS_* based on selected module
valuePointer to string value of configured parameter
Returns
0 - success, negative number - error
int mwm_socket ( int  type)

This function opens socket.

Parameters
typeType of socket, it can be MWM_TCP or MWM_UDP
Returns
handle of socket, negative number - error
int mwm_connect ( int  socket,
mwm_sockaddr_t *  addr,
uint32_t  addrlen 
)

This function connects the socket to remote host.

Parameters
socketHandle of socket
addrValid address of remote host
addrlenSize of addr
Returns
0 - success, negative number - error
int mwm_send ( int  socket,
void *  buf,
size_t  len 
)

This function sends data over a connected socket.

Parameters
socketHandle of socket
bufPointer to data buffer
lenSize of buf
Returns
Number of bytes sent, negative number - error
int mwm_sendto ( int  socket,
void *  buf,
int  len,
mwm_sockaddr_t *  to,
int  tolen 
)

This function sends data to a specified destination host and port (mwm_sockaddr_t).

Parameters
socketHandle of socket
bufPointer to data buffer
lenSize of buf
toAddress of remote host
tolenSize of to
Returns
Number of bytes sent, negative number - error
int mwm_recv_timeout ( int  socket,
void *  buf,
size_t  len,
uint32_t  timeout_ms 
)

This function receives data on a connected socket.

Parameters
socketHandle of socket
bufPointer to data buffer
lenSize of buf
timeout_msTimeout in ms - maximum amount of time that the request may block while waiting for data, 0 indicates it blocks forever
Returns
Number of bytes received, negative number - error
int mwm_recvfrom_timeout ( int  socket,
void *  buf,
size_t  len,
uint32_t  timeout_ms 
)

This function receives data on the opened socket.

Parameters
socketHandle of socket
bufPointer to data buffer
lenSize of buf
timeout_msTimeout in ms - maximum amount of time that the request may block while waiting for data, 0 indicates it blocks forever
Returns
Number of bytes received, negative number - error
int mwm_close ( int  socket)

This function closes a socket.

Parameters
socketHandle of socket
Returns
0 - success, negative number - error