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 NETDNSREQUEST_H
eqon 0:0ce833f21e63 25 #define NETDNSREQUEST_H
eqon 0:0ce833f21e63 26
eqon 0:0ce833f21e63 27 //class Socket;
eqon 0:0ce833f21e63 28 class Host;
eqon 0:0ce833f21e63 29 //class NetService;
eqon 0:0ce833f21e63 30 class NetDnsRequest;
eqon 0:0ce833f21e63 31
eqon 0:0ce833f21e63 32 #include "netservice.h"
eqon 0:0ce833f21e63 33 #include "ipaddr.h"
eqon 0:0ce833f21e63 34 #include "host.h"
eqon 0:0ce833f21e63 35
eqon 0:0ce833f21e63 36 enum NetDnsReply
eqon 0:0ce833f21e63 37 {
eqon 0:0ce833f21e63 38 NETDNS_PRTCL,
eqon 0:0ce833f21e63 39 NETDNS_NOTFOUND, //Hostname is unknown
eqon 0:0ce833f21e63 40 NETDNS_ERROR, //Problem with DNS Service
eqon 0:0ce833f21e63 41 //...
eqon 0:0ce833f21e63 42 NETDNS_FOUND,
eqon 0:0ce833f21e63 43 };
eqon 0:0ce833f21e63 44
eqon 0:0ce833f21e63 45 class NetDnsRequest : public NetService
eqon 0:0ce833f21e63 46 {
eqon 0:0ce833f21e63 47 public:
eqon 0:0ce833f21e63 48 NetDnsRequest(const char* hostname);
eqon 0:0ce833f21e63 49 NetDnsRequest(Host* pHost);
eqon 0:0ce833f21e63 50 virtual ~NetDnsRequest();
eqon 0:0ce833f21e63 51
eqon 0:0ce833f21e63 52 class CDummy;
eqon 0:0ce833f21e63 53 template<class T>
eqon 0:0ce833f21e63 54 //Linker bug : Must be defined here :(
eqon 0:0ce833f21e63 55 void setOnReply( T* pItem, void (T::*pMethod)(NetDnsReply) )
eqon 0:0ce833f21e63 56 {
eqon 0:0ce833f21e63 57 m_pCbItem = (CDummy*) pItem;
eqon 0:0ce833f21e63 58 m_pCbMeth = (void (CDummy::*)(NetDnsReply)) pMethod;
eqon 0:0ce833f21e63 59 }
eqon 0:0ce833f21e63 60
eqon 0:0ce833f21e63 61 //Execute request & return OK if found, NOTFOUND or ERROR on error, or PROCESSING if the request has not completed yet
eqon 0:0ce833f21e63 62 // virtual DnsErr pollState() = 0;
eqon 0:0ce833f21e63 63 virtual void poll() = 0; //NetService fn
eqon 0:0ce833f21e63 64
eqon 0:0ce833f21e63 65 void getResult(IpAddr* pIp);
eqon 0:0ce833f21e63 66
eqon 0:0ce833f21e63 67 virtual void close();
eqon 0:0ce833f21e63 68
eqon 0:0ce833f21e63 69 protected:
eqon 0:0ce833f21e63 70 void onReply(NetDnsReply reply); //Must be called by impl when the request completes
eqon 0:0ce833f21e63 71
eqon 0:0ce833f21e63 72 IpAddr m_ip;
eqon 0:0ce833f21e63 73 char* m_hostname;
eqon 0:0ce833f21e63 74
eqon 0:0ce833f21e63 75 private:
eqon 0:0ce833f21e63 76 CDummy* m_pCbItem;
eqon 0:0ce833f21e63 77 void (CDummy::*m_pCbMeth)(NetDnsReply);
eqon 0:0ce833f21e63 78
eqon 0:0ce833f21e63 79 Host* m_pHost;
eqon 0:0ce833f21e63 80
eqon 0:0ce833f21e63 81 bool m_closed;
eqon 0:0ce833f21e63 82 };
eqon 0:0ce833f21e63 83
eqon 0:0ce833f21e63 84 #endif