2 /* Copyright (C) 2012 mbed.org, MIT License
4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice shall be included in all copies or
11 * substantial portions of the Software.
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 #ifndef CDMASMSINTERFACE_H_
21 #define CDMASMSINTERFACE_H_
23 #include "SMSInterface.h"
27 /** Component to use the Short Messages Service (SMS)
30 class CDMASMSInterface
: public ISMSInterface
, protected IATCommandsProcessor
33 /** Create SMSInterface instance
34 @param pIf Pointer to the ATCommandsInterface instance to use
36 CDMASMSInterface(ATCommandsInterface
* pIf
);
38 /** Initialize interface
39 Configure SMS commands & register for SMS-related unsolicited result codes
44 @param number The receiver's phone number
45 @param message The message to send
46 @return 0 on success, error code on failure
48 virtual int send(const char* number
, const char* message
);
52 @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)
53 @param message Pointer to a buffer to store the the incoming message
54 @param maxLength Maximum message length that can be stored in buffer (including null-terminating character)
55 @return 0 on success, error code on failure
57 virtual int get(char* number
, char* message
, size_t maxLength
);
60 /** Get the number of SMs in the incoming box
61 @param pCount pointer to store the number of unprocessed SMs on
62 @return 0 on success, error code on failure
64 virtual int getCount(size_t* pCount
);
67 //IATCommandsProcessor
68 virtual int onNewATResponseLine(ATCommandsInterface
* pInst
, const char* line
);
69 virtual int onNewEntryPrompt(ATCommandsInterface
* pInst
);
71 int updateInbox(); //Update messages count in the different inboxes
74 ATCommandsInterface
* m_pIf
;
78 size_t m_maxMsgLength
;
82 size_t m_msgInListsCount
[4]; //4 lists
84 size_t m_headersToRead
;
86 enum { SMS_NONE
, SMS_SENT
, SMS_PENDING
, SMS_FAILED
} m_txState
;
87 enum { SMS_IDLE
, SMS_SEND_CMD_SENT
, SMS_GET_TX_STATUS_CMD_SENT
, SMS_GET_CMD_SENT
, SMS_GET_HDR_RECEIVED
, SMS_GET_COUNT_CMD_SENT
, SMS_CMD_PROCESSED
} m_state
;
90 #endif /* CDMASMSINTERFACE_H_ */