A library for talking to Multi-Tech's Cellular SocketModem Devices.
Dependents: M2X_dev axeda_wrapper_dev MTS_M2x_Example1 MTS_Cellular_Connect_Example ... more
Socket/Transport.h@146:efc4db23a564, 2014-01-20 (annotated)
- Committer:
- jengbrecht
- Date:
- Mon Jan 20 15:33:54 2014 +0000
- Revision:
- 146:efc4db23a564
- Parent:
- 141:571e0ef6c8dc
Moved IPStack.h to Socket folder, should eventually be its own library. Also added overloaded setTransport method to Transport for passing in any IPStack derived object, look at merging this concept to mbed official.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kranjan | 141:571e0ef6c8dc | 1 | /* Universal Socket Modem Interface Library |
kranjan | 141:571e0ef6c8dc | 2 | * Copyright (c) 2013 Multi-Tech Systems |
kranjan | 141:571e0ef6c8dc | 3 | * |
kranjan | 141:571e0ef6c8dc | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
kranjan | 141:571e0ef6c8dc | 5 | * you may not use this file except in compliance with the License. |
kranjan | 141:571e0ef6c8dc | 6 | * You may obtain a copy of the License at |
kranjan | 141:571e0ef6c8dc | 7 | * |
kranjan | 141:571e0ef6c8dc | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
kranjan | 141:571e0ef6c8dc | 9 | * |
kranjan | 141:571e0ef6c8dc | 10 | * Unless required by applicable law or agreed to in writing, software |
kranjan | 141:571e0ef6c8dc | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
kranjan | 141:571e0ef6c8dc | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
kranjan | 141:571e0ef6c8dc | 13 | * See the License for the specific language governing permissions and |
kranjan | 141:571e0ef6c8dc | 14 | * limitations under the License. |
kranjan | 141:571e0ef6c8dc | 15 | */ |
kranjan | 141:571e0ef6c8dc | 16 | |
jengbrecht | 66:a170496ec5cf | 17 | #ifndef TRANSPORT_H |
jengbrecht | 66:a170496ec5cf | 18 | #define TRANSPORT_H |
jengbrecht | 66:a170496ec5cf | 19 | |
jengbrecht | 66:a170496ec5cf | 20 | #include "mbed.h" |
jengbrecht | 66:a170496ec5cf | 21 | #include "IPStack.h" |
jengbrecht | 66:a170496ec5cf | 22 | |
jengbrecht | 66:a170496ec5cf | 23 | using namespace mts; |
jengbrecht | 66:a170496ec5cf | 24 | |
jengbrecht | 66:a170496ec5cf | 25 | /** This class has been added to the standard mbed Socket library enabling people |
jengbrecht | 66:a170496ec5cf | 26 | * to use the Socket library interfaces for different transports that have |
jengbrecht | 66:a170496ec5cf | 27 | * their own internal IP-Stack. Use this class prior to instantiating any of the |
jengbrecht | 66:a170496ec5cf | 28 | * other classes in this folder to determine the underlying transport that will |
jengbrecht | 66:a170496ec5cf | 29 | * be used by them. It is important to know that the transport classes themsleves |
jengbrecht | 66:a170496ec5cf | 30 | * like Cellular or WiFi, must be properly initialized and connected before any |
jengbrecht | 66:a170496ec5cf | 31 | * of the Socket package classes can be used or even instantiated. |
jengbrecht | 66:a170496ec5cf | 32 | */ |
jengbrecht | 66:a170496ec5cf | 33 | class Transport |
jengbrecht | 66:a170496ec5cf | 34 | { |
jengbrecht | 66:a170496ec5cf | 35 | public: |
jengbrecht | 66:a170496ec5cf | 36 | ///An enumeration that holds the supported Transport Types. |
jengbrecht | 66:a170496ec5cf | 37 | enum TransportType { |
jengbrecht | 146:efc4db23a564 | 38 | CELLULAR, WIFI, NONE, CUSTOM |
jengbrecht | 66:a170496ec5cf | 39 | }; |
jengbrecht | 66:a170496ec5cf | 40 | |
jengbrecht | 66:a170496ec5cf | 41 | /** This method allows you to set the transport to be used when creating other |
jengbrecht | 66:a170496ec5cf | 42 | * objects from the Socket folder like TCPSocketConnection and UDPSocket. |
jengbrecht | 66:a170496ec5cf | 43 | * |
jengbrecht | 113:7238f9b8db17 | 44 | * @param type the type of underlying transport to be used. The default is NONE. |
jengbrecht | 66:a170496ec5cf | 45 | */ |
jengbrecht | 66:a170496ec5cf | 46 | static void setTransport(TransportType type); |
jengbrecht | 66:a170496ec5cf | 47 | |
jengbrecht | 146:efc4db23a564 | 48 | /** This method allows you to set the transport to be used when creatin other |
jengbrecht | 146:efc4db23a564 | 49 | * objects from the Socket folder like TCPSocketConnection and UDPSocket. It |
jengbrecht | 146:efc4db23a564 | 50 | * differs from the other setTransport method in that it allows for any transport |
jengbrecht | 146:efc4db23a564 | 51 | * that derives from IPStack to be used with the native mbed Socket interfaces. |
jengbrecht | 146:efc4db23a564 | 52 | * |
jengbrecht | 146:efc4db23a564 | 53 | * @param type the type of underlying transport to be used as an IPStack object. |
jengbrecht | 146:efc4db23a564 | 54 | */ |
jengbrecht | 146:efc4db23a564 | 55 | static void setTransport(IPStack* type); |
jengbrecht | 146:efc4db23a564 | 56 | |
jengbrecht | 66:a170496ec5cf | 57 | /** This method is used within the Socket class to get the appropraite transport |
jengbrecht | 66:a170496ec5cf | 58 | * as an IPStack object. In general you do not need to call this directly, but |
jengbrecht | 66:a170496ec5cf | 59 | * simply use the other classes in this folder. |
jengbrecht | 66:a170496ec5cf | 60 | * |
jengbrecht | 66:a170496ec5cf | 61 | * @returns a pointer to an object that implements IPStack. |
jengbrecht | 66:a170496ec5cf | 62 | */ |
jengbrecht | 66:a170496ec5cf | 63 | static IPStack* getInstance(); |
jengbrecht | 66:a170496ec5cf | 64 | |
jengbrecht | 66:a170496ec5cf | 65 | private: |
jengbrecht | 66:a170496ec5cf | 66 | static Transport::TransportType _type; // Member variable that holds the desired transport |
jengbrecht | 146:efc4db23a564 | 67 | static IPStack* customType; //Member variable that holds an custom transport type. |
jengbrecht | 66:a170496ec5cf | 68 | }; |
jengbrecht | 66:a170496ec5cf | 69 | |
jengbrecht | 66:a170496ec5cf | 70 | #endif /* TRANSPORT_H */ |