2525
2626class Nanostack ::Interface : public OnboardNetworkStack::Interface, private mbed::NonCopyable<Nanostack::Interface> {
2727public:
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 ;
3434
3535 void get_mac_address (uint8_t *buf) const
3636 {
@@ -59,20 +59,20 @@ class Nanostack::Interface : public OnboardNetworkStack::Interface, private mbed
5959 NanostackPhy &interface_phy;
6060protected:
6161 Interface (NanostackPhy &phy);
62- virtual nsapi_error_t register_phy ();
62+ nsapi_error_t register_phy ();
6363 NanostackPhy &get_phy () const
6464 {
6565 return interface_phy;
6666 }
67- int8_t interface_id;
68- int8_t _device_id;
67+ int8_t interface_id = - 1 ;
68+ int8_t _device_id = - 1 ;
6969 rtos::Semaphore connect_semaphore;
7070 rtos::Semaphore disconnect_semaphore;
7171
7272 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 ;
7676};
7777
7878class Nanostack ::MeshInterface : public Nanostack::Interface {
@@ -91,21 +91,21 @@ class InterfaceNanostack : public virtual NetworkInterface {
9191 *
9292 * @return 0 on success, negative error code on failure
9393 */
94- virtual nsapi_error_t connect ();
94+ nsapi_error_t connect () override ;
9595
9696 /* * Stop the interface
9797 *
9898 * @return 0 on success, negative error code on failure
9999 */
100- virtual nsapi_error_t disconnect ();
100+ nsapi_error_t disconnect () override ;
101101
102102 /* * @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 ;
104104
105105 /* * Get the internally stored MAC address
106106 /return MAC address of the interface
107107 */
108- virtual const char *get_mac_address ();
108+ const char *get_mac_address () override ;
109109
110110 /* * Register callback for status reporting
111111 *
@@ -115,20 +115,20 @@ class InterfaceNanostack : public virtual NetworkInterface {
115115 *
116116 * @param status_cb The callback for status changes
117117 */
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 ;
119119
120120 /* * Get the connection status
121121 *
122122 * @return The connection status according to ConnectionStatusType
123123 */
124- virtual nsapi_connection_status_t get_connection_status () const ;
124+ nsapi_connection_status_t get_connection_status () const override ;
125125
126126 /* * Set blocking status of connect() which by default should be blocking
127127 *
128128 * @param blocking true if connect is blocking
129129 * @return 0 on success, negative error code on failure
130130 */
131- virtual nsapi_error_t set_blocking (bool blocking);
131+ nsapi_error_t set_blocking (bool blocking) override ;
132132
133133 /* * Set file system root path.
134134 *
@@ -138,7 +138,7 @@ class InterfaceNanostack : public virtual NetworkInterface {
138138 * @param root_path Address to NUL-terminated root-path string or NULL to disable file system usage.
139139 * @return MESH_ERROR_NONE on success, MESH_ERROR_MEMORY in case of memory failure, MESH_ERROR_UNKNOWN in case of other error.
140140 */
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);
142142
143143 /* * Get the interface ID
144144 * @return Interface identifier
@@ -149,20 +149,20 @@ class InterfaceNanostack : public virtual NetworkInterface {
149149 }
150150
151151protected:
152- InterfaceNanostack ();
153- virtual Nanostack *get_stack (void );
152+ InterfaceNanostack () = default ;
153+ Nanostack *get_stack (void ) override ;
154154 Nanostack::Interface *get_interface () const
155155 {
156156 return _interface;
157157 }
158158 virtual nsapi_error_t do_initialize () = 0;
159159
160- Nanostack::Interface *_interface;
160+ Nanostack::Interface *_interface = nullptr ;
161161
162162 SocketAddress ip_addr;
163- char mac_addr_str[24 ];
163+ char mac_addr_str[24 ] {} ;
164164 mbed::Callback<void (nsapi_event_t , intptr_t )> _connection_status_cb;
165- bool _blocking;
165+ bool _blocking = true ;
166166};
167167
168168class MeshInterfaceNanostack : public InterfaceNanostack , public MeshInterface , private mbed ::NonCopyable<MeshInterfaceNanostack> {
@@ -178,13 +178,13 @@ class MeshInterfaceNanostack : public InterfaceNanostack, public MeshInterface,
178178 nsapi_error_t initialize (NanostackRfPhy *phy);
179179
180180protected:
181- MeshInterfaceNanostack () : _phy( NULL ) { }
181+ MeshInterfaceNanostack () = default ;
182182 MeshInterfaceNanostack (NanostackRfPhy *phy) : _phy(phy) { }
183183 Nanostack::MeshInterface *get_interface () const
184184 {
185185 return static_cast <Nanostack::MeshInterface *>(_interface);
186186 }
187- NanostackRfPhy *_phy;
187+ NanostackRfPhy *_phy = nullptr ;
188188};
189189
190190#endif /* MESHINTERFACENANOSTACK_H */
0 commit comments