From 6eece441938c13f18804ee1ddabc3044d6913d2c Mon Sep 17 00:00:00 2001 From: Miguel Matey Sanz Date: Tue, 30 Aug 2022 10:54:31 +0200 Subject: [PATCH 1/3] feat: add missing properties to location sample --- .../record-messaging-service.android.spec.ts | 10 ++++++- .../record-messaging-service.android.ts | 26 ++++++++++++------- src/internal/sensors/location/sample.ts | 4 +++ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/demo/app/tests/internal/sensors/location/record-messaging-service.android.spec.ts b/demo/app/tests/internal/sensors/location/record-messaging-service.android.spec.ts index 91b74f9..cfb5443 100644 --- a/demo/app/tests/internal/sensors/location/record-messaging-service.android.spec.ts +++ b/demo/app/tests/internal/sensors/location/record-messaging-service.android.spec.ts @@ -37,11 +37,15 @@ function getFakeLocationData() { latitude: 39.9939752904, longitude: -0.0741332084749, altitude: 20, + verticalAccuracy: 10, + horizontalAccuracy: 10, + speed: 0, + direction: 90 }; } function buildFakeEncodedMessage(expectedSamples: LocationSensorSample[]) { - const bytes = Array.create("byte", (4 + (32) * expectedSamples.length)); + const bytes = Array.create("byte", (4 + (32 + 16) * expectedSamples.length)); // Int + (4 * Double + 4 * Float) * Size for (let i = 0; i < bytes.length; i++) { bytes[i] = 0; } @@ -51,6 +55,10 @@ function buildFakeEncodedMessage(expectedSamples: LocationSensorSample[]) { buff.putDouble(sample.latitude); buff.putDouble(sample.longitude); buff.putDouble(sample.altitude); + buff.putFloat(sample.verticalAccuracy); + buff.putFloat(sample.horizontalAccuracy); + buff.putFloat(sample.speed); + buff.putFloat(sample.direction); buff.putLong(sample.timestamp); }) diff --git a/src/internal/sensors/location/android/record-messaging-service.android.ts b/src/internal/sensors/location/android/record-messaging-service.android.ts index 910e086..de6375f 100644 --- a/src/internal/sensors/location/android/record-messaging-service.android.ts +++ b/src/internal/sensors/location/android/record-messaging-service.android.ts @@ -17,20 +17,28 @@ export class LocationRecordMessagingService extends AbstractRecordMessagingServi decodeSamples(messageEvent: wearOS.MessageEvent): SensorRecord { const buff = ByteBuffer.wrap(messageEvent.getData()); const size = buff.getInt(); - let lat, lon, alt, time; + let timestamp, latitude, longitude, altitude, verticalAccuracy, horizontalAccuracy, speed, direction; const samples: LocationSensorSample[] = []; for (let i = 0; i < size; i++) { - lat = buff.getDouble(); - lon = buff.getDouble(); - alt = buff.getDouble(); - time = buff.getLong(); + latitude = buff.getDouble(); + longitude = buff.getDouble(); + altitude = buff.getDouble(); + verticalAccuracy = buff.getFloat(); + horizontalAccuracy = buff.getFloat(); + speed = buff.getFloat(); + direction = buff.getFloat(); + timestamp = buff.getLong(); samples.push({ - timestamp: time, - latitude: lat, - longitude: lon, - altitude: alt, + timestamp, + latitude, + longitude, + altitude, + verticalAccuracy, + horizontalAccuracy, + speed, + direction }); } diff --git a/src/internal/sensors/location/sample.ts b/src/internal/sensors/location/sample.ts index 4bcd7a8..eda6535 100644 --- a/src/internal/sensors/location/sample.ts +++ b/src/internal/sensors/location/sample.ts @@ -4,4 +4,8 @@ export interface LocationSensorSample extends SensorSample { latitude: number; longitude: number; altitude: number; + verticalAccuracy: number; + horizontalAccuracy: number; + speed: number; + direction: number; } From 55b28b8c87a6001a8868cc31d2eee22210a51198 Mon Sep 17 00:00:00 2001 From: Miguel Matey Sanz Date: Tue, 30 Aug 2022 10:54:58 +0200 Subject: [PATCH 2/3] docs: update readme --- README.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 89d6c1f..e881c50 100644 --- a/README.md +++ b/README.md @@ -365,11 +365,16 @@ export const defaultConfig = { #### [`LocationSensorSample`](src/internal/sensors/location/sample.ts) -| Property | Type | Description | -|-------------|-----------|---------------------------------| -| `latitude` | `number` | Latitude coordinate component. | -| `longitude` | `number` | Longitude coordinate component. | -| `altitude` | `number` | Altitude coordinate component. | +| Property | Type | Description | +|----------------------|----------|--------------------------------------------------------------| +| `latitude` | `number` | Latitude coordinate component. | +| `longitude` | `number` | Longitude coordinate component. | +| `altitude` | `number` | Altitude coordinate component. | +| `verticalAccuracy` | `number` | Estimated error in the latitude. | +| `horizontalAccuracy` | `number` | Estimated error in the longitude. | +| `speed` | `number` | Estimated device's speed when the location was acquired. | +| `direction` | `number` | Estimated device's direction when the location was acquired. | + ### [`PlainMessageClient`](src/internal/communication/plain-message/android/plain-message-client.android.ts) From f81c909b5ef23e104bb7d706dff91b99c8c874d7 Mon Sep 17 00:00:00 2001 From: Miguel Matey Sanz Date: Tue, 30 Aug 2022 10:56:02 +0200 Subject: [PATCH 3/3] chore: bump minor --- src/package-lock.json | 4 ++-- src/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/package-lock.json b/src/package-lock.json index ec28b5d..ff7e6e3 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -1,12 +1,12 @@ { "name": "nativescript-wearos-sensors", - "version": "1.1.0", + "version": "1.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "nativescript-wearos-sensors", - "version": "1.1.0", + "version": "1.2.0", "license": "Apache-2.0", "dependencies": { "rxjs": "^7.5.5" diff --git a/src/package.json b/src/package.json index da0e758..dacb46f 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-wearos-sensors", - "version": "1.1.0", + "version": "1.2.0", "description": "Plugin to develop smartphone apps that receive sensors' data from a paired WearOS smartwatch.", "main": "wearos-sensors", "typings": "index.d.ts",