8     Esperanza EWS-103 sensor on 433.92Mhz
 
  10     Copyright (C) 2015 Alberts Saulitis
 
  11     This program is free software; you can redistribute it and/or modify
 
  12     it under the terms of the GNU General Public License version 3 as
 
  13     published by the Free Software Foundation.
 
  17     No frame description was available on the internet therefore it was required
 
  18     to reverse engineer it.
 
  20     AAAABBBB ????CCTT TTTTTTTT TTHHHHHH HH?????? ??
 
  25     T - Temperature (Little-endian)
 
  26     H - Humidity (Little-endian)
 
  32     Esperanze EWS: TemperatureF=55.5 TemperatureC=13.1 Humidity=74 Device_id=0 Channel=1
 
  34     *** signal_start = 16189, signal_end = 262145
 
  35     signal_len = 245956,  pulses = 266
 
  36     Iteration 1. t: 142    min: 141 (37)    max: 143 (229)    delta 4
 
  37     Iteration 2. t: 142    min: 141 (2)    max: 143 (264)    delta 0
 
  38     Distance coding: Pulse length 142
 
  40     Short distance: 487, long distance: 964, packet distance: 1920
 
  43     bitbuffer:: Number of rows: 14
 
  46     [02] {42} 00 53 e5 69 02 00 : 00000000 01010011 11100101 01101001 00000010 00
 
  48     [04] {42} 00 53 e5 69 02 00 : 00000000 01010011 11100101 01101001 00000010 00
 
  50     [06] {42} 00 53 e5 69 02 00 : 00000000 01010011 11100101 01101001 00000010 00
 
  52     [08] {42} 00 53 e5 69 02 00 : 00000000 01010011 11100101 01101001 00000010 00
 
  54     [10] {42} 00 53 e5 69 02 00 : 00000000 01010011 11100101 01101001 00000010 00
 
  56     [12] {42} 00 53 e5 69 02 00 : 00000000 01010011 11100101 01101001 00000010 00
 
  58     Test mode file issued 4 packets
 
  61 static int esperanza_ews_process_row(const bitbuffer_t *bitbuffer, int row)
 
  63     const uint8_t *b = bitbuffer->bb[row];
 
  65     uint16_t temperature_with_offset;
 
  72     char time_str[LOCAL_TIME_BUFLEN];
 
  74     local_time_str(0, time_str);
 
  76     humidity = (uint8_t)((b[3] << 6) | ((b[4] >> 2) & 0x0F) | ((b[3] >>2) & 0xF));
 
  77     temperature_with_offset = (uint16_t)(((b[2] << 10) | ((b[3] << 2) & 0x300) | ((b[3] << 2) & 0xF0) | ((b[1] << 2) & 0x0C) |  b[2] >> 6) & 0x0FFF);
 
  78     device_id = (uint8_t)(b[0] & 0x0F);
 
  79     channel = (uint8_t)((b[1] & 0x0C)+1);
 
  80     temperature_f = (float)((temperature_with_offset-900)/10.0);
 
  82     data = data_make("time",          "",            DATA_STRING, time_str,
 
  83                      "model",         "",            DATA_STRING, "Esperanza EWS",
 
  84                      "id",            "",            DATA_INT, device_id,
 
  85                      "channel",       "Channel",     DATA_INT, channel,
 
  86                      "temperature_F", "Temperature", DATA_FORMAT, "%.02f F", DATA_DOUBLE, temperature_f,
 
  87                      "humidity",      "Humidity",    DATA_FORMAT, "%u %%", DATA_INT, humidity,
 
  89     data_acquired_handler(data);
 
  94 static char *output_fields[] = {
 
 104 static int esperanza_ews_callback(bitbuffer_t *bitbuffer)
 
 106     if (bitbuffer->num_rows == 14) {
 
 107         for (int row=2; row < bitbuffer->num_rows-3; row+=2) {
 
 108             if (memcmp(bitbuffer->bb[row], bitbuffer->bb[row+2], sizeof(bitbuffer->bb[row])) != 0 || bitbuffer->bits_per_row[row] != 42) return 0;
 
 110         esperanza_ews_process_row(bitbuffer, 2);
 
 117 r_device esperanza_ews = {
 
 118         .name          = "Esperanza EWS",
 
 119         .modulation    = OOK_PULSE_PPM_RAW,
 
 123         .json_callback = &esperanza_ews_callback,