Skip to content

Commit

Permalink
feat(web2): separation between wlan channel configuration and status (#…
Browse files Browse the repository at this point in the history
…5140)

* feat(web2): separation between wlan channel configuration and status

Signed-off-by: SimoneFiorani <[email protected]>

* feat(web2): updated with suggestions

Signed-off-by: SimoneFiorani <[email protected]>

* feat(web2): updated messages

Signed-off-by: SimoneFiorani <[email protected]>

---------

Signed-off-by: SimoneFiorani <[email protected]>
  • Loading branch information
sfiorani authored Feb 21, 2024
1 parent 94341de commit fad4584
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ interface TabHardwareUiUiBinder extends UiBinder<Widget, TabHardwareUi> {
FormLabel labelUsb;
@UiField
FormLabel labelRssi;
@UiField
FormLabel labelChannel;

@UiField
FormControlStatic state;
Expand All @@ -80,6 +82,8 @@ interface TabHardwareUiUiBinder extends UiBinder<Widget, TabHardwareUi> {
FormControlStatic usb;
@UiField
FormControlStatic rssi;
@UiField
FormControlStatic channel;

public TabHardwareUi(GwtSession currentSession) {
initWidget(uiBinder.createAndBindUi(this));
Expand All @@ -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
Expand Down Expand Up @@ -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() {
Expand All @@ -162,6 +168,7 @@ private void reset() {
this.mtu.setText("");
this.usb.setText("");
this.rssi.setText("");
this.channel.setText("");
}

@Override
Expand All @@ -180,6 +187,7 @@ public void getUpdatedNetInterface(GwtNetInterfaceConfig updatedNetIf) {
}
updatedNetIf.setHwUsbDevice(this.usb.getText());
updatedNetIf.setHwRssi(this.rssi.getText());
updatedNetIf.setCurrentHwWifiChannel(this.channel.getText());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@
<b:FormControlStatic
b:id="state" ui:field="rssi" />
</b:FormGroup>
<b:FormGroup>
<b:FormLabel for="state"
ui:field="labelChannel" />
<b:FormControlStatic
b:id="state" ui:field="channel" />
</b:FormGroup>
</b:FieldSet>
</b:Form>
</b:Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -368,7 +367,7 @@ public TabWirelessUi(GwtSession currentSession, TabIp4Ui tcp4, TabIp6Ui tcp6,

update();
});

this.tcp6Tab.status.addChangeHandler(event -> {
evalActiveConfig();

Expand All @@ -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();
Expand Down Expand Up @@ -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<Integer> channels = config.getChannels();

if (channels != null && !channels.isEmpty()) {
channelToSelect = config.getChannels().get(0);
loadCountryCode();
}

this.channelList.setSelectedIndex(getChannelIndexFromValue(channelToSelect));

}

@Override
Expand Down Expand Up @@ -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++) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1814,34 +1794,37 @@ public void onFailure(Throwable caught) {
@Override
public void onSuccess(List<GwtWifiChannelFrequency> freqChannels) {

TabWirelessUi.this.channelList.clear();

addAutomaticChannel(freqChannels);
updateChannelListValues(freqChannels);

freqChannels.stream().forEach(TabWirelessUi.this::addItemChannelList);
}
});
}
});
}

List<Integer> currentChannels = TabWirelessUi.this.activeConfig.getChannels();
}

if (currentChannels != null && !currentChannels.isEmpty()) {
int channel = TabWirelessUi.this.activeConfig.getChannels().get(0);
private void updateChannelListValues(List<GwtWifiChannelFrequency> 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<GwtWifiChannelFrequency> freqs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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();
Expand All @@ -364,32 +378,6 @@ private void setWifiMasterStateProperties(GwtWifiNetInterfaceConfig gwtWifiNetIn
gwtConfig.setChannels(channelsBuilder.getChannelsIntegers());
}

private void setWifiInfraStateProperties(GwtWifiNetInterfaceConfig gwtWifiNetInterfaceConfig,
WifiInterfaceStatus wifiInterfaceInfo) {
AtomicReference<String> 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<Integer> 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<WifiSecurity> supportedSecurity) {
boolean isGroupCCMP = supportedSecurity.contains(WifiSecurity.GROUP_CCMP);
boolean isGroupTKIP = supportedSecurity.contains(WifiSecurity.GROUP_TKIP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ netHwFirmware=ファームウェア
netHwMTU=MTU
netHwUSBDevice=USBデバイス
netHwSignalStrength=受信したシグナル強度(dBm)
netCurrentHwWifiChannel=現在の Wlan チャネル

netStatusWarning=WANとして環境設定された他のインターフェースが存在します。洗濯されたインターフェースをWANにする前に、そちらをLANに変更することが推奨されます。複数のインターフェースをWAN設定にすることは推奨されていません。
netRouter=DHCPv4とNAT
Expand Down

0 comments on commit fad4584

Please sign in to comment.