Network commands

hub.network.get

Version: 1.0

Classes: ANY

Title: Network settings

Description: Return network settings

parameters:

No parameters required.

return result fields:

Field Type Required Description
interfaces JsonArray + Network configuration for each network interface
interfaces._id string + Id of the network interface
interfaces.internetAvailable string - Whether this interface is an internet provider (only one interface can be an internet provider)
interfaces.hwaddr string + Mac address assigned to interface (except 'modem' interfaces)
interfaces.imei string + IMEI (only for 'modem' interfaces)
interfaces.type string + Interface type (ethernet, wifi, modem)
interfaces.network string + Network type (wan, lan)
interfaces.priority integer - Priority to use the interface as an internet source (lower value, higher priority)
interfaces.status string + Interface status (up, down)
interfaces.error JsonObj - Description of a failure happend for this interface, if any (Error object)
interfaces.enabled enum + For wan interfaces: on, off, auto. For lan interfaces: on, off
interfaces.wifi JsonObj - WiFi settings (used with interface type: wifi)
interfaces.wifi.mode string + WiFi mode (ap, sta)
interfaces.wifi.channel integer + WiFi channel for access point (0 - auto)
interfaces.wifi.network JsonObj + Current WiFi network
interfaces.wifi.network.ssid string - WiFi SSID
interfaces.wifi.network.bssid string - WiFi BSSID
interfaces.wifi.network.encryption string - WiFi encryption (none, wep, psk, psk2)
interfaces.wifi.network.key string - WiFi encryption key (used with WiFi encryption: wep, psk, psk2)
interfaces.wifi.region string + WiFi region (ISO/IEC 3166 alpha2 country codes)
interfaces.modem JsonObj - 3G/4G Modem settings (used with interface type: modem)
interfaces.modem.operators JsonArray + List of mobile operators supported by this interface
interfaces.modem.network JsonObj - Current 3G/4G network
interfaces.modem.network.operator string + Mobile network operator
interfaces.modem.network.pinCode string - SIM pin code
interfaces.modem.network.initializeAt string - Modem initializing string
interfaces.modem.network.dialNumber string + Dial number
interfaces.modem.network.apn string + Access point name
interfaces.modem.network.username string - PPP username
interfaces.modem.network.password string - PPP password
interfaces.modem.network.authMode string - PPP authentication mode (auto, pap, chap)
interfaces.ipv4 JsonObj + IPv4 settings
interfaces.ipv4.mode string + IPv4 mode (ignore, static, dhcp, zeroconf (linklocal), ppp)
interfaces.ipv4.ip string - IPv4 address
interfaces.ipv4.mask string - IPv4 mask
interfaces.ipv4.gateway string - IPv4 gateway (for ppp used as remote endpoint)
interfaces.ipv4.dns JsonArray - IPv4 dns servers
interfaces.ipv4.dhcpId string - IPv4 gateway (used with dhcp)
interfaces.ipv6 JsonObj +??? IPv6 settings
interfaces.ipv6.mode string + IPv6 mode (ignore, static, dhcp (stateful), zeroconf (stateless), ppp)
interfaces.ipv6.ip JsonArray - IPv6 addresses with prefix
interfaces.ipv6.gateway string - IPv6 gateway (for ppp used as remote endpoint)
interfaces.ipv6.dns JsonArray - IPv6 dns servers
interfaces.ipv6.dhcpId string - IPv6 gateway (used with dhcp)
interfaces.stats JsonObj + Stats () TBD.

interfaces.error

Code Message Data
-32500 Could not connect to the network network.wifi.connection.failed
-32500 Network has no internet connection network.connection.no_internet
-32500 No SIM card present in the specified interface network.modem.sim.nopresent
-32500 Invalid pin code network.modem.invalid.pin
-32500 Not supported operator network.modem.noallowed.operator
-32500 Invalid authentication parameters network.modem.bad.auth
-32500 Invalid internet connection parameters network.modem.bad.internet.parameters
-32500 Modem doesn't response network.modem.hung
-32500 UNKNOW reason network.unknown

If there are some issues during an interface configuration or during its activity they are detailed in a error field.

Examples

call:

{
    "method": "hub.network.get",
    "id": "_ID_",
    "params": {}
}

reply:

