int LoWPANNDInterface::connect() { // initialize mesh networking resources, memory, timers, etc... mesh_system_init(); nanostack_lock(); mesh_api = MeshInterfaceFactory::createInterface(MESH_TYPE_6LOWPAN_ND); if (!mesh_api) { nanostack_unlock(); return NSAPI_ERROR_NO_MEMORY; } if (register_rf() < 0) { nanostack_unlock(); return NSAPI_ERROR_DEVICE_ERROR; } // After the RF is up, we can seed the random from it. randLIB_seed_random(); mesh_error_t status = ((Mesh6LoWPAN_ND *)mesh_api)->init(rf_device_id, AbstractMesh::mesh_network_handler_t(static_cast<MeshInterfaceNanostack *>(this), &LoWPANNDInterface::mesh_network_handler)); if (status != MESH_ERROR_NONE) { nanostack_unlock(); return map_mesh_error(status); } int ret = this->actual_connect(); nanostack_unlock(); return ret; }
Nanostack::Interface::Interface(NanostackPhy &phy) : interface_phy(phy), interface_id(-1), _device_id(-1), _connect_status(NSAPI_STATUS_DISCONNECTED), _previous_connection_status(NSAPI_STATUS_DISCONNECTED), _blocking(true) { mesh_system_init(); }