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.
AT_CellularNetwork.h
00001 /* 00002 * Copyright (c) 2017, 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 #ifndef AT_CELLULAR_NETWORK_H_ 00019 #define AT_CELLULAR_NETWORK_H_ 00020 00021 #include "CellularNetwork.h" 00022 #include "AT_CellularBase.h" 00023 #include "NetworkStack.h" 00024 00025 namespace mbed { 00026 00027 #define AT_NETWORK_TRIALS 5 00028 00029 /** 00030 * Class AT_CellularNetwork 00031 * 00032 * Class for connecting to a network and getting information from it. 00033 */ 00034 class AT_CellularNetwork : public CellularNetwork, public AT_CellularBase 00035 { 00036 00037 public: 00038 00039 AT_CellularNetwork(ATHandler &atHandler); 00040 virtual ~AT_CellularNetwork(); 00041 // declare friend so it can access stack 00042 friend class AT_CellularDevice; 00043 00044 public: // NetworkInterface 00045 00046 virtual nsapi_error_t set_credentials(const char *apn, 00047 const char *username = 0, const char *password = 0); 00048 00049 virtual nsapi_error_t set_credentials(const char *apn, AuthenticationType type, 00050 const char *username = 0, const char *password = 0); 00051 00052 virtual nsapi_error_t connect(const char *apn, 00053 const char *username = 0, const char *password = 0); 00054 00055 virtual nsapi_error_t connect(); 00056 00057 virtual nsapi_error_t disconnect(); 00058 00059 protected: 00060 virtual NetworkStack *get_stack(); 00061 00062 public: // CellularNetwork 00063 virtual nsapi_error_t set_registration(const char *plmn = 0); 00064 00065 virtual nsapi_error_t get_registration_status(RegistrationType type, RegistrationStatus &status); 00066 00067 virtual nsapi_error_t set_attach(int timeout = 10*1000); 00068 00069 virtual nsapi_error_t get_attach(AttachStatus &status); 00070 00071 virtual nsapi_error_t get_rate_control(CellularNetwork::RateControlExceptionReports &reports, 00072 CellularNetwork::RateControlUplinkTimeUnit &time_unit, int &uplink_rate); 00073 00074 virtual nsapi_error_t get_apn_backoff_timer(int &backoff_timer); 00075 00076 virtual void attach(Callback<void(nsapi_event_t, intptr_t)> status_cb); 00077 00078 virtual nsapi_connection_status_t get_connection_status() const; 00079 00080 virtual nsapi_error_t set_blocking(bool blocking); 00081 00082 virtual const char *get_ip_address(); 00083 00084 virtual nsapi_error_t set_access_technology(operator_t::RadioAccessTechnology op_rat); 00085 00086 virtual nsapi_error_t scan_plmn(operList_t &operators, int &ops_count); 00087 00088 virtual nsapi_error_t set_ciot_optimization_config(Supported_UE_Opt supported_opt, 00089 Preferred_UE_Opt preferred_opt); 00090 00091 virtual nsapi_error_t get_ciot_optimization_config(Supported_UE_Opt& supported_opt, 00092 Preferred_UE_Opt& preferred_opt); 00093 00094 virtual nsapi_error_t set_stack_type(nsapi_ip_stack_t stack_type); 00095 00096 virtual nsapi_ip_stack_t get_stack_type(); 00097 00098 virtual nsapi_error_t get_pdpcontext_params(pdpContextList_t& params_list); 00099 00100 virtual nsapi_error_t get_extended_signal_quality(int &rxlev, int &ber, int &rscp, int &ecno, int &rsrq, int &rsrp); 00101 00102 virtual nsapi_error_t get_signal_quality(int &rssi, int &ber); 00103 00104 virtual nsapi_error_t get_cell_id(int &cell_id); 00105 00106 virtual int get_3gpp_error(); 00107 00108 virtual nsapi_error_t get_operator_params(int &format, operator_t &operator_params); 00109 00110 protected: 00111 00112 /** Check if modem supports the given stack type. 00113 * 00114 * @return true if supported 00115 */ 00116 virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack); 00117 00118 /** Check if modem supports given registration type. 00119 * 00120 * @param reg_type enum RegistrationType 00121 * @return true if given registration type is supported by modem 00122 */ 00123 virtual bool has_registration(RegistrationType reg_type); 00124 00125 /** Sets access technology to be scanned. Modem specific implementation. 00126 * 00127 * @param op_rat Access technology 00128 * 00129 * @return zero on success 00130 */ 00131 virtual nsapi_error_t set_access_technology_impl(operator_t::RadioAccessTechnology op_rat); 00132 00133 private: 00134 // "NO CARRIER" urc 00135 void urc_no_carrier(); 00136 nsapi_error_t set_context_to_be_activated(); 00137 nsapi_ip_stack_t string_to_stack_type(const char* pdp_type); 00138 00139 void free_credentials(); 00140 00141 nsapi_error_t open_data_channel(); 00142 bool get_context(); 00143 bool set_new_context(int cid); 00144 nsapi_error_t set_registration_urc(bool on); 00145 nsapi_error_t delete_current_context(); 00146 00147 #if NSAPI_PPP_AVAILABLE 00148 void ppp_status_cb(nsapi_event_t, intptr_t); 00149 #endif 00150 00151 protected: 00152 NetworkStack *_stack; 00153 char *_apn; 00154 char *_uname; 00155 char *_pwd; 00156 nsapi_ip_stack_t _ip_stack_type_requested; 00157 nsapi_ip_stack_t _ip_stack_type; 00158 int _cid; 00159 Callback<void(nsapi_event_t, intptr_t)> _connection_status_cb; 00160 operator_t::RadioAccessTechnology _op_act; 00161 AuthenticationType _authentication_type; 00162 int _lac; 00163 int _cell_id; 00164 RegistrationType _last_reg_type; 00165 nsapi_connection_status_t _connect_status; 00166 bool _new_context_set; 00167 }; 00168 00169 } // namespace mbed 00170 00171 #endif // AT_CELLULAR_NETWORK_H_
Generated on Tue Jul 12 2022 14:23:20 by
