Tizen ZigbeeFW On ARTIK

From Tizen Wiki
Jump to: navigation, search

« back to Tizen_On_ARTIK

Introduction

From 4.0, Tizen supports Zigbee connectivity. Since Zigbee functions are deeply related to H/W, Tizen profile which supports Zigbee is limited to common profile. In general, Zigbee implementation, also, depends on H/W chipset and firmware. Within Tizen project, we focus on delivering Zigbee Framework, which is adaptable to various H/W, chipset combination. As a reference, we facilitate Zigbee Framework in ARTIK 5/7/10 on Tizen. Also, you can use CEL EM357 USB Stick to use Zigbee connectivity from another target device.

Installation

1. Download Zigbee firmware

ARTIK

The Zigbee radio on the ARTIK module works with the main processor on the module in what is called network co-processor (NCP) operation. We've tested ARTIK 5/7/10 which uses the EM3587 radio chip as NCP.

You can download required Zigbee firmware following link.
Firmware link
Please push required firmware into pre-defined path with following commands.
It will be flashed if you install following Zigbee plugin and enable Zigbee.

sdb root on
sdb shell mount -o remount,rw /
sdb push flash_firmware /usr/bin/
sdb push <Firmware file> <Temporary path>

ex) ARTIK5
sdb push ncp-uart-rts-cts-use-with-serial-uart-btl-5.7.4.ebl /tmp/
sdb shell flash_firware -p /dev/ttySAC1 -f /tmp/ncp-uart-rts-cts-use-with-serial-uart-btl-5.7.4.ebl -n

ex) ARTIK7
sdb push ncp-uart-xon-xoff-use-with-serial-uart-btl-5.7.4.ebl /tmp/
sdb shell flash_firware -p /dev/ttySAC0 -f /tmp/ncp-uart-xon-xoff-use-with-serial-uart-btl-5.7.4.ebl -n

ex) ARTIK10
sdb push ncp-uart-rts-cts-use-with-serial-uart-btl-5.6.0.ebl /tmp/
sdb shell flash_firware -p /dev/ttySAC0 -f /tmp/ncp-uart-rts-cts-use-with-serial-uart-btl-5.6.0.ebl -n


In case of a normal firmware download process, you can see the following output.

sh-3.2# flash_firmware -p /dev/ttySAC1 -f /tmp/ncp-uart-rts-cts-use-with-serial-uart-btl-5.7.4.ebl -n
ebl header tag/signature found
serial port opened successfully
bootloader connection is established
preparing file transfer using xmodem
file name : /tmp/ncp-uart-rts-cts-use-with-serial-uart-btl-5.7.4.ebl
file size : 151424 byte

................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................

============================================
image transfer is completed (version : 0.1)
============================================
sh-3.2# saerome.kim@lx:~/utils/flash$ 

After uploading required files, please follow the official guide below.
Update NCP Firmware


EM357 USB Stick

CEL's MeshConnect™ EM357 USB Sticks enable hardware vendors to quickly integrate ZigBee® into existing devices with a USB port.
With this hardware, you can use Zigbee connectivity on Tizen common profile with Odroid target device or something else.

Notice ! There are 2 types of USB Stick, one has installed bootloader and the other is not.
Updating firmware on the ZigBee USB dongle

You need to check 'Silicon Labs' manufacturer to upload the firmware without ISA3 debug adapter.
EM357 ZigBee USB Stick

A) Get firmware

Please download SiLabs' *Simplicity Studio* from below official page.
Simplicity Studio

After installation, you can get official firmware file (*.ebl extension) like below path.

~/SimplicityStudio_v4/developer/stacks/znet/v5.8.1.0/protocol/zigbee_5.8/ncp-images/em357/ncp-uart-xon-xoff-use-with-serial-uart-btl-5.8.1.ebl


B) Firmware download

Please get 'ncp.py' from below thread.
Script

And run below commands to download firmware.

sudo pip install xmodem
sudo python ncp.py scan
sudo python ncp.py flash -p /dev/<tty device> -f ./ncp-uart-xon-xoff-use-with-serial-uart-btl-5.7.2.ebl

