Skip to content

Commit

Permalink
Minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
breiler committed Dec 22, 2024
1 parent 6d1058c commit 7f09516
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 88 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@xterm/xterm": "^5.5.0",
"bootstrap": "^5.3.0",
"crypto-js": "^4.2.0",
"esptool-js": "^0.4.7",
"esptool-js": "^0.5.3",
"firebase": "^10.6.0",
"js-yaml": "^4.1.0",
"react": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/pages/filebrowser/FileBrowser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ const FileBrowser = () => {
return;
}

await controllerService.write(Buffer.from([0x0c])); // CTRL-L Restting echo mode
setIsLoading(true);
await controllerService.write(Buffer.from([0x0c])); // CTRL-L Restting echo mode
await refreshFileList();

setConfigFilename(
Expand Down
166 changes: 87 additions & 79 deletions src/pages/wifisettings/WiFiSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,86 +134,94 @@ const WiFiSettings = () => {
};

const saveSettings = async () => {
if (hostname !== settings?.hostname) {
await controllerService?.send(new Command("$Hostname=" + hostname));
}

if (wifiMode !== settings?.wifiMode) {
await controllerService?.send(
new Command("$WiFi/Mode=" + wifiMode)
);
}

if (stationSSID !== settings?.stationSSID) {
await controllerService?.send(
new Command("$Sta/SSID=" + stationSSID)
);
}

if (stationIpMode !== settings?.stationIpMode) {
await controllerService?.send(
new Command("$Sta/IPMode=" + stationIpMode)
);
}

if (stationPassword !== settings?.stationPassword) {
await controllerService?.send(
new Command(
"$Sta/Password=" + encodePassword(stationPassword ?? "")
)
);
}

if (stationMinSecurity !== settings?.stationMinSecurity) {
await controllerService?.send(
new Command("$Sta/MinSecurity=" + stationMinSecurity)
);
}

if (stationIP !== settings?.stationIP) {
await controllerService?.send(new Command("$Sta/IP=" + stationIP));
}

if (stationGateway !== settings?.stationGateway) {
await controllerService?.send(
new Command("$Sta/Gateway=" + stationGateway)
);
}

if (stationNetmask !== settings?.stationNetmask) {
await controllerService?.send(
new Command("$Sta/Netmask=" + stationNetmask)
);
}

if (apSSID !== settings?.apSSID) {
await controllerService?.send(new Command("$AP/SSID=" + apSSID));
}

if (apPassword !== settings?.apPassword) {
await controllerService?.send(
new Command("$AP/Password=" + encodePassword(apPassword ?? ""))
);
}

if (apChannel !== settings?.apChannel) {
await controllerService?.send(
new Command("$AP/Channel=" + apChannel)
);
}

if (apIP !== settings?.apIP) {
await controllerService?.send(new Command("$AP/IP=" + apIP));
}

if (apCountry !== settings?.apCountry) {
await controllerService?.send(
new Command("$AP/Country=" + apCountry)
);
}

setIsSaving(true);
try {
setIsSaving(true);
if (hostname !== settings?.hostname) {
await controllerService?.send(
new Command("$Hostname=" + hostname)
);
}

if (wifiMode !== settings?.wifiMode) {
await controllerService?.send(
new Command("$WiFi/Mode=" + wifiMode)
);
}

if (stationSSID !== settings?.stationSSID) {
await controllerService?.send(
new Command("$Sta/SSID=" + stationSSID)
);
}

if (stationIpMode !== settings?.stationIpMode) {
await controllerService?.send(
new Command("$Sta/IPMode=" + stationIpMode)
);
}

if (stationPassword !== settings?.stationPassword) {
await controllerService?.send(
new Command(
"$Sta/Password=" + encodePassword(stationPassword ?? "")
)
);
}

if (stationMinSecurity !== settings?.stationMinSecurity) {
await controllerService?.send(
new Command("$Sta/MinSecurity=" + stationMinSecurity)
);
}

if (stationIP !== settings?.stationIP) {
await controllerService?.send(
new Command("$Sta/IP=" + stationIP)
);
}

if (stationGateway !== settings?.stationGateway) {
await controllerService?.send(
new Command("$Sta/Gateway=" + stationGateway)
);
}

if (stationNetmask !== settings?.stationNetmask) {
await controllerService?.send(
new Command("$Sta/Netmask=" + stationNetmask)
);
}

if (apSSID !== settings?.apSSID) {
await controllerService?.send(
new Command("$AP/SSID=" + apSSID)
);
}

if (apPassword !== settings?.apPassword) {
await controllerService?.send(
new Command(
"$AP/Password=" + encodePassword(apPassword ?? "")
)
);
}

if (apChannel !== settings?.apChannel) {
await controllerService?.send(
new Command("$AP/Channel=" + apChannel)
);
}

if (apIP !== settings?.apIP) {
await controllerService?.send(new Command("$AP/IP=" + apIP));
}

if (apCountry !== settings?.apCountry) {
await controllerService?.send(
new Command("$AP/Country=" + apCountry)
);
}

await controllerService?.hardReset();
await refresh();
} finally {
Expand Down
11 changes: 11 additions & 0 deletions src/utils/serialport/SerialPort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export class SerialPort {
private readers: SerialReader[] = [];
private reader: ReadableStreamDefaultReader<Uint8Array>;
private deviceInfo: DeviceInfo;
private dtrState: boolean = false;

constructor(serialPort: NativeSerialPort) {
this.serialPort = serialPort;
Expand Down Expand Up @@ -155,9 +156,15 @@ export class SerialPort {
};

async setDTR(enabled: boolean) {
this.dtrState = enabled;
await this.serialPort.setSignals({ dataTerminalReady: enabled });
}

async setRTS(enabled: boolean) {
await this.serialPort.setSignals({ requestToSend: enabled });
this.setDTR(this.dtrState);
}

open = async (baudRate = 115200): Promise<void> => {
if (this.state === SerialPortState.DISCONNECTING) {
await new Promise((r) => setTimeout(r, 1000));
Expand Down Expand Up @@ -226,6 +233,10 @@ export class SerialPort {
}

try {
while (this.serialPort.writable.locked) {
await sleep(100);
}

const writer = this.serialPort.writable!.getWriter();
return writer.write(data).finally(() => {
writer.releaseLock();
Expand Down

0 comments on commit 7f09516

Please sign in to comment.