Presentation is loading. Please wait.

Presentation is loading. Please wait.

Rabbit Zigbee Application Kit Web Enabling your Zigbee network Derek Dippert Technical Sales Engineer - EMEA

Similar presentations


Presentation on theme: "Rabbit Zigbee Application Kit Web Enabling your Zigbee network Derek Dippert Technical Sales Engineer - EMEA"— Presentation transcript:

1 Rabbit Zigbee Application Kit Web Enabling your Zigbee network Derek Dippert Technical Sales Engineer - EMEA derek_dippert@digi.com

2 Agenda Characteristics of Dynamic C and the R3000,R4000 processor How to implement the Zigbee-Ethernet Gateway/ Wifi-Ethernet Hands on Demonstration –Zigbee Application kit –“Light Cube” demo –SD Card Sample

3 Creating an Ethernet-Zigbee or Wifi-Zigbee Gateways Review sections of xb_rweb_dio.c Cover configuration of TCP/IP stack Using the HTTP library CGI Programming Rabbit Web Overview

4 Operator Interfaces Network Enabled Core Modules SBCs Wireless Modules Complete Hardware and Software-based Solutions Integrated Solution

5 RCM4000 Familly Features Pin to Pin compatibility Easy migration for R2000 and R3000 users Increased memory options from previous families Wide range of connectivity Great synergy with Maxstream product line. Low cost controller for Zigbee networks

6 RCM42xx Objective –First RCM4xxx series with 10/100 Ethernet Features & Highlights –Rabbit 4000 with 58.98MHz or 29MHz –10/100 BaseT Ethernet –Serial Flash (4MB & 8MB versions) –8 channel, 12-bit A/D option –Industrial spec (-40C to +85C) –Estimated size: 2.5” x 1.8” (same as RCM40x0) –Pin compatible with RCM40x0, RCM41x0 –Two versions: 60 MHz 512K flash/512K SRAM+ 512KfRAM, 8MB SFlash, ADC 29 MHz, 4MB SFlash, no ADC

7 RCM43xx Objective –“Premium” RCM with mini-SD socket + large memory support Features & Highlights –Rabbit 4000 with 58.98MHz –10/100 BaseT Ethernet –Mini-SD removable card socket –Serial Flash (1MB or 4MB versions) –8 channel, 12-bit A/D option –Industrial spec (-40C to +85C) –Estimated size: 2.85” x 1.84” –Pin compatible with RCM4xxx family –Two versions: 58.98 MHz, 1MB fRAM, 512KbbRAM, 4MB SFlash, ADC 58.98 MHz, 512 fRAM, 512KbbRAM, 1MB SFlash

8 RCM4400W Rabbit Wi-Fi Core Module

9 RCM4400W - Strategy Rabbit needed a replacement strategy for the Wi-Fi Application Kit (CF card based) RCM4400W uses an FPGA for the WiFi technology –FPGA implementation is 802.11b Next generation processor will have WiFi integrated –When FPGA is replaced with next-gen chip, Wi-Fi feature will be 802.11 b/g. FPGA implementation allows us to develop the market and finalize the design before integration into silicon.

10 RCM4400W - Design Info 802.11b implementation (2.4GHz/11Mbps) FPGA based solution currently Nearly industrial grade temp. spec. (-20C to +85C) Socket compatibility with RCM4XXX family WEP encryption currently TKIP/WPA encryption –WPA2 available in the next generation Piper chip

11 RCM4400W - Specs. ProcessorRabbit 4000 @ 58.98 MHz Data SRAM512K Program Execution Fast SRAM 512K Flash Memory512K Serial Flash1MB* (Currently reserved for WiFi code and not user accessible) Backup BatteryConnection for user-supplied backup battery (to support RTC and data SRAM) General Purpose I/Oup to 35 parallel digital I/0 lines configurable with four layers of alternate functions Wi-Fi802.11b standard, ISM 2.4 GHz Serial Ports6 (1 shared with programming port, 1 shared with serial flash) Power (pins unloaded)3.3 V.DC ±5% 450 mA @ 3.3 V while transmitting/receiving 80 mA @ 3.3 V while not transmitting/receiving Operating Temperature-20°C to +85°C

12 RCM4400W - Dev. Kit Includes: 1 - RCM4400W (w/antenna) 1 - Development Board 1 - Serial Programming cable* 1 - Dynamic C 10 CD (Including all standard Libraries) 1 – Universal Power Supply * Serial programming cable replaced with a USB programming cable

13 New Product RCM5400W Series Positioning/Features 2 nd Generation Wi-Fi product Chip integration of 802.11b/g circuitry Debut of Rabbit 5000 product Fastest Wi-Fi product offered Design Advantages Addition of 802.11g (more of a standard in market) 25% faster performance compared to RCM4400W (for the same price) MegaByte Code Support (MCS) with RCM5450W Pin-compatible with other RCM4xxxx modules Status Scheduled for release in July 2008

14 Piper-Based Core Piper-based, pinout and memory configuration same as RabbitEars core Piper contains 802.11a/b/g, DAC, and ADC Requires transceiver RabbitEars Core Rabbit 4000-based core module (RCM4xxx family) Xilinx FPGA contains 802.11b WiFi design Requires DAC, ADC, transceiver

15 RCM4510W Rabbit Zigbee Core Module

16 RCM4510W - Strategy Rabbit wants to address multiple wireless technologies. Zigbee support puts Rabbit at the “cutting edge” of technology (not normal for Rabbit) Zigbee compliments Wi-Fi. It does not compete with it. Zigbee is destined to go everywhere Bluetooth failed to make an impact. Internal Mesh Networking could represent a huge market opportunity for Rabbit. Rabbit gained access to Zigbee technology and expertise when Maxstream was acquired by Digi.

