Skip to content

Commit 27cced7

Browse files
author
Seppo Takalo
committed
Get rid of Mesh6LoWPAN_ND and MeshThread classes.
* Move all the functionality to LoWPANNDInterface and ThreadInterface classes. * AbstractMesh class modified to be pure virtual * Thread/6LoWPAN specific functionality totally separated. Now linker will drop the unreferenced classes. * MeshInterfaceNanostack now inherits from AbstractMesh
1 parent 62558e9 commit 27cced7

File tree

13 files changed

+403
-655
lines changed

13 files changed

+403
-655
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2015 ARM Limited. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
* Licensed under the Apache License, Version 2.0 (the License); you may
5+
* 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, WITHOUT
12+
* 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 LOWPANNDINTERFACE_H
18+
#define LOWPANNDINTERFACE_H
19+
20+
#include "NanostackInterface.h"
21+
22+
class LoWPANNDInterface : public MeshInterfaceNanostack {
23+
public:
24+
25+
/** Create an uninitialized LoWPANNDInterface
26+
*
27+
* Must initialize to initialize the mesh on a phy.
28+
*/
29+
LoWPANNDInterface() : MeshInterfaceNanostack() {
30+
31+
}
32+
33+
/** Create an initialized MeshInterface
34+
*
35+
*/
36+
LoWPANNDInterface(NanostackRfPhy *phy) : MeshInterfaceNanostack(phy) {
37+
38+
}
39+
40+
int connect();
41+
int disconnect();
42+
bool getOwnIpAddress(char *address, int8_t len);
43+
bool getRouterIpAddress(char *address, int8_t len);
44+
private:
45+
mesh_error_t init();
46+
mesh_error_t mesh_connect();
47+
mesh_error_t mesh_disconnect();
48+
};
49+
50+
#endif

features/nanostack/FEATURE_NANOSTACK/mbed-mesh-api/mbed-mesh-api/Mesh6LoWPAN_ND.h

Lines changed: 0 additions & 61 deletions
This file was deleted.

features/nanostack/FEATURE_NANOSTACK/mbed-mesh-api/mbed-mesh-api/MeshThread.h

Lines changed: 0 additions & 75 deletions
This file was deleted.

features/nanostack/FEATURE_NANOSTACK/mbed-mesh-api/mbed-mesh-api/AbstractMesh.h renamed to features/nanostack/FEATURE_NANOSTACK/mbed-mesh-api/mbed-mesh-api/ThreadInterface.h

Lines changed: 23 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,40 @@
1414
* limitations under the License.
1515
*/
1616

17-
#ifndef __ABSTRACTMESH_H__
18-
#define __ABSTRACTMESH_H__
17+
#ifndef THREADINTERFACE_H
18+
#define THREADINTERFACE_H
1919

20-
#include "mbed.h"
21-
#include "mesh_interface_types.h"
22-
23-
/**
24-
* \brief Abstract Mesh networking interface.
25-
* This class can't be instantiated directly.
26-
*/
27-
class AbstractMesh
28-
{
20+
#include "NanostackInterface.h"
2921

22+
class ThreadInterface : public MeshInterfaceNanostack {
3023
public:
3124

32-
/**
33-
* Typedef for network callback
25+
/** Create an uninitialized LoWPANNDInterface
26+
*
27+
* Must initialize to initialize the mesh on a phy.
3428
*/
35-
typedef FunctionPointerArg1<void, mesh_connection_status_t> mesh_network_handler_t;
29+
ThreadInterface() : MeshInterfaceNanostack() {
3630

37-
/**
38-
* Constructor
39-
* \param type mesh network type
31+
}
32+
33+
/** Create an initialized MeshInterface
34+
*
4035
*/
41-
AbstractMesh(mesh_network_type_t type);
36+
ThreadInterface(NanostackRfPhy *phy) : MeshInterfaceNanostack(phy) {
4237

43-
// Destructor, force derived classes to implement own destructors
44-
// and prevent class creation.
45-
virtual ~AbstractMesh() = 0;
38+
}
4639

47-
/**
40+
int connect();
41+
int disconnect();
42+
private:
43+
/*
4844
* \brief Initialization of the interface.
49-
* \param registered device is physical device registered
50-
* \param callbackHandler is callback that is called when network state changes
5145
* \return MESH_ERROR_NONE on success.
5246
* \return MESH_ERROR_PARAM when input parameters are illegal (also in case when RF device is already associated to other interface)
5347
* \return MESH_ERROR_MEMORY in case of memory error
5448
* \return MESH_ERROR_UNKNOWN in other error cases
5549
*/
56-
virtual mesh_error_t init(int8_t registered_device_id, mesh_network_handler_t callbackHandler);
57-
50+
mesh_error_t init();
5851
/**
5952
* \brief Connect interface to the mesh network
6053
* \return MESH_ERROR_NONE on success.
@@ -63,20 +56,14 @@ class AbstractMesh
6356
* \return MESH_ERROR_STATE if interface is already connected to network.
6457
* \return MESH_ERROR_UNKNOWN in case of unspecified error.
6558
* */
66-
virtual mesh_error_t connect();
59+
mesh_error_t mesh_connect();
6760

6861
/**
6962
* \brief Disconnect interface from the mesh network
7063
* \return MESH_ERROR_NONE on success.
7164
* \return MESH_ERROR_UNKNOWN in case of error.
7265
* */
73-
virtual mesh_error_t disconnect();
74-
75-
/**
76-
* \brief Callback from C-layer
77-
* \param state state of the network
78-
* */
79-
void callback(mesh_connection_status_t state);
66+
mesh_error_t mesh_disconnect();
8067

8168
/**
8269
* \brief Read own global IP address
@@ -85,29 +72,7 @@ class AbstractMesh
8572
* \param len is the length of the address buffer, must be at least 40 bytes
8673
* \return true if address is read successfully, false otherwise
8774
*/
88-
virtual bool getOwnIpAddress(char *address, int8_t len) = 0;
89-
90-
protected:
91-
92-
/*
93-
* Mesh callback function
94-
*/
95-
mesh_network_handler_t _mesh_network_handler;
96-
97-
/*
98-
* Network interface ID
99-
*/
100-
int8_t _network_interface_id;
101-
102-
/*
103-
* Registered device ID
104-
*/
105-
int8_t _device_id;
106-
107-
/*
108-
* Mesh network type
109-
*/
110-
mesh_network_type_t _mesh_network_type;
75+
bool getOwnIpAddress(char *address, int8_t len);
11176
};
11277

113-
#endif /* __ABSTRACTMESH_H__ */
78+
#endif // THREADINTERFACE_H

0 commit comments

Comments
 (0)