Hands-on Workshop: Using Wireless Connectivity Stacks and Tools to Create Multi-Protocol projects for the Internet of Things (IoT) FTF-SDS-F0042 Alan Collins Wireless Applications Engineer Alin Lazar Software Team Manager Angel Corona Connectivity Engineer A P R. 2 0 1 4 TM External Use
Session Introduction This session will: Provide an overview on the wireless connectivity and its challenges for the IoT Show Freescale innovative solutions for wireless connectivity. Introduce the Dual-PAN concept: single radio participating in two complex networks simultaneously. This translates into a cost effective design. Hands-on training using complex software stacks to enable multiple wireless protocols External Use 1
Session Objectives After completing this session you will be able to: Start your IoT design and development understanding the wireless connectivity landscape & challenges. Use complex wireless multi-protocol software stack for embedded systems. Locate the documentation and reference designs to help you on your IoT product. External Use 2
Agenda IoT overview Multiple-protocol networks Use cases Solutions Dual-PAN Freescale Kinetis W series MCUs Hands-On training Dual-PAN example 1: ZigBee HA + ZigBee SE Dual-PAN example 2: ZigBee HA + IP stack Summary External Use 3
Dual-PAN Concept Overview What exactly is the Dual-PAN? PAN Personal Area Network Dual-PAN Id feature allows a single 802.15.4 radio participate in different networks simultaneously External Use 4
Agenda IoT overview Multiple-protocol networks Use cases Solutions Dual-PAN Freescale Kinetis W series MCUs Hands-on training Dual-PAN example 1: ZigBee HA + ZigBee SE Dual-PAN example 2: ZigBee HA + IP stack Summary External Use 5
The Internet of Things M2M. Connectivity. Context. External Use 6
IoT Use cases Smart Connectivity Personalized Marketing Statistical behavior New Patterns search triggered by relevant events Remove/Add feature-set to existing/new products Others we can imagine, Others we will discover External Use 7
Slices of the IoT pie: We all want a piece of it ACTUATORS Motors Water Engines Hydraulic Motion control Servomechanisms CONNECTIVITY Wired & Wireless Protocol Standards Ethernet USB Wi-Fi Bluetooth 4.1 ZigBee ANT+ IPv6 + 6LoWPAN SENSORS Compass Magnetometer Accelerometer Touch sensor Gyroscope Altimeter/pressure Temperature Humidity MICROCONTROLLERS 8-, 16-, 32-bit Low Power Frequency of operation Memory Inputs/Outputs Serial Interfaces & Connectivity Built-in Analog and Sensors External Use 8
Slices of the IoT pie: We all want a piece of it BIG DATA & ANALYTICS Collection of data sets Large & complex Database management tools Statistical analysis CLOUD Software, platforms and infrastructure Services Remotely through the internet Share resources to achieve coherence & economies of scale SECURITY Encryption High security across protocols and layers Network access Data access Weakest link in the chain in the most important FRONT-END User Interface Smart Phones, Tablets, TV, Laptop External Use 9
IoT Building blocks CLOUD BIG DATA & ANALYTICS Connectivity Connectivity MCU Sensors Connectivity Connectivity Gateway Actuator Microcontroller Edge Node External Use 10
IoT is all about the services Existing Business model New opportunities for users and service providers Thank you for downloading your new IoT service. It s free of charge, we just need your permission to access to your profile data. Please read the following agreement More things are connecting to the Internet than people over 12.5 billion devices in 2010 alone. We will have 50 billion devices connected by 2020. Cisco s Internet Business Solutions Group External Use 11
Wireless Connectivity for the IoT External Use 12
Agenda IoT overview Multiple-protocol networks Use cases Solutions Dual-PAN Freescale Kinetis W series MCUs Hands-On training Dual-PAN example 1: ZigBee HA + ZigBee SE Dual-PAN example 2: ZigBee HA + IP stack Summary External Use 13
Dual-PAN Use Cases Pick two network flavors from the protocols landscape: Smart Energy Home Automation RF4CE ZigBee IP (Smart Energy 2.0) IPv6 through 6LoWPAN adaptation for 802.15.4 Enable CoAP and other RESTful architecture frameworks 802.15.4 Proprietary All others ZigBee IP RF4CE ZigBee 2007/PRO ZigBee SE 2.0 Application Profiles RF4CE Network 802.15.4 MAC Security Application Framework Application Support Sub-Layer Network 802.15.4 MAC ZigBee Device Objects NWK manage r (ND, RPL) TC P IPv6 UDP 6LowPAN adaptation 802.15.4 MAC Security IP stack IPv6, IPv4 6LowPAN adaptation 802.15.4 MAC 802.15.4 PHY 802.15.4 PHY 802.15.4 PHY 802.15.4 PHY External Use 14
Dual-PAN Use Case: Smart Energy & Home Automation Smart Energy Network Security enhanced. Utilities own the network Smart Energy External Use 15
Dual-PAN Use Case : Home Automation Network Smart Energy Network Security enhanced. Utilities own the network Home Automation Network Residential Security. Home owns the network Smart Energy Home Automation External Use 16
Dual-PAN Use Case : Smart Energy and Home Automation Smart Energy Network Security enhanced. Utilities own the network Home Automation Network Residential Security. Home owns the network Dual-PAN Smart Energy & Home Automation Smart Energy Home Automation Dual PAN SE/HA External Use 17
IoT Convergence to IP Funnel Web services / EXI APP CoAP, SE 2.0, HTTPS,...etc Transport TCP, UDP Network IP (v6, v4) Link/PHY Wi-Fi, Ethernet, BT 4.1, PLC, 802.15.4, Etc External Use 18
Agenda IoT overview Multiple-protocol networks Use cases Solutions Dual-PAN Freescale Kinetis W series MCUs Hands-On training Dual-PAN example 1: ZigBee HA + ZigBee SE Dual-PAN example 2: ZigBee HA + IP stack Summary External Use 19
Multiple Radios Solution : Example One Two radios Two antennas and all RF components Two crystals (oscillators) Complex RF certification External Use 20
Multiple Radios Solution : Example Two MCU controls two stand alone radios using a communication interface Reduces cost, but increase the engineering complexity Still two antennas are needed with all RF components External Use 21
Dual-PAN Concept Overview - AGAIN What exactly is the Dual-PAN? PAN Personal Area Network Dual-PAN Id feature allows a single 802.15.4 radio participate in different networks simultaneously External Use 22
Where s the Complexity of Dual-PAN? TX is simple Just take control of the Radio and perform TX If ACK is required you wait in RX right after the TX TX: PAN 0 TX: PAN 0 TX: PAN 0 Dual-PAN enabled TX: PAN 1 TX: PAN 1 ACK External Use 23
Where s the Complexity of Dual-PAN? RX RX requires more complexity and synchronization TX: PAN 0 RETRY Dual-PAN enabled TX: PAN 1 External Use 24
Dual-PAN by SW Solution Dual-PAN by software Takes longer time to respond on each network Some automatic filtering features (MAC ACK, NWK address, PAN ID and etc.) cannot be used External Use 25
Agenda IoT overview Multiple-protocol networks Use cases Solutions Dual-PAN Freescale Kinetis W series MCUs Hands-on training Dual-PAN example 1: ZigBee HA + ZigBee SE Dual-PAN example 2: ZigBee HA + IP stack Summary External Use 26
Freescale Dual-PAN Feature Implementation How the Dual-PAN works Maintains two sets of network parameters PAN, MAC address, Network Address, Operation Channel Supports manual and automatic modes for switching between networks Manual controlled by software Auto controlled by hardware Device can function as a coordinator, router or end device on each network. PAN0 MacPANID0 (16-bit register) MacShortAddrs0 (16-bit register) MacLongAddrs0 (64-bit registers) PANCORDNTR0 (1-bit register) Channel0 PAN1 MacPANID1 (16-bit register) MacShortAddrs1 (16-bit register) MacLongAddrs1 (64-bit register) PANCORDNTR1 (1-bit register) Channel1 External Use 27
Dual-PAN in Multiple Channels 2 PANs, 2 Channels Time to dwell on channel can be set from 0.5 ms to 3.2 seconds Dwell prescaler and dwell selector registers If PAN is active when timer expired, sequence will complete before channel switch occurs Channel switch is 68 us Time to switch, poll, receive packet and switch back is <10ms 2 PANs, 1 Channel Address filtering is done simultaneously No channel switch is necessary External Use 28
Dual-PAN : Manual Mode External Use 29
Dual-PAN : Auto Mode External Use 30
Dual-PAN ID Demonstration 3 TWR-MKW2xDxxx boards Software available (http://www.freescale.com/beekit) Demonstrates Dual-PAN ID feature in AUTOMATIC mode @ 802.15.4 MAC layer 1 FFDC (coordinator) 2 RFD (End devices) Coordinator will create 2 networks (2 PAN IDs, 2 Channels) Each End Device will join one network The End Devices will perform Packet Error Test addressing the Coordinator The Coordinator shows how many packets it received from each End Device in different PAN ID External Use 31
Dual-PAN ID Demonstration 802.15.4 MAC Layer End Device Menu Coordinator Menu External Use 32
Freescale Multi-PAN Tool External Use 33
Agenda IoT overview Multiple-protocol networks Use cases Solutions Dual-PAN Freescale Kinetis W series MCUs Hands-On training Dual-PAN example 1: ZigBee HA + ZigBee SE Dual-PAN example 2: ZigBee HA + IP stack Summary External Use 34
What is KW Series? Extension of Kinetis line to include Wireless connectivity MKW2x IEEE-802.15.4 Radio for the 2.4 GHz space MKW01x Very flexible Radio for the Sub-GHz space Kinetis W is available today. More information available in the following link: http://www.freescale.com/webapp/sps/site/taxonomy.jsp?code=kinetis_ W_SERIES External Use 35
Choosing the Right Wireless Technology 2.4GHz Sub-GHz Range: ~ 30m indoor, ~ 100-300m outdoor Robust NWK protocols (Like ZigBee) enable multi hoping. High effective data rate 802.15.4 (250kbps) PWR consumption Less time on-air Years of battery life Quick TX/RX turnaround time Retries and ACKS mechanism Smaller Antenna Size 2.4 GHz ~ 3.1cm Global standards for the IoT Exhibits significantly longer range ~ 100m indoor, ~ 500-800m outdoor Better building penetration capability. Typically lower data rate 50 100kpbs Reduced power consumption Low interference = easier transmissions + fewer retries Years of battery life Antenna Size 433MHz ~17.3cm 915MHz ~8.2cm Proprietary standards Lower deployment and operating costs External Use 36
Kinetis W Series: KW2x Wireless MCUs CPU Up to 50 MHz Cortex -M4 16-channel-DMA Up to 512 KB Flash, 64 KB RAM, and 4k bytes of enhanced EEPROM/FlexRAM. Up to 64K FlexNVM (MKW21D256 only) Typical current consume: 250 ua/mhz run, 1.7uA RTC standby Radio Transceiver, 2.4GHz Highly integrated 2.4 GHz RF transceiver 802.15.4 Packet processor Supports single ended and diversity antennas Dual PAN support 110 dbm Link budget Programmable output power -30 to +8 dbm Sensitivity -102 dbm Low Power: TX 15mA @ 0dBm (CPU sleep), RX 15mA (CPU sleep) Security Cryptography Acceleration Unit (CAU) AES encryption (FIPS 140) External tamper detect 32-bit CRC System SPI (1), UART (2), I²C (2), USB FS OTG (KW22 and KW24) 8-channel 16-bit SAR ADC, 6-bit DA Real-Time Clock (RTC) Up to 24 GPIO, Multiple KBI Operating temperature of 40 C to 105 C Device Flash RAM Feature Package MKW21D256VHA5 256 KB 32 KB No USB 8x8 56-pin LGA MKW22D512VHA5 512 KB 64 KB USB 8x8 56-pin LGA MKW24D512VHA5 512 KB 64 KB USB and Smart Energy 2.0 8x8 56-pin LGA http://www.freescale.com/kw2x External Use 37
KW20 Development Kit Tower Form Factor Use standalone or in Tower System Boards sold individually Combine as many boards as needed USB-dongle Form Factor Use is as sniffer hardware Host processors USB-KW24D512 Available in Q2-2014 TWR-KW21D256 or TWR-KW24D512 External Use 38
RF Hardware Support External Use 39
Freescale ZigBee Stacks IP stack 802.15.4 ZigBee PRO ZigBee IP SynkroRF HID RF4CE Customer Defined & Developed Customer Developed ZigBee Profiles ZigBee NWK Customer Developed ZigBee Profiles ZigBee IP NWK Customer Defined SynkroRF NWK Customer Developed RF4CE Profiles RF4CE NWK 802.15.4 MAC 802.15.4 MAC 802.15.4-2006 MAC 802.15.4 MAC 802.15.4 MAC 802.15.4 PHY 802.15.4 PHY 802.15.4 PHY 802.15.4 PHY 802.15.4 PHY Hardware Hardware Hardware Hardware Hardware External Use 40
802.15.4 Protocol Stack Comparison Feature SMAC 802.15.4 MAC SynkroRF ZigBee RF4CE ZigBee Pro IP stack ZigBee IP Applications Cable Replacement Remote Control Home Control Home Automation Health Care Building Automation Smart Energy Network Stack No No Yes Yes Yes Yes Yes Application Profiles No No No Yes Yes No Yes Memory Requirement s 4-8K 32K <40K <40K 128-160K 256K 256K Network Topology Typical # of Nodes Typical Data Throughput Point-to- Point Peer-to- Peer Co-existing Star Co-existing Star Star Tree Mesh 32 per 32 per 2-1000 2-100 2-1000 Controlled Target ZigBee Device Device Pro Tree Mesh Mesh 2-32 2-32 50-115K 90-115K 70-100K 70-100K 30-70K <50K <50K External Use 41
ZigBee Test Infrastructure and Tools External Use 42
ZTC BlackBox and Test Serial API 100s of APIs and events available across layers External Use 43
ZigBee Test Client External Use 44
Python Test Automation External Use 45
MKW2x key differentiators Dedicated Hardware: Dual PAN ID Participate in two networks simultaneously Antenna Diversity Reduce multipath fading MCU with powerful core and energy efficiency options Flash / RAM capacity High radio link budget 802.15.4 hardware engine HW and SW enablement / support External Use 46
Agenda IoT overview Multiple-protocol networks Use cases Solutions Dual-PAN Freescale Kinetis W series MCUs Hands-On training Dual-PAN example 1: ZigBee HA + ZigBee SE Dual-PAN example 2: ZigBee HA + IP stack Summary External Use 47
Hands-On Objective Work with the Dual PAN feature of Kinetis KW2x in practice Use a single KW2x device with a multi-protocol network hub (gateway) application to implement 2 Dual PAN scenarios: 1. ZigBee Home Automation + ZigBee Smart Energy 2. UDP over IPv6 / 6LoWPAN + ZigBee Home Automation External Use 48
Dual PAN ZigBee Home Automation and Smart Energy Dual PAN Hub ZHA Combined Interface SE Energy Service Interface ZigBee Home Automation Network ZigBee Smart Energy Network ZHA Dimmable Light SE Meter External Use 49
Dual PAN 6LoWPAN and ZigBee Home Automation Dual PAN Hub ZHA Combined Interface IPv6 Data Concentrator ZigBee Home Automation Network UDP over IPv6 and 6LoWPAN ZHA Dimmable Light IPv6 End Node External Use 50
Hands-On Steps 1. Use MSD to program Dual PAN network hub firmware to TWR- KW24 2. Use BeeKit and IAR EWARM to export and deploy ZigBee applications end-nodes. 3. Create ZigBee Home Automation and Smart Energy Dual PAN networks. 4. Control and monitor ZHA and SE end-nodes from the Dual PAN hub. 5. Deploy 6LoWPAN end-node firmware to TWR-KW24. 6. Create Home Automation and 6LoWPAN Dual PAN networks. 7. Control and monitor IPv6 and ZHA end-nodes from the Dual PAN hub. External Use 51
Agenda IoT overview Multiple-protocol networks Use cases Solutions Dual-PAN Freescale Kinetis W series MCUs Hands-On training Dual-PAN example 1: ZigBee HA + ZigBee SE Dual-PAN example 2: ZigBee HA + IP stack Summary External Use 52
STEP 1: Program Hub Firmware to TWR-KW2x External Use 53
TWR-KW2x Hub Board Setup Plug in the 1st of the 3 TWR-KW2x board to the PC using the mini-usb port Check that switch SW5 next to the mini-usb port is set to the position towards the exterior of the board this allows the board to be powered via mini-usb If needed, wait for device to be detected by Windows and drivers to be installed. External Use 54
TWR-KW2x Hub Board Setup External Use 55
TWR-KW2x Mass Storage Device Launch Windows Explorer and verify that a USB Mass Storage Device called TWRKW2xDxxx is present. This allows easy binary firmware programming using regular file copy-paste: External Use 56
Program Hub Firmware to TWR-KW2x Using MSD Open the Firmware DualPAN_ZHA_SE subfolder on your desktop Open the TWRKW2xDxxx mass storage drive root folder Drag and drop (or copy-paste) DualPAN_Hub_HA_SE_StnXX.srec file from DualPAN_ZHA_SE subfolder to TWRKW2xDxxx to begin firmware programming Wait while KW2x flash memory is updated with new firmware. Green LED D11 will blink during the process External Use 57
Firmware Update Verification When the firmware update is completed successfully, blue LEDs D5 and D7 will be blinking. External Use 58
Disconnect the Board Disconnect the board before proceeding with deploying the other two end node applications. We will reconnect it once we are ready to start the wireless network formation External Use 59
STEP 2: Use BeeKit to deploy ZHA and Smart Energy end nodes External Use 60
Launch BeeKit Launch the Freescale BeeKit configuration GUI: External Use 61
Select Codebase Choose File Select Codebase External Use 62
Select Codebase Select Kinetis BeeStack 4.0 Codebase and click Set Active 1 2 External Use 63
Create New Project Choose File New Project External Use 64
Create New Project: HA Dimmable Light 1. Select ZigBee Home Automation Applications Project Type 2. Select Ha DimmableLight Template 3. Enter solution name. 4. Enter solution folder location 5. Click OK 1 2 3 4 5 External Use 65
BeeKit Wizard Configuration Overview Review default configuration and click Next External Use 66
BeeKit Wizard Target Board Leave board settings to TWR-KW24D512 and click Next External Use 67
BeeKit Wizard Platform Modules Uncheck NVM module for application to revert to factory defaults on reset. 1 2 External Use 68
BeeKit Wizard ZTC Enable ZTC UART interface to Test Tool. 1 2 External Use 69
BeeKit Wizard Device Type Select Router ZigBee device type. 1 2 External Use 70
BeeKit Wizard Concentrator Leave default concentrator settings. External Use 71
BeeKit Wizard Security Settings Leave default Network Security Parameters. External Use 72
BeeKit Wizard Security Keys Leave default Network Security Key settings. External Use 73
BeeKit Wizard Addresses Update PAN ID to be set to format 00 XX, where XX is your work station ID. E.g.: if your station has ID: 02, set PAN ID to be 00 02. 1 2 External Use 74
BeeKit Wizard RF Channel Update default RF channel to be the one assigned to your work station. E.g.: if the station has ID: 2, set channel to 12. 1 2 External Use 75
BeeKit Wizard OTA Upgrade Leave OTA Upgrade default settings. Click Finish to complete wizard. External Use 76
Adding a Second Project for Smart Energy In the BeeKit Solution Explorer, right-click on top level solution and choose Add Project External Use 77
Create New Project: SE Metering Device 1. Select ZigBee Smart Energy Applications Project Type 2. Select SE Metering Device Template 3. Click OK 1 2 3 External Use 78
BeeKit Wizard Configuration Overview Review default configuration and click Next External Use 79
BeeKit Wizard Target Board Leave board settings to TWR-KW24D512 and click Next External Use 80
BeeKit Wizard Platform Modules Uncheck NVM module for application to revert to factory defaults on reset. 1 2 External Use 81
BeeKit Wizard Device Type Leave default settings for device type. Meter will be an end device. External Use 82
BeeKit Wizard Low Power Mode Leave default settings for Low Power Mode. External Use 83
BeeKit Wizard Concentrator Leave default settings for Concentrator Mode. External Use 84
BeeKit Wizard Security Settings Leave default settings for security settings, including ECC. External Use 85
BeeKit Wizard Security Keys Leave default settings for Network Security Keys. External Use 86
BeeKit Wizard Addresses Update PAN ID to be set to format 50 XX, where XX is your work station ID. E.g.: if your station has ID: 02, set PAN ID to be 50 02. 1 2 External Use 87
BeeKit Wizard RF Channel Update default RF channel to be the one assigned to your work station. E.g.: if the station has ID: 2, set channel to 12. 1 2 External Use 88
BeeKit Wizard OTA Upgrade Leave OTA Upgrade default settings. Click Finish to complete wizard. External Use 89
Export Projects Choose Solution Export and Open Solution in CodeWarrior / IAR Embedded Workbench External Use 90
Export Projects to IAR EWARM Ensure IDE is set to IAR Embedded Workbench, click OK and wait for projects to be exported and launched in IAR EWARM. 1 2 External Use 91
IAR EWARM Workspace IAR EWARM workspace launches with the 2 end node projects. External Use 92
IAR EWARM Workspace Right click on each of the 2 projects (Ha DimmableLight and Se MeteringDevice) in EWARM workspace and choose Make to build the applications firmware. 1 2 External Use 93
TWR-KW2x Dimmable Light Board Setup Plug in the 2nd of the 3 TWR-KW2x board to the PC using the mini-usb port Check that switch SW5 next to the mini-usb port is set to the position towards the exterior of the board this allows the board to be powered via mini-usb If needed, wait for device to be detected by Windows and drivers to be installed. External Use 94
Download Firmware Using IAR EWARM Ensure Ha DimmableLight is highlighted (in bold) in workspace External Use 95
Download Firmware Using IAR EWARM Choose Project Download Download active application 1 4 2 3 External Use 96
Download Firmware Using IAR EWARM 1. Push the SW6 Reset on the TWR-KW2x board 2. LED D5 will blink 2 1 External Use 97
Disconnect the HA Dimmable Light Board Disconnect the board before proceeding with deploying the other application. We will reconnect it once we are ready to start the wireless network formation External Use 98
TWR-KW2x SE Metering Device Board Setup Plug in the 3rd of the 3 TWR-KW2x board to the PC using the mini-usb port Check that switch SW5 next to the mini-usb port is set to the position towards the exterior of the board this allows the board to be powered via mini-usb If needed, wait for device to be detected by Windows and drivers to be installed. External Use 99
Set SE Metering Device to Active Right-click Se MeteringDevice entry and select Set as Active External Use 100
Download Firmware Using IAR EWARM Choose Project Download Download active application 1 4 2 3 External Use 101
Download Firmware Using IAR EWARM 1. Push the SW6 Reset on the TWR-KW2x board 2. LED D5 will blink 2 1 External Use 102
Disconnect the SE Metering Device Board Disconnect the board before proceeding. We will reconnect it once we are ready to start the wireless network formation. External Use 103
STEP 3: Create ZHA and Smart Energy Networks External Use 104
Reconnect TWR-KW2x DualPAN Hub Board Reconnect the first board (programmed with Hub firmware) to the PC. External Use 105
Start Device Manager In Windows, enter Device Manager in Start menu search box, then select the Device Manager entry once found in search results. 2 1 External Use 106
Determine Hub Device COM Port In Device Manger, determine hub device COM Port by determining the Port number assigned to OpenSDA CDC device. External Use 107
Setup Connection in Terminal Application Setup a Connection in Putty or Tera Term to previously determined port on baud rate 115200bps. 2 3 1 External Use 108
Verify Shell Functionality Press SW6 Reset switch on TWR-KW2x hub to show shell banner in terminal application TWR-KW2x DualPAN Hub ZHA + ZSE. Build: Mar 24 2014 Copyright (c) 2014 Freescale Semiconductor $ _ External Use 109
Start ZigBee HA Combined Interface on 1 st PAN (zigbee0) $zigbee0 start ZigBee Pro with ZHA ZCL BeeStack v5.0.0.008 on PAN0 zigbee0 node ZC zigbee0 channel 12 zigbee0 panid 0xE253 zigbee0 nwkaddr 0x0000 zigbee0 extpanid 0x0050C215857039A2 Check initial 2.4 GHz RF channel assigned to station (11-26) Check initial PAN ID assigned to station. HA Coordinator will always have Network Address 0x0000 Extended PAN ID is randomly generated External Use 110
Joining HA Dimmable Light Node On Light Node: press SW3 to join Light is joined to hub when LED D5 becomes solid blue and a transport key security indication is shown in shell interface zigbee0 rx: transport key panid 0x0002 addr 0xE431 Combined interface provisions security key as a trust center to the Light NWK address of Light Device Is random External Use 111
STEP 4: Control and Monitor ZHA and SE End Nodes External Use 112
Discovering End Point and Setting Default Address Info $ zcl0 find levelctrl server zcl0: find levelctrl server... Discover Address and Endpoints for a ZHA device that can be level controlled in the ZigBee Network zcl0 rx: find levelctrl server match: addr 0xE431 endpoint 0x08 $ zcl set addrinfo dstaddr 0xE431 dstep 0x08 zcl0: setaddrinfo...success Discovered Light Information Use info above. Note: destaddr value will be different in practice!! External Use 113
Controlling HA Dimmable Light Application On Light: Press and HOLD SW4 for app mode All blue LEDs will be initially off in app mode $ zcl0 send level move up zcl0 rx: Data confirm status success $ zcl0 send level move down zcl0 rx: Data confirm status success Note how LEDs D6, D7, D8 turn on and back off to emulate a light dimming up and down NWK address of Light Device Is random External Use 114
Starting SE Energy Service Interface Hub on 2 nd PAN (zigbee1) $ zigbee1 start ZigBee Pro with SEP ZCL BeeStack v5.0.0.008 on PAN1 zigbee1 node ZC zigbee1 channel 12 zigbee1 panid 0x5002 zigbee1 nwkaddr 0x0000 zigbee1 extpanid 0x0050C2C5D3A49B73 Check initial 2.4 GHz RF channel assigned to station (11-26) Check initial PAN ID assigned to station. Coordinator will always have Network Address 0x0000 Extended PAN ID is randomly generated External Use 115
Joining SE Metering Device Node On SE Metering Device Node: press SW3 to join The node is joined to hub when LED D5 becomes solid blue and a transport key security indication is shown in shell interface zigbee1 rx: transport key panid 0x5002 addr 0x96C3 External Use 116
Retrieving SE Metering Data After joining, the metering device will periodically transmit meter data The DualPAN hub will display the data in the shell zcl1 rx: srcaddr 0x96C3 srcep 0x08 dstep 0x08 seq 0x07 channel 12 zcl1 rx seq 0x07: report attr metering 0x0000 "Current summation dlvrd" value 0x0000000016BE The current meter reading External Use 117
Changing Operating Frequency for ZigBee HA / SE $ zigbee0 set channel 13 zigbee0 set channel 12 success $ zigbee1 set channel 14 zigbee1 set channel 14 success Pick a value between 11 and 26 different than the pre-assigned channel. Both ZHA and SE networks will shift to use another 2.4GHz RF frequency channel. $ zcl0 send onoff toggle zcl0 rx: Data confirm status success ZHA commands are now sent on different channel. $ zcl0 send onoff toggle zcl0 rx: Data confirm status success External Use 118
Agenda IoT overview Multiple-protocol networks Use cases Solutions Dual-PAN Freescale Kinetis W series MCUs Hands-On training Dual-PAN example 1: ZigBee HA + ZigBee SE Dual-PAN example 2: ZigBee HA + IP stack Summary External Use 119
STEP 5: Program 6LoWPAN Firmware to TWR-KW2x External Use 120
Reset the 3 Boards Push the SW6 Reset on each TWR-KW2x board External Use 121
MSD Firmware Loading Exercise Use the MSD procedure to re-flash boards #1 and #3 (currently DualPAN Hub and SE MeteringDevice) using new firmware: Open Firmware DualPAN_ZHA_IPv6 subfolder on your desktop Open the TWRKW2xDxxx mass storage drive root folder for each board. Drag and drop (or copy-paste) DualPAN_Hub_HA_IPv6_StnXX.srec and IPv6_EndNode_StnXX.srec to boards #1 and #3 respectively External Use 122
STEP 6: Restart the ZigBee Network and Create 6LoWPAN Network External Use 123
Verify Shell Functionality Connect hub with new firmware to PC. Press SW6 Reset switch on TWR-KW2x hub to show shell banner in terminal application: TWR-KW2x DualPAN Hub ZHA + 6LoWPAN. Build: Mar 24 2014 Copyright (c) 2014 Freescale Semiconductor $ _ External Use 124
Restarting ZigBee Combined Interface Hub on 1 st PAN $ zigbee start ZigBee Pro with ZHA ZCL BeeStack v5.0.0.008 on PAN0 zigbee0 node ZC zigbee0 channel 12 zigbee0 panid 0x0002 zigbee0 nwkaddr 0x0000 zigbee0 extpanid 0x0050C22F7513C3D3 Check initial 2.4 GHz RF channel assigned to station (11-26) Check initial PAN ID assigned to station. HA Coordinator will always have Network Address 0x0000 Extended PAN ID is randomly generated External Use 125
Rejoining HA Dimmable Light Node On Light Node: press SW3 to re-join Light is joined to hub when LED D5 becomes solid blue and a transport key security indication is shown in shell interface zigbee0 rx: transport key panid 0x0002 addr 0xE431 Combined interface provisions security key as a trust center to the Light NWK address of Light Device Is random External Use 126
STEP 7: Control and Monitor ZHA and 6LoWPAN Nodes External Use 127
Discovering End Point and Setting Default Address Info $ zcl find levelctrl server zcl0: find levelctrl server... Discover Address and Endpoints for a ZHA device that can be level controlled in the ZigBee Network zcl0 rx: find levelctrl server match: addr 0xE431 endpoint 0x08 $ zcl set addrinfo dstaddr 0xE431 dstep 0x08 zcl0: setaddrinfo...success Discovered Light Information Use info above. Note: dstaddr value will be different in practice!! External Use 128
Controlling HA Dimmable Light Application Level Control On Light: Press and HOLD SW4 for app mode All blue LEDs will be initially OFF in app mode $ zcl send level move up zcl0 rx: Data confirm status success $ zcl send level move down zcl0 rx: Data confirm status success Note how LEDs D6, D7, D8 turn on and back off to emulate a light dimming up and down NWK address of Light Device Is random External Use 129
Sending Light On/Off Cluster Toggle Commands $ zcl send level move up zcl0 rx: Data confirm status success $ zcl send onoff toggle zigbee0 rx: Data confirm status success Repeat toggle several times. Hint: press Up Key to re-load command from shell history $ zcl send onoff toggle zigbee0 rx: Data confirm status success On Light Node: note LEDs toggling on/off External Use 130
Pinging the 6LoWPAN Node via ICMPv6 on 2 nd PAN Use value assigned to the global IPv6 address of the End node for your Work station. Example uses the value for Station 02 $ ping 2003::d0b8:8372:6354:4536:0002 1000 10 Pinging 2003::d0b8:8372:6354:4536:0002 with 32 bytes of data Reply from 2003::d0b8:8372:6354:4536:0002: bytes=32 time=15ms Reply from 2003::d0b8:8372:6354:4536:0002: bytes=32 time=25ms Reply from 2003::d0b8:8372:6354:4536:0002: bytes=32 time=26ms Reply from 2003::d0b8:8372:6354:4536:0002: bytes=32 time=18ms Reply from 2003::d0b8:8372:6354:4536:0002: bytes=32 time=18ms Reply from 2003::d0b8:8372:6354:4536:0002: bytes=32 time=23ms Reply from 2003::d0b8:8372:6354:4536:0002: bytes=32 time=19ms Reply from 2003::d0b8:8372:6354:4536:0002: bytes=32 time=22ms Reply from 2003::d0b8:8372:6354:4536:0002: bytes=32 time=24ms Reply from 2003::d0b8:8372:6354:4536:0002: bytes=32 time=21ms... External Use 131
Opening and Sending Data on UDP Socket over 6LoWPAN $ socket open udp 2003::d0b8:8372:6354:4536:0002 1234 Opening Socket on Data Concentrator... OK Socket id is: 0 Port $ socket send 0 led2on Command was sent $ socket send 0 led2flash Command was sent Send LED On/Off commands also over IPv6 Link. Note LED D6 on IP End Node Use value assigned to the global IPv6 address of the IP End node for your station. Example uses the value for Station 02 $ socket send 0 led2off Command was sent External Use 132
Polling UDP Socket for Data $ socket poll 0 2500 Keys:0000 Temp:29.64 Leds:1000 Keys:0000 Temp:29.59 Leds:0000 Keys:0000 Temp:29.56 Leds:1000 Keys:0000 Temp:29.56 Leds:0000 Keys:0010 Temp:29.83 Leds:1000 Keys:0010 Temp:30.19 Leds:0000 Keys:0010 Temp:29.83 Leds:1000 Keys:0010 Temp:29.75 Leds:0000 Keys:0010 Temp:29.75 Leds:0000 Temperature is read from KW2x internal sensor. Keys pressed and LED state is also transmitted when polled periodically. <Ctrl-C> <INTERRUPT> External Use 133
Closing the UDP Socket $ socket close 0 Socket 0 was closed External Use 134
Using Ubiqua and Test Tool for Protocol Analysis External Use 135
Adding a Sniffer Device Launch Ubiqua Plug-in Sniffer device such as MC1322x-USB or KW2x-USB Select Device Add Device External Use 136
Adding a Sniffer Device 1. Select Vendor: Freescale 2. Select COM port number in device list. This example uses MC1322x 3. Select Application: Sniffer 4. Click: Add Device 2 1 3 4 External Use 137
Select RF Channel to Monitor In Ubiqua Device Manager: right click sniffer device, choose Channel then select the channel to use 1 2 3 External Use 138
Select Protocol to Decode In Ubiqua Device Manager: right click sniffer device, choose Protocol Stack then select the protocol to use (e.g.: ZigBee for ZHA and SE, or IETF 6LoWPAN) 1 2 3 3 External Use 139
Starting the Capture In Ubiqua Device Manager: Set the Capture Knob to On Status will change from Idle to Capturing External Use 140
ZHA Capture Example External Use 141
Decoding ZCL Level Control Command: Move Up External Use 142
6LoWPAN Capture Example External Use 143
Test Tool ZigBee Test Client (ZTC) Serial Command Console All ZigBee commands Double click Ha Dimmable Light COM on baudrate 38400 Parameters for Each Command Command and Macro Shortcuts Send Command Serial TX/RX ZTC Message Log External Use 144
Agenda IoT overview Multiple-protocol networks Use cases Solutions Dual-PAN Freescale Kinetis W series MCUs Hands-on training Dual-PAN example 1: ZigBee HA + ZigBee SE Dual-PAN example 2: ZigBee HA + IP stack Summary External Use 145
Summary The IoT challenge of multi-protocols landscape Dual-PAN feature allows a single 802.15.4 radio to participate in two networks simultaneously Dual-PAN is flexible enough to support different application requirements Dual-PAN translates into a cost efficient design while maintaining good performance Kinetis W series Adding Wireless Connectivity to powerful MCUs Low Power oriented Terrific enablement tools and Software support EASE of USE of complex software stacks External Use 146
www.freescale.com 2014 Freescale Semiconductor, Inc. External Use