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 MTSSERIALFLOWCONTROL_H
jengbrecht 0:563b70517320 18 #define MTSSERIALFLOWCONTROL_H
jengbrecht 0:563b70517320 19
jengbrecht 0:563b70517320 20 #include "mbed.h"
jengbrecht 83:9813f9b8ee68 21 #include "MTSSerial.h"
jengbrecht 83:9813f9b8ee68 22
mfiore 2:8d3ea0dfce39 23
jengbrecht 77:d7b14688a704 24 namespace mts
jengbrecht 77:d7b14688a704 25 {
mfiore 39:6e94520a3217 26
jengbrecht 83:9813f9b8ee68 27 /** This class derives from MTSBufferedIO/MTSSerial and provides a buffered wrapper to the
jengbrecht 45:40745c2036cf 28 * standard mbed Serial class along with generic RTS/CTS HW flow control. Since it
jengbrecht 45:40745c2036cf 29 * depends only on the mbed Serial, DigitalOut and InterruptIn classes for accessing
jengbrecht 45:40745c2036cf 30 * the serial data, this class is inherently portable accross different mbed platforms
jengbrecht 45:40745c2036cf 31 * and provides HW flow control even when not natively supported by the processors
jengbrecht 83:9813f9b8ee68 32 * serial port. If HW flow control is not needed, use MTSSerial instead. It should also
jengbrecht 83:9813f9b8ee68 33 * be noted that the RTS/CTS functionality in this class is implemented as a DTE device.
jengbrecht 45:40745c2036cf 34 */
jengbrecht 83:9813f9b8ee68 35 class MTSSerialFlowControl : public MTSSerial
jengbrecht 0:563b70517320 36 {
jengbrecht 0:563b70517320 37 public:
jengbrecht 45:40745c2036cf 38 /** Creates a new MTSSerialFlowControl object that can be used to talk to an mbed serial
jengbrecht 36:bb6b293c7495 39 * port through internal SW buffers. Note that this class also adds the ability to use
jengbrecht 83:9813f9b8ee68 40 * RTS/CTS HW Flow Conrtol through and standard mbed DigitalIn and DigitalOut pins.
jengbrecht 83:9813f9b8ee68 41 * The RTS and CTS functionality assumes this is a DTE device.
jengbrecht 36:bb6b293c7495 42 *
jengbrecht 45:40745c2036cf 43 * @param TXD the transmit data pin on the desired mbed serial interface.
jengbrecht 45:40745c2036cf 44 * @param RXD the receive data pin on the desired mbed serial interface.
jengbrecht 83:9813f9b8ee68 45 * @param RTS the DigitalOut pin that RTS will be attached to. (DTE)
jengbrecht 83:9813f9b8ee68 46 * @param CTS the DigitalIn pin that CTS will be attached to. (DTE)
jengbrecht 36:bb6b293c7495 47 * @param txBufferSize the size in bytes of the internal SW transmit buffer. The
jengbrecht 36:bb6b293c7495 48 * default is 64 bytes.
jengbrecht 36:bb6b293c7495 49 * @param rxBufferSize the size in bytes of the internal SW receive buffer. The
jengbrecht 36:bb6b293c7495 50 * default is 64 bytes.
jengbrecht 36:bb6b293c7495 51 * @param name an optional name for the serial port. The default is blank.
jengbrecht 36:bb6b293c7495 52 */
sgodinez 86:186bbf974c7c 53 MTSSerialFlowControl(PinName TXD, PinName RXD, PinName RTS, PinName CTS, int txBufSize = 64, int rxBufSize = 64);
jengbrecht 36:bb6b293c7495 54
jengbrecht 36:bb6b293c7495 55 /** Destructs an MTSSerialFlowControl object and frees all related resources,
jengbrecht 36:bb6b293c7495 56 * including internal buffers.
jengbrecht 36:bb6b293c7495 57 */
jengbrecht 0:563b70517320 58 ~MTSSerialFlowControl();
sgodinez 101:27bb34e23304 59
sgodinez 101:27bb34e23304 60 /** This method clears all the data from the internal Rx or read buffer.
sgodinez 101:27bb34e23304 61 */
sgodinez 101:27bb34e23304 62 virtual void rxClear();
jengbrecht 36:bb6b293c7495 63
jengbrecht 0:563b70517320 64 private:
jengbrecht 77:d7b14688a704 65 void notifyStartSending(); // Used to set cts start signal
jengbrecht 77:d7b14688a704 66 void notifyStopSending(); // Used to set cts stop signal
sgodinez 78:ef3ee53cf5df 67
sgodinez 78:ef3ee53cf5df 68 //This device acts as a DTE
sgodinez 101:27bb34e23304 69 bool rxReadyFlag; //Tracks state change for rts signaling
sgodinez 86:186bbf974c7c 70 DigitalOut rts; // Used to tell DCE to send or not send data
sgodinez 86:186bbf974c7c 71 DigitalIn cts; // Used to check if DCE is ready for data
jengbrecht 45:40745c2036cf 72 int highThreshold; // High water mark for setting cts to stop
jengbrecht 45:40745c2036cf 73 int lowThreshold; // Low water mark for setting cts to start
jengbrecht 36:bb6b293c7495 74
jengbrecht 45:40745c2036cf 75 virtual void handleRead(); // Method for handling data to be read
jengbrecht 45:40745c2036cf 76 virtual void handleWrite(); // Method for handling data to be written
jengbrecht 0:563b70517320 77 };
mfiore 2:8d3ea0dfce39 78
mfiore 39:6e94520a3217 79 }
mfiore 39:6e94520a3217 80
kranjan 141:571e0ef6c8dc 81 #endif /* MTSSERIALFLOWCONTROL */