17 RCM4510W - Strategy XBee modules from Maxstream are the long-term solution for Rabbit RCM ’ s. Xbee Series 2 module technology being used (Ember based). Ember chip will better support the Zigbee solution than the Freescale chip, used in Series 1 XBee modules (and in the Rabbit Zigbee App Kit) Rabbit sees RCM4510 ’ s as intelligent end devices in Zigbee networks (something that can actually do something at the end point)

18 RCM4510W - Design Info 802.15.4 Zigbee compliant radio Ember chip mesh networking is not Zigbee certified … yet (planned for next year). Ember chips do not communicate with Freescale chips Series 2 Xbee module plug-in socket design Preview module uses Series 2 circuitry RCM uses I/O from Rabbit + I/O from Series 2 module A/D feature comes from Series 2 module –10 bit A/D

19 RCM4510W - Specs. Microprocessor Rabbit® 4000 @ 29.49 MHz Flash Memory 512K Data SRAM 512K Backup Battery Connection for user-supplied backup battery (to support RTC and data SRAM) General Purpose I/O Up to 49 parallel digital I/0 lines: –40 via Rabbit 4000 pins configurable with four layers of alternate functions 9 via ZigBee® modem pins, four of which may be configured as analog inputs * Analog Inputs * 4 channels single-ended 0–1.2 V DC A/D Converter Resolution 10 bits A/D Conversion Time40 ms Serial Ports 6 (1 shared with programming port) Power (with ZigBee® Modem)3.3 V.DC ±5% –150 mA @ 3.3 V while transmitting/receiving –80 mA @ 3.3 V while not transmitting/receiving –<20 μA @ 3.3 V while asleep Operating Temperature -40°C to +85°C RF Module MaxStream XBee™ Series 2 Compliance 802.15.4 Standard (ZigBee® Compliant)

20 RCM4510W - Dev. Kit Contents: 1 - RCM4510W Core Module 1 - Zigbee-to-USB adapter (in Digi-SP case) 1 - Development board (same as other RCM4xxx) 1 - Dynamic C 10 CD 1 - Programming cable* 1 – Universal Power Supply * USB programming cable included

21 Light Cube Demo

22 Light Cube Overview RCM4400W acts as the web server and passes commands over Zigbee to the RCM4510W RCM4510W acts as an intelligent end device controlling the I/O’s for the light cube No Wires needed Wifi – Zigbee gateway

23 Upcoming Product BL4S100 SBC Series Positioning/Features “True” Single Board Computer design Low priced SBC targeting $100-$150 USD RIO enabled Simple I/O with Ethernet & Wireless Design Advantages 10baseT Ethernet XBee socket (currently using ZNet 2.5) Optional 1-wire interface Optional robust plastic enclosure Status Scheduled for September, 2008 launch

24 Upcoming Product BL4S100 SBC Series Default Features (All versions) Rabbit 4000 processor @ 40MHz 12 Digital Inputs (0-36VDC) 8 Digital Outputs (200mA) 8 Analog Inputs (11/12-bit) 1 Ethernet port (10baseT) 2 RS232 (3-wire/5-wire) 1 Dallas 1-wire interface (build option) 1 RabbitNet port (build option) XBee module socket (currently ZNet2.5) Robust plastic enclosure (optional) Screw terminal interface

25 Upcoming Proudct BL4S100 SBC Series FeatureBL4S100BL4S110BL4S150BL4S160 Fast SRAM 512KB 1MB Battery-backed SRAM 512KB Connectivity 10-base-T Ethernet (Rabbit 4000) Mesh Networking XBee ZNet 2.5 Chip Antenna FCC and Telec versions N/AXBee ZNet 2.5 Chip Antenna FCC and Telec versions N/A Serial Flash 1MB 2MB Analog 8051-based, 8 channel 8051-based, 8 channel (ADS7870 as a custom option) Operating Temperature -40C to +85C

26 Upcoming Product BL4S200 SBC Series Positioning/Features Core Module based design Buy versus Build choice for RCM customers Target price range of $200-$300USD Multiple wireless options for connectivity RIO enabled Solid default feature set for most apps Design Advantages 10baseT and 10/100 networking Wi-Fi and Zigbee wireless connectivity Analog I/O and Serial I/O Robust plastic enclosure (optional) Status Scheduled launch starting in August, 2008

27 Upcoming Product BL4S200 SBC Series Default Features (All Versions) 32 Configurable I/O –(Bitwise, Digital Input or 200mA sinking Output) 8 High Current Outputs (2A sinking or sourcing) 8 11/12-bit Analog Inputs 4 12-bit Analog Outputs 2 RS232 (3-wire/5-wire) 1 RS485 port 2 RabbitNet ports Molex Keyed/Locking connectors Optional robust plastic enclosure

28 Upcoming Product BL4S200 SBC Series

29 Rabbit 4000 Major Features/Subsystems

30 Feature Highlights 0.18μm 3.3V & 1.8V I/O Ring 1.8V Core Up to 58.98 MHz 128-pin LQFP or 128-ball TFBGA RoHS Compliant PWM Outputs PWM Outputs Asynchronous Serial (IrDA Capable) A, B, C, D, E, F Asynchronous Serial (IrDA Capable) A, B, C, D, E, F Synchronous Serial & SPI A, B, C, D Synchronous Serial & SPI A, B, C, D Parallel & Bitwise I/O ports A, B, C, D, E Parallel & Bitwise I/O ports A, B, C, D, E Battery Backable Real Time Clock Battery Backable Real Time Clock DMA Controller DMA Controller 10-bit Timer System (B) 10-bit Timer System (B) Cascadable 8-bit Timer System (A) Cascadable 8-bit Timer System (A) External Interrupt Inputs External Interrupt Inputs Fast Oscillator Fast Oscillator 32.768 kHz Clock Input 32.768 kHz Clock Input Integrated Ethernet Integrated Ethernet Power Save and Clock Control Power Save and Clock Control Slave Interface Slave Interface Periodic Interrupt (488  S) Periodic Interrupt (488  S) Remote Bootstrap Remote Bootstrap SDLC & HDLC (IrDA Capable) E, F SDLC & HDLC (IrDA Capable) E, F Spectrum Spreader (Low EMI) Spectrum Spreader (Low EMI) Auxiliary I/O Data & Address Bus Auxiliary I/O Data & Address Bus External Memory and I/O Bus Interface External Memory and I/O Bus Interface Quadrature Decoder Quadrature Decoder Input Capture & Pulse Width Measurement Input Capture & Pulse Width Measurement Clock Doubler Clock Doubler Internal Address/Data Bus Watchdog Timer Watchdog Timer Glueless Memory and I/O Chip Control Glueless Memory and I/O Chip Control ® System/User Hardware System/User Hardware Encryption & Chip Security Encryption & Chip Security 16-bit Timer System (C) 16-bit Timer System (C)

