Add a bunch of APNs

Fork of C027_Support by Xinlei Cao

Committer:
mazgch
Date:
Fri Oct 25 08:47:22 2013 +0000
Revision:
2:b6012cd91657
Parent:
1:f41579f4e2ed
Child:
3:c7cd4887560d
GPS for Serial and I2c

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mazgch 1:f41579f4e2ed 1 #pragma once
mazgch 1:f41579f4e2ed 2
mazgch 2:b6012cd91657 3 #include "mbed.h"
mazgch 2:b6012cd91657 4 #include "Pipe.h"
mazgch 1:f41579f4e2ed 5 #include "SerialPipe.h"
mazgch 2:b6012cd91657 6 #include "C027_PinNames.h"
mazgch 2:b6012cd91657 7
mazgch 2:b6012cd91657 8 class GPSParser
mazgch 2:b6012cd91657 9 {
mazgch 2:b6012cd91657 10 public:
mazgch 2:b6012cd91657 11 #define WAIT -1
mazgch 2:b6012cd91657 12 #define NOT_FOUND 0
mazgch 2:b6012cd91657 13
mazgch 2:b6012cd91657 14 #define UBX 0x100000
mazgch 2:b6012cd91657 15 #define NMEA 0x200000
mazgch 2:b6012cd91657 16 #define LENGTH(x) (x & 0x00FFFF)
mazgch 2:b6012cd91657 17 #define PROTOCOL(x) (x & 0xFF0000)
mazgch 1:f41579f4e2ed 18
mazgch 2:b6012cd91657 19 virtual int getMessage(char* buf, int len) = 0;
mazgch 2:b6012cd91657 20 virtual int putNmea(const char* buf, int len) = 0;
mazgch 2:b6012cd91657 21 virtual int putUbx(const unsigned char cls, unsigned char id, unsigned char* buf, int len) = 0;
mazgch 2:b6012cd91657 22
mazgch 2:b6012cd91657 23 static const char* findNmeaItemPos(int ix, const char* start, const char* end);
mazgch 2:b6012cd91657 24 static bool getNmeaItem(int ix, char* buf, int len, double& val);
mazgch 2:b6012cd91657 25 static bool getNmeaItem(int ix, char* buf, int len, int& val, int base/*=10*/);
mazgch 2:b6012cd91657 26 static bool getNmeaItem(int ix, char* buf, int len, char& val);
mazgch 2:b6012cd91657 27 protected:
mazgch 2:b6012cd91657 28 static int _getMessage(Pipe<char>* pipe, char* buf, int len);
mazgch 2:b6012cd91657 29 static int _parseNmea(Pipe<char>* pipe, int len);
mazgch 2:b6012cd91657 30 static int _parseUbx(Pipe<char>* pipe, int len);
mazgch 2:b6012cd91657 31 static int _putNmea(Stream* stream, const char* buf, int len);
mazgch 2:b6012cd91657 32 static int _putUbx(Stream* stream, const unsigned char cls, unsigned char id, unsigned char* buf, int len);
mazgch 2:b6012cd91657 33 static const char toHex[16];
mazgch 2:b6012cd91657 34 };
mazgch 2:b6012cd91657 35
mazgch 2:b6012cd91657 36 class GPSSerial : public Serial, public GPSParser
mazgch 1:f41579f4e2ed 37 {
mazgch 1:f41579f4e2ed 38 public:
mazgch 2:b6012cd91657 39 GPSSerial(PinName tx = GPSTXD, PinName rx = GPSRXD, int baudrate = GPSBAUD);
mazgch 2:b6012cd91657 40 virtual ~GPSSerial(void);
mazgch 2:b6012cd91657 41
mazgch 2:b6012cd91657 42 virtual int getMessage(char* buf, int len);
mazgch 2:b6012cd91657 43 virtual int putNmea(const char* buf, int len)
mazgch 2:b6012cd91657 44 { return _putNmea(this, buf, len); }
mazgch 2:b6012cd91657 45 virtual int putUbx(const unsigned char cls, unsigned char id, unsigned char* buf, int len)
mazgch 2:b6012cd91657 46 { return _putUbx(this, cls, id, buf, len); }
mazgch 2:b6012cd91657 47 protected:
mazgch 2:b6012cd91657 48 void serialRxIrq(void);
mazgch 2:b6012cd91657 49 virtual char next(void) { return _pipe.next(); }
mazgch 2:b6012cd91657 50 Pipe<char> _pipe;
mazgch 1:f41579f4e2ed 51 };
mazgch 2:b6012cd91657 52
mazgch 2:b6012cd91657 53 class GPSI2C : public I2C, public GPSParser
mazgch 2:b6012cd91657 54 {
mazgch 2:b6012cd91657 55 public:
mazgch 2:b6012cd91657 56 GPSI2C(PinName sda = GPSSDA, PinName scl = GPSSCL);
mazgch 2:b6012cd91657 57 bool detect(void);
mazgch 2:b6012cd91657 58
mazgch 2:b6012cd91657 59 virtual int getMessage(char* buf, int len);
mazgch 2:b6012cd91657 60 //
mazgch 2:b6012cd91657 61 virtual int putNmea(const char* buf, int len)
mazgch 2:b6012cd91657 62 { return 0/*_putNmea(NULL, buf, len)*/; }
mazgch 2:b6012cd91657 63 virtual int putUbx(const unsigned char cls, unsigned char id, unsigned char* buf, int len)
mazgch 2:b6012cd91657 64 { return 0/*_putUbx(NULL, cls, id, buf, len)*/; }
mazgch 2:b6012cd91657 65 protected:
mazgch 2:b6012cd91657 66 virtual char next(void) { return _pipe.next(); }
mazgch 2:b6012cd91657 67 int _get(char* buf, int len); // read the NMEA or UBX stream
mazgch 2:b6012cd91657 68 int _put(const char* buf, int len); // Write the NMEA or UBX stream
mazgch 2:b6012cd91657 69
mazgch 2:b6012cd91657 70 Pipe<char> _pipe;
mazgch 2:b6012cd91657 71 bool found;
mazgch 2:b6012cd91657 72 static const char REGLEN;
mazgch 2:b6012cd91657 73 static const char REGSTREAM;
mazgch 2:b6012cd91657 74 };