Smart L Serial Gateway Development Instruction

The model DSGW-040-7 is smart L serial gateway product of Dusun which is used in smart home, intelligent security industry, pension services.
Table of Contents

1. Introduction

1.1 Purpose & Description

The model DSGW-040-7 is smart L serial gateway product of Dusun which is used in smart home, intelligent security industry, pension services. It’s a central device, support LTE CatM1, Wi-Fi, Zigbee3.0, Bluetooth 5.2 and Z-wave wireless protocol. User can connect the network through LTE CatM1, Wi-Fi and Ethernet. In addition, smart sensors can be connected through Zigbee3.0, Bluetooth and Z-wave.

It is a smart gateway with DC power supply. It can be used in various scenarios flexibly. It can control BLE device remotely, receives the data sent by the BLE devices and sends it to servers. The Wi-Fi data rate can be up to 580Mbps and BLE data rate can be up to2Mbps.It can also supports the 5V adapter power supply. It reserves the Zigbee3.0 function ,Z-wave, 4G LTE function.

1.2 Product Feature Summary 

  • Support 5V adapter power supply
  • Support IEEE802.11ac,IEEE802.11n,IEEE802.11g,IEEE 802.11b Protocol
  • Support Network Communication of 4G Module (LTE-TDD/LTE-FDD)
  • Support Bluetooth 5.2
  • Support ZigBee3.0
  • Support Z-WAVE
  • Supporting waterproof and dustproof
  • One WAN/LAN variable network port
  • Back up Li battery

 1.3 System block diagram

image 33

 1.4 Development Environment and Tool

image 34

2. Reference Documentation

2.1 Standard Protocol Documentation

Specifications for zigbee3.0 

  • docs-05-3474-21-0csg-zigbee-specification.pdf

Specifications for BT

Specifications for MQTT

2.2  Dusun standard documentation  

 Dusun_Communication_Protocol_between_Cloud_and_Gateway_V0.9606.pdf

3. Configuration

3.1 Basic Configuration

3.1.1 Deploy the environment of configuration 

image 1

Putting the PC connect to the LAN port of the gateway by netting twine.   

3.1.2 Login Password of Configuration Page

Open the website, Input Gateway IP Address: 192.168.66.1

image 35

Enter the username and Password

Username: root

Password: root

image 11

In this page, you can check the status of system, memory, Network.

System Information: The hostname, Model, Firmware Version, Kernel Version, Local Time.

Memory Information: Total Available, Free, Buffered.

Network: IPv4 WAN Status.

3.1.3 System Configuration

You can enter the “system” menu.

image 12

Here you can configure the basic aspects of your device like its hostname or time zone.

image 13

3.1.4  Administrator Configuration 

You can enter the “administrator” menu.

image 36

You change the administrator password for accessing the device.

image 14

3.1.4  Firmware Configuration 

You can enter the “Backup/flash” menu.

image 15

You can download the firmware from the current gateway to back up and restore.

And you also can upload a new firmware image to replace the running firmware.  

image 16

3.1.5  Reboot

Reboots the operating system of your device.

image 17

3.2 Network Configuration

3.2.1 Network Interfaces Configuration

You can enter the “Interfaces” menu in <Network>.

image 37

Interface Overview

image 38

3.2.2  Interfaces-WAN Configuration

On this page, you can configure the network interfaces. You can bridge several interfaces by ticking the “bridge interfaces” field and enter the names of several network interfaces separated by spaces. You can also use VLAN notation INTERFACE.VLANNR (e.g.: eth0.1).

image 18

3.2.3  Interfaces – WAN6 Configuration

On this page, you can configure the network interfaces. You can bridge several interfaces by ticking the “bridge interfaces” field and enter the names of several network interfaces separated by spaces. You can also use VLAN notation INTERFACE.VLANNR (e.g.: eth0.1).

image 19

3.2.4  Interfaces – WANPPP Configuration

On this page, you can configure the network interfaces. You can bridge several interfaces by ticking the “bridge interfaces” field and enter the names of several network interfaces separated by spaces. You can also use VLAN notation INTERFACE.VLANNR (e.g.: eth0.1).

image 20

3.2.5  Interfaces – LAN Configuration

On this page, you can configure the network interfaces. You can bridge several interfaces by ticking the “bridge interfaces” field and enter the names of several network interfaces separated by spaces. You can also use VLAN notation INTERFACE.VLANNR (e.g.: eth0.1).

image 21

3.2.6  Network Diagnostics

image 22

3.3  MQTT server configuration

You can enter the “MQTT server config” menu in <dusun>.

