Skip to content

Commit

Permalink
Merge pull request #892 from Dygmalab/fixRaiseBootloaderAccess
Browse files Browse the repository at this point in the history
fix: Raise bootloader mode was not accesible from Bazecor 1.4.X onwards
  • Loading branch information
alexpargon committed Sep 24, 2024
2 parents 736329d + 6fe447c commit 31216d9
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 126 deletions.
18 changes: 18 additions & 0 deletions src/api/comms/serial/SerialAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ const enumerate = async (
for (const device of serialDevices) {
const vID = parseInt(`0x${device.vendorId}`, 16);
const pID = parseInt(`0x${device.productId}`, 16);
const Bdevice = Hardware.bootloader.find(h => h.usb.productId === pID && h.usb.vendorId === vID);
if (Bdevice) {
// Special treatment for Raise Bootloader
const newPort: ExtendedPort = { ...device, device: { ...Bdevice } };
log.info("Detected Bootloader: ", newPort, Bdevice, true);
foundDevices.push(newPort);
// eslint-disable-next-line no-continue
continue;
}
if (vID === searchDevice.vendorId && pID === searchDevice.productId && !existingIDs.includes(device.serialNumber)) {
const supported = await checkProperties(device.path);
const Hdevice = Hardware.serial.find(
Expand All @@ -154,6 +163,15 @@ const enumerate = async (
for (const device of serialDevices) {
const vID = parseInt(`0x${device.vendorId}`, 16);
const pID = parseInt(`0x${device.productId}`, 16);
const Bdevice = Hardware.bootloader.find(h => h.usb.productId === pID && h.usb.vendorId === vID);
if (Bdevice) {
// Special treatment for Raise Bootloader
const newPort: ExtendedPort = { ...device, device: { ...Bdevice } };
log.info("Detected Bootloader: ", newPort, Bdevice, true);
foundDevices.push(newPort);
// eslint-disable-next-line no-continue
continue;
}
if ([0x35ef, 0x1209].includes(vID) && !existingIDs.includes(device.serialNumber.toLowerCase())) {
const supported = await checkProperties(device.path);
const Hdevice = Hardware.serial.find(
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/modules/DeviceManager/CardDevice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ const CardDevice = forwardRef<HTMLDivElement, CardDeviceProps>((props, ref) => {
</>
) : (
<Heading headingLevel={3} renderAs="h3" className="text-gray-600 dark:text-gray-50">
{device.device?.device?.info?.displayName}
{device.device?.device?.bootloader === true
? `${device.device?.device?.info?.vendor} ${device.device?.device?.info?.product} Bootloader`
: device.device?.device?.info?.displayName}
</Heading>
)}
{device.file ? (
Expand Down
13 changes: 9 additions & 4 deletions src/renderer/views/DeviceManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const DeviceManager = (props: DeviceManagerProps) => {

const handleOnDisconnect = async () => {
setScanned(false);
const cID = state.currentDevice.serialNumber.toLowerCase();
const cID = state.currentDevice.serialNumber?.toLowerCase();
await DeviceTools.disconnect(state.currentDevice);
dispatch({ type: "disconnect", payload: [cID] });
setDevicesList([]);
Expand All @@ -107,17 +107,22 @@ const DeviceManager = (props: DeviceManagerProps) => {
setLoading(true);
if (connected || state.deviceList?.length > 0) {
const toShowDevs: DeviceListType[] = [];
const existingIDs = state.deviceList.map(d => d.serialNumber.toLowerCase());
const existingIDs = state.deviceList.map(d => d.serialNumber?.toLowerCase());
const result = await DeviceTools.listNonConnected(false, existingIDs);
let newDeviceList = state.deviceList.filter(
x => !result.devicesToRemove.includes(x.serialNumber.toLowerCase()) || x.type === "virtual",
x => !result.devicesToRemove.includes(x.serialNumber?.toLowerCase()) || x.type === "virtual",
);
newDeviceList = newDeviceList.concat(result.finalDevices);
newDeviceList = newDeviceList.map((dev, i) => {
const localDev = dev;
localDev.serialNumber = dev.serialNumber !== undefined ? dev.serialNumber : `RaiseBootloader${i}`;
return localDev;
});
dispatch({ type: "addDevicesList", payload: newDeviceList });
log.info("Available Devices: ", newDeviceList);
newDeviceList.forEach((item, index) => {
const neurons = store.get("neurons") as Neuron[];
const neuron = neurons.find(n => n.id.toLowerCase() === item.device?.chipId?.toLowerCase());
const neuron = neurons.find(n => n.id?.toLowerCase() === item.device?.chipId?.toLowerCase());
toShowDevs.push({
name: neuron?.name ? neuron.name : "",
available: true,
Expand Down
167 changes: 46 additions & 121 deletions src/renderer/views/Welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

import React from "react";
import Styled from "styled-components";
import { toast } from "react-toastify";

import { Card, CardContent, CardFooter, CardHeader, CardTitle } from "@Renderer/components/atoms/Card";
Expand All @@ -32,78 +31,6 @@ import { Button } from "@Renderer/components/atoms/Button";
import { IconKeyboard, IconFloppyDisk } from "@Renderer/components/atoms/icons";
import { DygmaDeviceType } from "@Renderer/types/dygmaDefs";

const Styles = Styled.div`
height: inherit;
.main-container {
overflow: hidden;
height: 100vh;
}
.welcome {
height: 100%;
display: flex;
flex-wrap: wrap;
justify-content: center;
&.center-content {
height: 100vh;
}
}
.welcomeInner {
max-width: 960px;
width: 100%;
margin: auto;
}
.disclaimerContent {
font-size: 15px;
margin-top: 32px;
line-height: 1.5em;
font-weight: 500;
}
.card {
padding: 0;
}
.card-header {
padding: 24px 32px;
background-color: transparent;
}
.card-body {
padding: 24px 32px;
font-size: 14px;
font-weight: 401;
border-radius: 16px;
h3 {
margin-bottom: 16px;
}
ul {
margin: 0;
}
a {
color: ${({ theme }) => theme.styles.dropdown.dropdownMenu.linkColor};
}
}
.card-footer {
padding: 24px 32px;
border: none;
background-color: ${({ theme }) => theme.styles.standardView.footerBackground};
}
.firmwareButton {
display: flex;
justify-content: flex-end;
grid-gap: 8px;
}
.keyboardSelected {
display: flex;
grid-gap: 16px;
align-items: center;
justify-content: space-between;
h6 {
opacity: 0.6;
margin: 0;
}
}
`;

interface WelcomeProps {
onConnect: (currentDevice: unknown, file: null) => void;
device: DygmaDeviceType;
Expand Down Expand Up @@ -152,57 +79,55 @@ function Welcome(props: WelcomeProps) {
};

return (
<Styles>
<div className="welcome center-content w-full justify-center px-3">
<PageHeader text={i18n.welcome.title} />
<div className="welcomeWrapper">
<div className="welcomeInner">
<Card className="welcomeCard">
<CardHeader>
<CardTitle className="keyboardSelected">
{showDeviceName()}
<div className="icon">
<IconKeyboard />
</div>
</CardTitle>
</CardHeader>
<CardContent>
<div>
<Heading headingLevel={3} renderAs="h3" variant="warning">
{i18n.welcome.bootloaderTitle}
</Heading>
<p>{i18n.welcome.description}</p>

<span className="cardsub">
<ul style={{ lineHeight: "2rem" }}>
<li>This process will revert your keyboard&apos;s configuration back to factory settings.</li>
<li>
{"Before proceeding, we recommend that you "}
<a href="https://support.dygma.com/hc/en-us/articles/360014262298">export and save your layers</a>.
</li>
<li>To exit Bootloader Mode, unplug and replug the USB-C cable to your Neuron.</li>
</ul>
</span>
</div>
</CardContent>
<CardFooter>
<div className="firmwareButton">
{reconnectButton}
<Button
onClick={async () => {
navigate("/firmware-update");
}}
variant="primary"
>
{i18n.welcome.gotoUpdate}
</Button>
<div className="h-full w-full overflow-hidden justify-center px-3">
<PageHeader text={i18n.welcome.title} />
<div className="flex flex-col items-center justify-center h-4/5">
<div className="welcomeInner">
<Card className="welcomeCard">
<CardHeader className="p-6 pb-0">
<CardTitle className="keyboardSelected justify-between">
{showDeviceName()}
<div className="icon">
<IconKeyboard />
</div>
</CardFooter>
</Card>
</div>
</CardTitle>
</CardHeader>
<CardContent className="p-6">
<div>
<Heading headingLevel={3} renderAs="h3" variant="warning">
{i18n.welcome.bootloaderTitle}
</Heading>
<p>{i18n.welcome.description}</p>

<span className="cardsub">
<ul style={{ lineHeight: "2rem" }}>
<li>This process will revert your keyboard&apos;s configuration back to factory settings.</li>
<li>
{"Before proceeding, we recommend that you "}
<a href="https://support.dygma.com/hc/en-us/articles/360014262298">export and save your layers</a>.
</li>
<li>To exit Bootloader Mode, unplug and replug the USB-C cable to your Neuron.</li>
</ul>
</span>
</div>
</CardContent>
<CardFooter>
<div className="firmwareButton w-full flex justify-between">
{reconnectButton}
<Button
onClick={async () => {
navigate("/firmware-update");
}}
variant="primary"
>
{i18n.welcome.gotoUpdate}
</Button>
</div>
</CardFooter>
</Card>
</div>
</div>
</Styles>
</div>
);
}

Expand Down

0 comments on commit 31216d9

Please sign in to comment.