PHS module SMA-01 library. see: https://developer.mbed.org/users/phsfan/notebook/abitusbmodem/

Dependencies:   Socket lwip-sys lwip

Dependents:   AbitUSBModem_HTTPTest AbitUSBModem_MQTTTest AbitUSBModem_WebsocketTest AbitUSBModem_SMSTest

Fork of VodafoneUSBModem by mbed official

/media/uploads/phsfan/sma01_003.png

Committer:
phsfan
Date:
Wed Feb 25 14:34:13 2015 +0000
Revision:
99:514e67a69ad6
Parent:
96:b50f5f795684
supported SMS

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 0:3b2f052c333b 1 /* USBSerialStream.h */
donatien 22:06fb2a93a1f6 2 /* Copyright (C) 2012 mbed.org, MIT License
donatien 22:06fb2a93a1f6 3 *
donatien 22:06fb2a93a1f6 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
donatien 22:06fb2a93a1f6 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
donatien 22:06fb2a93a1f6 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
donatien 22:06fb2a93a1f6 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
donatien 22:06fb2a93a1f6 8 * furnished to do so, subject to the following conditions:
donatien 22:06fb2a93a1f6 9 *
donatien 22:06fb2a93a1f6 10 * The above copyright notice and this permission notice shall be included in all copies or
donatien 22:06fb2a93a1f6 11 * substantial portions of the Software.
donatien 22:06fb2a93a1f6 12 *
donatien 22:06fb2a93a1f6 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
donatien 22:06fb2a93a1f6 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
donatien 22:06fb2a93a1f6 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
donatien 22:06fb2a93a1f6 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
donatien 22:06fb2a93a1f6 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
donatien 22:06fb2a93a1f6 18 */
donatien 0:3b2f052c333b 19
donatien 0:3b2f052c333b 20 #ifndef USBSERIALSTREAM_H_
donatien 0:3b2f052c333b 21 #define USBSERIALSTREAM_H_
donatien 0:3b2f052c333b 22
donatien 0:3b2f052c333b 23
donatien 0:3b2f052c333b 24 #include "core/fwk.h"
donatien 0:3b2f052c333b 25
phsfan 96:b50f5f795684 26 #include "USBHostSerial.h"
phsfan 96:b50f5f795684 27 #include "IUSBHostSerial.h"
phsfan 96:b50f5f795684 28 #include "IUSBHostSerialListener.h"
donatien 0:3b2f052c333b 29
donatien 0:3b2f052c333b 30 #include "rtos.h"
phsfan 96:b50f5f795684 31 #include "MtxCircBuffer.h"
donatien 0:3b2f052c333b 32
donatien 0:3b2f052c333b 33 /* Input Serial Stream for USB virtual serial ports interfaces
donatien 0:3b2f052c333b 34 This class is not thread-safe, except for the *Abort() methods that can be called by any thread/ISR
donatien 0:3b2f052c333b 35 */
donatien 16:02db4f537955 36 #define CIRCBUF_SIZE 127
donatien 0:3b2f052c333b 37 class USBSerialStream : public IOStream, IUSBHostSerialListener
donatien 0:3b2f052c333b 38 {
donatien 0:3b2f052c333b 39 public:
donatien 0:3b2f052c333b 40 USBSerialStream(IUSBHostSerial& serial);
donatien 0:3b2f052c333b 41 /*virtual*/ ~USBSerialStream();
donatien 0:3b2f052c333b 42
donatien 0:3b2f052c333b 43 //0 for non-blocking (returns immediately), osWaitForever for infinite blocking
donatien 0:3b2f052c333b 44 virtual int read(uint8_t* buf, size_t* pLength, size_t maxLength, uint32_t timeout=osWaitForever);
donatien 0:3b2f052c333b 45 virtual size_t available();
donatien 0:3b2f052c333b 46 virtual int waitAvailable(uint32_t timeout=osWaitForever); //Wait for data to be available
donatien 0:3b2f052c333b 47 virtual int abortRead(); //Abort current reading (or waiting) operation
donatien 0:3b2f052c333b 48
donatien 0:3b2f052c333b 49
donatien 0:3b2f052c333b 50 //0 for non-blocking (returns immediately), osWaitForever for infinite blocking
donatien 0:3b2f052c333b 51 virtual int write(uint8_t* buf, size_t length, uint32_t timeout=osWaitForever);
donatien 0:3b2f052c333b 52 virtual size_t space();
donatien 0:3b2f052c333b 53 virtual int waitSpace(uint32_t timeout=osWaitForever); //Wait for space to be available
donatien 0:3b2f052c333b 54 virtual int abortWrite(); //Abort current writing (or waiting) operation
donatien 0:3b2f052c333b 55
donatien 0:3b2f052c333b 56 private:
donatien 0:3b2f052c333b 57 IUSBHostSerial& m_serial;
donatien 0:3b2f052c333b 58 volatile bool m_serialTxFifoEmpty;
donatien 0:3b2f052c333b 59
donatien 0:3b2f052c333b 60 void setupReadableISR(bool en);
donatien 0:3b2f052c333b 61 virtual void readable(); //Callback from m_serial when new data is available
donatien 0:3b2f052c333b 62
donatien 0:3b2f052c333b 63 Semaphore m_availableSphre; //Used for signalling
donatien 0:3b2f052c333b 64
donatien 0:3b2f052c333b 65 void setupWriteableISR(bool en);
donatien 0:3b2f052c333b 66 virtual void writeable(); //Callback from m_serial when new space is available
donatien 0:3b2f052c333b 67
donatien 0:3b2f052c333b 68 Semaphore m_spaceSphre; //Used for signalling
donatien 0:3b2f052c333b 69
donatien 0:3b2f052c333b 70 MtxCircBuffer<uint8_t, CIRCBUF_SIZE + 1> m_inBuf;
donatien 0:3b2f052c333b 71 MtxCircBuffer<uint8_t, CIRCBUF_SIZE + 1> m_outBuf;
donatien 0:3b2f052c333b 72 };
donatien 0:3b2f052c333b 73
donatien 0:3b2f052c333b 74 #endif /* USBSERIALSTREAM_H_ */