mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-14 10:35:11 +00:00
ble: avoid aliases for UUID constants
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2020-2021 The Pybricks Authors
|
||||
// Copyright (c) 2020-2022 The Pybricks Authors
|
||||
|
||||
// Ref: https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#lego-hub-boot-loader-service
|
||||
|
||||
@@ -8,12 +8,12 @@ import { assert, hex } from '../utils';
|
||||
/**
|
||||
* LEGO Powered Up Bootloader Service UUID.
|
||||
*/
|
||||
export const ServiceUUID = '00001625-1212-efde-1623-785feabcd123';
|
||||
export const lwp3BootloaderServiceUUID = '00001625-1212-efde-1623-785feabcd123';
|
||||
|
||||
/**
|
||||
* LEGO Powered Up Bootloader Characteristic UUID.
|
||||
*/
|
||||
export const CharacteristicUUID = '00001626-1212-efde-1623-785feabcd123';
|
||||
export const lwp3BootloaderCharacteristicUUID = '00001626-1212-efde-1623-785feabcd123';
|
||||
|
||||
/**
|
||||
* The maximum message size that can be sent or received.
|
||||
|
||||
@@ -19,7 +19,10 @@ import {
|
||||
disconnect,
|
||||
send,
|
||||
} from './actions';
|
||||
import { CharacteristicUUID, ServiceUUID } from './protocol';
|
||||
import {
|
||||
lwp3BootloaderCharacteristicUUID,
|
||||
lwp3BootloaderServiceUUID,
|
||||
} from './protocol';
|
||||
|
||||
function* handleNotify(data: DataView): Generator {
|
||||
yield* put(didReceive(data));
|
||||
@@ -59,8 +62,8 @@ function* handleConnect(): Generator {
|
||||
try {
|
||||
device = yield* call(() =>
|
||||
navigator.bluetooth.requestDevice({
|
||||
filters: [{ services: [ServiceUUID] }],
|
||||
optionalServices: [ServiceUUID],
|
||||
filters: [{ services: [lwp3BootloaderServiceUUID] }],
|
||||
optionalServices: [lwp3BootloaderServiceUUID],
|
||||
}),
|
||||
);
|
||||
} catch (err) {
|
||||
@@ -98,7 +101,7 @@ function* handleConnect(): Generator {
|
||||
|
||||
let service: BluetoothRemoteGATTService;
|
||||
try {
|
||||
service = yield* call([server, 'getPrimaryService'], ServiceUUID);
|
||||
service = yield* call([server, 'getPrimaryService'], lwp3BootloaderServiceUUID);
|
||||
} catch (err) {
|
||||
server.disconnect();
|
||||
yield* takeMaybe(disconnectChannel);
|
||||
@@ -116,7 +119,7 @@ function* handleConnect(): Generator {
|
||||
try {
|
||||
characteristic = yield* call(
|
||||
[service, 'getCharacteristic'],
|
||||
CharacteristicUUID,
|
||||
lwp3BootloaderCharacteristicUUID,
|
||||
);
|
||||
} catch (err) {
|
||||
server.disconnect();
|
||||
|
||||
Reference in New Issue
Block a user