~krystianch/rtl_433

899b16974efc08b564be14c7290c975ca5dd62e7 — Krystian Chachuła 8 months ago 767e538
Add support for Tiny Weather
2 files changed, 68 insertions(+), 0 deletions(-)

M include/rtl_433_devices.h
M src/devices/radiohead_ask.c
M include/rtl_433_devices.h => include/rtl_433_devices.h +1 -0
@@ 253,6 253,7 @@
    DECL(celsia_czc1) \
    DECL(fineoffset_ws90) \
    DECL(thermopro_tx2c) \
    DECL(tiny_weather) \

    /* Add new decoders here. */


M src/devices/radiohead_ask.c => src/devices/radiohead_ask.c +67 -0
@@ 178,6 178,50 @@ static int radiohead_ask_callback(r_device *decoder, bitbuffer_t *bitbuffer)
    return 1;
}

static int tiny_weather_callback(r_device *decoder, bitbuffer_t *bitbuffer)
{
    data_t *data;
    uint8_t row = 0; // we are considering only first row
    int msg_len, data_len, header_to, header_from, header_seq;

    uint8_t rh_payload[RH_ASK_MAX_PAYLOAD_LEN] = {0};
    struct {
        int32_t temp;
        uint32_t pres, humi;
    } payload;

    msg_len = radiohead_ask_extract(decoder, bitbuffer, row, rh_payload);
    if (msg_len <= 0) {
        return msg_len; // pass error code on
    }
    data_len = msg_len - 2 - 3;
    if (data_len <= 0)
        return DECODE_FAIL_SANITY;

    header_to    = (rh_payload[1] & 0xf0) >> 4;
    header_from  = rh_payload[1] & 0x0f;
    header_seq   = rh_payload[2];

    // Format data
    memcpy(&payload, rh_payload + 3, 12);
    /* clang-format off */
    data = data_make(
            "model",        "",             DATA_STRING, "Tiny Weather",
            "len",          "Data len",     DATA_INT, data_len,
            "to",           "To",           DATA_INT, header_to,
            "from",         "From",         DATA_INT, header_from,
            "seq",          "Seq",          DATA_INT, header_seq,
	    "temp",         "Temperature",  DATA_DOUBLE, (double) payload.temp / 100.0,
	    "pres",         "Pressure",     DATA_DOUBLE, (double) payload.pres / 256.0 / 100.0,
	    "humi",         "Humidity",     DATA_DOUBLE, (double) payload.humi / 1024.0,
            "mic",          "Integrity",    DATA_STRING, "CRC",
            NULL);
    /* clang-format on */

    decoder_output_data(decoder, data);
    return 1;
}

/**
Sensible Living Mini-Plant Moisture Sensor.



@@ 235,6 279,19 @@ static char const *const radiohead_ask_output_fields[] = {
        NULL,
};

static char const *const tiny_weather_output_fields[] = {
        "model",
        "len",
        "to",
        "from",
        "seq",
        "temp",
        "pres",
        "humi",
        "mic",
        NULL,
};

static char const *const sensible_living_output_fields[] = {
        "model",
        "house_id",


@@ 258,6 315,16 @@ r_device const radiohead_ask = {
        .fields      = radiohead_ask_output_fields,
};

r_device const tiny_weather = {
        .name        = "Tiny Weather",
        .modulation  = OOK_PULSE_PCM,
        .short_width = 1000,
        .long_width  = 1000,
        .reset_limit = 5 * 1000,
        .decode_fn   = &tiny_weather_callback,
        .fields      = tiny_weather_output_fields,
};

r_device const sensible_living = {
        .name        = "Sensible Living Mini-Plant Moisture Sensor",
        .modulation  = OOK_PULSE_PCM,