Project - WiFi 4.2.9 plus Selection of Access Point using T35

WiFi 4.2.9 plus Selection of Access Point using T35

This code expands on the code presented at http://www.tinyclr.com/codeshare/entry/657 and also uses the library developed for the T35 here at http://www.tinyclr.com/codeshare/entry/668 .

Testing has been carried out using the EMX Development System.

Just as a tablet has the ability to change Wireless Access Points as one travels from city to city, a embedded system in a mobile object such as a robot needs the ability to use different wireless access points as it travels about.

The GHI Libraries (for wireless connection) have been quite sensitive to code changes or additions in the area of: scanning for and joining networks. Depending on your processor I believe it is helpful to slow down the code at various points e.g. Thread.Sleep(200). This is an art commonly used in Arduino systems e.g. Delay(100) in microseconds, where it needs delays to some significant degree in order to keep the program being at the right point at the right time.

The output below shows what happens if you do not have the correct pass phrase to gain access to a secured access point. At the point of trying to Join the Network a NetworkInterfaceExtensionException is thrown. However the program then tries to connect to your default network.

LISTING:

Found debugger!

Create TS.

Loading start at a0e00000, end a0e1383c

Assembly: mscorlib (4.2.0.0) Assembly: Microsoft.SPOT.Native (4.2.0.0) Assembly: Microsoft.SPOT.Security.PKCS11 (4.2
.0.0) Assembly: System.Security (4.2.0.0) Loading Deployment Assemblies.

Attaching deployed file.

Assembly: T35_Console_Library (1.0.0.0) Attaching deployed file.

Assembly: Microsoft.SPOT.Graphics (4.2.0.0) Attaching deployed file.

Assembly: Microsoft.SPOT.Hardware (4.2.0.0) Attaching deployed file.

Assembly: GHI.Premium.System (4.2.9.0) Attaching deployed file.

Assembly: System (4.2.0.0) Attaching deployed file.

Assembly: GHIwifiT35_429 (1.0.0.0) Attaching deployed file.

Assembly: Microsoft.SPOT.TinyCore (4.2.0.0) Attaching deployed file.

Assembly: GHI.Premium.Net (4.2.9.0) Attaching deployed file.

Assembly: Microsoft.SPOT.Net (4.2.0.0) Attaching deployed file.

Assembly: GHI.Premium.Hardware (4.2.9.0) Attaching deployed file.

Assembly: GHI.Premium.Hardware.EMX (4.2.9.0) Resolving.

GC: 1msec 26220 bytes used, 7313448 bytes available

Type 0F (STRING ): 24 bytes

Type 15 (FREEBLOCK ): 7313448 bytes

Type 17 (ASSEMBLY ): 22080 bytes

Type 1E (BINARY_BLOB_HEAD ): 4044 bytes

Type 34 (APPDOMAIN_HEAD ): 72 bytes

GC: performing heap compaction…

The debugging target runtime is loading the application assemblies and starting execution.
Ready.

‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\mscorlib.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Native.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Security.PKCS11.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.Security.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Graphics.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Programming\Projects\GHIwifiT35_429\T35_Console_Library\bin\Debug\le..\GHI.Premium.System.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Programming\Projects\GHIwifiT35_429\T35_Console_Library\bin\Debug\le..\GHI.Premium.Hardware.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.TinyCore.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Programming\Projects\GHIwifiT35_429\T35_Console_Library\bin\Debug\le\T35_Console_Library.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Net.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies\le\GHI.Premium.Net.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Programming\Projects\GHIwifiT35_429\GHIwifiT35_429\bin\Debug\le\GHIwifiT35_429.exe’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\GHI Electronics\GHI Premium NETMF v4.2 SDK\Assemblies\le\GHI.Premium.Hardware.EMX.dll’
The thread ‘’ (0x2) has exited with code 0 (0x0).
Initialising Display
Initialised Display 320 240
RS9110 firmware version Number is 4.4.5
RS9110 driver version Number is 4.4.5
Now scanning for Access Point.
The selected Access Point is: J+J
#### Exception GHI.Premium.Net.NetworkInterfaceExtensionException - 0x00000000 (1) ####
#### Message:
#### GHI.Premium.Net.WiFiRS9110::Join [IP: 005e] ####
#### Robot.Program::Main [IP: 0142] ####
#### Exception GHI.Premium.Net.NetworkInterfaceExtensionException - 0x00000000 (1) ####
#### Message:
#### GHI.Premium.Net.WiFiRS9110::Join [IP: 00f6] ####
#### Robot.Program::Main [IP: 0142] ####
A first chance exception of type ‘GHI.Premium.Net.NetworkInterfaceExtensionException’ occurred in GHI.Premium.Net.dll
PassPhrase probably faulty for the selected Access Point
Exception was thrown: GHI.Premium.Net.NetworkInterfaceExtensionExceptionGHI.Premium.Net.WiFiRS9110::Join
Robot.Program::Main

Now scanning for Access Point.
The selected Access Point is: KGNETGEAR
Wireless connectivity changed!
Wireless is: Connected
SSID: KGNETGEAR
WiFi Channel number: 11
Wireless Network Type: Access Point
MAC Address: 64:70:02:40:69:3A
RSSI: -50dB
Wireless Security Mode: WPA2
Network address changed!
DHCP is: Enabled
Is DynamicDnsEnabled enabled: False
NetworkInterfaceType 71
Network settings:
IP Address: 192.168.1.5
Subnet Mask: 255.255.255.0
Default Gateway: 192.168.1.1
Number of DNS servers:2
DNS Server 0:8.8.8.8
DNS Server 1:8.8.4.4

Network settings for: count1 = 2
IP Address: 192.168.1.5
Subnet Mask: 255.255.255.0
Default Getway: 192.168.1.1
DNS Server: 8.8.8.8
DNS Server: 8.8.4.4

Testing access to Internet and DNS:
www.ghielectronics.com: 207.58.176.212

Create Socket here!
Closing WiFi interface
Network address changed!
DHCP is: Enabled
No IP Address allocated!

Wireless connectivity changed!
Wireless is: Disconnected
The thread ‘’ (0x3) has exited with code 0 (0x0).
The thread ‘’ (0x1) has exited with code 0 (0x0).
Done.
Waiting for debug commands…
The program ‘[9] Micro Framework application: Managed’ has exited with code 0 (0x0).