31 Similar to Z180 Architecture 16 bit Program Counter CPU Registers almost identical Enhanced Instruction Set Instructions execute in fewer clock cycles Priority-based Interrupts

32 Major Features/Subsystems 60MHz Maximum Clock Frequency 128 pin LQFP – not compatible with Rabbit 3000 Low Power Operation Reduced EMI 20 to 24 bit Address Bus – up to 16 MB Up to Six Memory Chips – 96 MB Support for 16 bit memories

33 Major Features/Subsystems 1.8V core with 1.8 - 3.3V I/O Inputs are 3.3V tolerant (not 5V!) Hardware Debugging Enhancements 10BaseT Ethernet – MAC and Phy –Analog part is external 8 DMA Channels Four PWM Channels

34 Parallel Ports Port D Alternate Outputs BitAlt Out 0Alt Out 1Alt Out 2Alt Out 3 7IA7I7PWM 3SCLK C 6TxAI6PWM 2TxE 5IA6I5PWM 1RCLK E 4TxBI4PWM 0TCLK E 3IA7I3Timer C3SCLK D 2SCLK CI2Timer C2TxF 1IA6I1Timer C1RCLK F 0SCLK DI0Timer C0TCLK F 16 Bit Data Bus D15 D14 D13 D12 D11 D10 D09 D08

35 Rabbit 4000 I/O Utility Allows the user to customize the I/O pins on the Rabbit 4000 Control for setting port functions as well as timing functions for PWM, serial ports, etc. Generates a configuration library for the user which initializes the pins and ports for the various peripherals. Takes advantage of API in serial RS232, PWM and other libraries. “Live” Rabbit 4000 Reference Poster Two views available Can set each pin as input or output or any of the other alternate pin functions

36 Rabbit 4000 I/O Utility

37 Reduced EMI Separate Power Pins for CPU Core and I/O –Also reduces EMI by 15db Spectrum Spreader –Reduces EMI by 15db –Three Modes: off, weak and strong

38 Reduced EMI (cont’d) Spectrum Spreader

39 Low Power Operation Sleepy Mode

40 Serial Ports Six Serial Ports (A-F) All capable of standard UART operation All capable of IrDA bit timing Ports A-D capable of SPI I/O of Serial Ports A-D are on Parallel Port C I/O of Serial Ports E & F are on Parallel Port G

41 Serial Ports (cont’d) Serial Ports A & B can be directed to Parallel Port D Serial Ports E & F are capable of HDLC/SDLC Maximum Asynchronous Baud Rate is CPU clock/8 –default = clock/32 Maximum Synchronous Bit Rate is CPU clock/2 –default = clock/4 Each Serial Port has its own timer from Timer A as its Baud Rate Generator

42 Serial Ports (cont’d) Block Diagram

43 Built-in Real Time Clock 32 kHz Oscillator circuit 48 bit counter good for over 100 years Required to download via Dynamic C Used to measure the frequency of the CPU oscillator Battery Backed Accuracy is about +/- 3 seconds/day

44 Watchdog Timer 17 bit counter Driven by 32 kHz oscillator Selectable timeout period: 0.25, 0.5, 1, 2 sec Setup and “petted” by Dynamic C via the periodic ISR within the BIOS User is expected to use Virtual Watchdogs available in Dynamic C – see the vwd… functions

45 Dynamic C

46 Software Overview Complete development environment –C Compiler –Advanced Editor –Debugger –Many libraries provided –Separate software modules available for purchase –Many sample programs provided

47 Philosophy Easy to use –Simple installation (both software and hardware) –“Hello, world” in 15 minutes –Gentle development process –Allows customers to be successful –Simple progression from prototype to complete application Provided with all development kits

48 Debugging Features Editor with syntax highlighting Breakpoints Single-stepping program execution Variable tooltips Stdio window Watch expressions Disassembled code Register window Stack window

49 Debugging Features (cont’d) Function help system Execution tracing Memory dump Stack trace

50 Libraries Standard libraries –Many standard C functions are provided Processor features –E.g., serial ports, quadrature decoder, etc. TCP/IP and networking –TCP, UDP, DNS, FTP, HTTP, SMTP, POP3… Extended memory support Board-specific libraries

51 Sample Programs Samples range from very simple to complex Over 800 samples total –Over 10 board-specific samples for product. –Over 200 TCP/IP Sample Programs –About 70 Module Samples

52 TCP/IP Support TCP/IP stack is included royalty-free –Includes web server, email support, FTP, and socket-level programming API is not BSD sockets-based –Our API is generally considered simpler TCP Performance (44 MHz, 100BaseT) –Up to ~470 Kbyte/s reading –Up to ~600 Kbyte/s writing

