Mistake on this page?
Report an issue in GitHub or email us
AT_CellularNetwork.h
1 /*
2  * Copyright (c) 2017, Arm Limited and affiliates.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef AT_CELLULAR_NETWORK_H_
19 #define AT_CELLULAR_NETWORK_H_
20 
21 #include "CellularNetwork.h"
22 #include "AT_CellularBase.h"
23 
24 namespace mbed {
25 
26 #define AT_NETWORK_TRIALS 5
27 #define TIMER_UNIT_LENGTH 3
28 #define TWO_BYTES_HEX 4
29 #define FOUR_BYTES_HEX 8
30 #define ONE_BYTE_BINARY 8
31 
32 /**
33  * Class AT_CellularNetwork
34  *
35  * Class for attaching to a network and getting information from it.
36  */
38 
39 public:
40 
41  AT_CellularNetwork(ATHandler &atHandler);
42  virtual ~AT_CellularNetwork();
43  // declare friend so it can access stack
44  friend class AT_CellularDevice;
45 
46  enum RegistrationMode {
47  RegistrationModeDisable = 0,
48  RegistrationModeEnable, // <stat>
49  RegistrationModeLAC, // <stat>[,<[lac>,]<[ci>],[<AcT>],[<rac>]]
50  };
51 
52 public: // CellularNetwork
53 
54  virtual nsapi_error_t set_registration(const char *plmn = 0);
55 
57 
58  virtual nsapi_error_t set_attach();
59 
60  virtual nsapi_error_t get_attach(AttachStatus &status);
61 
62  virtual nsapi_error_t detach();
63 
64  virtual void attach(Callback<void(nsapi_event_t, intptr_t)> status_cb);
65 
66  virtual nsapi_error_t set_access_technology(RadioAccessTechnology rat);
67 
68  virtual nsapi_error_t scan_plmn(operList_t &operators, int &ops_count);
69 
70  virtual nsapi_error_t set_ciot_optimization_config(CIoT_Supported_Opt supported_opt,
71  CIoT_Preferred_UE_Opt preferred_opt,
72  Callback<void(CIoT_Supported_Opt)> network_support_cb);
73 
74  virtual nsapi_error_t get_ciot_ue_optimization_config(CIoT_Supported_Opt &supported_opt,
75  CIoT_Preferred_UE_Opt &preferred_opt);
76 
77  virtual nsapi_error_t get_ciot_network_optimization_config(CIoT_Supported_Opt &supported_network_opt);
78 
79  virtual nsapi_error_t get_signal_quality(int &rssi, int *ber = NULL);
80 
81  virtual int get_3gpp_error();
82 
83  virtual nsapi_error_t get_operator_params(int &format, operator_t &operator_params);
84 
85  virtual nsapi_error_t set_registration_urc(RegistrationType type, bool on);
86 
88 
89  virtual bool is_active_context(int *number_of_active_contexts = NULL, int cid = -1);
90 
92 
93  virtual nsapi_error_t get_registration_params(RegistrationType type, registration_params_t &reg_params);
94 
95  virtual nsapi_error_t set_receive_period(int mode, EDRXAccessTechnology act_type, uint8_t edrx_value);
96 
98 
99 protected:
100 
101  /** Sets access technology to be scanned. Modem specific implementation.
102  *
103  * @param op_rat Access technology
104  *
105  * @return zero on success
106  */
107  virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology op_rat);
108 
109  /** Sends a command to query the active state of the PDP contexts.
110  * Can be overridden by the target class.
111  */
112  virtual void get_context_state_command();
113 private:
114  // "NO CARRIER" urc
115  void urc_no_carrier();
116  void urc_creg();
117  void urc_cereg();
118  void urc_cgreg();
119  void urc_cgev();
120  void urc_cciotopti();
121 
122  void read_reg_params_and_compare(RegistrationType type);
123  void read_reg_params(RegistrationType type, registration_params_t &reg_params);
124 
125  // Returns active time(Table 10.5.163/3GPP TS 24.008: GPRS Timer 2 information element) in seconds
126  int calculate_active_time(const char *active_time_string, int active_time_length);
127  // Returns periodic tau(Table 10.5.163a/3GPP TS 24.008: GPRS Timer 3 information element) in seconds
128  int calculate_periodic_tau(const char *periodic_tau_string, int periodic_tau_length);
129 
130  // calls network callback only if status was changed, updates local connection status
131  void call_network_cb(nsapi_connection_status_t status);
132 
133 protected:
134 
135  Callback<void(nsapi_event_t, intptr_t)> _connection_status_cb;
136  Callback<void(CIoT_Supported_Opt)> _ciotopt_network_support_cb;
137  RadioAccessTechnology _op_act;
138  nsapi_connection_status_t _connect_status;
139  CIoT_Supported_Opt _supported_network_opt;
140 
141  registration_params_t _reg_params;
142  mbed::Callback<void()> _urc_funcs[C_MAX];
143 };
144 
145 } // namespace mbed
146 
147 #endif // AT_CELLULAR_NETWORK_H_
virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology op_rat)
Sets access technology to be scanned.
Class CellularList.
Definition: CellularList.h:30
virtual nsapi_error_t detach()
Request detach and deregister from a network.
virtual void attach(Callback< void(nsapi_event_t, intptr_t)> status_cb)
Register callback for status reporting.
NWRegisteringMode
Network registering mode.
virtual nsapi_error_t set_ciot_optimization_config(CIoT_Supported_Opt supported_opt, CIoT_Preferred_UE_Opt preferred_opt, Callback< void(CIoT_Supported_Opt)> network_support_cb)
Set CIoT optimizations.
virtual nsapi_error_t set_registration_urc(RegistrationType type, bool on)
Activate/deactivate listening of network events for the given RegistrationType.
virtual nsapi_error_t set_registration(const char *plmn=0)
Request registering to network.
virtual nsapi_error_t set_attach()
Request attach to network.
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:95
virtual bool is_active_context(int *number_of_active_contexts=NULL, int cid=-1)
Check if there is any PDP context active.
virtual int get_3gpp_error()
Get the last 3GPP error code.
Network registration information.
virtual nsapi_error_t set_packet_domain_event_reporting(bool on)
Sets the packet domain network reporting.
virtual nsapi_error_t get_network_registering_mode(NWRegisteringMode &mode)
Get the current network registering mode.
virtual void get_context_state_command()
Sends a command to query the active state of the PDP contexts.
An abstract interface for connecting to a network and getting information from it.
virtual nsapi_error_t get_registration_params(registration_params_t &reg_params)
Gets the latest received registration parameters from the network: type, status, access technology...
Class AT_CellularBase.
virtual nsapi_error_t get_attach(AttachStatus &status)
Request attach status from network.
virtual nsapi_error_t get_operator_params(int &format, operator_t &operator_params)
Get the operator parameters.
EDRXAccessTechnology
Set discontinuous reception time on cellular device.
Class AT_CellularDevice.
Class AT_CellularNetwork.
virtual nsapi_error_t scan_plmn(operList_t &operators, int &ops_count)
Scans for operators module can reach.
virtual nsapi_error_t get_ciot_ue_optimization_config(CIoT_Supported_Opt &supported_opt, CIoT_Preferred_UE_Opt &preferred_opt)
Get UE CIoT optimizations.
virtual nsapi_error_t get_ciot_network_optimization_config(CIoT_Supported_Opt &supported_network_opt)
Get Network CIoT optimizations.
3GPP TS 27.007 - 7.3 PLMN selection +COPS
virtual nsapi_error_t get_operator_names(operator_names_list &op_names)
Read operator names.
Callback class based on template specialization.
Definition: Callback.h:39
Definition: AnalogIn.h:28
Class for sending AT commands and parsing AT responses.
Definition: ATHandler.h:62
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.