u-blox USB modems (GSM and CDMA)

Dependencies:   CellularUSBModem

Dependents:   C027_CANInterfaceComm C027_ModemTransparentUSBCDC_revb UbloxModemHTTPClientTest C027_HTTPClientTest ... more

Legacy Networking Libray

This is an mbed 2 networking library. For an mbed OS 5 compatible library, please see:

Import libraryC027Interface

Socket interface for C027Interface. Implements the NetworkSocketAPI

Committer:
bogdanm
Date:
Thu Oct 17 13:06:33 2013 +0300
Revision:
1:71286b99c1cb
Child:
3:4d2c18a3b2a4
Initial release of the UbloxUSBModem library

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 1:71286b99c1cb 30
bogdanm 1:71286b99c1cb 31 /** u-blox LISA-C200 modem
bogdanm 1:71286b99c1cb 32 */
bogdanm 1:71286b99c1cb 33 class UbloxUSBCDMAModem
bogdanm 1:71286b99c1cb 34 {
bogdanm 1:71286b99c1cb 35 public:
bogdanm 1:71286b99c1cb 36 /** Create Sprint USB Modem (Sierra Wireless 598U) API instance
bogdanm 1:71286b99c1cb 37 @param powerGatingPin Optional pin commanding a power gating transistor on the modem's power line
bogdanm 1:71286b99c1cb 38 @param powerGatingOnWhenPinHigh true if the pin needs to be high to power the dongle, defaults to true
bogdanm 1:71286b99c1cb 39 */
bogdanm 1:71286b99c1cb 40 UbloxUSBCDMAModem(PinName powerGatingPin = NC, bool powerGatingOnWhenPinHigh = true, int serial = 0);
bogdanm 1:71286b99c1cb 41
bogdanm 1:71286b99c1cb 42 //Internet-related functions
bogdanm 1:71286b99c1cb 43
bogdanm 1:71286b99c1cb 44 /** Open a 3G internet connection
bogdanm 1:71286b99c1cb 45 @return 0 on success, error code on failure
bogdanm 1:71286b99c1cb 46 */
bogdanm 1:71286b99c1cb 47 int connect(const char* apn = NULL, const char* user = NULL, const char* password = NULL);
bogdanm 1:71286b99c1cb 48
bogdanm 1:71286b99c1cb 49 /** Close the internet connection
bogdanm 1:71286b99c1cb 50 @return 0 on success, error code on failure
bogdanm 1:71286b99c1cb 51 */
bogdanm 1:71286b99c1cb 52 int disconnect();
bogdanm 1:71286b99c1cb 53
bogdanm 1:71286b99c1cb 54
bogdanm 1:71286b99c1cb 55 /** Send a SM
bogdanm 1:71286b99c1cb 56 @param number The receiver's phone number
bogdanm 1:71286b99c1cb 57 @param message The message to send
bogdanm 1:71286b99c1cb 58 @return 0 on success, error code on failure
bogdanm 1:71286b99c1cb 59 */
bogdanm 1:71286b99c1cb 60 int sendSM(const char* number, const char* message);
bogdanm 1:71286b99c1cb 61
bogdanm 1:71286b99c1cb 62
bogdanm 1:71286b99c1cb 63 /** Receive a SM
bogdanm 1:71286b99c1cb 64 @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 65 @param message Pointer to a buffer to store the the incoming message
bogdanm 1:71286b99c1cb 66 @param maxLength Maximum message length that can be stored in buffer (including null-terminating character)
bogdanm 1:71286b99c1cb 67 @return 0 on success, error code on failure
bogdanm 1:71286b99c1cb 68 */
bogdanm 1:71286b99c1cb 69 int getSM(char* number, char* message, size_t maxLength);
bogdanm 1:71286b99c1cb 70
bogdanm 1:71286b99c1cb 71 /** Get the number of SMs in the incoming box
bogdanm 1:71286b99c1cb 72 @param pCount pointer to store the number of unprocessed SMs on
bogdanm 1:71286b99c1cb 73 @return 0 on success, error code on failure
bogdanm 1:71286b99c1cb 74 */
bogdanm 1:71286b99c1cb 75 int getSMCount(size_t* pCount);
bogdanm 1:71286b99c1cb 76
bogdanm 1:71286b99c1cb 77 /** Get the ATCommandsInterface instance
bogdanm 1:71286b99c1cb 78 @return Pointer to the ATCommandsInterface instance
bogdanm 1:71286b99c1cb 79 */
bogdanm 1:71286b99c1cb 80 ATCommandsInterface* getATCommandsInterface();
bogdanm 1:71286b99c1cb 81
bogdanm 1:71286b99c1cb 82 /** Switch power on or off
bogdanm 1:71286b99c1cb 83 In order to use this function, a pin name must have been entered in the constructor
bogdanm 1:71286b99c1cb 84 @param enable true to switch the dongle on, false to switch it off
bogdanm 1:71286b99c1cb 85 @return 0 on success, error code on failure
bogdanm 1:71286b99c1cb 86 */
bogdanm 1:71286b99c1cb 87 int power(bool enable);
bogdanm 1:71286b99c1cb 88
bogdanm 1:71286b99c1cb 89 protected:
bogdanm 1:71286b99c1cb 90 bool power();
bogdanm 1:71286b99c1cb 91
bogdanm 1:71286b99c1cb 92 int init();
bogdanm 1:71286b99c1cb 93 int cleanup();
bogdanm 1:71286b99c1cb 94
bogdanm 1:71286b99c1cb 95 private:
bogdanm 1:71286b99c1cb 96 WANDongle m_dongle;
bogdanm 1:71286b99c1cb 97
bogdanm 1:71286b99c1cb 98 USBSerialStream m_stream;
bogdanm 1:71286b99c1cb 99
bogdanm 1:71286b99c1cb 100 ATCommandsInterface m_at;
bogdanm 1:71286b99c1cb 101
bogdanm 1:71286b99c1cb 102 CDMASMSInterface m_sms;
bogdanm 1:71286b99c1cb 103
bogdanm 1:71286b99c1cb 104 PPPIPInterface m_ppp;
bogdanm 1:71286b99c1cb 105
bogdanm 1:71286b99c1cb 106 bool m_dongleConnected;
bogdanm 1:71286b99c1cb 107 bool m_ipInit;
bogdanm 1:71286b99c1cb 108 bool m_smsInit;
bogdanm 1:71286b99c1cb 109 bool m_atOpen;
bogdanm 1:71286b99c1cb 110
bogdanm 1:71286b99c1cb 111 PinName m_powerGatingPin;
bogdanm 1:71286b99c1cb 112 bool m_powerGatingOnWhenPinHigh;
bogdanm 1:71286b99c1cb 113 };
bogdanm 1:71286b99c1cb 114
bogdanm 1:71286b99c1cb 115
bogdanm 1:71286b99c1cb 116 #endif /* UBLOXUSBCDMAMODEM_H_ */
bogdanm 1:71286b99c1cb 117