mbed-os
Fork of mbed-os by
features/unsupported/net/cellular/CellularModem/CellularModem.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 | /* CellularModem.h */ |
elessair | 0:f269e3021894 | 2 | /* Copyright (C) 2013 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 CELLULARMODEM_H_ |
elessair | 0:f269e3021894 | 21 | #define CELLULARMODEM_H_ |
elessair | 0:f269e3021894 | 22 | |
elessair | 0:f269e3021894 | 23 | #include "core/fwk.h" |
elessair | 0:f269e3021894 | 24 | #include "at/ATCommandsInterface.h" |
elessair | 0:f269e3021894 | 25 | |
elessair | 0:f269e3021894 | 26 | class CellularModem |
elessair | 0:f269e3021894 | 27 | { |
elessair | 0:f269e3021894 | 28 | public: |
elessair | 0:f269e3021894 | 29 | //Internet-related functions |
elessair | 0:f269e3021894 | 30 | |
elessair | 0:f269e3021894 | 31 | /** Open a 3G internet connection |
elessair | 0:f269e3021894 | 32 | @return 0 on success, error code on failure |
elessair | 0:f269e3021894 | 33 | */ |
elessair | 0:f269e3021894 | 34 | virtual int connect(const char* apn = NULL, const char* user = NULL, const char* password = NULL) = 0; |
elessair | 0:f269e3021894 | 35 | |
elessair | 0:f269e3021894 | 36 | /** Close the internet connection |
elessair | 0:f269e3021894 | 37 | @return 0 on success, error code on failure |
elessair | 0:f269e3021894 | 38 | */ |
elessair | 0:f269e3021894 | 39 | virtual int disconnect() = 0; |
elessair | 0:f269e3021894 | 40 | |
elessair | 0:f269e3021894 | 41 | |
elessair | 0:f269e3021894 | 42 | /** Send a SM |
elessair | 0:f269e3021894 | 43 | @param number The receiver's phone number |
elessair | 0:f269e3021894 | 44 | @param message The message to send |
elessair | 0:f269e3021894 | 45 | @return 0 on success, error code on failure |
elessair | 0:f269e3021894 | 46 | */ |
elessair | 0:f269e3021894 | 47 | virtual int sendSM(const char* number, const char* message) = 0; |
elessair | 0:f269e3021894 | 48 | |
elessair | 0:f269e3021894 | 49 | |
elessair | 0:f269e3021894 | 50 | /** Receive a SM |
elessair | 0:f269e3021894 | 51 | @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 | 52 | @param message Pointer to a buffer to store the the incoming message |
elessair | 0:f269e3021894 | 53 | @param maxLength Maximum message length that can be stored in buffer (including null-terminating character) |
elessair | 0:f269e3021894 | 54 | @return 0 on success, error code on failure |
elessair | 0:f269e3021894 | 55 | */ |
elessair | 0:f269e3021894 | 56 | virtual int getSM(char* number, char* message, size_t maxLength) = 0; |
elessair | 0:f269e3021894 | 57 | |
elessair | 0:f269e3021894 | 58 | /** Get the number of SMs in the incoming box |
elessair | 0:f269e3021894 | 59 | @param pCount pointer to store the number of unprocessed SMs on |
elessair | 0:f269e3021894 | 60 | @return 0 on success, error code on failure |
elessair | 0:f269e3021894 | 61 | */ |
elessair | 0:f269e3021894 | 62 | virtual int getSMCount(size_t* pCount) = 0; |
elessair | 0:f269e3021894 | 63 | |
elessair | 0:f269e3021894 | 64 | /** Get the ATCommandsInterface instance |
elessair | 0:f269e3021894 | 65 | @return Pointer to the ATCommandsInterface instance |
elessair | 0:f269e3021894 | 66 | */ |
elessair | 0:f269e3021894 | 67 | virtual ATCommandsInterface* getATCommandsInterface() = 0; |
elessair | 0:f269e3021894 | 68 | |
elessair | 0:f269e3021894 | 69 | /** Switch power on or off |
elessair | 0:f269e3021894 | 70 | In order to use this function, a pin name must have been entered in the constructor |
elessair | 0:f269e3021894 | 71 | @param enable true to switch the dongle on, false to switch it off |
elessair | 0:f269e3021894 | 72 | @return 0 on success, error code on failure |
elessair | 0:f269e3021894 | 73 | */ |
elessair | 0:f269e3021894 | 74 | virtual int power(bool enable) = 0; |
elessair | 0:f269e3021894 | 75 | }; |
elessair | 0:f269e3021894 | 76 | |
elessair | 0:f269e3021894 | 77 | |
elessair | 0:f269e3021894 | 78 | #endif /* CELLULARMODEM_H_ */ |