Hey, guys, I am using the wifi_rs21 module, but I am confused about the NetworkDown event.
Once the InitializeNetwork() method finishes, which enables wifi_rs21 to find the network to join and succeeds in retrieving the time from network, the Network Down event is raised. This means that the network connection is not correctly configured, thus cannot receive any messages, but inside the event handler, I can still get the time from network. This is really confusing. Can somebody help me?
Here is the code:
void ProgramStarted()
{
this.InitializeNetwork();
this.InitializeSDCard();
this.InitializeSensor();
}
void InitializeNetwork()
{
// setup events
wifi_RS21.NetworkDown += wifi_NetworkDown;
wifi_RS21.NetworkUp += wifi_NetworkUp;
wifi_RS21.Interface.NetworkAddressChanged += Interface_NetworkAddressChanged;
// use the router's DHCP server to set my network info
wifi_RS21.UseDHCP();
// to use hold the network to connect to
WiFiNetworkInfo targetNetwork = TargetNetwork(wifi_RS21.Interface.Scan(), targetSSID);
if (targetNetwork != null)
{
wifi_RS21.Interface.Join(targetNetwork, password);
Debug.Print("Network joined");
Debug.Print("Connected: " + wifi_RS21.IsNetworkConnected.ToString());
Debug.Print("Up: " + wifi_RS21.IsNetworkUp.ToString());
Debug.Print("Current Time: " + NtpClient.GetNetworkTime().ToString("dd/MM/yyyy HH:mm:ss"));
}
}
void wifi_NetworkDown(GTM.Module.NetworkModule sender,
GT.Modules.Module.NetworkModule.NetworkState state)
{
Debug.Print("Current Time: " + NtpClient.GetNetworkTime().ToString("dd/MM/yyyy HH:mm:ss"));
Debug.Print("Network Down Event");
}