Integrating the ublox LISA C200 modem

Fork of SprintUSBModemHTTPClientTest by Donatien Garnier

Committer:
mike.pulice@proxy-usa.com
Date:
Thu Sep 26 11:15:22 2013 -0700
Revision:
7:655438fd019f
Parent:
5:3f93dd1d4cb3
Correct issues with C200 parsing interface and endpoints.

Sprint USB Modem
Added a constructor variable for which serial port stream to use for AT.
The default is 0 in order to not break previous modems.

C200 uses serial stream 1

main.cpp
Sprint modem constructor pass 1 for the serial stream.

Who changed what in which revision?

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