~krystianch/rtl_433

7e1b3d81507cf0ad40b5ee8ba276746f78a61389 — Krystian Chachuła 6 months ago 899b169 master
Update Tiny Weather
1 files changed, 9 insertions(+), 10 deletions(-)

M src/devices/radiohead_ask.c
M src/devices/radiohead_ask.c => src/devices/radiohead_ask.c +9 -10
@@ 182,10 182,12 @@ 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;
    int msg_len, data_len;

    uint8_t rh_payload[RH_ASK_MAX_PAYLOAD_LEN] = {0};
    struct {
        char id[2];
        uint16_t serial;
        int32_t temp;
        uint32_t pres, humi;
    } payload;


@@ 194,23 196,20 @@ static int tiny_weather_callback(r_device *decoder, bitbuffer_t *bitbuffer)
    if (msg_len <= 0) {
        return msg_len; // pass error code on
    }
    data_len = msg_len - 2 - 3;
    data_len = msg_len - 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);
    memcpy(&payload, rh_payload + 1, 16);
    if (payload.id[0] != 'T' || payload.id[1] != 'W')
        return DECODE_ABORT_EARLY;

    /* 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,
	    "serial",       "Serial",       DATA_FORMAT, "%04x", DATA_INT, payload.serial,
	    "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,