Gateways are used when it's not possible that agent establishes the direct connection for the meter. The reason might be that the agent is not allowed to connect for the meter or gateway must establish the connection e.g. when dynamic IP addresses are used. Gateway can be simply RS-232 or RS-485 to TCP/IP converter that establishes the connection for the given IP address.
If the agent doesn't know the IP address of the meter, the gateway must identify itself by sending an identify message when a connection is established.
If the gateway is not able to configure to send identify message the gateway IP address can be used as a identifier. In that case, it's important that the IP address is not changing (dynamic IP address) or it's not possible to identify the gateway.
Because the initial message is not standardized, the script is used to handle the identified message. This allows easy configuration of different gateways. Below is a simple identification script for the gateways. It expects that the gateway sends an identification message every time when the connection is established.
public GXGateway? Identify(string sender, IGXMedia media, byte[] data) { GXGateway? gw = new GXGateway(); gw.Identifier = System.Text.ASCIIEncoding.ASCII.GetString(data); gw = Ami.SingleOrDefault(gw); if(gw == null) { //Add unknown gateway. gw = new GXGateway(); gw.Name = gw.Identifier = System.Text.ASCIIEncoding.ASCII.GetString(data); Ami.Add(gw); } return gw; }This Identify script must be selected on the agent's auto-connect tab. The identification waiting time tells how long an identification message is expected from the gateway. If the gateway doesn't send an identification message the connection is closed.