0.10: Fix cscsensor when using coospoo sensor that supports crank *and* wheel

pull/3428/head
Gordon Williams 2024-05-17 12:45:32 +01:00
parent a4c5e14ba9
commit 799da73129
3 changed files with 7 additions and 4 deletions

View File

@ -8,3 +8,4 @@
0.07: Make Bangle.js 2 compatible
0.08: Convert Yes/No On/Off in settings to checkboxes
0.09: Automatically reconnect on error
0.10: Fix cscsensor when using coospoo sensor that supports crank *and* wheel

View File

@ -160,7 +160,8 @@ class CSCSensor {
updateSensor(event) {
var qChanged = false;
if (event.target.uuid == "0x2a5b") {
if (event.target.value.getUint8(0, true) & 0x2) {
let flags = event.target.value.getUint8(0);
if (flags & 2) {
// crank revolution - if enabled
const crankRevs = event.target.value.getUint16(1, true);
const crankTime = event.target.value.getUint16(3, true);
@ -170,7 +171,8 @@ class CSCSensor {
}
this.lastCrankRevs = crankRevs;
this.lastCrankTime = crankTime;
} else {
}
if (flags & 1) {
// wheel revolution
var wheelRevs = event.target.value.getUint32(1, true);
var dRevs = (this.lastRevs>0 ? wheelRevs-this.lastRevs : 0);
@ -226,7 +228,7 @@ function getSensorBatteryLevel(gatt) {
function connection_setup() {
mySensor.screenInit = true;
E.showMessage("Scanning for CSC sensor...");
NRF.requestDevice({ filters: [{services:["1816"]}], maxInterval: 100}).then(function(d) {
NRF.requestDevice({ filters: [{services:["1816"]}]}).then(function(d) {
device = d;
E.showMessage("Found device");
return device.gatt.connect();

View File

@ -2,7 +2,7 @@
"id": "cscsensor",
"name": "Cycling speed sensor",
"shortName": "CSCSensor",
"version": "0.09",
"version": "0.10",
"description": "Read BLE enabled cycling speed and cadence sensor and display readings on watch",
"icon": "icons8-cycling-48.png",
"tags": "outdoors,exercise,ble,bluetooth,bike,cycle,bicycle",