firmware: add windows BLE hacks

This works around some issues that have been observed on a specific
Windows computer.

Issue: https://github.com/pybricks/support/issues/256
This commit is contained in:
David Lechner
2021-05-16 16:18:34 -05:00
parent b001748f95
commit 956b6f3c96
7 changed files with 63 additions and 19 deletions
+12 -1
View File
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2021 The Pybricks Authors
import { isMacOS, prefersDarkMode } from './os';
import { isMacOS, isWindows, prefersDarkMode } from './os';
describe('isMacOS', () => {
test('is true', () => {
@@ -14,6 +14,17 @@ describe('isMacOS', () => {
});
});
describe('isWindows', () => {
test('is true', () => {
jest.spyOn(navigator, 'platform', 'get').mockReturnValue('Win32');
expect(isWindows()).toBeTruthy();
});
test('is false', () => {
jest.spyOn(navigator, 'platform', 'get').mockReturnValue('MacIntel');
expect(isWindows()).toBeFalsy();
});
});
describe('prefersDarkMode', () => {
test('is true', () => {
window.matchMedia = jest.fn().mockReturnValue({
+8
View File
@@ -11,6 +11,14 @@ export function isMacOS(): boolean {
return /mac/i.test(navigator.platform);
}
/**
* Tests if we are running on Windows.
* @returns `true` if running on Windows, otherwise `false`.
*/
export function isWindows(): boolean {
return /win/i.test(navigator.platform);
}
/**
* Tests if the OS is set to dark mode.
* @returns: `true` if dark mode should be preferred, otherwise `false`.