IoT Gateway With Open API to Connect Cloud Platforms

The gateway and the platform use mqtt protocol to communicate. Our gateway is connected to our own cloud platform by default, and customers can modify it according to their own environment.
Table of Contents

General operation of the gateway

1. Log in the gateway with terminal tool

  1. For example, I used the Putty to log in the gateway, which can be realized within three steps,

1.1 Fill in the Host Name(or IP address) with the gateway’s IP address, which in my case is 192.168.0.96, port 22, connection type SSH, and press open, shown in figure 1.

1)The IP address of the gateway can be obtained via gateway’s superior router’s dhcp list or network scanning tools like Advanced IP scanner.

RB Gateway 1
Figure 1

1.2 The type in the default user name root and password root, log into the gateway, shown in figure 

RB Gateway 2
Figure 2.

Open a web browser on PC, Input Gateway IP Address, in my case is 192.168.0.105; Enter the username and Password(default Username: root, Password: root),login to the gateway, the process is shown in figure 3.

2. WinScp file transfer tool

2. For example, I used the WinSCP program to interchange with the gateway.

2.1 Create a new session. Then fill in the Host name with the IP address 192.168.0.96, User name root and Password root of the gateway then click login, shown in figure 3.

RB Gateway 3
Figure 3

3. Luci Embedded Web

3.1 Open a browser and type in the IP address. Then you can configure the gateway through the Luci Embedded Web, shown in figure 4 and figure 5.
RB Gateway 4
Figure 4
RB Gateway 5
Figure 5

4. Simple Linux Commands in Gateway

4.1 Is Command to view directory files, shown in figure 6.

RB Gateway 6
Figure 6

4.2 cd Command to enter a directory, shown in figure 7.

RB Gateway 7
Figure 7

4.3 ps Command to view system process, shown in figure 8.

RB Gateway 8
Figure 8

4.4 logread –f Commands can viewa background program execution logs, useful when debugging, shown in figure 9.

RB Gateway 9
Figure 9

4.5 cp Command for copying files, shown in figure 10.

RB Gateway 10
Figure 10

4.5 mv Command to move files, shown in figure 11.

RB Gateway 11
Figure 11

4.6 sysupgrade Command for upgrading gateway firmware, shown in figure 12.

RB Gateway 12
Figure 12

4.7 /etc/init.d/*** stop|start|restart Command. Start, stop or restart a program ***, which stands for the specific startup file name. For example, start stop or restart the Zigbee demo program amber, shown in figure 13

RB Gateway 13
After restarting, ps | grep AmberGwZ3 command can be used to see if a program has been launched successfully.

4.8 Top Command to view the memory usage of the system, shown in figure 14.

RB Gateway 14
Figure 14

4.9 df -h Command to view the system’s flash space, shown in figure 15.

RB Gateway 15
Figure 15

4.10 free Command, similar to top command to view the memory usage, shown in figure 16.

RB Gateway 16
Figure 16

Gateway Docking-Gateway Internal Application Development

1. Gateway Docking-Platform Service Development

1. MQTT communication

  • The gateway and the platform use mqtt protocol to communicate. Our gateway is connected to our own cloud platform by default, and customers can modify it according to their own environment.
  • The uplink message of the gateway will be sent to the topic: ‘t’
  • The gateway will subscribe to the topic: ‘t / mac’ to accept messages, where the mac address is the mac address of the gateway
  • Configure the mqtt address and port of the gateway on the luci embedded web, or use our gateway management tool

2. JSON format

The communication between the gateway and the platform uses the JSON. The following are some JSON protocol communication processes and formats.

  • After the gateway is powered on for the first time, register itself with the platform registerReq, shown in figure 17
RB Gateway 17
Figure 17

The platform should response with registerResp command after receiving registerReq, otherwise the gateway would keep registering. Therefore, the platform is recommended to response the gateway’s registration command at any time. This is because the gateway may delete the registration record in some cases like restore command.

  • After the gateway successfully registers itself, it will actively report the basic information of the gateway reportAttribute(gateway.status) , shown in figure 18
RB Gateway 18
Figure 18

The gateway will report basic information including wireless_ip, ethernet_ip, uplinkType, versioin, model, factory and so on.

Platform issued device list command getAttribute(mod.device_list) , shown in figure 19

RB Gateway 19
Figure 19
  • The platform issues a request to add a device, shown in figure 20
RB Gateway 20
Figure 20

After the Platform sends the request for additional devices,

  • If the Gateway receives it, verify the parameters first, and if there are no errors, it will return the code 99, indicating that the Gateway has received the command and is executing.
  • If the parameter is wrong, the gateway will return the parameter error, code is 101.
  • After that, the operator can watch the indicator light of the Gateway flashing, indicating that the Gateway is open for pairing. At this time, the operator needs to operate the device end to open for network access.
  • Wait 10 seconds to 1 minute or so. If you add it successfully, the Gateway will return the message with code 0, which will be a mod.new_device_added message
  • Failure usually returns a timeout message with code 104.

 

Remove devices from Platform:

  • The platform issues a delete device, shown in figure 21.
RB Gateway 21
Figure 21

Delete device command would delete the device data directly and return code 0.

  • Gateway soft start, shown in figure 22.
RB Gateway 22
Figure 22
  • Remote firmware update on gateway, shown in figure 23.
RB Gateway 23
Figure 23
Related IoT Product Specifications

Looking For An IoT Device Supplier For Your Projects?

CONTACT US

    This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

    IoT Gateways for Recommendation

    CONTACT US

      This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

      Welcome to DusunIoT

      Hi there 👋 Is there anything we can help you with today? Please fill in the form below for the team to follow up if you become disconnected.

        DusunIoT Distributor Program

          This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

            This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.