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
ussd/USSDInterface.h@10:21a6f09d5631, 2012-07-06 (annotated)
- Committer:
- donatien
- Date:
- Fri Jul 06 08:56:32 2012 +0000
- Revision:
- 10:21a6f09d5631
- Parent:
- 8:04b6a042595f
- Child:
- 22:06fb2a93a1f6
Dual serial ports support
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
donatien | 0:3b2f052c333b | 1 | /* USSDInterface.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 USSDINTERFACE_H_ |
donatien | 0:3b2f052c333b | 25 | #define USSDINTERFACE_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 | 10:21a6f09d5631 | 31 | #include "at/ATCommandsInterface.h" |
donatien | 0:3b2f052c333b | 32 | |
donatien | 0:3b2f052c333b | 33 | /** Component to send/receive Unstructured Supplementary Service Data (USSD) |
donatien | 0:3b2f052c333b | 34 | * |
donatien | 0:3b2f052c333b | 35 | */ |
donatien | 0:3b2f052c333b | 36 | class USSDInterface : protected IATEventsHandler |
donatien | 0:3b2f052c333b | 37 | { |
donatien | 0:3b2f052c333b | 38 | public: |
donatien | 0:3b2f052c333b | 39 | /** Create USSDInterface instance |
donatien | 0:3b2f052c333b | 40 | @param pIf Pointer to the ATCommandsInterface instance to use |
donatien | 0:3b2f052c333b | 41 | */ |
donatien | 0:3b2f052c333b | 42 | USSDInterface(ATCommandsInterface* pIf); |
donatien | 0:3b2f052c333b | 43 | |
donatien | 0:3b2f052c333b | 44 | /** Initialize interface |
donatien | 0:3b2f052c333b | 45 | Configure USSD commands & register for USSD-related unsolicited result codes |
donatien | 0:3b2f052c333b | 46 | */ |
donatien | 0:3b2f052c333b | 47 | int init(); |
donatien | 0:3b2f052c333b | 48 | |
donatien | 0:3b2f052c333b | 49 | /** Send a USSD command & wait for its result |
donatien | 0:3b2f052c333b | 50 | @param command The command to send |
donatien | 0:3b2f052c333b | 51 | @param result Buffer in which to store the result |
donatien | 0:3b2f052c333b | 52 | @param maxLength Maximum result length that can be stored in buffer (including null-terminating character) |
donatien | 0:3b2f052c333b | 53 | @return 0 on success, error code on failure |
donatien | 0:3b2f052c333b | 54 | */ |
donatien | 0:3b2f052c333b | 55 | int send(const char* command, char* result, size_t maxLength); |
donatien | 0:3b2f052c333b | 56 | |
donatien | 0:3b2f052c333b | 57 | protected: |
donatien | 0:3b2f052c333b | 58 | //IATEventsHandler |
donatien | 0:3b2f052c333b | 59 | virtual bool isATCodeHandled(const char* atCode); //Is this AT code handled |
donatien | 0:3b2f052c333b | 60 | virtual void onDispatchStart(); |
donatien | 0:3b2f052c333b | 61 | virtual void onDispatchStop(); |
donatien | 0:3b2f052c333b | 62 | virtual void onEvent(const char* atCode, const char* evt); |
donatien | 0:3b2f052c333b | 63 | |
donatien | 0:3b2f052c333b | 64 | private: |
donatien | 0:3b2f052c333b | 65 | ATCommandsInterface* m_pIf; |
donatien | 0:3b2f052c333b | 66 | Mutex m_responseMtx; //To protect concurrent accesses btw the user's thread and the AT thread |
donatien | 0:3b2f052c333b | 67 | Semaphore m_responseSphre; |
donatien | 0:3b2f052c333b | 68 | |
donatien | 0:3b2f052c333b | 69 | //Result |
donatien | 0:3b2f052c333b | 70 | char* m_result; |
donatien | 0:3b2f052c333b | 71 | size_t m_maxResultLength; |
donatien | 0:3b2f052c333b | 72 | |
donatien | 0:3b2f052c333b | 73 | }; |
donatien | 0:3b2f052c333b | 74 | |
donatien | 0:3b2f052c333b | 75 | |
donatien | 0:3b2f052c333b | 76 | #endif /* USSDINTERFACE_H_ */ |