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 "ATHandler.h"
23 #include "AT_CellularDevice.h"
24 
25 namespace mbed {
26 
27 #define AT_NETWORK_TRIALS 5
28 #define TIMER_UNIT_LENGTH 3
29 #define TWO_BYTES_HEX 4
30 #define FOUR_BYTES_HEX 8
31 #define ONE_BYTE_BINARY 8
32 
33 /**
34  * Class AT_CellularNetwork
35  *
36  * Class for attaching to a network and getting information from it.
37  */
39 public:
40 
41  AT_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device);
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  /** Sets access technology to be scanned. Modem specific implementation.
101  *
102  * @param op_rat Access technology
103  *
104  * @return zero on success
105  */
106  virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology op_rat);
107 
108  /** Sends a command to query the active state of the PDP contexts.
109  * Can be overridden by the target class.
110  */
111  virtual void get_context_state_command();
112 
113  /** Clear the network and contexts to a known default state
114  *
115  * @return NSAPI_ERROR_OK on success
116  */
117  virtual nsapi_error_t clear();
118 
119 private:
120  void urc_creg();
121  void urc_cereg();
122  void urc_cgreg();
123  void urc_cgev();
124  void urc_cciotopti();
125 
126  void read_reg_params_and_compare(RegistrationType type);
127  void read_reg_params(RegistrationType type, registration_params_t &reg_params);
128 
129  // Returns active time(Table 10.5.163/3GPP TS 24.008: GPRS Timer 2 information element) in seconds
130  int calculate_active_time(const char *active_time_string, int active_time_length);
131  // Returns periodic tau(Table 10.5.163a/3GPP TS 24.008: GPRS Timer 3 information element) in seconds
132  int calculate_periodic_tau(const char *periodic_tau_string, int periodic_tau_length);
133 
134  // calls network callback only if status was changed, updates local connection status
135  void call_network_cb(nsapi_connection_status_t status);
136 
137 protected:
138  Callback<void(nsapi_event_t, intptr_t)> _connection_status_cb;
139  Callback<void(CIoT_Supported_Opt)> _ciotopt_network_support_cb;
140  RadioAccessTechnology _op_act;
141  nsapi_connection_status_t _connect_status;
142  CIoT_Supported_Opt _supported_network_opt;
143 
144  registration_params_t _reg_params;
145  mbed::Callback<void()> _urc_funcs[C_MAX];
146 
147  ATHandler &_at;
148  AT_CellularDevice &_device;
149 };
150 
151 } // namespace mbed
152 
153 #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:140
virtual bool is_active_context(int *number_of_active_contexts=NULL, int cid=-1)
Check if there is any PDP context active.
virtual nsapi_error_t clear()
Clear the network and contexts to a known default state.
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...
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:53
Definition: ATHandler.h:46
Class for sending AT commands and parsing AT responses.
Definition: ATHandler.h:68
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.