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.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
GEMALTO_CINTERION.cpp
00001 /* 00002 * Copyright (c) 2018, Arm Limited and affiliates. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #include "GEMALTO_CINTERION_CellularContext.h" 00019 #include "GEMALTO_CINTERION_CellularInformation.h" 00020 #include "GEMALTO_CINTERION.h" 00021 #include "AT_CellularNetwork.h" 00022 #include "CellularLog.h" 00023 00024 using namespace mbed; 00025 using namespace events; 00026 00027 const uint16_t RESPONSE_TO_SEND_DELAY = 100; // response-to-send delay in milliseconds at bit-rate over 9600 00028 00029 GEMALTO_CINTERION::Module GEMALTO_CINTERION::_module; 00030 00031 GEMALTO_CINTERION::GEMALTO_CINTERION(FileHandle *fh) : AT_CellularDevice(fh) 00032 { 00033 } 00034 00035 AT_CellularContext *GEMALTO_CINTERION::create_context_impl(ATHandler &at, const char *apn, bool cp_req, bool nonip_req) 00036 { 00037 return new GEMALTO_CINTERION_CellularContext(at, this, apn, cp_req, nonip_req); 00038 } 00039 00040 AT_CellularInformation *GEMALTO_CINTERION::open_information_impl(ATHandler &at) 00041 { 00042 if (_module == ModuleBGS2) { 00043 return new GEMALTO_CINTERION_CellularInformation(at, *this); 00044 } 00045 return AT_CellularDevice::open_information_impl(at); 00046 } 00047 00048 nsapi_error_t GEMALTO_CINTERION::init() 00049 { 00050 nsapi_error_t err = AT_CellularDevice::init(); 00051 if (err != NSAPI_ERROR_OK ) { 00052 return err; 00053 } 00054 00055 CellularInformation *information = open_information(); 00056 if (!information) { 00057 return NSAPI_ERROR_NO_MEMORY ; 00058 } 00059 char model[sizeof("EHS5-E") + 1]; // sizeof need to be long enough to hold just the model text 00060 nsapi_error_t ret = information->get_model(model, sizeof(model)); 00061 close_information(); 00062 if (ret != NSAPI_ERROR_OK ) { 00063 tr_error("Cellular model not found!"); 00064 return NSAPI_ERROR_DEVICE_ERROR ; 00065 } 00066 00067 if (memcmp(model, "ELS61", sizeof("ELS61") - 1) == 0) { 00068 init_module_els61(); 00069 } else if (memcmp(model, "BGS2", sizeof("BGS2") - 1) == 0) { 00070 init_module_bgs2(); 00071 } else if (memcmp(model, "EMS31", sizeof("EMS31") - 1) == 0) { 00072 init_module_ems31(); 00073 } else if (memcmp(model, "EHS5-E", sizeof("EHS5-E") - 1) == 0) { 00074 init_module_ehs5e(); 00075 } else { 00076 tr_error("Cinterion model unsupported %s", model); 00077 return NSAPI_ERROR_UNSUPPORTED ; 00078 } 00079 tr_info("Cinterion model %s (%d)", model, _module); 00080 00081 set_at_urcs(); 00082 00083 return NSAPI_ERROR_OK ; 00084 } 00085 00086 uint16_t GEMALTO_CINTERION::get_send_delay() const 00087 { 00088 return RESPONSE_TO_SEND_DELAY; 00089 } 00090 00091 GEMALTO_CINTERION::Module GEMALTO_CINTERION::get_module() 00092 { 00093 return _module; 00094 } 00095 00096 void GEMALTO_CINTERION::init_module_bgs2() 00097 { 00098 // BGS2-W_ATC_V00.100 00099 static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = { 00100 AT_CellularNetwork::RegistrationModeDisable, // C_EREG 00101 AT_CellularNetwork::RegistrationModeEnable, // C_GREG 00102 AT_CellularNetwork::RegistrationModeLAC, // C_REG 00103 0, // AT_CGSN_WITH_TYPE 00104 1, // AT_CGDATA 00105 1, // AT_CGAUTH 00106 1, // AT_CNMI 00107 1, // AT_CSMP 00108 1, // AT_CMGF 00109 1, // AT_CSDH 00110 1, // PROPERTY_IPV4_STACK 00111 0, // PROPERTY_IPV6_STACK 00112 0, // PROPERTY_IPV4V6_STACK 00113 0, // PROPERTY_NON_IP_PDP_TYPE 00114 1, // PROPERTY_AT_CGEREP 00115 }; 00116 set_cellular_properties(cellular_properties); 00117 _module = ModuleBGS2; 00118 } 00119 00120 void GEMALTO_CINTERION::init_module_els61() 00121 { 00122 // ELS61-E2_ATC_V01.000 00123 static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = { 00124 AT_CellularNetwork::RegistrationModeDisable, // C_EREG 00125 AT_CellularNetwork::RegistrationModeEnable, // C_GREG 00126 AT_CellularNetwork::RegistrationModeLAC, // C_REG 00127 0, // AT_CGSN_WITH_TYPE 00128 1, // AT_CGDATA 00129 1, // AT_CGAUTH 00130 1, // AT_CNMI 00131 1, // AT_CSMP 00132 1, // AT_CMGF 00133 1, // AT_CSDH 00134 1, // PROPERTY_IPV4_STACK 00135 1, // PROPERTY_IPV6_STACK 00136 0, // PROPERTY_IPV4V6_STACK 00137 0, // PROPERTY_NON_IP_PDP_TYPE 00138 1, // PROPERTY_AT_CGEREP 00139 }; 00140 set_cellular_properties(cellular_properties); 00141 _module = ModuleELS61; 00142 } 00143 00144 void GEMALTO_CINTERION::init_module_ems31() 00145 { 00146 // EMS31-US_ATC_V4.9.5 00147 static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = { 00148 AT_CellularNetwork::RegistrationModeLAC, // C_EREG 00149 AT_CellularNetwork::RegistrationModeDisable, // C_GREG 00150 AT_CellularNetwork::RegistrationModeDisable, // C_REG 00151 1, // AT_CGSN_WITH_TYPE 00152 1, // AT_CGDATA 00153 1, // AT_CGAUTH 00154 1, // AT_CNMI 00155 1, // AT_CSMP 00156 1, // AT_CMGF 00157 1, // AT_CSDH 00158 1, // PROPERTY_IPV4_STACK 00159 1, // PROPERTY_IPV6_STACK 00160 1, // PROPERTY_IPV4V6_STACK 00161 0, // PROPERTY_NON_IP_PDP_TYPE 00162 1, // PROPERTY_AT_CGEREP 00163 }; 00164 set_cellular_properties(cellular_properties); 00165 _module = ModuleEMS31; 00166 } 00167 00168 void GEMALTO_CINTERION::init_module_ehs5e() 00169 { 00170 // EHS5-E 00171 static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = { 00172 AT_CellularNetwork::RegistrationModeDisable, // C_EREG 00173 AT_CellularNetwork::RegistrationModeLAC, // C_GREG 00174 AT_CellularNetwork::RegistrationModeLAC, // C_REG 00175 0, // AT_CGSN_WITH_TYPE 00176 1, // AT_CGDATA 00177 1, // AT_CGAUTH 00178 1, // PROPERTY_IPV4_STACK 00179 1, // PROPERTY_IPV6_STACK 00180 0, // PROPERTY_IPV4V6_STACK 00181 }; 00182 set_cellular_properties(cellular_properties); 00183 _module = ModuleEHS5E; 00184 } 00185 00186 #if MBED_CONF_GEMALTO_CINTERION_PROVIDE_DEFAULT 00187 #include "UARTSerial.h" 00188 CellularDevice *CellularDevice::get_default_instance() 00189 { 00190 static UARTSerial serial(MBED_CONF_GEMALTO_CINTERION_TX, MBED_CONF_GEMALTO_CINTERION_RX, MBED_CONF_GEMALTO_CINTERION_BAUDRATE); 00191 #if defined(MBED_CONF_GEMALTO_CINTERION_RTS) && defined(MBED_CONF_GEMALTO_CINTERION_CTS) 00192 tr_debug("GEMALTO_CINTERION flow control: RTS %d CTS %d", MBED_CONF_GEMALTO_CINTERION_RTS, MBED_CONF_GEMALTO_CINTERION_CTS); 00193 serial.set_flow_control(SerialBase::RTSCTS, MBED_CONF_GEMALTO_CINTERION_RTS, MBED_CONF_GEMALTO_CINTERION_CTS); 00194 #endif 00195 static GEMALTO_CINTERION device(&serial); 00196 return &device; 00197 } 00198 #endif
Generated on Tue Jul 12 2022 13:54:23 by
