EXTRA information.
To test the actions on the EasyIOT server running on the Pi, I have add an Cron job to set the relais on... example found here on this forum:
public void Run()
{
DriverHelper.ProcessCommad(Domains.VIRTUAL, "N1S0", "ControlOn","");
}
The console, does report some actions and I can see at the webinterface that the Module has been set to ON. This means that the Cron job did start, but again not the program to send URL to the ESP8266.
At the console, found this ERROR, where I do not know for sure this is the problem....
[ at System.Net.Sockets.TcpClient.Connect (System.Net.IPAddress[] ipAddresses, Int32 port) [0x00000] in <filename unknown>:0]
The program that I use for the relais module comes from the Windows example, also I have found the same code on the web, so looks fine to me, this code:
const String ESP8266_IP_ADDRESS = "192.168.1.10";
/*
This code is running one time when program is enabled
*/
public void Setup()
{
// System.Diagnostics.Process.Start("CMD.exe","");
EventHelper.ModuleChangedHandler((o, m, p) =>
{
Console.WriteLine(m.Domain +" "+ m.Address + " in program id "+ Program.ProgramId.ToString()+ " property "+ p.Property + " value " + p.Value);
if (m.Domain == "Virtual" && m.Address == "N1S0" && p.Property == "Sensor.DigitalValue")
sendCommand(p.Value);
return true;
});
}
/*
This code is running periodicaly when program is enabled.
Cron job detirmine running period.
*/
public void Run()
{
}
private void sendCommand(string value)
{
sendToServer("/gpio/"+value);
}
private void sendToServer(String message)
{
try
{
Console.WriteLine("TCP client command:" + message);
Int32 port = 80;
System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient( ESP8266_IP_ADDRESS, port);
Byte[] data = System.Text.Encoding.ASCII.GetBytes(message);
System.Net.Sockets.NetworkStream stream = client.GetStream();
stream.Write(data, 0, data.Length);
// Close everything.
stream.Close();
client.Close();
}
catch(Exception e)
{
Console.WriteLine(e.StackTrace);
}
}
Again any help would be nice, and hope this part of information does help.
Adam