image 23

You can configure the MQTT server: MQTT server Address, MQTT server Port, MQTT keep Alive Time, MQTT User Name, MQTT Password.

image 24

3.4   zigbee 3.0 manage

You can enter the “zigbee3.0 manage” menu in <dusun>.

image 39

You can press the<permit> button to pair with Zigbee devices.  

If pair successful, you can see the sensor information.   

image 40

3.5   Remote Assistance

You can enter the “remote assistance” menu in <dusun> .

image 41

 It can Remote connect back so that doing some develop work and upgrade.

image 25

3.6   Z-WAVE Manage

You can enter the “Zwave Manage” menu in <dusun> .

image 26

<Include>button: It can let gateway pair with sensors.

<Exclude>button: It can let gateway unpair with sensors

3.7   LTE Configuration

You can enter the “4G3G Argments config” menu in <dusun>

image 27

You can set the APN in this page.  

3.8   Wi-Fi Configuration

You can enter the “Wi-Fi manage” menu in <dusun>

image 28

You can set the mode of Wi-Fi, AP or STA.

3.8.1   AP mode

If you set AP mode, The gateway enter the AP mode. You can set the SSID ,Wi-Fi Encryption, and Wi-Fi key .

3.8.2   STA mode

If you set STA mode, The gateway enter the STA mode . You can set the SSID and WI-FI key that you want to connect the router.

4. Configuration

An IoT application on the gateway is normally fetching data from IoT devices or sensors, then processing data and sending data to the cloud. The Dusun gateways support most protocols for these connectivity types and suit for many applications. Common connectivity protocols include BLE(4.x/5.0/Mesh), ZigBee 1.2/3.0, Z-Wave, TCP/UDP, etc.

4.1  Communication with ZigBee IoT devices

This sub chapter will discuss how to write an application for the gateway which communicates with a ZigBee sensor/device to get corresponding sensor data.

4.1.1  UBUS in OpenWrt

UBUS is a message bus in OpenWrt. Its main function is to realize information exchange between different applications. When UBUS starts, it runs the ubusd process in the background, which listens for a UNIX socket to communicate with other applications. Other applications can communicate with libubox based on the interface provided by libubox (or implemented by themselves). Figure 1 shows the simplified gateway OpenWrt system architecture.

image 29

Figure 1 the gateway system architecture

4.1.2  Getting ZigBee sensors/devices data from UBUS

Dusun has provided a library (please see the attached code files) in which a set of APIs can be used to fetch data from the ZigBee sensors/devices. The API library includes the static link library (librbsdk.a) and a corresponding header file (rbsdk.h). The API functions can be seen from the header file (rbsdk.h). Some core functions are listed below:

				
					
/*Function to initialize the SDK. */
int rbsdk_init(void *unused, int (*msgcb)(char *src, char *dest, char *msg));
/*Function to get the SDK version. */
  int rbsdk_vers(char *version);
/*A General Call Functions. */
  int rbsdk_call(char *mac, char *attr, int setOrget, void *jvalue);
  /*Function to Set the Message Callback. */
  int rbsdk_dev_msgcb_set(stDevMsgCb_t *dmc); 
  /*Function to Get Device list. */
  int rbsdk_list_dev();
/*Functoin to Send adding device Request. */
  int rbsdk_add_dev(char *mac, char *type);
  /*Function to Send Deleting Device Request. */
  int rbsdk_del_dev(char *mac); 
  /*Function to Send Add Lock PassWord Request. */
  int rbsdk_dev_lock_add_pass(char *mac, int type, int id, int passVal1, int passVal2, int startTime, int endTime, int suspend);  
/*Function to Send Delete Lock Password Request. */
  int rbsdk_dev_lock_del_pass(char *mac, int type, int id);  
/*Function to Send Modify Lock Password Request. */
  int rbsdk_dev_lock_mod_pass(char *mac, int type, int id, int passVal1, int passVal2, int startTime, int endTime, int suspend);
  /*Function to Send Clear Lock Password Request. */
  int rbsdk_dev_lock_clr_pass(char *mac, int type);
  /*Function to Send Set Dynamic Password Seed Request. */
  int rbsdk_dev_lock_set_seed(char *mac, int id, int seed, int interval, int startTime, int endTime);
  /*Function To Send Light OnOff Request. */
  int rbsdk_dev_light_onoff(char *mac, int onoff);
  /*Function to Send Window Controller's Open Request. */
  int rbsdk_dev_winctr_open(char *mac);
  /*Function to Send Window Controller's Stop Request. */
  int rbsdk_dev_winctr_stop(char *mac);
  /*Function to Send Window Controller's Close Request.*/
  int rbsdk_dev_winctr_close(char *mac);
  /*Function to Send Air conditioner Onoff Request.*/
  int rbsdk_dev_air_onoff(char *mac, int onoff);
  /*Function to Send Air conditioner Mode Request.*/
  int rbsdk_dev_air_mode(char *mac, int mode);
  /*Function to Send Air conditioner Fan Request. */
  int rbsdk_dev_air_fan(char *mac, int fan);