{
    "error": null,
    "id": "_ID_",
    "method": "hub.network.get",
    "result": {
        "interfaces": [
            {
                "_id": "eth0",
                "enabled": "auto",
                "hwaddr": "02:42:8B:03:79:38",
                "internetAvailable": true,
                "ipv4": {
                    "dns": [
                        "192.168.10.10",
                        "1.1.1.1",
                        "8.8.8.8"
                    ],
                    "gateway": "192.168.10.1",
                    "ip": "192.168.10.227",
                    "mask": "255.255.254.0",
                    "mode": "dhcp"
                },
                "network": "wan",
                "status": "up",
                "type": "ethernet"
            },
            {
                "_id": "wlan0",
                "enabled": "auto",
                "hwaddr": "8C:F7:10:E4:ED:90",
                "internetAvailable": false,
                "ipv4": {
                    "dns": [
                        "192.168.10.10",
                        "1.1.1.1",
                        "8.8.8.8"
                    ],
                    "gateway": "192.168.10.1",
                    "ip": "192.168.11.126",
                    "mask": "255.255.254.0",
                    "mode": "dhcp"
                },
                "network": "wan",
                "status": "down",
                "type": "wifi",
                "wifi": {
                    "channel": 0,
                    "mode": "sta",
                    "network": {
                        "bssid": "",
                        "encryption": "psk2",
                        "key": "",
                        "ssid": ""
                    },
                    "region": "00"
                }
            },
            {
                "_id": "wlan0.1",
                "enabled": "on",
                "hwaddr": "8C:F7:10:E4:ED:90",
                "ipv4": {
                    "ip": "192.168.4.1",
                    "mask": "255.255.255.0",
                    "mode": "static"
                },
                "network": "lan",
                "status": "down",
                "type": "wifi",
                "wifi": {
                    "channel": 0,
                    "mode": "ap",
                    "network": {
                        "encryption": "psk2",
                        "key": "nothing43here",
                        "ssid": "ezlo_70010999"
                    },
                    "region": "00"
                }
            },
            {
                "_id": "ppp0",
                "enabled": "auto",
                "internetAvailable": true,
                "ipv4": {
                    "mode": "ppp",
                    "ip": "100.83.201.239",
                    "gateway": "10.64.64.64",
                    "dns": [
                        "10.74.32.5",
                        "10.74.32.6"
                    ]
                },
                "modem": {
                    "operators": [
                        "lifecell"
                    ],
                    "network": {
                        "operator": "lifecell",
                        "pinCode": "1234",
                        "dialNumber": "*99#",
                        "apn": "internet"
                    }
                },
                "network": "wan",
                "status": "up",
                "type": "modem"
            },
            {
                "_id": "ppp1",
                "enabled": "auto",
                "error": {
                    "code": -32500,
                    "data": "network.modem.sim.nopresent",
                    "message": "No SIM card present in the specified interface"
                },
                "internetAvailable": false,
                "network": "wan",
                "status": "down",
                "type": "modem"
            }
        ]
    }
}

hub.network.enabled.set

Version: 1.0

Classes: ANY

Title: Control enable policy of an interface

Description: Control enable policy of an interface. For H2+/H2++(H2 Secure)/G150/G450/G550 an ethernet type interface is always enabled, any attempts to change it will be rejected. For Atom32 a wifi type interface is always enabled, any attempts to change it will be rejected.

parameters:

Field Type Required Description
interfaceId string + Id of the interface
enabled enum + (on, off, auto)

return result fields:

Return empty result or error

Here is it an example of usage:

call:

{
    "method": "hub.network.enabled.set",
    "id": "_ID_",
    "params": {
        "interfaceId" : "wifi0",
        "enabled" : "auto"
    }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {}
}

errors:

Code Message Data
-32500 Invalid interface id network.invalid.interface
-32500 Operation is not permitted network.operation.prohibited

hub.network.wifi.scan.start

Version: 1.0

Classes: ANY

Title: Wifi client start scan

Description: Start scan wifi network by network interface with type "wifi". Scan stops automatically after 5 minutes. Calling the method again resets this time counter.

parameters:

Field Type Required Description
interfaceId string + Id of the interface (wifi)

return result fields:

Return empty result or error

Scan result returned by broadcast

broadcasts:

Broadcast Description
hub.network.wifi.scan.progress Provides status of scan

Here is it an example of usage:

call:

{
    "method": "hub.network.wifi.scan.start",
    "id": "_ID_",
    "params": {
        "interfaceId" : "wlan0"
    }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {}
}

