Leest de waarde van een sensor binnen een maakt deze beschikbaar via internet

Dependencies:   NTPClient_NetServices mbed

Committer:
hendrikvincent
Date:
Mon Dec 02 09:01:23 2013 +0000
Revision:
0:05ccbd4f84f1
eerste programma;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hendrikvincent 0:05ccbd4f84f1 1
hendrikvincent 0:05ccbd4f84f1 2 /*
hendrikvincent 0:05ccbd4f84f1 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
hendrikvincent 0:05ccbd4f84f1 4
hendrikvincent 0:05ccbd4f84f1 5 Permission is hereby granted, free of charge, to any person obtaining a copy
hendrikvincent 0:05ccbd4f84f1 6 of this software and associated documentation files (the "Software"), to deal
hendrikvincent 0:05ccbd4f84f1 7 in the Software without restriction, including without limitation the rights
hendrikvincent 0:05ccbd4f84f1 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
hendrikvincent 0:05ccbd4f84f1 9 copies of the Software, and to permit persons to whom the Software is
hendrikvincent 0:05ccbd4f84f1 10 furnished to do so, subject to the following conditions:
hendrikvincent 0:05ccbd4f84f1 11
hendrikvincent 0:05ccbd4f84f1 12 The above copyright notice and this permission notice shall be included in
hendrikvincent 0:05ccbd4f84f1 13 all copies or substantial portions of the Software.
hendrikvincent 0:05ccbd4f84f1 14
hendrikvincent 0:05ccbd4f84f1 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
hendrikvincent 0:05ccbd4f84f1 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
hendrikvincent 0:05ccbd4f84f1 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
hendrikvincent 0:05ccbd4f84f1 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
hendrikvincent 0:05ccbd4f84f1 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
hendrikvincent 0:05ccbd4f84f1 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
hendrikvincent 0:05ccbd4f84f1 21 THE SOFTWARE.
hendrikvincent 0:05ccbd4f84f1 22 */
hendrikvincent 0:05ccbd4f84f1 23
hendrikvincent 0:05ccbd4f84f1 24 #ifndef NET_H
hendrikvincent 0:05ccbd4f84f1 25 #define NET_H
hendrikvincent 0:05ccbd4f84f1 26
hendrikvincent 0:05ccbd4f84f1 27 class NetIf;
hendrikvincent 0:05ccbd4f84f1 28 class NetTcpSocket;
hendrikvincent 0:05ccbd4f84f1 29 class NetUdpSocket;
hendrikvincent 0:05ccbd4f84f1 30 class NetDnsRequest;
hendrikvincent 0:05ccbd4f84f1 31
hendrikvincent 0:05ccbd4f84f1 32 #include <list>
hendrikvincent 0:05ccbd4f84f1 33 using std::list;
hendrikvincent 0:05ccbd4f84f1 34
hendrikvincent 0:05ccbd4f84f1 35 /*
hendrikvincent 0:05ccbd4f84f1 36 #include "host.h"
hendrikvincent 0:05ccbd4f84f1 37 #include "ipaddr.h"
hendrikvincent 0:05ccbd4f84f1 38 #include "netservice.h"
hendrikvincent 0:05ccbd4f84f1 39 #include "if/net/netif.h"
hendrikvincent 0:05ccbd4f84f1 40 #include "if/net/nettcpsocket.h"
hendrikvincent 0:05ccbd4f84f1 41 #include "if/net/netudpsocket.h"
hendrikvincent 0:05ccbd4f84f1 42 #include "if/net/netdnsrequest.h"
hendrikvincent 0:05ccbd4f84f1 43 */
hendrikvincent 0:05ccbd4f84f1 44
hendrikvincent 0:05ccbd4f84f1 45 class Host;
hendrikvincent 0:05ccbd4f84f1 46 class NetIf;
hendrikvincent 0:05ccbd4f84f1 47 class NetTcpSocket;
hendrikvincent 0:05ccbd4f84f1 48 class NetUdpSocket;
hendrikvincent 0:05ccbd4f84f1 49 class NetDnsRequest;
hendrikvincent 0:05ccbd4f84f1 50
hendrikvincent 0:05ccbd4f84f1 51 class Net
hendrikvincent 0:05ccbd4f84f1 52 {
hendrikvincent 0:05ccbd4f84f1 53 private:
hendrikvincent 0:05ccbd4f84f1 54 Net();
hendrikvincent 0:05ccbd4f84f1 55 ~Net();
hendrikvincent 0:05ccbd4f84f1 56 public:
hendrikvincent 0:05ccbd4f84f1 57 static void poll(); //Poll every if & socket
hendrikvincent 0:05ccbd4f84f1 58
hendrikvincent 0:05ccbd4f84f1 59 static NetTcpSocket* tcpSocket(NetIf& netif);
hendrikvincent 0:05ccbd4f84f1 60 static NetTcpSocket* tcpSocket(); //Socket on default if
hendrikvincent 0:05ccbd4f84f1 61 static void releaseTcpSocket(NetTcpSocket* pNetTcpSocket);
hendrikvincent 0:05ccbd4f84f1 62
hendrikvincent 0:05ccbd4f84f1 63 static NetUdpSocket* udpSocket(NetIf& netif);
hendrikvincent 0:05ccbd4f84f1 64 static NetUdpSocket* udpSocket(); //Socket on default if
hendrikvincent 0:05ccbd4f84f1 65 static void releaseUdpSocket(NetUdpSocket* pNetUdpSocket);
hendrikvincent 0:05ccbd4f84f1 66
hendrikvincent 0:05ccbd4f84f1 67 static NetDnsRequest* dnsRequest(const char* hostname, NetIf& netif);
hendrikvincent 0:05ccbd4f84f1 68 static NetDnsRequest* dnsRequest(const char* hostname); //Create a new NetDnsRequest object from default if
hendrikvincent 0:05ccbd4f84f1 69
hendrikvincent 0:05ccbd4f84f1 70 static NetDnsRequest* dnsRequest(Host* pHost, NetIf& netif);
hendrikvincent 0:05ccbd4f84f1 71 static NetDnsRequest* dnsRequest(Host* pHost); //Create a new NetDnsRequest object from default if
hendrikvincent 0:05ccbd4f84f1 72
hendrikvincent 0:05ccbd4f84f1 73 static void setDefaultIf(NetIf& netif); //Deprecated
hendrikvincent 0:05ccbd4f84f1 74 static void setDefaultIf(NetIf* pIf);
hendrikvincent 0:05ccbd4f84f1 75 static NetIf* getDefaultIf();
hendrikvincent 0:05ccbd4f84f1 76
hendrikvincent 0:05ccbd4f84f1 77 protected:
hendrikvincent 0:05ccbd4f84f1 78 friend class NetIf;
hendrikvincent 0:05ccbd4f84f1 79 friend class NetTcpSocket;
hendrikvincent 0:05ccbd4f84f1 80 friend class NetUdpSocket;
hendrikvincent 0:05ccbd4f84f1 81
hendrikvincent 0:05ccbd4f84f1 82 static void registerIf(NetIf* pIf);
hendrikvincent 0:05ccbd4f84f1 83 static void unregisterIf(NetIf* pIf);
hendrikvincent 0:05ccbd4f84f1 84
hendrikvincent 0:05ccbd4f84f1 85 static void registerNetTcpSocket(NetTcpSocket* pNetTcpSocket);
hendrikvincent 0:05ccbd4f84f1 86 static void unregisterNetTcpSocket(NetTcpSocket* pNetTcpSocket);
hendrikvincent 0:05ccbd4f84f1 87
hendrikvincent 0:05ccbd4f84f1 88 static void registerNetUdpSocket(NetUdpSocket* pNetUdpSocket);
hendrikvincent 0:05ccbd4f84f1 89 static void unregisterNetUdpSocket(NetUdpSocket* pNetUdpSocket);
hendrikvincent 0:05ccbd4f84f1 90
hendrikvincent 0:05ccbd4f84f1 91 private:
hendrikvincent 0:05ccbd4f84f1 92 static Net& net(); //Return inst of singleton
hendrikvincent 0:05ccbd4f84f1 93
hendrikvincent 0:05ccbd4f84f1 94 NetIf* m_defaultIf;
hendrikvincent 0:05ccbd4f84f1 95
hendrikvincent 0:05ccbd4f84f1 96 list<NetIf*> m_lpIf;
hendrikvincent 0:05ccbd4f84f1 97 list<NetTcpSocket*> m_lpNetTcpSocket;
hendrikvincent 0:05ccbd4f84f1 98 list<NetUdpSocket*> m_lpNetUdpSocket;
hendrikvincent 0:05ccbd4f84f1 99 };
hendrikvincent 0:05ccbd4f84f1 100
hendrikvincent 0:05ccbd4f84f1 101 #endif