DSI-0134 Gateway

Development Instruction

1. Introduction ...................................................................................................................................3

1.1 Purpose& Description  ...............................................................................................................3

1.2 Product Feature Summary  ........................................................................................................3

1.3 System block diagram ................................................................................................................3

1.4 Development Environment and Tool ........................................................................................4

2. Reference Documentation ...........................................................................................................4

2.1 Standard Protocol Documentation ...........................................................................................4

2.2 Dusun standard documentation ...............................................................................................4

3. Configuration .................................................................................................................................4

3.1 Basic Configuration .....................................................................................................................4

3.1.1 Deploy the environment of configuration .............................................................................4

3.1.2 Login Password of Configuration Page ..................................................................................5

3.1.3 System Configuration ...............................................................................................................6

3.1.4 Administrator Configuration ...................................................................................................7

3.1.5 Firmware Configuration ..........................................................................................................7

3.1.6 Reboot .......................................................................................................................................8

3.2 Network Configuration ...............................................................................................................8

3.2.1 Network Interfaces Configuration ..........................................................................................8

3.2.2 Interfaces-WAN Configuration ................................................................................................8

3.2.3 Interfaces – WAN6 Configuration ...........................................................................................9

3.2.4 Interfaces – WANPPP Configuration .......................................................................................9

3.2.5 Interfaces – LAN Configuration ..............................................................................................10

3.2.6 Network Diagnostics ................................................................................................................11

3.3 MQTT server configuration ........................................................................................................11

3.4 zigbee 3.0 manage ......................................................................................................................12

3.5 Remote Assistance .....................................................................................................................12

3.6 Z-WAVE Manage ..........................................................................................................................13

3.7 LET Configuration .......................................................................................................................13

3.8 Wi-Fi Configuration .....................................................................................................................14

3.8.1 AP mode ....................................................................................................................................14

3.8.2 STA mode ...................................................................................................................................14

4. Development Application on gateway .........................................................................................14

4.1 UBUS in OpenWrt .........................................................................................................................14

4.2 Ubus Architecture .........................................................................................................................15

4.3 Getting the zigbee sensors data from Ubus .............................................................................15

4.4 Bluetooth Debug ..........................................................................................................................16

4.4.1 hcitool .........................................................................................................................................16

4.4.2 gatttool .......................................................................................................................................17

4.5 Control all LED and buttons .........................................................................................................18

4.6 Building Tool ..................................................................................................................................19

4.7 Install the Application on gateway ..............................................................................................20

4.7.1 Use the SCP command ..............................................................................................................20

4.7.2 Use opkg command ...................................................................................................................21

1. Introduction

1.1 Purpose & Description

The DSI-0134 is gateway product used in smart home, intelligent security industry, pension services. It’s a central device, support LTE-M1 (EMTC), Wi-Fi, zigbee3.0, Bluetooth and Z-WAVE wireless protocol. User can connect the network through LTE-M1, Wi-Fi and Ethernet. In addition, smart sensors can be connected through zigbee3.0, Bluetooth and z-wave.  

1.2 Product Feature Summary 

System:

  • OS: Linux@ OpenWrt

  • Processor: MTK7620A (MIPS24KEc(580MHZ))

  • RAM: 128MB

  • Flash: 16/32MB

Wireless protocol:

  • LTE-M1

  • Wi-Fi

  • Zigbee3.0

  • Bluetooth

  • Z-Wave

Ethernet:

  • WLAN

  • LAN

 1.3 System block diagram

 1.4 Development Environment and Tool

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 

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

Enter the username and Password

Username: root

Password: root

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.

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

3.1.4  Administrator Configuration 

 

You can enter the “administrator” menu.

You change the administrator password for accessing the device.

3.1.4  Firmware Configuration 

 

You can enter the “Backup/flash” menu.

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.  

3.1.5  Reboot

 

Reboots the operating system of your device.

3.2 Network Configuration

3.2.1 Network Interfaces Configuration

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

Interface Overview

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).

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).

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).

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).

3.2.6  Network Diagnostics

3.3  MQTT server configuration

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

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

3.4   zigbee 3.0 manage

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

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

If pair successful, you can see the sensor information.   

3.5   Remote Assistance

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

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

3.6   Z-WAVE Manage

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

<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>

You can set the APN in this page.  

3.8   Wi-Fi Configuration

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

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.

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(&dmc);

 

while (1) {

sleep (1);

}

return 0;

}