mbed official / VodafoneUSBModem

Dependencies:   Socket USBHostWANDongle lwip-sys lwip

Dependents:   VodafoneUSBModemHTTPClientTest VodafoneUSBModemNTPClientTest VodafoneUSBModemSMSTest VodafoneUSBModemUSSDTest ... more

Fork of VodafoneUSBModem_bleedingedge by Donatien Garnier

Committer:
ashleymills
Date:
Fri Sep 20 10:40:58 2013 +0000
Revision:
91:7b311719374d
Parent:
27:37d3ac289e86
Added support for Ublox LISA U200 module. Fixed bug for modules that throw away blocked unsolicited messages.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 16:02db4f537955 1 /* IPInterface.cpp */
donatien 16:02db4f537955 2 /* Copyright (C) 2012 mbed.org, MIT License
donatien 16:02db4f537955 3 *
donatien 16:02db4f537955 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
donatien 16:02db4f537955 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
donatien 16:02db4f537955 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
donatien 16:02db4f537955 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
donatien 16:02db4f537955 8 * furnished to do so, subject to the following conditions:
donatien 16:02db4f537955 9 *
donatien 16:02db4f537955 10 * The above copyright notice and this permission notice shall be included in all copies or
donatien 16:02db4f537955 11 * substantial portions of the Software.
donatien 16:02db4f537955 12 *
donatien 16:02db4f537955 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
donatien 16:02db4f537955 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
donatien 16:02db4f537955 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
donatien 16:02db4f537955 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
donatien 16:02db4f537955 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
donatien 16:02db4f537955 18 */
donatien 16:02db4f537955 19
donatien 16:02db4f537955 20 #include "core/fwk.h"
donatien 16:02db4f537955 21
donatien 16:02db4f537955 22 #include "IPInterface.h"
donatien 16:02db4f537955 23
donatien 16:02db4f537955 24 #include <cstring> //For strcpy
donatien 16:02db4f537955 25
donatien 16:02db4f537955 26
donatien 27:37d3ac289e86 27 IPInterface::IPInterface() : m_connected(false)
donatien 16:02db4f537955 28 {
donatien 16:02db4f537955 29
donatien 16:02db4f537955 30 }
donatien 16:02db4f537955 31
donatien 16:02db4f537955 32 /*virtual*/ IPInterface::~IPInterface()
donatien 16:02db4f537955 33 {
donatien 16:02db4f537955 34
donatien 16:02db4f537955 35 }
donatien 16:02db4f537955 36
donatien 16:02db4f537955 37 void IPInterface::registerAsDefaultInterface() //First come, first served
donatien 16:02db4f537955 38 {
donatien 16:02db4f537955 39 s_pDefaultInterface = this;
donatien 16:02db4f537955 40 }
donatien 16:02db4f537955 41
donatien 16:02db4f537955 42 void IPInterface::unregisterAsDefaultInterface() //Must be called before inst is destroyed to avoid invalid ptr fault
donatien 16:02db4f537955 43 {
donatien 16:02db4f537955 44 s_pDefaultInterface = NULL;
donatien 16:02db4f537955 45 }
donatien 16:02db4f537955 46
donatien 16:02db4f537955 47 /*static*/ IPInterface* IPInterface::getDefaultInterface() //For use by TCP, UDP sockets library
donatien 16:02db4f537955 48 {
donatien 16:02db4f537955 49 return s_pDefaultInterface;
donatien 16:02db4f537955 50 }
donatien 16:02db4f537955 51
donatien 16:02db4f537955 52 /*static*/ IPInterface* IPInterface::s_pDefaultInterface = NULL;
donatien 16:02db4f537955 53
donatien 16:02db4f537955 54
donatien 16:02db4f537955 55 char* IPInterface::getIPAddress() //Get IP Address as a string ('a.b.c.d')
donatien 16:02db4f537955 56 {
donatien 16:02db4f537955 57 if(isConnected())
donatien 16:02db4f537955 58 {
donatien 16:02db4f537955 59 return m_ipAddr;
donatien 16:02db4f537955 60 }
donatien 16:02db4f537955 61 else
donatien 16:02db4f537955 62 {
donatien 16:02db4f537955 63 return NULL;
donatien 16:02db4f537955 64 }
donatien 16:02db4f537955 65 }
donatien 16:02db4f537955 66
donatien 16:02db4f537955 67 bool IPInterface::isConnected() //Is the interface connected?
donatien 16:02db4f537955 68 {
donatien 16:02db4f537955 69 return m_connected;
donatien 16:02db4f537955 70 }
donatien 16:02db4f537955 71
donatien 16:02db4f537955 72 void IPInterface::setIPAddress(char* ipAddr)
donatien 16:02db4f537955 73 {
donatien 16:02db4f537955 74 std::strcpy(m_ipAddr, ipAddr); //Let's trust the derived class not to buffer overflow us
donatien 16:02db4f537955 75 }
donatien 16:02db4f537955 76
donatien 16:02db4f537955 77 void IPInterface::setConnected(bool connected)
donatien 16:02db4f537955 78 {
donatien 16:02db4f537955 79 m_connected = connected;
donatien 16:02db4f537955 80 }
donatien 16:02db4f537955 81