PHS module SMA-01 library. see: https://developer.mbed.org/users/phsfan/notebook/abitusbmodem/

Dependencies:   Socket lwip-sys lwip

Dependents:   AbitUSBModem_HTTPTest AbitUSBModem_MQTTTest AbitUSBModem_WebsocketTest AbitUSBModem_SMSTest

Fork of VodafoneUSBModem by mbed official

/media/uploads/phsfan/sma01_003.png

Committer:
phsfan
Date:
Wed Feb 25 14:34:13 2015 +0000
Revision:
99:514e67a69ad6
Parent:
97:7d9cc95e2ea7
supported SMS

Who changed what in which revision?

UserRevisionLine numberNew contents of line
phsfan 97:7d9cc95e2ea7 1 /* AbitUSBModem.h */
phsfan 97:7d9cc95e2ea7 2 /* Modified by 2015 phsfan
phsfan 97:7d9cc95e2ea7 3 * for ABIT SMA-01
phsfan 96:b50f5f795684 4 */
phsfan 96:b50f5f795684 5 /* VodafoneUSBModem.h */
phsfan 96:b50f5f795684 6 /* Copyright (C) 2012 mbed.org, MIT License
phsfan 96:b50f5f795684 7 *
phsfan 96:b50f5f795684 8 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
phsfan 96:b50f5f795684 9 * and associated documentation files (the "Software"), to deal in the Software without restriction,
phsfan 96:b50f5f795684 10 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
phsfan 96:b50f5f795684 11 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
phsfan 96:b50f5f795684 12 * furnished to do so, subject to the following conditions:
phsfan 96:b50f5f795684 13 *
phsfan 96:b50f5f795684 14 * The above copyright notice and this permission notice shall be included in all copies or
phsfan 96:b50f5f795684 15 * substantial portions of the Software.
phsfan 96:b50f5f795684 16 *
phsfan 96:b50f5f795684 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
phsfan 96:b50f5f795684 18 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
phsfan 96:b50f5f795684 19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
phsfan 96:b50f5f795684 20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
phsfan 96:b50f5f795684 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
phsfan 96:b50f5f795684 22 */
phsfan 96:b50f5f795684 23
phsfan 96:b50f5f795684 24 #ifndef _ABITUSBMODEM_H_
phsfan 96:b50f5f795684 25 #define _ABITUSBMODEM_H_
phsfan 96:b50f5f795684 26
phsfan 96:b50f5f795684 27 #include "core/fwk.h"
phsfan 96:b50f5f795684 28
phsfan 96:b50f5f795684 29 #include "USBHostPhs.h"
phsfan 97:7d9cc95e2ea7 30 #include "at/ATCommandsInterface.h"
phsfan 96:b50f5f795684 31 #include "serial/usb/USBSerialStream.h"
phsfan 96:b50f5f795684 32 #include "ip/PPPIPInterface.h"
phsfan 97:7d9cc95e2ea7 33 #include "sms/SMSInterface.h"
phsfan 96:b50f5f795684 34
phsfan 96:b50f5f795684 35 class AbitUSBModem {
phsfan 96:b50f5f795684 36 public:
phsfan 96:b50f5f795684 37 AbitUSBModem ();
phsfan 96:b50f5f795684 38
phsfan 96:b50f5f795684 39 /** Open a 3G internet connection
phsfan 96:b50f5f795684 40 @return 0 on success, error code on failure
phsfan 96:b50f5f795684 41 */
phsfan 96:b50f5f795684 42 int connect(const char* user = NULL, const char* password = NULL);
phsfan 96:b50f5f795684 43
phsfan 96:b50f5f795684 44 /** Close the internet connection
phsfan 96:b50f5f795684 45 @return 0 on success, error code on failure
phsfan 96:b50f5f795684 46 */
phsfan 96:b50f5f795684 47 int disconnect();
phsfan 96:b50f5f795684 48
phsfan 97:7d9cc95e2ea7 49 /** Send a SM
phsfan 97:7d9cc95e2ea7 50 @param number The receiver's phone number
phsfan 97:7d9cc95e2ea7 51 @param message The message to send
phsfan 97:7d9cc95e2ea7 52 @return 0 on success, error code on failure
phsfan 97:7d9cc95e2ea7 53 */
phsfan 97:7d9cc95e2ea7 54 int sendSM(const char* number, const char* message);
phsfan 97:7d9cc95e2ea7 55
phsfan 97:7d9cc95e2ea7 56 /** Receive a SM
phsfan 97:7d9cc95e2ea7 57 @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)
phsfan 97:7d9cc95e2ea7 58 @param message Pointer to a buffer to store the the incoming message
phsfan 97:7d9cc95e2ea7 59 @param maxLength Maximum message length that can be stored in buffer (including null-terminating character)
phsfan 97:7d9cc95e2ea7 60 @return 0 on success, error code on failure
phsfan 97:7d9cc95e2ea7 61 */
phsfan 97:7d9cc95e2ea7 62 int getSM(char* number, char* message, size_t maxLength);
phsfan 97:7d9cc95e2ea7 63
phsfan 96:b50f5f795684 64 /** Get the IP address of a connected device
phsfan 96:b50f5f795684 65 @return A pointer to a string containing the IP address.
phsfan 96:b50f5f795684 66 */
phsfan 96:b50f5f795684 67 char* getIPAddress();
phsfan 96:b50f5f795684 68
phsfan 96:b50f5f795684 69 protected:
phsfan 96:b50f5f795684 70 int init();
phsfan 96:b50f5f795684 71
phsfan 96:b50f5f795684 72 private:
phsfan 96:b50f5f795684 73 USBHostPhs m_dongle; //< Interface to USB connected WAN dongle
phsfan 96:b50f5f795684 74
phsfan 96:b50f5f795684 75 USBSerialStream m_pppStream; //< Serial interface to PPP channel on modem
phsfan 96:b50f5f795684 76
phsfan 96:b50f5f795684 77 ATCommandsInterface m_at; //< Interface to AT commands processing
phsfan 96:b50f5f795684 78
phsfan 97:7d9cc95e2ea7 79 SMSInterface m_sms; //< Interface to SMS manager (send/receive etc)
phsfan 97:7d9cc95e2ea7 80
phsfan 96:b50f5f795684 81 PPPIPInterface m_ppp; //< Interface to PPP conection manager (IP assignment etc)
phsfan 96:b50f5f795684 82
phsfan 96:b50f5f795684 83 bool m_dongleConnected; //< Is the dongle physically connected (does the USB stack respond)? true/false
phsfan 96:b50f5f795684 84 bool m_ipInit; //< Has PPIPInterface object (m_ppp) been initialised? true/false
phsfan 97:7d9cc95e2ea7 85 bool m_smsInit; //< Has SMSInterface object (m_sms) been initialised? true/false
phsfan 96:b50f5f795684 86 bool m_atOpen; //< Is the interface to the ATCommandsInterface open? true/false
phsfan 96:b50f5f795684 87
phsfan 96:b50f5f795684 88 };
phsfan 96:b50f5f795684 89
phsfan 96:b50f5f795684 90 #endif