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

Committer:
mfiore
Date:
Tue Sep 02 18:38:55 2014 +0000
Revision:
152:9a2c7ed27744
Parent:
146:efc4db23a564
Wifi: fix compatibility break with old shields by checking for both old and new style responses to "show connection" command

Who changed what in which revision?

UserRevisionLine numberNew 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 #include "Transport.h"
jengbrecht 66:a170496ec5cf 18 #include "Cellular.h"
jengbrecht 74:9f87bd22c222 19 #include "Wifi.h"
jengbrecht 66:a170496ec5cf 20
jengbrecht 113:7238f9b8db17 21 Transport::TransportType Transport::_type = Transport::NONE;
jengbrecht 66:a170496ec5cf 22
jengbrecht 146:efc4db23a564 23 IPStack* Transport::customType = NULL;
jengbrecht 146:efc4db23a564 24
jengbrecht 66:a170496ec5cf 25 void Transport::setTransport(TransportType type)
jengbrecht 66:a170496ec5cf 26 {
jengbrecht 146:efc4db23a564 27 if (type == CUSTOM) {
jengbrecht 146:efc4db23a564 28 printf("[ERROR] Transport not set, use other setTransport method for setting custom type.\n\r");
jengbrecht 146:efc4db23a564 29 return;
jengbrecht 146:efc4db23a564 30 }
jengbrecht 66:a170496ec5cf 31 _type = type;
jengbrecht 66:a170496ec5cf 32 }
jengbrecht 66:a170496ec5cf 33
jengbrecht 146:efc4db23a564 34 void Transport::setTransport(IPStack* type)
jengbrecht 146:efc4db23a564 35 {
jengbrecht 146:efc4db23a564 36 customType = type;
jengbrecht 146:efc4db23a564 37 _type = CUSTOM;
jengbrecht 146:efc4db23a564 38 }
jengbrecht 146:efc4db23a564 39
jengbrecht 66:a170496ec5cf 40 IPStack* Transport::getInstance()
jengbrecht 66:a170496ec5cf 41 {
jengbrecht 66:a170496ec5cf 42 switch (_type) {
jengbrecht 66:a170496ec5cf 43 case CELLULAR:
jengbrecht 66:a170496ec5cf 44 return (IPStack*) Cellular::getInstance();
jengbrecht 66:a170496ec5cf 45 case WIFI:
jengbrecht 74:9f87bd22c222 46 return (IPStack*) Wifi::getInstance();
jengbrecht 146:efc4db23a564 47 case CUSTOM:
jengbrecht 146:efc4db23a564 48 return customType;
jengbrecht 66:a170496ec5cf 49 default:
jengbrecht 113:7238f9b8db17 50 printf("[ERROR] Transport not set, use setTransport method.\n\r");
jengbrecht 113:7238f9b8db17 51 return NULL;
jengbrecht 66:a170496ec5cf 52 }
jengbrecht 66:a170496ec5cf 53 }
kranjan 141:571e0ef6c8dc 54