@ dobova -
Hi,
I now take the port as a parameter in the JoinWirelessNetwork method
#region JoinWirelessNetwork
/// <summary>
/// Attempt to join a wireless with static IP.
/// Function does not return until and IP address has been granted,
/// or a time-out has occured.
/// </summary>
/// <param name="SSID"></param>
/// <param name="Passphrase"></param>
/// <param name="channel"></param>
/// <param name="Authentication"></param>
/// <param name="enableDHCP"></param>
/// <param name="IP"></param>
/// <param name="Gateway"></param>
/// <param name="SubnetMask"></param>
/// <param name="DNS"></param>
/// <returns>Whether or not it was successful</returns>
///
public bool JoinWirelessNetwork(string SSID, string Passphrase, int channel = 0, WirelessEncryptionMode Authentication = WirelessEncryptionMode.Open,
bool enableDHCP = false,
string listenPort = "2000",
string IP = "192.168.1.5",
string Gateway = "192.168.1.1",
string SubnetMask = "255.255.255.0",
string DNS = "192.168.1.1")
{
return DoJoinToWirelessNetwork(SSID, Passphrase, channel, Authentication, enableDHCP, listenPort, IP, Gateway,SubnetMask, DNS);
}
/// <summary>
/// Attempt to join a wireless network with given parameters using DHCP.
/// Function does not return until and IP address has been granted,
/// or a time-out has occured.
/// </summary>
/// <param name="SSID"></param>
/// <param name="Passphrase"></param>
/// <param name="channel"></param>
/// <param name="Authentication"></param>
/// <returns>Whether or not it was successful</returns>
///
public bool JoinWirelessNetwork(string SSID, string Passphrase, int channel = 0, WirelessEncryptionMode Authentication = WirelessEncryptionMode.Open, string listenPort = "2000")
{
return DoJoinToWirelessNetwork(SSID, Passphrase, channel, Authentication, true, listenPort, "", "", "", "");
}
private bool DoJoinToWirelessNetwork(string SSID, string Passphrase, int channel, WirelessEncryptionMode Authentication,
bool enableDHCP,
string listenPort = "2000",
string IP = "",
string Gateway = "",
string SubnetMask = "",
string DNS = "")
{
_DHCP = enableDHCP;
_device_ready = false;
//Reset the module
Reset.Write(false);
Thread.Sleep(100);
Reset.Write(true);
Thread.Sleep(250);
//Wait for the device to be ready
_TimeOutDate = DateTime.Now.AddMilliseconds((double)_Timeout);
while (!_device_ready)
{
if (_TimeOutDate <= DateTime.Now)
return false;
Thread.Sleep(1);
}
//Exit command mode..just in case
if (!_Command_Mode_Exit())
return false;
//Enter command mode
if (!_Command_Mode_Start())
return false;
if (!enableDHCP)
{
//Set DHCP off (use static IP address)
if (!_Command_Execute("set ip dhcp 0"))
return false;
//Set requested IP address
if (!_Command_Execute("set ip address " + IP))
return false;
//Set requested gateway
if (!_Command_Execute("set ip gateway " + Gateway))
return false;
//Set requested subnetmask
if (!_Command_Execute("set ip netmask " + SubnetMask))
return false;
//Set requested DNS address
if (!_Command_Execute("set dns address " + DNS))
return false;
}
else
{
//Set DHCP on
if (!_Command_Execute("set ip dhcp 1"))
return false;
}
//if (!_Command_Execute("scan"))
// return false;
if (!_Command_Execute("set ip localport " + listenPort))
return false;
if (!_Command_Execute("set ip protocol 2"))
//if (!_Command_Execute("set ip protocol 3"))
return false;
if (!_Command_Execute("set wlan join 0"))
return false;
if (!_Command_Execute("set wlan ssid " + SSID))
return false;
if (!_Command_Execute("set wlan channel " + channel.ToString()))
return false;
if (!_Command_Execute("set wlan auth " + Authentication.ToString()))
return false;
if (Authentication == WirelessEncryptionMode.Open)
{
Debug.Print("I set wlan key to - No");
}
else
{
if (Authentication == WirelessEncryptionMode.WEP_128)
{
if (!_Command_Execute("set wlan key " + Passphrase))
return false;
}
else
{
if (!_Command_Execute("set wlan phrase " + Passphrase))
return false;
}
}
if (!_Command_Execute("set wlan hide 1")) // Hide Wlan password / -phrase
return false;
if (!_Command_Execute("join"))
return false;
if (!_Command_Execute("get ip"))
return false;
//Exit command mode
if (!_Command_Mode_Exit())
return false;
return true;
}
#endregion
But I have now issues with a favicon.ico request of Internet Explorer that Comes after the request for /index.html