Skip to content

Commit

Permalink
Update README.md, add CHANGELOG.mb, Minor bugfix in hcidump parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Scrin committed Nov 19, 2017
1 parent 61d36fd commit 1f70935
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 7 deletions.
52 changes: 52 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Changelog

## v0.2.0

- Major refactoring in the application logic
- Changed the preferred format how data is saved to InfluxDB
- Added new configuration properties and changed some old ones
- Added the ability to give (human readable) friendly names for tags

##### --- Migrating from a pre-v.0.2.0 version:

Versions prior to v0.2.0 use single-value measurements, v0.2.0 uses multi-value measurements by default (for a limited time you can use the legacy format by changing that in the config). To migrate from a version prior to v0.2.0:

- If you are using a custom config, copy the new ruuvi-collector.properties.example and replace your existing ruuvi-collector.properties and change the values you need. Some properties have their names changed and some new ones are added.
- If you want to give names to your tags (in your existing measurements as well as future measurements), copy the ruuvi-names.properties.example to ruuvi-names.properties (in the same directory) as the collector and edit the file accordingly.
- Run the collector with `migrate` parameter to migrate existing data to the new format: `java -jar ruuvi-collector-*.jar migrate` and let it run, this may take a long time if you have a lot of data or have a slow system (ie. Raspberry PI).
- The log should say something like this once the migration is finished:

```
2017-11-19 13:46:29.416 INFO [InfluxDataMigrator] Starting query threads...
2017-11-19 13:46:30.023 INFO [InfluxDataMigrator] Processing...
2017-11-19 13:47:52.012 INFO [InfluxDataMigrator] Finished migration! 912816 measurements migrated, took 82.823 seconds (11021.286357654275 measurements per second)
2017-11-19 13:47:52.016 INFO [InfluxDataMigrator] accelerationX discarded: 0
2017-11-19 13:47:52.016 INFO [InfluxDataMigrator] accelerationY discarded: 0
2017-11-19 13:47:52.016 INFO [InfluxDataMigrator] accelerationZ discarded: 0
2017-11-19 13:47:52.016 INFO [InfluxDataMigrator] battery discarded: 0
2017-11-19 13:47:52.017 INFO [InfluxDataMigrator] humidity discarded: 0
2017-11-19 13:47:52.017 INFO [InfluxDataMigrator] pressure discarded: 0
2017-11-19 13:47:52.017 INFO [InfluxDataMigrator] rssi discarded: 0
2017-11-19 13:47:52.017 INFO [InfluxDataMigrator] temperature discarded: 0
2017-11-19 13:47:52.478 INFO [Main] Clean exit
```

- Ideally you should have 0 discards like in the example above, and the number of measurements migrated should be the amount of measurements you had stored.
- The migrator does *not* delete the old measurements, so if something goes wrong, you can always try again
- When you are happy with the result, you can continue running the collector normally like before, without the migrate argument
- NOTE: as the format in InfluxDB changes, you need to update your applications accordingly (ie. Grafana, choose 'ruuvi_measurements' as the measurement and the desired type as the 'value')

### v0.1.2

- Improved error handling
- Added support for whitelist/blacklist filtering
- Added support for dryrun mode

### v0.1.1

- Support for protocol version 4
- Bugfix related to protocol version 3 with latest weather-station firmware

## v0.1.0

- First public release
32 changes: 30 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@ RuuviCollector is an application for collecting sensor measurements from RuuviTa

Note: As this is the first release of this application, there is very little documentation at this point, so some knowledge in Linux and Java is necessary for fully understanding how to use this at this point.

### Features

