]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/net/cellular/CellularModem/sms/CDMASMSInterface.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / net / cellular / CellularModem / sms / CDMASMSInterface.h
1 /* SMSInterface.h */
2 /* Copyright (C) 2012 mbed.org, MIT License
3  *
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:
9  *
10  * The above copyright notice and this permission notice shall be included in all copies or
11  * substantial portions of the Software.
12  *
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.
18  */
19
20 #ifndef CDMASMSINTERFACE_H_
21 #define CDMASMSINTERFACE_H_
22
23 #include "SMSInterface.h"
24
25 #define MAX_SM 8
26
27 /** Component to use the Short Messages Service (SMS)
28  *
29  */
30 class CDMASMSInterface : public ISMSInterface, protected IATCommandsProcessor
31 {
32 public:
33   /** Create SMSInterface instance
34      @param pIf Pointer to the ATCommandsInterface instance to use
35    */
36   CDMASMSInterface(ATCommandsInterface* pIf);
37
38   /** Initialize interface
39     Configure SMS commands & register for SMS-related unsolicited result codes
40    */
41   virtual int init();
42
43   /** Send a SM
44      @param number The receiver's phone number
45      @param message The message to send
46      @return 0 on success, error code on failure
47    */
48   virtual int send(const char* number, const char* message);
49
50
51   /** Receive a SM
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
56    */
57   virtual int get(char* number, char* message, size_t maxLength);
58
59
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
63    */
64   virtual int getCount(size_t* pCount);
65
66 protected:
67   //IATCommandsProcessor
68   virtual int onNewATResponseLine(ATCommandsInterface* pInst, const char* line);
69   virtual int onNewEntryPrompt(ATCommandsInterface* pInst);
70
71   int updateInbox(); //Update messages count in the different inboxes
72
73 private:
74   ATCommandsInterface* m_pIf;
75
76   //Current message
77   char* m_msg;
78   size_t m_maxMsgLength;
79   char* m_msisdn;
80
81   //Messages list
82   size_t m_msgInListsCount[4]; //4 lists
83   
84   size_t m_headersToRead;
85   
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;
88 };
89
90 #endif /* CDMASMSINTERFACE_H_ */