mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #14817 from artokin/add_nanostack_system_time_callbacks_to_master
Add system time read/write callbacks to mbed-mesh-apipull/14897/head
commit
1849bb55ed
|
@ -24,6 +24,10 @@
|
|||
"help": "Definition of heap statistics `mem_stat_t` storage.",
|
||||
"value": null
|
||||
},
|
||||
"system-time-update-from-nanostack": {
|
||||
"help": "Allow nanostack to read and write device system time to synchronise time in the network. Feature enabled when set to true, false otherwise.",
|
||||
"value": true
|
||||
},
|
||||
"6lowpan-nd-channel-mask": {
|
||||
"help": "Channel mask, bit-mask of channels to use. [0-0x07fff800]",
|
||||
"value": "0x7fff800"
|
||||
|
|
|
@ -22,6 +22,21 @@
|
|||
#include "thread_management_if.h"
|
||||
#include "ip6string.h"
|
||||
#include "mbed_error.h"
|
||||
#include "mbed_rtc_time.h"
|
||||
|
||||
#if (MBED_CONF_MBED_MESH_API_SYSTEM_TIME_UPDATE_FROM_NANOSTACK == true)
|
||||
static uint64_t time_read_callback(void)
|
||||
{
|
||||
time_t seconds = time(NULL);
|
||||
|
||||
return (uint64_t)seconds;
|
||||
}
|
||||
|
||||
static void time_write_callback(uint64_t time_write)
|
||||
{
|
||||
set_time((time_t)time_write);
|
||||
}
|
||||
#endif /* MBED_CONF_MBED_MESH_API_SYSTEM_TIME_UPDATE_FROM_NANOSTACK */
|
||||
|
||||
nsapi_error_t Nanostack::Interface::get_ip_address(SocketAddress *address)
|
||||
{
|
||||
|
@ -110,6 +125,10 @@ int InterfaceNanostack::connect()
|
|||
return error;
|
||||
}
|
||||
|
||||
#if (MBED_CONF_MBED_MESH_API_SYSTEM_TIME_UPDATE_FROM_NANOSTACK == true)
|
||||
mesh_system_time_callback_set(time_read_callback, time_write_callback);
|
||||
#endif /* MBED_CONF_MBED_MESH_API_SYSTEM_TIME_UPDATE_FROM_NANOSTACK */
|
||||
|
||||
return _interface->bringup(false, NULL, NULL, NULL, IPV6_STACK, _blocking);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,11 @@ enum {
|
|||
APPL_BACKHAUL_LINK_UP
|
||||
};
|
||||
|
||||
|
||||
typedef uint64_t ns_time_read_cb(void);
|
||||
typedef void ns_time_write_cb(uint64_t);
|
||||
|
||||
|
||||
/*
|
||||
* \brief Send application connect event to receiver tasklet to
|
||||
* ensure that connection is made in right tasklet.
|
||||
|
@ -40,6 +45,8 @@ void mesh_system_send_connect_event(uint8_t receiver);
|
|||
|
||||
int mesh_system_set_file_system_root_path(const char *root_path);
|
||||
|
||||
void mesh_system_time_callback_set(ns_time_read_cb, ns_time_write_cb);
|
||||
|
||||
/*
|
||||
* \brief Initialize mesh system.
|
||||
* Memory pool, timers, traces and support are initialized.
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "mbed_assert.h"
|
||||
#include "mbed_error.h"
|
||||
#include "ns_file_system.h"
|
||||
#include "ns_time_api.h"
|
||||
// For tracing we need to define flag, have include and define group
|
||||
#define HAVE_DEBUG 1
|
||||
#include "ns_trace.h"
|
||||
|
@ -83,3 +84,9 @@ int mesh_system_set_file_system_root_path(const char *root_path)
|
|||
{
|
||||
return ns_file_system_set_root_path(root_path);
|
||||
}
|
||||
|
||||
void mesh_system_time_callback_set(ns_time_read_cb read_cb, ns_time_write_cb write_cb)
|
||||
{
|
||||
ns_time_api_system_time_callback_set(read_cb);
|
||||
ns_time_api_system_time_write_callback_set(write_cb);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue