Skip to content

Commit

Permalink
Merge pull request #3 from AlfredoSystems/battery+timeout
Browse files Browse the repository at this point in the history
Battery+timeout
  • Loading branch information
SaintSampo authored Oct 3, 2024
2 parents e4e8597 + bd0fa0f commit 4419f79
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,21 @@ function createBleAgent() {
server = await device.gatt.connect();
service = await server.getPrimaryService(SERVICE_UUID_PESTOBLE);
characteristic_gamepad = await service.getCharacteristic(CHARACTERISTIC_UUID_GAMEPAD);

try{
characteristic_battery = await service.getCharacteristic(CHARACTERISTIC_UUID_TELEMETRY);
await characteristic_battery.startNotifications()
await characteristic_battery.addEventListener('characteristicvaluechanged', handleBatteryCharacteristic);
}catch{
console.log("Pestolink version on robot is real old :(")
}

await device.addEventListener('gattserverdisconnected', robotDisconnect);

displayBleStatus('Connected');
isConnectedBLE = true;
buttonBLE.innerHTML = '❌';
displayBleStatus('Connected', '#4dae50'); //green


} catch (error) {
displayBleStatus("Error");
Expand Down
1 change: 1 addition & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ body {
background: grey;
border-radius: 50%;
user-select: none;
-webkit-user-select: none;
cursor: pointer;
height: 13vw;
width: 13vw;
Expand Down

0 comments on commit 4419f79

Please sign in to comment.