hub.network.wifi.scan.stop

Version: 1.0

Classes: ANY

Title: Wifi client stop scan

Description: Stop started scan wifi network

parameters:

Field Type Required Description
interfaceId string + Id of the interface (wifi)

return result fields:

Return empty result or error

broadcasts:

Broadcast Description
hub.network.wifi.scan.progress Provides status of scan

Here is it an example of usage:

call:

{
    "method": "hub.network.wifi.scan.stop",
    "id": "_ID_",
    "params": {
        "interfaceId" : "wlan0"
    }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {}
}

hub.network.wifi.try_connect

Version: 1.0

Classes: ANY

Title: Try connect to wifi network

Description: Try connect to wifi network as client and save setting if success

parameters:

Field Type Required Description
interfaceId string + Id of the interface (wifi)
network JsonObj + New WiFi network
network.ssid string + WiFi SSID
network.bssid string - WiFi BSSID
network.encryption string + WiFi encryption (none, wep, psk, psk2)
network.key string - WiFi encryption key (used with WiFi encryption: wep, psk, psk2)
ipv4 JsonObj - IPv4 settings (default mode: dhcp)
ipv4.mode string - IPv4 mode (ignore, static, dhcp, zeroconf (linklocal), ppp)
ipv4.ip string - IPv4 address
ipv4.mask string - IPv4 mask
ipv4.gateway string - IPv4 gateway (for ppp used as remote endpoint)
ipv4.dns JsonArray - IPv4 dns servers
ipv4.dhcpId string - IPv4 gateway (used with dhcp)
ipv6 JsonObj - IPv6 settings (default mode: ignore)
ipv6.mode string - IPv6 mode (ignore, static, dhcp (stateful), zeroconf (stateless), ppp)
ipv6.ip JsonArray - IPv6 addresses with prefix
ipv6.gateway string - IPv6 gateway (for ppp used as remote endpoint)
ipv6.dns JsonArray - IPv6 dns servers
ipv6.dhcpId string - IPv6 gateway (used with dhcp)

response:

empty result

broadcasts:

Broadcast Description
hub.network.changed Result of try_connect request

Examples

Here is it an example of usage:

call:

{
    "method": "hub.network.wifi.try_connect",
    "id": "_ID_",
    "params": {
        "interfaceId": "wlan0",
        "network": {
            "ssid": "eZLO_Smart_House",
            "bssid": "fc:ec:da:32:a0:04",
            "encryption": "psk2",
            "key": "correct_passkey"
        }
    }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {}
}

hub.network.wifi.try_connect.wifi.security.list

Version: 1.0

Classes: ANY

Title: Supported wifi security types

Description: Supported wifi security types as client

parameters:

No parameters required.

return result fields:

Field Type Required Description
security JsonArray + List supported wifi security types

Here is it an example of usage:

call:

{
    "method": "hub.network.wifi.try_connect.wifi.security.list",
    "id": "_ID_",
    "params": {}
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {
        "security": [
            "open",
            "wep",
            "wpa-psk",
            "wpa2-psk
        ]
    }
}

hub.network.wifi.try_connect.ipv4.mode.list

Version: 1.0

Classes: ANY

Title: Supported wifi ipv4 modes

Description: Supported wifi ipv4 modes as client

parameters:

No parameters required.

return result fields:

Field Type Required Description
modes JsonArray + List supported wifi ipv4 modes

Here is it an example of usage:

call:

{
    "method": "hub.network.wifi.try_connect.ipv4.mode.list",
    "id": "_ID_",
    "params": {}
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {
        "modes": [
            "ignore",
            "static",
            "dhcp"
        ]
    }
}

hub.network.wifi.try_connect.ipv6.mode.list

Version: 1.0

Classes: ANY

Title: Supported wifi ipv6 modes

Description: Supported wifi ipv6 modes as client

parameters:

No parameters required.

return result fields:

Field Type Required Description
modes JsonArray + List supported wifi ipv6 modes

Here is it an example of usage:

call:

{
    "method": "hub.network.wifi.try_connect.ipv6.mode.list",
    "id": "_ID_",
    "params": {}
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {
        "modes": [
            "ignore"
        ]
    }
}

hub.network.wifi.up_hostap

Version: 1.0

Classes: ANY

Title: Try up access point on wifi

