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 /* SMSInterface.h */
phsfan 97:7d9cc95e2ea7 2 /* Copyright (C) 2012 mbed.org, MIT License
phsfan 97:7d9cc95e2ea7 3 *
phsfan 97:7d9cc95e2ea7 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
phsfan 97:7d9cc95e2ea7 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
phsfan 97:7d9cc95e2ea7 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
phsfan 97:7d9cc95e2ea7 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
phsfan 97:7d9cc95e2ea7 8 * furnished to do so, subject to the following conditions:
phsfan 97:7d9cc95e2ea7 9 *
phsfan 97:7d9cc95e2ea7 10 * The above copyright notice and this permission notice shall be included in all copies or
phsfan 97:7d9cc95e2ea7 11 * substantial portions of the Software.
phsfan 97:7d9cc95e2ea7 12 *
phsfan 97:7d9cc95e2ea7 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
phsfan 97:7d9cc95e2ea7 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
phsfan 97:7d9cc95e2ea7 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
phsfan 97:7d9cc95e2ea7 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
phsfan 97:7d9cc95e2ea7 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
phsfan 97:7d9cc95e2ea7 18 */
phsfan 97:7d9cc95e2ea7 19
phsfan 97:7d9cc95e2ea7 20 #ifndef SMSINTERFACE_H_
phsfan 97:7d9cc95e2ea7 21 #define SMSINTERFACE_H_
phsfan 97:7d9cc95e2ea7 22
phsfan 97:7d9cc95e2ea7 23 #include "core/fwk.h"
phsfan 97:7d9cc95e2ea7 24
phsfan 97:7d9cc95e2ea7 25 #include "rtos.h"
phsfan 97:7d9cc95e2ea7 26
phsfan 97:7d9cc95e2ea7 27 #include "at/ATCommandsInterface.h"
phsfan 97:7d9cc95e2ea7 28
phsfan 97:7d9cc95e2ea7 29 /** Component to use the Short Messages Service (SMS)
phsfan 97:7d9cc95e2ea7 30 *
phsfan 97:7d9cc95e2ea7 31 */
phsfan 97:7d9cc95e2ea7 32 class SMSInterface : protected IATCommandsProcessor, IATEventsHandler
phsfan 97:7d9cc95e2ea7 33 {
phsfan 97:7d9cc95e2ea7 34 public:
phsfan 97:7d9cc95e2ea7 35 /** Create SMSInterface instance
phsfan 97:7d9cc95e2ea7 36 @param pIf Pointer to the ATCommandsInterface instance to use
phsfan 97:7d9cc95e2ea7 37 */
phsfan 97:7d9cc95e2ea7 38 SMSInterface(ATCommandsInterface* pIf);
phsfan 97:7d9cc95e2ea7 39
phsfan 97:7d9cc95e2ea7 40 /** Initialize interface
phsfan 97:7d9cc95e2ea7 41 Configure SMS commands & register for SMS-related unsolicited result codes
phsfan 97:7d9cc95e2ea7 42 */
phsfan 97:7d9cc95e2ea7 43 int init();
phsfan 97:7d9cc95e2ea7 44
phsfan 97:7d9cc95e2ea7 45 /** Send a SM
phsfan 97:7d9cc95e2ea7 46 @param number The receiver's phone number
phsfan 97:7d9cc95e2ea7 47 @param message The message to send
phsfan 97:7d9cc95e2ea7 48 @return 0 on success, error code on failure
phsfan 97:7d9cc95e2ea7 49 */
phsfan 97:7d9cc95e2ea7 50 int send(const char* number, const char* message);
phsfan 97:7d9cc95e2ea7 51
phsfan 97:7d9cc95e2ea7 52
phsfan 97:7d9cc95e2ea7 53 /** Receive a SM
phsfan 97:7d9cc95e2ea7 54 @param number Pointer to a buffer to store the sender's phone number (must be at least 17 characters-long, including the space for the null-terminating char)
phsfan 97:7d9cc95e2ea7 55 @param message Pointer to a buffer to store the the incoming message
phsfan 97:7d9cc95e2ea7 56 @param maxLength Maximum message length that can be stored in buffer (including null-terminating character)
phsfan 97:7d9cc95e2ea7 57 @return 0 on success, error code on failure
phsfan 97:7d9cc95e2ea7 58 */
phsfan 97:7d9cc95e2ea7 59 int get(char* number, char* message, size_t maxLength);
phsfan 97:7d9cc95e2ea7 60
phsfan 97:7d9cc95e2ea7 61 protected:
phsfan 97:7d9cc95e2ea7 62 //IATCommandsProcessor
phsfan 97:7d9cc95e2ea7 63 virtual int onNewATResponseLine(ATCommandsInterface* pInst, const char* line);
phsfan 97:7d9cc95e2ea7 64 virtual int onNewEntryPrompt(ATCommandsInterface* pInst);
phsfan 97:7d9cc95e2ea7 65
phsfan 97:7d9cc95e2ea7 66 //IATEventsHandler
phsfan 97:7d9cc95e2ea7 67 virtual bool isATCodeHandled(const char* atCode); //Is this AT code handled
phsfan 97:7d9cc95e2ea7 68 virtual void onDispatchStart();
phsfan 97:7d9cc95e2ea7 69 virtual void onDispatchStop();
phsfan 97:7d9cc95e2ea7 70 virtual char* getEventsEnableCommand();
phsfan 97:7d9cc95e2ea7 71 virtual char* getEventsDisableCommand();
phsfan 97:7d9cc95e2ea7 72 virtual void onEvent(const char* atCode, const char* evt);
phsfan 97:7d9cc95e2ea7 73
phsfan 97:7d9cc95e2ea7 74 private:
phsfan 97:7d9cc95e2ea7 75 ATCommandsInterface* m_pIf;
phsfan 97:7d9cc95e2ea7 76
phsfan 97:7d9cc95e2ea7 77 //Current message
phsfan 97:7d9cc95e2ea7 78 char* m_msg;
phsfan 97:7d9cc95e2ea7 79 size_t m_maxMsgLength;
phsfan 97:7d9cc95e2ea7 80 char* m_msisdn;
phsfan 99:514e67a69ad6 81 char m_caller[12];
phsfan 97:7d9cc95e2ea7 82
phsfan 99:514e67a69ad6 83 enum { SMS_IDLE, SMS_SEND_CMD_SENT, SMS_GET_CMD_SENT, SMS_RING, SMS_CMD_BUSY, SMS_CMD_PROCESSED } m_state;
phsfan 97:7d9cc95e2ea7 84 };
phsfan 97:7d9cc95e2ea7 85
phsfan 97:7d9cc95e2ea7 86 #endif /* SMSINTERFACE_H_ */