21
21
#include " ns_address.h"
22
22
#include " nsdynmemLIB.h"
23
23
#include " eventOS_scheduler.h"
24
+ #include " randLIB.h"
24
25
25
26
#include " mbed-mesh-api/MeshInterfaceFactory.h"
26
27
28
+ #include " mesh_system.h" // from inside mbed-mesh-api
27
29
#include " socket_api.h"
28
30
#include " driverRFPhy.h"
29
31
#include " net_interface.h"
@@ -481,8 +483,6 @@ int NanostackInterface::register_rf()
481
483
482
484
int NanostackInterface::actual_connect ()
483
485
{
484
- nanostack_lock ();
485
-
486
486
mesh_error_t status = get_mesh_api ()->connect ();
487
487
if (status != MESH_ERROR_NONE) {
488
488
nanostack_unlock ();
@@ -512,6 +512,8 @@ int NanostackInterface::disconnect()
512
512
513
513
int ThreadInterface::connect ()
514
514
{
515
+ // initialize mesh networking resources, memory, timers, etc...
516
+ mesh_system_init ();
515
517
nanostack_lock ();
516
518
517
519
mesh_api = MeshInterfaceFactory::createInterface (MESH_TYPE_THREAD);
@@ -523,6 +525,10 @@ int ThreadInterface::connect()
523
525
nanostack_unlock ();
524
526
return NSAPI_ERROR_DEVICE_ERROR;
525
527
}
528
+
529
+ // After the RF is up, we can seed the random from it.
530
+ randLIB_seed_random ();
531
+
526
532
mesh_error_t status = ((MeshThread *)mesh_api)->init (rf_device_id, AbstractMesh::mesh_network_handler_t (static_cast <NanostackInterface *>(this ), &ThreadInterface::mesh_network_handler), eui64, NULL );
527
533
if (status != MESH_ERROR_NONE) {
528
534
nanostack_unlock ();
@@ -537,6 +543,8 @@ int ThreadInterface::connect()
537
543
538
544
int LoWPANNDInterface::connect ()
539
545
{
546
+ // initialize mesh networking resources, memory, timers, etc...
547
+ mesh_system_init ();
540
548
nanostack_lock ();
541
549
542
550
mesh_api = MeshInterfaceFactory::createInterface (MESH_TYPE_6LOWPAN_ND);
@@ -548,6 +556,10 @@ int LoWPANNDInterface::connect()
548
556
nanostack_unlock ();
549
557
return NSAPI_ERROR_DEVICE_ERROR;
550
558
}
559
+
560
+ // After the RF is up, we can seed the random from it.
561
+ randLIB_seed_random ();
562
+
551
563
mesh_error_t status = ((Mesh6LoWPAN_ND *)mesh_api)->init (rf_device_id, AbstractMesh::mesh_network_handler_t (static_cast <NanostackInterface *>(this ), &LoWPANNDInterface::mesh_network_handler));
552
564
if (status != MESH_ERROR_NONE) {
553
565
nanostack_unlock ();
0 commit comments