Skip to content

Compiling and running application

Dusuniot edited this page Aug 3, 2019 · 12 revisions

Code compiling and running

The examples in the code files can be compiled and run in the gateway following the steps below:

  1. Get the Openwork toolchain and copy it to a Linux PC. Get the cross compile OpenWrt-Toolchain from Dusun, whose name is openwrt-sdk-ramips-mt7620_gcc-4.8-linaro_uClibc-0.9.33.2. Linux-x86_64.tar.bz2. 4. Decompress the downloaded OpenWrt Toolchain to a local folder (E.g.: home/software/OpenWrt-SDK).

  2. Compiled the attached code files. Using git to clone the code files: git clone https://github.com/dusuniot/Dusun_Gateway_API.git Then open ./example/make folder, and edit the arch.mk file to revise the CROSSTOOLDIR to the OpenWrt toolchain directory you created above as depicted in the figure below.

    11

  3. Then open a terminal on the Linux PC, and type the following commands:

    cd ./example make cd build

    Finally, the test bin file which can be run in the gateway has been compiled.

    12

  4. Copy the compiled test bin file into the gateway and run it. There are some ways one can do it. Under Linux PC, you can use SCP command (scp local_file remote_username@remote_ip:remote_folder ) to do it. Make sure the gateway is connected to the same router with PC, then run the following commands:

    scp /home/software/test/example/test root@192.168.66.1:/user/bin

    Then remote login to the gateway using SSH commands or SSH client (windows: putty or SecureCrt) and run the copied bin file.

  5. Joining the sensor to the gateway.

    • For the ZigBee sensor:

      Open a door contact sensor and press the ZigBee pairing button on the sensor for about 3 seconds (figure below). Then run a command in the SSH terminal (after the pc has connected the gateway through SSH):

      dusun_ucmd.sh permit 1

      17

      The API function rbsdk_add_dev can be used in the application to allow the ZigBee device to join ZigBee network. This will start the ZigBee pairing procedure and connect the sensor to the gateway. Finally, we can see the report messages appearing in the console (Figure below). When the sensor is connected to the gateway, the rpt_dev_added function is invoked; When the communication begins, the rpt_dev_online function is invoked; When the sensor reports the door status, the rpt_door function is invoked and the door status is printed. If your sensor has a customized ZigBee cluster, the rpt_cmd and rpt_attr should be used to get the data.

      18

    • For the Z-Wave sensor:

      Power up the light switch sensor and press any one button three times to start pairing with the gateway (figure below).

      14

      Run the compiled test execute file (Figure below line 1),then run include command in the terminal (Figure below line 7). We can see the callback functions rpt_zwdev_added/ rpt_zwdev_online are invoked and print the device information including the mac address(30AE7B63F3164646). We then input the flowing command on the console (Figure below)

      cmd 30AE7B63F3164646 0 96 13 0002250100

      cmd 30AE7B63F3164646 0 96 13 0002250101

      It can be seen that sensor button status has changed twice. The rbsdk_zw_class_cmd API function was used to send the command data. Please check do_cmd_class_cmd function listed in the code for more detail. The sensor data format can be checked in the sensor user manual and Z-Wave manual. (0002250101 00: fixed; 02: button 2;25: class number; 01: command; 01: switch status on)

      16

Clone this wiki locally