53 Additional Software Modules These software modules with Dynamic C increase functionality with select Rabbit Core modules FAT File System – File Allocation Tables PPP – Point to Point Protocol SNMP – Simple Network Management Protocol RabbitWeb – HTML interface with embedded applications AES - Advanced Encryption Standard SSL – Secure Sockets Layer Library Encryption – For Development PC RFU – Rabbit Field Utility allows binary image files generated by Dynamic C to be loaded to Rabbit targets without Dynamic C. µC/OS-II Real-Time Kernel - Jean LaBrosse's popular real time kernel. This is a preemptive, prioritized kernel that allows 63 different tasks, flags, semaphores, mutex semaphores, queues, and message mail boxes.

54 Dynamic C 10.x Features & Highlights –Support for 4000- based products –Large memory device support – 1MB of code –Hardware breakpoint support for Rabbit 4000 –Includes Add on Modules as standard feature –Improved DC project handling –Optimized code generation (current) –Far data and pointers (current) –Support for 16-bit SRAM and flash (current)

55 New Software Dynamic C Dynamic C is now online for free –Includes previous versions to support customer development –Downloads require customer registration Dynamic C is now split into 2 development trees –DC 9.xx supports Rabbit 2000 and Rabbit 3000 –DC 10.xx supports Rabbit 4000 and Rabbit 5000 Dynamic C has integrated most of the separate modules –Includes FAT, Library Encryption, uC/OS-II (no book), PPP, RabbitWeb, SNMP, ModbusTCP –AES & SSL/TLS are now bundled into one security module available for purchase MSRP@$289USD for download and $299 for shipped CD

56 Creating an Ethernet to Zigbee Gateway Ethernet to Zigbee Gateway

57 802.15.4 Kit Goals ZigBee & 802.15.4 Using Dynamic C XBee API and AT commands Web interface to a ZigBee Network –Using RabbitWeb –Using Yahoo! User Interface Library –3 rd party tools for debugging

58 ZigBee TM / 802.15.4 Application Kit Highlights Illustrates how a Rabbit-based product interfaces with ZigBee modules as a way to add low-cost wireless to Rabbit enabled devices RabbitCore module with Ethernet, memory for data storage Programs and samples for the mesh network communication. RabbitWeb html programming software module included User-friendly GUI for easy network set-up

59 Rabbit’s ZigBee TM / 802.15.4 Application Kit Features RCM3720 Development system RabbitCore module with Ethernet, 512K Flash/256K SRAM, 1MB serial flash, 33 GPIO, etc. Development board with prototyping area 3 Maxstream XBee TM RF modems at 2.4GHz 3 RF interface boards with battery RabbitWeb html programming software module User-friendly web interface

60 Rabbit’s ZigBee TM / 802.15.4 Application Kit Functions –RabbitCore module acts as a network coordinator, gateway or control device. Can act as an http server as well as intelligent control device –Supports various topologies: point-to-point (peer- to-peer), point-to-multipoint, and mesh network –User configurable GUI allows for network set-up, identify and poll similar ZigBee devices, and establish communications between other node devices –Wireless data logging and monitoring

61 Main Components of xb_rweb_dio.c Enabling Serial Comms and I/O Line Passing( AT and API mode settings) –Node Discovery CGI –DIO Read CGI –Dio Write CGI Enabling TCP/IP settings Enabling the HTTP server Utilizing Rabbit Web

62 Configuration Screens Modem Configuration Set modem as coordinator or node – name the device Set serial interface configurations AES Encryption switch Set modem characteristics AT command options

63 Additional Sample –Discovering maximum associated nodes Technique –(ND) Node Discovery –RabbitWeb –Remote Scripting with Iframes. Rabbit ZigBee/802.15.4 Application Kit

64 Configuration Screens I/O Control “See” other nodes in the network Switch I/O points online – or receive feedback from device Automatic refresh Reference I/O control

65 Terminal Window Emulates the XCTU software

66 Libraries Needed #memmap xmem compiles all functions to xmem – Good for TCP/IP programs – Large TCP/IP functions can fill root code area #use “http.lib” includes the web server #use “dcrtcp.lib” Includes main TCP/IP libraries – Must be present in all TCP/IP programs – Configuration macros (TCP buffer sizes, etc.) must occur before this statement #use “xbee.lib” includes customized library from Application Kit #memmap xmem #use "dcrtcp.lib" #use "http.lib" #use "xbee.lib" #memmap xmem #use "dcrtcp.lib" #use "http.lib" #use "xbee.lib"

67 Main main() http_init(); tcp_reserveport(80); memset(&xB,0,sizeof(xB));// set all to 0 xB.at.on = xb_atModeOn(xB.at.gt); if(xB.at.on>0) xb_getAll();// read all commands from modem xb_atModeOff(); while (1) { http_handler(); } main() http_init(); tcp_reserveport(80); memset(&xB,0,sizeof(xB));// set all to 0 xB.at.on = xb_atModeOn(xB.at.gt); if(xB.at.on>0) xb_getAll();// read all commands from modem xb_atModeOff(); while (1) { http_handler(); } Initialize TCP/IP stack and the HTTP state machine Drive the HTTP state machine – The TCP/IP stack is driven within http_handler() http_init() initializes the HTTP server tcp_reserveport(80): – Enables queueing of requests http_handler() drives the HTTP server – Calls tcp_tick() internally