/*Function to Send Air conditioner temp Request. */
  int rbsdk_dev_air_temp(char *mac, int temp_mode, int dir, int temp_delt); 
/*A callback function for pushing the sensor command data reported by the sensor using a customized cluster to the application*/
int (*rpt_cmd)(char *mac, int ep, int cluster, int cmd, char *buf, int len);
/*A callback function for pushing the sensor attribute data reported by the sensor using a customized cluster to the application*/     
int (*rpt_attr)(char *mac, int ep, int cluster, int attr, char *buf, int len);
  /*A function for sending the command data to the sensor using a customized cluster */
int rbsdk_zcl_cmd(char *mac, int ep, int cluster, int cmdid, char *data, int len);
/*A function for sending the attribute data to the sensor using a customized cluster */
int rbsdk_set_attr(char *mac, int ep, int cluster, int attrid, char *data, int len);
/*A function for sending the get atrribute command to the sensor using a customized cluster */
int rbsdk_get_attr(char *mac, int ep, int cluster, int attrid);
				
			

4.1.3  A sample: communicate with a door ZigBee sensor using the APIs

 

The code below shows how to use the provided APIs to get a Dusun door contact sensor data. First, we should init the sdk by calling rbsdk_init(NULL, NULL); Then, we write four callback functions, and fill a stDevMsgCb struct which is used by rbsdk_dev_msgcb_set to set the callback functions. We will get the data when the callback functions are invoking. For example, the rpt_door function can print the door status reported. If your sensor report data using a customized ZigBee cluster, you should write the rpt_cmd and rpt_attr callback functions in which you can get the sensor data to be processed.

#include <stdio.h>

#include <stdlib.h>

#include “rbsdk.h”

				
					int rpt_dev_added(char *mac, char *ModelStr, char *model, int type, int battery) {
printf("[%s] - %s added\n", __func__, mac);
return 0;
}
int rpt_dev_deled(char *mac) {
printf("[%s] - %s deleted\n", __func__, mac);
return 0;
}
int rpt_dev_online(char *mac, int online) {
printf("[%s] - %s online : %d\n", __func__, mac, online);
return 0;
}
int rpt_door(char *mac, int door) {
printf("[%s] - %s door status:%d\n", __func__, mac, door);
return 0;
}
int main(int argc, char *argv[]) {
rbsdk_init(NULL, NULL);
char sver[32];
rbsdk_vers(sver);
printf("rbsdk version : %s\n", sver);
stDevMsgCb_t dmc = {
.rpt_dev_added = rpt_dev_added,
.rpt_dev_deled = rpt_dev_deled,
.rpt_dev_online = rpt_dev_online,
.rpt_dev_battery = NULL,
.rpt_dev_lowpower = NULL,
.rpt_temp = NULL,
.rpt_humi = NULL,
.rpt_door = rpt_door,
.rpt_pir = NULL,
.rpt_leak = NULL,
.ret_lock_password_add = NULL,
.ret_lock_password_del = NULL,
.ret_lock_password_mod= NULL,
.ret_lock_password_clr = NULL,
.ret_lock_dynamic_seed = NULL,
.rpt_lock_checkrecord = NULL,
.rpt_lock_system_locked= NULL,
.rpt_smoke = NULL,
.rpt_light_onoff = NULL,
.rpt_winctr_status = NULL,
.rpt_winctr_percent = NULL,
        .rpt_cmd             = NULL,
.rpt_attr              = NULL,
};
rbsdk_dev_msgcb_set(&amp;dmc);
while (1) {
sleep (1);
}
return 0;
}
				
			
Related IoT Product Specifications

MIR-IR100 PIR Motion Sensor Spec

1. Product Description 1.1. Purpose and Description The MIR-IR100 PIR Motion Sensor utilizes Fresnel lens to focus on the infrared light emitted by the human

MIR-MC100 Door/Window Sensor

The window door sensor monitors the opening and closing status of entry points, and sends alerts to the alarm system when necessary. Surface-mounted. Wholesale prices

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.