Minor style cleanup Opus XT300

This commit is contained in:
Christian W. Zuckschwerdt 2020-10-10 10:31:30 +02:00
parent e7c07dae68
commit 46041c5a99

View file

@ -16,21 +16,21 @@ https://www.plantcaretools.com/product/wireless-moisture-monitor/
Data is transmitted with 6 bytes row:
0. 1. 2. 3. 4. 5
FF ID SM TT ?? CC
0. 1. 2. 3. 4. 5
FF ID SM TT ?? CC
FF: initial preamble
ID: 0101 01ID
SM: soil moisure (decimal 05 -> 99 %)
TT: temperature °C + 40°C (decimal)
??: always FF... maybe spare bytes
CC: check sum (simple sum) except 0xFF preamble
- FF: initial preamble
- ID: 0101 01ID
- SM: soil moisure (decimal 05 -> 99 %)
- TT: temperature °C + 40°C (decimal)
- ??: always FF... maybe spare bytes
- CC: check sum (simple sum) except 0xFF preamble
*/
#include "decoder.h"
static int opus_xt300_callback(r_device *decoder, bitbuffer_t *bitbuffer)
static int opus_xt300_decode(r_device *decoder, bitbuffer_t *bitbuffer)
{
int ret = 0;
int fail_code = 0;
@ -70,7 +70,7 @@ static int opus_xt300_callback(r_device *decoder, bitbuffer_t *bitbuffer)
channel = (b[1] & 0x03);
temp = b[3] - 40;
moisture = b[2];
moisture = b[2];
// unverified sales advert say Outdoor temperature range: -40°C to +65°C
// test for Boiling water
@ -81,13 +81,16 @@ static int opus_xt300_callback(r_device *decoder, bitbuffer_t *bitbuffer)
continue;
}
/* clang-format off */
data = data_make(
"model", "", DATA_STRING, "Opus-XT300",
"channel", "Channel", DATA_INT, channel,
"temperature_C", "Temperature", DATA_FORMAT, "%d C", DATA_INT, temp,
"temperature_C", "Temperature", DATA_FORMAT, "%.0f C", DATA_DOUBLE, (double)temp,
"moisture", "Moisture", DATA_FORMAT, "%d %%", DATA_INT, moisture,
"mic", "Integrity", DATA_STRING, "CHECKSUM",
NULL);
/* clang-format on */
decoder_output_data(decoder, data);
ret++;
}
@ -95,22 +98,20 @@ static int opus_xt300_callback(r_device *decoder, bitbuffer_t *bitbuffer)
}
static char *output_fields[] = {
"model",
"channel",
"temperature_C",
"moisture",
NULL,
"model",
"channel",
"temperature_C",
"moisture",
NULL,
};
r_device opus_xt300 = {
.name = "Opus/Imagintronix XT300 Soil Moisture",
.modulation = OOK_PULSE_PWM,
.short_width = 544,
.long_width = 932,
.gap_limit = 10000,
.reset_limit = 31000,
.decode_fn = &opus_xt300_callback,
.disabled = 0,
.fields = output_fields,
.name = "Opus/Imagintronix XT300 Soil Moisture",
.modulation = OOK_PULSE_PWM,
.short_width = 544,
.long_width = 932,
.gap_limit = 10000,
.reset_limit = 31000,
.decode_fn = &opus_xt300_decode,
.fields = output_fields,
};