68 Serial Communication #define ATCMDRSP_SP D/set to serial port A, B, C, D, E, or F #define DINBUFSIZE 511//PC1 = RxD -- Xbee pin 2 = Dout #define DOUTBUFSIZE 127//PC0 = TxD – Xbee pin 3 = Din #define SERD_RTS_PORT PCDR//RTS is output flowcontrol #define SERD_RTS_SHADOW PCDRShadow #define SERD_RTS_BIT 2 //PC2 #define SERD_CTS_PORT PCDR //CTS is input flowcontrol #define SERD_CTS_BIT 3 //PC3 #define DEFAULTBAUD9600L //factory default baud rate #define ATCMDRSP_SP D/set to serial port A, B, C, D, E, or F #define DINBUFSIZE 511//PC1 = RxD -- Xbee pin 2 = Dout #define DOUTBUFSIZE 127//PC0 = TxD – Xbee pin 3 = Din #define SERD_RTS_PORT PCDR//RTS is output flowcontrol #define SERD_RTS_SHADOW PCDRShadow #define SERD_RTS_BIT 2 //PC2 #define SERD_CTS_PORT PCDR //CTS is input flowcontrol #define SERD_CTS_BIT 3 //PC3 #define DEFAULTBAUD9600L //factory default baud rate #define ATCMDRSP - macro is used to specify the serial port used by AT commands in the Dynamic C ATCMDRSP.LIB library. The D specifies Serial Port D as the main RS-232 serial port. #define DINBUFSIZE - macro is specifies the size of the buffer used to store data received from pin 2 of the XBee™ RF modem, which was configured for DOUT. The D in DINBUFSIZE specifies Serial Port D, where PC1 is RxD. #define DOUTBUFSIZE - macro is specifies the size of the buffer used to send data to pin 3 of the XBee™ RF modem, which was configured for DIN. The D in DOUTBUFSIZE specifies Serial Port D, where PC0 is TxD. #define SERD_RTS_PORT- macro identifies PCDR, the output flow control via Parallel Port C. #define SERD_RTS_SHADOW - macro identifies the shadow register via Parallel Port C used by the output flow control. #define SERD_RTS_BIT - macro identifies the bit on Parallel Port C, PC2, used by the output flow control. #define SEND_CTS_PORT - macro identifies PCDR, the input flow control via Parallel Port C. #define SERD_CTS_BIT - macro identifies the bit on Parallel Port C, PC3, used by the input flow control.

69 Statically Configuring TCP/IP In Dynamic C, load the file “lib\tcpip\tcp_config.lib” Can modify: – IP address – Netmask – Name server – Default gateway

70 Statically Configuring TCP/IP (cont’d) Optionally, you can create a “custom_config.lib” file for configuration – Use “tcp_config.lib” as a basis – Change config numbers to be >= 100 – Add entry to “lib.dir” file – Macros in configuration section specify default parameters to ifconfig() Allows configurations without modifying Rabbit libraries

71 TCP Config Settings TCPCONFIG macro set to 1 for static For Hands on portion IP address will need to be changed for crossover cable #define TCPCONFIG 1 // 1 for static (tcp_config.lib) or 3 for DHCP #define LOCAL_VERBOSE 0//0 = none; 1 = basic; 2 = details; 5 = most details #define XBEE_VERBOSE// xbee.lib printf info //#define XBEE_DEBUG// xbee.lib debugable //#define AT_CMDRSP_VERBOSE// atcmdrsp.lib low driver printf info //#define AT_CMDRSP_DEBUG// atcmdrsp.lib low driver debugable #define TCPCONFIG 1 // 1 for static (tcp_config.lib) or 3 for DHCP #define LOCAL_VERBOSE 0//0 = none; 1 = basic; 2 = details; 5 = most details #define XBEE_VERBOSE// xbee.lib printf info //#define XBEE_DEBUG// xbee.lib debugable //#define AT_CMDRSP_VERBOSE// atcmdrsp.lib low driver printf info //#define AT_CMDRSP_DEBUG// atcmdrsp.lib low driver debugable

72 Compile-Time Configuration The following table is an overview of the predefined TCPCONFIG configuration values. Note that "Runtime" means that that value only allows runtime configuration. TCP | Ethernet | PPP | DHCP | Runtime | Comments ----------+----------+-----+------+---------+------------------------------- 1 | Yes | No | No | No | Simple Ethernet or Wifi configuration. Boardtype determines functionality. ----------+----------+-----+------+---------+------------------------------- 2 | No | Yes | No | No | Obsolete: use 8 instead ----------+----------+-----+------+---------+------------------------------ 3 | Yes | No | Yes | No | Obsolete: use 5 instead ----------+----------+-----+------+---------+------------------------------- 4 | Yes | Yes | No | No | Multiple interface example ----------+----------+-----+------+---------+------------------------------- 5 | Yes | No | Yes | No | Like #3, but no optional flags. Also works with WiFi boards. ----------+----------+-----+------+---------+------------------------------- 6 | Yes | No | No | Yes | "Empty": runtime setup req'd ----------+----------+-----+------+---------+------------------------------- 7 | Yes | No | Yes | No | DHCP, with static IP fallback ----------+----------+-----+------+---------+------------------------------- 8 | No | Yes | Yes | No | PPP with modem support ** ----------+----------+-----+------+---------+-------------------------------

