Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Serial Console Wifi Scan #930

Merged
merged 5 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gui/public/i18n/en/translation.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ settings-serial-factory_reset-warning-cancel = Cancel
settings-serial-get_infos = Get Infos
settings-serial-serial_select = Select a serial port
settings-serial-auto_dropdown_item = Auto
settings-serial-get_wifi_scan = Get WiFi Scan

## OSC router settings
settings-osc-router = OSC router
Expand Down
10 changes: 10 additions & 0 deletions gui/src/components/settings/pages/Serial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
SerialTrackerGetInfoRequestT,
SerialTrackerRebootRequestT,
SerialUpdateResponseT,
SerialTrackerGetWifiScanRequestT,
} from 'solarxr-protocol';
import { useElemSize, useLayout } from '@/hooks/layout';
import { useWebsocketAPI } from '@/hooks/websocket-api';
Expand Down Expand Up @@ -158,6 +159,12 @@ export function Serial() {
new SerialTrackerGetInfoRequestT()
);
};
const getWifiScan = () => {
sendRPCPacket(
RpcMessage.SerialTrackerGetWifiScanRequest,
new SerialTrackerGetWifiScanRequestT()
);
};

return (
<>
Expand Down Expand Up @@ -231,6 +238,9 @@ export function Serial() {
<Button variant="quaternary" onClick={getInfos}>
{l10n.getString('settings-serial-get_infos')}
</Button>
<Button variant="quaternary" onClick={getWifiScan}>
{l10n.getString('settings-serial-get_wifi_scan')}
</Button>
{isMobile && (
<Dropdown
control={control}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ class AndroidSerialHandler(val activity: AppCompatActivity) :
writeSerial("GET INFO")
}

override fun wifiScanRequest() {
writeSerial("GET WIFISCAN")
}

override fun closeSerial() {
try {
if (isConnected) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public RPCSerialHandler(RPCHandler rpcHandler, ProtocolAPI api) {
RpcMessage.SerialTrackerFactoryResetRequest,
this::onSerialTrackerFactoryResetRequest
);
rpcHandler
.registerPacketListener(
RpcMessage.SerialTrackerGetWifiScanRequest,
this::onSerialTrackerGetWifiScanRequest
);
ButterscotchV marked this conversation as resolved.
Show resolved Hide resolved
rpcHandler.registerPacketListener(RpcMessage.SetWifiRequest, this::onSetWifiRequest);
rpcHandler.registerPacketListener(RpcMessage.OpenSerialRequest, this::onOpenSerialRequest);
rpcHandler
Expand Down Expand Up @@ -158,6 +163,17 @@ public void onSerialTrackerFactoryResetRequest(
this.api.server.serialHandler.factoryResetRequest();
}

public void onSerialTrackerGetWifiScanRequest(
GenericConnection conn,
RpcMessageHeader messageHeader
) {
SerialTrackerGetWifiScanRequest req = (SerialTrackerGetWifiScanRequest) messageHeader
.message(new SerialTrackerGetWifiScanRequest());
if (req == null)
return;

this.api.server.serialHandler.wifiScanRequest();
}

private void onRequestSerialDevices(GenericConnection conn, RpcMessageHeader messageHeader) {
SerialDevicesRequest req = (SerialDevicesRequest) messageHeader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ abstract class SerialHandler {
abstract fun rebootRequest()
abstract fun factoryResetRequest()
abstract fun infoRequest()
abstract fun wifiScanRequest()
abstract fun closeSerial()
abstract fun setWifi(ssid: String, passwd: String)

Expand Down Expand Up @@ -62,6 +63,8 @@ class SerialHandlerStub() : SerialHandler() {

override fun infoRequest() {}

override fun wifiScanRequest() {}

override fun closeSerial() {}

override fun setWifi(ssid: String, passwd: String) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ class DesktopSerialHandler : SerialHandler(), SerialPortMessageListener {
writeSerial("GET INFO")
}

override fun wifiScanRequest() {
writeSerial("GET WIFISCAN")
}

@Synchronized
override fun closeSerial() {
try {
Expand Down
Loading