Output :

$ sudo python ncp.py scan
...
{"deviceType": "unknown", "pid": "8856", "port": "/dev/ttyUSB0", "vid": "10c4"},
...

$ sudo python ncp.py flash -p /dev/ttyUSB0 -f ./ncp-uart-xon-xoff-use-with-serial-uart-btl-5.7.2.ebl
Restarting NCP into Bootloader mode...
EFR 32Serial Btl v5.7.2.0 b444

Successfully restarted into bootloader mode! Starting upload of NCP image...
Finished!
Rebooting NCP...
$

2. Install Zigbee plugin

Zigbee plugin for Tizen (ARTIK5/10 are available now) can be downloaded following link.
Plugin link

After download, please install plugin with below commands.

sdb root on
sdb shell mount -o remount,rw /
sdb push zigbee-plugin-ember-X.X.X-X.armv7l.rpm /tmp/
sdb shell rpm -Uvh --force /tmp/zigbee-plugin-ember-X.X.X-X.armv7l.rpm

How to check

Console application is un-officially provided. It is not guaranteed to work all functionalities in console application.

Prerequistes

Zigbee thing device is required to comminicate with. We've tested 'Samjin smart plug' for below scenario.

Run test program

Please run 'test-zigbee' on console to use zigbee test application.

sh-3.2# test-zigbee

* ZigBee Test application 
* Build On: Apr 17 2017  10:23:31

=================================================================
 Main
-----------------------------------------------------------------
 [  1] Init                                                    >
 --------------------------------------------------------------- 
 [ t ] Target addr [0x1D1A]
 --------------------------------------------------------------- 
 [ p ] Previous menu 
 [ m ] Show Menu 
 [ q ] Quit 
=================================================================
(24536) >>

Enable Zigbee FW

Please run 'Init' menu.

1 (enter)

If Zigbee FW enabled successfully, you can see 'ZB_ZDP_ENABLE_EVENT' event.

(24536) >> 1

zb_create(0x0) - SUCCESS!!!. handle [0x4ccf8]
 - zb_set_event_cb() ret: [0x0] [ZIGBEE_ERROR_NONE]
 - zb_enable() ret: [0x0] [ZIGBEE_ERROR_NONE]
(24536) >> 
=================================================================
 Main >> Init
-----------------------------------------------------------------
 [  1] Device                                                  >
 [  2] Network                                                 >
 [  3] Cluster Library                                         >
 [  4] Device Object                                           >
 [  5] Custom                                                  >
 --------------------------------------------------------------- 
 [ t ] Target addr [0x1D1A]
 --------------------------------------------------------------- 
 [ p ] Previous menu 
 [ m ] Show Menu 
 [ q ] Quit 
=================================================================
(24536) >> 
Event received = ZB_ZDP_ENABLE_EVENT [0x00]
  zigbee state = 1 [Enabled]


Event received = ZB_ZDP_FORM_NETWORK_DONE [0x01]
  form network done

Permit join

Tizen Zigbee FW on ARTIK works as a Zigbee coordinator, so permitting is required to communicate with a new Zigbee device.
Zigbee is enabled first time or network is re-created, you need to make coordinator to permit joining state.

You can enter below menu and run it.

Network > zb_permit_join > Run (2 > 6 > 2)

After permit setting, please make Zigbee thing search mode.
(There is a button or something mechanism on Zigbee thing device. Please find device manual for details.)

If device is joined, you can see 'ZB_ZDP_JOIN_EVENT' like below result.

=================================================================
 Main >> Init
-----------------------------------------------------------------
 [  1] Device                                                  >
 [  2] Network                                                 >
 [  3] Cluster Library                                         >
 [  4] Device Object                                           >
 [  5] Custom                                                  >
 --------------------------------------------------------------- 
 [ t ] Target addr [0x1D1A]
 --------------------------------------------------------------- 
 [ p ] Previous menu 
 [ m ] Show Menu 
 [ q ] Quit 
=================================================================
(24536) >> 2

=================================================================
 Main >> Init >> Network
