3535import org .eclipse .kura .net .wifi .WifiSecurity ;
3636import org .eclipse .kura .nm .configuration .NMSettingsConverter ;
3737import org .eclipse .kura .nm .enums .MMModemLocationSource ;
38- import org .eclipse .kura .nm .enums .MMModemState ;
3938import org .eclipse .kura .nm .enums .NMDeviceState ;
4039import org .eclipse .kura .nm .enums .NMDeviceType ;
4140import org .eclipse .kura .nm .signal .handlers .DeviceCreationLock ;
@@ -139,8 +138,8 @@ protected boolean configurationEnforcementIsActive() {
139138 && this .configurationEnforcementHandlerIsArmed ;
140139 }
141140
142- protected boolean failedModemResetTimerIsActive (String modemId ) {
143- return this .modemManager .isMMFailedModemResetTimerArmed (modemId );
141+ protected boolean modemTaskHandlerIsPresent (String modemId ) {
142+ return this .modemManager .isModemTaskHandlerActive (modemId );
144143 }
145144
146145 public void checkPermissions () {
@@ -358,7 +357,7 @@ ip4configProperties, ip6configProperties, new AccessPointsProperties(activeAcces
358357 public synchronized void apply (Map <String , Object > networkConfiguration ) throws DBusException {
359358 try {
360359 configurationEnforcementDisable ();
361- this .modemManager .resetHandlersDisable ();
360+ this .modemManager .modemTaskHandlerDisable ();
362361 doApply (networkConfiguration );
363362 this .cachedConfiguration = networkConfiguration ;
364363 } finally {
@@ -373,7 +372,7 @@ public synchronized void apply() throws DBusException {
373372 }
374373 try {
375374 configurationEnforcementDisable ();
376- this .modemManager .resetHandlersDisable ();
375+ this .modemManager .modemTaskHandlerDisable ();
377376 doApply (this .cachedConfiguration );
378377 } finally {
379378 configurationEnforcementEnable ();
@@ -390,7 +389,7 @@ public synchronized void apply(String deviceId) throws DBusException {
390389 }
391390 try {
392391 configurationEnforcementDisable ();
393- this .modemManager .resetHandlersDisable (deviceId );
392+ this .modemManager .modemTaskHandlerDisable (deviceId );
394393 doApply (deviceId , this .cachedConfiguration );
395394 } finally {
396395 configurationEnforcementEnable ();
@@ -561,31 +560,8 @@ private void enableInterface(String deviceId, NetworkProperties properties, Devi
561560 connection = Optional .of (createdConnection );
562561 }
563562
564- // boolean activationSucceeded = true;
565- // try {
566- // this.modemManager.failedModemResetTimerCancel(deviceId);
567- // // this.modemManager.modemConnectionTaskCancel(deviceId);
568- // this.modemManager.connectionHandlersDisable(deviceId);
569- // this.networkManager.activateConnection(connection.get(), device);
570- // dsLock.waitForSignal();
571- // } catch (DBusExecutionException e) {
572- // logger.warn("Couldn't complete activation of {} interface, caused by:", deviceId, e);
573- // activationSucceeded = false;
574- // }
575- //
576- // // Housekeeping
577- // List<Connection> availableConnections = this.networkManager.getAvaliableConnections(device);
578- // for (Connection availableConnection : availableConnections) {
579- // if (!connection.get().getObjectPath().equals(availableConnection.getObjectPath())) {
580- // availableConnection.Delete();
581- // }
582- // }
583-
584563 if (deviceType == NMDeviceType .NM_DEVICE_TYPE_MODEM ) {
585- this .modemManager .failedModemResetTimerCancel (deviceId );
586- // this.modemManager.modemConnectionTaskCancel(deviceId);
587- this .modemManager .connectionHandlersDisable (deviceId );
588-
564+ this .modemManager .modemTaskHandlerDisable (deviceId );
589565 Optional <String > mmDbusPath = this .networkManager .getModemManagerDbusPath (device .getObjectPath ());
590566 if (!mmDbusPath .isPresent ()) {
591567 return ;
@@ -599,52 +575,16 @@ private void enableInterface(String deviceId, NetworkProperties properties, Devi
599575 return ;
600576 }
601577
602- // int resetDelayMinutes = properties.get(Integer.class, "net.interface.%s.config.resetTimeout", deviceId);
603- // boolean autoconnect = properties.get(Boolean.class, "net.interface.%s.config.persist", deviceId);
604- int holdoff = properties .get (Integer .class , "net.interface.%s.config.holdoff" , deviceId );
605- int maxFail = properties .get (Integer .class , "net.interface.%s.config.maxFail" , deviceId );
606-
607578 logger .info ("Modem {} activated. Starting monitoring task..." , deviceId );
608- this .modemManager .modemConnectionTask (deviceId , this .modemManager , this .networkManager , connection .get (),
609- device , maxFail , holdoff , autoconnect , resetDelayMinutes ); // maybe change to handler...
610-
611- // this.modemManager.resetHandlerEnable(deviceId, mmDbusPath, resetDelayMinutes, device.getObjectPath());
612- //
613- //
614- //
615- // if (autoconnect) {
616- // logger.info("Modem {} configured for autoconnect. Starting connection task...", deviceId);
617- // this.modemManager.modemConnectionTask(deviceId, this.networkManager, connection.get(), device, maxFail,
618- // holdoff);
619- // }
620- //
621- // // If a modem connection fails at the first try, it stays in the failed state, thus not triggering the
622- // usual
623- // // modem reset procedure. So, start a reset timer here.
624- // if (!activationSucceeded && isModemFailed(mmDbusPath.get())) {
625- // logger.info("Modem {} in failed state or unavailable. Scheduling modem reset in {} minutes ...",
626- // device.getObjectPath(), resetDelayMinutes);
627- //
628- // this.modemManager.failedModemResetTimerSchedule(deviceId, mmDbusPath, resetDelayMinutes);
629- //
630- // // if (autoconnect) {
631- // // logger.info("Modem {} configured for autoconnect. Starting connection task...", deviceId);
632- // // this.modemManager.modemConnectionTask(deviceId, this.networkManager, connection.get(), device,
633- // // maxFail, holdoff);
634- // // }
635- // }
579+ this .modemManager .modemTaskHandler (deviceId , this .modemManager , this .networkManager , connection .get (),
580+ device , properties );
636581
637582 } else {
638- boolean activationSucceeded = true ;
639583 try {
640- // this.modemManager.failedModemResetTimerCancel(deviceId);
641- // // this.modemManager.modemConnectionTaskCancel(deviceId);
642- // this.modemManager.connectionHandlersDisable(deviceId);
643584 this .networkManager .activateConnection (connection .get (), device );
644585 dsLock .waitForSignal ();
645586 } catch (DBusExecutionException e ) {
646587 logger .warn ("Couldn't complete activation of {} interface, caused by:" , deviceId , e );
647- activationSucceeded = false ;
648588 }
649589 }
650590
@@ -656,48 +596,6 @@ private void enableInterface(String deviceId, NetworkProperties properties, Devi
656596 }
657597 }
658598
659- // if (deviceType == NMDeviceType.NM_DEVICE_TYPE_MODEM) { // add checks for reset and autoconnect
660- // int delayMinutes = properties.get(Integer.class, "net.interface.%s.config.resetTimeout", deviceId);
661- // Optional<String> mmDbusPath = this.networkManager.getModemManagerDbusPath(device.getObjectPath());
662- //
663- // if (delayMinutes == 0 || !mmDbusPath.isPresent()) {
664- // return;
665- // }
666- //
667- // this.modemManager.resetHandlerEnable(deviceId, mmDbusPath, delayMinutes, device.getObjectPath());
668- //
669- // boolean autoconnect = properties.get(Boolean.class, "net.interface.%s.config.persist", deviceId);
670- // int holdoff = properties.get(Integer.class, "net.interface.%s.config.holdoff", deviceId);
671- // int maxFail = properties.get(Integer.class, "net.interface.%s.config.maxFail", deviceId);
672- //
673- // if (autoconnect) {
674- // logger.info("Modem {} configured for autoconnect. Starting connection task...", deviceId);
675- // this.modemManager.modemConnectionTask(deviceId, this.networkManager, connection.get(), device, maxFail,
676- // holdoff);
677- // }
678- //
679- // // If a modem connection fails at the first try, it stays in the failed state, thus not triggering the usual
680- // // modem reset procedure. So, start a reset timer here.
681- // if (!activationSucceeded && isModemFailed(mmDbusPath.get())) {
682- // logger.info("Modem {} in failed state or unavailable. Scheduling modem reset in {} minutes ...",
683- // device.getObjectPath(), delayMinutes);
684- //
685- // this.modemManager.failedModemResetTimerSchedule(deviceId, mmDbusPath, delayMinutes);
686- //
687- // // if (autoconnect) {
688- // // logger.info("Modem {} configured for autoconnect. Starting connection task...", deviceId);
689- // // this.modemManager.modemConnectionTask(deviceId, this.networkManager, connection.get(), device,
690- // // maxFail, holdoff);
691- // // }
692- // }
693- //
694- // }
695-
696- }
697-
698- private boolean isModemFailed (String mmDbusPath ) throws DBusException {
699- MMModemState modemState = this .modemManager .getMMModemState (mmDbusPath );
700- return MMModemState .MM_MODEM_STATE_FAILED .equals (modemState );
701599 }
702600
703601 private void createVirtualInterface (String deviceId , NetworkProperties properties , NMDeviceType deviceType )
@@ -761,8 +659,7 @@ private void disable(Optional<Device> optDevice, String deviceId) throws DBusExc
761659 logger .warn ("Can't disable missing device {}" , deviceId );
762660 return ;
763661 }
764- this .modemManager .failedModemResetTimerCancel (deviceId );
765- this .modemManager .modemConnectionTaskCancel (deviceId );
662+ this .modemManager .modemTaskHandlerDisable (deviceId );
766663 Device device = optDevice .get ();
767664 Optional <Connection > appliedConnection = this .networkManager .getAppliedConnection (device );
768665
0 commit comments