Own fork of C027_Support

Dependents:   MbedSmartRestMain MbedSmartRestMain

Fork of C027_Support by u-blox

MDM.h

Committer:
mazgch
Date:
2014-03-17
Revision:
20:535ef78655df
Parent:
18:e5697801df29
Child:
24:0e287a85ac9e

File content as of revision 20:535ef78655df:

#pragma once 

#include "mbed.h"
#include "Pipe.h"
#include "SerialPipe.h"
#include "C027_PinNames.h"

#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(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