The beta version of the Vodafone K3770 dongle driver
This library is deprecated. Please use the newest production branch of the library from https://mbed.org/users/mbed_official/code/VodafoneUSBModem/
contrib/vodafone/if/VodafoneK3770.h@0:0ac66acdfdc0, 2012-05-31 (annotated)
- Committer:
- donatien
- Date:
- Thu May 31 15:32:49 2012 +0000
- Revision:
- 0:0ac66acdfdc0
- Child:
- 1:4b33ffe61bfa
Initial Commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
donatien | 0:0ac66acdfdc0 | 1 | /* VodafoneK3770.h */ |
donatien | 0:0ac66acdfdc0 | 2 | /* |
donatien | 0:0ac66acdfdc0 | 3 | Copyright (C) 2012 ARM Limited. |
donatien | 0:0ac66acdfdc0 | 4 | |
donatien | 0:0ac66acdfdc0 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of |
donatien | 0:0ac66acdfdc0 | 6 | this software and associated documentation files (the "Software"), to deal in |
donatien | 0:0ac66acdfdc0 | 7 | the Software without restriction, including without limitation the rights to |
donatien | 0:0ac66acdfdc0 | 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies |
donatien | 0:0ac66acdfdc0 | 9 | of the Software, and to permit persons to whom the Software is furnished to do |
donatien | 0:0ac66acdfdc0 | 10 | so, subject to the following conditions: |
donatien | 0:0ac66acdfdc0 | 11 | |
donatien | 0:0ac66acdfdc0 | 12 | The above copyright notice and this permission notice shall be included in all |
donatien | 0:0ac66acdfdc0 | 13 | copies or substantial portions of the Software. |
donatien | 0:0ac66acdfdc0 | 14 | |
donatien | 0:0ac66acdfdc0 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
donatien | 0:0ac66acdfdc0 | 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
donatien | 0:0ac66acdfdc0 | 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
donatien | 0:0ac66acdfdc0 | 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
donatien | 0:0ac66acdfdc0 | 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
donatien | 0:0ac66acdfdc0 | 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
donatien | 0:0ac66acdfdc0 | 21 | SOFTWARE. |
donatien | 0:0ac66acdfdc0 | 22 | */ |
donatien | 0:0ac66acdfdc0 | 23 | |
donatien | 0:0ac66acdfdc0 | 24 | #ifndef VODAFONEK3770_H_ |
donatien | 0:0ac66acdfdc0 | 25 | #define VODAFONEK3770_H_ |
donatien | 0:0ac66acdfdc0 | 26 | |
donatien | 0:0ac66acdfdc0 | 27 | #include "core/fwk.h" |
donatien | 0:0ac66acdfdc0 | 28 | |
donatien | 0:0ac66acdfdc0 | 29 | #include "USB3GModule/WANDongle.h" |
donatien | 0:0ac66acdfdc0 | 30 | #include "drv/at/ATCommandsInterface.h" |
donatien | 0:0ac66acdfdc0 | 31 | #include "drv/serial/usb/USBSerialStream.h" |
donatien | 0:0ac66acdfdc0 | 32 | #include "if/ip/PPPIPInterface.h" |
donatien | 0:0ac66acdfdc0 | 33 | #include "if/sms/SMSInterface.h" |
donatien | 0:0ac66acdfdc0 | 34 | #include "if/ussd/USSDInterface.h" |
donatien | 0:0ac66acdfdc0 | 35 | |
donatien | 0:0ac66acdfdc0 | 36 | /** Vodafone K3770 dongle |
donatien | 0:0ac66acdfdc0 | 37 | */ |
donatien | 0:0ac66acdfdc0 | 38 | class VodafoneK3770 |
donatien | 0:0ac66acdfdc0 | 39 | { |
donatien | 0:0ac66acdfdc0 | 40 | public: |
donatien | 0:0ac66acdfdc0 | 41 | /** Create Vodafone K3770 dongle API instance |
donatien | 0:0ac66acdfdc0 | 42 | |
donatien | 0:0ac66acdfdc0 | 43 | */ |
donatien | 0:0ac66acdfdc0 | 44 | VodafoneK3770(); |
donatien | 0:0ac66acdfdc0 | 45 | |
donatien | 0:0ac66acdfdc0 | 46 | //Internet-related functions |
donatien | 0:0ac66acdfdc0 | 47 | |
donatien | 0:0ac66acdfdc0 | 48 | /** Open a 3G internet connection |
donatien | 0:0ac66acdfdc0 | 49 | @return 0 on success, error code on failure |
donatien | 0:0ac66acdfdc0 | 50 | */ |
donatien | 0:0ac66acdfdc0 | 51 | int connect(const char* apn = NULL, const char* user = NULL, const char* password = NULL); |
donatien | 0:0ac66acdfdc0 | 52 | |
donatien | 0:0ac66acdfdc0 | 53 | /** Close the internet connection |
donatien | 0:0ac66acdfdc0 | 54 | @return 0 on success, error code on failure |
donatien | 0:0ac66acdfdc0 | 55 | */ |
donatien | 0:0ac66acdfdc0 | 56 | int disconnect(); |
donatien | 0:0ac66acdfdc0 | 57 | |
donatien | 0:0ac66acdfdc0 | 58 | |
donatien | 0:0ac66acdfdc0 | 59 | /** Send a SM |
donatien | 0:0ac66acdfdc0 | 60 | @param number The receiver's phone number |
donatien | 0:0ac66acdfdc0 | 61 | @param message The message to send |
donatien | 0:0ac66acdfdc0 | 62 | @return 0 on success, error code on failure |
donatien | 0:0ac66acdfdc0 | 63 | */ |
donatien | 0:0ac66acdfdc0 | 64 | int sendSM(const char* number, const char* message); |
donatien | 0:0ac66acdfdc0 | 65 | |
donatien | 0:0ac66acdfdc0 | 66 | |
donatien | 0:0ac66acdfdc0 | 67 | /** Receive a SM |
donatien | 0:0ac66acdfdc0 | 68 | @param number Pointer to a buffer to store the sender's phone number (must be at least 17 characters-long, including the sapce for the null-terminating char) |
donatien | 0:0ac66acdfdc0 | 69 | @param message Pointer to a buffer to store the the incoming message |
donatien | 0:0ac66acdfdc0 | 70 | @param maxLength Maximum message length that can be stored in buffer (including null-terminating character) |
donatien | 0:0ac66acdfdc0 | 71 | @return 0 on success, error code on failure |
donatien | 0:0ac66acdfdc0 | 72 | */ |
donatien | 0:0ac66acdfdc0 | 73 | int getSM(char* number, char* message, size_t maxLength); |
donatien | 0:0ac66acdfdc0 | 74 | |
donatien | 0:0ac66acdfdc0 | 75 | /** Get the number of SMs in the incoming box |
donatien | 0:0ac66acdfdc0 | 76 | @param pCount pointer to store the number of unprocessed SMs on |
donatien | 0:0ac66acdfdc0 | 77 | @return 0 on success, error code on failure |
donatien | 0:0ac66acdfdc0 | 78 | */ |
donatien | 0:0ac66acdfdc0 | 79 | int getSMCount(size_t* pCount); |
donatien | 0:0ac66acdfdc0 | 80 | |
donatien | 0:0ac66acdfdc0 | 81 | /** Send a USSD command & wait for its result |
donatien | 0:0ac66acdfdc0 | 82 | @param command The command to send |
donatien | 0:0ac66acdfdc0 | 83 | @param result Buffer in which to store the result |
donatien | 0:0ac66acdfdc0 | 84 | @param maxLength Maximum result length that can be stored in buffer (including null-terminating character) |
donatien | 0:0ac66acdfdc0 | 85 | @return 0 on success, error code on failure |
donatien | 0:0ac66acdfdc0 | 86 | */ |
donatien | 0:0ac66acdfdc0 | 87 | int sendUSSD(const char* command, char* result, size_t maxLength); |
donatien | 0:0ac66acdfdc0 | 88 | |
donatien | 0:0ac66acdfdc0 | 89 | /** Get the ATCommandsInterface instance |
donatien | 0:0ac66acdfdc0 | 90 | @return Pointer to the ATCommandsInterface instance |
donatien | 0:0ac66acdfdc0 | 91 | */ |
donatien | 0:0ac66acdfdc0 | 92 | ATCommandsInterface* getATCommandsInterface(); |
donatien | 0:0ac66acdfdc0 | 93 | |
donatien | 0:0ac66acdfdc0 | 94 | protected: |
donatien | 0:0ac66acdfdc0 | 95 | int init(); |
donatien | 0:0ac66acdfdc0 | 96 | |
donatien | 0:0ac66acdfdc0 | 97 | private: |
donatien | 0:0ac66acdfdc0 | 98 | WANDongle m_dongle; |
donatien | 0:0ac66acdfdc0 | 99 | USBSerialStream m_stream; |
donatien | 0:0ac66acdfdc0 | 100 | ATCommandsInterface m_at; |
donatien | 0:0ac66acdfdc0 | 101 | PPPIPInterface m_ppp; |
donatien | 0:0ac66acdfdc0 | 102 | SMSInterface m_sms; |
donatien | 0:0ac66acdfdc0 | 103 | USSDInterface m_ussd; |
donatien | 0:0ac66acdfdc0 | 104 | |
donatien | 0:0ac66acdfdc0 | 105 | bool m_dongleConnected; |
donatien | 0:0ac66acdfdc0 | 106 | bool m_ipInit; |
donatien | 0:0ac66acdfdc0 | 107 | bool m_smsInit; |
donatien | 0:0ac66acdfdc0 | 108 | bool m_ussdInit; |
donatien | 0:0ac66acdfdc0 | 109 | bool m_atOpen; |
donatien | 0:0ac66acdfdc0 | 110 | }; |
donatien | 0:0ac66acdfdc0 | 111 | |
donatien | 0:0ac66acdfdc0 | 112 | |
donatien | 0:0ac66acdfdc0 | 113 | #endif /* VODAFONEK3770_H_ */ |