Supports following RuuviTag [Data Formats](https://github.com/ruuvi/ruuvi-sensor-protocols):

- Data Format 2: Eddystone-URL, URL-safe base64 -encoded, kickstarter edition
- Data Format 3: BLE Manufacturer specific data, all current sensor readings
- Data Format 4: Eddystone-URL, URL-safe base64 -encoded, with tag id.

Supports following data from the tag (depending on tag firmware):

- Temperature (Celcsius)
- Relative humidity (0-100%)
- Air pressure (Pascal)
- Acceleration for X, Y and Z axes (g)
- Battery voltage (Volts)
- RSSI (Signal strength *at the receiver*, dBm)

Ability to calculate following values in addition to the raw data (the accuracy of these values are approximations):

- Total acceleration (g)
- Absolute humidity (g/m³)
- Dew point (Celsius)
- Equilibrium vapor pressure (Pascal)
- Air density (Accounts for humidity in the air, kg/m³)
- Acceleration angle from X, Y and Z axes (Degrees)

### Requirements

* Linux-based OS (this application uses the bluez stack for Bluetooth which is not available for Windows for example)
Expand Down Expand Up @@ -32,7 +58,7 @@ sudo setcap 'cap_net_raw,cap_net_admin+eip' `which hcitool`
sudo setcap 'cap_net_raw,cap_net_admin+eip' `which hcidump`
```

- Run the built JAR-file with `java -jar ruuvi-collector-0.1.jar`. Note: as there is no service scripts yet, it's recommended to run this for example inside *screen* to avoid the application being killed when terminal session ends
- Run the built JAR-file with `java -jar ruuvi-collector-*.jar`. Note: as there is no service scripts yet, it's recommended to run this for example inside *screen* to avoid the application being killed when terminal session ends
- To configure the settings, copy the `ruuvi-collector.properties.example` to `ruuvi-collector.properties` and place it in the same directory as the JAR file and edit the file according to your needs.

### Configuration
Expand All @@ -41,12 +67,14 @@ The default configuration which works without a config file assumes InfluxDB is
To change the default settings, copy the ruuvi-collector.properties.example file as ruuvi-collector.properties in the same directory as the collector jar file and change the settings you want.
Most up-to-date information about the supported configuration options can be found in the ruuvi-collector.properties.example file.

To give human readable friendly names to tags (based on their MAC address), copy the ruuvi-names.properties.example file as ruuvi-names.properties in the same directory as the collector jar file and set the names in this file according to the examples there.

### Running

For built version (while in the "root" of the project):

```sh
java -jar target/ruuvi-collector-0.1.jar
java -jar target/ruuvi-collector-*.jar
```

Easily compile and run while developing:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fi.tkgwf.ruuvi</groupId>
<artifactId>ruuvi-collector</artifactId>
<version>0.1</version>
<version>0.2</version>
<packaging>jar</packaging>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion ruuvi-collector.properties.example
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# Storage method, currently valid values: "influxdb", "legacy_influxdb" and "dummy"
# influxdb = Recommended and default, this stores the values to InfluxDB into a single measurement
# influxdb_legacy = The old format used by this collector on versions before 0.2.0, stores values into separate measurements.
# NOTE: influxdb_legacy is no longer supported, you should use the new influxdb format and migrate old data, see README.md
# NOTE: influxdb_legacy is no longer supported, you should use the new influxdb format and migrate old data, see CHANGELOG.md
# dummy = Logs the measurements to the log rather than sending them anywhere, feasible for testing and development
#storage.method=influxdb

Expand Down
12 changes: 10 additions & 2 deletions src/main/java/fi/tkgwf/ruuvi/utils/HCIParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
public class HCIParser {

private boolean sendingData;
private int indexInPacket;
private int indexInReport;
private int indexInADData;
Expand All @@ -37,9 +38,15 @@ public HCIData readLine(String line) {
return null; // ignore blank lines
}
line = line.trim();
if (line.charAt(0) == '>') {
if (line.charAt(0) == '>') { // new incoming packet begins
reset();
line = line.substring(1).trim();
line = line.substring(1).trim(); // discard the > char
}
if (line.charAt(0) == '<') { // new outgoing packet begins
sendingData = true;
}
if (sendingData) {
return null; // currently reading a packet that is being sent rather than received, ignore it
}
byte[] lineData = RuuviUtils.hexToBytes(line);
int i = 0;
Expand All @@ -55,6 +62,7 @@ public HCIData readLine(String line) {
}

private void reset() {
sendingData = false;
indexInPacket = 0;
indexInReport = 0;
indexInADData = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static Double totalAcceleration(Double accelerationX, Double acceleration
* @return Angle between the components axis and the vector, in degrees
*/
public static Double angleBetweenVectorComponentAndAxis(Double vectorComponent, Double vectorLength) {
if (vectorComponent == null || vectorLength == null) {
if (vectorComponent == null || vectorLength == null || vectorLength == 0) {
return null;
}
return Math.toDegrees(Math.acos(vectorComponent / vectorLength));
Expand Down

0 comments on commit 1f70935

Please sign in to comment.