Skip to content

Commit b754767

Browse files
author
Arto Kinnunen
committed
Add property API to NetworkInterface
Property API allows application to ask network specific properties from the NetworkInterface. Queried information can be used to avoid network congestion by adjusting transmission jitter and retry timeouts.
1 parent 5c16018 commit b754767

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ class InterfaceNanostack : public virtual NetworkInterface {
140140
*/
141141
virtual nsapi_error_t set_file_system_root_path(const char *root_path);
142142

143+
/** @copydoc NetworkInterface::get_interface_property */
144+
virtual nsapi_error_t get_interface_property(nsapi_size_t data_amount, nsapi_size_t *jitter);
145+
143146
/** Get the interface ID
144147
* @return Interface identifier
145148
*/

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "NanostackLockGuard.h"
2020
#include "mesh_system.h"
2121
#include "nanostack/net_interface.h"
22+
#include "nanostack/ns_property.h"
2223
#include "thread_management_if.h"
2324
#include "ip6string.h"
2425
#include "mbed_error.h"
@@ -232,6 +233,19 @@ nsapi_error_t InterfaceNanostack::set_file_system_root_path(const char *root_pat
232233
return MESH_ERROR_UNKNOWN;
233234
}
234235

236+
nsapi_error_t InterfaceNanostack::get_interface_property(nsapi_size_t data_amount, nsapi_size_t *jitter) {
237+
ns_properties_t ns_properties;
238+
239+
ns_properties.data_amount = data_amount;
240+
241+
if (ns_property_get(get_interface_id(), &ns_properties) == 0) {
242+
*jitter = ns_properties.tx_jitter;
243+
return NSAPI_ERROR_OK;
244+
}
245+
246+
return NSAPI_ERROR_NO_CONNECTION;
247+
}
248+
235249
#if !DEVICE_802_15_4_PHY
236250
MBED_WEAK MeshInterface *MeshInterface::get_target_default_instance()
237251
{

features/netsocket/NetworkInterface.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,7 @@ nsapi_error_t NetworkInterface::set_blocking(bool blocking)
174174
return NSAPI_ERROR_UNSUPPORTED;
175175
}
176176

177+
nsapi_error_t NetworkInterface::get_interface_property(unsigned int data_amount, unsigned int *jitter)
178+
{
179+
return NSAPI_ERROR_UNSUPPORTED;
180+
}

features/netsocket/NetworkInterface.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,15 @@ class NetworkInterface: public DNS {
378378
*/
379379
virtual nsapi_error_t set_blocking(bool blocking);
380380

381+
/** Get suggested data transmission jitter from underlying network interface.
382+
*
383+
* @param data_amount Amount of data to be sent
384+
* @param jitter Address to location where suggested jitter value is written
385+
* @return NSAPI_ERROR_OK on success
386+
* @return NSAPI_ERROR_UNSUPPORTED, NSAPI_ERROR_NO_CONNECTION
387+
*/
388+
virtual nsapi_error_t get_interface_property(unsigned int data_amount, unsigned int *jitter);
389+
381390
/** Return pointer to an EthInterface.
382391
* @return Pointer to requested interface type or NULL if this class doesn't implement the interface.
383392
*/

0 commit comments

Comments
 (0)