Skip to content

Commit f8289ec

Browse files
author
Arto Kinnunen
committed
mbed-mesh-api: Add API set_file_system_root_path
1 parent 774162d commit f8289ec

File tree

5 files changed

+41
-10
lines changed

5 files changed

+41
-10
lines changed

features/nanostack/mbed-mesh-api/mbed-mesh-api/MeshInterfaceNanostack.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016 ARM Limited. All rights reserved.
2+
* Copyright (c) 2016-2019 ARM Limited. All rights reserved.
33
* SPDX-License-Identifier: Apache-2.0
44
* Licensed under the Apache License, Version 2.0 (the License); you may
55
* not use this file except in compliance with the License.
@@ -132,9 +132,19 @@ class InterfaceNanostack : public virtual NetworkInterface {
132132
*/
133133
virtual nsapi_error_t set_blocking(bool blocking);
134134

135+
/** Set file system root path.
136+
*
137+
* Set file system root path that stack will use to write and read its data.
138+
* Setting root_path to NULL will disable file system usage.
139+
*
140+
* @param root_path Address to NUL-terminated root-path string or NULL to disable file system usage.
141+
* @return MESH_ERROR_NONE on success, MESH_ERROR_MEMORY in case of memory failure, MESH_ERROR_UNKNOWN in case of other error.
142+
*/
143+
virtual nsapi_error_t set_file_system_root_path(const char *root_path);
144+
135145
/** Get the interface ID
136-
/return Interface identifier
137-
*/
146+
* @return Interface identifier
147+
*/
138148
int8_t get_interface_id() const
139149
{
140150
return _interface->get_interface_id();

features/nanostack/mbed-mesh-api/mbed-mesh-api/WisunInterface.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class WisunInterface : public MeshInterfaceNanostack {
7575
* Function can be called several times if intermediate certificates are used. Then each call to the function
7676
* adds a certificate reference to own certificate chain. Certificates are in bottom up order i.e. the top certificate is given last.
7777
*
78-
* Function must be called before connecting the device i.e before first call to connect() method.
78+
* Function must be called before connecting the device i.e before call to connect() method.
7979
* Function will not copy certificate or key, therefore addresses must remain valid.
8080
*
8181
* \param cert Certificate address.
@@ -91,7 +91,7 @@ class WisunInterface : public MeshInterfaceNanostack {
9191
/**
9292
* \brief Remove own certificates from the Wi-SUN network.
9393
*
94-
* Function must be called before connecting the device i.e before first call to connect() method.
94+
* Function must be called before connecting the device i.e before call to connect() method.
9595
*
9696
* \return MESH_ERROR_NONE on success.
9797
* \return MESH_ERROR_STATE if method is called after calling connect().
@@ -103,7 +103,7 @@ class WisunInterface : public MeshInterfaceNanostack {
103103
*
104104
* Function can be called several times. Certificates are in bottom up order i.e. the top certificate is given last.
105105
*
106-
* Function must be called before connecting the device i.e before first call to connect() method.
106+
* Function must be called before connecting the device i.e before call to connect() method.
107107
* Function will not copy certificate, therefore addresses must remain valid.
108108
*
109109
* \param cert Certificate address.
@@ -117,7 +117,7 @@ class WisunInterface : public MeshInterfaceNanostack {
117117
/**
118118
* \brief Remove trusted certificates from the Wi-SUN network.
119119
*
120-
* Function must be called before connecting the device i.e before first call to connect() method.
120+
* Function must be called before connecting the device i.e before call to connect() method.
121121
*
122122
* \return MESH_ERROR_NONE on success.
123123
* \return MESH_ERROR_STATE if method is called after calling connect().

features/nanostack/mbed-mesh-api/source/MeshInterfaceNanostack.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016 ARM Limited. All rights reserved.
2+
* Copyright (c) 2016-2019 ARM Limited. All rights reserved.
33
* SPDX-License-Identifier: Apache-2.0
44
* Licensed under the Apache License, Version 2.0 (the License); you may
55
* not use this file except in compliance with the License.
@@ -217,6 +217,19 @@ nsapi_error_t InterfaceNanostack::set_blocking(bool blocking)
217217
return NSAPI_ERROR_OK;
218218
}
219219

220+
nsapi_error_t InterfaceNanostack::set_file_system_root_path(const char *root_path)
221+
{
222+
int status = mesh_system_set_file_system_root_path(root_path);
223+
224+
if (status == 0) {
225+
return MESH_ERROR_NONE;
226+
} else if (status == -2) {
227+
return MESH_ERROR_MEMORY;
228+
}
229+
230+
return MESH_ERROR_UNKNOWN;
231+
}
232+
220233
#if !DEVICE_802_15_4_PHY
221234
MBED_WEAK MeshInterface *MeshInterface::get_target_default_instance()
222235
{

features/nanostack/mbed-mesh-api/source/include/mesh_system.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015 ARM Limited. All rights reserved.
2+
* Copyright (c) 2015-2019 ARM Limited. All rights reserved.
33
* SPDX-License-Identifier: Apache-2.0
44
* Licensed under the Apache License, Version 2.0 (the License); you may
55
* not use this file except in compliance with the License.
@@ -38,6 +38,8 @@ enum {
3838
*/
3939
void mesh_system_send_connect_event(uint8_t receiver);
4040

41+
int mesh_system_set_file_system_root_path(const char *root_path);
42+
4143
/*
4244
* \brief Initialize mesh system.
4345
* Memory pool, timers, traces and support are initialized.

features/nanostack/mbed-mesh-api/source/mesh_system.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015 ARM Limited. All rights reserved.
2+
* Copyright (c) 2015-2019 ARM Limited. All rights reserved.
33
* SPDX-License-Identifier: Apache-2.0
44
* Licensed under the Apache License, Version 2.0 (the License); you may
55
* not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525
#include "include/mesh_system.h"
2626
#include "mbed_assert.h"
2727
#include "mbed_error.h"
28+
#include "ns_file_system.h"
2829
// For tracing we need to define flag, have include and define group
2930
#define HAVE_DEBUG 1
3031
#include "ns_trace.h"
@@ -77,3 +78,8 @@ void mesh_system_send_connect_event(uint8_t receiver)
7778
};
7879
eventOS_event_send(&event);
7980
}
81+
82+
int mesh_system_set_file_system_root_path(const char *root_path)
83+
{
84+
return ns_file_system_set_root_path(root_path);
85+
}

0 commit comments

Comments
 (0)