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
NetServices/if/ppp/PPPNetIf.h@0:51f1ef89ec7b, 2014-06-06 (annotated)
- Committer:
- ED7418
- Date:
- Fri Jun 06 09:06:03 2014 +0000
- Revision:
- 0:51f1ef89ec7b
06062014
Who changed what in which revision?
User | Revision | Line number | New 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 | /** \file |
ED7418 | 0:51f1ef89ec7b | 25 | PPP Generic network interface header file |
ED7418 | 0:51f1ef89ec7b | 26 | */ |
ED7418 | 0:51f1ef89ec7b | 27 | |
ED7418 | 0:51f1ef89ec7b | 28 | //This is a backend for PPP, using lwIP |
ED7418 | 0:51f1ef89ec7b | 29 | |
ED7418 | 0:51f1ef89ec7b | 30 | #ifndef PPPNETIF_H |
ED7418 | 0:51f1ef89ec7b | 31 | #define PPPNETIF_H |
ED7418 | 0:51f1ef89ec7b | 32 | |
ED7418 | 0:51f1ef89ec7b | 33 | #include "mbed.h" |
ED7418 | 0:51f1ef89ec7b | 34 | |
ED7418 | 0:51f1ef89ec7b | 35 | //For now, only a GPRS Modem is supported, |
ED7418 | 0:51f1ef89ec7b | 36 | //but we could easily split this class into a base class + two derived classes |
ED7418 | 0:51f1ef89ec7b | 37 | // (PPP over GPRS + PPP over Serial Modem) |
ED7418 | 0:51f1ef89ec7b | 38 | #include "drv/gprs/GPRSModem.h" |
ED7418 | 0:51f1ef89ec7b | 39 | #include "if/lwip/LwipNetIf.h" |
ED7418 | 0:51f1ef89ec7b | 40 | |
ED7418 | 0:51f1ef89ec7b | 41 | ///PPP connection error codes |
ED7418 | 0:51f1ef89ec7b | 42 | enum PPPErr |
ED7418 | 0:51f1ef89ec7b | 43 | { |
ED7418 | 0:51f1ef89ec7b | 44 | __PPP_MIN = -0xFFFF, |
ED7418 | 0:51f1ef89ec7b | 45 | PPP_MODEM, ///<AT error returned |
ED7418 | 0:51f1ef89ec7b | 46 | PPP_NETWORK, ///<Network is down |
ED7418 | 0:51f1ef89ec7b | 47 | PPP_PROTOCOL, ///<PPP Protocol error |
ED7418 | 0:51f1ef89ec7b | 48 | PPP_CLOSED, ///<Connection is closed |
ED7418 | 0:51f1ef89ec7b | 49 | PPP_OK = 0 ///<Success |
ED7418 | 0:51f1ef89ec7b | 50 | }; |
ED7418 | 0:51f1ef89ec7b | 51 | |
ED7418 | 0:51f1ef89ec7b | 52 | enum PPPStatus |
ED7418 | 0:51f1ef89ec7b | 53 | { |
ED7418 | 0:51f1ef89ec7b | 54 | PPP_CONNECTING, |
ED7418 | 0:51f1ef89ec7b | 55 | PPP_CONNECTED, |
ED7418 | 0:51f1ef89ec7b | 56 | PPP_DISCONNECTED, |
ED7418 | 0:51f1ef89ec7b | 57 | }; |
ED7418 | 0:51f1ef89ec7b | 58 | |
ED7418 | 0:51f1ef89ec7b | 59 | class PPPNetIf : public LwipNetIf |
ED7418 | 0:51f1ef89ec7b | 60 | { |
ED7418 | 0:51f1ef89ec7b | 61 | public: |
ED7418 | 0:51f1ef89ec7b | 62 | PPPNetIf(GPRSModem* pIf); |
ED7418 | 0:51f1ef89ec7b | 63 | virtual ~PPPNetIf(); |
ED7418 | 0:51f1ef89ec7b | 64 | |
ED7418 | 0:51f1ef89ec7b | 65 | #if 0 |
ED7418 | 0:51f1ef89ec7b | 66 | PPPErr open(Serial* pSerial); |
ED7418 | 0:51f1ef89ec7b | 67 | #endif |
ED7418 | 0:51f1ef89ec7b | 68 | |
ED7418 | 0:51f1ef89ec7b | 69 | PPPErr GPRSConnect(const char* apn, const char* userId, const char* password); //Connect using GPRS |
ED7418 | 0:51f1ef89ec7b | 70 | PPPErr ATConnect(const char* number); //Connect using a "classic" voice modem or GSM |
ED7418 | 0:51f1ef89ec7b | 71 | |
ED7418 | 0:51f1ef89ec7b | 72 | virtual void poll(); |
ED7418 | 0:51f1ef89ec7b | 73 | |
ED7418 | 0:51f1ef89ec7b | 74 | PPPErr disconnect(); |
ED7418 | 0:51f1ef89ec7b | 75 | |
ED7418 | 0:51f1ef89ec7b | 76 | #if 0 |
ED7418 | 0:51f1ef89ec7b | 77 | PPPErr close(); |
ED7418 | 0:51f1ef89ec7b | 78 | #endif |
ED7418 | 0:51f1ef89ec7b | 79 | |
ED7418 | 0:51f1ef89ec7b | 80 | protected: |
ED7418 | 0:51f1ef89ec7b | 81 | GPRSModem* m_pIf; |
ED7418 | 0:51f1ef89ec7b | 82 | |
ED7418 | 0:51f1ef89ec7b | 83 | private: |
ED7418 | 0:51f1ef89ec7b | 84 | void pppCallback(int errCode, void *arg); |
ED7418 | 0:51f1ef89ec7b | 85 | |
ED7418 | 0:51f1ef89ec7b | 86 | static void sPppCallback(void *ctx, int errCode, void *arg) //Callback from ppp.c |
ED7418 | 0:51f1ef89ec7b | 87 | { return ((PPPNetIf*)ctx)->pppCallback(errCode, arg); } |
ED7418 | 0:51f1ef89ec7b | 88 | |
ED7418 | 0:51f1ef89ec7b | 89 | bool m_connected; |
ED7418 | 0:51f1ef89ec7b | 90 | /*bool m_open;*/ |
ED7418 | 0:51f1ef89ec7b | 91 | volatile PPPStatus m_status; |
ED7418 | 0:51f1ef89ec7b | 92 | volatile int m_fd; //PPP Session descriptor |
ED7418 | 0:51f1ef89ec7b | 93 | |
ED7418 | 0:51f1ef89ec7b | 94 | //int m_id; |
ED7418 | 0:51f1ef89ec7b | 95 | |
ED7418 | 0:51f1ef89ec7b | 96 | uint8_t* m_buf; |
ED7418 | 0:51f1ef89ec7b | 97 | |
ED7418 | 0:51f1ef89ec7b | 98 | }; |
ED7418 | 0:51f1ef89ec7b | 99 | |
ED7418 | 0:51f1ef89ec7b | 100 | #endif |