Mbed OS Reference
Loading...
Searching...
No Matches
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
26namespace mbed {
27
28/**
29 * @addtogroup at-hayes AT/Hayes Command Set
30 * @ingroup Cellular
31 * @{
32 */
33
34#define AT_NETWORK_TRIALS 5
35#define TIMER_UNIT_LENGTH 3
36#define TWO_BYTES_HEX 4
37#define FOUR_BYTES_HEX 8
38#define ONE_BYTE_BINARY 8
39
40/**
41 * Class AT_CellularNetwork
42 *
43 * Class for attaching to a network and getting information from it.
44 */
46public:
47
49 virtual ~AT_CellularNetwork();
50 // declare friend so it can access stack
51 friend class AT_CellularDevice;
52
53 enum RegistrationMode {
54 RegistrationModeDisable = 0,
55 RegistrationModeEnable, // <stat>
56 RegistrationModeLAC, // <stat>[,<[lac>,]<[ci>],[<AcT>],[<rac>]]
57 };
58
59public: // CellularNetwork
60
61 virtual nsapi_error_t set_registration(const char *plmn = 0);
62
64
66
67 virtual nsapi_error_t get_attach(AttachStatus &status);
68
70
71 virtual void attach(Callback<void(nsapi_event_t, intptr_t)> status_cb);
72
73 virtual nsapi_error_t set_access_technology(RadioAccessTechnology rat);
74
75 virtual nsapi_error_t scan_plmn(operList_t &operators, int &ops_count);
76
77 virtual nsapi_error_t set_ciot_optimization_config(CIoT_Supported_Opt supported_opt,
78 CIoT_Preferred_UE_Opt preferred_opt,
79 Callback<void(CIoT_Supported_Opt)> network_support_cb);
80
81 virtual nsapi_error_t get_ciot_ue_optimization_config(CIoT_Supported_Opt &supported_opt,
82 CIoT_Preferred_UE_Opt &preferred_opt);
83
84 virtual nsapi_error_t get_ciot_network_optimization_config(CIoT_Supported_Opt &supported_network_opt);
85
86 virtual nsapi_error_t get_signal_quality(int &rssi, int *ber = NULL);
87
88 virtual int get_3gpp_error();
89
90 virtual nsapi_error_t get_operator_params(int &format, operator_t &operator_params);
91
92 virtual nsapi_error_t set_registration_urc(RegistrationType type, bool on);
93
95
96 virtual bool is_active_context(int *number_of_active_contexts = NULL, int cid = -1);
97
99
100 virtual nsapi_error_t get_registration_params(RegistrationType type, registration_params_t &reg_params);
101
102 virtual nsapi_error_t set_receive_period(int mode, EDRXAccessTechnology act_type, uint8_t edrx_value);
103
105
106protected:
107 /** Sets access technology to be scanned. Modem specific implementation.
108 *
109 * @param op_rat Access technology
110 *
111 * @return zero on success
112 */
113 virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology op_rat);
114
115 /** Sends a command to query the active state of the PDP contexts.
116 * Can be overridden by the target class.
117 */
119
120 /** Clear the network and contexts to a known default state
121 *
122 * @return NSAPI_ERROR_OK on success
123 */
125
126private:
127 void urc_creg();
128 void urc_cereg();
129 void urc_cgreg();
130 void urc_cgev();
131 void urc_cciotopti();
132
133 void read_reg_params_and_compare(RegistrationType type);
134 void read_reg_params(RegistrationType type, registration_params_t &reg_params);
135
136 // Returns active time(Table 10.5.163/3GPP TS 24.008: GPRS Timer 2 information element) in seconds
137 int calculate_active_time(const char *active_time_string, int active_time_length);
138 // Returns periodic tau(Table 10.5.163a/3GPP TS 24.008: GPRS Timer 3 information element) in seconds
139 int calculate_periodic_tau(const char *periodic_tau_string, int periodic_tau_length);
140
141 // calls network callback only if status was changed, updates local connection status
142 void call_network_cb(nsapi_connection_status_t status);
143
144protected:
145 Callback<void(nsapi_event_t, intptr_t)> _connection_status_cb;
146 Callback<void(CIoT_Supported_Opt)> _ciotopt_network_support_cb;
147 RadioAccessTechnology _op_act;
148 nsapi_connection_status_t _connect_status;
149 CIoT_Supported_Opt _supported_network_opt;
150
151 registration_params_t _reg_params;
152 mbed::Callback<void()> _urc_funcs[C_MAX];
153
154 ATHandler &_at;
155 AT_CellularDevice &_device;
156};
157
158/**
159 * @}
160 */
161
162} // namespace mbed
163
164#endif // AT_CELLULAR_NETWORK_H_
Class AT_CellularDevice.
Class AT_CellularNetwork.
virtual nsapi_error_t set_packet_domain_event_reporting(bool on)
Sets the packet domain network reporting.
virtual nsapi_error_t clear()
Clear the network and contexts to a known default state.
virtual nsapi_error_t get_network_registering_mode(NWRegisteringMode &mode)
Get the current network registering mode.
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_receive_period(int mode, EDRXAccessTechnology act_type, uint8_t edrx_value)
Set discontinuous reception time on cellular device.
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 set_access_technology_impl(RadioAccessTechnology op_rat)
Sets access technology to be scanned.
virtual nsapi_error_t get_attach(AttachStatus &status)
Request attach status from network.
virtual void attach(Callback< void(nsapi_event_t, intptr_t)> status_cb)
Register callback for status reporting.
virtual nsapi_error_t get_operator_names(operator_names_list &op_names)
Read operator names.
virtual nsapi_error_t get_signal_quality(int &rssi, int *ber=NULL)
Get signal quality parameters.
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 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 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 get_operator_params(int &format, operator_t&operator_params)
Get the operator parameters.
virtual nsapi_error_t get_ciot_network_optimization_config(CIoT_Supported_Opt &supported_network_opt)
Get Network CIoT optimizations.
virtual void get_context_state_command()
Sends a command to query the active state of the PDP contexts.
virtual nsapi_error_t set_access_technology(RadioAccessTechnology rat)
Sets radio access technology.
virtual nsapi_error_t scan_plmn(operList_t &operators, int &ops_count)
Scans for operators module can reach.
virtual nsapi_error_t set_attach()
Request attach to network.
virtual int get_3gpp_error()
Get the last 3GPP error code.
virtual nsapi_error_t detach()
Request detach and deregister from a network.
virtual nsapi_error_t set_registration(const char *plmn=0)
Request registering to network.
virtual nsapi_error_t get_registration_params(RegistrationType type, registration_params_t &reg_params)
Gets the current network registration parameters from the network with type: status,...
Class for sending AT commands and parsing AT responses.
Definition: ATHandler.h:68
Callback class based on template specialization.
Definition: Callback.h:53
Class CellularList.
Definition: CellularList.h:30
An abstract interface for connecting to a network and getting information from it.
NWRegisteringMode
Network registering mode.
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:142
3GPP TS 27.007 - 7.3 PLMN selection +COPS
Network registration information.