diff --git a/features/nanostack/mbed-mesh-api/mbed-mesh-api/MeshInterfaceNanostack.h b/features/nanostack/mbed-mesh-api/mbed-mesh-api/MeshInterfaceNanostack.h index 187a24d849..77ab9a55f0 100644 --- a/features/nanostack/mbed-mesh-api/mbed-mesh-api/MeshInterfaceNanostack.h +++ b/features/nanostack/mbed-mesh-api/mbed-mesh-api/MeshInterfaceNanostack.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 ARM Limited. All rights reserved. + * Copyright (c) 2016-2019 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. @@ -132,9 +132,19 @@ public: */ virtual nsapi_error_t set_blocking(bool blocking); + /** Set file system root path. + * + * Set file system root path that stack will use to write and read its data. + * Setting root_path to NULL will disable file system usage. + * + * @param root_path Address to NUL-terminated root-path string or NULL to disable file system usage. + * @return MESH_ERROR_NONE on success, MESH_ERROR_MEMORY in case of memory failure, MESH_ERROR_UNKNOWN in case of other error. + */ + virtual nsapi_error_t set_file_system_root_path(const char *root_path); + /** Get the interface ID - /return Interface identifier - */ + * @return Interface identifier + */ int8_t get_interface_id() const { return _interface->get_interface_id(); diff --git a/features/nanostack/mbed-mesh-api/mbed-mesh-api/WisunInterface.h b/features/nanostack/mbed-mesh-api/mbed-mesh-api/WisunInterface.h index e605e2550a..e80657c3e3 100644 --- a/features/nanostack/mbed-mesh-api/mbed-mesh-api/WisunInterface.h +++ b/features/nanostack/mbed-mesh-api/mbed-mesh-api/WisunInterface.h @@ -75,7 +75,7 @@ public: * Function can be called several times if intermediate certificates are used. Then each call to the function * adds a certificate reference to own certificate chain. Certificates are in bottom up order i.e. the top certificate is given last. * - * Function must be called before connecting the device i.e before first call to connect() method. + * Function must be called before connecting the device i.e before call to connect() method. * Function will not copy certificate or key, therefore addresses must remain valid. * * \param cert Certificate address. @@ -91,7 +91,7 @@ public: /** * \brief Remove own certificates from the Wi-SUN network. * - * Function must be called before connecting the device i.e before first call to connect() method. + * Function must be called before connecting the device i.e before call to connect() method. * * \return MESH_ERROR_NONE on success. * \return MESH_ERROR_STATE if method is called after calling connect(). @@ -103,7 +103,7 @@ public: * * Function can be called several times. Certificates are in bottom up order i.e. the top certificate is given last. * - * Function must be called before connecting the device i.e before first call to connect() method. + * Function must be called before connecting the device i.e before call to connect() method. * Function will not copy certificate, therefore addresses must remain valid. * * \param cert Certificate address. @@ -117,7 +117,7 @@ public: /** * \brief Remove trusted certificates from the Wi-SUN network. * - * Function must be called before connecting the device i.e before first call to connect() method. + * Function must be called before connecting the device i.e before call to connect() method. * * \return MESH_ERROR_NONE on success. * \return MESH_ERROR_STATE if method is called after calling connect(). diff --git a/features/nanostack/mbed-mesh-api/source/MeshInterfaceNanostack.cpp b/features/nanostack/mbed-mesh-api/source/MeshInterfaceNanostack.cpp index 255aeef030..dfbe3539fe 100644 --- a/features/nanostack/mbed-mesh-api/source/MeshInterfaceNanostack.cpp +++ b/features/nanostack/mbed-mesh-api/source/MeshInterfaceNanostack.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 ARM Limited. All rights reserved. + * Copyright (c) 2016-2019 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. @@ -217,6 +217,19 @@ nsapi_error_t InterfaceNanostack::set_blocking(bool blocking) return NSAPI_ERROR_OK; } +nsapi_error_t InterfaceNanostack::set_file_system_root_path(const char *root_path) +{ + int status = mesh_system_set_file_system_root_path(root_path); + + if (status == 0) { + return MESH_ERROR_NONE; + } else if (status == -2) { + return MESH_ERROR_MEMORY; + } + + return MESH_ERROR_UNKNOWN; +} + #if !DEVICE_802_15_4_PHY MBED_WEAK MeshInterface *MeshInterface::get_target_default_instance() { diff --git a/features/nanostack/mbed-mesh-api/source/include/mesh_system.h b/features/nanostack/mbed-mesh-api/source/include/mesh_system.h index f8cd90c564..b075ec6004 100644 --- a/features/nanostack/mbed-mesh-api/source/include/mesh_system.h +++ b/features/nanostack/mbed-mesh-api/source/include/mesh_system.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 ARM Limited. All rights reserved. + * Copyright (c) 2015-2019 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. @@ -38,6 +38,8 @@ enum { */ void mesh_system_send_connect_event(uint8_t receiver); +int mesh_system_set_file_system_root_path(const char *root_path); + /* * \brief Initialize mesh system. * Memory pool, timers, traces and support are initialized. diff --git a/features/nanostack/mbed-mesh-api/source/mesh_system.c b/features/nanostack/mbed-mesh-api/source/mesh_system.c index 0971f02e4a..59fa78582f 100644 --- a/features/nanostack/mbed-mesh-api/source/mesh_system.c +++ b/features/nanostack/mbed-mesh-api/source/mesh_system.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 ARM Limited. All rights reserved. + * Copyright (c) 2015-2019 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. @@ -25,6 +25,7 @@ #include "include/mesh_system.h" #include "mbed_assert.h" #include "mbed_error.h" +#include "ns_file_system.h" // For tracing we need to define flag, have include and define group #define HAVE_DEBUG 1 #include "ns_trace.h" @@ -77,3 +78,8 @@ void mesh_system_send_connect_event(uint8_t receiver) }; eventOS_event_send(&event); } + +int mesh_system_set_file_system_root_path(const char *root_path) +{ + return ns_file_system_set_root_path(root_path); +}