WIZ820io(W5200) network interface、EthernetNetIf compatible.
example
#include "WIZ820ioNetIf.h" #include "HTTPClient.h" #include "HTTPServer.h" #if defined(TARGET_KL25Z) WIZ820ioNetIf eth(PTD2,PTD3,PTD1,PTD0,PTD5); #endif HTTPClient http; HTTPStream stream; void callback(HTTPResult r){ printf("callback %d %s\n", r, HTTPClient::ResultStr(r)); } int main() { int err = eth.setup(); if (err < 0) { printf("setup error %d\n", err); exit(-1); } HTTPServer svr; svr.addHandler<SimpleHandler>("/"); svr.bind(80); const char* uri = "http://va009039-mbed.appspot.com/kl25z/"; http.get(uri, &stream, callback); uint8_t buf[256]; int total = 0; stream.readNext(buf, sizeof(buf)); while(1) { if(stream.readable()) { int len = stream.readLen(); total += len; printf("%d %d\n", total, len); stream.readNext(buf, sizeof(buf)); } Net::poll(); } }
MyNetIf.h@1:22b9052d864d, 2013-03-24 (annotated)
- Committer:
- va009039
- Date:
- Sun Mar 24 11:25:31 2013 +0000
- Revision:
- 1:22b9052d864d
- Parent:
- 0:bdeec5f86894
WIZ820io(W8200) ethernet interface, EthernetNetIf compatible.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
va009039 | 0:bdeec5f86894 | 1 | // MyNetIf.h 2012/4/15 |
va009039 | 0:bdeec5f86894 | 2 | #ifndef MYIPNETIF_H |
va009039 | 0:bdeec5f86894 | 3 | #define MYIPNETIF_H |
va009039 | 0:bdeec5f86894 | 4 | #include "mbed.h" |
va009039 | 0:bdeec5f86894 | 5 | #include "core/net.h" |
va009039 | 0:bdeec5f86894 | 6 | #include "if/net/netif.h" |
va009039 | 0:bdeec5f86894 | 7 | |
va009039 | 0:bdeec5f86894 | 8 | class MyNetIf : public NetIf { |
va009039 | 0:bdeec5f86894 | 9 | public: |
va009039 | 0:bdeec5f86894 | 10 | MyNetIf(); |
va009039 | 0:bdeec5f86894 | 11 | |
va009039 | 0:bdeec5f86894 | 12 | void init(); |
va009039 | 0:bdeec5f86894 | 13 | |
va009039 | 0:bdeec5f86894 | 14 | virtual ~MyNetIf(); |
va009039 | 0:bdeec5f86894 | 15 | virtual NetTcpSocket* tcpSocket(); |
va009039 | 0:bdeec5f86894 | 16 | virtual NetUdpSocket* udpSocket(); |
va009039 | 0:bdeec5f86894 | 17 | virtual NetDnsRequest* dnsRequest(const char* hostname); |
va009039 | 0:bdeec5f86894 | 18 | virtual NetDnsRequest* dnsRequest(Host* pHost); |
va009039 | 0:bdeec5f86894 | 19 | |
va009039 | 0:bdeec5f86894 | 20 | virtual void poll(); |
va009039 | 0:bdeec5f86894 | 21 | private: |
va009039 | 0:bdeec5f86894 | 22 | bool m_init; |
va009039 | 0:bdeec5f86894 | 23 | }; |
va009039 | 0:bdeec5f86894 | 24 | #endif //MYIPNETIF_H |