Added support for remote connection by name via Pentair servers

This brings along proper password encryption and validation for the login process (which is still not needed for local connections).

You can run the remote connection tests by passing a system name and password as 2 arguments (so the system name needs to be quoted, e.g.: `test "Pentair: xx-xx-xx" 1234`)

Also updated to latest .NET Core and C# versions while I was at it.
This commit is contained in:
2019-02-20 15:19:42 -06:00
parent 810342ecc9
commit d6dfcb14a9
8 changed files with 211 additions and 56 deletions

View File

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace ScreenLogicConnect.Messages
{
public class GetGatewayData : HLMessage
{
public string GatewayName;
public bool GatewayFound;
public bool LicenseOK;
public string IPAddr;
public short Port;
public bool PortOpen;
public bool RelayOn;
public const short HLM_GETGATEWAYDATA = 18003;
public static GetGatewayData QUERY(string systemName, short senderID = 0)
{
var ret = new GetGatewayData(senderID, HLM_GETGATEWAYDATA);
ret.GatewayName = systemName;
return ret;
}
public GetGatewayData(short senderID, short msgID)
: base(senderID, msgID)
{
}
public GetGatewayData(HLMessage msg)
: base(msg)
{
}
public override byte[] asByteArray()
{
using (var ms = new MemoryStream())
{
using (var bw = new BinaryWriter(ms))
{
bw.WritePrefixLength(GatewayName);
bw.WritePrefixLength(GatewayName);
}
data = ms.ToArray();
}
return base.asByteArray();
}
protected override void decode()
{
using (var ms = new MemoryStream(data))
{
using (var br = new BinaryReader(ms))
{
GatewayFound = br.ReadBoolean();
LicenseOK = br.ReadBoolean();
IPAddr = HLMessageTypeHelper.extractString(br);
Port = br.ReadInt16();
PortOpen = br.ReadBoolean();
RelayOn = br.ReadBoolean();
}
}
}
}
}