SMS Scheduler that will automatically send and receive text messages using the Enfora 1308 GSM Modem. Please note that it uses a modified NetServices library and to set the baud rate for the GSM Modem to 19.2K.

Dependencies:   mbed

Committer:
mafischl
Date:
Thu Oct 13 18:01:31 2011 +0000
Revision:
1:5a7cce9994a3
Parent:
0:d9266031f832

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mafischl 0:d9266031f832 1
mafischl 0:d9266031f832 2 /*
mafischl 0:d9266031f832 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
mafischl 0:d9266031f832 4
mafischl 0:d9266031f832 5 Permission is hereby granted, free of charge, to any person obtaining a copy
mafischl 0:d9266031f832 6 of this software and associated documentation files (the "Software"), to deal
mafischl 0:d9266031f832 7 in the Software without restriction, including without limitation the rights
mafischl 0:d9266031f832 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
mafischl 0:d9266031f832 9 copies of the Software, and to permit persons to whom the Software is
mafischl 0:d9266031f832 10 furnished to do so, subject to the following conditions:
mafischl 0:d9266031f832 11
mafischl 0:d9266031f832 12 The above copyright notice and this permission notice shall be included in
mafischl 0:d9266031f832 13 all copies or substantial portions of the Software.
mafischl 0:d9266031f832 14
mafischl 0:d9266031f832 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
mafischl 0:d9266031f832 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
mafischl 0:d9266031f832 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
mafischl 0:d9266031f832 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
mafischl 0:d9266031f832 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
mafischl 0:d9266031f832 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
mafischl 0:d9266031f832 21 THE SOFTWARE.
mafischl 0:d9266031f832 22 */
mafischl 0:d9266031f832 23
mafischl 0:d9266031f832 24 #ifndef SERIALBUF_H
mafischl 0:d9266031f832 25 #define SERIALBUF_H
mafischl 0:d9266031f832 26
mafischl 0:d9266031f832 27 #include "mbed.h"
mafischl 0:d9266031f832 28 #include "netCfg.h"
mafischl 0:d9266031f832 29 #if NET_USB_SERIAL
mafischl 0:d9266031f832 30 #include "drv/serial/usb/UsbSerial.h"
mafischl 0:d9266031f832 31 #endif
mafischl 0:d9266031f832 32
mafischl 0:d9266031f832 33 class SerialCircularBuf
mafischl 0:d9266031f832 34 {
mafischl 0:d9266031f832 35 public:
mafischl 0:d9266031f832 36 SerialCircularBuf(int len);
mafischl 0:d9266031f832 37 ~SerialCircularBuf();
mafischl 0:d9266031f832 38
mafischl 0:d9266031f832 39 int room();
mafischl 0:d9266031f832 40 int len();
mafischl 0:d9266031f832 41
mafischl 0:d9266031f832 42 void write(char c);
mafischl 0:d9266031f832 43 char read();
mafischl 0:d9266031f832 44
mafischl 0:d9266031f832 45 void setReadMode(bool readMode); //If true, keeps chars in buf when read, false by default
mafischl 0:d9266031f832 46 void flushRead(); //Delete chars that have been read & return chars len (only useful with readMode = true)
mafischl 0:d9266031f832 47 void resetRead(); //Go back to initial read position & return chars len (only useful with readMode = true)
mafischl 0:d9266031f832 48
mafischl 0:d9266031f832 49 private:
mafischl 0:d9266031f832 50 char* m_buf;
mafischl 0:d9266031f832 51 int m_len;
mafischl 0:d9266031f832 52
mafischl 0:d9266031f832 53 volatile char* m_pReadStart;
mafischl 0:d9266031f832 54 volatile char* m_pRead;
mafischl 0:d9266031f832 55 volatile char* m_pWrite;
mafischl 0:d9266031f832 56 volatile bool m_readMode;
mafischl 0:d9266031f832 57 };
mafischl 0:d9266031f832 58
mafischl 0:d9266031f832 59 class SerialBuf
mafischl 0:d9266031f832 60 {
mafischl 0:d9266031f832 61 public:
mafischl 0:d9266031f832 62 SerialBuf(int len); //Buffer length
mafischl 0:d9266031f832 63 virtual ~SerialBuf();
mafischl 0:d9266031f832 64
mafischl 0:d9266031f832 65 void attach(Serial* pSerial);
mafischl 0:d9266031f832 66 void detach();
mafischl 0:d9266031f832 67
mafischl 0:d9266031f832 68 #if NET_USB_SERIAL
mafischl 0:d9266031f832 69 void attach(UsbSerial* pUsbSerial);
mafischl 0:d9266031f832 70 #endif
mafischl 0:d9266031f832 71
mafischl 0:d9266031f832 72 //Really useful for debugging
mafischl 0:d9266031f832 73 char getc();
mafischl 0:d9266031f832 74 void putc(char c);
mafischl 0:d9266031f832 75 bool readable();
mafischl 0:d9266031f832 76 bool writeable();
mafischl 0:d9266031f832 77 /*protected:*/
mafischl 0:d9266031f832 78 void setReadMode(bool readMode); //If true, keeps chars in buf when read, false by default
mafischl 0:d9266031f832 79 void flushRead(); //Delete chars that have been read & return chars len (only useful with readMode = true)
mafischl 0:d9266031f832 80 void resetRead(); //Go back to initial read position & return chars len (only useful with readMode = true)
mafischl 0:d9266031f832 81
mafischl 0:d9266031f832 82 private:
mafischl 0:d9266031f832 83 void onRxInterrupt(); //Callback from m_pSerial
mafischl 0:d9266031f832 84 void onTxInterrupt(); //Callback from m_pSerial
mafischl 0:d9266031f832 85
mafischl 0:d9266031f832 86 SerialCircularBuf m_rxBuf;
mafischl 0:d9266031f832 87 SerialCircularBuf m_txBuf;
mafischl 0:d9266031f832 88
mafischl 0:d9266031f832 89 Serial* m_pSerial; //Not owned
mafischl 0:d9266031f832 90
mafischl 0:d9266031f832 91 #if NET_USB_SERIAL
mafischl 0:d9266031f832 92 //USB Serial Impl
mafischl 0:d9266031f832 93 UsbSerial* m_pUsbSerial; //Not owned
mafischl 0:d9266031f832 94 //Ticker m_usbTick;
mafischl 0:d9266031f832 95 #endif
mafischl 0:d9266031f832 96 };
mafischl 0:d9266031f832 97
mafischl 0:d9266031f832 98
mafischl 0:d9266031f832 99 #endif