Manage the eWON communication

Sometimes, LAN devices (as for example a PLC) connected to your eWON should be able to control the Internet connection of the eWON.

The following BASIC example describes the settings needed for each communication media (comcfg parameter) and also indicates which status field can be used to check the connectivity status.

With this example, the user should be able to design his own eWON program and so manage the eWON communication using tags or user defined web pages.

Below, we will list the corresponding comcfg parameters and the estat parameters.

  • The comcfg parameters are the configuration parameters acting on the communication settings of the eWON.
  • The estat parameters are status information given back by your eWON allowing control of the communication status.

The comcfg and the estat parameters can be read and modified using the basic "Getsys/ Setsys" commands.
Please refer to the general Programming guide for detailed information of the use of the GetSYS/SetSys commands.

// Example of COMCFG use
SETSYS COM, "LOAD"
SETSYS COM, "PPPClPhone1",0123456789
SETSYS COM, "SAVE"
CFGSAVE :   REM to write setting into flash

// Example of ESTAT use
SETSYS INF,"load"
A$ = GETSYS INF,"VPNIP" 

Internet Connection Parameters

Possible connection media:

  • Ethernet
  • Cellular
  • Wi-Fi

Comcfg.txt

  • Network connection = WANCnx
WanCnxNetwork Connection
0No Internet Access
1Modem Connection
2Ethernet WAN Connection
4Wi-Fi
  • Maintain connection = WANPermCnx
WanPermCnxConnection Maintened
0Disabled
1Enabled

// Open the connection
Setsys COM,"load"
Setsys COM,"WANCnx","2"                             : REM (1, 2 or 3)
Setsys COM,"WANPermCnx","1"
Setsys COM,"save"

// Close the connection
Setsys COM,"load"
Setsys COM,"WANCnx","0" 
Setsys COM,"WANPermCnx","0"
Setsys COM,"save"

Cellular Connection Information

Comcfg.txt

  • Modem Init String= ModemInitStr
  • Operator Selection= GSMOpId
GSMOpIdDescription
0The operator is automcatically selected
XX is the Operator Id that must be manually selected.

The X value can be obtained from the "GsmOperList" parameter provided in the estat file. This list has the following form: GsmOperList:[{opna:"BEL PROXIMUS ",opid:" 20601",stat:"="},{opna:"BASE ",opid:"20620",stat:"-"},{opna:"B mobistar ",opid:" 20610",stat:"-"}]

Each entry provides an operator name, id and status. To select the Operator "Bel Proximus", set GSMOpID=20601

  • GSM Pin Code= PIN
  • PDP context definition= PdpApnUse (boolean)
  • Access Point Name= PdpApn
  • Auto band = GsmBand
GsmBandDescription
0The modem band is not Specified. Current value in modem is used
1850
2900E
31800
41900
5850 1900
6900E 1800
7900E 1900
10Enable band auto-detection

ESTAT Parameters

  • Signal Level = GSMSignal
  • Network = GsmNetReg
GsmNetRegGSM Status
1Home network
2Searching registration
3Registration denied
4Unknown Registration
5Roaming
101Registration in progress
  • Available Operators = GsmOperList
  • Initialization status of the modem= ModemInitStatus
  • GSM Band detection= GsmBand (valid only when the ModemInitStatus is 0)
  • GSM Operator= GsmOpId (valid only when the ModemInitStatus is 0)
GoOnline:
LOGEVENT "Online connection triggered by scripting", 101
SETSYS COM,"load"
SETSYS COM,"WanCnx",1
SETSYS COM,"WANPermCnx",1
SETSYS COM,"save"
PRINT Time$;"Maintain connection activated"
Tset 1,5
Ontimer 1, "Goto CheckConnection"
END

CHECKConnection:
A$ = Getsys PRG, "PPPIP"
IF A$ <> "0.0.0.0" THEN
Tset 1,0
SETSYS COM,"load"
SETSYS COM,"WanCnx",1
SETSYS COM,"WANPermCnx",0
SETSYS COM,"save"
PRINT Time$;"Maintain connection deactivated"
LOGEVENT "Online connection established. PPP IP address: " + A$, 101
ENDIF

VPN Connection

Comcfg.txt

  • VPN connection type= VPNCnxType
VPNCnxTypeDescription
0Disable VPN
1Listen for incoming VPN from client
2Establish outgoing VPN to server

ESTAT Parameters

  • Indication if eWON has VPN capabilities= HasVPN
HasVPNDescription
0without VPN capability
1with VPN capability
ONVPN "goto VPN_Action"
END

VPN_Action:
I%=GETSYS PRG,"EVTINFO"
IF I%=1 then
PRINT "VPN Online"
ELSE
PRINT "VPN Going offline"
ENDIF
END