Home

Lightweight Mesh to Ethernet Gateway with

image

Contents

1. No ARP packet ip input Yes l No etharp_arp_input CP protocol Yes tcp_ input Other protocol handler tcp client received appSendMessageT oLwIP tcp write tcp output Atmel AT02744 Lightweight Mesh to Ethernet Gateway with SAM3X Software User s Guide APPLICATION NOTE 10 A t Mm el 42165A SAM 11 2013 5 1 Main API Introduction The main API s introduction will be divided into two parts Lightweight Mesh Software Stack API LwIP Stack API driver API Each part will be introduced respectively in the following sections Note the APIs described here are focusing on application layer For complete API descriptions refer to the stacks and their documents mentioned in Chapter 3 Lightweight Mesh Software Stack API As the Lightweight Mesh task is based on WSNDemo example similar APIs in WSNDemo are used in the Gateway Most of the Lightweight Mesh APIs used in Gateway are in WSNDemo c The main APIs are as below e sys Init It initializes Lightweight Mesh HAL PHY NWK layer and system timer It s called from board init e SYS TaskHandler It s the core API of Lightweight Mesh The PHY NWK and system timer task handlers are called in this API e APP TaskHandler It s the application layer task handler of Lightweight Mesh The main purpose of using Lightweight Mesh on Gateway is to exchange data Here are some APIs for sending and receivi
2. It re initializes Gateway to TCP client if connection aborted or connection reset occurs in LwIP ev status callback It s the callback function for a status change in default network interface It initializes the Gateway as TCP client by calling tcp client init For more details about LwIP APIs refer to LwIP stack Atmel AT02744 Lightweight Mesh to Ethernet Gateway with SAM3X Software User s Guide APPLICATION NOTE 12 A t Mm el 42165A SAM 11 2013 6 Software Package Content As mentioned before the Gateway is developed based on ASF The directory structure of the software package integrates ASF structure and Lightweight Mesh Software Stack structure For details of the structure of ASF refer to Atmel AVR4029 Atmel Software Framework Getting Started For the structure of Lightweight Mesh refer to Atmel AVR2130 Lightweight Mesh Developer Guide The Gateway directory structure is shown as below Figure 6 1 The Gateway Directory Structure B Sy src el 037 apps ol Og WSNDemo Ly asf a Ly common E 3 boards ia 3 services amp Og utils Gi Gy sam Be components H C drivers w Og utils oe UG thirdparty H Og CMsIS EE Og mp E gt config hd conf board h ve hl conf clock h h conf eth h hl conf spi master h Eri conf uart serialh vee config h Iwipopts h Be stack E hal GS E atsam3x8e E inc w gi sre B Og nwk GB Gi E SIE GI E phy E atserfz1 H E
3. The ASF config file of UART port It s for debug purpose in the Gateway e config h The config file of Lightweight Mesh Software Stack The device type and working channel are defined in this file e Iwipopts h The config file of LwIP stack Atmel AT02744 Lightweight Mesh to Ethernet Gateway with SAM3X Software User s Guide APPLICATION NOTE 14 A t Mm el 42165A SAM 11 2013 e stack e hal e atsam3x8e Hardware abstraction layer of Lightweight Mesh Software Stack In the Gateway it reuses the low level drivers from ASF e nwk Network layer of Lightweight Mesh Software Stack e phy e at86rf231 The radio PHY chip supported by the Gateway e Services The Lightweight Mesh application services OTA service is provided but it s not used in the Gateway It can be removed from the project folder with no harm It s kept there for not breaking Lightweight Mesh Software Stack original structure e Sys The Lightweight Mesh system services Atmel AT02744 Lightweight Mesh to Ethernet Gateway with SAM3X Software User s Guide APPLICATION NOTE 15 A t Mm el 42165A SAM 11 2013 7 Footprint Figure 7 1 and Figure 7 2 illustrate the CODE and RAM spaces that each module used in the software of the Gateway Figure 7 1 Lightweight Mesh to Ethernet Gateway CODE Footprint KB Application 1 504 Figure 7 2 Lightweight Mesh to Ethernet Gateway RAM Footprint KB Application 0 312 ASF 0 392 Toolcha
4. broadcast or multipath unicast are rejected e Small footprint less than 8kB of Flash and 4kB of RAM for a typical application Atmel AT02744 Lightweight Mesh to Ethernet Gateway with SAM3X Software User s Guide APPLICATION NOTE 5 A t Mm el 42165A SAM 11 2013 3 2 3 3 Currently the public release version of Lightweight Mesh software stack works with AVR based MCUs but given its extreme portability and low resource requirements it can be run on almost any Atmel MCU In the Gateway it runs on ATSAM3X8E MCU The Lightweight Mesh software stack version is v1 0 0 Note that at time of writing this application note the Atmel Lightweight Mesh Software Stack is not integrated into ASF In this reference design the files in hal folder of Lightweight Mesh Software Stack are modified to reuse the low level drivers from ASF LwIP TCP IP Stack The Lightweight TCP IP stack is designed for embedded systems The focus of the LwIP TCP IP implementation is to reduce resource usage while still having a full scale TCP LwIP features e IP Internet Protocol including packet forwarding over multiple network interfaces e ICMP Internet Control Message Protocol for network maintenance and debugging e UDP User Datagram Protocol including experimental UDP lite extensions e TCP Transmission Control Protocol with congestion control RTT estimation and fast recovery fast retransmit e Specialized raw API for enhanced performance e Optional B
5. while 1 LwMesh task handler SYS TaskHandler HAL UartTaskHandler APP TaskHandler ES nerneL task sysclk init and board init are two functions to initialize clock and board from ASF The Lightweight Mesh Software Stack hardware initializations are also put in board init init ethernet Is to initialize Ethernet The task handlers in the while loop handles application tasks They are introduced in the following sections By following this structure more functions can be added into main to enrich the Gateway features Several macro switches are defined in conf_board h to give different application options Here are some examples e define LWMESH USED 1 Enable LWMESH PHY e define ETH USED 1 Enable Ethernet To run the Gateway with default features don t not change the macro switches unless you know what it changes clearly Lightweight Mesh Task In the Gateway Lightweight Mesh task is based on WSNDemo example from Lightweight Mesh Software Stack The SYS TaskHandler and APP TaskHandler are the two APIs of Lightweight Mesh task They should be called as frequently as possible The Lightweight Mesh stack low layer tasks are handled by calling SYS TaskHandler The application layer is handled in APP_TaskHandler The Gateway is a node in Ethernet network It sends data to Ethernet by calling appSendData from APP TaskHandler ata predefined interval The Gateway acts as Coordinator
6. DISCLAIMS ANY EXPRESS IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTY OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE OR NON INFRINGEMENT IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT INDIRECT CONSEQUENTIAL PUNITIVE SPECIAL OR INCIDENTAL DAMAGES INCLUDING WITHOUT LIMITATION DAMAGES FOR LOSS AND PROFITS BUSINESS INTERRUPTION OR LOSS OF INFORMATION ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and products descriptions at any time without notice Atmel does not make any commitment to update the information contained herein Unless specifically provided otherwise Atmel products are not suitable for and shall not be used in automotive applications Atmel products are not intended authorized or warranted for use as components in applications intended to support or sustain life
7. SAM3X Software User s Guide j APPLICATION NOTE 6 A t mel 42165A SAM 11 2013 The following information is displayed in the status bar e The server status e Client IP address e Port number e Number of devices in Lightweight Mesh network e Received data pack A screenshot of the PC software is shown in Figure 3 2 For details of the PC software operation check Chapter 8 Figure 3 2 The Gateway PC Software TCPServer 5 TEPServer 2 5 x Status Channel TSensoarfl LED Status 1 EndDevice 08030 Found 0x18 01234 0 Jo 3008518 OFF 2 EndDevice Ox8O037 Found Ox 1 8 Ose 234 3014475 OFF LED Status LED Control ON OFF Client IP 192 168 1 101 Port 51430 Status Barevice Listed 2 Perceived Data Pack 208 Atmel AT02744 Lightweight Mesh to Ethernet Gateway with SAM3X Software User s Guide Atmel APPLICATION NOTE 7 42165A SAM 11 2013 4 1 4 2 Inside the Gateway Application In this chapter the overall Gateway application layer structure is explained And by different functions the main application tasks in the Gateway are introduced in two parts Lightweight Mesh LwIP task Gateway Application Layer Structure As the Gateway is based on WSNDemo example from Lightweight Mesh Software Stack it has similar structure in main The main function of the Gateway is shown below int main void SyoCLe tn board init J init ethernet This is the main polling loop
8. 013 52 LwiIP API Introduction As no operating system is running LwIP raw API has been used in the Gateway And the Gateway is set as TCP client Most of the LwIP APIs are in ethernet sam c The main APIs of LwIP are as below Hver It initializes LwIP Ethernet interface and related hardware SLiernet Taski The LwIP Ethernet task handler It polls the Ethernet tasks periodically The specific application codes are implemented in several call back functions top Client Inir It initializes the Gateway as TCP client By default static IP is assigned to Gateway and a port number is bound In this function it tries to connect to TCP server with the default parameters amp appSendMessageToLwIP This function sends data from Lightweight Mesh to LwIP It fills the data buffer to be transferred tcp write and tcp ouput are the actual functions sends data in LwIP Here is the list of callback functions used in the Gateway Lop elient received It s the callback function invoked whenever a data packet is received from LwIP For Gateway it stores data received from TCP server in a buffer LK COP Lien connected It s the callback function invoked when a TCP connection is established It sends a string to TCP server after successful connection and set TCP client in receive state by registering a callback function tcp client received N tcp recv e tcp err handler It s the callback function for TCP error handler
9. 8 1 101 Port 50963 Number of Zigbee Device Listed 0 Received Data Pack 0 ESS 5 Power on the other Lightweight Mesh devices If the Lightweight Mesh devices are setup correctly the device information will be displayed in the main window of TCPServer as shown in Figure 8 3 The green color of bi color LED D7 on Gateway will toggle each time it receives data from connected devices Figure 8 3 Lightweight Mesh devices connected via Ethernet erepserver iolxi Fie View Action Help Mo Device Status T ensor C1 LED Status 1 EndDevice O lt 8007 Found O18 Ox 234 2 EndDevice 0x8030 Found 0x18 Ox 234 Address Ox6007 LED Status et LED Control ON C OFF Connected Client IP 192 168 1 101 Port 50963 Number of Zigbee Device Listed 2 Received Data Pack 114 gt gt gt gt 6 Click on one device in main window The LED status on selected device is displayed in control window Select ON or OFF and then click Submit the LED on the device can be controlled accordingly Atmel AT02744 Lightweight Mesh to Ethernet Gateway with SAM3X Software User s Guide Itmel APPLICATION NOTE 19 l JE 42165A SAM 11 2013 4 lt a V Ge 8 3 PC software Menu The TCPServer provided with this document is a simple GUI to demonstrate the Gateway reference design In a real application a more complicated GUI may be used For an overview of the PC software features refer to
10. Atmel APPLICATION NOTE Atmel AT02744 Lightweight Mesh to Ethernet Gateway with SAM3X Software User s Guide Atmel 32 bit Microcontroller Features e Atmel ATSAM3X8E microcontroller e Atmel AT86RF231 2 4GHz radio transceiver e Atmel proprietary Lightweight Mesh software stack e 10 100Mbps Ethernet e LwiP TCP IP stack support e TCP IP client e Single MCU gateway solution e Preprogrammed firmware of wireless lighting control via PC software Introduction This application note mainly describes the software architecture and the application programming interfaces API of Lightweight Mesh to Ethernet Gateway reference design hereafter the Gateway A getting started guide at the end of this document gives details about the setup and operation of preprogrammed firmware Figure 1 Lightweight Mesh to Ethernet Gateway The Gateway is based on Atmel ATSAM3X8E microcontroller and Atmel AT86RF231 2 4GHz radio transceiver For gateway hardware design details refer to Atmel AT2200 ZigBee to Ethernet and Wi Fi Gateway with SAM3X Hardware User s Guide 42165A SAM 11 2013 For this reference design the hardware design files schematic BOM and PCB Gerber and software source code can be downloaded from Atmel website The provided hardware documentation can be used with no limitations to manufacture the reference hardware solution for the design Atmel AT02744 Lightweight Mesh to Ethernet Gateway with SAM3X Softwar
11. J inc H SFC B Sy service H inc fa src a By sys H inc H SC i fE asf h Atmel AT02744 Lightweight Mesh to Ethernet Gateway with SAM3X Software User s Guide APPLICATION NOTE 13 A t Mm el 42165A SAM 11 2013 The directory details are described below e apps e WSNDemo The Gateway application layer code The main is in WSNDemo c e asf e common e boards This directory contains the various board definitions shared between multiple architectures As the Gateway is not a standard Atmel Kit it s defined as USER_BOARD And the board details are defined user_board h and conf_board h e services ASF common services e utils ASF common utilities e components Components supported by sam Here the Gateway Ethernet PHY chip is supported by ASF e drivers ASF sam drivers It contains the low level drivers of sam peripherals e utils ASF sam utilities e thirdparty e CMSIS ARM Cortex Microcontroller Software Interface Standard folder e Iwip LwIP stack folder e config e conf_board h The ASF config file of board The Gateway board settings and macros are placed in this file e conf_clock h The ASF config file of clock The Gateway clock settings can be configured here e conf_eth h The ASF config file of EMAC The Gateway Ethernet hardware MAC address and IP address if static IP if used etc are defined in this file e conf spi master h The ASF config file of SPI in master mode e conf_uart_serial h
12. SAM3X Software User s Guide APPLICATION NOTE 22 A t Mm el 42165A SAM 11 2013 Atmel Enabling Unlimited Possibilities Atmel Corporation Atmel Asia Limited Atmel Munich GmbH Atmel Japan G K 1600 Technology Drive Unit 01 5 amp 16 19F Business Campus 16F Shin Osaki Kangyo Building San Jose CA 95110 BEA Tower Millennium City 5 Parkring 4 1 6 4 Osaki Shinagawa ku USA 418 Kwun Tong Road D 85748 Garching b Munich Tokyo 141 0032 Tel 1 408 441 0311 Kwun Tong Kowloon GERMANY JAPAN Fax 1 408 487 2600 HONG KONG Tel 49 89 31970 0 Tel 81 3 6417 0300 www atmel com Tel 852 2245 6100 Fax 49 89 3194621 Fax 81 3 6417 0370 Fax 852 2722 1369 2013 Atmel Corporation All rights reserved Rev 42165A SAM 11 2013 Atmel Atmel logo and combinations thereof Enabling Unlimited Possibilities AVR and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries ARM and Cortex are registered trademarks or trademarks of ARM Ltd Other terms and product names may be trademarks of others Disclaimer The information in this document is provided in connection with Atmel products No license express or implied by estoppel or otherwise to any intellectual property right is granted by this document or in connection with the sale of Atmel products EXCEPT AS SET FORTH IN THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE ATMEL ASSUMES NO LIABILITY WHATSOEVER AND
13. Section 3 3 The menu of TCPServer is simple Only the menu items under Action are implemented They are described as below e Refresh List Refresh the device list manually e Start Listening Start listening on the default server port 8840 e Stop Listening Stop listening on the default server port 8840 Whenever the device list is not updated or showing Not Found in main window as in Figure 8 4 the TCPServer can restart working by selecting Stop Listening and Start Listening Figure 8 4 Device Not Found in TCPSerever 5 rTCPServer File View Action Help Moj Device Status Channel TSensor Cl T EndDevice O 8007 Mot Found 0x18 0x1234 2 EndDevice Ox8030 Mot Found O18 Ox1 234 Address Oxe00 LED Status LED Control C ON amp OFF Submit Client IF 192 168 1 101 Port 50963 Number of figbee Device Listed 7 Received Data Pack 26 Connected o gt Atmel AT02744 Lightweight Mesh to Ethernet Gateway with SAM3X Software User s Guide Atmel APPLICATION NOTE 20 42165A SAM 11 2013 Appendix A Additional Information A 1 Lightweight Mesh Configuration Table A 1 lists the Lightweight Mesh Software Stack configuration used in this reference design and this configuration can be modified in src config config h Table A 1 Lightweight Mesh Options SOption Value Description APP_ADDR 0 Coordinator Node network address It should be 0 for the Gateway APP CHANNEL 0x18 Radio transceiv
14. Sub net mask 255 255 255 0 Default Gateway 192 168 1 1 as shown in Figure 8 1 Figure 8 1 PC IP address configuration Internet Protocol TCP IP Properties General Tou can get IP settings assigned automatically if your network supports this capability Otherwise you need to ask your network administrator for the appropriate IP settings Obtain an IP address automatically Subnet mask 255 255 255 Default gateway 192 168 1 Obtain ONS server address automatically IP address 192 7668 1 105 0 1 8 Use the following DNS server addresses Prefered DNS server Alternate DNS server 2 Connect Ethernet cable between Gateway and PC 3 Power on Gateway by connecting USB cable Ethernet connection status is indicated by LED D2 D3 and D4 on Gateway The red color of bi color LED D7 on Gateway will be on when Lightweight Mesh network ready 4 Open TCPServer in PC If the Gateway and PC are setup correctly TCPServer will report Connected Client IP and Port in the status bar as shown in Figure 8 2 Atmel AT02744 Lightweight Mesh to Ethernet Gateway with SAM3X Software User s Guide Atmel APPLICATION NOTE 18 42165A SAM 11 2013 Figure 8 2 The Gateway connected to TCPServer ioli File View Action Help Mo Device Address Status Channel TSensorfl LED Status Address Ox6030 LED Status LED Control C ON fr OFF Submit connected Client IP 192 16
15. e User s Guide APPLICATION NOTE 2 A t Mm el 42165A SAM 11 2013 Table of Contents lb ENN 4 2 Development Tools rrarnnnrnannnnrnannnnrnannnnrnnnnannnernannnnenunnnennernnsnnnenunener 4 3 Software Architecture rrrrrrrrrarrrnnrrrnnrrnrnnrrrnnrennarennnnrnnnnernnanennanennnsen 4 3 1 Atmel Lightweight Mesh Software Stack cccccccccseeeecceeeeeceeseeeseeseesseaeees 5 3 2 LWP TOPP SCR EEE EE 6 GE E GSE gt EN E EE 6 4 Inside the Gateway Application arrrarnnnernnernnerarevanennrrnnnrnnrnnnennnennnen 8 4 1 Gateway Application Layer Structure cccccccceeseeeeeceeeeeeeeeeeeeueeeeesaeeeesaeeees 8 4 2 Lightweight Mesh Task fawaideriwslatiiwncgndatiuadsiusiuneddniadiastsvaicetieipartierinnediniadsnscaetion 8 do TAP TASE oE E ee rere 10 5 Main API INtroduction cccccccceccseeeeeeeeceeeeeeeeseeeeeueeseeeeeeeeeeeeseeeaes 11 5 1 Lightweight Mesh Software Stack API rrrnrnnnnnnnnnrnnnnnnrrenrnnrrnnnnsrrnnnnerensnnnnen 11 5 2 LwIP PAR LA OC UIC TOM EN 12 6 Software Package Content ccccccceccceecceeeeeeeeceeeeseeeeeeseeeeeeeeaes 13 ne FONN ene eee A eee nee eee ne eee eee eee eee 16 8 Getting Started Guide rrnnrnrnnnnnnnnnnnnvnnnnnnnnvnnnnrnnnvnnnnnnnnnnnnnnnnnsnnsennn 17 8 1 Programming the Gateway eccscsccosssieceiesesse ecpantiveneceeneanns aaeeserniteseeiaiecanenctesecdes UV 8 2 Connecting to Ethernet rrrnnrnrnrnrnnnrvnrnnnrvnrnnnrnvnnernrn
16. er channel Valid range for 2 4GHz radios is 11 26 7 OxOb Ox1a APP PAN ID 0x1234 Network identifier APP_ENDPOINT 1 Application main data communication endpoint NWK BUFFERS AMOUNT 10 Number of buffers reserved for stack operation HAL UART RX FIFO SIZE 4 UART RX buffer size A 2 LwiP Configuration Table A 2 lists the LwIP stack configuration in this reference design and these configurations can be modified in src config Iwipopts h Table A 2 LwiP Options Option Value scription MEM SIZE 31024 The size of the heap memory MEMP NUM PBUF 12 The number of memp struct pbufs MEMP_NUM_TCP_PCB 2 The number of simultaneously active TCP connections MEMP NUM TCP PCB LISTEN 1 The number of listening TCP connections MEMP NUM TCP SEG 9 The number of simultaneously queued TCP segments PBUF POOL SIZE 6 The number of buffers in the pbuf pool PBUF POOL BUFSIZE 512 The size of each pbuf in the pbuf pool LWIP TCP 1 Turn on TCP TCP WND 1500 The size of a TCP window TCP MSS 1500 TCP Maximum segment size TCP SND BUF 2150 TCP sender buffer space TCP SND QUEUELEN 6 TCP SND BUF TCP MSS 1 TCP_MSS TCP sender buffer space Atmel AT02744 Lightweight Mesh to Ethernet Gateway with SAM3X Software User s Guide Atmel APPLICATION NOTE 21 42165A SAM 11 2013 Appendix B Revision History Doc Rev BEN Comments 42165A 11 2013 Initial document release Atmel AT02744 Lightweight Mesh to Ethernet Gateway with
17. erkeley alike socket API e DHCP Dynamic Host Configuration Protocol e PPP Point to Point Protocol e ARP Address Resolution Protocol for Ethernet For more detailed information about the LwIP refer to LwIP Wiki http Iwip wikia com wiki LwIP Wiki or the Atmel AVR32817 Getting Started with the 32 bit AVR UC3 Software Framework LwIP TCP IP Stack application note In the Gateway only TCP IP client is implemented The LwIP version is 1 4 0 PC software PC software named TCPServer is provided to control and monitor devices in Lightweight Mesh network The following information is displayed in the TCPServer main window e Device End device or Router e Address Device short address in Lightweight Mesh network e Status Device in network or not e Channel Working channel e PAN ID Lightweight Mesh network PAN ID e LQI Link quality Indicator of the last data transfer e RSSI Received Signal Strength Indication of the last data transfer e TSensor Dummy sensor data sent from devices in Lightweight Mesh network e LED status LED on off status When clicking on a specific device in main window the selected device can be controlled and monitored in the TCPServer control window e The LED status will be displayed Red stands for ON and blank indicates OFF e The LED can be turned on or off by selecting ON or OFF and clicking Submit Atmel AT02744 Lightweight Mesh to Ethernet Gateway with
18. gram SAM3X Application Lightweight Mesh Stack SPI RF Ethernet PHY f Interface AT86RF231 3 1 Atmel Lightweight Mesh Software Stack Atmel Lightweight Mesh is the easy to use proprietary low power wireless mesh network protocol from Atmel It is designed to work with all Atmel IEEE 802 15 4 transceivers and SoCs To find more detailed information about the Lightweight Mesh architecture and application development process refer to Atmel AVR2130 Lightweight Mesh Developer Guide Atmel Lightweight Mesh software stack features e Simplicity of configuration and use e Up to 65535 nodes in one network theoretical limit e Up to 65535 separate PANs on one channel e Up to 15 independent application endpoints e No dedicated node is required to start a network e No periodic service traffic occupying bandwidth e Two distinct types of nodes e Routing network address lt 0x8000 e Non routing network address gt 0x8000 e Once powered on the node is ready to send and receive data no special joining procedure is required e No child parent relationship between the nodes e Non routing nodes can send and receive data to from any other node including non routing nodes but they will never be used for routing purposes e Route discovery happens automatically if route to the destination is not known e Routing table is updated automatically based on the data from the received and transmitted frames e Duplicate frames
19. ice Programming Tool Device Interface Device signature Target Voltage SAM ICE w ATSAMSXBE v Taa Apply 0x285E0660 3 39 Read Interface settings Device Tool information Device information Flash 512KB Memories C LwMesh_Gateway hex a Verify Flash after programming Program Verify Read Lock bits Security Erasing device OK Programming Flash OK verifying Flash OK Verifying Flash The hex file for Lightweight Mesh devices is running on RCB128RFA1 It acts as End Device in the network LED D4 on RCB128RFA1 can be monitored and controlled through the Gateway Refer to Atmel AVR2131 Lightweight Mesh Getting Started Guide for the setup and programming the RCB128RFA1 Radio Control Board Atmel AT02744 Lightweight Mesh to Ethernet Gateway with SAM3X Software User s Guide Atmel APPLICATION NOTE 17 42165A SAM 11 2013 8 2 Connecting to Ethernet In the preprogrammed firmware the Gateway Ethernet is configured as below e TCP client e Server IP 192 168 1 105 Port 8840 e Gateway static IP 192 168 1 101 Sub net mask 255 255 255 0 Default Gateway 192 168 1 1 The parameters can be changed in the Gateway firmware but the PC software TCPServer provided with this document is designed to work with the settings above 8 2 1 Step by step guide To directly connect the Gateway to PC via Ethernet follow the steps below 1 Configure PC IP address to 192 168 1 105
20. in lib 2 196 The Lightweight Mesh and LwIP stack RAM usage should be configured in their corresponding configuration file according to real application Atmel AT02744 Lightweight Mesh to Ethernet Gateway with SAM3X Software User s Guide APPLICATION NOTE 16 Atmel 42165A SAM 11 2013 8 Getting Started Guide In this chapter it gives step by step guide to setup the Gateway and run the preprogrammed firmware 8 1 Programming the Gateway Along with this document two hex files are provided One is for the Gateway LwMesh_Gateway hex and the other is for Lightweight Mesh devices connecting to the Gateway LwMesh RCB128RFA1 hex To program the Gateway hex file SAM ICE adaptor mentioned in Chapter 2 is needed The steps are as below Connect SAM ICE to the SAM ICE adapter Connect SAM ICE adapter to the Gateway programming header J2 Power the Gateway via the USB cable Open Atmel Studio and select menu Tools gt Device Programming Choose SAM ICE for Tool ATSAM3X8E for Device and JTAG for Interface and then click Apply button Click the Device signature Read button to check if the connection is correct Select the Memories tab and then select the pre built image for the Gateway from in Flash section Click Program If the pre built image is downloaded to the board message Verifying Flash OK appears St a oO a dl a Figure 8 2 Programming the Gateway SAM ICE 000078011795 Dev
21. in Lightweight Mesh network It receives data from other Lightweight Mesh devices from callback function appDataInd and sends data back to Lightweight Mesh network by filling the Acknowledgment command frame in this function Atmel AT02744 Lightweight Mesh to Ethernet Gateway with SAM3X Software User s Guide j APPLICATION NOTE 8 A t mel 42165A SAM 11 2013 Figure 4 1 Lightweight Mesh Task Flow APP_STATE_INITIAL APP STATE SEND appSendData APP STATE SENDING DONE SYS TimerStart Data received appDatalnd APP_STATE_SEND appDataSendingT imerHandlen APP STATE WAIT SEND TIMER anses gt ACK Control field filled Atmel AT02744 Lightweight Mesh to Ethernet Gateway with SAM3X Software User s Guide Atmel APPLICATION NOTE 9 42165A SAM 11 2013 4 3 LwiP Task The Gateway is configured as TCP client when LwIP network connection is initialized The LwIP task uses the ethernet task function to read data packet and run periodical tasks This function should be called periodically If Ethernet is used the Gateway tries to connect to TCP server on a port specified in firmware After successful connection the Gateway is informed of incoming data through callback function tcp client received The data is sent to LwIP by calling appSendMessageToLwIP Figure 4 2 LwiP Task Flow lwip_ init ethernet_configure_interface gt ethernet task q i Yes Yes
22. ng data e appDatalnd The call back function registered by NNK OpenEndpoint in appInit It s called when valid data received from Lightweight Mesh low level layer It also fills the Acknowledgment command frame control field by calling NNK SetAckControl Thus the data sent back to Lightweight Mesh network is implemented in a very simple manner The limit here is the control field is only one byte If large amount of data needs to be transmitted a dedicated API and structure should be used Refer to the none coordinator code in WSNDemo c for example e appSendData It s called by a predefined interval from APP TaskHandler appSendMessageToLwIP and appSendMessage are called in this function to send data to LwIP Tx buffer respectively The timer API is used to generate fix interval through call back function Here is the timer call back function in application layer e appDataSendingTimerHandler It is registered by SYS TimerStart and called at predefined interval As the Gateway acts as Coordinator in Lightweight Mesh network some APIs from the stack are not used For more details about other APIs in Lightweight Mesh refer to the software package and documents inside The latest Lightweight Mesh Software Stack package can be downloaded from http www atmel com tools LIGHTWEIGHT_MESH aspx Atmel AT02744 Lightweight Mesh to Ethernet Gateway with SAM3X Software User s Guide APPLICATION NOTE 11 A t mel 42165A SAM 11 2
23. nnsrnrnnnsnnnasernsnnsernsnnnsen 18 8 2 1 Step by step guide rrrrnnrnrrrnnnrvvnnnnrnvnnnnrnrnnnrnnnnnnsnnnnnnrnsnnnsnnnnnnsnnnnn 18 AS Poe a E EE E reset 20 Appendix A Additional Information ccccccceccceeeseeeeeeeeeeeeneeeeeees 21 A 1 Lightweight Mesh Configuration cccccccssececcssececeeseecceeseecseeseessseessaaeees 21 A2 LWP C nfig uratiOM gcc cst ccneecintunneshesswontidrnnncdGdaucadaataunduinsiveedddeeuondtieadeatsatewodeuds 21 Appendix B Revision History ccccccceeceecceeceeceeeceececceeeeeeeeeeeeeees 22 Atmel AT02744 Lightweight Mesh to Ethernet Gateway with SAM3X Software User s Guide APPLICATION NOTE 3 A t Mm el 42165A SAM 11 2013 1 Overview The Lightweight Mesh to Ethernet Gateway is designed to interface Lightweight Mesh network to Ethernet network Through the Gateway the user can control and monitor any nodes in Lightweight Mesh network remotely via Ethernet A typical application scenario is shown in Figure 1 1 Figure 1 1 Typical Gateway Application Scenario Lightweight Mesh network op OmEDD2 p Pi Ont iG Oxe000 L oww O Internet LAN i 0x0093 08001 Ethernet amp Wi Fi Gateway Remote PC In the preprogrammed firmware a wireless lighting control and monitor network is established The lights in Lightweight Mesh network can be controlled and monitored via PC software remotely 2 Development Tools To download or debug the p
24. reprogrammed firmware the following development toolchain is needed e Atmel Studio 6 Version 6 1 2674 with Service Pack 1 or above e Atmel ARM GNU Toolchain Version 4 7 3 158 GCC 4 7 3 or above e Atmel Software Framework Version 3 9 1 or above e Programming and debugging device Atmel SAM ICE e SAM ICE Adaptor a minimized 1 27mm pitch 10 pin header adaptor for Atmel SAM ICE For more details refer to Atmel AVR2033 SAM ICE Adapter Hardware User Manual 3 Software Architecture The software for the Gateway is composed of two main parts e Atmel Lightweight Mesh Software Stack e LwIP TCP IP Stack Besides the Gateway itself PC software named TCP server is also provided as a simple graphic user interface GUI Atmel AT02744 Lightweight Mesh to Ethernet Gateway with SAM3X Software User s Guide Atmel APPLICATION NOTE 4 42165A SAM 1 1 2013 The Gateway application is designed based on Atmel Software Framework ASF In fact except the Lightweight Mesh Software Stack other modules are from ASF The Gateway exchanges data between Lightweight Mesh network and Ethernet network The Lightweight Mesh network data is collected by the Gateway and transferred into Ethernet network and finally displayed in PC software The user input in PC software is also sent back to Lightweight Mesh network via the Gateway The software block diagram of the Gateway is given in Figure 3 1 Figure 3 1 The Gateway Software Block Dia

Download Pdf Manuals

image

Related Search

Related Contents

    Avaya 2033 IP Conference Phone - Communication Server 1000 User Guide  ROMAINE & JULES  AT&T 5U000249C0A User's Manual  Citizen Systems CBM-291 User's Manual  Tacens SUPERO 1000  D SC-50.IR  Gigaset C1/C2/S1colour/SL1colour  Compaq dc5750 User's Manual  

Copyright © All rights reserved.
Failed to retrieve file