Home

Smart Energy Sample Application User's Guide

image

Contents

1. 1020000 2 100000100000 naris eset nsns sese eene 37 ii Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 1 Introduction ZigBee Smart Energy ZSE is one of the public application profiles released for the ZigBee 2007 specification It enables utility companies and their customers to directly communicate with thermostats and other smart appliances see www zigbee org for more information The Smart Energy Sample application part of the Z Stack installer for ZigBee 2007 covering ZigBee and ZigBee PRO is the optimal starting point to build your own SE application on top of Texas Instruments Z Stack www ti com z stack 1 1 Scope This document describes how to use the Smart Energy Sample Application and discusses its theory of operation For a more general description of Smart Energy the reader is referred to the Zigbee Smart Energy specification available from www zigbee org The reader should also review the Z Stack Smart Energy Developer s Guide prior to using this document There are seven defined application instances within the IAR project a Energy Service Portal ESP as a Coordinator b Metering Device as a Router and also as an End Device c In Premise Display as an End Device d In Premise Display as an End Device with OTA cluster client support e Programmable Comm
2. DCO constants verification in location 0 10 8 to Ox10FF MSP430F2xx and Autoprogram only Check DCO constants 0 0000 or OxFFFF are invalid 2618 Fet Pro430 sample code file 1000 01 00 00 00 00 4b 12 00 1008 Read Address Range All Memory Information Memory Segments D 0x1800 0x187F 0 1880 Ox18FF Main Memory onl O B 0x1900 0x197F 0x1980 Ox19FF Info Memory only Memor Enable Start Address 0 1100 CO User defined Stop Address 0 45 Write Yerification S Fast Write Verify Check Sum Recommended Standard Write Verify Check Sum Read Verify None About Microcontroller Main Memory Start Addr 0 5 00 Selected Microcontroller Main Memory Stop Addr 0 45 5 430 5438 RAM Size in Bytes 16384 Cancel 03 07 8c 45 de a5 06 dO 7f 1b 82 21 22 b5 a3 1e bO a0 46 29 55 db 00 12 4b 00 00 00 00 01 54 45 53 54 53 45 43 41 01 09 00 08 00 00 00 00 00 00 1038 02 00 fd a7 41 08 42 24 96 2a 4e 7c 54 9a c3 1044 b8 104 02 28 4a 56 3f 02 f2 c8 bd a7 57 f9 61 bb 8c b4 fb 6e 90 ed 42 q 16 Copyright O 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 2618 Fet Pro430 configuration screenshots IP FET Pro430 FET MSP430 Flash Programmer Elprotronic Inc File View Setup Serialization Tools About Help Op
3. Once key establishment is successful use the ZDO_GET_LINK_KEY command to extract the link key established for the device This can be run on any of the pair of devices in order to get the key needed for the packet sniffer as described below Configure the ZDO_GET_LINK_KEY command as shown below The only value that changes is the IEEEAddress of the partner device 11 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 Z00_AUTO_FIND_DESTINATI ZD0_SET_LINK_KEY hi REMOVE Gi UNK 200 Enter the correct partner IEEE address here IECEAddr Uintb4 the IEEE address of the device Active Device COMI NONE In order to decode APS secured packets in Ubiqua one must enter in this key The best way to format this key is to copy and paste it into notepad and just replace with blank space then with blank space If the link key extraction is not successful the string of bytes 16 total will not be displayed Copy and paste the key into Ubiqua Options X ubiqua A protocol RM ZB Columns Keys File Types Command Line Auto Save Addresses List of Security Keys currently available in the application All the information is display in Big Endian De Add Add Key Applicat
4. DK Device Serialization O Verifying Security Fuse OK Erasing memory he done d D O N E run time 0 3 sec z Reading Code done Read SN Code size 0x0063 99 bytes NeWMEde B WRITE SN Model JTAG communication initialization OK Verifying Security Fuse OK Flash programming done 3 Next SN 00000000 DON E runtime 0 3 sec Format vuyv1234 READ COPY v ormat yyyy123 Port USB Automatic Erase Write memory option JTAG 4 wires User Defined WRITE FLASH NEXT F5 15 Copyright O 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 Memory Options Memory Erase Write V erify Address Range Information Memory Segments O Update only Fi D 0x1800 0x187F O All Memory 0x1880 0x18FF including locked segment C B 0x1900 0x197F 0x1980 0x19FF O Main Memory only Main Memory C Enable O Used by Code File Start Address 0 1100 User defined Stop Address 0x455FF Retain Data in Flash Autoprogram and Erase DCO constants Ox10F8 Ox10FF MSP430F2xx only user defined Start Address 01000 max 256 bytes Stop Address 01000
5. Load Control Event Received E ReportEventStatus Load Control Event Started Set Load Control OSAL timer event for 1 minute blink LED 4 Display Load Evt Started on LCD ReportEventStatus Load Control Event Complete 4 Load Control OSAL timer event occured stop blinking LED 4 display Load Evt Complete on LCD Figure 6 Sequence Diagram for a Load Control Device OSAL loadcontrol c functions and tables for task initialization loadcontrol c main application function that has init and event loop function loadcontrol h header file for application module loadcontrol_data c container for declaration of attributes clusters simple descriptor 20 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 The Load Control application makes function calls to the following ZCL SE functions and ZDO API functions loadcontrol_LoadControlEventCB this function is called when the load control device received a load control command ZclISE LoadControl Send ReportEventStatus When a load control command is received the device sends a report event status command back to the ESP Possible values for the event type for this particular sample app could be event received event started and event completed The response structure rsp is made a global variable so that the process event loop can manipulate the eventSt
6. Por Settings COM16 COM16 COM20 COM20 21 COM21 COM22 COM22 8 COM25 ooo Rate Parity Auto Scan Handshake Stop Bits RTS CTS 2 v Scan all Enabled com ports startup and manual sca El Message Parameters AppEndpoint 0 9 ClusterlD 0x800 Dest ddress OxE37B DestEndpoint 0x9 E Message Byte Array MsgLen 4 DestAddress Ulnt16 Destination address of the outgoing message Active Device COM25 0 0000000000000000 NONE Open Z Tool from the Texas Instruments start menu links and select Tools gt Settings to configure the baud rate Port Alias and Handshake protocol as shown above It is crucial that the Port Alias matches what is used in the script Then as shown in the figure below go to the Settings gt Scripts tab to import the scripts Point it to the folder where the scripts are located by clicking on add There are already pre made Z Tool scripts which you can use in the folder Z Tool scripts in ZStack 2 4 0 1 4 0 Tools Z Converter There is one for each type of device coordinator router and end device Coordinator IEEE address ending with 01 Port Alias Router IEEE address ending with 02 Port Alias R End Device IEEE address ending with 03 Port Alias E Of course there is no reason that you couldn t interchangeably use the scripts but using it in this order makes it easier to keep track of configuration of certs 9 Copyri
7. Pricing Send PublishPrice to send out the publish price command to IPD If SW3 is pressed the function zclSE Message Send DisplayMessagec is called to send a display MESSAGE to the IPD device When a PCT or Load Control device joins the network and establishes a link key with the ESP the ESP will discover these devices by using the end device annce to trigger a simple descriptor ZDO request Each simple descriptor response is parsed in the ZDO callback handler esp ProcessZDOMsg and the device ID field is checked to determine whether this response came from the PCT or Load Control Device Depending on the device ID the destination address for the PCT or Load Control Device is then populated This is how the ESP then knows which type of load control event to send to which device SW1 is used to send a PCT event to the PCT and SW2 is used to send an event to the load control device 26 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 4 5 Simple Metering Device The Simple Metering Device will periodically send reports for the CurrentSummationDelivered Simple Metering attribute to the ESP The ESP will display the CurrentSummationDelivered value on the LCD See Figure 5 for a sequence diagram Simple Metering Device Association Request User presses SW1 Association Response 200 STATE CHANGE event to application Initiate Matc
8. S F path to hex file gt to certificate file txt gt The format of the certificate should be as follows IEEE Address 00124b0000000003 Pub Key 0200fde8a7f3d1084224962a4e7c54e69ac3f04da6b8 19 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 Device Implicit Cert 0204ac2c2656f leea4ffSdac4eddal76bfe4fa70d95600 124b0000000003544553545345434101090 001000001091003 Device Private Key 034bc37a7210b7407a51dc11e5aebaf2e1503f6955 Device Public Key 02071802 1c2ce9c58d2ad8352ab9ff452ff1lc3bdadb3 Note The data for the device implicit cert should be on one line i e no carriage return separations should be included The image would then be programmed into the CC2530 using the SmartRF Flash Programmer tool at the same time the lock bits page is programmed with the certificate data in the txt file The screenshot below shows an example C Program Files Texas Instruments SmartRF Flash Programmer gt SmartRFProgConsole S EPU F C Program Files Texas Instruments SmartRF Flash Programmer rangeext hex EKF 2 c Ncert3 txt Texas Instruments SmartRF Flash Programmer v1 8 1 Erasing entire flash 5 Programming osc ccc cic cc ewe wie Se wicca dc wwe 66 re cecie eee see ce Verifying flash Cbytewise check Erase program and verify OK There are also several functions in th
9. another one when it starts it The Start Time field will indicate to Start Now The event duration will last 1 minute While the load control event is in process the Load Control Device will flash its LED When the load control event is finished another ReportEventStatus command will be sent to the ESP to indicate the completion of the load control event See Figure 6 for a sequence diagram 28 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 Load Control Device Association Request Association 200 STATE CHANGE event to application End Device Annce Process End Device Annce Callback Simple Descriptor Request to discover PCT or Load Control Device Process ZDO Simple Simple Descriptor Response Descriptor Response Callback 4 Initiate Match Descriptor Request for Key Establishment Endpoint Match Descriptor Response 5 5 5 loadcontrol_ProcessZDOMsgs function called to process Match Descriptor Response Initiate Key Establishment i Key Establishment Response ZCL KEY ESTABLISH IND event to application Send Load Control Event to Residential ON User presses SW2 OFF Load Duration Aminute loadcontrol_LoadControlEventCB called ReportEventStatus
10. init and event loop function pct h header file for application module pct data c container for declaration of attributes clusters simple descriptor The PCT application makes function calls to the following ZCL SE functions and ZDO API functions pct LoadControlEventCB this function is called when the PCT device received a load control command ZclISE LoadControl Send ReportEventStatus When a load control command is received the device sends a report event status command back to the ESP Possible values for the event type for this particular sample app could be event received event started and event completed The response structure rsp is made a global variable so that the process event loop can manipulate the eventStatus field once the PCT event is complete pct HandleKeys user switch events are processed here HOLD AUTO START is defined so the device will normally not join the network upon startup The user has to press SW1 which then calls ZDOInitDevice to start the device The rationale for doing this is so that the user can have time to configure the Certicom keys prior to joining the network Once the PCT device joins the network it goes through the state machine explained in Figure 4 pct KeyEstablish ReturnLinkKey is called to check if a link key has already been established with the ESP If one hasn t been established it will send out a match descriptor request in search of the endpoint on the ESP that
11. method to install certificate data into the device One of the methods used to install Certicom certificate data is by using Z Tool a PC tool that can communicate with the device using the Monitor and Test API over a UART port Test scripts are provided to inject test certificates into the device for development purposes only The test certificate data comes in a format that a Z Tool script does not understand and therefore a tool called Z Converter has been provided to take Certicom certificate data as input the actual input requires no carriage returns in order for Z Converter to process the data correctly and then generate arrays that can copied and pasted into a Z Tool script For example a typical test certificate from Certicom looks like the following IEEE Address 00124b0000000001 Pub Key 0200fde8a7f3d1084224962a4e7c54e69ac3f04da6b8 Device Implicit Cert 0204ac2c2656f1eeadff5dacdedda176bfe4fa70d9560012450000000001544553545345434101090001000001091003 Device Private Key 00f035a9f731f265530ad5c1202562d56d1b822543 Device Public Key 0202f71c27abfd28eb39e0b4a718ace4cf374559a6f6 This data must be entered line by line as shown above with no carriage returns into a text file and the user inputs this data using the Load button Z Converter then transforms this data into an array output as follows IEEE Address 0x01 0x00 0x00 0x00 0x00 0x4b 0x12 0x00 Pub Key 0x02 0x00 0xfd 0xe8 0xa7 0xf3 0xd1 0x08 0x42 0x24 0x96 0x2
12. to configure the Certicom keys prior to joining the network Once the IPD device joins the network it goes through the state machine explained in Figure 4 ipd_KeyEstablish_ReturnLinkKey is called to check if a link key has already been established with the ESP If one hasn t been established it will send out a match descriptor request in search of the endpoint on the ESP that has the key establishment cluster Upon processing the match descriptor response in the ipd_ProcessZDOMsgs function the osal event IPD KEY ESTABLISHMENT REQUEST EVT is set The event handler for this in the process event loop will then zclGeneral_KeyEstablish_InitiateKeyEstablishment to do the CBKE procedure Upon its success the application will receive ZCL_KEY_ESTABLISH_IND system message An osal timer event called IPD_GET_PRICING_INFO_EVT is then started to send the get pricing info request every 5 seconds The result of the pricing request is received via ipd_PublishPriceCB and is displayed on the LCD Only the provider ID field of the published price payload is displayed 4 9 In Premise Display OTA The In Premise Display OTA configuration provides the same functionality as the In Premise Display configuration except that it provides client support for the OTA upgrade cluster This sample app configuration should be used with the OTA Dongle Coordinator application as described in 6 where more information can be found regarding how to exercise
13. with the sniffer that the end device received the confirm key response Then press SW2 joystick to the right to send a PCT event to the PCT device The PCT device will flash its LED and display PCT Evt Started When it completes the PCT event which is for 1 min then it will stop flashing its LED and display PCT Evt Complete Power up the IPD end device Hit SW1 to let it join the network Wait about 20 seconds for the key establishment procedure to complete Verify with the sniffer that the end device received the confirm key response Then every 5 seconds it will get the pricing info and display the provider id On the coord hit SW3 joystick down to send a display message to the IPD Revd MESSAGE Cmd should be displayed The Get Current Price command can also be sent from the IPD via INTER PAN by press SW2 on the IPD Note NV RESTORE is not turned on by default so if you power cycle any of the devices it needs to go through the key establishment procedure again and a different link key would be used NV RESTORE is turned off by default to allow rapid development Also any device joining the ESP wouldn t be able to join more than once since the new link key is used for authenticating the device instead of the default TC link key Power cycle the ESP and then the joining device so that it is able to join using the default TC link key The following shows what happens in the Ubiqua Protocol Analyzer for these application instanc
14. 0 0 0x10FF CO Main Memory only Main Memory C Enable O used by Code File Start Address 0x110 Stop Address 0x456FF Retain Data in Flash Autoprogram and Erase DCO constants in INFO 0 10 8 0x10FF User defined M5P430F2xx only C User defined Start Address 1000 max 256 bytes Stop Address d DCO constants verification in location 0 10 8 to Ox10FF MSP430F2xx and Autoprogram only Check DCO constants 0x0000 or OxFFFF are invalid Read Address Range O All Memory Information Memory Segments D 0x1000 0 103 C 0x1040 0x107F Main Memory onl O debi B 0 1080 Ox10BF 0 10 0 Ox10FF 9 Info Memory only Main Memory Enable Start Address 1100 O User defined Stop Address Write Verification S Fast Write verify Check Sum Recommended 1 O Standard Write verify Check Sum Read verify O None About Microcontroller Main Memory Start Addr 0x3100 Selected Microcontroller Main Memory Stop Ox 1 FFFF MSP430F2618 RAM Size in Bytes 8192 Cancel For the CC2530 the console version of the SmartRF Flash Programmer has been updated since ver 1 8 to provide a command line interface that is able to program the lock bits page with the certificate data The console program accepts a hex file along with the certificate data in txt format The hex image can be created using the linker output tab and by un co
15. 00000 NOW in order to make sure that it is not just blindly responding to a random load control event Furthermore it checks the deviceGroupClass to determine whether this load control event was for the PCT or load control device The values within this load control command originate from the ESP The correct string on the LCD is then displayed to indicate whether this is a load control device event or PCT event It is assumed that the load control device belongs to the residential on off load device class and that the PCT belongs to the HVAC compressor furnace device class An osal timer event called LOADCONTROL LOAD CTRL EVT is then started to commence the load control event and flash the LED for the duration specified which is 1 minute When this timer event expires the status response of event completed is sent back to the ESP and the LED stops flashing The user also sees a display on the LCD indicating that the load control event is complete 30 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 4 7 PCT The PCT will have a very similar behavior to the Load Control Device However in the Load Control Event payload the Device Class Field BitMap will indicate that Bit 0 is set HVAC compressor or furnace The Load Control Event for the PCT will be regarded as a PCT Event and the message PCT Event Started will be displayed if the device has
16. 3 for MSP430 builds and drop it into C Texas Instruments VZStack 2 4 0 1 4 0 Projects zstack Libraries lt Target gt bin e g Target CC2530DB The NWK INDIRECT MSG TIMEOUT parameter in the f8wConfig cfg file must be increased to a suggested value of 10 in order to buffer the message long enough to accommodate the 8 second poll period by the end device The MAX POLL FAILURE RETRIES parameter should also be set to 4 as during the CBKE procedure the ESP will be somewhat unresponsive to data requests during this time To gain access to the link key that is established via CBKE using Z Tool the compile options MT ZDO FUNC and MT SYS KEY MANAGEMENT must be defined For production it is not recommended to turn on the MT SYS KEY MANAGEMENT compile option so that the established link key cannot be read via the serial port Select Project gt Rebuild Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 5 Highlight the configuration desired and go to Project gt Options and select the Erase flash option as shown for the CC2530 project Options for node SampleApp Category Factory Settings General Options C C Compiler Assembler Custom Build Download Build Actions Linker Erase m Flash Lack Protection Debugger Boot block lock Debug interface lock Texas Instruments i Lo
17. 4159 19 20 29 844927 19 20 29 861263 19 20 29 864815 19 25 02 155510 19 25 02 158902 Time Delta 00 00 00 784616 00 00 002200 00 00 00 849672 00 00 003144 00 00 508784 00 00 001048 00 00 493760 00 00 00 000960 00 00 002416 00 00 001248 00 00 128520 00 00 002728 00 00 085064 00 00 4240 00 00 022256 00 00 081952 00 01 576392 00 00 003584 00 00 00 14744 00 00 00 002752 00 00 00 2824 00 60 00 001824 00 00 021408 00 00 003584 00 00 028472 00 00 001832 00 00 021096 60 00 002624 00 00 1344 00 00 001824 00 00 243872 00 00 472856 00 06 678096 00 01 858768 00 00 00 002624 99 60 00 017576 60 00 011456 00 00 00 001824 00 07 649112 00 00 002432 00 00 05 418536 00 06 01 932520 08 08 09 777064 08 08 003 200 00 00 00 004384 08 08 08 611912 00 00 004384 00 00 00 015 184 90 90 00 070632 00 00 00 002528 00 08 08 011664 00 00 00 002528 90 00 00 053 128 100 002496 99 00 00 003552 90 00 00 017304 90 00 00 003392 90 00 03 430416 Channel stack 18 ZigBee 18 ZigBee 18 18 ZigBee 18 18 ZigBee 18 ZigBee 18 ZigBee 18 18 ZigBee 18 18 ZigBee 18 ZigBee 18 ZigBee 1
18. 49 5 INSTRUMENTS Smart Energy Sample Application User s Guide Documen t Number SWRU215 as Instru 2 n Die ego Califor aUSA Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 Revision Description Date _ 1 1 Updated for Z Stack 2 3 release Document modifications include 12 23 2009 INTER PAN support for ESP and IPD use of End Device Annce message to trigger device discovery instead of Match Descriptor Request Updated for Z stack 2 3 1 release Document modifications include 07 29 2010 support for installing Certicom keys in the CC2530 lock bits flash page and MSP430 information memory segments The APP_MSG command is no longer used to retrieve the established link key Instead ZDO_GET_LINK_KEY is used discover the key establishment endpoint instead of assuming a fixed endpoint number 1 3 Added In Premise Display End Device OTA configuration 11 16 2010 which provides a sample client application Changed router and end device startup behavior to initiate a match descriptor request to 1 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 Table of Contents 1 INTRODUCTION coo een nea o n o o na no ao GG ne no na oe aene ub o ne na ni So nno ao o neo no a ae na ao o aa na a nana io 1 1 1 SCOPE atv UE D
19. 8 ZigBee 18 ZigBee 18 ZigBee 18 ZigBee 18 ZigBee 18 ZigBee 18 ZigBee 18 ZigBee 18 18 ZigBee 18 ZigBee 18 ZigBee 18 18 ZigBee 18 ZigBee 18 ZigBee 18 18 ZigBee 18 ZigBee 18 18 ZigBee 18 ZigBee 18 18 ZigBee 18 18 ZigBee 18 ZigBee 18 ZigBee 18 Zigsee 18 ZigBee 18 18 ZigBee 18 18 ZigBee 18 ZigBee 18 ZigBee 18 18 ZigBee 18 ZigBee 18 18 ZigBee 18 ZigBee 18 ZigBee 18 18 ZigBee 18 ZigBee 18 ZigBee Packet Information MAC Beacon Request Beacon 716 Beacon Request Beacon 716 Association Request OXF FFF Acknowledgment Data Request Acknowledgment MAC Association Response Acknowledgment APS Command Key transport key Transport Key Acknowledgment Device_annce Device_annce Simple Desc req Acknowledgment SE Key Establishment Acknowledgment ZDP Simple Desc rsp Acknowledgment APS Acknowledgment Acknowledgment SE Key Establishment Acknowledgment APS Acknowledgment Acknowledgment SE Key Establishment Acknowledgment APS Acknowledgment Acknowledgment ZDP Device annce ZDP Device annce SE Key Establishment Acknowledgment Link status Link Status APS Acknowledgment Acknowledgment SE Key Establishment Acknowledgment Link status Link status SE Demand Response
20. 96 0x2a 0x4e 0x7c 0x54 0xe6 0x9a 0xc3 0xf0 0x4d 0xa6 0xb8 The mapping of the labels from the Certicom certificate to the Z Tool script is IEEE gt var ieee Device Implicit Cert gt var data 0x69 Device Private Key gt var data CA Pub Key gt var data0x6b Figure 2 provides a screenshot of the Z Converter graphical interface The user can also save the output into a text file for later use using the Save As button 7 7 Converter Texas Instruments Conversion Tool BAR 9 49 5 INSTRUMENTS Help Exit Figure 2 Z Converter Graphical Interface Z Tool is used to program the Certicom Certificate information into Z stack Non Volatile memory serial cable is required to allow Z Tool to communicate with the stack via the DB 9 4 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 connector on the SmartRFOSEB board The MSP5438 Experimenter s board uses the mini USB connector with the supported virtual COM port driver available from the TI website 2 3 Supported Hardware Platforms a SmartRFOSEB BB boards with CC2530EM b SmartRFOSEB boards with CCMSP2618 CC2520EM c MSP5438 Experimenter boards with CC2520EM 3 Getting Started 3 1 Building the ESP PCT and IPD Application Instances The Smart Energy sample application project is located in C Texas Instruments ZStack 2 4 0 1 4 0 Projects zstack SE S
21. ART OF THE Z STACK INSTALLER eene nennen 39 6 2 OTHER DOCUMENTS 0 0000000 01010100000000000000000 39 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 Table of Figures FIGURE 1 SYSTEM CONTEXT DIAGRAM sssssscsccccssssssncccececeessnseaecececsesesaaesecececeensnauaecececeensaauaesecsesensasaeesecsesensnnnaeeeeecs 2 FIGURE 2 Z CONVERTER GRAPHICAL INTERFACE 1 22 2 2000 0 001101000000000000000000000000000000000 4 FIGURE 3 MEMORY MAP OF LOCK BITS PAGE ccccssssessscecececeeseseeecececeesesececececeeseuaaecececeesessaaeseecesesesnsaeceeececeensaeaeeess 13 FIGURE 4 FLOWCHART OF DEVICE STARTUP LOGIC 12 2 00 01000000000000000000000000000000000000000 24 FIGURE 5 SEQUENCE DIAGRAM FOR A SIMPLE METER 27 FIGURE 6 SEQUENCE DIAGRAM FOR A LOAD CONTROL DEVICE 2 1 29 FIGURE 7 SEQUENCE DIAGRAM FOR A 31 FIGURE 8 SEQUENCE DIAGRAM FOR AN IN PREMISE 33 FIGURE 9 SEQUENCE DIAGRAM FOR AN IN PREMISE DISPLAY WITH OTA CLUSTER CLIENT SUPPORT 0 35 FIGURE 10 SEQUENCE DIAGRAM FOR A RANGE
22. Acknowledgment and Load Control Data key SE Demand Response and Load Control Acknowledgment SE Demand Response Acknowledgment and Load Control Data key Link Status SE Demand Response Acknowledgment SE Demand Response Acknowledgment and Load Control Data key and Load Control Data key SE Price Data key Acknowledgment MAC Data Request Acknowledgment SE Price Data key Acknowledgment SE Message Data key Acknowledgment Dst Pan Mac Src Addr exFFFF exeeoo exFFFF exeeoo 716 0x6012480000000002 716 0x6012480000000002 716 0x6012480000000001 716 0x0716 x8DE2 716 0x0716 716 x8DE2 0x0716 x8DE2 0x0716 716 0x0716 Ox8DE2 0x0716 x8DE2 0x0716 716 x8DE2 716 2 0x0716 x8DE2 9 716 0x0716 0x0716 x8DE2 716 x8DE2 0x0716 ex8DE2 716 9x0716 716 x8DE2 9 0716 ex8DE2 9x0716 716 4291 xBB4F 4291 exBBAF Mac Dst Addr exFFFF 0x6012480000000002 ex8DE2 xF FFF xF FFF x8DE2 x8DE2 x8DE2 2 xF FFF xF FFF OxF FFF x8DE2 OxF FFF OxF FFF OxF FFF xBDE2 OxF FFF x8DE2 4291 Copyright 2009 2010 Texas I
23. ER LEO IK XC EE E 1 1 2 DEFINITIONS ABBREVIATIONS 5 1 22 2 3 21 vREQUIRED TOOLS 5 5 ote tiere eei 3 2 2 USING Z CONVERTER TO TRANSFORM CERTICOM CERTIFICATES 3 2 3 SUPPORTED HARDWARE PLATFORMS 6 sene es 5 2 GETTING STARTED eo eene eese o se ene Se aa erae o ae Gene eene eee ao se eae Tons eene na se cese ases eee nose eae 5 3 1 BUILDING THE ESP PCT AND IPD APPLICATION INSTANCES eene 5 3 2 CONFIGURING CERTICOM KEYS USING 7 nennen nr nn enne 8 3 3 CONFIGURING CERTICOM KEYS FOR PRODUCTION DEVICES eee 13 3 4 RUNNING THE ESP PCT AND IPD eene enne nnn enne 20 4 THEORY OF OPERATION e e e e e eee e e e eee eee e eee 23 4l SESEGCUREJIOINING ecce eoe eve ewe eee vea 23 4 2 KEY 05 3 23 4 3 DEVICE AND SERVICE 5 1 66 hehe eene ne 25 A MEM IS CM m et lass tients 25 4 5 SI
24. LCD support See Figure 7 for a sequence diagram Programmable Communicating Thermostat PCT Association Request Association Response p ZDO_STATE_CHANGE event to application End Device Annce Process End Device Annce Simple Descriptor Request to discover PCT or Load Control Device Process ZDO Simple Simple Descriptor Response Descriptor Response Callback 4 Initiate Match Descriptor Request for Key Establishment Endpoint 4 Match Descriptor Response pct_ProcessZDOMsgs function called to process Match Descriptor Response Initiate Key Establishment YASS Key Establishment Response ZCL KEY ESTABLISH IND event to application Send Load Control Event to HVAC User presses SW1 Duration minute pct_LoadControlEventCB called ReportEventStatus Load Control Event Received ReportEventStatus Load Control Event Started Set PCT OSAL timer event for 1 minute blink LED 4 Display PCT Evt Started on LCD ReportEventStatus Load Control Event Complete q 22 PCT OSAL timer event occured stop blinking LED 4 display PCT Evt Complete on LCD Figure 7 Sequence Diagram for a PCT 31 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 OSAL_pct c functions and tables for task initialization pct c main application function that has
25. MPLE METERING 2 etes essaie tasa 27 4 6 LOAD CONTROL 2 1 60000000000 ees eene 28 31 45 IN PREMISE DISPEAY ak ck E E 33 4 9 IN PREMISE 0040000 0 0 0 00000000 34 4 10 RANGE EXTENDER C iore eet eH eet 36 5 J ELIMIETATIO NS e eoe sodo Pe eae de se saa esas oa Pepe 38 5 1 TRUST CENTER OPERATION eene eiiis erstes eene testes sene sienta eee 38 5 2 NETWORK MANAGER OPERATION 02000000000 38 5 3 SECURE JOINING 2 2 1 00 000 38 5 4 KEY ESTABLISHMENT 38 5 5 DEVICE STARTUP 002 1 6 38 5 6 LOAD CONTROL DEVICE BEHAVIOR 0 0 39 3o VES BEHAVIOR Lecce ica 39 6 APPLICABLE DOCUMENT cccccccscccssssssssssscscscssssssssssscssssssssssssscssssscssssssssscsssssces 39 6 1 7 5 DOCUMENTS P
26. _CHANGE Event Set POLL_RATE to 8 SECURE 1 seconds Start Application Function Is Router End Device Do Nothing Check Link Key Status Initiate Match Descriptor Match Desc Rsp Request for Key Revd Do Nothing Establishment Endpoint Link Key Exists Initiate Key Set POLL_RATE to 8 Establishment Key Established Do Nothing seconds Start Application Function Start Application Function Figure 4 Flowchart of Device Startup Logic 24 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 4 3 Device and Service Discovery Each device communicates with the ESP Since the ESP is the coordinator and will always have a short address of 0x0000 devices that join the network can assume this and communicate with the ESP directly Therefore no device discovery or service discovery is required for joining devices Once the device joins the network and performs a successful key establishment it starts its communications with the ESP based on the application behavior The following section defines the application behavior for each device after it has successfully joined the network using SE secure join and has an application link key established with the ESP 4 4 ESP The ESP is assumed to be the coordinator trust center and network manager of the network Every other device communicates with the ESP The ESP application instance c
27. a 0x4e 0x7c 0x54 0xe6 0x9a 0xc3 0xf0 0x4d 0xa6 0xb8 Device Implicit Cert 0x02 0x04 0xac 0x2c 0x26 0x56 0xf1 0xee 0xa4 0xff 0x5d 0xac 0x4e 0xdd 0xa1 0x76 0xbf 0xe4 0xfa 0x70 0xd9 0x56 0x00 0x12 0x4b 0x00 0x00 0x00 0x00 0x01 0x54 0x45 0x53 0x54 0x53 0x45 0x43 0x41 0x01 0x09 0x00 0x01 0x00 0x00 0x01 0x09 0x10 0x03 3 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 Device Private Key 0x00 0xf0 0x35 0xa9 0xf7 0x31 0xf2 0x65 0x53 0x0a 0xd5 0xc1 0x20 0x25 0x62 0xd5 0x6d O0x1b 0x82 0x25 0x43 Device Public Key 0x02 0x02 0xf7 0x 1c 0x27 0xab 0xfd 0x28 0xeb 0x39 0xe0 0xb4 0xa7 0x 18 0xac 0xe4 0xcf 0x37 0x45 0x59 0xa6 0xf 6 Note that the Device Public Key is not used as part of the input into the Certicom library but is provided for completeness The user then copies these values into a Z Tool script that uses arrays such as the following var ieee 0x01 0x00 0x00 0x00 0x00 0x4b 0x12 0x00 var data0x69 0x02 0x04 0xac 0x2c 0x26 0x56 0xf1 0xee 0xa4 0xff 0x5d 0xac 0x4e 0xdd 0xa1 0x76 0xbf 0xe4 0xfa 0x70 0xd9 0x56 0x00 0x12 0x4b 0x00 0x00 0x00 0x00 0x01 0x54 0x45 0x53 0x54 0 53 0 45 0 43 0 41 0 01 0 09 0 00 0 01 0 00 0 00 0 01 0 09 0 10 0 031 var data0x6a 0x00 0xf0 0x35 0xa9 0xf7 0x31 0xf2 0x65 0x53 0x0a 0xd5 0xc1 0x20 0x25 0x62 0xd5 0x6d 0 10 0 82 0 25 0 43 var data0x6b 0x02 0x00 0xfd 0xe8 0xa7 0xf3 0xd1 0x08 0x42 0x24 0x
28. ampleA pp lt Target gt e g Target CC2530DB Open the SampleApp eww project file The figures below show how each configuration is organized For each device configuration only the relevant application files are brought in for each device configuration Load Control Device Router Y ESP Coordinator In Premise Display End Device Load Control Device Router PCT End Device Range Extender Router Simple Metering End Device Simple Metering Router 5 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 JAR Embedded Workbench IDE File Edip View Project Tools Window Help D gug OSAL_esp c Jln Premise Display ipd c ipd h ipd_data c OSAL_ipd c ad Control Device loadcontrol c loadcontrol h loadcontrol data c OSAL LoadControl c D DOLI 8 pctc _ Jpcth pct data c Range Extender OSAL RangeExt c rangeext c rangeext h rangeext data c imple Metering JOSAL SimpleMeter c _ simplemeter c _jsimplemeter h _ simplemeter_data c eel el p ETT TT e Build the ESP Coordinator End Device and In Premise Display End Device configurations 1 If the SECURE 1 compile option is used before rebuilding the project take the Certicom library and rename it to ecc r51 for 8051 builds or ecc r4
29. atus field once the load control event is complete loadcontrol HandleKeys user switch events are processed here HOLD AUTO START is defined so the device will normally not join the network upon startup The user has to press SW1 which then calls ZDOInitDevice to start the device The rationale for doing this is so that the user can have time to configure the Certicom keys prior to joining the network Once the Load Control device joins the network it goes through the state machine explained in Figure 4 loadcontrol KeyEstablish ReturnLinkKey is called to check if a link key has already been established with the ESP If one hasn t been established it will send out a match descriptor request in search of the endpoint on the ESP that has the key establishment cluster Upon processing the match descriptor response in the loadcontrol_ProcessZDOMsgs function the osal event LOADCONTROL KEY ESTABLISHMENT REQUEST is set The event handler for this in the process event loop will then call zclGeneral KeyEstablish InitiateKeyEstablishment to do the CBKE procedure Upon its success the application will receive a ZCZL KEY ESTABLISH IND system message Nothing is done at this point and the load control device is ready to accept load control messages from the ESP When a load control command is received the callback loadcontrol_LoadControlEventCB is executed This callback function checks the issuer event id 0x12345678 the start time 0 000
30. ck flash memory Infineon ROM Monitor Verify download Analog Devices CRC 16 Silabs C Read back memory Simulator Retain flash pages p Cancel This allows one to start with a clean slate before programming Certicom certs After the device has been configured unselect this box so you can retain the IEEE address and key information when downloading new code each time For MSP5438 projects select Erase main and information memory as shown below IMPORTANT NOTE For MSP430 users that have ADC calibration info stored in INFOA information memory such as MSP430F2618 users DO NOT select this option unless you are sure that the INFOA information memory segment is locked Otherwise you will erase the ADC calibration info and DCO constants and may have to restore it From the factory the INFO information memory segment is typically locked so unless the user has unlocked this segment there is no danger of overwriting this region of information memory 7 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 Options for node SampleApp Category Factory Settings General Options C C compiler Assembler Custom Build Setup Download Breakpoints Build Actions Linker Verify download Debugger Suppress download Ask when downloading Allow erase write access to locked flash memory Simu
31. e console version that can be used to create a very flexible script First note the x option that will list all available EBs Example C Program Files Texas Instruments SmartRF Flash Programmer gt SmartRFProgConsole exe x Texas Instruments SmartRF Flash Programmer Device SmartRFOSEB 10 2769 fwId 0500 fwRev 0013 Chip CC2530 Device SmartRFOSEB 10 7335 fwId 0500 fwRev 0013 Chip CC2530 One can then write a batch script or similar with the following lines SmartRFProgConsole exe 5 2769 image hex EKF certificate data 1 txt SmartRFProgConsole exe 5 7335 image hex EKF certificate data 2 txt This example assumes that the path of the hex image and the certificate data txt file are the same directory as the SmartRFProgConsole exe 3 4 Running the ESP PCT and IPD Applications After compiling these sample app instances and programming the devices one can start these applications as follows 1 Power the coordinator wait for Zigbee to show up on the LCD display The 2nd line of the LCD will display the PAN ID 20 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 2 Then power the PCT device The LED will flash waiting for you to press SW1 which is joystick UP This will cause the device to join the network Wait about 20 seconds for the key establishment procedure to complete Verify
32. e from ZCL application task is processed such as when the download has commenced or completed Once the IPD device joins the network it goes through the state machine explained in Figure 4 ipd KeyEstablish ReturnLinkKey is called to check if a link key has already been established with the ESP If one hasn t been established it will send out a match descriptor request in search of the endpoint on the ESP that has the key establishment cluster Upon processing the match descriptor response in the ipd_ProcessZDOMsgs function the event IPD KEY ESTABLISHMENT REQUEST EVT is set The event handler for this in the process event loop will then call zclGeneral KeyEstablish InitiateKeyEstablishment to do the CBKE procedure Upon its success the application will receive a KEY ESTABLISH IND system message osal timer event called PRICING INFO EVT is then started to send the get pricing info request every 5 seconds The result of the pricing request is received via ipd PublishPriceCB and is displayed on the LCD Only the provider ID field of the published price payload is displayed 4 10 Range Extender The Range Extender device will not exchange application data with the ESP It will be able to join the SE network perform key establishment and route packets Figure 10 shows a sequence diagram for the Range Extender 36 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sam
33. e info memory are used The INFOA page RESERVED for future Z Stack use 0x1980 0x199c define NV DEVICE PRIVATE KEY ADDR 0x199D define ADDR 0 19 2 define HAL_NV_IMPLICIT_CERTIFICATE_ADDR 0 19 8 define HAL_NV_IEEE ADDR Ox19F8 13 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 For the 2618 the following locations in the info memory are used define HAL_NV_IEEE ADDR 0x 1000 define HAL NV IMPLICIT CERTIFICATE ADDR 0 1008 define NV PUBLIC KEY ADDR 0 1038 define HAL NV DEVICE PRIVATE KEY ADDR Ox104E RESERVED for future Z Stack use 0x1063 0 1009 MSP Calibration Data ADC DCO Ox10DA Ox10FF Populating the Certicom key data in the MSP430 info memory can be done via a 3 party programmer tool like the FET Pro430 from Elprotronic Inc www elprotronic com Consult section 6 1 of the FET Pro430 user manual for more details on how to generate a code file to update the corresponding sections of info memory only The following sections below provide example code files and screenshots of the FET Pro430 setup for the 2618 and 54xx devices IMPORTANT NOTE For best results one should download the program first using IAR ensuring to erash flash then run the FET Pro430 to update the various information memory segments This is because when Z stack first starts up NV items a
34. en Code File 53 261 path C Documents and Settings a01 306 Blow Security Fuse C Enable SN File Power Device from Adapter BLOW FUSE Microcontroller Type Group 430625 MSP430F2618 v Total Selected Device Information RAM 8182 bytes FLASH 116 kB 30V Device Voltage Device Action Reload Code File 1mg ei SE M Verify Security Fuse Source 0 0012201 JTAG communication initialization Verifying Security Fuse Flash programming DONE runtime 0 2 JTAG communication initialization Verifying Security Fuse Reading Flash memory done DONE runtime 13 5 sec Device Serialization 8 BLANK CHECK WRITE FLASH WRITE SN Model Read SN Next Model Group Revision E VERIFY FLASH Next SN Format yyyy1234 READ COPY Port USB Automatic JTAG 4 wires Erase Write memory option User Defined READ COPY COCO OCC NEXT F5 17 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 Memory Options Memory Erase Write Verify Address Range C Update only Information Memory Segments v Ox v D 0x1000 0x103F O All Memory C 0x1040 0x107F including locked segment B 0x1080 Ox10BF A 0 1
35. epeats for multiple blocks until file transfer is complete Upgrade End Request If signature verfication and CRC check passes Upgrade End Response Client bootloader instantiates downloaded image Figure 9 Sequence Diagram for an In Premise Display with OTA cluster client support OSAL_ipd c functions and tables for task initialization 35 Copyright O 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 ipd c main application function that has init and event loop function ipd h header file for application module ipd_data c container for declaration of attributes clusters simple descriptor The IPD application makes function calls to the following ZCL SE functions and ZDO API functions zclSE_Pricing Send GetCurrentPrice this function sends the get current price request to the ESP ipd_PublishPriceCB this function is called when the IPD device receives the publish price command from the ESP and displays the provider ID on the LCD ipd_HandleKeys user switch events are processed here HOLD_AUTO_START is defined so the device will normally not join the network upon startup The user has to press SW1 which then calls ZDOInitDevice to start the device The rationale for doing this is so that the user can have time to configure the Certicom keys prior to joining the network ipd_ProcessOTAMsgs this function is called whenever a callback messag
36. ery 5 seconds or send via INTER PAN using SW2 SW 2 can be used to send ipd GetCurrentPriceCB ANTER PAN version of Get called Current Price Send Publish Price ipd PublishPriceCB called to display Provider ID on LCD Send Display Message User presses SW3 ipd DisplayMessageCB called to display Rcvd MESSAGE Cmd on LCD Figure 8 Sequence Diagram for an In Premise Display OSAL_ipd c functions and tables for task initialization ipd c main application function that has init and event loop function ipd h header file for application module ipd_data c container for declaration of attributes clusters simple descriptor The IPD application makes function calls to the following ZCL SE functions and ZDO API functions 33 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 zclSE_Pricing Send GetCurrentPrice this function sends the get current price request to the ESP ipd_PublishPriceCB this function is called when the IPD device receives the publish price command from the ESP and displays the provider ID on the LCD ipd_HandleKeys user switch events are processed here HOLD AUTO START is defined so the device will normally not join the network upon startup The user has to press SW1 which then calls ZDOInitDevice to start the device The rationale for doing this is so that the user can have time
37. es 21 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 114 115 124 8 126 127 A 128 130 131 8 132 133 134 135 0 136 137 4138 139 Ame 141 42 Qua A 145 6 A w7 9167 1169 22 Length 28 28 21 27 73 57 57 49 109 74 45 100 45 7e 45 57 57 7e Timestamp 18 35 59 992902 18 35 59 995102 18 36 00 844774 18 36 00 847918 18 36 01 356702 18 36 01 357750 18 36 01 851510 18 36 01 852470 18 36 01 854886 18 36 01 856134 18 36 01 984654 18 36 01 987382 18 36 02 072446 18 36 02 106686 18 36 02 128942 18 36 02 130894 18 36 03 707 286 18 36 03 710870 18 36 03 725614 18 36 03 728366 18 36 03 761190 18 36 03 763014 18 36 03 784 422 18 36 03 788006 18 36 03 816478 18 36 03 818310 18 36 03 839406 18 36 03 842030 18 36 03 873374 18 36 03 875198 18 36 04 119070 18 36 04 591926 18 36 11 270022 18 36 13 128798 18 36 13 131414 18 36 13 148990 18 36 13 160446 18 36 13 162270 18 36 20 811382 18 36 20 813814 18 36 26 303862 18 36 28 236382 18 36 38 013446 18 36 38 016646 18 36 41 447062 18 36 41 451446 18 36 41 463358 18 36 41 467742 18 36 41 482926 18 36 41 553558 18 36 41 556086 18 36 41 567750 18 36 41 570278 19 20 29 737767 19 20 29 740263 19 20 29 84
38. ght 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 Settings Scripts Serial Socket Devices Add Remove Script Folders C Documents and Settingssa 190613 Desktop C Documents and Settingsa01 9061 3 Desktop Smart Energy Testing Gui C Documents and Settings a01 9061 3 Desktop temp lt amp Script Editor notepad exe Then go to Tools gt Script Control and execute the script called writeC all Keys zjs by highlighting it and clicking on the RUN button 10 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 a Z Tool 2 0 File View Tools Window Help File Control gt Run Abort X Clear Z Sciipts SCRIPT STARTED witeC all Keys zis 7 5 09 CADocuments and Settings a0190613 Desk 5 5 OSAL NV WRITE to SB wileC al Keys zi lt TX gt 7 09 38 223 C SYS OSAL NV WRITE 02109 writeE all Keys zis 19 0 0069 writeR all Keys zis Offset 0x00 ELM JU K TESTSECA 0503 0x07 Ox8C 0545 0 5 US UU Uxol Ux45 USDE d x 3 0x06 OxD0 0x82 0x21 0822 OBS 0xA3 DTE 0980 0 0 0828 _ 8 Documents and Setti
39. h Descriptor Request for Key Establishment Endpoint Match Descriptor Response simplemeter_ProcessZDOMsgs function called to process Match Descriptor Resposne Initiate Key Establishment Key Establishment Response ZCL_KEY_ESTABLISH_IND event to application esp ProcessInReportCmd Report Simple Metering Attribute called to display attribute on every 5 seconds LCD Figure 5 Sequence Diagram for a Simple Meter Device The Simple Meter application instance consists of the following modules OSAL_simplemeter c functions and tables for task initialization simplemeter c main application function that has init and event loop function simplemeter h header file for application module simplemeter_data c container for declaration of attributes clusters simple descriptor The Simple Meter application makes the following function calls zcl SendReportCmd this function sends the CurrentSummationDelivered report attribute to the ESP 27 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 simplemeter_HandleKeys user switch events are processed here HOLD_AUTO_START is defined so the device will normally not join the network upon startup The user has to press SW1 which then calls ZDOInitDevice to start the device The rationale for doing this is so that the user can have time to configure the Certicom ke
40. has the key establishment cluster Upon processing the match descriptor response in the pct ProcessZDOMssgs function the event PCT KEY ESTABLISHMENT REQUEST is set The event handler for this in the process event loop will then call zclGeneral_KeyEstablish_InitiateKeyEstablishment to do the CBKE procedure Upon its success the application will receive a KEY ESTABLISH IND system message Nothing is done at this point and the PCT device is ready to accept load control messages from the ESP When a load control command is received the callback pct LoadControlEventCB is executed This callback function checks the issuer event id 0x12345678 the start time 0 00000000 NOW in order to make sure that it is not just blindly responding to a random load control event Furthermore it checks the deviceGroupClass to determine whether this load control event was for the PCT or load control device The values within this load control command originate from the ESP The correct string on the LCD is then displayed to indicate whether this is a load control device event or PCT event It is assumed that the load control device belongs to the residential on off load device class and that the PCT belongs to the HVAC compressor furnace device class An timer event called PCT LOAD is then started to commence the load control event and flash the LED for the duration specified which is 1 minute When this timer event exp
41. in rejoin mechanism as implemented in ZDApp c The Smart Energy Profile spec says that end devices should not be more than 7 5 seconds This sample application therefore supports a nominal poll rate of 8 seconds The NWK INDIRECT MSG TIMEOUT parameter in the f8wConfig cfg file must be increased to a suggested value of 10 in order to buffer the message long enough to accommodate the 8 second poll period by the end device The MAX POLL FAILURE RETRIES parameter should also be set to 4 as during the CBKE procedure the ESP will be somewhat unresponsive to data requests during this time 38 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 5 6 Load Control Device Behavior There is no example of how to cancel a load control event from the ESP or how to supersede an ongoing load control event 5 7 ESP Behavior The ESP service discovery implementation is limited to supporting up to two load control devices at any given time but could be easily modified to support more 6 Applicable Documents 6 1 Z Stack Documents part of the Z Stack installer OSAL API Texas Instruments Document SWRA194 Z Stack API Texas Instruments Document 5 195 Z Stack ZCL API Texas Instruments Document SWRA197 Z Stack Monitor and Test API Texas Instruments Document SWRA198 Z Stack Smart Energy Developer s Guide Texas Instruments Document SWRA216 Z Stack OTA Upgrade Use
42. ion or Trust Center Link v Pan ID Sequence Number Device 1 Device 2 58 D3 7F 1D 72 96 E5 4E C9 9D 1F 09 96 CB FC 28 M E m gt 12 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 3 3 Configuring Certicom Keys for Production Devices Section 3 2 discussed a method for configuring Certicom keys This works well for the development phase but for production a different solution is often desired to help streamline the manufacturing process For this reason and also for enhanced security Z stack provides an option to store the Certicom keys in the lock bits page of the CC2530 and information memory of the MSP430 This is also the recommended option as each family of chips has a locking mechanism to prevent direct access of code space from their respective debug ports such as JTAG On the 2530 the last available page of flash is used Figure 3 shows the memory map of the lock bits page Byte 2048 Lock Bit Bytes 16 bytes Secondary IEEE 8 bytes Device Private Key 21 bytes 1 byte padding to NV word size CA Public Key 22 bytes Implicit Cert 48 bytes CC2530 flash 7 127 Lock bits page Reserved for future Z stack use Pages 1 126 1932 bytes Byte 0 Page 0 Figure 3 Memory map of lock bits page On the 54xx the following locations in th
43. ires the status response of event completed is sent back to the ESP and the LED stops flashing The user also sees a display on the LCD indicating that the PCT event is complete Note The mechanics of the PCT and Load Control Device are the same There are just slight differences in variable names and the type of message displayed on the LCD 32 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 4 8 In Premise Display The In Premise Display will use the Get Current Price command to obtain the current pricing info from the ESP The user can press SW2 to send an INTER PAN version of the Get Current Price command to the ESP The pricing information will be displayed on its LCD The ESP will be able to use the SW3 button press to send a display MESSAGE command to the In Premise Display This message will then be displayed on the LCD See Figure 8 for a sequence diagram In Premise Display Association Request 4 Association Response ZDO_STATE_CHANGE event to application Initiate Match Descriptor Request for Key Establishment Endpoint Match Descriptor Response ipd ProcessZDOMsgs function called to process Match Descriptor Response Initiate Key Establishment tt Key Establishment Response T gt ZCL KEY ESTABLISH IND event to application Get Pricing Info ev
44. lator Allow erase write access to BSL flash memory m Flash erase C Erase main memory Erase main and Information memory C Retain unchanged memory DK Cancel 6 Download the program by clicking the debug icon or by going to Project gt Debug Hit the Run button and watch the coordinator start up or if it s a device it will blink its LED waiting for you to press SW1 to join an existing network 3 2 Configuring Certicom Keys Using Z Tool In order to configure the IEEE address and Certicom keys for each device use the provided Z Tools scripts and Z Tool as shown in the following screen captures 8 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 m a Z Tool 2 0 File View Tools Window Help 9 25 p O System 25 LogEnabled gt lt Clear Save 4a SYS_VERSION MsgLen 0x04 4a SYS OSAL NV READ Message 0x02 0x11 0x00 0x04 42 OSAL NV WRITE 4a SYS OSAL START TIMER OSAL STOP TIMER Scripts Serial Devices Socket Devices O Serial Devices SYS_RANDOM Scripts Socket Devices Settings SYS_ADC_READ Modify Serial Devices se pp Port Name Device Alias COM25 Information COMI3 COMI3 4 APP USER TEST 14 COMI4
45. ll rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 5 Limitations 5 1 Trust Center Operation e The trust center does not demonstrate how to refresh network keys e The trust center does not demonstrate how to manage an access control list e The trust center assumes that joining devices have the same pre configured trust center link key It is assumed that the trust center link key is already available Out of band means of deriving the trust center link key is out of the scope of this sample application 5 2 Network Manager Operation e The ESP is the only device that has the Network Manager functionality e The ESP application instance should be compiled with the NWK_MANAGER compile option in order to enable Network Manager functionality hooks e The default network manager application ZDNwkMgr c is provided as is and there is no application level functionality incorporated to demonstrate this Network Manager application 5 3 Secure Joining Operation All devices must have the pre configured Trust Center Link Key defined at compile time or entered via Z Tool 5 4 Key Establishment Operation SE Key Establishment is always initiated by the joining device and its partner will always be the ESP 5 5 Device Startup Behavior The Smart Energy Profile spec mentions application best practices of controlling join rejoin duty cycles This sample app does not make any attempt at changing the jo
46. mmenting the lines in the f8w2530 xcl file as shown in the following screenshots 18 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 Options for node SampleAppSrc Category Factory Settings General Options C C Compiler Assembler Custom Build Output Extra Output ttdefine Diagnostics List Config Proce 2 Build Actions m Output file pee Override default Secondary output file SimpleM eter hex None for the selected format Infineon ROM Monitor Debug information for C SPY Analog Devices Silabs with 1 0 emulatior Simulator eb I Is Allow C SPY specitic extra output file Other Output format intel extended Format variant None 7 Module local symbols Include all 205 206 D 0 78000 207 D_BANK _END 0x7FFFF 208 209 210 Include these two lines when generating a hex file for banked code model 211 CODEBANK START4 FIRST BANK ADDR CODEBANK FIRST BANK ADDR 212 NR 5 FIRST BANK ADDR 0x8000 213 214 715 rade that will he rim from hw aettinr nf mist hawe the aan At the command line prompt the following syntax should be used SmartRFProgConsole
47. nge app data Extender with the ESP Figure 1 System Context Diagram Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 2 Setup 2 1 Required Tools The tools that will be needed to evaluate this sample app and build your own application based on it are the following IAR Embedded Workbench EW8051 7 60 CC2530 EW430 5 10 6 MSP430 b SmartRF Flash Programmer Tool includes USB drivers for the SmartRFOSEB board c Ubiqua Protocol Analyzer from Ubilogix www ubilogix com or other type of network analyzer that can support Smart Energy profile decodes d 7 1 2 0 provided as part of the Z Stack install e Z Converter A tool used to transform Certicom certificates data into arrays that can easily be imported into a Z Tool script Provided as part of the Z Stack install f Certicom ECC library if using security Fill out their SDK license registration form at this URL http www certicom com index php component chronocontact chronoformname certicom zigbee sdk registrati on form Alternatively you may contact TI directly to obtain a special installer that has the Certicom ECC library included 2 2 Using Z Converter to Transform Certicom Certificates In order to build a ZigBee Smart Energy certified device one must support Certificate Based Key Establishment CBKE CBKE requires the use of an ECC library from Certicom and a
48. ngs 0855 OxDB 0x00 0x12 Ox4B 0x00 0x00 0x00 0x00 0x01 0x54 0x45 0x53 0x54 9 O C Documents and Settingssa01S90613 0 053 045 0x43 0x41 0x01 0x09 0x00 0x08 0x00 0x00 0x00 0x00 0x00 0x00 1 C Documents and Settings a0190613 C 515 DSAL NV WRITE to C z 57 09 38 426 C SYS 0SAL NV WRITE 092108 Id Ox0064 2 C Documents and Settings a01 9061 3 C E 122 C Documents and 01 906133 42 C NDocuments and Settinas a0190613 Desk V 0x02 0 28 0x44 0x56 Ox3F 0 02 0 2 8 OxBD gi a i xA7 0557 BB 0 8 0 4 OxFB 0x90 ED 0x42 Offset 0x00 Value 0x01 0x00 0x00 0x00 0x00 Ox4B 0x12 0x00 eg El Message Parameters AppEndpoint 0x9 ClusterlD 0x800 DestAddress 0xE37B DestEndpoint 0 9 Message Byte Array MsgLen 4 DestAddress UlInt16 Destination address of the outgoing message Active Device COM25 0x0000000000000000 NONE Repeat this procedure for each device you wish to configure with the IEEE address and certificate data Note For the CC2530 platform if Z Tool is not used to populate the IEEE address and certificate data then the pre defined data in zcl_cert_data c will be used to initialize the corresponding NV items This is the out of box behavior that is enabled via the TC_LINKKEY_JOIN compile option
49. nstruments Inc All rights reserved 0x43 excc xBDE2 x8DE2 Ox8DE2 Ox8DE2 xBDE2 0x8DE2 OxBDE2 x8DE2 80 2 80 2 80 2 exBDE2 exBDE2 x8DE2 4291 Smart Energy Sample Application User s Guide SWRU215 Version 1 3 4 Theory of Operation This section explains how each application instance behaves with respect to the ESP device and also discusses the design of each application instance 4 1 SE Secure Joining The default trust center link key TC link key is used to commission each device Each device uses the SE secure joining process See the Z stack Smart Energy Developer s Guide for more details 4 2 Key Establishment Upon successfully joining the network using security each device will initiate key establishment with the ESP Certificate information required to perform the key establishment is entered in ahead of time using Z Tool Figure 4 shows a flowchart of the device startup logic The ZDO_STATE_CHANGE event is an OSAL system message that is provided to the application to indicate that the device has successfully started or joined the network 23 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 ZDO_STATE
50. onsists of the following modules OSAL esp c functions and tables for task initialization esp c main application function that has init and event loop function esp h header file for application module esp_data c container for declaration of attributes clusters simple descriptor The ESP application makes function calls to the following ZCL SE functions and ZDO API functions esp_GetCurrentPriceCB callback executed when get current price message is received ZclSE Pricing Send PublishPrice send publish price command to IPD esp ProcessInReportCmd print out value of current summation delivered when attribute report is received ZclISE LoadControl Send LoadControlEvent send a load control event message to a load control device ZclSE Message Send DisplayMessage send a message command to an IPD esp ProcessAppMsg MT SYS APP 5 can be used to tunnel any application specific messages into the device via UART e g by using Z Tool It is left as a hook so the application developer can fill in the necessary functionality esp ProcessZDOMsg responses for end device annce and simple descriptor requests are processed here When an end device annce message is received the 25 Copyright O 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 SIMPLE_DESC_QUERY_EVT event is set and this causes the simple descriptor request to be triggered for this so
51. ple Application User s Guide SWRU215 Version 1 3 Extender Association Request Association Response ZDO STATE CHANGE event to application Initiate Match Descriptor Request for Key Establishment Endpoint Match Descriptor Response rangeext ProcessZDOMsgs function called to process Match Descriptor Response Initiate Key Establishment Key Establishment Response y P ZCL KEY ESTABLISH IND event to application Figure 10 Sequence Diagram for a Range Extender OSAL rangeext c functions and tables for task initialization rangeext c main application function that has init and event loop function rangeext h header file for application module rangeext_data c container for declaration of attributes clusters simple descriptor The Range Extender application makes function calls to the following functions rangeext HandleKeys user switch events are processed here HOLD AUTO START is defined so the device will normally not join the network upon startup The user has to press SW1 which then calls ZDOInitDevice to start the device The rationale for doing this is so that the user can have time to configure the Certicom keys prior to joining the network The Range Extender application does not send any application level SE messages but it does join the network and perform key establishment It functions as a standard Zigbee Pro router device 37 Copyright 2009 2010 Texas Instruments Inc A
52. r s Guide Texas Instruments Document SWRA353 Quoc ee ps 6 2 Other Documents www zigbee org 1 ZigBee Alliance Smart Energy Profile Specification 2 ZigBee Alliance ZigBee Smart Energy Test Specification 3 ZigBee Alliance ZigBee Upgrade Cluster Specification 39 Copyright 2009 2010 Texas Instruments Inc All rights reserved
53. re created and populated with the values read from the information memory segments 54xx Fet Pro430 sample code file OF8 01 00 00 00 00 4b 12 00 19 8 03 07 8c 45 de a5 06 dO 7f 1b 82 21 22 b5 a3 1e bO a0 29 55 db 00 12 4b 00 00 00 00 01 54 45 53 54 53 45 43 41 01 09 00 08 00 00 00 00 00 00 19 2 02 00 fd e8 a7 d1 08 42 24 96 2a 4e 7c 54 9 c3 10 4d 58 9 199D 02 28 56 3f 02 f2 c8 bd a7 57 f9 61 bb 8c b4 fb 90 ed 42 q 14 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 54xx Fet Pro430 configuration screenshots FET Pro430 FET MSP430 Flash Programmer Hpretronjc File Setup Serialization Tools About Help Open Code File gt 54 txt path C Documents and Settings a01 306 Blow Security Fuse C Enable SN File Power Device from Adapter slow ruse Microcontroller Type Status 30V v Device Group 430F5xx v Voltage Device Action POWER ON OFF Reload Code File MSP430F5438 v RESET E Target MSP430F5438 Balance 0 BSL ver 900 PICS um verity Security Fuse Source OxO010BB82 Selected Device Information RAM 16384 bytes FLASH 256 kB Memory L _ SST Report 2 PUE BLANK CHECK JTAG communication initialization
54. the OTA upgrade cluster functionality Figure 9 shows the high level interactions between the In Premise Display OTA upgrade client and the OTA upgrade server 34 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 In Premise OTA Server Displa Dongle Association Request Association Response M ZDO STATE CHANGE event to application Initiate Match Descriptor Request for OTA Cluster Endpoint OTA ProcessZDOMsgs function called to process Match Descriptor Response Match Descriptor Response Initiate Match Descriptor Request for Key Establishment Endpoint Match Descriptor Response ipd ProcessZDOMsgs function called to process Match Descriptor Response Initiate Key Establishment 4 ipd_GetCurrentPriceCB Key Establishment Response called 701 KEY ESTABLISH IND event to application Get Pricing Info every 5 seconds or send via INTER PAN using SW2 SW2 can be used to send an INTER PAN version of Get Current Price OTA Console user Image Notify sends Image Notity Get Current Price OSAL timer event is halted Query Next Image Request Query Next Image Response Image Block Request If image version number is gt to executing version number Image Block Response p e r
55. unicating Thermostat PCT as an End Device f Load Control Device as a Router g Range Extender as a Router Figure 1 shows the usage model of how these sample application instances interact with the ESP 1 2 Definitions Abbreviations Acronyms Term Definition AF Application Framework CBKE Certificate based Key Establishment DCO Digitally Controlled Oscillator DUT Device Under Test ECC Elliptic Curve Cryptography ESP Energy Service Portal An alternate name is Energy Service Interface ESI HAN Home Area Network IPD In Premise Display OSAL Operating System Abstraction Layer OTA Over The Air firmware upgrade 1 Copyright 2009 2010 Texas Instruments Inc All rights reserved Smart Energy Sample Application User s Guide SWRU215 Version 1 3 PCT Programmable Communicating Thermostat SE Smart Energy ZCL ZigBee Cluster Library ZDO Zigbee Device Object In Premise Display Queries For Latest Pricing Info and displays MESSAGE command from ESP In Premise Display ESP Sends PCT Load Control Event Programmable Communicating Thermostat PCT ESP Sends Load Control Event Load Control Device Simple Metering Device Reports Current Summation Delivered Attribute Periodically Simple Metering Device Range Extender will join the network perform key establishment and route Range packets but won t excha
56. urce address esp_HandleKeys user switch events are processed here SW1 sends out a load control event to the PCT SW2 sends out a load control event to the load control device SW3 sends out a display message command to the IPD The ESP interacts with other application instances in different ways At first the ESP is configured with Certicom key information using MT OSAL_NV_READ and OSAL_NV_WRITE commands A Z Tool script is used to configure each device Endpoints command structures ZDO callbacks and SE callbacks are initialized by calling esp_Init System and user events are handled in esp_event_loop When a Simple Metering device joins the network once the key establishment procedure is successful the ESP application doesn t have to do anything here since key establishment is handled via the zcl_key_establishment c module it will receive attribute reports from the Simple Metering device every 5 seconds Therefore every 5 seconds the function esp ProcessInReportCmd is called to display the received CurrentSummationDelivered attribute on the ESP s LCD screen When an IPD device joins the network once the key establishment procedure is successful the ESP application doesn t have to do anything here since key establishment is handled via the zcl key establishment c module it will send a get pricing info message On the ESP the esp GetCurrentPriceCB is called when the get pricing info message is received This then calls ZcISE
57. ys prior to joining the network Once the simple meter device joins the network it goes through the state machine explained in Figure 4 simplemeter KeyEstablish ReturnLinkKey is called to check if a link key has already been established with the ESP If one hasn t been established it will send out a match descriptor request in search of the endpoint on the ESP that has the key establishment cluster Upon processing the match descriptor response in the simplemeter_ProcessZDOMsgs function the osal event SIMPLEMETER KEY ESTABLISHMENT REQUEST EVT is set The event handler for this in the process event loop will then call zclGeneral KeyEstablish InitiateKeyEstablishment to do the CBKE procedure Upon its success the application will receive a ZCL KEY ESTABLISH IND system message An osal timer event called SIMPLEMETER REPORT ATTRIBUTE EVT is then started to send attribute reports every 5 seconds of the CurrentSummationDelivered attribute The structure for the report command is created and initialization of the attribute is done in the simplemeter Init function 4 6 Load Control Device The ESP will send a load control event to the Load Control Device via a user switch button press In the Load Control Event payload the Device Class Field Bitmap will indicate that Bit 7 is set representing Residential ON OFF Load When the Load Control Device receives the load control event it sends a ReportEventStatus command that it received it and sends

Download Pdf Manuals

image

Related Search

Related Contents

Dyson DC31 User's Manual  CDR-882 - innoton  Generac 0H0923PMNL User's Manual  マイオリサーチ XP  TBS Payments User Guide  Manuel d`utilisation Générateur de courant, Essence - BC  

Copyright © All rights reserved.
Failed to retrieve file