code that uses Watchdog to reset Mbed every 30seconds. After 30-60mins, the ethernet interface fails to setup() after WatchDog reset.

Dependencies:   mbed

Committer:
eqon
Date:
Thu Jun 07 05:44:29 2012 +0000
Revision:
0:0ce833f21e63

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
eqon 0:0ce833f21e63 1
eqon 0:0ce833f21e63 2 /*
eqon 0:0ce833f21e63 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
eqon 0:0ce833f21e63 4
eqon 0:0ce833f21e63 5 Permission is hereby granted, free of charge, to any person obtaining a copy
eqon 0:0ce833f21e63 6 of this software and associated documentation files (the "Software"), to deal
eqon 0:0ce833f21e63 7 in the Software without restriction, including without limitation the rights
eqon 0:0ce833f21e63 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
eqon 0:0ce833f21e63 9 copies of the Software, and to permit persons to whom the Software is
eqon 0:0ce833f21e63 10 furnished to do so, subject to the following conditions:
eqon 0:0ce833f21e63 11
eqon 0:0ce833f21e63 12 The above copyright notice and this permission notice shall be included in
eqon 0:0ce833f21e63 13 all copies or substantial portions of the Software.
eqon 0:0ce833f21e63 14
eqon 0:0ce833f21e63 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
eqon 0:0ce833f21e63 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
eqon 0:0ce833f21e63 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
eqon 0:0ce833f21e63 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
eqon 0:0ce833f21e63 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
eqon 0:0ce833f21e63 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
eqon 0:0ce833f21e63 21 THE SOFTWARE.
eqon 0:0ce833f21e63 22 */
eqon 0:0ce833f21e63 23
eqon 0:0ce833f21e63 24 #ifndef HOST_H
eqon 0:0ce833f21e63 25 #define HOST_H
eqon 0:0ce833f21e63 26
eqon 0:0ce833f21e63 27 #include "ipaddr.h"
eqon 0:0ce833f21e63 28 #include <string.h>
eqon 0:0ce833f21e63 29
eqon 0:0ce833f21e63 30 ///Host information container
eqon 0:0ce833f21e63 31 /**
eqon 0:0ce833f21e63 32 This class is a container for data relative to a connection:
eqon 0:0ce833f21e63 33 - IP Address
eqon 0:0ce833f21e63 34 - Port number
eqon 0:0ce833f21e63 35 - Host Name
eqon 0:0ce833f21e63 36 */
eqon 0:0ce833f21e63 37 class Host
eqon 0:0ce833f21e63 38 {
eqon 0:0ce833f21e63 39 public:
eqon 0:0ce833f21e63 40 ///Initiliazes host with null values
eqon 0:0ce833f21e63 41 Host() : m_ip(0,0,0,0), m_port(0), m_name(NULL)
eqon 0:0ce833f21e63 42 {
eqon 0:0ce833f21e63 43
eqon 0:0ce833f21e63 44 }
eqon 0:0ce833f21e63 45
eqon 0:0ce833f21e63 46 ///Initializes host
eqon 0:0ce833f21e63 47 Host(const IpAddr& ip, const int& port, const char* name="" ) : m_ip(ip), m_port(port), m_name(NULL)
eqon 0:0ce833f21e63 48 {
eqon 0:0ce833f21e63 49 setName(name);
eqon 0:0ce833f21e63 50 }
eqon 0:0ce833f21e63 51
eqon 0:0ce833f21e63 52 ~Host()
eqon 0:0ce833f21e63 53 {
eqon 0:0ce833f21e63 54 if(m_name)
eqon 0:0ce833f21e63 55 {
eqon 0:0ce833f21e63 56 delete[] m_name;
eqon 0:0ce833f21e63 57 }
eqon 0:0ce833f21e63 58 }
eqon 0:0ce833f21e63 59
eqon 0:0ce833f21e63 60 ///Returns IP address
eqon 0:0ce833f21e63 61 const IpAddr& getIp() const
eqon 0:0ce833f21e63 62 {
eqon 0:0ce833f21e63 63 return m_ip;
eqon 0:0ce833f21e63 64 }
eqon 0:0ce833f21e63 65
eqon 0:0ce833f21e63 66 ///Returns port number
eqon 0:0ce833f21e63 67 const int& getPort() const
eqon 0:0ce833f21e63 68 {
eqon 0:0ce833f21e63 69 return m_port;
eqon 0:0ce833f21e63 70 }
eqon 0:0ce833f21e63 71
eqon 0:0ce833f21e63 72 ///Returns host name
eqon 0:0ce833f21e63 73 const char* getName() const
eqon 0:0ce833f21e63 74 {
eqon 0:0ce833f21e63 75 return m_name;
eqon 0:0ce833f21e63 76 }
eqon 0:0ce833f21e63 77
eqon 0:0ce833f21e63 78 ///Sets IP address
eqon 0:0ce833f21e63 79 void setIp(const IpAddr& ip)
eqon 0:0ce833f21e63 80 {
eqon 0:0ce833f21e63 81 m_ip = ip;
eqon 0:0ce833f21e63 82 }
eqon 0:0ce833f21e63 83
eqon 0:0ce833f21e63 84 ///Sets port number
eqon 0:0ce833f21e63 85 void setPort(int port)
eqon 0:0ce833f21e63 86 {
eqon 0:0ce833f21e63 87 m_port = port;
eqon 0:0ce833f21e63 88 }
eqon 0:0ce833f21e63 89
eqon 0:0ce833f21e63 90 ///Sets host name
eqon 0:0ce833f21e63 91 void setName(const char* name)
eqon 0:0ce833f21e63 92 {
eqon 0:0ce833f21e63 93 if(m_name)
eqon 0:0ce833f21e63 94 delete[] m_name;
eqon 0:0ce833f21e63 95 int len = strlen(name);
eqon 0:0ce833f21e63 96 if(len)
eqon 0:0ce833f21e63 97 {
eqon 0:0ce833f21e63 98 m_name = new char[len+1];
eqon 0:0ce833f21e63 99 strcpy(m_name, name);
eqon 0:0ce833f21e63 100 }
eqon 0:0ce833f21e63 101 }
eqon 0:0ce833f21e63 102
eqon 0:0ce833f21e63 103 private:
eqon 0:0ce833f21e63 104 IpAddr m_ip;
eqon 0:0ce833f21e63 105 int m_port;
eqon 0:0ce833f21e63 106 char* m_name;
eqon 0:0ce833f21e63 107 };
eqon 0:0ce833f21e63 108
eqon 0:0ce833f21e63 109 #endif