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:
donatien
Date:
Thu May 24 16:40:40 2012 +0000
Revision:
0:3b2f052c333b
Initial Commit

Who changed what in which revision?

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