Xbee test 2

Dependencies:   XBee mbed

Committer:
takashiyamanoue
Date:
Sat Jul 21 04:08:27 2012 +0000
Revision:
0:ffac63d6a7f0
xbee test 2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
takashiyamanoue 0:ffac63d6a7f0 1
takashiyamanoue 0:ffac63d6a7f0 2 /*
takashiyamanoue 0:ffac63d6a7f0 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
takashiyamanoue 0:ffac63d6a7f0 4
takashiyamanoue 0:ffac63d6a7f0 5 Permission is hereby granted, free of charge, to any person obtaining a copy
takashiyamanoue 0:ffac63d6a7f0 6 of this software and associated documentation files (the "Software"), to deal
takashiyamanoue 0:ffac63d6a7f0 7 in the Software without restriction, including without limitation the rights
takashiyamanoue 0:ffac63d6a7f0 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
takashiyamanoue 0:ffac63d6a7f0 9 copies of the Software, and to permit persons to whom the Software is
takashiyamanoue 0:ffac63d6a7f0 10 furnished to do so, subject to the following conditions:
takashiyamanoue 0:ffac63d6a7f0 11
takashiyamanoue 0:ffac63d6a7f0 12 The above copyright notice and this permission notice shall be included in
takashiyamanoue 0:ffac63d6a7f0 13 all copies or substantial portions of the Software.
takashiyamanoue 0:ffac63d6a7f0 14
takashiyamanoue 0:ffac63d6a7f0 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
takashiyamanoue 0:ffac63d6a7f0 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
takashiyamanoue 0:ffac63d6a7f0 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
takashiyamanoue 0:ffac63d6a7f0 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
takashiyamanoue 0:ffac63d6a7f0 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
takashiyamanoue 0:ffac63d6a7f0 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
takashiyamanoue 0:ffac63d6a7f0 21 THE SOFTWARE.
takashiyamanoue 0:ffac63d6a7f0 22 */
takashiyamanoue 0:ffac63d6a7f0 23
takashiyamanoue 0:ffac63d6a7f0 24 /** \file
takashiyamanoue 0:ffac63d6a7f0 25 Ethernet network interface header file
takashiyamanoue 0:ffac63d6a7f0 26 */
takashiyamanoue 0:ffac63d6a7f0 27
takashiyamanoue 0:ffac63d6a7f0 28 #ifndef ETHERNETNETIF_H
takashiyamanoue 0:ffac63d6a7f0 29 #define ETHERNETNETIF_H
takashiyamanoue 0:ffac63d6a7f0 30
takashiyamanoue 0:ffac63d6a7f0 31 struct netif;
takashiyamanoue 0:ffac63d6a7f0 32
takashiyamanoue 0:ffac63d6a7f0 33 #include "mbed.h"
takashiyamanoue 0:ffac63d6a7f0 34
takashiyamanoue 0:ffac63d6a7f0 35 #include "if/lwip/LwipNetIf.h"
takashiyamanoue 0:ffac63d6a7f0 36
takashiyamanoue 0:ffac63d6a7f0 37 ///Ethernet network interface return codes
takashiyamanoue 0:ffac63d6a7f0 38 enum EthernetErr
takashiyamanoue 0:ffac63d6a7f0 39 {
takashiyamanoue 0:ffac63d6a7f0 40 __ETH_MIN = -0xFFFF,
takashiyamanoue 0:ffac63d6a7f0 41 ETH_TIMEOUT, ///<Timeout during setup
takashiyamanoue 0:ffac63d6a7f0 42 ETH_OK = 0 ///<Success
takashiyamanoue 0:ffac63d6a7f0 43 };
takashiyamanoue 0:ffac63d6a7f0 44
takashiyamanoue 0:ffac63d6a7f0 45 ///Ethernet network interface
takashiyamanoue 0:ffac63d6a7f0 46 /**
takashiyamanoue 0:ffac63d6a7f0 47 This class provides Ethernet connectivity to the stack
takashiyamanoue 0:ffac63d6a7f0 48 */
takashiyamanoue 0:ffac63d6a7f0 49 class EthernetNetIf : public LwipNetIf
takashiyamanoue 0:ffac63d6a7f0 50 {
takashiyamanoue 0:ffac63d6a7f0 51 public:
takashiyamanoue 0:ffac63d6a7f0 52 ///Instantiates the Interface and register it against the stack, DHCP will be used
takashiyamanoue 0:ffac63d6a7f0 53 EthernetNetIf(); //W/ DHCP
takashiyamanoue 0:ffac63d6a7f0 54
takashiyamanoue 0:ffac63d6a7f0 55 ///Instantiates the Interface and register it against the stack, DHCP will not be used
takashiyamanoue 0:ffac63d6a7f0 56 /**
takashiyamanoue 0:ffac63d6a7f0 57 IpAddr is a container class that can be constructed with either 4 bytes or no parameters for a null IP address.
takashiyamanoue 0:ffac63d6a7f0 58 */
takashiyamanoue 0:ffac63d6a7f0 59 EthernetNetIf(IpAddr ip, IpAddr netmask, IpAddr gateway, IpAddr dns); //W/o DHCP
takashiyamanoue 0:ffac63d6a7f0 60 virtual ~EthernetNetIf();
takashiyamanoue 0:ffac63d6a7f0 61
takashiyamanoue 0:ffac63d6a7f0 62 ///Brings the interface up
takashiyamanoue 0:ffac63d6a7f0 63 /**
takashiyamanoue 0:ffac63d6a7f0 64 Uses DHCP if necessary
takashiyamanoue 0:ffac63d6a7f0 65 @param timeout_ms : You can set the timeout parameter in milliseconds, if not it defaults to 15s
takashiyamanoue 0:ffac63d6a7f0 66 @return : ETH_OK on success or ETH_TIMEOUT on timeout
takashiyamanoue 0:ffac63d6a7f0 67 */
takashiyamanoue 0:ffac63d6a7f0 68 EthernetErr setup(int timeout_ms = 15000);
takashiyamanoue 0:ffac63d6a7f0 69
takashiyamanoue 0:ffac63d6a7f0 70 virtual void poll();
takashiyamanoue 0:ffac63d6a7f0 71
takashiyamanoue 0:ffac63d6a7f0 72 private:
takashiyamanoue 0:ffac63d6a7f0 73 Timer m_ethArpTimer;
takashiyamanoue 0:ffac63d6a7f0 74 Timer m_dhcpCoarseTimer;
takashiyamanoue 0:ffac63d6a7f0 75 Timer m_dhcpFineTimer;
takashiyamanoue 0:ffac63d6a7f0 76 Timer m_igmpTimer;
takashiyamanoue 0:ffac63d6a7f0 77
takashiyamanoue 0:ffac63d6a7f0 78 bool m_useDhcp;
takashiyamanoue 0:ffac63d6a7f0 79
takashiyamanoue 0:ffac63d6a7f0 80 netif* m_pNetIf;
takashiyamanoue 0:ffac63d6a7f0 81
takashiyamanoue 0:ffac63d6a7f0 82 IpAddr m_netmask;
takashiyamanoue 0:ffac63d6a7f0 83 IpAddr m_gateway;
takashiyamanoue 0:ffac63d6a7f0 84
takashiyamanoue 0:ffac63d6a7f0 85 const char* m_hostname;
takashiyamanoue 0:ffac63d6a7f0 86
takashiyamanoue 0:ffac63d6a7f0 87 };
takashiyamanoue 0:ffac63d6a7f0 88
takashiyamanoue 0:ffac63d6a7f0 89 #endif
takashiyamanoue 0:ffac63d6a7f0 90