Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
CDMASMSInterface.h
00001 /* SMSInterface.h */ 00002 /* Copyright (C) 2012 mbed.org, MIT License 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00005 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00006 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00007 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00008 * furnished to do so, subject to the following conditions: 00009 * 00010 * The above copyright notice and this permission notice shall be included in all copies or 00011 * substantial portions of the Software. 00012 * 00013 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00014 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00015 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00016 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00017 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00018 */ 00019 00020 #ifndef CDMASMSINTERFACE_H_ 00021 #define CDMASMSINTERFACE_H_ 00022 00023 #include "SMSInterface.h" 00024 00025 #define MAX_SM 8 00026 00027 /** Component to use the Short Messages Service (SMS) 00028 * 00029 */ 00030 class CDMASMSInterface : public ISMSInterface, protected IATCommandsProcessor 00031 { 00032 public: 00033 /** Create SMSInterface instance 00034 @param pIf Pointer to the ATCommandsInterface instance to use 00035 */ 00036 CDMASMSInterface(ATCommandsInterface* pIf); 00037 00038 /** Initialize interface 00039 Configure SMS commands & register for SMS-related unsolicited result codes 00040 */ 00041 virtual int init(); 00042 00043 /** Send a SM 00044 @param number The receiver's phone number 00045 @param message The message to send 00046 @return 0 on success, error code on failure 00047 */ 00048 virtual int send(const char* number, const char* message); 00049 00050 00051 /** Receive a SM 00052 @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) 00053 @param message Pointer to a buffer to store the the incoming message 00054 @param maxLength Maximum message length that can be stored in buffer (including null-terminating character) 00055 @return 0 on success, error code on failure 00056 */ 00057 virtual int get(char* number, char* message, size_t maxLength); 00058 00059 00060 /** Get the number of SMs in the incoming box 00061 @param pCount pointer to store the number of unprocessed SMs on 00062 @return 0 on success, error code on failure 00063 */ 00064 virtual int getCount(size_t* pCount); 00065 00066 protected: 00067 //IATCommandsProcessor 00068 virtual int onNewATResponseLine(ATCommandsInterface* pInst, const char* line); 00069 virtual int onNewEntryPrompt(ATCommandsInterface* pInst); 00070 00071 int updateInbox(); //Update messages count in the different inboxes 00072 00073 private: 00074 ATCommandsInterface* m_pIf; 00075 00076 //Current message 00077 char* m_msg; 00078 size_t m_maxMsgLength; 00079 char* m_msisdn; 00080 00081 //Messages list 00082 size_t m_msgInListsCount[4]; //4 lists 00083 00084 size_t m_headersToRead; 00085 00086 enum { SMS_NONE, SMS_SENT, SMS_PENDING, SMS_FAILED } m_txState; 00087 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; 00088 }; 00089 00090 #endif /* CDMASMSINTERFACE_H_ */
Generated on Tue Jul 12 2022 17:34:38 by
