25
25
26
26
class Nanostack ::Interface : public OnboardNetworkStack::Interface, private mbed::NonCopyable<Nanostack::Interface> {
27
27
public:
28
- virtual nsapi_error_t get_ip_address (SocketAddress *address);
29
- virtual char *get_mac_address (char *buf, nsapi_size_t buflen);
30
- virtual nsapi_error_t get_netmask (SocketAddress *address);
31
- virtual nsapi_error_t get_gateway (SocketAddress *address);
32
- virtual void attach (mbed::Callback<void (nsapi_event_t , intptr_t )> status_cb);
33
- virtual nsapi_connection_status_t get_connection_status () const ;
28
+ nsapi_error_t get_ip_address (SocketAddress *address) final ;
29
+ char *get_mac_address (char *buf, nsapi_size_t buflen) final ;
30
+ nsapi_error_t get_netmask (SocketAddress *address) final ;
31
+ nsapi_error_t get_gateway (SocketAddress *address) override ;
32
+ void attach (mbed::Callback<void (nsapi_event_t , intptr_t )> status_cb) final ;
33
+ nsapi_connection_status_t get_connection_status () const final ;
34
34
35
35
void get_mac_address (uint8_t *buf) const
36
36
{
@@ -59,20 +59,20 @@ class Nanostack::Interface : public OnboardNetworkStack::Interface, private mbed
59
59
NanostackPhy &interface_phy;
60
60
protected:
61
61
Interface (NanostackPhy &phy);
62
- virtual nsapi_error_t register_phy ();
62
+ nsapi_error_t register_phy ();
63
63
NanostackPhy &get_phy () const
64
64
{
65
65
return interface_phy;
66
66
}
67
- int8_t interface_id;
68
- int8_t _device_id;
67
+ int8_t interface_id = - 1 ;
68
+ int8_t _device_id = - 1 ;
69
69
rtos::Semaphore connect_semaphore;
70
70
rtos::Semaphore disconnect_semaphore;
71
71
72
72
mbed::Callback<void (nsapi_event_t , intptr_t )> _connection_status_cb;
73
- nsapi_connection_status_t _connect_status;
74
- nsapi_connection_status_t _previous_connection_status;
75
- bool _blocking;
73
+ nsapi_connection_status_t _connect_status = NSAPI_STATUS_DISCONNECTED ;
74
+ nsapi_connection_status_t _previous_connection_status = NSAPI_STATUS_DISCONNECTED ;
75
+ bool _blocking = true ;
76
76
};
77
77
78
78
class Nanostack ::MeshInterface : public Nanostack::Interface {
@@ -91,21 +91,21 @@ class InterfaceNanostack : public virtual NetworkInterface {
91
91
*
92
92
* @return 0 on success, negative error code on failure
93
93
*/
94
- virtual nsapi_error_t connect ();
94
+ nsapi_error_t connect () override ;
95
95
96
96
/* * Stop the interface
97
97
*
98
98
* @return 0 on success, negative error code on failure
99
99
*/
100
- virtual nsapi_error_t disconnect ();
100
+ nsapi_error_t disconnect () override ;
101
101
102
102
/* * @copydoc NetworkInterface::get_ip_address */
103
- virtual nsapi_error_t get_ip_address (SocketAddress *address);
103
+ nsapi_error_t get_ip_address (SocketAddress *address) override ;
104
104
105
105
/* * Get the internally stored MAC address
106
106
/return MAC address of the interface
107
107
*/
108
- virtual const char *get_mac_address ();
108
+ const char *get_mac_address () override ;
109
109
110
110
/* * Register callback for status reporting
111
111
*
@@ -115,20 +115,20 @@ class InterfaceNanostack : public virtual NetworkInterface {
115
115
*
116
116
* @param status_cb The callback for status changes
117
117
*/
118
- virtual void attach (mbed::Callback<void (nsapi_event_t , intptr_t )> status_cb);
118
+ void attach (mbed::Callback<void (nsapi_event_t , intptr_t )> status_cb) override ;
119
119
120
120
/* * Get the connection status
121
121
*
122
122
* @return The connection status according to ConnectionStatusType
123
123
*/
124
- virtual nsapi_connection_status_t get_connection_status () const ;
124
+ nsapi_connection_status_t get_connection_status () const override ;
125
125
126
126
/* * Set blocking status of connect() which by default should be blocking
127
127
*
128
128
* @param blocking true if connect is blocking
129
129
* @return 0 on success, negative error code on failure
130
130
*/
131
- virtual nsapi_error_t set_blocking (bool blocking);
131
+ nsapi_error_t set_blocking (bool blocking) override ;
132
132
133
133
/* * Set file system root path.
134
134
*
@@ -138,7 +138,7 @@ class InterfaceNanostack : public virtual NetworkInterface {
138
138
* @param root_path Address to NUL-terminated root-path string or NULL to disable file system usage.
139
139
* @return MESH_ERROR_NONE on success, MESH_ERROR_MEMORY in case of memory failure, MESH_ERROR_UNKNOWN in case of other error.
140
140
*/
141
- virtual nsapi_error_t set_file_system_root_path (const char *root_path);
141
+ nsapi_error_t set_file_system_root_path (const char *root_path);
142
142
143
143
/* * Get the interface ID
144
144
* @return Interface identifier
@@ -149,20 +149,20 @@ class InterfaceNanostack : public virtual NetworkInterface {
149
149
}
150
150
151
151
protected:
152
- InterfaceNanostack ();
153
- virtual Nanostack *get_stack (void );
152
+ InterfaceNanostack () = default ;
153
+ Nanostack *get_stack (void ) override ;
154
154
Nanostack::Interface *get_interface () const
155
155
{
156
156
return _interface;
157
157
}
158
158
virtual nsapi_error_t do_initialize () = 0;
159
159
160
- Nanostack::Interface *_interface;
160
+ Nanostack::Interface *_interface = nullptr ;
161
161
162
162
SocketAddress ip_addr;
163
- char mac_addr_str[24 ];
163
+ char mac_addr_str[24 ] {} ;
164
164
mbed::Callback<void (nsapi_event_t , intptr_t )> _connection_status_cb;
165
- bool _blocking;
165
+ bool _blocking = true ;
166
166
};
167
167
168
168
class MeshInterfaceNanostack : public InterfaceNanostack , public MeshInterface , private mbed ::NonCopyable<MeshInterfaceNanostack> {
@@ -178,13 +178,13 @@ class MeshInterfaceNanostack : public InterfaceNanostack, public MeshInterface,
178
178
nsapi_error_t initialize (NanostackRfPhy *phy);
179
179
180
180
protected:
181
- MeshInterfaceNanostack () : _phy( NULL ) { }
181
+ MeshInterfaceNanostack () = default ;
182
182
MeshInterfaceNanostack (NanostackRfPhy *phy) : _phy(phy) { }
183
183
Nanostack::MeshInterface *get_interface () const
184
184
{
185
185
return static_cast <Nanostack::MeshInterface *>(_interface);
186
186
}
187
- NanostackRfPhy *_phy;
187
+ NanostackRfPhy *_phy = nullptr ;
188
188
};
189
189
190
190
#endif /* MESHINTERFACENANOSTACK_H */
0 commit comments