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"
@@ -482,8 +484,6 @@ int NanostackInterface::register_rf()
482
484
483
485
int NanostackInterface::actual_connect ()
484
486
{
485
- nanostack_lock ();
486
-
487
487
mesh_error_t status = get_mesh_api ()->connect ();
488
488
if (status != MESH_ERROR_NONE) {
489
489
nanostack_unlock ();
@@ -513,6 +513,8 @@ int NanostackInterface::disconnect()
513
513
514
514
int ThreadInterface::connect ()
515
515
{
516
+ // initialize mesh networking resources, memory, timers, etc...
517
+ mesh_system_init ();
516
518
nanostack_lock ();
517
519
518
520
mesh_api = MeshInterfaceFactory::createInterface (MESH_TYPE_THREAD);
@@ -524,6 +526,10 @@ int ThreadInterface::connect()
524
526
nanostack_unlock ();
525
527
return NSAPI_ERROR_DEVICE_ERROR;
526
528
}
529
+
530
+ // After the RF is up, we can seed the random from it.
531
+ randLIB_seed_random ();
532
+
527
533
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 );
528
534
if (status != MESH_ERROR_NONE) {
529
535
nanostack_unlock ();
@@ -538,6 +544,8 @@ int ThreadInterface::connect()
538
544
539
545
int LoWPANNDInterface::connect ()
540
546
{
547
+ // initialize mesh networking resources, memory, timers, etc...
548
+ mesh_system_init ();
541
549
nanostack_lock ();
542
550
543
551
mesh_api = MeshInterfaceFactory::createInterface (MESH_TYPE_6LOWPAN_ND);
@@ -549,6 +557,10 @@ int LoWPANNDInterface::connect()
549
557
nanostack_unlock ();
550
558
return NSAPI_ERROR_DEVICE_ERROR;
551
559
}
560
+
561
+ // After the RF is up, we can seed the random from it.
562
+ randLIB_seed_random ();
563
+
552
564
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));
553
565
if (status != MESH_ERROR_NONE) {
554
566
nanostack_unlock ();
0 commit comments