73 AT Command Mode/DIO Write CGI if(nodes[i].sh == sh && nodes[i].sl == sl)// found the node {// set the coordinators ios to match the remote xbee's ios {// set the coordinators ios to match the remote xbee's ios if(xb_atModeOn(xB.at.gt)>0) if(xb_atModeOn(xB.at.gt)>0) { xb_setDH(0);// set to 0, so data will not tx over the air xb_setDH(0);// set to 0, so data will not tx over the air xb_setDL(0);// set to 0, so data will not tx over the air xb_setDL(0);// set to 0, so data will not tx over the air xb_setD0(nodes[i].ds[0]);// set coordinator's io to match nodes xb_setD0(nodes[i].ds[0]);// set coordinator's io to match nodes xb_setD1(nodes[i].ds[1]);// set coordinator's io to match nodes xb_setD1(nodes[i].ds[1]);// set coordinator's io to match nodes xb_atModeOff(); xb_atModeOff(); if(xb_atModeOn(xB.at.gt)>0) if(xb_atModeOn(xB.at.gt)>0) { xb_setDH(sh); // set destination high to match node xb_setDH(sh); // set destination high to match node xb_setDL(sl); // set destination low to match node xb_setDL(sl); // set destination low to match node if(!strcmp(ds1,"ON"))// needs to turn on so set to 0 if(!strcmp(ds1,"ON"))// needs to turn on so set to 0 { xb_setD0(0);// set coordinator's io to disable xb_setD0(0);// set coordinator's io to disable nodes[i].ds[0] = 0; nodes[i].ds[0] = 0; } else else { xb_setD0(3);// set coordinator's io to input xb_setD0(3);// set coordinator's io to input nodes[i].ds[0] = 3; nodes[i].ds[0] = 3;} xb_atModeOff(); xb_atModeOff(); http_setState(s,2); http_setState(s,2); } } if(nodes[i].sh == sh && nodes[i].sl == sl)// found the node {// set the coordinators ios to match the remote xbee's ios {// set the coordinators ios to match the remote xbee's ios if(xb_atModeOn(xB.at.gt)>0) if(xb_atModeOn(xB.at.gt)>0) { xb_setDH(0);// set to 0, so data will not tx over the air xb_setDH(0);// set to 0, so data will not tx over the air xb_setDL(0);// set to 0, so data will not tx over the air xb_setDL(0);// set to 0, so data will not tx over the air xb_setD0(nodes[i].ds[0]);// set coordinator's io to match nodes xb_setD0(nodes[i].ds[0]);// set coordinator's io to match nodes xb_setD1(nodes[i].ds[1]);// set coordinator's io to match nodes xb_setD1(nodes[i].ds[1]);// set coordinator's io to match nodes xb_atModeOff(); xb_atModeOff(); if(xb_atModeOn(xB.at.gt)>0) if(xb_atModeOn(xB.at.gt)>0) { xb_setDH(sh); // set destination high to match node xb_setDH(sh); // set destination high to match node xb_setDL(sl); // set destination low to match node xb_setDL(sl); // set destination low to match node if(!strcmp(ds1,"ON"))// needs to turn on so set to 0 if(!strcmp(ds1,"ON"))// needs to turn on so set to 0 { xb_setD0(0);// set coordinator's io to disable xb_setD0(0);// set coordinator's io to disable nodes[i].ds[0] = 0; nodes[i].ds[0] = 0; } else else { xb_setD0(3);// set coordinator's io to input xb_setD0(3);// set coordinator's io to input nodes[i].ds[0] = 3; nodes[i].ds[0] = 3;} xb_atModeOff(); xb_atModeOff(); http_setState(s,2); http_setState(s,2); } }

74 API Mode Operation/DIO Read CGI 7E 00 10 82 00 13 A2 00 40 08 DD 98 2C 00 01 00 18 00 18 AE Delimiter Length API Identifier SH SL # of samples ChI DIOs Checksum(FFF-351) int dioRead_cgi(HttpState* s) { static char serBuf[ATRSP_MAXSIZE]; char sh[9],sl[9]; char sh[9],sl[9]; int i,samples,chi,dio,adc,byteSum,chkSum; int i,samples,chi,dio,adc,byteSum,chkSum; switch(http_getState(s)) switch(http_getState(s)) { case 1:// check for API packet indicating dio change case 1:// check for API packet indicating dio change if(serRdUsed(ATCMDRSP_SP))// is invalid data? if(serRdUsed(ATCMDRSP_SP))// is invalid data? { if(0x007E == serPeek(ATCMDRSP_SP))// check for start of API packet (0x7E) if(0x007E == serPeek(ATCMDRSP_SP))// check for start of API packet (0x7E) { if(serRdUsed(ATCMDRSP_SP)>=3)// make sure 2 byte length is here if(serRdUsed(ATCMDRSP_SP)>=3)// make sure 2 byte length is here { serRead(ATCMDRSP_SP,serBuf,3,100);// get the 7E and length (2 bytes) serRead(ATCMDRSP_SP,serBuf,3,100);// get the 7E and length (2 bytes) s->subsubstate = (serBuf[1] subsubstate = (serBuf[1]<<8|serBuf[2])+1;// convert length to int + CRC s->timeout = set_timeout(3);// time to wait for the next part of packet s->timeout = set_timeout(3);// time to wait for the next part of packet http_setState(s,2);// valid and all here so http_setState(s,2);// valid and all here so int dioRead_cgi(HttpState* s) { static char serBuf[ATRSP_MAXSIZE]; char sh[9],sl[9]; char sh[9],sl[9]; int i,samples,chi,dio,adc,byteSum,chkSum; int i,samples,chi,dio,adc,byteSum,chkSum; switch(http_getState(s)) switch(http_getState(s)) { case 1:// check for API packet indicating dio change case 1:// check for API packet indicating dio change if(serRdUsed(ATCMDRSP_SP))// is invalid data? if(serRdUsed(ATCMDRSP_SP))// is invalid data? { if(0x007E == serPeek(ATCMDRSP_SP))// check for start of API packet (0x7E) if(0x007E == serPeek(ATCMDRSP_SP))// check for start of API packet (0x7E) { if(serRdUsed(ATCMDRSP_SP)>=3)// make sure 2 byte length is here if(serRdUsed(ATCMDRSP_SP)>=3)// make sure 2 byte length is here { serRead(ATCMDRSP_SP,serBuf,3,100);// get the 7E and length (2 bytes) serRead(ATCMDRSP_SP,serBuf,3,100);// get the 7E and length (2 bytes) s->subsubstate = (serBuf[1] subsubstate = (serBuf[1]<<8|serBuf[2])+1;// convert length to int + CRC s->timeout = set_timeout(3);// time to wait for the next part of packet s->timeout = set_timeout(3);// time to wait for the next part of packet http_setState(s,2);// valid and all here so http_setState(s,2);// valid and all here so

75 XBEE_API.LIB –zigbee_init(); –_zb_begin_service_discovery(); –zb_tick_ext (&frame); frame = pointer to the last frame structure. Returns –ZB_NOMESSAGE –ZB_MESSAGE –ZB_RADIO_STAT –ZB_MSG_STAT

