Berckvens Michiel & Basteyns Jonas

Dependencies:   DS1307 TextLCD mbed

Committer:
Michielber
Date:
Thu Dec 11 16:07:34 2014 +0000
Revision:
5:6878defcfeb9
Parent:
0:f615d151a72c
Project updated belastingslijn

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Michielber 0:f615d151a72c 1
Michielber 0:f615d151a72c 2 /*
Michielber 0:f615d151a72c 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
Michielber 0:f615d151a72c 4
Michielber 0:f615d151a72c 5 Permission is hereby granted, free of charge, to any person obtaining a copy
Michielber 0:f615d151a72c 6 of this software and associated documentation files (the "Software"), to deal
Michielber 0:f615d151a72c 7 in the Software without restriction, including without limitation the rights
Michielber 0:f615d151a72c 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Michielber 0:f615d151a72c 9 copies of the Software, and to permit persons to whom the Software is
Michielber 0:f615d151a72c 10 furnished to do so, subject to the following conditions:
Michielber 0:f615d151a72c 11
Michielber 0:f615d151a72c 12 The above copyright notice and this permission notice shall be included in
Michielber 0:f615d151a72c 13 all copies or substantial portions of the Software.
Michielber 0:f615d151a72c 14
Michielber 0:f615d151a72c 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Michielber 0:f615d151a72c 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Michielber 0:f615d151a72c 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Michielber 0:f615d151a72c 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Michielber 0:f615d151a72c 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Michielber 0:f615d151a72c 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Michielber 0:f615d151a72c 21 THE SOFTWARE.
Michielber 0:f615d151a72c 22 */
Michielber 0:f615d151a72c 23
Michielber 0:f615d151a72c 24 /** \file
Michielber 0:f615d151a72c 25 PPP Generic network interface header file
Michielber 0:f615d151a72c 26 */
Michielber 0:f615d151a72c 27
Michielber 0:f615d151a72c 28 //This is a backend for PPP, using lwIP
Michielber 0:f615d151a72c 29
Michielber 0:f615d151a72c 30 #ifndef PPPNETIF_H
Michielber 0:f615d151a72c 31 #define PPPNETIF_H
Michielber 0:f615d151a72c 32
Michielber 0:f615d151a72c 33 #include "mbed.h"
Michielber 0:f615d151a72c 34
Michielber 0:f615d151a72c 35 //For now, only a GPRS Modem is supported,
Michielber 0:f615d151a72c 36 //but we could easily split this class into a base class + two derived classes
Michielber 0:f615d151a72c 37 // (PPP over GPRS + PPP over Serial Modem)
Michielber 0:f615d151a72c 38 #include "drv/gprs/GPRSModem.h"
Michielber 0:f615d151a72c 39 #include "if/lwip/LwipNetIf.h"
Michielber 0:f615d151a72c 40
Michielber 0:f615d151a72c 41 ///PPP connection error codes
Michielber 0:f615d151a72c 42 enum PPPErr
Michielber 0:f615d151a72c 43 {
Michielber 0:f615d151a72c 44 __PPP_MIN = -0xFFFF,
Michielber 0:f615d151a72c 45 PPP_MODEM, ///<AT error returned
Michielber 0:f615d151a72c 46 PPP_NETWORK, ///<Network is down
Michielber 0:f615d151a72c 47 PPP_PROTOCOL, ///<PPP Protocol error
Michielber 0:f615d151a72c 48 PPP_CLOSED, ///<Connection is closed
Michielber 0:f615d151a72c 49 PPP_OK = 0 ///<Success
Michielber 0:f615d151a72c 50 };
Michielber 0:f615d151a72c 51
Michielber 0:f615d151a72c 52 enum PPPStatus
Michielber 0:f615d151a72c 53 {
Michielber 0:f615d151a72c 54 PPP_CONNECTING,
Michielber 0:f615d151a72c 55 PPP_CONNECTED,
Michielber 0:f615d151a72c 56 PPP_DISCONNECTED,
Michielber 0:f615d151a72c 57 };
Michielber 0:f615d151a72c 58
Michielber 0:f615d151a72c 59 class PPPNetIf : public LwipNetIf
Michielber 0:f615d151a72c 60 {
Michielber 0:f615d151a72c 61 public:
Michielber 0:f615d151a72c 62 PPPNetIf(GPRSModem* pIf);
Michielber 0:f615d151a72c 63 virtual ~PPPNetIf();
Michielber 0:f615d151a72c 64
Michielber 0:f615d151a72c 65 #if 0
Michielber 0:f615d151a72c 66 PPPErr open(Serial* pSerial);
Michielber 0:f615d151a72c 67 #endif
Michielber 0:f615d151a72c 68
Michielber 0:f615d151a72c 69 PPPErr GPRSConnect(const char* apn, const char* userId, const char* password); //Connect using GPRS
Michielber 0:f615d151a72c 70 PPPErr ATConnect(const char* number); //Connect using a "classic" voice modem or GSM
Michielber 0:f615d151a72c 71
Michielber 0:f615d151a72c 72 virtual void poll();
Michielber 0:f615d151a72c 73
Michielber 0:f615d151a72c 74 PPPErr disconnect();
Michielber 0:f615d151a72c 75
Michielber 0:f615d151a72c 76 #if 0
Michielber 0:f615d151a72c 77 PPPErr close();
Michielber 0:f615d151a72c 78 #endif
Michielber 0:f615d151a72c 79
Michielber 0:f615d151a72c 80 protected:
Michielber 0:f615d151a72c 81 GPRSModem* m_pIf;
Michielber 0:f615d151a72c 82
Michielber 0:f615d151a72c 83 private:
Michielber 0:f615d151a72c 84 void pppCallback(int errCode, void *arg);
Michielber 0:f615d151a72c 85
Michielber 0:f615d151a72c 86 static void sPppCallback(void *ctx, int errCode, void *arg) //Callback from ppp.c
Michielber 0:f615d151a72c 87 { return ((PPPNetIf*)ctx)->pppCallback(errCode, arg); }
Michielber 0:f615d151a72c 88
Michielber 0:f615d151a72c 89 bool m_connected;
Michielber 0:f615d151a72c 90 /*bool m_open;*/
Michielber 0:f615d151a72c 91 volatile PPPStatus m_status;
Michielber 0:f615d151a72c 92 volatile int m_fd; //PPP Session descriptor
Michielber 0:f615d151a72c 93
Michielber 0:f615d151a72c 94 //int m_id;
Michielber 0:f615d151a72c 95
Michielber 0:f615d151a72c 96 uint8_t* m_buf;
Michielber 0:f615d151a72c 97
Michielber 0:f615d151a72c 98 };
Michielber 0:f615d151a72c 99
Michielber 0:f615d151a72c 100 #endif