Skip to content

Commit 5ada4bf

Browse files
authored
Merge pull request #9746 from blind-owl/retire_cellularbase_class
Cellular: retire CellularBase class
2 parents 39c8374 + 7a195ae commit 5ada4bf

File tree

5 files changed

+185
-134
lines changed

5 files changed

+185
-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

@@ -41,8 +41,8 @@ typedef enum pdp_type {
4141
* @{
4242
*/
4343

44-
/// CellularContext is CellularBase/NetworkInterface with extensions for cellular connectivity
45-
class CellularContext : public CellularBase {
44+
/// CellularContext is CellularInterface/NetworkInterface with extensions for cellular connectivity
45+
class CellularContext : public CellularInterface {
4646

4747
public:
4848

@@ -140,7 +140,7 @@ class CellularContext : public CellularBase {
140140
virtual nsapi_error_t connect() = 0;
141141
virtual nsapi_error_t disconnect() = 0;
142142

143-
// from CellularBase
143+
// from CellularInterface
144144
virtual void set_plmn(const char *plmn) = 0;
145145
virtual void set_sim_pin(const char *sim_pin) = 0;
146146
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: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
/* Copyright (c) 2019 ARM Limited
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef CELLULAR_INTERFACE_H_
18+
#define CELLULAR_INTERFACE_H_
19+
20+
#include "netsocket/NetworkInterface.h"
21+
22+
/**
23+
* @addtogroup cellular
24+
* @{
25+
*/
26+
27+
/** Common interface that is shared between cellular interfaces.
28+
*/
29+
class CellularInterface: 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 CellularInterface *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+
MBED_DEPRECATED_SINCE("mbed-os-5.12", "Migrated to CellularInterface")
122+
virtual CellularInterface *cellularBase()
123+
{
124+
return this;
125+
}
126+
127+
/** @copydoc NetworkInterface::cellularInterface
128+
*/
129+
virtual CellularInterface *cellularInterface()
130+
{
131+
return this;
132+
}
133+
134+
#if !defined(DOXYGEN_ONLY)
135+
136+
protected:
137+
/** Get the target's default cellular interface.
138+
*
139+
* This is provided as a weak method so targets can override. The
140+
* default implementation configures and returns the OnBoardModemInterface,
141+
* if available.
142+
*
143+
* @return Pointer to interface, if any.
144+
*/
145+
static CellularInterface *get_target_default_instance();
146+
147+
#endif //!defined(DOXYGEN_ONLY)
148+
149+
public:
150+
/** Set default parameters on a cellular interface.
151+
*
152+
* A cellular interface instantiated directly or using
153+
* CellularInterface::get_default_instance() is initially unconfigured.
154+
* This call can be used to set the default parameters that would
155+
* have been set if the interface had been requested using
156+
* NetworkInterface::get_default_instance() (see nsapi JSON
157+
* configuration).
158+
*/
159+
virtual void set_default_parameters();
160+
};
161+
162+
#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,11 @@ 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()
332333
{
333334
return 0;
334335
}
@@ -401,6 +402,14 @@ class NetworkInterface: public DNS {
401402
* configuration).
402403
*/
403404
virtual void set_default_parameters();
405+
406+
/** Return pointer to a CellularInterface.
407+
* @return Pointer to requested interface type or NULL if this class doesn't implement the interface.
408+
*/
409+
virtual CellularInterface *cellularInterface()
410+
{
411+
return 0;
412+
}
404413
};
405414

406415
#endif

0 commit comments

Comments
 (0)