76 XBEE_API.LIB Important API Frames –Frame ID _API_FRAME_RECV_BIND _API_FRAME_IO_SAMPLE _API_FRAME_REMOTE_RESP

77 XBEE_API.LIB –zb_sendAPIremoteATcmd (A,B,C,D,E,F) –A = 64-bit IEEE address –B = 16-bit network address –C = options –D = remote command –E = remote data –F = remote data length

78 HTTP Server Library HTTP/1.0 Implementation – Works with all major browsers Serves both static and dynamic content – CGI functions and RabbitWeb assist with dynamic content Filesystem support Authentication (basic, digest) supported HTTPS support with added module

79 HTTP State Configuration Macros HTTP_MAXBUFFER This is the size of the buffer accessible through the HttpSpec structure. It defaults to 256 bytes. The size of this buffer affects the speed of the HTTP server; the larger the buffer (up to a point), the faster the server will run. The buffer size is also important for use in CGI functions because it is a work space the programmer can use. HTTP_MAXBUFFER must be at least 180 bytes for CGI functionality. HTTP_MAXSERVERS This is the maximum number of HTTP servers listening on port 80. The default is 2. You may increase this value to the maximum number of independent entities on your page. For example, for a Web page with four pictures, two of which are the same, set HTTP_MAXSERVERS to 4: one for the page, one for the duplicate images, and one for each of the other two images. By default, each server takes 2500 bytes of RAM. This RAM usage can be changed by the macro SOCK_BUF_SIZE (or tcp_MaxBufSize which is deprecated as of Dynamic C ver. 6.57). Another option is to use the tcp_reserveport() function and a smaller number of sockets. #define HTTP_MAXSERVERS 8 #define HTTP_MAXBUFFER(MAX_NODE_SIZE*MAX_DISCOVERABLE_NODES) #define TCP_BUF_SIZE (HTTP_MAXBUFFER*6) #define MAX_TCP_SOCKET_BUFFERS HTTP_MAXSERVERS #define HTTP_MAXSERVERS 8 #define HTTP_MAXBUFFER(MAX_NODE_SIZE*MAX_DISCOVERABLE_NODES) #define TCP_BUF_SIZE (HTTP_MAXBUFFER*6) #define MAX_TCP_SOCKET_BUFFERS HTTP_MAXSERVERS

80 HTTP Server Library Static content is defined in compile-time data structures – Resource table – MIME types table Content can also be added and removed at run-time ZServer.lib manages resources for the HTTP and FTP servers – Provides abstraction layer

81 Zserver Library SSPEC_MAX_OPEN Determine the maximum number of simultaneously open resources. Defaults to 4. Choose this number carefully, since each entry can take up a fairly large amount of root storage, depending on the mix of filesystems in use. Unless you are anticipating a very busy server, 4 should be enough. If you increase the default value of HTTP_MAXSERVERS from 4, you may experience 404 or 503 messages. The solution is to increase SSPEC_MAX_OPEN. Ideally, this value should be HTTP_MAXSERVERS + FTP_MAXSERVERS + any special use of zserver.lib that you create. SSPEC_MAXNAME Define the maximum name length of each dynamic or static resource. Defaults to 20. You can minimize memory usage by choosing short names for all resources, and reducing the value of this macro. #define SSPEC_MAXNAME 32 // default = 20, max len of mime type #define SSPEC_MAX_OPEN MAX_TCP_SOCKET_BUFFERS #define RWEB_POST_MAXVARS 128// default = 64, *20 = total root needed #define SSPEC_MAXNAME 32 // default = 20, max len of mime type #define SSPEC_MAX_OPEN MAX_TCP_SOCKET_BUFFERS #define RWEB_POST_MAXVARS 128// default = 64, *20 = total root needed

82 Yahoo! User Interface Library The YUI library is a set of utilities and controls, written in JavaScript, for building feature rich web interfaces. http://developer.yahoo.com/yui

83 CGI Support For dynamic content, Common Gateway Interface (CGI) functions can be used When a CGI resource is loaded by the browser, the server gives control to a callback function The callback function has complete control of the HTTP socket Very flexible, but difficult to code RabbitWeb provides a simpler model

84 CGI Basics CGI functions. CGI stands for “Common Gateway Interface,” however this acronym has a more specific use in Dynamic C— Refers to a C function that is called by the HTTP server to generate some dynamic content for the browser. This is the only truly optional block. Many applications can be written without resorting to CGI functions; however, there are some cases where the power and flexibility of a CGI will be required.

85 CGI Functions Use of the HttpState structure is necessary for CGI functions CGI is a standard for interfacing external applications with HTTP servers. Each time a client requests an URL corresponding to a CGI program, the server will execute the CGI program in real-time. int nodeDiscover_cgi(HttpState* s); int terminal_cgi(HttpState* s); int dioRead_cgi(HttpState* s); int dioWrite_cgi(HttpState* s); int nodeDiscover_cgi(HttpState* s); int terminal_cgi(HttpState* s); int dioRead_cgi(HttpState* s); int dioWrite_cgi(HttpState* s);

