Small Testprogram to have WebAccess via Webserver to a 433Mhz tranmitter to control remotly some devices from remote, with TFTP, NTP and RMF. This could be a base to develop applications.

Dependencies:   ChaNFSSD TFTPServer RMFWeb

Dependents:   RMFWeb

Committer:
ED7418
Date:
Mon Jun 16 07:40:08 2014 +0000
Revision:
1:809b59c7a800
Parent:
0:51f1ef89ec7b
mbed-lib and other libs are a based on a project, published in a Elektor-book "ARM-microkontroller Part II".

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ED7418 0:51f1ef89ec7b 1
ED7418 0:51f1ef89ec7b 2 /*
ED7418 0:51f1ef89ec7b 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
ED7418 0:51f1ef89ec7b 4
ED7418 0:51f1ef89ec7b 5 Permission is hereby granted, free of charge, to any person obtaining a copy
ED7418 0:51f1ef89ec7b 6 of this software and associated documentation files (the "Software"), to deal
ED7418 0:51f1ef89ec7b 7 in the Software without restriction, including without limitation the rights
ED7418 0:51f1ef89ec7b 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
ED7418 0:51f1ef89ec7b 9 copies of the Software, and to permit persons to whom the Software is
ED7418 0:51f1ef89ec7b 10 furnished to do so, subject to the following conditions:
ED7418 0:51f1ef89ec7b 11
ED7418 0:51f1ef89ec7b 12 The above copyright notice and this permission notice shall be included in
ED7418 0:51f1ef89ec7b 13 all copies or substantial portions of the Software.
ED7418 0:51f1ef89ec7b 14
ED7418 0:51f1ef89ec7b 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
ED7418 0:51f1ef89ec7b 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
ED7418 0:51f1ef89ec7b 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
ED7418 0:51f1ef89ec7b 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
ED7418 0:51f1ef89ec7b 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
ED7418 0:51f1ef89ec7b 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
ED7418 0:51f1ef89ec7b 21 THE SOFTWARE.
ED7418 0:51f1ef89ec7b 22 */
ED7418 0:51f1ef89ec7b 23
ED7418 0:51f1ef89ec7b 24 #include "LwipNetIf.h"
ED7418 0:51f1ef89ec7b 25 #include "lwip/init.h"
ED7418 0:51f1ef89ec7b 26 #include "lwip/tcp_impl.h"
ED7418 0:51f1ef89ec7b 27 #include "lwip/dns.h"
ED7418 0:51f1ef89ec7b 28
ED7418 0:51f1ef89ec7b 29 #include "lwipNetTcpSocket.h"
ED7418 0:51f1ef89ec7b 30 #include "lwipNetUdpSocket.h"
ED7418 0:51f1ef89ec7b 31 #include "lwipNetDnsRequest.h"
ED7418 0:51f1ef89ec7b 32
ED7418 0:51f1ef89ec7b 33 #include "netCfg.h"
ED7418 0:51f1ef89ec7b 34 #if NET_LWIP_STACK
ED7418 0:51f1ef89ec7b 35
ED7418 0:51f1ef89ec7b 36 //See doc/rawapi.txt for details
ED7418 0:51f1ef89ec7b 37
ED7418 0:51f1ef89ec7b 38 LwipNetIf::LwipNetIf() : NetIf(), m_tcpTimer(), m_dnsTimer(), m_init(false)
ED7418 0:51f1ef89ec7b 39 {
ED7418 0:51f1ef89ec7b 40
ED7418 0:51f1ef89ec7b 41 }
ED7418 0:51f1ef89ec7b 42
ED7418 0:51f1ef89ec7b 43
ED7418 0:51f1ef89ec7b 44 LwipNetIf::~LwipNetIf()
ED7418 0:51f1ef89ec7b 45 {
ED7418 0:51f1ef89ec7b 46
ED7418 0:51f1ef89ec7b 47 }
ED7418 0:51f1ef89ec7b 48
ED7418 0:51f1ef89ec7b 49 void LwipNetIf::init()
ED7418 0:51f1ef89ec7b 50 {
ED7418 0:51f1ef89ec7b 51 if(m_init)
ED7418 0:51f1ef89ec7b 52 return;
ED7418 0:51f1ef89ec7b 53 m_init=true;
ED7418 0:51f1ef89ec7b 54 lwip_init(); //init lwip, see init.c for details
ED7418 0:51f1ef89ec7b 55
ED7418 0:51f1ef89ec7b 56 //Setup Clocks
ED7418 0:51f1ef89ec7b 57 m_tcpTimer.start();
ED7418 0:51f1ef89ec7b 58 m_dnsTimer.start();
ED7418 0:51f1ef89ec7b 59 //m_tcpTicker.attach_us( tcp_tmr, TCP_TMR_INTERVAL * 1000 ); //TCP_TMR_INTERVAL = 250 ms in tcp_impl.h
ED7418 0:51f1ef89ec7b 60 //m_dnsTicker.attach_us( dns_tmr, DNS_TMR_INTERVAL * 1000 ); //DNS_TMR_INTERVAL = 1000 ms in dns.h
ED7418 0:51f1ef89ec7b 61 }
ED7418 0:51f1ef89ec7b 62
ED7418 0:51f1ef89ec7b 63 NetTcpSocket* LwipNetIf::tcpSocket() //Create a new tcp socket
ED7418 0:51f1ef89ec7b 64 {
ED7418 0:51f1ef89ec7b 65 return new LwipNetTcpSocket();
ED7418 0:51f1ef89ec7b 66 }
ED7418 0:51f1ef89ec7b 67
ED7418 0:51f1ef89ec7b 68 NetUdpSocket* LwipNetIf::udpSocket() //Create a new udp socket
ED7418 0:51f1ef89ec7b 69 {
ED7418 0:51f1ef89ec7b 70 return new LwipNetUdpSocket();
ED7418 0:51f1ef89ec7b 71 }
ED7418 0:51f1ef89ec7b 72
ED7418 0:51f1ef89ec7b 73 NetDnsRequest* LwipNetIf::dnsRequest(const char* hostname) //Create a new NetDnsRequest object
ED7418 0:51f1ef89ec7b 74 {
ED7418 0:51f1ef89ec7b 75 return new LwipNetDnsRequest(hostname);
ED7418 0:51f1ef89ec7b 76 }
ED7418 0:51f1ef89ec7b 77
ED7418 0:51f1ef89ec7b 78 NetDnsRequest* LwipNetIf::dnsRequest(Host* pHost) //Create a new NetDnsRequest object
ED7418 0:51f1ef89ec7b 79 {
ED7418 0:51f1ef89ec7b 80 return new LwipNetDnsRequest(pHost);
ED7418 0:51f1ef89ec7b 81 }
ED7418 0:51f1ef89ec7b 82
ED7418 0:51f1ef89ec7b 83 void LwipNetIf::poll()
ED7418 0:51f1ef89ec7b 84 {
ED7418 0:51f1ef89ec7b 85 if(m_init && m_tcpTimer.read_ms() >= TCP_TMR_INTERVAL)
ED7418 0:51f1ef89ec7b 86 {
ED7418 0:51f1ef89ec7b 87 m_tcpTimer.reset();
ED7418 0:51f1ef89ec7b 88 tcp_tmr(); //Poll LwIP
ED7418 0:51f1ef89ec7b 89 }
ED7418 0:51f1ef89ec7b 90 if(m_init && m_dnsTimer.read_ms() >= DNS_TMR_INTERVAL)
ED7418 0:51f1ef89ec7b 91 {
ED7418 0:51f1ef89ec7b 92 m_dnsTimer.reset();
ED7418 0:51f1ef89ec7b 93 dns_tmr();
ED7418 0:51f1ef89ec7b 94 }
ED7418 0:51f1ef89ec7b 95 //Do some stuff...
ED7418 0:51f1ef89ec7b 96 }
ED7418 0:51f1ef89ec7b 97
ED7418 0:51f1ef89ec7b 98 #endif