local fork
Dependencies: Socket USBHostWANDongle_bleedingedge lwip-sys lwip
Fork of VodafoneUSBModem_bleedingedge by
ussd/USSDInterface.h@57:593fb493172f, 2012-10-24 (annotated)
- Committer:
- donatien
- Date:
- Wed Oct 24 14:13:49 2012 +0000
- Revision:
- 57:593fb493172f
- Parent:
- 35:be311326ee06
- Disabling/Re-enabling of unsollicited response codes between commands to avoid having unsollicited result codes mixed up with commands responses; - Suppressed 100ms guard time in ATCommandsInterface; - Fixed race condition in ATCommandsInterface
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
donatien | 0:3b2f052c333b | 1 | /* USSDInterface.h */ |
donatien | 22:06fb2a93a1f6 | 2 | /* Copyright (C) 2012 mbed.org, MIT License |
donatien | 22:06fb2a93a1f6 | 3 | * |
donatien | 22:06fb2a93a1f6 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
donatien | 22:06fb2a93a1f6 | 5 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
donatien | 22:06fb2a93a1f6 | 6 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
donatien | 22:06fb2a93a1f6 | 7 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
donatien | 22:06fb2a93a1f6 | 8 | * furnished to do so, subject to the following conditions: |
donatien | 22:06fb2a93a1f6 | 9 | * |
donatien | 22:06fb2a93a1f6 | 10 | * The above copyright notice and this permission notice shall be included in all copies or |
donatien | 22:06fb2a93a1f6 | 11 | * substantial portions of the Software. |
donatien | 22:06fb2a93a1f6 | 12 | * |
donatien | 22:06fb2a93a1f6 | 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
donatien | 22:06fb2a93a1f6 | 14 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
donatien | 22:06fb2a93a1f6 | 15 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
donatien | 22:06fb2a93a1f6 | 16 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
donatien | 22:06fb2a93a1f6 | 17 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
donatien | 22:06fb2a93a1f6 | 18 | */ |
donatien | 0:3b2f052c333b | 19 | |
donatien | 0:3b2f052c333b | 20 | #ifndef USSDINTERFACE_H_ |
donatien | 0:3b2f052c333b | 21 | #define USSDINTERFACE_H_ |
donatien | 0:3b2f052c333b | 22 | |
donatien | 0:3b2f052c333b | 23 | #include "core/fwk.h" |
donatien | 0:3b2f052c333b | 24 | |
donatien | 0:3b2f052c333b | 25 | #include "rtos.h" |
donatien | 0:3b2f052c333b | 26 | |
donatien | 10:21a6f09d5631 | 27 | #include "at/ATCommandsInterface.h" |
donatien | 0:3b2f052c333b | 28 | |
donatien | 0:3b2f052c333b | 29 | /** Component to send/receive Unstructured Supplementary Service Data (USSD) |
donatien | 0:3b2f052c333b | 30 | * |
donatien | 0:3b2f052c333b | 31 | */ |
donatien | 29:870de7db2ccb | 32 | class USSDInterface : protected IATCommandsProcessor, IATEventsHandler |
donatien | 0:3b2f052c333b | 33 | { |
donatien | 0:3b2f052c333b | 34 | public: |
donatien | 0:3b2f052c333b | 35 | /** Create USSDInterface instance |
donatien | 0:3b2f052c333b | 36 | @param pIf Pointer to the ATCommandsInterface instance to use |
donatien | 0:3b2f052c333b | 37 | */ |
donatien | 0:3b2f052c333b | 38 | USSDInterface(ATCommandsInterface* pIf); |
donatien | 0:3b2f052c333b | 39 | |
donatien | 0:3b2f052c333b | 40 | /** Initialize interface |
donatien | 0:3b2f052c333b | 41 | Configure USSD commands & register for USSD-related unsolicited result codes |
donatien | 0:3b2f052c333b | 42 | */ |
donatien | 0:3b2f052c333b | 43 | int init(); |
donatien | 0:3b2f052c333b | 44 | |
donatien | 0:3b2f052c333b | 45 | /** Send a USSD command & wait for its result |
donatien | 0:3b2f052c333b | 46 | @param command The command to send |
donatien | 0:3b2f052c333b | 47 | @param result Buffer in which to store the result |
donatien | 0:3b2f052c333b | 48 | @param maxLength Maximum result length that can be stored in buffer (including null-terminating character) |
donatien | 0:3b2f052c333b | 49 | @return 0 on success, error code on failure |
donatien | 0:3b2f052c333b | 50 | */ |
donatien | 0:3b2f052c333b | 51 | int send(const char* command, char* result, size_t maxLength); |
donatien | 0:3b2f052c333b | 52 | |
donatien | 0:3b2f052c333b | 53 | protected: |
donatien | 29:870de7db2ccb | 54 | //IATCommandsProcessor, needed for implementations of 3GGP standard < r06 |
donatien | 29:870de7db2ccb | 55 | virtual int onNewATResponseLine(ATCommandsInterface* pInst, const char* line); |
donatien | 29:870de7db2ccb | 56 | virtual int onNewEntryPrompt(ATCommandsInterface* pInst); |
donatien | 29:870de7db2ccb | 57 | |
donatien | 29:870de7db2ccb | 58 | //IATEventsHandler, needed for implementations of 3GGP standard >= r06 |
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 | 57:593fb493172f | 62 | virtual char* getEventsEnableCommand(); |
donatien | 57:593fb493172f | 63 | virtual char* getEventsDisableCommand(); |
donatien | 0:3b2f052c333b | 64 | virtual void onEvent(const char* atCode, const char* evt); |
donatien | 0:3b2f052c333b | 65 | |
donatien | 0:3b2f052c333b | 66 | private: |
donatien | 29:870de7db2ccb | 67 | void processResult(const char* data); |
donatien | 29:870de7db2ccb | 68 | |
donatien | 0:3b2f052c333b | 69 | ATCommandsInterface* m_pIf; |
donatien | 0:3b2f052c333b | 70 | Mutex m_responseMtx; //To protect concurrent accesses btw the user's thread and the AT thread |
donatien | 0:3b2f052c333b | 71 | Semaphore m_responseSphre; |
donatien | 0:3b2f052c333b | 72 | |
donatien | 0:3b2f052c333b | 73 | //Result |
donatien | 35:be311326ee06 | 74 | volatile char* m_result; |
donatien | 35:be311326ee06 | 75 | volatile size_t m_maxResultLength; |
donatien | 0:3b2f052c333b | 76 | |
donatien | 0:3b2f052c333b | 77 | }; |
donatien | 0:3b2f052c333b | 78 | |
donatien | 0:3b2f052c333b | 79 | |
donatien | 0:3b2f052c333b | 80 | #endif /* USSDINTERFACE_H_ */ |