Base library for cellular modem implementations
Dependencies: Socket lwip-sys lwip
Dependents: CellularUSBModem CellularUSBModem
Deprecated
This is an mbed 2 networking library. For mbed 5, the networking libraries have been revised to better support additional network stacks and thread safety here.
sms/GSMSMSInterface.h@8:944cd194963e, 2014-05-08 (annotated)
- Committer:
- mbed_official
- Date:
- Thu May 08 11:00:26 2014 +0100
- Revision:
- 8:944cd194963e
- Parent:
- 1:4a23efdf0da9
Synchronized with git revision df12bf01ac7dbb50751e2b16a351c894994e1dcf
Full URL: https://github.com/mbedmicro/mbed/commit/df12bf01ac7dbb50751e2b16a351c894994e1dcf/
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 1:4a23efdf0da9 | 1 | /* SMSInterface.h */ |
bogdanm | 1:4a23efdf0da9 | 2 | /* Copyright (C) 2012 mbed.org, MIT License |
bogdanm | 1:4a23efdf0da9 | 3 | * |
bogdanm | 1:4a23efdf0da9 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
bogdanm | 1:4a23efdf0da9 | 5 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
bogdanm | 1:4a23efdf0da9 | 6 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
bogdanm | 1:4a23efdf0da9 | 7 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
bogdanm | 1:4a23efdf0da9 | 8 | * furnished to do so, subject to the following conditions: |
bogdanm | 1:4a23efdf0da9 | 9 | * |
bogdanm | 1:4a23efdf0da9 | 10 | * The above copyright notice and this permission notice shall be included in all copies or |
bogdanm | 1:4a23efdf0da9 | 11 | * substantial portions of the Software. |
bogdanm | 1:4a23efdf0da9 | 12 | * |
bogdanm | 1:4a23efdf0da9 | 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
bogdanm | 1:4a23efdf0da9 | 14 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
bogdanm | 1:4a23efdf0da9 | 15 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
bogdanm | 1:4a23efdf0da9 | 16 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
bogdanm | 1:4a23efdf0da9 | 17 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
bogdanm | 1:4a23efdf0da9 | 18 | */ |
bogdanm | 1:4a23efdf0da9 | 19 | |
bogdanm | 1:4a23efdf0da9 | 20 | #ifndef GSMSMSINTERFACE_H_ |
bogdanm | 1:4a23efdf0da9 | 21 | #define GSMSMSINTERFACE_H_ |
bogdanm | 1:4a23efdf0da9 | 22 | |
bogdanm | 1:4a23efdf0da9 | 23 | #include "SMSInterface.h" |
bogdanm | 1:4a23efdf0da9 | 24 | |
bogdanm | 1:4a23efdf0da9 | 25 | /** Component to use the Short Messages Service (SMS) |
bogdanm | 1:4a23efdf0da9 | 26 | * |
bogdanm | 1:4a23efdf0da9 | 27 | */ |
bogdanm | 1:4a23efdf0da9 | 28 | class GSMSMSInterface : public ISMSInterface, protected IATCommandsProcessor, IATEventsHandler |
bogdanm | 1:4a23efdf0da9 | 29 | { |
bogdanm | 1:4a23efdf0da9 | 30 | public: |
bogdanm | 1:4a23efdf0da9 | 31 | /** Create SMSInterface instance |
bogdanm | 1:4a23efdf0da9 | 32 | @param pIf Pointer to the ATCommandsInterface instance to use |
bogdanm | 1:4a23efdf0da9 | 33 | */ |
bogdanm | 1:4a23efdf0da9 | 34 | GSMSMSInterface(ATCommandsInterface* pIf); |
bogdanm | 1:4a23efdf0da9 | 35 | |
bogdanm | 1:4a23efdf0da9 | 36 | /** Initialize interface |
bogdanm | 1:4a23efdf0da9 | 37 | Configure SMS commands & register for SMS-related unsolicited result codes |
bogdanm | 1:4a23efdf0da9 | 38 | */ |
bogdanm | 1:4a23efdf0da9 | 39 | virtual int init(); |
bogdanm | 1:4a23efdf0da9 | 40 | |
bogdanm | 1:4a23efdf0da9 | 41 | /** Send a SM |
bogdanm | 1:4a23efdf0da9 | 42 | @param number The receiver's phone number |
bogdanm | 1:4a23efdf0da9 | 43 | @param message The message to send |
bogdanm | 1:4a23efdf0da9 | 44 | @return 0 on success, error code on failure |
bogdanm | 1:4a23efdf0da9 | 45 | */ |
bogdanm | 1:4a23efdf0da9 | 46 | virtual int send(const char* number, const char* message); |
bogdanm | 1:4a23efdf0da9 | 47 | |
bogdanm | 1:4a23efdf0da9 | 48 | |
bogdanm | 1:4a23efdf0da9 | 49 | /** Receive a SM |
bogdanm | 1:4a23efdf0da9 | 50 | @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) |
bogdanm | 1:4a23efdf0da9 | 51 | @param message Pointer to a buffer to store the the incoming message |
bogdanm | 1:4a23efdf0da9 | 52 | @param maxLength Maximum message length that can be stored in buffer (including null-terminating character) |
bogdanm | 1:4a23efdf0da9 | 53 | @return 0 on success, error code on failure |
bogdanm | 1:4a23efdf0da9 | 54 | */ |
bogdanm | 1:4a23efdf0da9 | 55 | virtual int get(char* number, char* message, size_t maxLength); |
bogdanm | 1:4a23efdf0da9 | 56 | |
bogdanm | 1:4a23efdf0da9 | 57 | |
bogdanm | 1:4a23efdf0da9 | 58 | /** Get the number of SMs in the incoming box |
bogdanm | 1:4a23efdf0da9 | 59 | @param pCount pointer to store the number of unprocessed SMs on |
bogdanm | 1:4a23efdf0da9 | 60 | @return 0 on success, error code on failure |
bogdanm | 1:4a23efdf0da9 | 61 | */ |
bogdanm | 1:4a23efdf0da9 | 62 | virtual int getCount(size_t* pCount); |
bogdanm | 1:4a23efdf0da9 | 63 | |
bogdanm | 1:4a23efdf0da9 | 64 | protected: |
bogdanm | 1:4a23efdf0da9 | 65 | //IATCommandsProcessor |
bogdanm | 1:4a23efdf0da9 | 66 | virtual int onNewATResponseLine(ATCommandsInterface* pInst, const char* line); |
bogdanm | 1:4a23efdf0da9 | 67 | virtual int onNewEntryPrompt(ATCommandsInterface* pInst); |
bogdanm | 1:4a23efdf0da9 | 68 | |
bogdanm | 1:4a23efdf0da9 | 69 | //IATEventsHandler |
bogdanm | 1:4a23efdf0da9 | 70 | virtual bool isATCodeHandled(const char* atCode); //Is this AT code handled |
bogdanm | 1:4a23efdf0da9 | 71 | virtual void onDispatchStart(); |
bogdanm | 1:4a23efdf0da9 | 72 | virtual void onDispatchStop(); |
bogdanm | 1:4a23efdf0da9 | 73 | virtual char* getEventsEnableCommand(); |
bogdanm | 1:4a23efdf0da9 | 74 | virtual char* getEventsDisableCommand(); |
bogdanm | 1:4a23efdf0da9 | 75 | virtual void onEvent(const char* atCode, const char* evt); |
bogdanm | 1:4a23efdf0da9 | 76 | |
bogdanm | 1:4a23efdf0da9 | 77 | //Updates messages count/references |
bogdanm | 1:4a23efdf0da9 | 78 | int updateInbox(); |
bogdanm | 1:4a23efdf0da9 | 79 | |
bogdanm | 1:4a23efdf0da9 | 80 | private: |
bogdanm | 1:4a23efdf0da9 | 81 | ATCommandsInterface* m_pIf; |
bogdanm | 1:4a23efdf0da9 | 82 | |
bogdanm | 1:4a23efdf0da9 | 83 | //Current message |
bogdanm | 1:4a23efdf0da9 | 84 | char* m_msg; |
bogdanm | 1:4a23efdf0da9 | 85 | size_t m_maxMsgLength; |
bogdanm | 1:4a23efdf0da9 | 86 | char* m_msisdn; |
bogdanm | 1:4a23efdf0da9 | 87 | |
bogdanm | 1:4a23efdf0da9 | 88 | //Messages list |
bogdanm | 1:4a23efdf0da9 | 89 | int m_msgRefList[MAX_SM]; |
bogdanm | 1:4a23efdf0da9 | 90 | size_t m_msgRefListCount; |
bogdanm | 1:4a23efdf0da9 | 91 | bool m_needsUpdate; |
bogdanm | 1:4a23efdf0da9 | 92 | Mutex m_inboxMtx; //To protect concurrent accesses btw the user's thread and the AT thread |
bogdanm | 1:4a23efdf0da9 | 93 | |
bogdanm | 1:4a23efdf0da9 | 94 | 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; |
bogdanm | 1:4a23efdf0da9 | 95 | }; |
bogdanm | 1:4a23efdf0da9 | 96 | |
bogdanm | 1:4a23efdf0da9 | 97 | #endif /* GSMSMSINTERFACE_H_ */ |