PHS module SMA-01 library. see: https://developer.mbed.org/users/phsfan/notebook/abitusbmodem/

Dependencies:   Socket lwip-sys lwip

Dependents:   AbitUSBModem_HTTPTest AbitUSBModem_MQTTTest AbitUSBModem_WebsocketTest AbitUSBModem_SMSTest

Fork of VodafoneUSBModem by mbed official

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PPPIPInterface.h Source File

PPPIPInterface.h

00001 /* PPPIPInterface.h */
00002 /* Copyright (C) 2012 mbed.org, MIT License
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00005  * and associated documentation files (the "Software"), to deal in the Software without restriction,
00006  * including without limitation the rights to use, copy, modify, merge, publish, distribute,
00007  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
00008  * furnished to do so, subject to the following conditions:
00009  *
00010  * The above copyright notice and this permission notice shall be included in all copies or
00011  * substantial portions of the Software.
00012  *
00013  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00014  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00015  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00016  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00017  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00018  */
00019 
00020 #ifndef PPPIPINTERFACE_H_
00021 #define PPPIPINTERFACE_H_
00022 
00023 #include "core/fwk.h"
00024 
00025 #include "LwIPInterface.h"
00026 
00027 #include "lwip/sio.h"
00028 #include "at/ATCommandsInterface.h"
00029 
00030 namespace rtos {
00031 class Semaphore;
00032 }
00033 using namespace rtos;
00034 
00035 /** Interface using PPP to connect to an IP-based network
00036  *
00037  */
00038 class PPPIPInterface : public LwIPInterface
00039 {
00040 public:
00041     PPPIPInterface(IOStream* pStream, IOStream* atStream, ATCommandsInterface* pIf, bool hangupViaATPort);
00042     ATCommandsInterface* m_pIf;
00043     virtual ~PPPIPInterface();
00044 
00045     int init(); //Init PPP-specific stuff, create the right bindings, etc
00046     int setup(const char* user, const char* pw); //Setup authentication
00047     
00048     // should the modem hangup via AT port or PPP port? true for AT port
00049     void setHangupViaATPort(bool val);
00050     virtual int connect();
00051     virtual int disconnect();
00052 
00053 private:
00054     int cleanupLink();
00055 
00056     static void linkStatusCb(void *ctx, int errCode, void *arg); //PPP link status
00057     Semaphore m_linkStatusSphre;
00058     int m_pppErrCode;
00059 
00060     IOStream* m_pStream; //Serial stream
00061     
00062     IOStream* m_atStream;
00063     bool m_streamAvail;
00064     
00065     // if this is true, then PPP connection must be terminated using AT virtual serial port 
00066     // this is usually because the ppp stream doesn't support +++ escape sequence
00067     bool m_hangupViaATPort;
00068     int m_pppd;
00069 
00070     friend u32_t sio_write(sio_fd_t fd, u8_t *data, u32_t len);
00071     friend u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len);
00072     friend void sio_read_abort(sio_fd_t fd);
00073 };
00074 
00075 #endif /* PPPIPINTERFACE_H_ */