Reference Home

Get configuration,net scanning and setting

Get configuration reads MAC address of shield, the name of shield when connected, the net address MASK and the GATEWAY address and finally the IP address and the STATUS global variable. IP address is not important when connected with an access point, because DHCP.

STATUS variable old the connection status : 1 connected, 2 failed,3 temporally lost retrying, 4 reestablished,5 definitively lost.

Several functions for getting and setting are listed later on.

Syntax

MWiFi.getConfig()

Parameters

none

Returns

none directly but puts several values into variables

these variables can be retrieved using following functions

MAC format "xx.xx.xx.xx.xx" (xx: hexadecimal)( 18 char max)

IP,MASK,GATEWAY format "n.n.n.n" (16 char max)

Syntax

MWiFi.getMAC(char mac[18]) // puts MAC into a buffer as string

MWiFi.getName(char name[8] )//puts shield net name to a string buffer

Is the (computer) name visible from net (composed with some MAC bytes)

MWiFi.getIP(char ip[16]) //puts ip into a buffer as string. Call after connection to have ip assigned.

MWiFi.setIP(char *ip) // only if you use static ip (switch to static ip mode)

WWiFi.setIPdhcp() //set dhcp mode (default) use only to reset to dhcp mode

MWiFi.getNetMask(char mask[16]) // puts MASK address into a string buffer

MWiFi.setNetMask(char *mask)

MWiFi.getGateway(char gateway[16]) //puts Gateway address into a string buffer

MWiFi.getRemoteIP(char remoteip[16]) // puts ip of client after linking. Call after server has accepted link.

MWiFi.resetMCW() // just for eventuality

MWiFi.setLed(int nled,int state) //switch on/off (1/0) the led nled (nled: from 0 to 4)

Be careful! Led 0 is used as flag for connection and led 1 is used as flag for link

MWiFi.setPowerOff() //switch off radio (shield can be waked-up only by begin() function)

MWiFi.setPowerSave(int millis) //in PSPOLL

MWiFi.setFullPower(int millis) //exits from power save mode

 

Scanning functions can be used to detect WIFI visible hotspot.

Syntax

MWiFi.scanNets() //scanning for visible hotspots

Parameters

none

Returns

total number of access point discovered (int).

Details can be retrieved by following function

Syntax

MWiFi.getNetScanned(int i) //get result of access point i

Parameters

access point index (in list prepared by scanNets() function)

Returns

Pointer to a string in this format:

"Net: name secure type rssi"

Where:

-secure=OPEN/WAP/WAP2/WEP

-type=Acc.P/AdHoc

-rssi= integer (signal power)

Syntax

MWiFi.getSSIDBestOpen(int totnet) //select the best open (no secure) net in terms of signal

Parameters

tot number of access point detected by scanNets() function

Returns

Pointer to a string name of best access point

Syntax

MWiFi.existSSID(char *name) //verify if an Access Point is availabe

Parameters

name of AP

Returns

record with AP data (see getNetScanned) or null

 

 

Next example demonstrates the use of some basic commands for MWiFi shield
- startup
- get default configuration
- set some configuration value
- scan wifi visible networks
- select the best open (without password) access point in terms of radio signal (RSSI) (if any)
- try to connect to this best access point (if any)
- get the dynamic IP provided by the access point
- close connection

Example:




Reference Home