86 Server Resource Table #ximport is a Dynamic C directive – Loads the given file into the program flash – The last parameter is a long pointer to the loaded file – File is loaded into xmem – #zimport can be used to compress loaded files #ximport "\pages\main.htm"main_htm #ximport "\pages\main.css"main_css #ximport "\pages\com.htm"com_htm #ximport "\pages\term.htm"term_htm #ximport "\pages\ajax.js"ajax_js #ximport "\pages\nodes.htm"nodes_htm #ximport "\pages\dio.htm"dio_htm #ximport "\pages\dio_spe.htm"dio_spe_htm #ximport "\pages\dio_net.htm"dio_net_htm #ximport "\pages\dio_rf.htm"dio_rf_htm #ximport "\pages\dio_ser.htm"dio_ser_htm #ximport "\pages\dio_dia.htm"dio_dia_htm #ximport "\pages\dio_at.htm"dio_at_htm #ximport "\pages\dio.js"dio_js #ximport "\pages\loading.gif"loading_gif #ximport "\pages\blank.gif"blank_gif #ximport "\pages\main.htm"main_htm #ximport "\pages\main.css"main_css #ximport "\pages\com.htm"com_htm #ximport "\pages\term.htm"term_htm #ximport "\pages\ajax.js"ajax_js #ximport "\pages\nodes.htm"nodes_htm #ximport "\pages\dio.htm"dio_htm #ximport "\pages\dio_spe.htm"dio_spe_htm #ximport "\pages\dio_net.htm"dio_net_htm #ximport "\pages\dio_rf.htm"dio_rf_htm #ximport "\pages\dio_ser.htm"dio_ser_htm #ximport "\pages\dio_dia.htm"dio_dia_htm #ximport "\pages\dio_at.htm"dio_at_htm #ximport "\pages\dio.js"dio_js #ximport "\pages\loading.gif"loading_gif #ximport "\pages\blank.gif"blank_gif

87 Server MIME Table SSPEC_MIMETABLE_STARTSSPEC_MIME_FUNC(".htm","text/html",zhtml_handler), SSPEC_MIME(".js","application/x-javascript"),// will need to change SSPEC_MAXNAME SSPEC_MIME(".css","text/css"),SSPEC_MIME(".xml","text/xml"),SSPEC_MIME(".gif","image/gif"),SSPEC_MIME(".cgi","")SSPEC_MIMETABLE_ENDSSPEC_MIMETABLE_STARTSSPEC_MIME_FUNC(".htm","text/html",zhtml_handler), SSPEC_MIME(".css","text/css"),SSPEC_MIME(".xml","text/xml"),SSPEC_MIME(".gif","image/gif"),SSPEC_MIME(".cgi","")SSPEC_MIMETABLE_END Creates a table of file types HTTP server indicates to the browser that files ending in “.html” are HTML (“text/html”) files “.gif” are “image/gif” files These are MIME types (Multipurpose Internet Mail Extensions) Must add types your server will be serving Defines the resource table SSPEC_RESOURCE_XMEMFILEindicates we are adding a file in xmem – First parameter indicates the name of the resource – Second parameter gives the location of the resource Other resource types are available – Root files, CGI functions, root variables, etc.

88 RabbitWeb Goals Ease the chore of creating web interfaces Enable choices about presentation tobe made in the HTML files, not code Retain flexibility of web page design Leverage web designers’ existing knowledge Take ideas from server-oriented realm (e.g., PHP, ASP) and refashion to be appropriate to small embedded systems

89 Solution Develop light HTML scripting language (ZHTML) Link variables in ZHTML with C variables Enable simple error-checking of user input Use ZHTML to report errors in user input Restrict updates to specific users Allow callbacks to be executed on user input

90 RabbitWeb Error Checking When user input is received, all received variables are checked for errors If any of the variables fail their guards, then none of the new values are applied Allows interfaces to be designed so that user can inspect erroneous values and correct them This technique is very difficult to achieve by other methods

91 RabbitWeb Compiler Extensions #web directive registers variables C variable must have been previously declared Optional error-checking expression (guard) Optional “groups=” parameter imposes security limits { struct struct // AT COMMAND OPTIONS { int ct,gt,cc;// txtBox { int ct,gt,cc;// txtBox int on,off;// button(writeOnly) int on,off;// button(writeOnly) }at;// AT Command Options }at;// AT Command Options}xb_type; void atCallBack();// callback function for at option changes #web xB.at.ct (((2 <= $xB.at.ct) && ($xB.at.ct <= 0x028F))?1:ERR(NULL)) #web xB.at.gt (((1 <= $xB.at.gt) && ($xB.at.gt <= 0x0CE4))?1:ERR(NULL)) #web xB.at.cc // text box(0-0xFF) #web xB.at.on (xb_atModeOn(xB.at.gt)>0?1:WEB_ERROR("on")) #web_update xB.at.ct,xB.at.gt,xB.at.ccatCallBack { struct struct // AT COMMAND OPTIONS { int ct,gt,cc;// txtBox { int ct,gt,cc;// txtBox int on,off;// button(writeOnly) int on,off;// button(writeOnly) }at;// AT Command Options }at;// AT Command Options}xb_type; void atCallBack();// callback function for at option changes #web xB.at.ct (((2 <= $xB.at.ct) && ($xB.at.ct <= 0x028F))?1:ERR(NULL)) #web xB.at.gt (((1 <= $xB.at.gt) && ($xB.at.gt <= 0x0CE4))?1:ERR(NULL)) #web xB.at.cc // text box(0-0xFF) #web xB.at.on (xb_atModeOn(xB.at.gt)>0?1:WEB_ERROR("on")) #web_update xB.at.ct,xB.at.gt,xB.at.ccatCallBack

92 Rabbit Web HTML Scripting Example shows how AT command options are changed " type="hidden" value=" " /> AT Command Mode Timeout: " id="ct" type="text" size="4" value=" " onchange="change(this);"/> Guard Time: " id="gt" type="text" size="4" value=" " onchange="change(this);"/> Command Sequence Character: " id="cc" type="text" size="2" value=" " onchange="change(this);"/> " type="hidden" value=" " /> AT Command Mode Timeout: " id="ct" type="text" size="4" value=" " onchange="change(this);"/> Guard Time: " id="gt" type="text" size="4" value=" " onchange="change(this);"/> Command Sequence Character: " id="cc" type="text" size="2" value=" " onchange="change(this);"/>


Download ppt "Rabbit Zigbee Application Kit Web Enabling your Zigbee network Derek Dippert Technical Sales Engineer - EMEA"

Similar presentations


Ads by Google