diff --git a/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX.cpp b/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX.cpp index 27e69d9365..c27182c093 100644 --- a/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX.cpp +++ b/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX.cpp @@ -34,6 +34,8 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = { 1, // PROPERTY_IPV4_STACK 0, // PROPERTY_IPV6_STACK 0, // PROPERTY_IPV4V6_STACK + 1, // PROPERTY_NON_IP_PDP_TYPE + 0, // PROPERTY_AT_CGEREP 1, // PROPERTY_AT_COPS_FALLBACK_AUTO }; @@ -59,6 +61,11 @@ void UBLOX_N2XX::NPIN_URC() _at->read_string(simstr, sizeof(simstr)); } +AT_CellularNetwork *UBLOX_N2XX::open_network_impl(ATHandler &at) +{ + return new UBLOX_N2XX_CellularNetwork(at, *this); +} + AT_CellularContext *UBLOX_N2XX::create_context_impl(ATHandler &at, const char *apn, bool cp_req, bool nonip_req) { return new UBLOX_N2XX_CellularContext(at, this, apn, cp_req, nonip_req); @@ -94,8 +101,8 @@ nsapi_error_t UBLOX_N2XX::get_sim_state(SimState &state) _at->lock(); _at->flush(); //Special case: Command put in cmd_chr to make a 1 liner - _at->at_cmd_str("", "+CFUN=1", simstr, sizeof(simstr)); - error = _at->unlock_return_error(); + error = _at->at_cmd_str("", "+CFUN=1", simstr, sizeof(simstr)); + _at->unlock(); int len = strlen(simstr); if (len > 0 || error == NSAPI_ERROR_OK) { diff --git a/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX.h b/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX.h index 7bff286136..b20450951d 100644 --- a/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX.h +++ b/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX.h @@ -33,6 +33,7 @@ #include "AT_CellularNetwork.h" #include "UBLOX_N2XX_CellularSMS.h" #include "UBLOX_N2XX_CellularContext.h" +#include "UBLOX_N2XX_CellularNetwork.h" namespace mbed { @@ -50,6 +51,7 @@ public: protected: // AT_CellularDevice + virtual AT_CellularNetwork *open_network_impl(ATHandler &at); virtual AT_CellularContext *create_context_impl(ATHandler &at, const char *apn, bool cp_req = false, bool nonip_req = false); #if MBED_CONF_CELLULAR_USE_SMS virtual AT_CellularSMS *open_sms_impl(ATHandler &at); diff --git a/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX_CellularContext.cpp b/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX_CellularContext.cpp index 9946d59b58..0e29d9b4cf 100644 --- a/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX_CellularContext.cpp +++ b/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX_CellularContext.cpp @@ -44,4 +44,9 @@ NetworkStack *UBLOX_N2XX_CellularContext::get_stack() } #endif +const char* UBLOX_N2XX_CellularContext::get_nonip_context_type_str() +{ + return "NONIP"; +} + } /* namespace mbed */ diff --git a/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX_CellularContext.h b/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX_CellularContext.h index d2bd9d3327..cc5a005546 100644 --- a/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX_CellularContext.h +++ b/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX_CellularContext.h @@ -34,6 +34,7 @@ protected: virtual NetworkStack *get_stack(); #endif + virtual const char* get_nonip_context_type_str(); }; } /* namespace mbed */ diff --git a/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX_CellularNetwork.cpp b/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX_CellularNetwork.cpp new file mode 100644 index 0000000000..874958f09d --- /dev/null +++ b/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX_CellularNetwork.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2019, Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "UBLOX_N2XX_CellularNetwork.h" + +using namespace mbed; + +UBLOX_N2XX_CellularNetwork::UBLOX_N2XX_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device) : AT_CellularNetwork(atHandler, device) +{ +} + +nsapi_error_t UBLOX_N2XX_CellularNetwork::clear() +{ + nsapi_error_t err = AT_CellularNetwork::clear(); +#if MBED_CONF_CELLULAR_CONTROL_PLANE_OPT + if (!err) { +#ifdef MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN + (void) _at.at_cmd_discard("+CGDCONT", "=", "%d%s%s", 1, "NONIP", MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN); +#endif + (void) _at.at_cmd_discard("+CIPCA", "=", "%d%d", 3, 1); // EPS Attach without PDN connection + _at.lock(); + _at.cmd_start("AT+NCONFIG=\"AUTOCONNECT\",\"FALSE\""); // disable auto connect to IP context + _at.cmd_stop_read_resp(); + _at.unlock(); + } +#endif + return err; +} + +nsapi_error_t UBLOX_N2XX_CellularNetwork::set_ciot_optimization_config(CIoT_Supported_Opt supported_opt, + CIoT_Preferred_UE_Opt preferred_opt, + Callback network_support_cb) +{ + _ciotopt_network_support_cb = network_support_cb; + nsapi_error_t err = _at.at_cmd_discard("+CRTDCP", "=", "%d", 1); + return err; +} diff --git a/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX_CellularNetwork.h b/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX_CellularNetwork.h new file mode 100644 index 0000000000..112db976d5 --- /dev/null +++ b/features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX_CellularNetwork.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2019, Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef UBLOX_N2XX_CELLULAR_NETWORK_H_ +#define UBLOX_N2XX_CELLULAR_NETWORK_H_ + +#include "AT_CellularNetwork.h" + +namespace mbed { + +class UBLOX_N2XX_CellularNetwork : public AT_CellularNetwork { +public: + UBLOX_N2XX_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device); + virtual nsapi_error_t clear(); + virtual nsapi_error_t set_ciot_optimization_config(CIoT_Supported_Opt supported_opt, + CIoT_Preferred_UE_Opt preferred_opt, + Callback network_support_cb); +}; + +} // namespace mbed + +#endif // UBLOX_N2XX_CELLULAR_NETWORK_H_