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
WanCnx | Network Connection |
---|---|
0 | No Internet Access |
1 | Modem Connection |
2 | Ethernet WAN Connection |
4 | Wi-Fi |
- Maintain connection = WANPermCnx
WanPermCnx | Connection Maintened |
---|---|
0 | Disabled |
1 | Enabled |
// 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
GSMOpId | Description |
---|---|
0 | The operator is automcatically selected |
X | X 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
GsmBand | Description |
---|---|
0 | The modem band is not Specified. Current value in modem is used |
1 | 850 |
2 | 900E |
3 | 1800 |
4 | 1900 |
5 | 850 1900 |
6 | 900E 1800 |
7 | 900E 1900 |
10 | Enable band auto-detection |
ESTAT Parameters
- Signal Level = GSMSignal
- Network = GsmNetReg
GsmNetReg | GSM Status |
---|---|
1 | Home network |
2 | Searching registration |
3 | Registration denied |
4 | Unknown Registration |
5 | Roaming |
101 | Registration 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
VPNCnxType | Description |
---|---|
0 | Disable VPN |
1 | Listen for incoming VPN from client |
2 | Establish outgoing VPN to server |
ESTAT Parameters
- Indication if eWON has VPN capabilities= HasVPN
HasVPN | Description |
---|---|
0 | without VPN capability |
1 | with 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