5 // Actually 37 bits for all but last transmission which is 36 bits
8 static int springfield_callback(bitbuffer_t *bitbuffer) {
10 char time_str[LOCAL_TIME_BUFLEN];
14 int nibble[NUM_BITS/4+1];
15 int sid, battery, transmit, channel, temp;
23 local_time_str(0, time_str);
25 for(row = 0; row < bitbuffer->num_rows; row++) {
26 if(bitbuffer->bits_per_row[row] == NUM_BITS || bitbuffer->bits_per_row[row] == NUM_BITS + 1) {
28 tmpData = (bitbuffer->bb[row][0] << 24) + (bitbuffer->bb[row][1] << 16) + (bitbuffer->bb[row][2] << 8) + bitbuffer->bb[row][3];
29 for(i = 0; i < (NUM_BITS/4); i++) {
30 if((i & 0x01) == 0x01)
31 nibble[i] = bitbuffer->bb[row][i >> 1] & 0x0f;
33 nibble[i] = bitbuffer->bb[row][i >> 1] >> 0x04;
34 if(i < 7) cs ^= nibble[i];
38 if(checksum == cs && tmpData != savData) {
40 sid = (nibble[0] << 4) + nibble[1];
41 battery = (nibble[2] >> 3) & 0x01;
42 transmit = (nibble[2] >> 2) & 0x01;
43 channel = (nibble[2] & 0x03) + 1;
44 temp = ((nibble[3] << 8) + (nibble[4] << 4) + nibble[5]);
45 if(temp >= 0xf00) temp = temp - 0x1000;
48 uk1 = nibble[8]; /* unknown. */
51 "time", "", DATA_STRING, time_str,
52 "model", "", DATA_STRING, "Springfield Temperature & Moisture",
53 "sid", "SID", DATA_INT, sid,
54 "channel", "Channel", DATA_INT, channel,
55 "battery", "Battery", DATA_STRING, battery ? "LOW" : "OK",
56 "transmit", "Transmit", DATA_STRING, transmit ? "MANUAL" : "AUTO",
57 "temperature_C","Temperature", DATA_FORMAT, "%.01f C", DATA_DOUBLE, tempC,
58 "moisture", "Moisture", DATA_INT, moisture,
59 // "uk1", "uk1", DATA_INT, uk1,
61 data_acquired_handler(data);
69 static char *output_fields[] = {
81 r_device springfield = {
82 .name = "Springfield Temperature and Soil Moisture",
83 .modulation = OOK_PULSE_PPM_RAW,
84 .short_limit = 500 * 4,
85 .long_limit = 1000 * 4,
86 .reset_limit = 2300 * 4,
87 .json_callback = &springfield_callback,
90 .fields = output_fields