vvvv
Diff: MDM.h
- Revision:
- 18:e5697801df29
- Parent:
- 17:296d94a006b4
- Child:
- 19:2b5d097ca15d
- Child:
- 20:535ef78655df
--- a/MDM.h Fri Jan 31 09:49:51 2014 +0000 +++ b/MDM.h Fri Mar 14 13:07:48 2014 +0000 @@ -1,14 +1,60 @@ #pragma once #include "mbed.h" +#include "Pipe.h" +#include "SerialPipe.h" #include "C027_PinNames.h" -class MDMSerial : public RawSerial +#define RX_SIZE 256 +#define TX_SIZE 128 + +class MDMParser +{ +public: + #define WAIT -1 + #define NOT_FOUND 0 + + #define LENGTH(x) (x & 0x00FFFF) +// #define PROTOCOL(x) (x & 0xFF0000) + virtual int getLine(char* buf, int len) = 0; + virtual int getResp(char* buf, int len) = 0; + virtual int send(const char* buf, int len); + +protected: + static int _getLine(Pipe<char>* pipe, char* buffer, int length); + static int _getResp(Pipe<char>* pipe, char* buffer, int length); + virtual int _send(const void* buf, int len) = 0; +}; + +// ----------------------------------------------------------------------- + +class MDMSerial : public SerialPipe, public MDMParser { public: - MDMSerial() : RawSerial(MDMTXD,MDMRXD) - { - baud(MDMBAUD); - set_flow_control(SerialBase::RTSCTS, MDMRTS, MDMCTS); - } + MDMSerial(PinName tx = MDMTXD, PinName rx = MDMRXD, int baudrate = MDMBAUD, + int rxSize = RX_SIZE, int txSize = TX_SIZE); + MDMSerial(PinName tx = MDMTXD, PinName rx = MDMRXD, int baudrate = MDMBAUD, + PinName rts = MDMRTS, PinName cts = MDMCTS, + int rxSize = RX_SIZE, int txSize = TX_SIZE); + virtual int getLine(char* buffer, int length); + virtual int getResp(char* buffer, int length); +protected: + virtual int _send(const void* buf, int len); }; + +// ----------------------------------------------------------------------- + +#define HAVE_MDMUSB +#ifdef HAVE_MDMUSB +class MDMUsb : /*public UsbSerial,*/ public MDMParser +{ +public: + MDMUsb(void); + virtual int getLine(char* buffer, int length); + virtual int getResp(char* buffer, int length); +protected: + virtual int _send(const void* buf, int len); +}; +#endif + +