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