Description: Try up access point on wifi and save settings

parameters:

Field Type Required Description
interfaceId string + Id of the interface (wifi)
network JsonObj + AP WiFi network
network.ssid string + WiFi SSID
network.security string + WiFi security (open, wpa-psk, wpa2-psk, ...)
network.psk string - WiFi security key (used with WiFi security: wep, wpa-psk, wpa2-psk
ipv4 JsonObj - IPv4 settings (only mode: static + dhcp server)
ipv4.ip string - IPv4 address
ipv4.mask string - IPv4 mask

return result fields:

Return empty result or error

Here is it an example of usage:

call:

{
    "method": "hub.network.wifi.up_hostap",
    "id": "_ID_",
    "params": {
        "interfaceId" : "wlan0",
        "network" : {
            "ssid" : "ezlo_AP",
            "security" : "wpa2-psk",
            "psk" : "xxxxxxxx"
        },
        "ipv4" : {
            "ip" : "192.168.2.2",
            "mask" : "255.255.255.0"
        }
    }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {}
}

hub.network.wifi.up_hostap.wifi.security.list

Version: 1.0

Classes: ANY

Title: Supported wifi security types

Description: Supported wifi security types as ap

parameters:

No parameters required.

return result fields:

Field Type Required Description
security JsonArray + List supported wifi security types

Here is it an example of usage:

call:

{
    "method": "hub.network.wifi.up_hostap.wifi.security.list",
    "id": "_ID_",
    "params": {}
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {
        "security": [
            "open",
            "wpa-psk",
            "wpa2-psk
        ]
    }
}

hub.network.modem.try_connect

Version: 1.0

Classes: ANY

Title: Try to establish a modem internet connection

Description: Try to establish a modem internet connection via the specified interface. It's an async request, errors, mainly, are returned, if any, via broadcasts.

parameters:

Field Type Required Description
interfaceId string + Id of the interface (modemX)
operator string - Mobile operator to establish a modem internet connection through
pinCode string - SIM pin code
initializeAt string - Modem initializing string
dialNumber string - Dial number
apn string - Access point name
username string - PPP username
password string - PPP password
authMode string - PPP authentication mode (auto, pap, chap)

return result fields:

Return empty result or error

broadcasts:

Broadcast Description
hub.network.changed Result of try_connect request

Here is it an example of usage:

call:

{
    "method": "hub.network.modem.try_connect",
    "id": "_ID_",
    "params": {
        "interfaceId" : "modem0",
        "operator" : "lifecell",
        "pinCode" : "1234",
        "initializeAt" : "AT&F1&R2%7=60",
        "dialNumber" : "*99#",
        "apn" : "internet"
    }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {}
}

errors:

Code Message Data
-32500 Invalid interface id network.invalid.interface

hub.network.modem.pin_code.set

Version: 1.0

Classes: ANY

Title: Change a SIM pin code

Description: Change a SIM pin code for the specified 'modem' interface. It's a sync request, any errors, if any, are reported immediately.

parameters:

Field Type Required Description
interfaceId string + Id of the interface (modemX)
pinCodeOld string + An old SIM pin code to pass an authentication
pinCodeNew string + A new SIM pin code to set

return result fields:

Return empty result or error

Here is it an example of usage:

call:

{
    "method": "hub.network.modem.pin_code.set",
    "id": "_ID_",
    "params": {
        "interfaceId" : "modem0",
        "pinCodeOld": "1234",
        "pinCodeNew" : "4321"
    }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {}
}

errors:

Code Message Data
-32500 Invalid interface id network.invalid.interface
-32500 Invalid pin code network.modem.invalid.pin
-32500 Not allowed new pin code network.modem.noallowed.pin
-32500 No SIM card present in the specified interface network.modem.sim.nopresent
-32500 Modem doesn't response network.modem.hung

hub.network.reset

Version: 1.0

Classes: ANY

Title: Reset network settings

Description: Clear network settings on Hub for interface(s)

parameters:

Field Type Required Description
interfaceId string - Id of the interface to reset network settings for, if omitted - reset all interfaces

return result fields:

Return empty result or error

Example:

call:

{
    "method": "hub.network.reset",
    "id": "_ID_",
    "params": {
        "interfaceId": "modem0"
    }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {}
}

errors:

Code Message Data
-32500 Invalid interface id network.invalid.interface