-----------------------------------------------------------------
 [  1] zb_get_network_info
 [  2] zb_get_controller_mac_address
 [  3] zb_form_network
 [  4] zb_disable_network
 [  5] zb_leave_device                                         >
 [  6] zb_permit_join                                          >
 --------------------------------------------------------------- 
 [ t ] Target addr [0x1D1A]
 --------------------------------------------------------------- 
 [ p ] Previous menu 
 [ m ] Show Menu 
 [ q ] Quit 
=================================================================
(24536) >> 6

=================================================================
 Main >> Init >> Network >> zb_permit_join
-----------------------------------------------------------------
 [  1] Timeout (90)
 [  2] Run
 --------------------------------------------------------------- 
 [ t ] Target addr [0x1D1A]
 --------------------------------------------------------------- 
 [ p ] Previous menu 
 [ m ] Show Menu 
 [ q ] Quit 
=================================================================
(24536) >> 2
 - zb_permit_join() ret: [0x0]
(24536) >> 

*** Wait for some seconds... 

Event received = ZB_ZDP_JOIN_EVENT [0x02]
  24:FD:5B:00:01:01:86:B6 joined
end-point count=1

Select target device

To communicate specific Zigbee thing in network, you need to set target device.

You can enter below menu and run it.

Target addr > Device list > (Select number) > Apply (t > 1 > (number) > 3)

If target device is selected. you can communicate and send data to them.

(24536) >> t

=================================================================
 Main >> Init >> Select target
-----------------------------------------------------------------
 [  1] Device list (1)
 [  2] Input network addr manually (hex) ()
 [  3] Apply
 --------------------------------------------------------------- 
 [ t ] Target addr [0x1D1A]
 --------------------------------------------------------------- 
 [ p ] Previous menu 
 [ m ] Show Menu 
 [ q ] Quit 
=================================================================
(24536) >> 1
 - zb_get_all_device_list() ret: [0x0] [ZIGBEE_ERROR_NONE]
End device [1]
   Samjin Power Outlet Find!!
    nwk address = 0xF8E9
   ieee address = 24:FD:5B:00:01:01:86:B6
   number of end-points = 0x0001
      0001 

(24536) >> 
=================================================================
 Input [Device list] data 
-----------------------------------------------------------------
 current = [1]
 new >> 1
OK.

=================================================================
 Main >> Init >> Select target
-----------------------------------------------------------------
 [  1] Device list (1)
 [  2] Input network addr manually (hex) ()
 [  3] Apply
 --------------------------------------------------------------- 
 [ t ] Target addr [0xF8E9]
 --------------------------------------------------------------- 
 [ p ] Previous menu 
 [ m ] Show Menu 
 [ q ] Quit 
=================================================================
(24536) >> 3
  network addr [0xF8E9] selected.
  ieee address = 24:FD:5B:00:01:01:86:B6

On/Off cluster operation

You can execute cluster operation to selected target device.

Cluster Library > Cluster Commands > On/Off Cluster > zb_zcl_onoff_control > Operation (3 > 2 > 8 > 1 > (number))
=================================================================
 Main >> Init >> Cluster Library >> Cluster Commands >> On/Off Cluster >> zb_zcl_onoff_control
-----------------------------------------------------------------
 [  1] On
 [  2] Off
 [  3] Toggle
 --------------------------------------------------------------- 
 [ t ] Target addr [0xF8E9]
 --------------------------------------------------------------- 
 [ p ] Previous menu 
 [ m ] Show Menu 
 [ q ] Quit 
=================================================================
(24536) >> 3
 - zb_zcl_onoff_control() ret: [0x0]

(24536) >> 
Event received = ZB_ZCL_GLOBAL_DEFAULT_RSP_EVENT [0x10]
  addr16     = 0xF8E9
  endpoint   = 0x01
  cluster_id = 0x0006 (ZB_ZCL_ON_OFF)
  command_id = 0x02
  status     = 0x00 (ZB_ZCL_SUCCESS)

Notice

Architecture

Resource

Tizen Zigbee CAPI link : https://review.tizen.org/gerrit/#/admin/projects/platform/core/api/zigbee