1 /* Generic temperature sensor 1
3 * Copyright (C) 2015 Alexandre Coffignal
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
15 static int generic_temperature_sensor_callback(bitbuffer_t *bitbuffer) {
16 bitrow_t *bb = bitbuffer->bb;
18 char time_str[LOCAL_TIME_BUFLEN];
19 local_time_str(0, time_str);
25 if(bitbuffer->bits_per_row[i]!=24){
31 //AAAAAAAA BBCCCCCC CCCCCCCC
37 battery=(bb[1][1]&0xF0)>>4;
38 fTemp=(float)((signed short)(((bb[1][1]&0x3f)*256+bb[1][2])<<2))/160.0;
40 data = data_make("time", "", DATA_STRING, time_str,
41 "model", "", DATA_STRING, "Generic temperature sensor 1",
42 "id", "Id", DATA_FORMAT, "\t %d", DATA_INT, device,
43 "temperature_C", "Temperature", DATA_FORMAT, "%.02f C", DATA_DOUBLE, fTemp,
44 "battery", "Battery?", DATA_INT, battery,
46 data_acquired_handler(data);
52 static char *output_fields[] = {
61 r_device generic_temperature_sensor = {
63 .name = "Generic temperature sensor 1",
64 .modulation = OOK_PULSE_PPM_RAW,
68 .json_callback = &generic_temperature_sensor_callback,
71 .fields = output_fields,