Skip to content

ONME-2857: Ethernet interface for Nanostack #3267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 38 additions & 7 deletions features/nanostack/FEATURE_NANOSTACK/mbed-mesh-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ARM mbed mesh API allows the client to use the IPv6 mesh network.

The client can use the `LoWPANNDInterface` or `ThreadInterface` object for connecting to the mesh network and when successfully connected, the client can create a socket by using the [mbed C++ socket API](https://developer.mbed.org/teams/NetworkSocketAPI/code/NetworkSocketAPI/docs/tip/) to start communication with a remote peer.

For ethernet `NanostackEthernetInterface` is provided.

## Supported mesh networking modes

Currently, 6LoWPAN-ND (neighbour discovery) and Thread bootstrap modes are supported.
Expand All @@ -27,18 +29,18 @@ An example of the configuration file:
}
```

**Configurable parameters in section `mbed-mesh-api`:**
### Configurable parameters in section mbed-mesh-api

| Parameter name | Value | Description |
| --------------- | ------------- | ----------- |
| heap-size | number [0-0xfffe] | Nanostack's internal heap size |

**Thread related configuration parameters:**
### Thread related configuration parameters

| Parameter name | Value | Description |
| --------------- | ------------- | ----------- |
| thread-pskd | string [6-255 chars] | Human-scaled commissioning credentials. |
| hread-device-type | enum from mesh_device_type_t | Set device operating mode. |
| thread-device-type | enum from mesh_device_type_t | Set device operating mode. |
| thread-config-channel-mask | number [0-0x07fff800] | Channel mask, 0x07fff800 scans all channels. |
| thread-config-channel-page | number [0, 2]| Channel page, 0 for 2,4 GHz and 2 for sub-GHz radios. |
| thread-config-channel | number [0-27] | RF channel to use. |
Expand All @@ -47,7 +49,7 @@ An example of the configuration file:
| thread-config-ml-prefix | byte array [8] | Mesh local prefix. |
| thread-config-pskc | byte array [16] | Pre-Shared Key for the Commissioner. |

**6LoWPAN related configuration parameters:**
### 6LoWPAN related configuration parameters

| Parameter name | Type | Description |
| --------------- | ---------| ----------- |
Expand All @@ -63,7 +65,9 @@ An example of the configuration file:

## Usage notes

This module should not be used directly by the applications. The applications should use the `LoWPANNDInterface` or `ThreadInterface` directly.
This module should not be used directly by the applications. The applications should use the `LoWPANNDInterface`, `ThreadInterface` or `NanostackEthernetInterface` directly.

When using Ethernet interface, there is no configuration options available. It is using dynamic mode to learn the IPv6 prefix from the network. No static configuration is supported.

### Network connection states

Expand All @@ -77,13 +81,20 @@ See the example application [mbed-os-example-mesh-minimal](https://github.com/AR

## Usage example for 6LoWPAN ND mode

**Create a network interface:**
Create a network interface and driver objects.

```
LoWPANNDInterface mesh;
NanostackRfPhyNcs36510 rf_phy;
```

**Connect:**
Initialize interface with given PHY driver.

```
mesh.initialize(&rf_phy);
```

Then connect to network:

```
if (mesh.connect()) {
Expand All @@ -102,3 +113,23 @@ Basically the same as for ND, but the network interface uses different class:
ThreadInterface mesh;
mesh.connect();
```

## Usage example with Ethernet

API is still the same, you just need to provide a driver that implements `NanostackEthernetPhy` API.

```
NanostackEthernetInterface eth;
NanostackEthernetPhyK64F phy;

int main() {
eth.initialize(&phy);

if (eth.connect()) {
printf("Connection failed!\r\n");
return -1;
}

printf("connected. IP = %s\r\n", eth.get_ip_address());
}
```

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2015 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef LOWPANNDINTERFACE_H
#define LOWPANNDINTERFACE_H

#include "MeshInterfaceNanostack.h"

class LoWPANNDInterface : public MeshInterfaceNanostack {
public:

/** Create an uninitialized LoWPANNDInterface
*
* Must initialize to initialize the mesh on a phy.
*/
LoWPANNDInterface() : MeshInterfaceNanostack() { }

/** Create an initialized MeshInterface
*
*/
LoWPANNDInterface(NanostackRfPhy *phy) : MeshInterfaceNanostack(phy) { }

nsapi_error_t initialize(NanostackRfPhy *phy);
int connect();
int disconnect();
bool getOwnIpAddress(char *address, int8_t len);
bool getRouterIpAddress(char *address, int8_t len);
private:
mesh_error_t init();
mesh_error_t mesh_connect();
mesh_error_t mesh_disconnect();
};

#endif

This file was deleted.

Loading