modified u-blox modem driver

Dependencies:   CellularUSBModem

Fork of UbloxUSBModem by mbed official

Committer:
mbed_official
Date:
Tue Mar 04 13:51:49 2014 +0000
Revision:
11:71550cccbe73
Parent:
3:4d2c18a3b2a4
Use latest version of CellularUSBModem

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 1:71286b99c1cb 1 /* UbloxUSBCDMAModem.h */
bogdanm 1:71286b99c1cb 2 /* Copyright (C) 2012 mbed.org, MIT License
bogdanm 1:71286b99c1cb 3 *
bogdanm 1:71286b99c1cb 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
bogdanm 1:71286b99c1cb 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
bogdanm 1:71286b99c1cb 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
bogdanm 1:71286b99c1cb 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
bogdanm 1:71286b99c1cb 8 * furnished to do so, subject to the following conditions:
bogdanm 1:71286b99c1cb 9 *
bogdanm 1:71286b99c1cb 10 * The above copyright notice and this permission notice shall be included in all copies or
bogdanm 1:71286b99c1cb 11 * substantial portions of the Software.
bogdanm 1:71286b99c1cb 12 *
bogdanm 1:71286b99c1cb 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
bogdanm 1:71286b99c1cb 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
bogdanm 1:71286b99c1cb 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
bogdanm 1:71286b99c1cb 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
bogdanm 1:71286b99c1cb 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
bogdanm 1:71286b99c1cb 18 */
bogdanm 1:71286b99c1cb 19
bogdanm 1:71286b99c1cb 20 #ifndef UBLOXUSBCDMAMODEM_H_
bogdanm 1:71286b99c1cb 21 #define UBLOXUSBCDMAMODEM_H_
bogdanm 1:71286b99c1cb 22
bogdanm 1:71286b99c1cb 23 #include "core/fwk.h"
bogdanm 1:71286b99c1cb 24
bogdanm 1:71286b99c1cb 25 #include "WANDongle.h"
bogdanm 1:71286b99c1cb 26 #include "at/ATCommandsInterface.h"
bogdanm 1:71286b99c1cb 27 #include "USBSerialStream.h"
bogdanm 1:71286b99c1cb 28 #include "ip/PPPIPInterface.h"
bogdanm 1:71286b99c1cb 29 #include "sms/CDMASMSInterface.h"
bogdanm 3:4d2c18a3b2a4 30 #include "CellularModem.h"
bogdanm 1:71286b99c1cb 31
bogdanm 1:71286b99c1cb 32 /** u-blox LISA-C200 modem
bogdanm 1:71286b99c1cb 33 */
bogdanm 3:4d2c18a3b2a4 34 class UbloxUSBCDMAModem: public CellularModem
bogdanm 1:71286b99c1cb 35 {
bogdanm 1:71286b99c1cb 36 public:
bogdanm 1:71286b99c1cb 37 /** Create Sprint USB Modem (Sierra Wireless 598U) API instance
bogdanm 1:71286b99c1cb 38 @param powerGatingPin Optional pin commanding a power gating transistor on the modem's power line
bogdanm 1:71286b99c1cb 39 @param powerGatingOnWhenPinHigh true if the pin needs to be high to power the dongle, defaults to true
bogdanm 1:71286b99c1cb 40 */
bogdanm 1:71286b99c1cb 41 UbloxUSBCDMAModem(PinName powerGatingPin = NC, bool powerGatingOnWhenPinHigh = true, int serial = 0);
bogdanm 1:71286b99c1cb 42
bogdanm 1:71286b99c1cb 43 //Internet-related functions
bogdanm 1:71286b99c1cb 44
bogdanm 1:71286b99c1cb 45 /** Open a 3G internet connection
bogdanm 1:71286b99c1cb 46 @return 0 on success, error code on failure
bogdanm 1:71286b99c1cb 47 */
bogdanm 3:4d2c18a3b2a4 48 virtual int connect(const char* apn = NULL, const char* user = NULL, const char* password = NULL);
bogdanm 1:71286b99c1cb 49
bogdanm 1:71286b99c1cb 50 /** Close the internet connection
bogdanm 1:71286b99c1cb 51 @return 0 on success, error code on failure
bogdanm 1:71286b99c1cb 52 */
bogdanm 3:4d2c18a3b2a4 53 virtual int disconnect();
bogdanm 1:71286b99c1cb 54
bogdanm 1:71286b99c1cb 55
bogdanm 1:71286b99c1cb 56 /** Send a SM
bogdanm 1:71286b99c1cb 57 @param number The receiver's phone number
bogdanm 1:71286b99c1cb 58 @param message The message to send
bogdanm 1:71286b99c1cb 59 @return 0 on success, error code on failure
bogdanm 1:71286b99c1cb 60 */
bogdanm 3:4d2c18a3b2a4 61 virtual int sendSM(const char* number, const char* message);
bogdanm 1:71286b99c1cb 62
bogdanm 1:71286b99c1cb 63
bogdanm 1:71286b99c1cb 64 /** Receive a SM
bogdanm 1:71286b99c1cb 65 @param number Pointer to a buffer to store the sender's phone number (must be at least 17 characters-long, including the sapce for the null-terminating char)
bogdanm 1:71286b99c1cb 66 @param message Pointer to a buffer to store the the incoming message
bogdanm 1:71286b99c1cb 67 @param maxLength Maximum message length that can be stored in buffer (including null-terminating character)
bogdanm 1:71286b99c1cb 68 @return 0 on success, error code on failure
bogdanm 1:71286b99c1cb 69 */
bogdanm 3:4d2c18a3b2a4 70 virtual int getSM(char* number, char* message, size_t maxLength);
bogdanm 1:71286b99c1cb 71
bogdanm 1:71286b99c1cb 72 /** Get the number of SMs in the incoming box
bogdanm 1:71286b99c1cb 73 @param pCount pointer to store the number of unprocessed SMs on
bogdanm 1:71286b99c1cb 74 @return 0 on success, error code on failure
bogdanm 1:71286b99c1cb 75 */
bogdanm 3:4d2c18a3b2a4 76 virtual int getSMCount(size_t* pCount);
bogdanm 1:71286b99c1cb 77
bogdanm 1:71286b99c1cb 78 /** Get the ATCommandsInterface instance
bogdanm 1:71286b99c1cb 79 @return Pointer to the ATCommandsInterface instance
bogdanm 1:71286b99c1cb 80 */
bogdanm 3:4d2c18a3b2a4 81 virtual ATCommandsInterface* getATCommandsInterface();
bogdanm 1:71286b99c1cb 82
bogdanm 1:71286b99c1cb 83 /** Switch power on or off
bogdanm 1:71286b99c1cb 84 In order to use this function, a pin name must have been entered in the constructor
bogdanm 1:71286b99c1cb 85 @param enable true to switch the dongle on, false to switch it off
bogdanm 1:71286b99c1cb 86 @return 0 on success, error code on failure
bogdanm 1:71286b99c1cb 87 */
bogdanm 3:4d2c18a3b2a4 88 virtual int power(bool enable);
bogdanm 1:71286b99c1cb 89
bogdanm 1:71286b99c1cb 90 protected:
bogdanm 1:71286b99c1cb 91 bool power();
bogdanm 1:71286b99c1cb 92
bogdanm 1:71286b99c1cb 93 int init();
bogdanm 1:71286b99c1cb 94 int cleanup();
bogdanm 1:71286b99c1cb 95
bogdanm 1:71286b99c1cb 96 private:
bogdanm 1:71286b99c1cb 97 WANDongle m_dongle;
bogdanm 1:71286b99c1cb 98
bogdanm 1:71286b99c1cb 99 USBSerialStream m_stream;
bogdanm 1:71286b99c1cb 100
bogdanm 1:71286b99c1cb 101 ATCommandsInterface m_at;
bogdanm 1:71286b99c1cb 102
bogdanm 1:71286b99c1cb 103 CDMASMSInterface m_sms;
bogdanm 1:71286b99c1cb 104
bogdanm 1:71286b99c1cb 105 PPPIPInterface m_ppp;
bogdanm 1:71286b99c1cb 106
bogdanm 1:71286b99c1cb 107 bool m_dongleConnected;
bogdanm 1:71286b99c1cb 108 bool m_ipInit;
bogdanm 1:71286b99c1cb 109 bool m_smsInit;
bogdanm 1:71286b99c1cb 110 bool m_atOpen;
bogdanm 1:71286b99c1cb 111
bogdanm 1:71286b99c1cb 112 PinName m_powerGatingPin;
bogdanm 1:71286b99c1cb 113 bool m_powerGatingOnWhenPinHigh;
bogdanm 1:71286b99c1cb 114 };
bogdanm 1:71286b99c1cb 115
bogdanm 1:71286b99c1cb 116
bogdanm 1:71286b99c1cb 117 #endif /* UBLOXUSBCDMAMODEM_H_ */
bogdanm 1:71286b99c1cb 118