mirror of
https://github.com/merbanan/rtl_433.git
synced 2026-05-19 07:15:15 -04:00
suggested changes
This commit is contained in:
committed by
Benjamin Larsson
parent
0b64ef588e
commit
d3bb88b435
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* x - ID // changes on battery switch
|
||||
* c - Unknown Checksum (changes on every transmit if the other values are different)
|
||||
* h - Humidity // each nibble represents one diggit of percentage value
|
||||
* h - Humidity // BCD-encoded, each nibble is one digit
|
||||
* t - Temperature // in °F as binary number with one decimal place + 90 °F offset
|
||||
*
|
||||
*
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#include "rtl_433.h"
|
||||
#include "util.h"
|
||||
#include "pulse_demod.h"
|
||||
#include "data.h"
|
||||
|
||||
static int infactory_callback(bitbuffer_t *bitbuffer) {
|
||||
@@ -29,37 +28,33 @@ static int infactory_callback(bitbuffer_t *bitbuffer) {
|
||||
uint8_t *b = bb[0];
|
||||
data_t *data;
|
||||
|
||||
if (bitbuffer->bits_per_row[0] != 40) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t id = b[0];
|
||||
|
||||
uint hum1 = b[3] & 0xF;
|
||||
uint hum2 = b[4] >> 4;
|
||||
uint humidity = hum1 * 10 + hum2;
|
||||
|
||||
uint8_t temp1 = b[2];
|
||||
uint temp2 = b[3] >> 4;
|
||||
uint16_t temp = (temp1 << 4) | temp2;
|
||||
|
||||
double temp_f = (double)temp / 10 - 90;
|
||||
|
||||
char time_str[LOCAL_TIME_BUFLEN];
|
||||
local_time_str(0, time_str);
|
||||
|
||||
if (bitbuffer->bits_per_row[0] == 40) {
|
||||
data = data_make( "time", "", DATA_STRING, time_str,
|
||||
"model", "", DATA_STRING, "inFactory sensor",
|
||||
"id", "ID", DATA_FORMAT, "%u", DATA_INT, id,
|
||||
"temperature_F", "Temperature",DATA_FORMAT, "%.02f °F", DATA_DOUBLE, temp_f,
|
||||
"humidity", "Humidity", DATA_FORMAT, "%u %%", DATA_INT, humidity,
|
||||
NULL);
|
||||
data_acquired_handler(data);
|
||||
|
||||
//bitbuffer_print(bitbuffer);
|
||||
|
||||
uint8_t id = b[0];
|
||||
//uint8_t test = b[1];
|
||||
|
||||
uint hum1 = b[3] & 0xF;
|
||||
uint hum2 = b[4] >> 4;
|
||||
uint humidity = hum1 * 10 + hum2;
|
||||
|
||||
uint8_t temp1 = b[2];
|
||||
uint temp2 = b[3] >> 4;
|
||||
uint16_t temp = (temp1 << 4) | temp2;
|
||||
|
||||
double temp_f = (double)temp / 10 - 90;
|
||||
double temp_c = (temp_f - 32)*5/9;
|
||||
|
||||
|
||||
data = data_make( "time", "", DATA_STRING, time_str,
|
||||
"model", "", DATA_STRING, "inFactory sensor",
|
||||
"id", "ID", DATA_FORMAT, "%u", DATA_INT, id,
|
||||
"temperature_c", "Temperature",DATA_FORMAT, "%.02f °C", DATA_DOUBLE, temp_c,
|
||||
"humidity", "Humidity", DATA_FORMAT, "%u %%", DATA_INT, humidity,
|
||||
NULL);
|
||||
data_acquired_handler(data);
|
||||
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -69,7 +64,7 @@ static char *output_fields[] = {
|
||||
"time",
|
||||
"model"
|
||||
"id",
|
||||
"temperature_c",
|
||||
"temperature_F",
|
||||
"humidity",
|
||||
NULL
|
||||
};
|
||||
@@ -81,6 +76,6 @@ r_device infactory = {
|
||||
.long_limit = 5000, // Maximum gap size before new row of bits [us]
|
||||
.reset_limit = 6000, // Maximum gap size before End Of Message [us].
|
||||
.json_callback = &infactory_callback,
|
||||
.disabled = 0,
|
||||
.disabled = 1,
|
||||
.fields = output_fields
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user