3 /* Currently this can decode the temperature and id from Rubicson sensors
5 * the sensor sends 36 bits 12 times pwm modulated
6 * the data is grouped into 9 nibles
7 * [id0] [id1], [unk0] [temp0], [temp1] [temp2], [unk1] [unk2], [unk3]
9 * The id changes when the battery is changed in the sensor.
10 * unk0 is always 1 0 0 0, most likely 2 channel bits as the sensor can recevice 3 channels
11 * unk1-3 changes and the meaning is unknown
12 * temp is 12 bit signed scaled by 10
14 * The sensor can be bought at Kjell&Co
17 static int rubicson_callback(uint8_t bb[BITBUF_ROWS][BITBUF_COLS],int16_t bits_per_row[BITBUF_ROWS]) {
18 int temperature_before_dec;
19 int temperature_after_dec;
22 /* FIXME validate the received message better, figure out crc */
23 if (bb[1][0] == bb[2][0] && bb[2][0] == bb[3][0] && bb[3][0] == bb[4][0] &&
24 bb[4][0] == bb[5][0] && bb[5][0] == bb[6][0] && bb[6][0] == bb[7][0] && bb[7][0] == bb[8][0] &&
25 bb[8][0] == bb[9][0] && (bb[5][0] != 0 && bb[5][1] != 0 && bb[5][2] != 0)) {
27 /* Nible 3,4,5 contains 12 bits of temperature
28 * The temerature is signed and scaled by 10 */
29 temp = (int16_t)((uint16_t)(bb[0][1] << 12) | (bb[0][2] << 4));
32 temperature_before_dec = abs(temp / 10);
33 temperature_after_dec = abs(temp % 10);
35 fprintf(stderr, "Sensor temperature event:\n");
36 fprintf(stderr, "protocol = Rubicson/Auriol, %d bits\n",bits_per_row[1]);
37 fprintf(stderr, "rid = %x\n",bb[0][0]);
38 fprintf(stderr, "temp = %s%d.%d\n",temp<0?"-":"",temperature_before_dec, temperature_after_dec);
39 fprintf(stderr, "%02x %02x %02x %02x %02x\n",bb[1][0],bb[0][1],bb[0][2],bb[0][3],bb[0][4]);
42 debug_callback(bb, bits_per_row);
49 // timings based on samp_rate=1024000
52 /* .name = */ "Rubicson Temperature Sensor",
53 /* .modulation = */ OOK_PWM_D,
54 /* .short_limit = */ 1744/4,
55 /* .long_limit = */ 3500/4,
56 /* .reset_limit = */ 5000/4,
57 /* .json_callback = */ &rubicson_callback,