Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MTS-Cellular by
CellularFactory.cpp
00001 #include "mbed.h" 00002 #include "CellularFactory.h" 00003 #include "MTSLog.h" 00004 #include <string> 00005 00006 using namespace mts; 00007 00008 Cellular* CellularFactory::create(MTSBufferedIO* io) { 00009 bool uip; 00010 std::string model; 00011 std::string reply; 00012 Cellular::Radio type = Cellular::NA; 00013 Cellular* cell; 00014 00015 /* wait for radio to get into a good state */ 00016 while (true) { 00017 if (sendCommand(io, "AT", 1000).find("OK") != string::npos) { 00018 logTrace("radio replied"); 00019 break; 00020 } else { 00021 logTrace("waiting on radio..."); 00022 } 00023 wait(1); 00024 } 00025 00026 while (true) { 00027 /* AT#VVERSION is a UIP specific AT command 00028 * if we get an error response, we're not using a UIP board */ 00029 reply = sendCommand(io, "AT#VVERSION", 2000); 00030 if ((reply.find("ERROR") != string::npos) || (reply.find("error") != string::npos)) { 00031 uip = false; 00032 break; 00033 } else if (reply.find("VVERSION:") != string::npos) { 00034 uip = true; 00035 break; 00036 } else { 00037 logTrace("Checking for UIP chip"); 00038 } 00039 wait(1); 00040 } 00041 00042 /* "ATI4" gets us the model (HE910, DE910, etc) */ 00043 while (true) { 00044 string mNumber; 00045 model = sendCommand(io, "ATI4", 3000); 00046 logTrace("Modem reported model: %s", model.c_str()); 00047 if (uip) { 00048 if (model.find("HE910") != string::npos) { 00049 type = Cellular::MTSMC_H5_IP; 00050 mNumber = "HE910"; 00051 } else if (model.find("DE910") != string::npos) { 00052 type = Cellular::MTSMC_EV3_IP; 00053 mNumber = "DE910"; 00054 } else if (model.find("CE910") != string::npos) { 00055 type = Cellular::MTSMC_C2_IP; 00056 mNumber = "CE910"; 00057 } 00058 if (type != Cellular::NA) { 00059 cell = new UIP(type); 00060 logDebug("UIP radio model: %s", mNumber.c_str()); 00061 break; 00062 } 00063 } else { 00064 if (model.find("HE910") != string::npos) { 00065 type = Cellular::MTSMC_H5; 00066 mNumber = "HE910"; 00067 } else if (model.find("DE910") != string::npos) { 00068 type = Cellular::MTSMC_EV3; 00069 mNumber = "DE910"; 00070 } else if (model.find("CE910") != string::npos) { 00071 type = Cellular::MTSMC_C2; 00072 mNumber = "CE910"; 00073 } else if (model.find("GE910") != string::npos) { 00074 type = Cellular::MTSMC_G3; 00075 mNumber = "GE910"; 00076 } else if (model.find("LE910-NAG") != string::npos) { 00077 type = Cellular::MTSMC_LAT1; 00078 mNumber = "LE910-NAG"; 00079 } else if(model.find("ME910C1-NV") != string::npos) { 00080 type = Cellular::MTSMC_LAT3; 00081 mNumber = "ME910C-NV"; 00082 } else if (model.find("LE910-SVG") != string::npos) { 00083 type = Cellular::MTSMC_LVW2; 00084 mNumber = "LE910-SVG"; 00085 } else if (model.find("LE910-EUG") != string::npos) { 00086 type = Cellular::MTSMC_LEU1; 00087 mNumber = "LE910-EUG"; 00088 } 00089 if (type != Cellular::NA) { 00090 cell = new EasyIP(type); 00091 logDebug("EasyIP radio model: %s", mNumber.c_str()); 00092 break; 00093 } 00094 } 00095 logTrace("Determining radio type"); 00096 wait(1); 00097 } 00098 00099 if (! cell->init(io)) { 00100 logError("cellular initialization failed"); 00101 return NULL; 00102 } 00103 00104 return cell; 00105 }
Generated on Tue Jul 12 2022 19:53:40 by
1.7.2
