Nicholas Herriot / VodafoneK3770Lib
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers VodafoneK3770.h Source File

VodafoneK3770.h

00001 /* VodafoneK3770.h */
00002 /*
00003 Copyright (C) 2012 ARM Limited.
00004 
00005 Permission is hereby granted, free of charge, to any person obtaining a copy of
00006 this software and associated documentation files (the "Software"), to deal in
00007 the Software without restriction, including without limitation the rights to
00008 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
00009 of the Software, and to permit persons to whom the Software is furnished to do
00010 so, subject to the following conditions:
00011 
00012 The above copyright notice and this permission notice shall be included in all
00013 copies or substantial portions of the Software.
00014 
00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00018 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00019 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00020 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
00021 SOFTWARE.
00022 */
00023 
00024 #ifndef VODAFONEK3770_H_
00025 #define VODAFONEK3770_H_
00026 
00027 #include "core/fwk.h"
00028 
00029 #include "USB3GModule/WANDongle.h"
00030 #include "drv/at/ATCommandsInterface.h"
00031 #include "drv/serial/usb/USBSerialStream.h"
00032 #include "if/ip/PPPIPInterface.h"
00033 #include "if/sms/SMSInterface.h"
00034 
00035 /** Vodafone K3770 dongle
00036  */
00037 class VodafoneK3770
00038 {
00039 public:
00040   /** Create Vodafone K3770 dongle API instance
00041 
00042    */
00043   VodafoneK3770();
00044 
00045   //Internet-related functions
00046 
00047   /** Open a 3G internet connection
00048       @return 0 on success, error code on failure
00049   */
00050   int connect(const char* apn = NULL, const char* user = NULL, const char* password = NULL);
00051 
00052   /** Close the internet connection
00053      @return 0 on success, error code on failure
00054   */
00055   int disconnect();
00056 
00057 
00058   /** Send a SM
00059      @param number The receiver's phone number
00060      @param message The message to send
00061      @return 0 on success, error code on failure
00062    */
00063   int sendSM(const char* number, const char* message);
00064 
00065 
00066   /** Receive a SM
00067      @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)
00068      @param message Pointer to a buffer to store the the incoming message
00069      @param maxLength Maximum message length that can be stored in buffer (including null-terminating character)
00070      @return 0 on success, error code on failure
00071    */
00072   int getSM(char* number, char* message, size_t maxLength);
00073 
00074   /** Get the number of SMs in the incoming box
00075      @param pCount pointer to store the number of unprocessed SMs on
00076      @return 0 on success, error code on failure
00077    */
00078   int getSMCount(size_t* pCount);
00079 
00080 protected:
00081   int init();
00082 
00083 private:
00084   WANDongle m_dongle;
00085   USBSerialStream m_stream;
00086   ATCommandsInterface m_at;
00087   PPPIPInterface m_ppp;
00088   SMSInterface m_sms;
00089 
00090   bool m_dongleConnected;
00091   bool m_ipInit;
00092   bool m_smsInit;
00093   bool m_atOpen;
00094 };
00095 
00096 
00097 #endif /* VODAFONEK3770_H_ */