Support for LISA-N101

Fork of C027_Support by u-blox

This is a variant of the C027 driver code for the C027N version, i.e. the one with the Neul/Huawei/u-blox Cellular Internet of Things module on board. The AT command interface for this module is entirely different to the AT interface for the other u-blox modules, hence this fork of the driver. Work is underway to rearchitect the original C027 driver so that a merge can be done.

GPS.h

Committer:
mazgch
Date:
2013-10-25
Revision:
4:c959dd4c5fe8
Parent:
3:c7cd4887560d
Child:
9:e7a5959ffae1

File content as of revision 4:c959dd4c5fe8:

#pragma once 

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

class GPSParser
{
public:
    #define WAIT      -1
    #define NOT_FOUND  0
    
    #define UBX         0x100000
    #define NMEA        0x200000
    #define LENGTH(x)   (x & 0x00FFFF)
    #define PROTOCOL(x) (x & 0xFF0000)

    virtual int getMessage(char* buf, int len) = 0; 
    virtual int send(const char* buf, int len);
    virtual int sendNmea(const char* buf, int len);
    virtual int sendUbx(unsigned char cls, unsigned char id, const void* buf, int len);
    
    static const char* findNmeaItemPos(int ix, const char* start, const char* end);
    static bool getNmeaItem(int ix, char* buf, int len, double& val);
    static bool getNmeaItem(int ix, char* buf, int len, int& val, int base/*=10*/);
    static bool getNmeaItem(int ix, char* buf, int len, char& val);
protected:
    static int _getMessage(Pipe<char>* pipe, char* buf, int len);
    static int _parseNmea(Pipe<char>* pipe, int len);
    static int _parseUbx(Pipe<char>* pipe, int len);
    virtual int _send(const void* buf, int len) = 0;
    static const char toHex[16];
};

class GPSSerial : public Serial, public GPSParser
{
public:
    GPSSerial(PinName tx = GPSTXD, PinName rx = GPSRXD, int baudrate = GPSBAUD);
    virtual ~GPSSerial(void);
    
    virtual int getMessage(char* buf, int len);
protected:
    void serialRxIrq(void);
    virtual char next(void);
    virtual int _send(const void* buf, int len);
    Pipe<char> _pipe;
};

class GPSI2C : public I2C, public GPSParser
{
public: 
    GPSI2C(PinName sda = GPSSDA, PinName scl = GPSSCL);
    bool detect(void);
    
    virtual int getMessage(char* buf, int len);
    virtual int send(const char* buf, int len);
    virtual int sendNmea(const char* buf, int len);
    virtual int sendUbx(unsigned char cls, unsigned char id, const void* buf, int len);
protected:
    virtual char next(void);
    virtual int _send(const void* buf, int len);
    int _get(char* buf, int len);                 // read the NMEA or UBX stream
    
    Pipe<char> _pipe; 
    bool found;
    static const char REGLEN;
    static const char REGSTREAM;
};