support library for C027 helper functions for Buffer Pipes, Buffered Serial Port (rtos capable) and GPS parsing. It includes modem APIs for USSD, SMS and Sockets.

Dependents:   HTTPClient_Cellular_HelloWorld Cellular_HelloMQTT MbedSmartRestMain Car_Bon_car_module ... more

This library is intended to be used with u-blox products such as the C027 or a shield with u-blox cellular and GPS modules like the cellular and positioning shield from Embedded Artist.

For 2G/GSM and 3G/UMTS you need to:

  • have a SIM card and know its PIN number
  • need to know you network operators APN setting These setting should be passed to the connect or init and join functions. You can also extend the APN database in MDMAPN.h.

For CDMA products you need to make sure that you have provisioned and activated the modem with either Sprint or Verizon.

Committer:
mazgch
Date:
Mon Mar 24 07:38:05 2014 +0000
Revision:
19:2b5d097ca15d
Parent:
18:e5697801df29
Child:
35:9275215a3a5b
prepare for native C027 platform support; add api to get lat/lon; better separation of mdm libarary from serial

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mazgch 9:e7a5959ffae1 1 #pragma once
mazgch 9:e7a5959ffae1 2
mazgch 9:e7a5959ffae1 3 #include "SerialPipe.h"
mazgch 9:e7a5959ffae1 4
mazgch 15:5eda64e5b9d1 5 SerialPipe::SerialPipe(PinName tx, PinName rx, int rxSize, int txSize)
mazgch 15:5eda64e5b9d1 6 : _SerialPipeBase(tx,rx), _pipeRx(rxSize), _pipeTx(txSize)
mazgch 9:e7a5959ffae1 7 {
mazgch 9:e7a5959ffae1 8 attach(this, &SerialPipe::rxIrqBuf, RxIrq);
mazgch 9:e7a5959ffae1 9 attach(this, &SerialPipe::txIrqBuf, TxIrq);
mazgch 9:e7a5959ffae1 10 }
mazgch 9:e7a5959ffae1 11
mazgch 19:2b5d097ca15d 12
mazgch 19:2b5d097ca15d 13 #if DEVICE_SERIAL_FC
mazgch 17:296d94a006b4 14 SerialPipe::SerialPipe(PinName tx, PinName rx, PinName rts, PinName cts,
mazgch 17:296d94a006b4 15 int rxSize, int txSize)
mazgch 17:296d94a006b4 16 : _SerialPipeBase(tx,rx), _pipeRx(rxSize), _pipeTx(txSize)
mazgch 17:296d94a006b4 17 {
mazgch 17:296d94a006b4 18 attach(this, &SerialPipe::rxIrqBuf, RxIrq);
mazgch 17:296d94a006b4 19 attach(this, &SerialPipe::txIrqBuf, TxIrq);
mazgch 17:296d94a006b4 20
mazgch 17:296d94a006b4 21 set_flow_control(RTSCTS, rts, cts);
mazgch 17:296d94a006b4 22 }
mazgch 19:2b5d097ca15d 23 #endif
mazgch 17:296d94a006b4 24
mazgch 9:e7a5959ffae1 25 SerialPipe::~SerialPipe(void)
mazgch 9:e7a5959ffae1 26 {
mazgch 9:e7a5959ffae1 27 attach(NULL, RxIrq);
mazgch 9:e7a5959ffae1 28 attach(NULL, TxIrq);
mazgch 9:e7a5959ffae1 29 }
mazgch 9:e7a5959ffae1 30
mazgch 9:e7a5959ffae1 31 // tx channel
mazgch 13:e2446fcdc246 32 int SerialPipe::writeable(void)
mazgch 13:e2446fcdc246 33 {
mazgch 13:e2446fcdc246 34 return _pipeTx.free();
mazgch 13:e2446fcdc246 35 }
mazgch 13:e2446fcdc246 36
mazgch 13:e2446fcdc246 37 int SerialPipe::putc(int c)
mazgch 13:e2446fcdc246 38 {
mazgch 15:5eda64e5b9d1 39 c = _pipeTx.putc(c);
mazgch 15:5eda64e5b9d1 40 txStart();
mazgch 15:5eda64e5b9d1 41 return c;
mazgch 13:e2446fcdc246 42 }
mazgch 13:e2446fcdc246 43
mazgch 13:e2446fcdc246 44 int SerialPipe::put(const void* buffer, int length, bool blocking)
mazgch 9:e7a5959ffae1 45 {
mazgch 13:e2446fcdc246 46 int count = length;
mazgch 13:e2446fcdc246 47 const char* ptr = (const char*)buffer;
mazgch 15:5eda64e5b9d1 48 if (count)
mazgch 9:e7a5959ffae1 49 {
mazgch 15:5eda64e5b9d1 50 do
mazgch 15:5eda64e5b9d1 51 {
mazgch 15:5eda64e5b9d1 52 int written = _pipeTx.put(ptr, count, false);
mazgch 15:5eda64e5b9d1 53 ptr += written;
mazgch 15:5eda64e5b9d1 54 count -= written;
mazgch 15:5eda64e5b9d1 55 txStart();
mazgch 15:5eda64e5b9d1 56 }
mazgch 15:5eda64e5b9d1 57 while (count && blocking);
mazgch 9:e7a5959ffae1 58 }
mazgch 13:e2446fcdc246 59 return (length - count);
mazgch 13:e2446fcdc246 60 }
mazgch 13:e2446fcdc246 61
mazgch 9:e7a5959ffae1 62 void SerialPipe::txIrqBuf(void)
mazgch 9:e7a5959ffae1 63 {
mazgch 15:5eda64e5b9d1 64 while (_SerialPipeBase::writeable() && _pipeTx.readable())
mazgch 11:b084552b03fe 65 {
mazgch 13:e2446fcdc246 66 char c = _pipeTx.getc();
mazgch 15:5eda64e5b9d1 67 _SerialPipeBase::_base_putc(c);
mazgch 11:b084552b03fe 68 }
mazgch 9:e7a5959ffae1 69 }
mazgch 9:e7a5959ffae1 70
mazgch 13:e2446fcdc246 71 void SerialPipe::txStart(void)
mazgch 13:e2446fcdc246 72 {
mazgch 13:e2446fcdc246 73 __disable_irq();
mazgch 13:e2446fcdc246 74 txIrqBuf();
mazgch 13:e2446fcdc246 75 __enable_irq();
mazgch 13:e2446fcdc246 76 }
mazgch 13:e2446fcdc246 77
mazgch 9:e7a5959ffae1 78 // rx channel
mazgch 9:e7a5959ffae1 79 int SerialPipe::readable(void)
mazgch 9:e7a5959ffae1 80 {
mazgch 9:e7a5959ffae1 81 return _pipeRx.readable();
mazgch 9:e7a5959ffae1 82 }
mazgch 9:e7a5959ffae1 83
mazgch 9:e7a5959ffae1 84 int SerialPipe::getc(void)
mazgch 9:e7a5959ffae1 85 {
mazgch 15:5eda64e5b9d1 86 if (!_pipeRx.readable())
mazgch 15:5eda64e5b9d1 87 return EOF;
mazgch 15:5eda64e5b9d1 88 return _pipeRx.getc();
mazgch 13:e2446fcdc246 89 }
mazgch 13:e2446fcdc246 90
mazgch 13:e2446fcdc246 91 int SerialPipe::get(void* buffer, int length, bool blocking)
mazgch 13:e2446fcdc246 92 {
mazgch 13:e2446fcdc246 93 return _pipeRx.get((char*)buffer,length,blocking);
mazgch 13:e2446fcdc246 94 }
mazgch 13:e2446fcdc246 95
mazgch 9:e7a5959ffae1 96 void SerialPipe::rxIrqBuf(void)
mazgch 9:e7a5959ffae1 97 {
mazgch 15:5eda64e5b9d1 98 while (_SerialPipeBase::readable())
mazgch 9:e7a5959ffae1 99 {
mazgch 15:5eda64e5b9d1 100 char c = _SerialPipeBase::_base_getc();
mazgch 9:e7a5959ffae1 101 if (_pipeRx.writeable())
mazgch 13:e2446fcdc246 102 _pipeRx.putc(c);
mazgch 9:e7a5959ffae1 103 else
mazgch 9:e7a5959ffae1 104 /* overflow */;
mazgch 9:e7a5959ffae1 105 }
mazgch 9:e7a5959ffae1 106 }
mazgch 9:e7a5959ffae1 107