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