diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2015-06-29 21:37:58 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2015-06-29 21:37:58 +0200 |
commit | 21b5d60f6d0a4e3a26b8391bba9e78205b861bc6 (patch) | |
tree | 6d7b9ac052ce2192d397c9386f42a61d70d6fa46 | |
parent | 61bdbbdc3f81b89ce1679075664fe50012ccd78d (diff) | |
download | io.trygvis.soilmoisture-android-21b5d60f6d0a4e3a26b8391bba9e78205b861bc6.tar.gz io.trygvis.soilmoisture-android-21b5d60f6d0a4e3a26b8391bba9e78205b861bc6.tar.bz2 io.trygvis.soilmoisture-android-21b5d60f6d0a4e3a26b8391bba9e78205b861bc6.tar.xz io.trygvis.soilmoisture-android-21b5d60f6d0a4e3a26b8391bba9e78205b861bc6.zip |
o Using new code for GET_VALUE.
-rw-r--r-- | app/src/main/java/io/trygvis/soilmoisture/SmDevice.java | 10 | ||||
-rw-r--r-- | app/src/main/java/io/trygvis/soilmoisture/SoilMoistureService.java | 2 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 2 |
3 files changed, 10 insertions, 4 deletions
diff --git a/app/src/main/java/io/trygvis/soilmoisture/SmDevice.java b/app/src/main/java/io/trygvis/soilmoisture/SmDevice.java index 808cbb6..e114f3c 100644 --- a/app/src/main/java/io/trygvis/soilmoisture/SmDevice.java +++ b/app/src/main/java/io/trygvis/soilmoisture/SmDevice.java @@ -127,7 +127,9 @@ class SmDevice { if (c == GET_SENSOR_COUNT.code) { return (T) new GetSensorCountRes(bytes[1]); } else if (c == GET_VALUE.code) { - return (T) new GetValueRes((bytes[2] & 0xff) << 8 | (bytes[1] & 0xff)); + int sensor = bytes[1] & 0xff; + int value = (bytes[3] & 0xff) << 8 | (bytes[2] & 0xff); + return (T) new GetValueRes(sensor, value); } else if (c == SET_WARNING_VALUE.code) { } else if (c == GET_WARNING_VALUE.code) { } else if (c == SET_SENSOR_NAME.code) { @@ -147,9 +149,11 @@ class SmDevice { } public static class GetValueRes { + public final int sensor; public final int value; - public GetValueRes(int value) { + public GetValueRes(int sensor, int value) { + this.sensor = sensor; this.value = value; } } @@ -217,7 +221,7 @@ class SmDevice { public enum SmCmdCode { GET_SENSOR_COUNT(1), - GET_VALUE(2), + GET_VALUE(8), SET_WARNING_VALUE(3), GET_WARNING_VALUE(4), SET_SENSOR_NAME(5), diff --git a/app/src/main/java/io/trygvis/soilmoisture/SoilMoistureService.java b/app/src/main/java/io/trygvis/soilmoisture/SoilMoistureService.java index 352cba3..40f4262 100644 --- a/app/src/main/java/io/trygvis/soilmoisture/SoilMoistureService.java +++ b/app/src/main/java/io/trygvis/soilmoisture/SoilMoistureService.java @@ -21,7 +21,7 @@ public interface SoilMoistureService { void stopScanning(); - public abstract static class SoilMoistureListener extends BroadcastReceiver { + abstract class SoilMoistureListener extends BroadcastReceiver { public static final String INTENT_NAME = SoilMoistureListener.class.getName(); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 30ae8df..fb6658f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -40,5 +40,7 @@ <string name="title_activity_sensor">Sensor</string> <string name="value">Value</string> <string name="warning_value">Warning value</string> + <string name="title_sensor_list">Sensors</string> + <string name="title_sensor_detail">Sensor Detail</string> </resources> |