A library for talking to Multi-Tech's Cellular SocketModem Devices.

Dependents:   M2X_dev axeda_wrapper_dev MTS_M2x_Example1 MTS_Cellular_Connect_Example ... more

Committer:
mfiore
Date:
Tue Sep 02 18:38:55 2014 +0000
Revision:
152:9a2c7ed27744
Parent:
141:571e0ef6c8dc
Wifi: fix compatibility break with old shields by checking for both old and new style responses to "show connection" command

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kranjan 141:571e0ef6c8dc 1 /* Universal Socket Modem Interface Library
kranjan 141:571e0ef6c8dc 2 * Copyright (c) 2013 Multi-Tech Systems
kranjan 141:571e0ef6c8dc 3 *
kranjan 141:571e0ef6c8dc 4 * Licensed under the Apache License, Version 2.0 (the "License");
kranjan 141:571e0ef6c8dc 5 * you may not use this file except in compliance with the License.
kranjan 141:571e0ef6c8dc 6 * You may obtain a copy of the License at
kranjan 141:571e0ef6c8dc 7 *
kranjan 141:571e0ef6c8dc 8 * http://www.apache.org/licenses/LICENSE-2.0
kranjan 141:571e0ef6c8dc 9 *
kranjan 141:571e0ef6c8dc 10 * Unless required by applicable law or agreed to in writing, software
kranjan 141:571e0ef6c8dc 11 * distributed under the License is distributed on an "AS IS" BASIS,
kranjan 141:571e0ef6c8dc 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
kranjan 141:571e0ef6c8dc 13 * See the License for the specific language governing permissions and
kranjan 141:571e0ef6c8dc 14 * limitations under the License.
kranjan 141:571e0ef6c8dc 15 */
kranjan 141:571e0ef6c8dc 16
jengbrecht 0:563b70517320 17 #ifndef MTSSERIAL_H
jengbrecht 0:563b70517320 18 #define MTSSERIAL_H
jengbrecht 0:563b70517320 19
jengbrecht 0:563b70517320 20 #include "mbed.h"
jengbrecht 0:563b70517320 21 #include "MTSBufferedIO.h"
jengbrecht 0:563b70517320 22
jengbrecht 83:9813f9b8ee68 23 namespace mts
jengbrecht 83:9813f9b8ee68 24 {
jengbrecht 83:9813f9b8ee68 25
jengbrecht 36:bb6b293c7495 26 /** This class derives from MTSBufferedIO and provides a buffered wrapper to the
jengbrecht 45:40745c2036cf 27 * standard mbed Serial class. Since it depends only on the mbed Serial class for
jengbrecht 45:40745c2036cf 28 * accessing serial data, this class is inherently portable accross different mbed
jengbrecht 45:40745c2036cf 29 * platforms.
jengbrecht 36:bb6b293c7495 30 */
jengbrecht 0:563b70517320 31 class MTSSerial : public MTSBufferedIO
jengbrecht 0:563b70517320 32 {
jengbrecht 0:563b70517320 33 public:
jengbrecht 45:40745c2036cf 34 /** Creates a new MTSSerial object that can be used to talk to an mbed serial port
jengbrecht 36:bb6b293c7495 35 * through internal SW buffers.
jengbrecht 36:bb6b293c7495 36 *
jengbrecht 45:40745c2036cf 37 * @param TXD the transmit data pin on the desired mbed Serial interface.
jengbrecht 45:40745c2036cf 38 * @param RXD the receive data pin on the desired mbed Serial interface.
jengbrecht 36:bb6b293c7495 39 * @param txBufferSize the size in bytes of the internal SW transmit buffer. The
jengbrecht 36:bb6b293c7495 40 * default is 64 bytes.
jengbrecht 36:bb6b293c7495 41 * @param rxBufferSize the size in bytes of the internal SW receive buffer. The
jengbrecht 36:bb6b293c7495 42 * default is 64 bytes.
jengbrecht 36:bb6b293c7495 43 */
jengbrecht 120:3051dd49fa3a 44 MTSSerial(PinName TXD, PinName RXD, int txBufferSize = 256, int rxBufferSize = 256);
jengbrecht 36:bb6b293c7495 45
jengbrecht 36:bb6b293c7495 46 /** Destructs an MTSSerial object and frees all related resources, including
jengbrecht 36:bb6b293c7495 47 * internal buffers.
jengbrecht 36:bb6b293c7495 48 */
jengbrecht 0:563b70517320 49 ~MTSSerial();
jengbrecht 45:40745c2036cf 50
jengbrecht 36:bb6b293c7495 51 /** This method is used to the set the baud rate of the serial port.
jengbrecht 45:40745c2036cf 52 *
jengbrecht 45:40745c2036cf 53 * @param baudrate the baudrate in bps as an int. The default is 9600 bps.
jengbrecht 36:bb6b293c7495 54 */
jengbrecht 0:563b70517320 55 void baud(int baudrate);
jengbrecht 0:563b70517320 56
jengbrecht 45:40745c2036cf 57 /** This method sets the transmission format used by the serial port.
jengbrecht 45:40745c2036cf 58 *
jengbrecht 45:40745c2036cf 59 * @param bits the number of bits in a word (5-8; default = 8)
jengbrecht 45:40745c2036cf 60 * @param parity the parity used (SerialBase::None, SerialBase::Odd, SerialBase::Even,
jengbrecht 45:40745c2036cf 61 * SerialBase::Forced1, SerialBase::Forced0; default = SerialBase::None)
jengbrecht 45:40745c2036cf 62 * @param stop the number of stop bits (1 or 2; default = 1)
jengbrecht 36:bb6b293c7495 63 */
mfiore 51:d22d3d87391f 64 void format(int bits=8, SerialBase::Parity parity=mbed::SerialBase::None, int stop_bits=1);
jengbrecht 0:563b70517320 65
jengbrecht 83:9813f9b8ee68 66 protected:
sgodinez 86:186bbf974c7c 67 Serial serial; // Internal mbed Serial object
jengbrecht 83:9813f9b8ee68 68
jengbrecht 0:563b70517320 69 private:
jengbrecht 45:40745c2036cf 70 virtual void handleWrite(); // Method for handling data to be written
jengbrecht 45:40745c2036cf 71 virtual void handleRead(); // Method for handling data to be read
jengbrecht 0:563b70517320 72 };
jengbrecht 0:563b70517320 73
mfiore 39:6e94520a3217 74 }
mfiore 39:6e94520a3217 75
kranjan 141:571e0ef6c8dc 76 #endif /* MTSSERIAL_H */