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
QUECTEL_M26.cpp
00001 /* 00002 #include <M26/QUECTEL_M26_CellularInformation.h> 00003 * Copyright (c) 2018, Arm Limited and affiliates. 00004 * SPDX-License-Identifier: Apache-2.0 00005 * 00006 * Licensed under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 00019 #include "AT_CellularNetwork.h" 00020 #include "QUECTEL_M26_CellularContext.h" 00021 #include "QUECTEL_M26.h" 00022 00023 #include "CellularLog.h" 00024 00025 using namespace mbed; 00026 00027 static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = { 00028 AT_CellularNetwork::RegistrationModeDisable,// C_EREG 00029 AT_CellularNetwork::RegistrationModeLAC, // C_GREG 00030 AT_CellularNetwork::RegistrationModeDisable,// C_REG 00031 0, // AT_CGSN_WITH_TYPE 00032 1, // AT_CGDATA 00033 0, // AT_CGAUTH 00034 1, // AT_CNMI 00035 1, // AT_CSMP 00036 1, // AT_CMGF 00037 1, // AT_CSDH 00038 1, // PROPERTY_IPV4_STACK 00039 0, // PROPERTY_IPV6_STACK 00040 0, // PROPERTY_IPV4V6_STACK 00041 0, // PROPERTY_NON_IP_PDP_TYPE 00042 1, // PROPERTY_AT_CGEREP 00043 }; 00044 00045 QUECTEL_M26::QUECTEL_M26(FileHandle *fh) : AT_CellularDevice(fh) 00046 { 00047 set_cellular_properties(cellular_properties); 00048 } 00049 00050 nsapi_error_t QUECTEL_M26::get_sim_state(SimState &state) 00051 { 00052 char buf[13]; 00053 00054 _at->lock(); 00055 nsapi_error_t err = _at->at_cmd_str("+CPIN", "?", buf, 13); 00056 tr_debug("CPIN: %s", buf); 00057 _at->unlock(); 00058 00059 if (memcmp(buf, "READY", 5) == 0) { 00060 state = SimStateReady; 00061 } else if (memcmp(buf, "SIM PIN", 7) == 0) { 00062 state = SimStatePinNeeded; 00063 } else if (memcmp(buf, "SIM PUK", 7) == 0) { 00064 state = SimStatePukNeeded; 00065 } else if (memcmp(buf, "PH_SIM PIN", 10) == 0) { 00066 state = SimStatePinNeeded; 00067 } else if (memcmp(buf, "PH_SIM PUK", 10) == 0) { 00068 state = SimStatePukNeeded; 00069 } else if (memcmp(buf, "SIM PIN2", 8) == 0) { 00070 state = SimStatePinNeeded; 00071 } else if (memcmp(buf, "SIM PUK2", 8) == 0) { 00072 state = SimStatePukNeeded; 00073 } else { 00074 state = SimStateUnknown; // SIM may not be ready yet 00075 } 00076 00077 return err; 00078 } 00079 00080 AT_CellularContext *QUECTEL_M26::create_context_impl(ATHandler &at, const char *apn, bool cp_req, bool nonip_req) 00081 { 00082 return new QUECTEL_M26_CellularContext(at, this, apn, cp_req, nonip_req); 00083 } 00084 00085 nsapi_error_t QUECTEL_M26::shutdown() 00086 { 00087 return _at->at_cmd_discard("+QPOWD", "=0"); 00088 } 00089 00090 00091 #if MBED_CONF_QUECTEL_M26_PROVIDE_DEFAULT 00092 #include "UARTSerial.h" 00093 CellularDevice *CellularDevice::get_default_instance() 00094 { 00095 static UARTSerial serial(MBED_CONF_QUECTEL_M26_TX, MBED_CONF_QUECTEL_M26_RX, MBED_CONF_QUECTEL_M26_BAUDRATE); 00096 #if defined (MBED_CONF_QUECTEL_M26_RTS) && defined(MBED_CONF_QUECTEL_M26_CTS) 00097 tr_debug("QUECTEL_M26 flow control: RTS %d CTS %d", MBED_CONF_QUECTEL_M26_RTS, MBED_CONF_QUECTEL_M26_CTS); 00098 serial.set_flow_control(SerialBase::RTSCTS, MBED_CONF_QUECTEL_M26_RTS, MBED_CONF_QUECTEL_M26_CTS); 00099 #endif 00100 static QUECTEL_M26 device(&serial); 00101 return &device; 00102 } 00103 #endif
Generated on Tue Jul 12 2022 13:54:46 by
1.7.2