@@ -13,24 +13,29 @@ Hideki Temperature, Humidity, Wind, Rain sensor.
13
13
The received bits are inverted.
14
14
15
15
Every 8 bits are stuffed with a (even) parity bit.
16
- The payload (excluding the header) has an byte parity (XOR) check
17
- The payload (excluding the header) has CRC-8, poly 0x07 init 0x00 check
18
- The payload bytes are reflected (LSB first / LSB last) after the CRC check
16
+ The payload (excluding the header) has an byte parity (XOR) check.
17
+ The payload (excluding the header) has CRC-8, poly 0x07 init 0x00 check.
18
+ The payload bytes are reflected (LSB first / LSB last) after the CRC check.
19
19
20
- 11111001 0 11110101 0 01110011 1 01111010 1 11001100 0 01000011 1 01000110 1 00111111 0 00001001 0 00010111 0
21
- SYNC+HEAD P RC cha P LEN P Nr.? P .1° 1° P 10° BV P 1% 10% P ? P XOR P CRC P
20
+ Temp:
21
+
22
+ 11111001 0 11110101 0 01110011 1 01111010 1 11001100 0 01000011 1 01000110 1 00111111 0 00001001 0 00010111 0
23
+ SYNC+HEAD P RC cha P LEN P Nr.? P .1° 1° P 10° BV P 1% 10% P ? P XOR P CRC P
22
24
23
25
TS04:
24
- 00000000 11111111 22222222 33333333 44444444 55555555 66666666 77777777 88888888 99999999
25
- SYNC+HEAD cha RC LEN Nr.? 1° .1° VB 10° 10% 1% ? XOR CRC
26
+
27
+ 00000000 11111111 22222222 33333333 44444444 55555555 66666666 77777777 88888888 99999999
28
+ SYNC+HEAD cha RC LEN Nr.? 1° .1° VB 10° 10% 1% ? XOR CRC
26
29
27
30
Wind:
28
- 00000000 11111111 22222222 33333333 44444444 55555555 66666666 77777777 88888888 99999999 AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD
29
- SYNC+HEAD cha RC LEN Nr.? 1° .1° VB 10° 1° .1° VB 10° 1W .1W .1G 10W 10G 1G w° AA XOR CRC
31
+
32
+ 00000000 11111111 22222222 33333333 44444444 55555555 66666666 77777777 88888888 99999999 AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD
33
+ SYNC+HEAD cha RC LEN Nr.? 1° .1° VB 10° 1° .1° VB 10° 1W .1W .1G 10W 10G 1G w° AA XOR CRC
30
34
31
35
Rain:
32
- 00000000 11111111 22222222 33333333 44444444 55555555 66666666 77777777 88888888
33
- SYNC+HEAD cha RC B LEN Nr.? RAIN_L RAIN_H 0x66 XOR CRC
36
+
37
+ 00000000 11111111 22222222 33333333 44444444 55555555 66666666 77777777 88888888
38
+ SYNC+HEAD cha RC B LEN Nr.? RAIN_L RAIN_H 0x66 XOR CRC
34
39
35
40
*/
36
41
@@ -69,10 +74,10 @@ static int hideki_ts04_callback(r_device *decoder, bitbuffer_t *bitbuffer)
69
74
// Strip (unstuff) and check parity bit
70
75
// TODO: refactor to util function
71
76
for (int i = 0 ; i < unstuffed_len ; ++ i ) {
72
- unsigned int offset = i / 8 ;
73
- packet [i ] = (b [i + offset ] << (i % 8 )) | (b [i + offset + 1 ] >> (8 - i % 8 ));
77
+ unsigned int offset = i / 8 ;
78
+ packet [i ] = (b [i + offset ] << (i % 8 )) | (b [i + offset + 1 ] >> (8 - i % 8 ));
74
79
// check parity
75
- uint8_t parity = (b [i + offset + 1 ] >> (7 - i % 8 )) & 1 ;
80
+ uint8_t parity = (b [i + offset + 1 ] >> (7 - i % 8 )) & 1 ;
76
81
if (parity != parity8 (packet [i ])) {
77
82
if (decoder -> verbose )
78
83
fprintf (stderr , "%s: Parity error at %d\n" , __func__ , i );
@@ -127,6 +132,7 @@ static int hideki_ts04_callback(r_device *decoder, bitbuffer_t *bitbuffer)
127
132
128
133
if (sensortype == HIDEKI_TS04 ) {
129
134
humidity = ((packet [6 ] & 0xF0 ) >> 4 ) * 10 + (packet [6 ] & 0x0F );
135
+ /* clang-format off */
130
136
data = data_make (
131
137
"model" , "" , DATA_STRING , _X ("Hideki-TS04" ,"HIDEKI TS04 sensor" ),
132
138
_X ("id" ,"rc" ), "Rolling Code" , DATA_INT , rc ,
@@ -136,17 +142,19 @@ static int hideki_ts04_callback(r_device *decoder, bitbuffer_t *bitbuffer)
136
142
"humidity" , "Humidity" , DATA_FORMAT , "%u %%" , DATA_INT , humidity ,
137
143
"mic" , "Integrity" , DATA_STRING , "CRC" ,
138
144
NULL );
145
+ /* clang-format on */
139
146
decoder_output_data (decoder , data );
140
147
return 1 ;
141
148
}
142
149
if (sensortype == HIDEKI_WIND ) {
143
150
int const wd [] = { 0 , 15 , 13 , 14 , 9 , 10 , 12 , 11 , 1 , 2 , 4 , 3 , 8 , 7 , 5 , 6 };
144
151
wind_direction = wd [((packet [11 ] & 0xF0 ) >> 4 )] * 225 ;
145
152
wind_speed = (packet [9 ] & 0x0F ) * 100 + (packet [8 ] >> 4 ) * 10 + (packet [8 ] & 0x0F );
146
- gust_speed = (packet [10 ] & 0xF0 ) * 100 + (packet [10 ] >> 4 ) * 10 + (packet [9 ] >> 4 );
153
+ gust_speed = (packet [10 ] >> 4 ) * 100 + (packet [10 ] & 0x0F ) * 10 + (packet [9 ] >> 4 );
147
154
int const ad [] = { 0 , 1 , -1 , 2 }; // i.e. None, CW, CCW, invalid
148
155
wind_approach = ad [(packet [11 ] >> 2 ) & 0x03 ];
149
156
157
+ /* clang-format off */
150
158
data = data_make (
151
159
"model" , "" , DATA_STRING , _X ("Hideki-Wind" ,"HIDEKI Wind sensor" ),
152
160
_X ("id" ,"rc" ), "Rolling Code" , DATA_INT , rc ,
@@ -159,10 +167,12 @@ static int hideki_ts04_callback(r_device *decoder, bitbuffer_t *bitbuffer)
159
167
_X ("wind_dir_deg" ,"wind_direction" ), "Wind Direction" , DATA_FORMAT , "%.01f" , DATA_DOUBLE , wind_direction * 0.1f ,
160
168
"mic" , "Integrity" , DATA_STRING , "CRC" ,
161
169
NULL );
170
+ /* clang-format on */
162
171
decoder_output_data (decoder , data );
163
172
return 1 ;
164
173
}
165
174
if (sensortype == HIDEKI_TEMP ) {
175
+ /* clang-format off */
166
176
data = data_make (
167
177
"model" , "" , DATA_STRING , _X ("Hideki-Temperature" ,"HIDEKI Temperature sensor" ),
168
178
_X ("id" ,"rc" ), "Rolling Code" , DATA_INT , rc ,
@@ -171,13 +181,15 @@ static int hideki_ts04_callback(r_device *decoder, bitbuffer_t *bitbuffer)
171
181
"temperature_C" , "Temperature" , DATA_FORMAT , "%.01f C" , DATA_DOUBLE , temp * 0.1f ,
172
182
"mic" , "Integrity" , DATA_STRING , "CRC" ,
173
183
NULL );
184
+ /* clang-format on */
174
185
decoder_output_data (decoder , data );
175
186
return 1 ;
176
187
}
177
188
if (sensortype == HIDEKI_RAIN ) {
178
189
rain_units = (packet [5 ] << 8 ) | packet [4 ];
179
190
battery_ok = (packet [2 ] >> 6 ) & 1 ;
180
191
192
+ /* clang-format off */
181
193
data = data_make (
182
194
"model" , "" , DATA_STRING , _X ("Hideki-Rain" ,"HIDEKI Rain sensor" ),
183
195
_X ("id" ,"rc" ), "Rolling Code" , DATA_INT , rc ,
@@ -186,6 +198,7 @@ static int hideki_ts04_callback(r_device *decoder, bitbuffer_t *bitbuffer)
186
198
"rain_mm" , "Rain" , DATA_FORMAT , "%.01f mm" , DATA_DOUBLE , rain_units * 0.7f ,
187
199
"mic" , "Integrity" , DATA_STRING , "CRC" ,
188
200
NULL );
201
+ /* clang-format on */
189
202
decoder_output_data (decoder , data );
190
203
return 1 ;
191
204
}
@@ -194,33 +207,32 @@ static int hideki_ts04_callback(r_device *decoder, bitbuffer_t *bitbuffer)
194
207
}
195
208
196
209
static char * output_fields [] = {
197
- "model" ,
198
- "rc" , // TODO: delete this
199
- "id" ,
200
- "channel" ,
201
- "battery" ,
202
- "temperature_C" ,
203
- "humidity" ,
204
- "wind_speed_mph" , // TODO: remove this
205
- "gust_speed_mph" , // TODO: remove this
206
- "wind_avg_mi_h" ,
207
- "wind_max_mi_h" ,
208
- "wind_approach" ,
209
- "wind_direction" , // TODO: remove this
210
- "wind_dir_deg" ,
211
- "rain_mm" ,
212
- "mic" ,
213
- NULL ,
210
+ "model" ,
211
+ "rc" , // TODO: delete this
212
+ "id" ,
213
+ "channel" ,
214
+ "battery" ,
215
+ "temperature_C" ,
216
+ "humidity" ,
217
+ "wind_speed_mph" , // TODO: remove this
218
+ "gust_speed_mph" , // TODO: remove this
219
+ "wind_avg_mi_h" ,
220
+ "wind_max_mi_h" ,
221
+ "wind_approach" ,
222
+ "wind_direction" , // TODO: remove this
223
+ "wind_dir_deg" ,
224
+ "rain_mm" ,
225
+ "mic" ,
226
+ NULL ,
214
227
};
215
228
216
229
r_device hideki_ts04 = {
217
- .name = "HIDEKI TS04 Temperature, Humidity, Wind and Rain Sensor" ,
218
- .modulation = OOK_PULSE_DMC ,
219
- .short_width = 520 , // half-bit width 520 us
220
- .long_width = 1040 , // bit width 1040 us
221
- .reset_limit = 4000 ,
222
- .tolerance = 240 ,
223
- .decode_fn = & hideki_ts04_callback ,
224
- .disabled = 0 ,
225
- .fields = output_fields ,
230
+ .name = "HIDEKI TS04 Temperature, Humidity, Wind and Rain Sensor" ,
231
+ .modulation = OOK_PULSE_DMC ,
232
+ .short_width = 520 , // half-bit width 520 us
233
+ .long_width = 1040 , // bit width 1040 us
234
+ .reset_limit = 4000 ,
235
+ .tolerance = 240 ,
236
+ .decode_fn = & hideki_ts04_callback ,
237
+ .fields = output_fields ,
226
238
};
0 commit comments