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:
148:df9feef182b4
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 0:563b70517320 17 #ifndef VARS_H
jengbrecht 0:563b70517320 18 #define VARS_H
jengbrecht 0:563b70517320 19
jengbrecht 0:563b70517320 20 #include <string>
jengbrecht 0:563b70517320 21
jengbrecht 87:5db6c084adc7 22 namespace mts
jengbrecht 87:5db6c084adc7 23 {
mfiore 39:6e94520a3217 24
sgodinez 32:629e6b1c8e22 25 #ifndef MAX
sgodinez 32:629e6b1c8e22 26 #define MAX(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
sgodinez 32:629e6b1c8e22 27 #endif
jengbrecht 87:5db6c084adc7 28
sgodinez 32:629e6b1c8e22 29 #ifndef MIN
sgodinez 32:629e6b1c8e22 30 #define MIN(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
sgodinez 32:629e6b1c8e22 31 #endif
sgodinez 32:629e6b1c8e22 32
sgodinez 32:629e6b1c8e22 33
sgodinez 71:82205735732b 34 /// An enumeration for common responses.
sgodinez 71:82205735732b 35 enum Code {
mfiore 148:df9feef182b4 36 MTS_SUCCESS, MTS_ERROR, MTS_FAILURE, MTS_NO_RESPONSE
sgodinez 71:82205735732b 37 };
sgodinez 71:82205735732b 38
jengbrecht 87:5db6c084adc7 39 /** A static method for getting a string representation for the Code
jengbrecht 87:5db6c084adc7 40 * enumeration.
jengbrecht 87:5db6c084adc7 41 *
jengbrecht 87:5db6c084adc7 42 * @param code a Code enumeration.
jengbrecht 87:5db6c084adc7 43 * @returns the enumeration name as a string.
jengbrecht 87:5db6c084adc7 44 */
jengbrecht 87:5db6c084adc7 45 static std::string getCodeNames(Code code)
jengbrecht 87:5db6c084adc7 46 {
jengbrecht 87:5db6c084adc7 47 switch(code) {
mfiore 148:df9feef182b4 48 case MTS_SUCCESS:
jengbrecht 87:5db6c084adc7 49 return "SUCCESS";
mfiore 148:df9feef182b4 50 case MTS_ERROR:
jengbrecht 87:5db6c084adc7 51 return "ERROR";
mfiore 148:df9feef182b4 52 case MTS_NO_RESPONSE:
jengbrecht 87:5db6c084adc7 53 return "NO_RESPONSE";
mfiore 148:df9feef182b4 54 case MTS_FAILURE:
jengbrecht 87:5db6c084adc7 55 return "FAILURE";
jengbrecht 87:5db6c084adc7 56 default:
jengbrecht 87:5db6c084adc7 57 return "UNKNOWN ENUM";
jengbrecht 87:5db6c084adc7 58 }
jengbrecht 87:5db6c084adc7 59 }
sgodinez 71:82205735732b 60
sgodinez 71:82205735732b 61 const unsigned int PINGDELAY = 3; //Time to wait on each ping for a response before timimg out (seconds)
sgodinez 71:82205735732b 62 const unsigned int PINGNUM = 4; //Number of pings to try on ping command
sgodinez 71:82205735732b 63
sgodinez 71:82205735732b 64 //Special Payload Characters
sgodinez 71:82205735732b 65 const char ETX = 0x03; //Ends socket connection
sgodinez 71:82205735732b 66 const char DLE = 0x10; //Escapes ETX and DLE within Payload
sgodinez 71:82205735732b 67 const char CR = 0x0D;
sgodinez 71:82205735732b 68 const char NL = 0x0A;
sgodinez 71:82205735732b 69 const char CTRL_Z = 0x1A;
sgodinez 71:82205735732b 70
jengbrecht 0:563b70517320 71
jengbrecht 0:563b70517320 72 /** This class holds several enum types and other static variables
jengbrecht 0:563b70517320 73 * that are used throughout the rest of the SDK.
jengbrecht 0:563b70517320 74 */
jengbrecht 0:563b70517320 75 class Vars
jengbrecht 0:563b70517320 76 {
jengbrecht 0:563b70517320 77 public:
jengbrecht 0:563b70517320 78 /// Enumeration for different cellular radio types.
jengbrecht 0:563b70517320 79 enum Radio {NA, E1, G2, EV2, H4, EV3, H5};
jengbrecht 0:563b70517320 80
jengbrecht 0:563b70517320 81 enum RelationalOperator {GREATER, LESS, EQUAL, GREATER_EQUAL, LESS_EQUAL};
jengbrecht 0:563b70517320 82 };
jengbrecht 0:563b70517320 83
mfiore 39:6e94520a3217 84 }
mfiore 39:6e94520a3217 85
jengbrecht 1:f641337952a9 86 //Test Commit!!!
jengbrecht 1:f641337952a9 87
jengbrecht 87:5db6c084adc7 88 #endif /* VARS_H */