diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabHardwareUi.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabHardwareUi.java index 854acae5638..37d4e6d1671 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabHardwareUi.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabHardwareUi.java @@ -57,6 +57,8 @@ interface TabHardwareUiUiBinder extends UiBinder { FormLabel labelUsb; @UiField FormLabel labelRssi; + @UiField + FormLabel labelChannel; @UiField FormControlStatic state; @@ -80,6 +82,8 @@ interface TabHardwareUiUiBinder extends UiBinder { FormControlStatic usb; @UiField FormControlStatic rssi; + @UiField + FormControlStatic channel; public TabHardwareUi(GwtSession currentSession) { initWidget(uiBinder.createAndBindUi(this)); @@ -98,6 +102,7 @@ public TabHardwareUi(GwtSession currentSession) { this.labelMtu.setText(MSGS.netHwMTU()); this.labelUsb.setText(MSGS.netHwUSBDevice()); this.labelRssi.setText(MSGS.netHwSignalStrength()); + this.labelChannel.setText(MSGS.netCurrentHwWifiChannel()); } // Dirty flag not needed here since this tab is not modifiable @@ -148,6 +153,7 @@ private void loadData() { this.mtu.setText(String.valueOf(this.selectedNetIfConfig.getHwMTU())); this.usb.setText(this.selectedNetIfConfig.getHwUsbDevice()); this.rssi.setText(this.selectedNetIfConfig.getHwRssi()); + this.channel.setText(this.selectedNetIfConfig.getCurrentHwWifiChannel()); } private void reset() { @@ -162,6 +168,7 @@ private void reset() { this.mtu.setText(""); this.usb.setText(""); this.rssi.setText(""); + this.channel.setText(""); } @Override @@ -180,6 +187,7 @@ public void getUpdatedNetInterface(GwtNetInterfaceConfig updatedNetIf) { } updatedNetIf.setHwUsbDevice(this.usb.getText()); updatedNetIf.setHwRssi(this.rssi.getText()); + updatedNetIf.setCurrentHwWifiChannel(this.channel.getText()); } } } diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabHardwareUi.ui.xml b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabHardwareUi.ui.xml index 3ea46a3125e..5d7f49f2876 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabHardwareUi.ui.xml +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabHardwareUi.ui.xml @@ -112,6 +112,12 @@ + + + + diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabWirelessUi.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabWirelessUi.java index 34e3444a769..af6512a3872 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabWirelessUi.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabWirelessUi.java @@ -16,7 +16,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Objects; import java.util.logging.Logger; import org.eclipse.kura.web.client.messages.Messages; @@ -368,7 +367,7 @@ public TabWirelessUi(GwtSession currentSession, TabIp4Ui tcp4, TabIp6Ui tcp6, update(); }); - + this.tcp6Tab.status.addChangeHandler(event -> { evalActiveConfig(); @@ -387,7 +386,8 @@ private void evalActiveConfig() { || !tcpIp6Status.equals(TabWirelessUi.this.tcp6Status); if (isStatusChanged) { - if (tcpIp4Status.equals(MessageUtils.get(GwtNetIfStatus.netIPv4StatusEnabledWAN.name())) || tcpIp6Status.equals(MessageUtils.get(GwtNetIfStatus.netIPv4StatusEnabledWAN.name()))) { + if (tcpIp4Status.equals(MessageUtils.get(GwtNetIfStatus.netIPv4StatusEnabledWAN.name())) + || tcpIp6Status.equals(MessageUtils.get(GwtNetIfStatus.netIPv4StatusEnabledWAN.name()))) { TabWirelessUi.this.activeConfig = TabWirelessUi.this.selectedNetIfConfig.getStationWifiConfig(); } else { TabWirelessUi.this.activeConfig = TabWirelessUi.this.selectedNetIfConfig.getActiveWifiConfig(); @@ -460,27 +460,9 @@ public void setNetInterface(GwtNetInterfaceConfig config) { this.selectedNetIfConfig = (GwtWifiNetInterfaceConfig) config; this.activeConfig = this.selectedNetIfConfig.getActiveWifiConfig(); - if (Objects.nonNull(this.activeConfig)) { - if (this.activeConfig.getChannels() != null - && !TabWirelessUi.this.activeConfig.getChannels().isEmpty()) { - updateChanneList(TabWirelessUi.this.activeConfig); - } - } - loadCountryCode(); - } - } - - private void updateChanneList(GwtWifiConfig config) { - int channelToSelect = 0; - List channels = config.getChannels(); - - if (channels != null && !channels.isEmpty()) { - channelToSelect = config.getChannels().get(0); + loadCountryCode(); } - - this.channelList.setSelectedIndex(getChannelIndexFromValue(channelToSelect)); - } @Override @@ -560,9 +542,6 @@ private void setValues() { setRadioModeByValue(this.activeConfig.getRadioMode()); - // select proper channels - updateChanneList(this.activeConfig); - String activeSecurity = this.activeConfig.getSecurity(); if (activeSecurity != null) { for (int i = 0; i < this.security.getItemCount(); i++) { @@ -659,7 +638,8 @@ private void refreshForm() { String tcpip6Status = this.tcp6Tab.getStatus(); // Tcp/IP disabled - if (tcpip4Status.equals(GwtNetIfStatus.netIPv4StatusDisabled.name()) && tcpip6Status.equals(GwtNetIfStatus.netIPv4StatusDisabled.name())) { + if (tcpip4Status.equals(GwtNetIfStatus.netIPv4StatusDisabled.name()) + && tcpip6Status.equals(GwtNetIfStatus.netIPv4StatusDisabled.name())) { setForm(false); } else { setForm(true); @@ -1814,34 +1794,37 @@ public void onFailure(Throwable caught) { @Override public void onSuccess(List freqChannels) { - TabWirelessUi.this.channelList.clear(); - - addAutomaticChannel(freqChannels); + updateChannelListValues(freqChannels); - freqChannels.stream().forEach(TabWirelessUi.this::addItemChannelList); + } + }); + } + }); + } - List currentChannels = TabWirelessUi.this.activeConfig.getChannels(); + } - if (currentChannels != null && !currentChannels.isEmpty()) { - int channel = TabWirelessUi.this.activeConfig.getChannels().get(0); + private void updateChannelListValues(List freqChannels) { - int selectedChannelIndex = getChannelIndexFromValue(channel); - int channelIndex = selectedChannelIndex == -1 ? 0 : selectedChannelIndex; + int selectedChannelValue = 0; - TabWirelessUi.this.channelList.setSelectedIndex(channelIndex); + if (TabWirelessUi.this.channelList.getItemCount() != 0) { + selectedChannelValue = this.channelList.getSelectedIndex(); + } - } + this.channelList.clear(); - boolean hasChannels = TabWirelessUi.this.channelList.getItemCount() > 0; + addAutomaticChannel(freqChannels); + freqChannels.stream().forEach(this::addItemChannelList); - TabWirelessUi.this.noChannels.setVisible(!hasChannels); + if (this.activeConfig.getChannels() != null && !this.activeConfig.getChannels().isEmpty()) { + this.netTabs.hardwareTab.channel + .setText(this.channelList.getItemText(this.activeConfig.getChannels().get(0))); - } - }); - } - }); + this.channelList.setSelectedIndex(selectedChannelValue); } + this.noChannels.setVisible((this.channelList.getItemCount() <= 0)); } private void addAutomaticChannel(List freqs) { diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net2/status/NetworkStatusServiceAdapter.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net2/status/NetworkStatusServiceAdapter.java index e0021381053..d17a48fb3b5 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net2/status/NetworkStatusServiceAdapter.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/server/net2/status/NetworkStatusServiceAdapter.java @@ -332,22 +332,36 @@ private void setWifiStateProperties(GwtNetInterfaceConfig gwtNetInterfaceConfig, WifiInterfaceStatus wifiInterfaceInfo = (WifiInterfaceStatus) networkInterfaceInfo; gwtWifiNetInterfaceConfig.setHwState(wifiInterfaceInfo.getState().toString()); - if (wifiInterfaceInfo.getMode() == WifiMode.MASTER) { - setWifiMasterStateProperties(gwtWifiNetInterfaceConfig, wifiInterfaceInfo); - } else if (wifiInterfaceInfo.getMode() == WifiMode.INFRA) { - setWifiInfraStateProperties(gwtWifiNetInterfaceConfig, wifiInterfaceInfo); - } + setWifiSpecificStateProperties(wifiInterfaceInfo.getMode(), gwtWifiNetInterfaceConfig, wifiInterfaceInfo); } } - private void setWifiMasterStateProperties(GwtWifiNetInterfaceConfig gwtWifiNetInterfaceConfig, + private void setWifiSpecificStateProperties(WifiMode wifiMode, GwtWifiNetInterfaceConfig gwtWifiNetInterfaceConfig, WifiInterfaceStatus wifiInterfaceInfo) { + GwtWifiConfig gwtConfig; - if (Objects.nonNull(gwtWifiNetInterfaceConfig.getAccessPointWifiConfig())) { - gwtConfig = gwtWifiNetInterfaceConfig.getAccessPointWifiConfig(); + + if (wifiMode.equals(WifiMode.INFRA)) { + AtomicReference rssi = new AtomicReference<>("N/A"); + wifiInterfaceInfo.getActiveWifiAccessPoint() + .ifPresent(accessPoint -> rssi.set(String.valueOf(accessPoint.getSignalStrength()))); + gwtWifiNetInterfaceConfig.setHwRssi(rssi.get()); + + if (Objects.nonNull(gwtWifiNetInterfaceConfig.getStationWifiConfig())) { + gwtConfig = gwtWifiNetInterfaceConfig.getStationWifiConfig(); + } else { + gwtConfig = gwtWifiNetInterfaceConfig.getActiveWifiConfig(); + gwtWifiNetInterfaceConfig.setStationWifiConfig(gwtConfig); + } + } else { - gwtConfig = gwtWifiNetInterfaceConfig.getActiveWifiConfig(); - gwtWifiNetInterfaceConfig.setAccessPointWifiConfig(gwtConfig); + + if (Objects.nonNull(gwtWifiNetInterfaceConfig.getAccessPointWifiConfig())) { + gwtConfig = gwtWifiNetInterfaceConfig.getAccessPointWifiConfig(); + } else { + gwtConfig = gwtWifiNetInterfaceConfig.getActiveWifiConfig(); + gwtWifiNetInterfaceConfig.setAccessPointWifiConfig(gwtConfig); + } } ChannelsBuilder channelsBuilder = new ChannelsBuilder(); @@ -364,32 +378,6 @@ private void setWifiMasterStateProperties(GwtWifiNetInterfaceConfig gwtWifiNetIn gwtConfig.setChannels(channelsBuilder.getChannelsIntegers()); } - private void setWifiInfraStateProperties(GwtWifiNetInterfaceConfig gwtWifiNetInterfaceConfig, - WifiInterfaceStatus wifiInterfaceInfo) { - AtomicReference rssi = new AtomicReference<>("N/A"); - wifiInterfaceInfo.getActiveWifiAccessPoint() - .ifPresent(accessPoint -> rssi.set(String.valueOf(accessPoint.getSignalStrength()))); - gwtWifiNetInterfaceConfig.setHwRssi(rssi.get()); - - GwtWifiConfig gwtConfig; - - if (Objects.nonNull(gwtWifiNetInterfaceConfig.getStationWifiConfig())) { - gwtConfig = gwtWifiNetInterfaceConfig.getStationWifiConfig(); - } else { - gwtConfig = gwtWifiNetInterfaceConfig.getActiveWifiConfig(); - gwtWifiNetInterfaceConfig.setStationWifiConfig(gwtConfig); - } - - ChannelsBuilder channelsBuilder = new ChannelsBuilder(); - List activeChannel = gwtConfig.getChannels(); - if (activeChannel != null && activeChannel.size() == 1) { - channelsBuilder.setActiveChannel(activeChannel.get(0)); - } - channelsBuilder.addChannels(wifiInterfaceInfo.getChannels()); - - gwtConfig.setChannels(channelsBuilder.getChannelsIntegers()); - } - private void parseAndSetWifiSecurity(GwtWifiHotspotEntry entryToModify, Set supportedSecurity) { boolean isGroupCCMP = supportedSecurity.contains(WifiSecurity.GROUP_CCMP); boolean isGroupTKIP = supportedSecurity.contains(WifiSecurity.GROUP_TKIP); diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/model/GwtNetInterfaceConfig.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/model/GwtNetInterfaceConfig.java index 9cf9b1ea562..9c674dfaedf 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/model/GwtNetInterfaceConfig.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/shared/model/GwtNetInterfaceConfig.java @@ -239,6 +239,14 @@ public void setHwRssi(String rssi) { set("hwRssi", rssi); } + public String getCurrentHwWifiChannel() { + return get("currentHwWifiChannel"); + } + + public void setCurrentHwWifiChannel(String channel) { + set("currentHwWifiChannel", channel); + } + public GwtNetRouterMode getRouterModeEnum() { return GwtNetRouterMode.valueOf(getRouterMode()); } diff --git a/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages.properties b/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages.properties index 0184da7ed27..b3c82c374ab 100644 --- a/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages.properties +++ b/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages.properties @@ -562,6 +562,7 @@ netHwRadio=Radio netHwBand=Frequency Band netHwLAC=LAC netHwCI=CI +netCurrentHwWifiChannel=Current WLAN Channel netStatusWarning=There is another interface configured as WAN. That interface should bet set to LAN before changing the selected interface to WAN. Multiple WAN interfaces is not recommended. netRouter=DHCPv4 & NAT diff --git a/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages_ja.properties b/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages_ja.properties index 946a399f20f..e4052d2c858 100644 --- a/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages_ja.properties +++ b/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages_ja.properties @@ -538,6 +538,7 @@ netHwFirmware=ファームウェア netHwMTU=MTU netHwUSBDevice=USBデバイス netHwSignalStrength=受信したシグナル強度(dBm) +netCurrentHwWifiChannel=現在の Wlan チャネル netStatusWarning=WANとして環境設定された他のインターフェースが存在します。洗濯されたインターフェースをWANにする前に、そちらをLANに変更することが推奨されます。複数のインターフェースをWAN設定にすることは推奨されていません。 netRouter=DHCPv4とNAT