Skip to content

Commit 90c9a85

Browse files
Jari PoyhonenJari Poyhonen
authored andcommitted
Cellular: retire CellularBase class
It was decided to retire CellularBase class which served as a pure virtual interface class from which Cellular network stack implementations would get inherited. However, the current view is that we may be the only user of it so we could retire CellularBase.
1 parent f95ec95 commit 90c9a85

File tree

5 files changed

+184
-134
lines changed

5 files changed

+184
-134
lines changed

features/cellular/framework/API/CellularContext.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifndef _CELLULARCONTEXT_H_
1818
#define _CELLULARCONTEXT_H_
1919

20-
#include "CellularBase.h"
20+
#include "CellularInterface.h"
2121
#include "CellularDevice.h"
2222
#include "ControlPlane_netif.h"
2323

@@ -36,8 +36,8 @@ typedef enum pdp_type {
3636
* @{
3737
*/
3838

39-
/// CellularContext is CellularBase/NetworkInterface with extensions for cellular connectivity
40-
class CellularContext : public CellularBase {
39+
/// CellularContext is CellularInterface/NetworkInterface with extensions for cellular connectivity
40+
class CellularContext : public CellularInterface {
4141

4242
public:
4343

@@ -135,7 +135,7 @@ class CellularContext : public CellularBase {
135135
virtual nsapi_error_t connect() = 0;
136136
virtual nsapi_error_t disconnect() = 0;
137137

138-
// from CellularBase
138+
// from CellularInterface
139139
virtual void set_plmn(const char *plmn) = 0;
140140
virtual void set_sim_pin(const char *sim_pin) = 0;
141141
virtual nsapi_error_t connect(const char *sim_pin, const char *apn = 0, const char *uname = 0,

features/cellular/framework/device/CellularContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
#include "CellularContext.h"
1818

19-
MBED_WEAK CellularBase *CellularBase::get_target_default_instance()
19+
MBED_WEAK CellularInterface *CellularInterface::get_target_default_instance()
2020
{
2121
return mbed::CellularContext::get_default_instance();
2222
}

features/netsocket/CellularBase.h

Lines changed: 6 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -22,134 +22,14 @@
2222
#ifndef CELLULAR_BASE_H
2323
#define CELLULAR_BASE_H
2424

25-
#include "netsocket/NetworkInterface.h"
26-
27-
/** Common interface that is shared between cellular interfaces.
25+
/**
26+
* This class is deprecated and will be removed altogether after expiration of
27+
* deprecation notice.
2828
*/
29-
class CellularBase: public NetworkInterface {
30-
31-
public:
32-
/** Get the default cellular interface.
33-
*
34-
* This is provided as a weak method so applications can override.
35-
* Default behavior is to get the target's default interface, if
36-
* any.
37-
*
38-
* @return pointer to interface, if any.
39-
*/
40-
static CellularBase *get_default_instance();
41-
42-
/** Set the cellular network credentials.
43-
*
44-
* Please check documentation of connect() for default behavior of APN settings.
45-
*
46-
* @param apn Access point name.
47-
* @param uname Username (optional).
48-
* @param pwd Password (optional).
49-
*/
50-
virtual void set_credentials(const char *apn, const char *uname = 0,
51-
const char *pwd = 0) = 0;
52-
53-
/** Set the plmn. PLMN controls to what network device registers.
54-
*
55-
* @param plmn user to force what network to register.
56-
*/
57-
virtual void set_plmn(const char *plmn) = 0;
58-
59-
/** Set the PIN code for SIM card.
60-
*
61-
* @param sim_pin PIN for the SIM card.
62-
*/
63-
virtual void set_sim_pin(const char *sim_pin) = 0;
64-
65-
/** Attempt to connect to a cellular network with a PIN and credentials.
66-
*
67-
* @param sim_pin PIN for the SIM card.
68-
* @param apn Access point name (optional).
69-
* @param uname Username (optional).
70-
* @param pwd Password (optional).
71-
* @return NSAPI_ERROR_OK on success, or negative error code on failure.
72-
*/
73-
virtual nsapi_error_t connect(const char *sim_pin, const char *apn = 0,
74-
const char *uname = 0,
75-
const char *pwd = 0) = 0;
76-
77-
/** Attempt to connect to a cellular network.
78-
*
79-
* If the SIM requires a PIN, and it is invalid or not set, NSAPI_ERROR_AUTH_ERROR is returned.
80-
*
81-
* @return NSAPI_ERROR_OK on success, or negative error code on failure.
82-
*/
83-
virtual nsapi_error_t connect() = 0;
84-
85-
/** Stop the interface.
86-
*
87-
* @return NSAPI_ERROR_OK on success, or error code on failure.
88-
*/
89-
virtual nsapi_error_t disconnect() = 0;
90-
91-
/** Check if the connection is currently established.
92-
*
93-
* @return `true` if the cellular module have successfully acquired a carrier and is
94-
* connected to an external packet data network using PPP, `false` otherwise.
95-
*/
96-
virtual bool is_connected() = 0;
97-
98-
/** Get the local IP address.
99-
*
100-
* @return Null-terminated representation of the local IP address,
101-
* or null if no IP address has been received.
102-
*/
103-
virtual const char *get_ip_address() = 0;
104-
105-
/** Get the local network mask.
106-
*
107-
* @return Null-terminated representation of the local network mask,
108-
* or null if no network mask has been received.
109-
*/
110-
virtual const char *get_netmask() = 0;
111-
112-
/** Get the local gateways.
113-
*
114-
* @return Null-terminated representation of the local gateway,
115-
* or null if no network mask has been received.
116-
*/
117-
virtual const char *get_gateway() = 0;
118-
119-
/** @copydoc NetworkInterface::cellularBase
120-
*/
121-
virtual CellularBase *cellularBase()
122-
{
123-
return this;
124-
}
125-
126-
#if !defined(DOXYGEN_ONLY)
127-
128-
protected:
129-
/** Get the target's default cellular interface.
130-
*
131-
* This is provided as a weak method so targets can override. The
132-
* default implementation configures and returns the OnBoardModemInterface,
133-
* if available.
134-
*
135-
* @return Pointer to interface, if any.
136-
*/
137-
static CellularBase *get_target_default_instance();
138-
139-
#endif //!defined(DOXYGEN_ONLY)
29+
#include "CellularInterface.h"
14030

141-
public:
142-
/** Set default parameters on a cellular interface.
143-
*
144-
* A cellular interface instantiated directly or using
145-
* CellularBase::get_default_instance() is initially unconfigured.
146-
* This call can be used to set the default parameters that would
147-
* have been set if the interface had been requested using
148-
* NetworkInterface::get_default_instance() (see nsapi JSON
149-
* configuration).
150-
*/
151-
virtual void set_default_parameters();
152-
};
31+
MBED_DEPRECATED_SINCE("mbed-os-5.12", "Migrated to CellularInterface")
32+
typedef CellularInterface CellularBase;
15333

15434
#endif //CELLULAR_BASE_H
15535

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
/* Copyright (c) 2019 ARM Limited
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
#ifndef CELLULAR_INTERFACE_H_
17+
#define CELLULAR_INTERFACE_H_
18+
19+
#include "netsocket/NetworkInterface.h"
20+
21+
/**
22+
* @addtogroup cellular
23+
* @{
24+
*/
25+
26+
/** Common interface that is shared between cellular interfaces.
27+
*/
28+
class CellularInterface: public NetworkInterface {
29+
30+
public:
31+
/** Get the default cellular interface.
32+
*
33+
* This is provided as a weak method so applications can override.
34+
* Default behavior is to get the target's default interface, if
35+
* any.
36+
*
37+
* @return pointer to interface, if any.
38+
*/
39+
static CellularInterface *get_default_instance();
40+
41+
/** Set the cellular network credentials.
42+
*
43+
* Please check documentation of connect() for default behavior of APN settings.
44+
*
45+
* @param apn Access point name.
46+
* @param uname Username (optional).
47+
* @param pwd Password (optional).
48+
*/
49+
virtual void set_credentials(const char *apn, const char *uname = 0,
50+
const char *pwd = 0) = 0;
51+
52+
/** Set the plmn. PLMN controls to what network device registers.
53+
*
54+
* @param plmn user to force what network to register.
55+
*/
56+
virtual void set_plmn(const char *plmn) = 0;
57+
58+
/** Set the PIN code for SIM card.
59+
*
60+
* @param sim_pin PIN for the SIM card.
61+
*/
62+
virtual void set_sim_pin(const char *sim_pin) = 0;
63+
64+
/** Attempt to connect to a cellular network with a PIN and credentials.
65+
*
66+
* @param sim_pin PIN for the SIM card.
67+
* @param apn Access point name (optional).
68+
* @param uname Username (optional).
69+
* @param pwd Password (optional).
70+
* @return NSAPI_ERROR_OK on success, or negative error code on failure.
71+
*/
72+
virtual nsapi_error_t connect(const char *sim_pin, const char *apn = 0,
73+
const char *uname = 0,
74+
const char *pwd = 0) = 0;
75+
76+
/** Attempt to connect to a cellular network.
77+
*
78+
* If the SIM requires a PIN, and it is invalid or not set, NSAPI_ERROR_AUTH_ERROR is returned.
79+
*
80+
* @return NSAPI_ERROR_OK on success, or negative error code on failure.
81+
*/
82+
virtual nsapi_error_t connect() = 0;
83+
84+
/** Stop the interface.
85+
*
86+
* @return NSAPI_ERROR_OK on success, or error code on failure.
87+
*/
88+
virtual nsapi_error_t disconnect() = 0;
89+
90+
/** Check if the connection is currently established.
91+
*
92+
* @return `true` if the cellular module have successfully acquired a carrier and is
93+
* connected to an external packet data network using PPP, `false` otherwise.
94+
*/
95+
virtual bool is_connected() = 0;
96+
97+
/** Get the local IP address.
98+
*
99+
* @return Null-terminated representation of the local IP address,
100+
* or null if no IP address has been received.
101+
*/
102+
virtual const char *get_ip_address() = 0;
103+
104+
/** Get the local network mask.
105+
*
106+
* @return Null-terminated representation of the local network mask,
107+
* or null if no network mask has been received.
108+
*/
109+
virtual const char *get_netmask() = 0;
110+
111+
/** Get the local gateways.
112+
*
113+
* @return Null-terminated representation of the local gateway,
114+
* or null if no network mask has been received.
115+
*/
116+
virtual const char *get_gateway() = 0;
117+
118+
/** @copydoc NetworkInterface::cellularBase
119+
*/
120+
MBED_DEPRECATED_SINCE("mbed-os-5.12", "Migrated to CellularInterface")
121+
virtual CellularInterface *cellularBase()
122+
{
123+
return this;
124+
}
125+
126+
/** @copydoc NetworkInterface::cellularInterface
127+
*/
128+
virtual CellularInterface *cellularInterface()
129+
{
130+
return this;
131+
}
132+
133+
#if !defined(DOXYGEN_ONLY)
134+
135+
protected:
136+
/** Get the target's default cellular interface.
137+
*
138+
* This is provided as a weak method so targets can override. The
139+
* default implementation configures and returns the OnBoardModemInterface,
140+
* if available.
141+
*
142+
* @return Pointer to interface, if any.
143+
*/
144+
static CellularInterface *get_target_default_instance();
145+
146+
#endif //!defined(DOXYGEN_ONLY)
147+
148+
public:
149+
/** Set default parameters on a cellular interface.
150+
*
151+
* A cellular interface instantiated directly or using
152+
* CellularInterface::get_default_instance() is initially unconfigured.
153+
* This call can be used to set the default parameters that would
154+
* have been set if the interface had been requested using
155+
* NetworkInterface::get_default_instance() (see nsapi JSON
156+
* configuration).
157+
*/
158+
virtual void set_default_parameters();
159+
};
160+
161+
#endif // CELLULAR_INTERFACE_H_

features/netsocket/NetworkInterface.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class NetworkStack;
3434
class EthInterface;
3535
class WiFiInterface;
3636
class MeshInterface;
37-
class CellularBase;
37+
class CellularInterface;
3838
class EMACInterface;
3939

4040
/** Common interface that is shared between network devices.
@@ -325,10 +325,19 @@ class NetworkInterface: public DNS {
325325
return 0;
326326
}
327327

328-
/** Return pointer to a CellularBase.
328+
/** Return pointer to a CellularInterface.
329329
* @return Pointer to requested interface type or NULL if this class doesn't implement the interface.
330330
*/
331-
virtual CellularBase *cellularBase()
331+
MBED_DEPRECATED_SINCE("mbed-os-5.12", "Migrated to CellularInterface")
332+
virtual CellularInterface *cellularBase()
333+
{
334+
return 0;
335+
}
336+
337+
/** Return pointer to a CellularInterface.
338+
* @return Pointer to requested interface type or NULL if this class doesn't implement the interface.
339+
*/
340+
virtual CellularInterface *cellularInterface()
332341
{
333342
return 0;
334343
}

0 commit comments

Comments
 (0)