minor: Fix decoder indent and whitespace style
This commit is contained in:
parent
6cc8d4926a
commit
6e55cb6474
103 changed files with 635 additions and 650 deletions
.clang-format
src/devices
abmt.cacurite.cakhan_100F14.calecto.cambient_weather.cambientweather_tx8300.cambientweather_wh31e.cauriol_4ld5661.cauriol_aft77b2.cauriol_afw2a1.cauriol_ahfl.cauriol_hg02832.cblueline.cbrennenstuhl_rcs_2044.cbresser_7in1.cbt_rain.cburnhardbbq.ccavius.cchuango.ccmr113.ccompanion_wtr001.ccurrent_cost.cdanfoss.cdsc.cecowitt.cefergy_e2_classic.cefergy_optical.cefth800.celro_db286a.celv.cenocean_erp1.cert_idm.cert_scm.cesa.ceurochron.cflex.cfordremote.cft004b.cge_coloreffects.cgeneric_remote.cgovee.cgt_tmbbq05.chondaremote.choneywell_cm921.choneywell_wdb.cinfactory.cintertechno.ckerui.clacrosse.clacrosse_breezepro.clacrosse_r1.clacrosse_th3.clacrosse_wr1.clacrossews.clightwave_rf.cmarkisol.cmaverick_et73.cmebus.cmissil_ml0757.cnew_template.coil_standard.coil_watchman.copus_xt300.coregon_scientific_sl109h.cproflame2.cradiohead_ask.crftech.crubicson.cscmplus.csecplus_v1.csecplus_v2.csharp_spc775.csilvercrest.csimplisafe.csmoke_gs558.csomfy_rts.ctfa_30_3196.ctfa_30_3221.ctfa_marbella.ctfa_pool_thermometer.cthermopro_tp12.ctpms_abarth124.ctpms_ave.ctpms_citroen.ctpms_elantra2012.ctpms_ford.ctpms_jansite_solar.ctpms_pmv107j.ctpms_porsche.ctpms_renault.ctpms_toyota.ctpms_truck.cvaillant_vrt340f.cvisonic_powercode.cwaveman.cwg_pb12v1.cwssensor.cwt0124.cwt450.c
|
@ -5,7 +5,9 @@ BreakBeforeBraces: Stroustrup
|
|||
AlignAfterOpenBracket: DontAlign
|
||||
AlignEscapedNewlines: DontAlign
|
||||
AlignConsecutiveAssignments: true
|
||||
AlignConsecutiveMacros: AcrossEmptyLines
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
IndentCaseLabels: false
|
||||
ColumnLimit: 0
|
||||
SortIncludes: false
|
||||
|
|
|
@ -32,7 +32,7 @@ F - ones
|
|||
// Convert two BCD encoded nibbles to an integer
|
||||
static unsigned bcd2int(uint8_t bcd)
|
||||
{
|
||||
return 10*(bcd>>4) + (bcd & 0xF);
|
||||
return 10 * (bcd >> 4) + (bcd & 0xF);
|
||||
}
|
||||
|
||||
static int abmt_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
|
@ -62,12 +62,12 @@ static int abmt_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
return DECODE_FAIL_SANITY;
|
||||
|
||||
// sync bitstream
|
||||
bitbuffer_manchester_decode(bitbuffer, row, bitpos-SYNC_PATTERN_START_OFF, &packet_bits, 48);
|
||||
bitbuffer_manchester_decode(bitbuffer, row, bitpos - SYNC_PATTERN_START_OFF, &packet_bits, 48);
|
||||
bitbuffer_invert(&packet_bits);
|
||||
|
||||
b = packet_bits.bb[0];
|
||||
id = b[0];
|
||||
temp = bcd2int(b[3])*10 + bcd2int(b[4]>>4);
|
||||
b = packet_bits.bb[0];
|
||||
id = b[0];
|
||||
temp = bcd2int(b[3]) * 10 + bcd2int(b[4] >> 4);
|
||||
temp_c = (float)temp;
|
||||
|
||||
/* clang-format off */
|
||||
|
|
|
@ -188,8 +188,8 @@ static int acurite_th_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
|
||||
for (uint16_t brow = 0; brow < bitbuffer->num_rows; ++brow) {
|
||||
if (bitbuffer->bits_per_row[brow] != 40) {
|
||||
result = DECODE_ABORT_LENGTH;
|
||||
continue; // DECODE_ABORT_LENGTH
|
||||
result = DECODE_ABORT_LENGTH;
|
||||
continue; // DECODE_ABORT_LENGTH
|
||||
}
|
||||
|
||||
bb = bitbuffer->bb[brow];
|
||||
|
@ -366,7 +366,7 @@ static int acurite_6045_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsign
|
|||
int browlen = (bitbuffer->bits_per_row[row] + 7) / 8;
|
||||
uint8_t *bb = bitbuffer->bb[row];
|
||||
|
||||
char const *channel_str = acurite_getChannel(bb[0]); // same as TXR
|
||||
char const *channel_str = acurite_getChannel(bb[0]); // same as TXR
|
||||
|
||||
// Tower sensor ID is the last 14 bits of byte 0 and 1
|
||||
// CCII IIII | IIII IIII
|
||||
|
@ -534,7 +534,6 @@ static int acurite_atlas_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsig
|
|||
}
|
||||
*rawp = '\0';
|
||||
|
||||
|
||||
// The sensor sends the same data three times, each of these have
|
||||
// an indicator of which one of the three it is. This means the
|
||||
// checksum and first byte will be different for each one.
|
||||
|
@ -562,7 +561,7 @@ static int acurite_atlas_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsig
|
|||
/* clang-format on */
|
||||
|
||||
if (message_type == ACURITE_MSGTYPE_ATLAS_WNDSPD_TEMP_HUM ||
|
||||
message_type == ACURITE_MSGTYPE_ATLAS_WNDSPD_TEMP_HUM_LTNG) {
|
||||
message_type == ACURITE_MSGTYPE_ATLAS_WNDSPD_TEMP_HUM_LTNG) {
|
||||
// Wind speed, temperature and humidity
|
||||
|
||||
// range -40 to 160 F
|
||||
|
@ -581,7 +580,7 @@ static int acurite_atlas_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsig
|
|||
}
|
||||
|
||||
if (message_type == ACURITE_MSGTYPE_ATLAS_WNDSPD_RAIN ||
|
||||
message_type == ACURITE_MSGTYPE_ATLAS_WNDSPD_RAIN_LTNG) {
|
||||
message_type == ACURITE_MSGTYPE_ATLAS_WNDSPD_RAIN_LTNG) {
|
||||
// Wind speed, wind direction, and rain fall
|
||||
wind_dir = ((bb[4] & 0x1f) << 5) | ((bb[5] & 0x7c) >> 2);
|
||||
|
||||
|
@ -598,9 +597,9 @@ static int acurite_atlas_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsig
|
|||
}
|
||||
|
||||
if (message_type == ACURITE_MSGTYPE_ATLAS_WNDSPD_UV_LUX ||
|
||||
message_type == ACURITE_MSGTYPE_ATLAS_WNDSPD_UV_LUX_LTNG) {
|
||||
message_type == ACURITE_MSGTYPE_ATLAS_WNDSPD_UV_LUX_LTNG) {
|
||||
// Wind speed, UV Index, Light Intensity, Lightning?
|
||||
int uv = (bb[4] & 0x0f);
|
||||
int uv = (bb[4] & 0x0f);
|
||||
int lux = ((bb[5] & 0x7f) << 7) | (bb[6] & 0x7F);
|
||||
|
||||
/* clang-format off */
|
||||
|
@ -612,11 +611,11 @@ static int acurite_atlas_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsig
|
|||
}
|
||||
|
||||
if ((message_type == ACURITE_MSGTYPE_ATLAS_WNDSPD_TEMP_HUM_LTNG ||
|
||||
message_type == ACURITE_MSGTYPE_ATLAS_WNDSPD_RAIN_LTNG ||
|
||||
message_type == ACURITE_MSGTYPE_ATLAS_WNDSPD_UV_LUX_LTNG)) {
|
||||
message_type == ACURITE_MSGTYPE_ATLAS_WNDSPD_RAIN_LTNG ||
|
||||
message_type == ACURITE_MSGTYPE_ATLAS_WNDSPD_UV_LUX_LTNG)) {
|
||||
|
||||
// @todo decode strike_distance to miles or KM.
|
||||
int strike_count = ((bb[7] & 0x7f) << 2) | ((bb[8] & 0x60) >> 5);
|
||||
int strike_count = ((bb[7] & 0x7f) << 2) | ((bb[8] & 0x60) >> 5);
|
||||
int strike_distance = bb[8] & 0x1f;
|
||||
|
||||
/* clang-format off */
|
||||
|
@ -627,7 +626,6 @@ static int acurite_atlas_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsig
|
|||
/* clang-format on */
|
||||
}
|
||||
|
||||
|
||||
data = data_append(data,
|
||||
"exception", "data_exception", DATA_INT, exception, // @todo convert to bool
|
||||
"raw_msg", "raw_message", DATA_STRING, raw_str,
|
||||
|
@ -635,7 +633,7 @@ static int acurite_atlas_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsig
|
|||
|
||||
decoder_output_data(decoder, data);
|
||||
|
||||
return 1; // one valid message decoded
|
||||
return 1; // one valid message decoded
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -704,7 +702,7 @@ static int acurite_txr_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
for (int i = 0; i < browlen; i++) {
|
||||
fprintf(stderr, "%d", parity8(bb[i]));
|
||||
}
|
||||
fprintf(stderr,"\n");
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
// acurite sensors with a common format appear to have a message type
|
||||
|
@ -929,8 +927,8 @@ static int acurite_txr_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
}
|
||||
else {
|
||||
if (decoder->verbose > 1) {
|
||||
fprintf(stderr, "%s: Acurite 5n1 sensor 0x%04X Ch %s, Status %02X, Unknown message type 0x%02x\n",
|
||||
__func__, sensor_id, channel_str, bb[3], message_type);
|
||||
fprintf(stderr, "%s: Acurite 5n1 sensor 0x%04X Ch %s, Status %02X, Unknown message type 0x%02x\n",
|
||||
__func__, sensor_id, channel_str, bb[3], message_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1048,7 +1046,7 @@ static int acurite_986_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
|
||||
if (crcc != crc) {
|
||||
if (decoder->verbose > 1)
|
||||
bitrow_printf(br, browlen * 8, "%s: bad CRC: %02x -", __func__, crc8le(br, 4, 0x07, 0));
|
||||
bitrow_printf(br, browlen * 8, "%s: bad CRC: %02x -", __func__, crc8le(br, 4, 0x07, 0));
|
||||
// HACK: rct 2018-04-22
|
||||
// the message is often missing the last 1 bit either due to a
|
||||
// problem with the device or demodulator
|
||||
|
@ -1126,11 +1124,11 @@ static int acurite_606_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
// Processing the temperature:
|
||||
// Upper 4 bits are stored in nibble 1, lower 8 bits are stored in nibble 2
|
||||
// upper 4 bits of nibble 1 are reserved for other usages (e.g. battery status)
|
||||
sensor_id = b[0];
|
||||
sensor_id = b[0];
|
||||
battery_ok = (b[1] & 0x80) >> 7;
|
||||
temp_raw = (int16_t)((b[1] << 12) | (b[2] << 4));
|
||||
temp_raw = temp_raw >> 4;
|
||||
temp_c = temp_raw * 0.1f;
|
||||
temp_raw = (int16_t)((b[1] << 12) | (b[2] << 4));
|
||||
temp_raw = temp_raw >> 4;
|
||||
temp_c = temp_raw * 0.1f;
|
||||
|
||||
/* clang-format off */
|
||||
data = data_make(
|
||||
|
@ -1151,7 +1149,7 @@ static int acurite_590tx_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
data_t *data;
|
||||
uint8_t *b;
|
||||
int row;
|
||||
int sensor_id; // the sensor ID - basically a random number that gets reset whenever the battery is removed
|
||||
int sensor_id; // the sensor ID - basically a random number that gets reset whenever the battery is removed
|
||||
int battery_ok; // the battery status: 1 is good, 0 is low
|
||||
int channel;
|
||||
int humidity;
|
||||
|
@ -1207,7 +1205,7 @@ static int acurite_590tx_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
else
|
||||
humidity = -1;
|
||||
|
||||
/* clang-format off */
|
||||
/* clang-format off */
|
||||
data = data_make(
|
||||
"model", "", DATA_STRING, "Acurite-590TX",
|
||||
"id", "", DATA_INT, sensor_id,
|
||||
|
@ -1496,7 +1494,7 @@ r_device acurite_00275rm = {
|
|||
|
||||
r_device acurite_590tx = {
|
||||
.name = "Acurite 590TX Temperature with optional Humidity",
|
||||
.modulation = OOK_PULSE_PPM, //OOK_PULSE_PWM,
|
||||
.modulation = OOK_PULSE_PPM, // OOK_PULSE_PWM,
|
||||
.short_width = 500, // short pulse is 232 us
|
||||
.long_width = 1500, // long pulse is 420 us
|
||||
.gap_limit = 1484, // long gap is 384 us, sync gap is 592 us
|
||||
|
|
|
@ -32,19 +32,19 @@ static int akhan_rke_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
return DECODE_ABORT_LENGTH;
|
||||
b = bitbuffer->bb[0];
|
||||
|
||||
//invert bits, short pulse is 0, long pulse is 1
|
||||
// invert bits, short pulse is 0, long pulse is 1
|
||||
b[0] = ~b[0];
|
||||
b[1] = ~b[1];
|
||||
b[2] = ~b[2];
|
||||
|
||||
id = (b[0] << 12) | (b[1] << 4) | (b[2] >> 4);
|
||||
id = (b[0] << 12) | (b[1] << 4) | (b[2] >> 4);
|
||||
cmd = b[2] & 0x0F;
|
||||
switch (cmd) {
|
||||
case 0x1: cmd_str = "0x1 (Lock)"; break;
|
||||
case 0x2: cmd_str = "0x2 (Unlock)"; break;
|
||||
case 0x4: cmd_str = "0x4 (Mute)"; break;
|
||||
case 0x8: cmd_str = "0x8 (Alarm)"; break;
|
||||
default: cmd_str = NULL; break;
|
||||
case 0x1: cmd_str = "0x1 (Lock)"; break;
|
||||
case 0x2: cmd_str = "0x2 (Unlock)"; break;
|
||||
case 0x4: cmd_str = "0x4 (Mute)"; break;
|
||||
case 0x8: cmd_str = "0x8 (Alarm)"; break;
|
||||
default: cmd_str = NULL; break;
|
||||
}
|
||||
|
||||
if (!cmd_str)
|
||||
|
|
|
@ -135,15 +135,15 @@ static int alectov1_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
// Wind sensor
|
||||
int skip = -1;
|
||||
// Untested code written according to the specification, may not decode correctly
|
||||
if ((b[1]&0xe) == 0x8 && b[2] == 0) {
|
||||
if ((b[1] & 0xe) == 0x8 && b[2] == 0) {
|
||||
skip = 0;
|
||||
}
|
||||
else if ((b[1]&0xe) == 0xe) {
|
||||
else if ((b[1] & 0xe) == 0xe) {
|
||||
skip = 4;
|
||||
} //According to supplied data!
|
||||
} // According to supplied data!
|
||||
if (skip >= 0) {
|
||||
double speed = reverse8(bb[1 + skip][3]);
|
||||
double gust = reverse8(bb[5 + skip][3]);
|
||||
double speed = reverse8(bb[1 + skip][3]);
|
||||
double gust = reverse8(bb[5 + skip][3]);
|
||||
int direction = (reverse8(bb[5 + skip][2]) << 1) | (bb[5 + skip][1] & 0x1);
|
||||
|
||||
/* clang-format off */
|
||||
|
|
|
@ -31,9 +31,9 @@ static int ambient_weather_decode(r_device *decoder, bitbuffer_t *bitbuffer, uns
|
|||
int humidity;
|
||||
data_t *data;
|
||||
|
||||
bitbuffer_extract_bytes(bitbuffer, row, bitpos, b, 6*8);
|
||||
bitbuffer_extract_bytes(bitbuffer, row, bitpos, b, 6 * 8);
|
||||
|
||||
uint8_t expected = b[5];
|
||||
uint8_t expected = b[5];
|
||||
uint8_t calculated = lfsr_digest8(b, 5, 0x98, 0x3e) ^ 0x64;
|
||||
|
||||
if (expected != calculated) {
|
||||
|
@ -44,12 +44,12 @@ static int ambient_weather_decode(r_device *decoder, bitbuffer_t *bitbuffer, uns
|
|||
}
|
||||
|
||||
// int model_number = b[0] & 0x0F; // fixed 0x05, at least for "SwitchDoc Labs F016TH"
|
||||
deviceID = b[1];
|
||||
deviceID = b[1];
|
||||
isBatteryLow = (b[2] & 0x80) != 0; // if not zero, battery is low
|
||||
channel = ((b[2] & 0x70) >> 4) + 1;
|
||||
int temp_f = ((b[2] & 0x0f) << 8) | b[3];
|
||||
temperature = (temp_f - 400) * 0.1f;
|
||||
humidity = b[4];
|
||||
channel = ((b[2] & 0x70) >> 4) + 1;
|
||||
int temp_f = ((b[2] & 0x0f) << 8) | b[3];
|
||||
temperature = (temp_f - 400) * 0.1f;
|
||||
humidity = b[4];
|
||||
|
||||
/* clang-format off */
|
||||
data = data_make(
|
||||
|
@ -89,14 +89,16 @@ static int ambient_weather_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
while ((bitpos = bitbuffer_search(bitbuffer, row, bitpos, preamble_pattern, 12)) + 8 + 6 * 8 <=
|
||||
bitbuffer->bits_per_row[row]) {
|
||||
ret = ambient_weather_decode(decoder, bitbuffer, row, bitpos + 8);
|
||||
if (ret > 0) return ret; // for now, break after first successful message
|
||||
if (ret > 0)
|
||||
return ret; // for now, break after first successful message
|
||||
bitpos += 16;
|
||||
}
|
||||
bitpos = 0;
|
||||
while ((bitpos = bitbuffer_search(bitbuffer, row, bitpos, preamble_inverted, 12)) + 8 + 6 * 8 <=
|
||||
bitbuffer->bits_per_row[row]) {
|
||||
ret = ambient_weather_decode(decoder, bitbuffer, row, bitpos + 8);
|
||||
if (ret > 0) return ret; // for now, break after first successful message
|
||||
if (ret > 0)
|
||||
return ret; // for now, break after first successful message
|
||||
bitpos += 15;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ static uint8_t tx8300_chk(uint8_t *b)
|
|||
x += (b[i] & 0xF) + ((b[i] & 0xF0) >> 4);
|
||||
y += (b[i] & 0x5) + ((b[i] & 0x50) >> 4);
|
||||
}
|
||||
uint8_t c0 = (~(x & 0xF)) & 0xF;
|
||||
uint8_t c0 = (~(x & 0xF)) & 0xF;
|
||||
uint8_t c1 = (~(y & 0xF)) & 0xF;
|
||||
return c0 << 4 | c1;
|
||||
}
|
||||
|
|
|
@ -252,7 +252,7 @@ static int ambientweather_whx_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
continue; // DECODE_FAIL_MIC
|
||||
}
|
||||
|
||||
id = b[1];
|
||||
id = b[1];
|
||||
int unknown = b[2];
|
||||
int year = ((b[3] & 0xF0) >> 4) * 10 + (b[3] & 0x0F) + 2000;
|
||||
int month = ((b[4] & 0x10) >> 4) * 10 + (b[4] & 0x0F);
|
||||
|
|
|
@ -38,8 +38,8 @@ static int auriol_4ld5661_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
continue;
|
||||
}
|
||||
|
||||
uint8_t *b = bitbuffer->bb[i];
|
||||
int id = b[0];
|
||||
uint8_t *b = bitbuffer->bb[i];
|
||||
int id = b[0];
|
||||
int batt_ok = b[1] >> 7;
|
||||
|
||||
if (b[3] != 0xf0 || (b[1] & 0x70) != 0) {
|
||||
|
@ -51,7 +51,7 @@ static int auriol_4ld5661_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
float temp_c = (temp_raw >> 4) * 0.1F;
|
||||
|
||||
int rain_raw = (b[4] << 12) | (b[5] << 4) | b[6] >> 4;
|
||||
float rain = rain_raw * 0.3F;
|
||||
float rain = rain_raw * 0.3F;
|
||||
|
||||
/* clang-format off */
|
||||
data_t *data = data_make(
|
||||
|
|
|
@ -54,36 +54,36 @@ Bitbuffer example from rtl_433 -a:
|
|||
|
||||
#define LEN 8
|
||||
|
||||
static uint8_t lsrc( uint8_t frame[], int len )
|
||||
static uint8_t lsrc(uint8_t frame[], int len)
|
||||
{
|
||||
uint8_t result = 0 ;
|
||||
uint8_t key = KEY ;
|
||||
uint8_t result = 0;
|
||||
uint8_t key = KEY;
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
uint8_t byte = frame[i] ;
|
||||
for (int i = 0; i < len; i++) {
|
||||
uint8_t byte = frame[i];
|
||||
|
||||
for (uint8_t mask = 0x80; mask > 0; mask >>= 1) {
|
||||
if ((byte & mask) != 0)
|
||||
result ^= key ;
|
||||
for (uint8_t mask = 0x80; mask > 0; mask >>= 1) {
|
||||
if ((byte & mask) != 0)
|
||||
result ^= key;
|
||||
|
||||
if ((key & 1) != 0)
|
||||
key = (key >> 1) ^ GEN ;
|
||||
else
|
||||
key = (key >> 1) ;
|
||||
}
|
||||
}
|
||||
if ((key & 1) != 0)
|
||||
key = (key >> 1) ^ GEN;
|
||||
else
|
||||
key = (key >> 1);
|
||||
}
|
||||
}
|
||||
|
||||
return result ;
|
||||
return result;
|
||||
}
|
||||
|
||||
static int search_row( bitbuffer_t *bitbuffer )
|
||||
static int search_row(bitbuffer_t *bitbuffer)
|
||||
{
|
||||
for (int row = 0; row < bitbuffer->num_rows; row++) {
|
||||
if (bitbuffer->bits_per_row[row] == 68)
|
||||
return row ;
|
||||
}
|
||||
for (int row = 0; row < bitbuffer->num_rows; row++) {
|
||||
if (bitbuffer->bits_per_row[row] == 68)
|
||||
return row;
|
||||
}
|
||||
|
||||
return -1 ;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int auriol_aft77_b2_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
|
@ -91,38 +91,38 @@ static int auriol_aft77_b2_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
data_t *data;
|
||||
|
||||
// Search a suitable row in the bit buffer
|
||||
int row = search_row( bitbuffer );
|
||||
int row = search_row(bitbuffer);
|
||||
|
||||
// Check if found
|
||||
if (row == -1)
|
||||
return DECODE_ABORT_EARLY;
|
||||
return DECODE_ABORT_EARLY;
|
||||
|
||||
uint8_t *ptr = bitbuffer->bb[row];
|
||||
|
||||
// Check the prefix
|
||||
if (*ptr != 0xA5)
|
||||
return DECODE_ABORT_EARLY;
|
||||
return DECODE_ABORT_EARLY;
|
||||
|
||||
uint8_t frame[LEN];
|
||||
|
||||
// Drop the prefix and align the bytes
|
||||
for (int i = 0; i < LEN; i++)
|
||||
frame[i] = (ptr[i] << 4) | (ptr[i+1] >> 4);
|
||||
frame[i] = (ptr[i] << 4) | (ptr[i + 1] >> 4);
|
||||
|
||||
// Check the sum
|
||||
if ((uint8_t)add_bytes(frame,6) != frame[6])
|
||||
return DECODE_FAIL_MIC;
|
||||
if ((uint8_t)add_bytes(frame, 6) != frame[6])
|
||||
return DECODE_FAIL_MIC;
|
||||
|
||||
// Check the lsrc
|
||||
if (lsrc(frame,6) != frame[7])
|
||||
return DECODE_FAIL_MIC;
|
||||
if (lsrc(frame, 6) != frame[7])
|
||||
return DECODE_FAIL_MIC;
|
||||
|
||||
int id = frame[1];
|
||||
int id = frame[1];
|
||||
|
||||
int temp_raw = (ptr[4] >> 4) * 100 + (ptr[4] & 0x0F) * 10 + (ptr[5] >> 4);
|
||||
|
||||
if ((ptr[3] & 0x08) != 0)
|
||||
temp_raw = -temp_raw;
|
||||
temp_raw = -temp_raw;
|
||||
|
||||
/* clang-format off */
|
||||
data = data_make(
|
||||
|
|
|
@ -71,12 +71,12 @@ static int auriol_afw2a1_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
|
||||
b = bitbuffer->bb[row];
|
||||
|
||||
id = b[0];
|
||||
battery_ok = b[1] >> 7;
|
||||
tx_button = (b[1] & 0x40) >> 6;
|
||||
channel = (b[1] & 0x30) >> 4;
|
||||
temp_raw = (int16_t)(((b[1] & 0x0f) << 12) | (b[2] << 4)); // uses sign extend
|
||||
temp_c = (temp_raw >> 4) * 0.1f;
|
||||
id = b[0];
|
||||
battery_ok = b[1] >> 7;
|
||||
tx_button = (b[1] & 0x40) >> 6;
|
||||
channel = (b[1] & 0x30) >> 4;
|
||||
temp_raw = (int16_t)(((b[1] & 0x0f) << 12) | (b[2] << 4)); // uses sign extend
|
||||
temp_c = (temp_raw >> 4) * 0.1f;
|
||||
// 0xa is fixed. If it differs, it is a wrong device. Could anyone confirm that?
|
||||
if ((b[3] >> 4) != 0xa) {
|
||||
if (decoder->verbose) {
|
||||
|
|
|
@ -55,29 +55,29 @@ static int auriol_ahfl_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
b = bitbuffer->bb[row];
|
||||
|
||||
/* Check fixed message values */
|
||||
if (((b[4]&0xF0) != 0x40) || ((b[3]&0x1) != 0x0)) {
|
||||
if (((b[4] & 0xF0) != 0x40) || ((b[3] & 0x1) != 0x0)) {
|
||||
return DECODE_FAIL_SANITY;
|
||||
}
|
||||
|
||||
// calculate nibble sum
|
||||
nibble_sum = (b[0]&0xF) + (b[0]>>4) +
|
||||
(b[1]&0xF) + (b[1]>>4) +
|
||||
(b[2]&0xF) + (b[2]>>4) +
|
||||
(b[3]&0xF) + (b[3]>>4) +
|
||||
(b[4]>>4);
|
||||
checksum = ((b[4]&0xF) << 2) | ((b[5]&0xC0)>>6);
|
||||
nibble_sum = (b[0] & 0xF) + (b[0] >> 4) +
|
||||
(b[1] & 0xF) + (b[1] >> 4) +
|
||||
(b[2] & 0xF) + (b[2] >> 4) +
|
||||
(b[3] & 0xF) + (b[3] >> 4) +
|
||||
(b[4] >> 4);
|
||||
checksum = ((b[4] & 0xF) << 2) | ((b[5] & 0xC0) >> 6);
|
||||
|
||||
// check 6 bits of nibble sum
|
||||
if ((nibble_sum&0x3F) != checksum)
|
||||
if ((nibble_sum & 0x3F) != checksum)
|
||||
return DECODE_FAIL_MIC;
|
||||
|
||||
id = b[0];
|
||||
battery_ok = b[1] >> 7;
|
||||
channel = (b[1] & 0x30) >> 4;
|
||||
tx_button = (b[1] & 0x40) >> 6;
|
||||
temp_raw = (int16_t)(((b[1] & 0x0f) << 12) | (b[2] << 4)); // uses sign extend
|
||||
temp_c = (temp_raw >> 4) * 0.1f;
|
||||
humidity = b[3] >> 1;
|
||||
id = b[0];
|
||||
battery_ok = b[1] >> 7;
|
||||
channel = (b[1] & 0x30) >> 4;
|
||||
tx_button = (b[1] & 0x40) >> 6;
|
||||
temp_raw = (int16_t)(((b[1] & 0x0f) << 12) | (b[2] << 4)); // uses sign extend
|
||||
temp_c = (temp_raw >> 4) * 0.1f;
|
||||
humidity = b[3] >> 1;
|
||||
|
||||
/* clang-format off */
|
||||
data = data_make(
|
||||
|
|
|
@ -56,7 +56,7 @@ static int auriol_hg02832_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
|
||||
// They tried to implement CRC-8 poly 0x31, but (accidentally?) reset the key every new byte.
|
||||
// (equivalent key stream is 7a 3d 86 43 b9 c4 62 31 repeated 4 times.)
|
||||
uint8_t d0 = b[0] ^ b[1] ^ b[2] ^ b[3];
|
||||
uint8_t d0 = b[0] ^ b[1] ^ b[2] ^ b[3];
|
||||
uint8_t chk = crc8(&d0, 1, 0x31, 0x53) ^ b[4];
|
||||
|
||||
if (chk)
|
||||
|
@ -70,7 +70,7 @@ static int auriol_hg02832_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
channel = (b[2] & 0x30) >> 4;
|
||||
|
||||
temp_raw = (int16_t)(((b[2] & 0x0f) << 12) | (b[3] << 4)); // uses sign extend
|
||||
temp_c = (temp_raw >> 4) * 0.1f;
|
||||
temp_c = (temp_raw >> 4) * 0.1f;
|
||||
|
||||
/* clang-format off */
|
||||
data = data_make(
|
||||
|
|
|
@ -155,7 +155,8 @@ struct blueline_stateful_context {
|
|||
unsigned searching_for_new_id;
|
||||
};
|
||||
|
||||
static uint8_t rev_crc8(uint8_t const message[], unsigned nBytes, uint8_t polynomial, uint8_t remainder) {
|
||||
static uint8_t rev_crc8(uint8_t const message[], unsigned nBytes, uint8_t polynomial, uint8_t remainder)
|
||||
{
|
||||
unsigned byte, bit;
|
||||
|
||||
// Run a CRC backwards to find out what the init value would have been.
|
||||
|
@ -165,7 +166,7 @@ static uint8_t rev_crc8(uint8_t const message[], unsigned nBytes, uint8_t polyno
|
|||
// This logic only works assuming the polynomial has the lowest bit set,
|
||||
// Which should be true for most CRC polynomials, but let's be safe...
|
||||
if ((polynomial & 0x01) == 0) {
|
||||
fprintf(stderr,"Cannot run reverse CRC-8 with this polynomial!\n");
|
||||
fprintf(stderr, "Cannot run reverse CRC-8 with this polynomial!\n");
|
||||
return 0xFF;
|
||||
}
|
||||
polynomial = (polynomial >> 1) | 0x80;
|
||||
|
@ -176,10 +177,10 @@ static uint8_t rev_crc8(uint8_t const message[], unsigned nBytes, uint8_t polyno
|
|||
while (bit--) {
|
||||
if (remainder & 0x01) {
|
||||
remainder = (remainder >> 1) ^ polynomial;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
remainder = remainder >> 1;
|
||||
}
|
||||
|
||||
}
|
||||
remainder ^= message[byte];
|
||||
}
|
||||
|
@ -417,7 +418,7 @@ static r_device *blueline_create(char *arg)
|
|||
free(r_dev);
|
||||
return NULL; // NOTE: returns NULL on alloc failure.
|
||||
}
|
||||
memset(context,0,sizeof(*context));
|
||||
memset(context, 0, sizeof(*context));
|
||||
r_dev->decode_ctx = context;
|
||||
|
||||
if (arg != NULL) {
|
||||
|
|
|
@ -78,7 +78,8 @@ static int brennenstuhl_rcs_2044_process_row(r_device *decoder, bitbuffer_t *bit
|
|||
key = "D";
|
||||
else if (control_key == 0x01)
|
||||
key = "E"; /* (does not exist on the remote, but can be set and is accepted by receiver) */
|
||||
else return 0;
|
||||
else
|
||||
return 0;
|
||||
/* None of the keys has been pressed and we still received a message.
|
||||
* Skip it. It happens sometimes as the last code repetition
|
||||
*/
|
||||
|
|
|
@ -51,7 +51,7 @@ static int bresser_7in1_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
data_t *data;
|
||||
uint8_t msg[25];
|
||||
|
||||
if (bitbuffer->num_rows != 1 || bitbuffer->bits_per_row[0] < 240-80) {
|
||||
if (bitbuffer->num_rows != 1 || bitbuffer->bits_per_row[0] < 240 - 80) {
|
||||
if (decoder->verbose > 1)
|
||||
fprintf(stderr, "%s: to few bits (%u)\n", __func__, bitbuffer->bits_per_row[0]);
|
||||
return DECODE_ABORT_LENGTH; // unrecognized
|
||||
|
|
|
@ -51,15 +51,15 @@ static int bt_rain_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
if (b[0] == 0xff && b[1] == 0xff && b[2] == 0xff && b[3] == 0xff)
|
||||
return DECODE_FAIL_SANITY; // prevent false positive checksum
|
||||
|
||||
id = b[0];
|
||||
battery = b[1] >> 7;
|
||||
channel = ((b[1] & 0x30) >> 4) + 1; // either this or the rain top bits could be wrong
|
||||
button = (b[1] & 0x08) >> 3;
|
||||
id = b[0];
|
||||
battery = b[1] >> 7;
|
||||
channel = ((b[1] & 0x30) >> 4) + 1; // either this or the rain top bits could be wrong
|
||||
button = (b[1] & 0x08) >> 3;
|
||||
|
||||
temp_raw = (int16_t)(((b[1] & 0x07) << 13) | (b[2] << 5)); // uses sign extend
|
||||
temp_c = (temp_raw >> 5) * 0.1f;
|
||||
temp_c = (temp_raw >> 5) * 0.1f;
|
||||
|
||||
rain = ((b[1] & 0x07) << 4) | b[3]; // either b[1] or the channel above bould be wrong
|
||||
rain = ((b[1] & 0x07) << 4) | b[3]; // either b[1] or the channel above bould be wrong
|
||||
int rest = rain % 25;
|
||||
if (rest % 2)
|
||||
rain += ((rest / 2) * 2048);
|
||||
|
|
|
@ -74,26 +74,26 @@ static int burnhardbbq_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
sprintf(timer_str, "%02x:%02x", b[3], b[4] & 0x7f);
|
||||
|
||||
char *meat;
|
||||
switch(b[5] >> 4) {
|
||||
case 0: meat = "free"; break;
|
||||
case 1: meat = "beef"; break;
|
||||
case 2: meat = "veal"; break;
|
||||
case 3: meat = "pork"; break;
|
||||
case 4: meat = "chicken"; break;
|
||||
case 5: meat = "lamb"; break;
|
||||
case 6: meat = "fish"; break;
|
||||
case 7: meat = "ham"; break;
|
||||
default: meat = "";
|
||||
switch (b[5] >> 4) {
|
||||
case 0: meat = "free"; break;
|
||||
case 1: meat = "beef"; break;
|
||||
case 2: meat = "veal"; break;
|
||||
case 3: meat = "pork"; break;
|
||||
case 4: meat = "chicken"; break;
|
||||
case 5: meat = "lamb"; break;
|
||||
case 6: meat = "fish"; break;
|
||||
case 7: meat = "ham"; break;
|
||||
default: meat = "";
|
||||
}
|
||||
|
||||
char *taste;
|
||||
switch(b[5] & 0x0f) {
|
||||
case 0: taste = "rare"; break;
|
||||
case 1: taste = "medium rare"; break;
|
||||
case 2: taste = "medium"; break;
|
||||
case 3: taste = "medium well"; break;
|
||||
case 4: taste = "well done"; break;
|
||||
default: taste = "";
|
||||
switch (b[5] & 0x0f) {
|
||||
case 0: taste = "rare"; break;
|
||||
case 1: taste = "medium rare"; break;
|
||||
case 2: taste = "medium"; break;
|
||||
case 3: taste = "medium well"; break;
|
||||
case 4: taste = "well done"; break;
|
||||
default: taste = "";
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
|
|
|
@ -84,26 +84,26 @@ static int cavius_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
|
||||
char *text = "Unknown";
|
||||
switch (message) {
|
||||
case cavius_alarm:
|
||||
text = "Fire alarm";
|
||||
break;
|
||||
case cavius_mute:
|
||||
text = "Alarm muted";
|
||||
break;
|
||||
case cavius_pairing:
|
||||
text = "Pairing";
|
||||
break;
|
||||
case cavius_test:
|
||||
text = "Test alarm";
|
||||
break;
|
||||
case cavius_warning:
|
||||
text = "Warning/Water detected";
|
||||
break;
|
||||
case cavius_battlow:
|
||||
text = "Battery low";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case cavius_alarm:
|
||||
text = "Fire alarm";
|
||||
break;
|
||||
case cavius_mute:
|
||||
text = "Alarm muted";
|
||||
break;
|
||||
case cavius_pairing:
|
||||
text = "Pairing";
|
||||
break;
|
||||
case cavius_test:
|
||||
text = "Test alarm";
|
||||
break;
|
||||
case cavius_warning:
|
||||
text = "Warning/Water detected";
|
||||
break;
|
||||
case cavius_battlow:
|
||||
text = "Battery low";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
|
|
|
@ -28,7 +28,6 @@ Note: simple 24 bit fixed ID protocol (x1527 style) and should be handled by the
|
|||
|
||||
*/
|
||||
|
||||
|
||||
#include "decoder.h"
|
||||
|
||||
static int chuango_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
|
@ -48,31 +47,31 @@ static int chuango_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
b[2] = ~b[2];
|
||||
|
||||
// Validate package
|
||||
if (!(b[3] & 0x80) // Last bit (MSB here) is always 1
|
||||
|| !b[0] || !b[1] || !(b[2] & 0xF0)) // Reduce false positives. ID 0x00000 not supported
|
||||
if (!(b[3] & 0x80) // Last bit (MSB here) is always 1
|
||||
|| !b[0] || !b[1] || !(b[2] & 0xF0)) // Reduce false positives. ID 0x00000 not supported
|
||||
return DECODE_ABORT_EARLY;
|
||||
|
||||
id = (b[0] << 12) | (b[1] << 4) | (b[2] >> 4); // ID is 20 bits (Ad: "1 Million combinations" :-)
|
||||
id = (b[0] << 12) | (b[1] << 4) | (b[2] >> 4); // ID is 20 bits (Ad: "1 Million combinations" :-)
|
||||
cmd = b[2] & 0x0F;
|
||||
|
||||
switch(cmd) {
|
||||
case 0xF: cmd_str = "?"; break;
|
||||
case 0xE: cmd_str = "?"; break;
|
||||
case 0xD: cmd_str = "Low Battery"; break;
|
||||
case 0xC: cmd_str = "?"; break;
|
||||
case 0xB: cmd_str = "24H Zone"; break;
|
||||
case 0xA: cmd_str = "Single Delay Zone"; break;
|
||||
case 0x9: cmd_str = "?"; break;
|
||||
case 0x8: cmd_str = "Arm"; break;
|
||||
case 0x7: cmd_str = "Normal Zone"; break;
|
||||
case 0x6: cmd_str = "Home Mode Zone"; break;
|
||||
case 0x5: cmd_str = "On"; break;
|
||||
case 0x4: cmd_str = "Home Mode"; break;
|
||||
case 0x3: cmd_str = "Tamper"; break;
|
||||
case 0x2: cmd_str = "Alarm"; break;
|
||||
case 0x1: cmd_str = "Disarm"; break;
|
||||
case 0x0: cmd_str = "Test"; break;
|
||||
default: cmd_str = ""; break;
|
||||
switch (cmd) {
|
||||
case 0xF: cmd_str = "?"; break;
|
||||
case 0xE: cmd_str = "?"; break;
|
||||
case 0xD: cmd_str = "Low Battery"; break;
|
||||
case 0xC: cmd_str = "?"; break;
|
||||
case 0xB: cmd_str = "24H Zone"; break;
|
||||
case 0xA: cmd_str = "Single Delay Zone"; break;
|
||||
case 0x9: cmd_str = "?"; break;
|
||||
case 0x8: cmd_str = "Arm"; break;
|
||||
case 0x7: cmd_str = "Normal Zone"; break;
|
||||
case 0x6: cmd_str = "Home Mode Zone"; break;
|
||||
case 0x5: cmd_str = "On"; break;
|
||||
case 0x4: cmd_str = "Home Mode"; break;
|
||||
case 0x3: cmd_str = "Tamper"; break;
|
||||
case 0x2: cmd_str = "Alarm"; break;
|
||||
case 0x1: cmd_str = "Disarm"; break;
|
||||
case 0x0: cmd_str = "Test"; break;
|
||||
default: cmd_str = ""; break;
|
||||
}
|
||||
|
||||
data = data_make(
|
||||
|
|
|
@ -80,12 +80,12 @@ static int cmr113_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
return DECODE_ABORT_LENGTH;
|
||||
}
|
||||
|
||||
if (b.bits_per_row[0] < 2*COMPARE_BITS + 2)
|
||||
if (b.bits_per_row[0] < 2 * COMPARE_BITS + 2)
|
||||
return DECODE_ABORT_LENGTH;
|
||||
|
||||
// Compare the repeated section to ensure data integrity
|
||||
bitbuffer_extract_bytes(&b, 0, 0, b1, COMPARE_BITS);
|
||||
bitbuffer_extract_bytes(&b, 0, COMPARE_BITS+2, b2, COMPARE_BITS);
|
||||
bitbuffer_extract_bytes(&b, 0, COMPARE_BITS + 2, b2, COMPARE_BITS);
|
||||
if (memcmp(b1, b2, COMPARE_BYTES) != 0)
|
||||
return DECODE_FAIL_MIC;
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ static int companion_wtr001_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
|
||||
// Shift these 7 bits around into the right order
|
||||
// bin2dec(bits 12,7,6,11,10,9,8)
|
||||
uint8_t temp_whole_raw = reverse8(b[1]&0xf0) | reverse8(b[0]&0x03)>>2 | (b[1]&0x08)<<3;
|
||||
uint8_t temp_whole_raw = reverse8(b[1] & 0xf0) | reverse8(b[0] & 0x03) >> 2 | (b[1] & 0x08) << 3;
|
||||
|
||||
if (temp_whole_raw < 11) {
|
||||
// Value is too low (outside published specs)
|
||||
|
|
|
@ -87,21 +87,21 @@ static int current_cost_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
}
|
||||
// Counter (b[0] = 0100xxxx) bits 5 and 4 are "unknown", but always 0 to date.
|
||||
else if ((b[0] & 0xf0) == 64) {
|
||||
uint16_t device_id = (b[0] & 0x0f) << 8 | b[1];
|
||||
// b[2] is "Apparently unused"
|
||||
uint16_t sensor_type = b[3]; //Sensor type. Valid values are: 2-Electric, 3-Gas, 4-Water
|
||||
uint32_t c_impulse = (unsigned)b[4] << 24 | b[5] <<16 | b[6] <<8 | b[7];
|
||||
/* clang-format off */
|
||||
data = data_make(
|
||||
uint16_t device_id = (b[0] & 0x0f) << 8 | b[1];
|
||||
// b[2] is "Apparently unused"
|
||||
uint16_t sensor_type = b[3]; // Sensor type. Valid values are: 2-Electric, 3-Gas, 4-Water
|
||||
uint32_t c_impulse = (unsigned)b[4] << 24 | b[5] << 16 | b[6] << 8 | b[7];
|
||||
/* clang-format off */
|
||||
data = data_make(
|
||||
"model", "", DATA_STRING, is_envir ? "CurrentCost-EnviRCounter" : "CurrentCost-Counter", //TODO: it may have different CC Model ? any ref ?
|
||||
"subtype", "Sensor Id", DATA_FORMAT, "%d", DATA_INT, sensor_type, //Could "friendly name" this?
|
||||
"id", "Device Id", DATA_FORMAT, "%d", DATA_INT, device_id,
|
||||
//"counter", "Counter", DATA_FORMAT, "%d", DATA_INT, c_impulse,
|
||||
"power0", "Counter", DATA_FORMAT, "%d", DATA_INT, c_impulse,
|
||||
NULL);
|
||||
/* clang-format on */
|
||||
decoder_output_data(decoder, data);
|
||||
return 1;
|
||||
/* clang-format on */
|
||||
decoder_output_data(decoder, data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -51,40 +51,39 @@ Nibble content:
|
|||
static const uint8_t HEADER[] = { 0x36, 0x5c }; // Encoded prefix. Full prefix is 3 nibbles => 18 bits (but checking 16 is ok)
|
||||
|
||||
// Mapping from 6 bits to 4 bits
|
||||
static uint8_t danfoss_decode_nibble(uint8_t byte) {
|
||||
static uint8_t danfoss_decode_nibble(uint8_t byte)
|
||||
{
|
||||
uint8_t out = 0xFF; // Error
|
||||
switch(byte) {
|
||||
case 0x0B: out = 0xD; break;
|
||||
case 0x0D: out = 0xE; break;
|
||||
case 0x0E: out = 0x3; break;
|
||||
case 0x13: out = 0x4; break;
|
||||
case 0x15: out = 0xA; break;
|
||||
case 0x16: out = 0xF; break;
|
||||
case 0x19: out = 0x9; break;
|
||||
case 0x1A: out = 0x6; break;
|
||||
case 0x25: out = 0x0; break;
|
||||
case 0x26: out = 0x7; break;
|
||||
case 0x29: out = 0x1; break;
|
||||
case 0x2A: out = 0x5; break;
|
||||
case 0x2C: out = 0xC; break;
|
||||
case 0x31: out = 0xB; break;
|
||||
case 0x32: out = 0x2; break;
|
||||
case 0x34: out = 0x8; break;
|
||||
default: break; // Error
|
||||
switch (byte) {
|
||||
case 0x0B: out = 0xD; break;
|
||||
case 0x0D: out = 0xE; break;
|
||||
case 0x0E: out = 0x3; break;
|
||||
case 0x13: out = 0x4; break;
|
||||
case 0x15: out = 0xA; break;
|
||||
case 0x16: out = 0xF; break;
|
||||
case 0x19: out = 0x9; break;
|
||||
case 0x1A: out = 0x6; break;
|
||||
case 0x25: out = 0x0; break;
|
||||
case 0x26: out = 0x7; break;
|
||||
case 0x29: out = 0x1; break;
|
||||
case 0x2A: out = 0x5; break;
|
||||
case 0x2C: out = 0xC; break;
|
||||
case 0x31: out = 0xB; break;
|
||||
case 0x32: out = 0x2; break;
|
||||
case 0x34: out = 0x8; break;
|
||||
default: break; // Error
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
static int danfoss_cfr_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
{
|
||||
uint8_t bytes[NUM_BYTES]; // Decoded bytes with two 4 bit nibbles in each
|
||||
uint8_t bytes[NUM_BYTES]; // Decoded bytes with two 4 bit nibbles in each
|
||||
data_t *data;
|
||||
|
||||
|
||||
// Validate package
|
||||
unsigned bits = bitbuffer->bits_per_row[0];
|
||||
if (bits >= 246 && bits <= 260) { // Normal size is 255, but allow for some noise in preamble
|
||||
if (bits >= 246 && bits <= 260) { // Normal size is 255, but allow for some noise in preamble
|
||||
// Find a package
|
||||
unsigned bit_offset = bitbuffer_search(bitbuffer, 0, 112, HEADER, sizeof(HEADER)*8); // Normal index is 128, skip first 14 bytes to find faster
|
||||
if (bits-bit_offset < 126) { // Package should be at least 126 bits
|
||||
|
@ -94,12 +93,12 @@ static int danfoss_cfr_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
}
|
||||
return DECODE_ABORT_LENGTH;
|
||||
}
|
||||
bit_offset += 6; // Skip first nibble 0xE to get byte alignment and remove from CRC calculation
|
||||
bit_offset += 6; // Skip first nibble 0xE to get byte alignment and remove from CRC calculation
|
||||
|
||||
// Decode input 6 bit nibbles to output 4 bit nibbles (packed in bytes)
|
||||
for (unsigned n=0; n<NUM_BYTES; ++n) {
|
||||
uint8_t nibble_h = danfoss_decode_nibble(bitrow_get_byte(bitbuffer->bb[0], n*12+bit_offset) >> 2);
|
||||
uint8_t nibble_l = danfoss_decode_nibble(bitrow_get_byte(bitbuffer->bb[0], n*12+bit_offset+6) >> 2);
|
||||
for (unsigned n = 0; n < NUM_BYTES; ++n) {
|
||||
uint8_t nibble_h = danfoss_decode_nibble(bitrow_get_byte(bitbuffer->bb[0], n * 12 + bit_offset) >> 2);
|
||||
uint8_t nibble_l = danfoss_decode_nibble(bitrow_get_byte(bitbuffer->bb[0], n * 12 + bit_offset + 6) >> 2);
|
||||
if (nibble_h > 0xF || nibble_l > 0xF) {
|
||||
if (decoder->verbose) {
|
||||
fprintf(stderr, "Danfoss: 6b/4b decoding error\n");
|
||||
|
@ -133,14 +132,14 @@ static int danfoss_cfr_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
|
||||
char *str_sw;
|
||||
switch (bytes[3] & 0x0F) {
|
||||
case 2: str_sw = "DAY"; break;
|
||||
case 4: str_sw = "TIMER"; break;
|
||||
case 8: str_sw = "NIGHT"; break;
|
||||
default: str_sw = "ERROR";
|
||||
case 2: str_sw = "DAY"; break;
|
||||
case 4: str_sw = "TIMER"; break;
|
||||
case 8: str_sw = "NIGHT"; break;
|
||||
default: str_sw = "ERROR";
|
||||
}
|
||||
|
||||
float temp_meas = (float)bytes[5] + (float)bytes[4] / 256.0;
|
||||
float temp_setp = (float)bytes[7] + (float)bytes[6] / 256.0;
|
||||
float temp_meas = (float)bytes[5] + (float)bytes[4] / 256.0;
|
||||
float temp_setp = (float)bytes[7] + (float)bytes[6] / 256.0;
|
||||
|
||||
// Output data
|
||||
data = data_make(
|
||||
|
|
|
@ -94,7 +94,6 @@ Notes:
|
|||
|
||||
*/
|
||||
|
||||
|
||||
#include "decoder.h"
|
||||
|
||||
#define DSC_CT_MSGLEN 5
|
||||
|
@ -116,7 +115,7 @@ static int dsc_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
int result = 0;
|
||||
|
||||
for (int row = 0; row < bitbuffer->num_rows; row++) {
|
||||
if (decoder->verbose > 1 && bitbuffer->bits_per_row[row] > 0 ) {
|
||||
if (decoder->verbose > 1 && bitbuffer->bits_per_row[row] > 0) {
|
||||
fprintf(stderr, "%s: row %d bit count %d\n", __func__,
|
||||
row, bitbuffer->bits_per_row[row]);
|
||||
}
|
||||
|
@ -211,7 +210,6 @@ static int dsc_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
sprintf(status_str, "%02x", status);
|
||||
sprintf(esn_str, "%06x", esn);
|
||||
|
||||
|
||||
/* clang-format off */
|
||||
data = data_make(
|
||||
"model", "", DATA_STRING, "DSC-Security",
|
||||
|
|
|
@ -118,10 +118,10 @@ static char *output_fields[] = {
|
|||
r_device ecowitt = {
|
||||
.name = "Ecowitt Wireless Outdoor Thermometer WH53/WH0280/WH0281A",
|
||||
.modulation = OOK_PULSE_PWM,
|
||||
.short_width = 500, // 500 us nominal short pulse
|
||||
.long_width = 1480, // 1480 us nominal long pulse
|
||||
.gap_limit = 1500, // 960 us nominal fixed gap
|
||||
.reset_limit = 2000, // 31 ms packet distance (too far apart)
|
||||
.short_width = 500, // 500 us nominal short pulse
|
||||
.long_width = 1480, // 1480 us nominal long pulse
|
||||
.gap_limit = 1500, // 960 us nominal fixed gap
|
||||
.reset_limit = 2000, // 31 ms packet distance (too far apart)
|
||||
.sync_width = 0,
|
||||
.decode_fn = &ecowitt_decode,
|
||||
.fields = output_fields,
|
||||
|
|
|
@ -55,7 +55,6 @@ static int efergy_e2_classic_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Sometimes pulses and gaps are mixed up. If this happens, invert
|
||||
// all bytes to get correct interpretation.
|
||||
if (bytes[0] & 0xf0) {
|
||||
|
@ -65,13 +64,12 @@ static int efergy_e2_classic_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
}
|
||||
|
||||
int zero_count = 0;
|
||||
for (int i=0; i<8; i++) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (bytes[i] == 0)
|
||||
zero_count++;
|
||||
}
|
||||
if (zero_count++ > 5)
|
||||
return DECODE_FAIL_SANITY; // too many Null bytes
|
||||
|
||||
return DECODE_FAIL_SANITY; // too many Null bytes
|
||||
|
||||
unsigned checksum = add_bytes(bytes, 7);
|
||||
|
||||
|
|
|
@ -99,16 +99,16 @@ static int efergy_optical_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
// - red led (every 30s): bytes[3]=64 (0100 0000)
|
||||
// - orange led (every 60s): bytes[3]=80 (0101 0000)
|
||||
// - green led (every 90s): bytes[3]=96 (0110 0000)
|
||||
seconds = (((bytes[3] & 0x30 ) >> 4 ) + 1) * 30.0;
|
||||
seconds = (((bytes[3] & 0x30) >> 4) + 1) * 30.0;
|
||||
|
||||
pulsecount = bytes[8];
|
||||
|
||||
energy = (((float)pulsecount/n_imp) * (3600/seconds));
|
||||
energy = (((float)pulsecount / n_imp) * (3600 / seconds));
|
||||
|
||||
//New code for calculating various energy values for differing pulse-kwh values
|
||||
// New code for calculating various energy values for differing pulse-kwh values
|
||||
const int imp_kwh[] = {4000, 3200, 2000, 1000, 500, 0};
|
||||
for (unsigned i = 0; imp_kwh[i] != 0; ++i) {
|
||||
energy = (((float)pulsecount/imp_kwh[i]) * (3600/seconds));
|
||||
energy = (((float)pulsecount / imp_kwh[i]) * (3600 / seconds));
|
||||
|
||||
/* clang-format off */
|
||||
data = data_make(
|
||||
|
|
|
@ -57,7 +57,7 @@ static int eurochron_efth800_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
|
||||
// This is actially a 0x00 packet error ( bitbuffer_invert )
|
||||
// No need to decode/extract values for simple test
|
||||
if ( b[0] == 0xff && b[1] == 0xff && b[2] == 0xFF && b[4] == 0xFF ) {
|
||||
if (b[0] == 0xff && b[1] == 0xff && b[2] == 0xFF && b[4] == 0xFF) {
|
||||
if (decoder->verbose > 1) {
|
||||
fprintf(stderr, "%s: DECODE_FAIL_SANITY data all 0xff\n", __func__);
|
||||
}
|
||||
|
@ -105,13 +105,13 @@ static char *output_fields[] = {
|
|||
};
|
||||
|
||||
r_device eurochron_efth800 = {
|
||||
.name = "Eurochron EFTH-800 temperature and humidity sensor",
|
||||
.modulation = OOK_PULSE_PWM,
|
||||
.short_width = 250,
|
||||
.long_width = 500,
|
||||
.sync_width = 750,
|
||||
.gap_limit = 900,
|
||||
.reset_limit = 5500,
|
||||
.decode_fn = &eurochron_efth800_decode,
|
||||
.fields = output_fields,
|
||||
.name = "Eurochron EFTH-800 temperature and humidity sensor",
|
||||
.modulation = OOK_PULSE_PWM,
|
||||
.short_width = 250,
|
||||
.long_width = 500,
|
||||
.sync_width = 750,
|
||||
.gap_limit = 900,
|
||||
.reset_limit = 5500,
|
||||
.decode_fn = &eurochron_efth800_decode,
|
||||
.fields = output_fields,
|
||||
};
|
||||
|
|
|
@ -22,14 +22,13 @@ packet gap is 7016 us
|
|||
Example code: 37f62a6c80
|
||||
*/
|
||||
|
||||
|
||||
#include "decoder.h"
|
||||
|
||||
static int elro_db286a_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
{
|
||||
data_t *data;
|
||||
uint8_t *b;
|
||||
char id_str[4*2+1];
|
||||
char id_str[4 * 2 + 1];
|
||||
|
||||
// 33 bits expected, 5 minimum packet repetitions (14 expected)
|
||||
int row = bitbuffer_find_repeated_row(bitbuffer, 5, 33);
|
||||
|
@ -50,7 +49,6 @@ static int elro_db286a_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
decoder_output_data(decoder, data);
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
static char *output_fields[] = {
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
(at your option) any later version.
|
||||
*/
|
||||
|
||||
|
||||
#include "decoder.h"
|
||||
|
||||
static uint16_t AD_POP(uint8_t *bb, uint8_t bits, uint8_t bit)
|
||||
|
@ -177,7 +176,7 @@ static int ws2000_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
float temp = ((dec[1] & 8) ? -1.0f : 1.0f) * (dec[4] * 10 + dec[3] + dec[2] * 0.1f);
|
||||
float humidity = dec[7] * 10 + dec[6] + dec[5] * 0.1f;
|
||||
int pressure = 0;
|
||||
if (dec[0]==4) {
|
||||
if (dec[0] == 4) {
|
||||
pressure = 200 + dec[10] * 100 + dec[9] * 10 + dec[8];
|
||||
}
|
||||
|
||||
|
|
|
@ -52,8 +52,8 @@ static int enocean_erp1_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
|
||||
bitbuffer_invert(bitbuffer);
|
||||
|
||||
uint8_t preamble[2] = { 0x55, 0x20 };
|
||||
unsigned start = bitbuffer_search(bitbuffer, 0, 0, preamble, 11);
|
||||
uint8_t preamble[2] = {0x55, 0x20};
|
||||
unsigned start = bitbuffer_search(bitbuffer, 0, 0, preamble, 11);
|
||||
if (start >= bitbuffer->bits_per_row[0])
|
||||
return DECODE_FAIL_SANITY;
|
||||
|
||||
|
@ -62,7 +62,7 @@ static int enocean_erp1_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
unsigned end = start + len;
|
||||
|
||||
bitbuffer_t bytes = {0};
|
||||
uint8_t more = 0x01;
|
||||
uint8_t more = 0x01;
|
||||
do {
|
||||
more = decode_8of12(bitbuffer->bb[0], pos, end, &bytes);
|
||||
pos += 12;
|
||||
|
|
|
@ -466,7 +466,6 @@ static int ert_netidm_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
if (decoder->verbose > 1)
|
||||
bitrow_printf(&b[13], 6 * 8, "%s TamperCounters_str %s\t", __func__, TamperCounters_str);
|
||||
|
||||
|
||||
// should this be included ?
|
||||
p = Unknown_field_1_str;
|
||||
strncpy(p, "0x", sizeof(Unknown_field_1_str));
|
||||
|
@ -549,7 +548,7 @@ static int ert_netidm_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
}
|
||||
*/
|
||||
|
||||
char *meter_type = get_meter_type_name(ERTType);
|
||||
char *meter_type = get_meter_type_name(ERTType);
|
||||
|
||||
// fprintf(stderr, "meter_type = %s\n", meter_type);
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ static int ert_scm_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
|
||||
// No need to decode/extract values for simple test
|
||||
// check id tamper type crc value not all zero'ed
|
||||
if ( !b[0] && !b[1] && !b[2] && !b[3] ) {
|
||||
if (!b[0] && !b[1] && !b[2] && !b[3]) {
|
||||
if (decoder->verbose > 1) {
|
||||
fprintf(stderr, "%s: DECODE_FAIL_SANITY data all 0x00\n", __func__);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ static uint8_t decrypt_esa(uint8_t *b)
|
|||
crc += byte;
|
||||
b[pos++] ^= 0xff;
|
||||
|
||||
crc -= (b[pos] << 8) | b[pos+1];
|
||||
crc -= (b[pos] << 8) | b[pos + 1];
|
||||
return crc;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,13 +94,13 @@ static char *output_fields[] = {
|
|||
};
|
||||
|
||||
r_device eurochron = {
|
||||
.name = "Eurochron temperature and humidity sensor",
|
||||
.modulation = OOK_PULSE_PPM,
|
||||
.short_width = 1016,
|
||||
.long_width = 2024,
|
||||
.gap_limit = 2100,
|
||||
.reset_limit = 8200,
|
||||
.decode_fn = &eurochron_decode,
|
||||
.disabled = 1,
|
||||
.fields = output_fields,
|
||||
.name = "Eurochron temperature and humidity sensor",
|
||||
.modulation = OOK_PULSE_PPM,
|
||||
.short_width = 1016,
|
||||
.long_width = 2024,
|
||||
.gap_limit = 2100,
|
||||
.reset_limit = 8200,
|
||||
.decode_fn = &eurochron_decode,
|
||||
.disabled = 1,
|
||||
.fields = output_fields,
|
||||
};
|
||||
|
|
|
@ -133,8 +133,8 @@ static void render_getters(data_t *data, uint8_t *bits, struct flex_params *para
|
|||
NULL);
|
||||
} else {
|
||||
data_append(data,
|
||||
getter->name, "", DATA_INT, val,
|
||||
NULL);
|
||||
getter->name, "", DATA_INT, val,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,9 +46,9 @@ static int fordremote_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
bitbuffer_print(bitbuffer);
|
||||
}
|
||||
|
||||
bytes = bitbuffer->bb[i];
|
||||
device_id = (bytes[0]<<16) | (bytes[1]<<8) | bytes[2];
|
||||
code = bytes[7];
|
||||
bytes = bitbuffer->bb[i];
|
||||
device_id = (bytes[0] << 16) | (bytes[1] << 8) | bytes[2];
|
||||
code = bytes[7];
|
||||
|
||||
/* clang-format off */
|
||||
data = data_make(
|
||||
|
|
|
@ -31,7 +31,7 @@ Aligning at [..] (insert 2 bits) we get:
|
|||
|
||||
static int ft004b_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
{
|
||||
uint8_t* msg;
|
||||
uint8_t *msg;
|
||||
float temperature;
|
||||
data_t *data;
|
||||
|
||||
|
@ -45,14 +45,14 @@ static int ft004b_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
uint8_t a = bitrow_get_byte(msg, i * 8);
|
||||
uint8_t b = bitrow_get_byte(msg, i * 8 + 46);
|
||||
uint8_t c = bitrow_get_byte(msg, i * 8 + 46 * 2);
|
||||
msg[i] = reverse8((a & b) | (b & c) | (a & c));
|
||||
msg[i] = reverse8((a & b) | (b & c) | (a & c));
|
||||
}
|
||||
|
||||
if (msg[0] != 0xf4)
|
||||
return DECODE_FAIL_SANITY;
|
||||
|
||||
int temp_raw = ((msg[4] & 0x7) << 8) | msg[3];
|
||||
temperature = (temp_raw * 0.05f) - 40.0f;
|
||||
temperature = (temp_raw * 0.05f) - 40.0f;
|
||||
|
||||
/* clang-format off */
|
||||
data = data_make(
|
||||
|
|
|
@ -97,13 +97,13 @@ static int ge_coloreffects_decode(r_device *decoder, bitbuffer_t *bitbuffer, uns
|
|||
uint8_t command = b[1];
|
||||
|
||||
char cmd[7];
|
||||
switch(command) {
|
||||
case 0x5a: snprintf(cmd, sizeof(cmd), "change"); break;
|
||||
case 0xaa: snprintf(cmd, sizeof(cmd), "on"); break;
|
||||
case 0x55: snprintf(cmd, sizeof(cmd), "off"); break;
|
||||
default:
|
||||
snprintf(cmd, sizeof(cmd), "0x%x", command);
|
||||
break;
|
||||
switch (command) {
|
||||
case 0x5a: snprintf(cmd, sizeof(cmd), "change"); break;
|
||||
case 0xaa: snprintf(cmd, sizeof(cmd), "on"); break;
|
||||
case 0x55: snprintf(cmd, sizeof(cmd), "off"); break;
|
||||
default:
|
||||
snprintf(cmd, sizeof(cmd), "0x%x", command);
|
||||
break;
|
||||
}
|
||||
|
||||
// Format data
|
||||
|
@ -117,7 +117,6 @@ static int ge_coloreffects_decode(r_device *decoder, bitbuffer_t *bitbuffer, uns
|
|||
|
||||
decoder_output_data(decoder, data);
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -47,7 +47,7 @@ static int generic_remote_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
uint32_t full = b[0] << 16 | b[1] << 8 | b[2];
|
||||
|
||||
for (int i = 22; i >= 0; i -= 2) {
|
||||
switch ((full>>i) & 0x03) {
|
||||
switch ((full >> i) & 0x03) {
|
||||
case 0x00: *p++ = '0'; break;
|
||||
case 0x01: *p++ = 'Z'; break; // floating / "open"
|
||||
case 0x02: *p++ = 'X'; break; // tristate 10 is invalid code for SC226x but valid in EV1527
|
||||
|
|
|
@ -212,7 +212,7 @@ static int govee_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
event_str = "Open";
|
||||
}
|
||||
else {
|
||||
event_str = "Unknown";
|
||||
event_str = "Unknown";
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
|
|
|
@ -72,7 +72,7 @@ Frame structure:
|
|||
|
||||
static int gt_tmbbq05_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
{
|
||||
uint8_t b[4],p[4];
|
||||
uint8_t b[4], p[4];
|
||||
data_t *data;
|
||||
|
||||
// 33 bit, repeated multiple times (technically it is repeated 8 times, look for 5 identical versions)
|
||||
|
@ -97,7 +97,7 @@ static int gt_tmbbq05_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
|
||||
/* Parity check over 7 nibbles (must be ODD) */
|
||||
memcpy(p, b, 4);
|
||||
p[3]=p[3]&0xF0;
|
||||
p[3] = p[3] & 0xF0;
|
||||
|
||||
if (parity_bytes(p, 4)) {
|
||||
if (decoder->verbose > 1) {
|
||||
|
|
|
@ -23,7 +23,7 @@ static char const *command_code[] = {"boot", "unlock" , "lock",};
|
|||
static char const *get_command_codes(const uint8_t *bytes)
|
||||
{
|
||||
unsigned char command = bytes[46] - 0xAA;
|
||||
if (command < (sizeof(command_code)/sizeof(command_code[0]))) {
|
||||
if (command < (sizeof(command_code) / sizeof(command_code[0]))) {
|
||||
return command_code[command];
|
||||
} else {
|
||||
return "unknown";
|
||||
|
@ -41,7 +41,7 @@ static int hondaremote_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
b = bitbuffer->bb[row];
|
||||
// Validate package
|
||||
if (((bitbuffer->bits_per_row[row] < 385) || (bitbuffer->bits_per_row[row] > 394)) ||
|
||||
((b[0] != 0xFF ) || (b[38] != 0xFF)))
|
||||
((b[0] != 0xFF) || (b[38] != 0xFF)))
|
||||
continue; // DECODE_ABORT_LENGTH
|
||||
|
||||
code = get_command_codes(b);
|
||||
|
|
|
@ -52,7 +52,7 @@ typedef struct {
|
|||
#ifdef _DEBUG
|
||||
static data_t *add_hex_string(data_t *data, const char *name, const uint8_t *buf, size_t buf_sz)
|
||||
{
|
||||
if (buf && buf_sz > 0) {
|
||||
if (buf && buf_sz > 0) {
|
||||
char tstr[256];
|
||||
bitrow_snprint(buf, buf_sz * 8, tstr, sizeof (tstr));
|
||||
data = data_append(data, name, "", DATA_STRING, tstr, NULL);
|
||||
|
@ -67,21 +67,21 @@ typedef struct {
|
|||
} dev_map_entry_t;
|
||||
|
||||
static const dev_map_entry_t device_map[] = {
|
||||
{ .t = 1, .s = "CTL" }, // Controller
|
||||
{ .t = 2, .s = "UFH" }, // Underfloor heating (HCC80, HCE80)
|
||||
{ .t = 3, .s = " 30" }, // HCW82??
|
||||
{ .t = 4, .s = "TRV" }, // Thermostatic radiator valve (HR80, HR91, HR92)
|
||||
{ .t = 7, .s = "DHW" }, // DHW sensor (CS92)
|
||||
{ .t = 10, .s = "OTB" }, // OpenTherm bridge (R8810)
|
||||
{ .t = 12, .s = "THm" }, // Thermostat with setpoint schedule control (DTS92E, CME921)
|
||||
{ .t = 13, .s = "BDR" }, // Wireless relay box (BDR91) (HC60NG too?)
|
||||
{ .t = 17, .s = " 17" }, // Dunno - Outside weather sensor?
|
||||
{ .t = 18, .s = "HGI" }, // Honeywell Gateway Interface (HGI80, HGS80)
|
||||
{ .t = 22, .s = "THM" }, // Thermostat with setpoint schedule control (DTS92E)
|
||||
{ .t = 30, .s = "GWY" }, // Gateway (e.g. RFG100?)
|
||||
{ .t = 32, .s = "VNT" }, // (HCE80) Ventilation (Nuaire VMS-23HB33, VMN-23LMH23)
|
||||
{ .t = 34, .s = "STA" }, // Thermostat (T87RF)
|
||||
{ .t = 63, .s = "NUL" }, // No device
|
||||
{.t = 1, .s = "CTL"}, // Controller
|
||||
{.t = 2, .s = "UFH"}, // Underfloor heating (HCC80, HCE80)
|
||||
{.t = 3, .s = " 30"}, // HCW82??
|
||||
{.t = 4, .s = "TRV"}, // Thermostatic radiator valve (HR80, HR91, HR92)
|
||||
{.t = 7, .s = "DHW"}, // DHW sensor (CS92)
|
||||
{.t = 10, .s = "OTB"}, // OpenTherm bridge (R8810)
|
||||
{.t = 12, .s = "THm"}, // Thermostat with setpoint schedule control (DTS92E, CME921)
|
||||
{.t = 13, .s = "BDR"}, // Wireless relay box (BDR91) (HC60NG too?)
|
||||
{.t = 17, .s = " 17"}, // Dunno - Outside weather sensor?
|
||||
{.t = 18, .s = "HGI"}, // Honeywell Gateway Interface (HGI80, HGS80)
|
||||
{.t = 22, .s = "THM"}, // Thermostat with setpoint schedule control (DTS92E)
|
||||
{.t = 30, .s = "GWY"}, // Gateway (e.g. RFG100?)
|
||||
{.t = 32, .s = "VNT"}, // (HCE80) Ventilation (Nuaire VMS-23HB33, VMN-23LMH23)
|
||||
{.t = 34, .s = "STA"}, // Thermostat (T87RF)
|
||||
{.t = 63, .s = "NUL"}, // No device
|
||||
};
|
||||
|
||||
static void decode_device_id(const uint8_t device_id[3], char *buf, size_t buf_sz)
|
||||
|
@ -102,7 +102,8 @@ static data_t *decode_device_ids(const message_t *msg, data_t *data, int style)
|
|||
char ds[64] = {0}; // up to 4 ids of at most 10+1 chars
|
||||
|
||||
for (unsigned i = 0; i < msg->num_device_ids; i++) {
|
||||
if (i != 0) strcat(ds, " ");
|
||||
if (i != 0)
|
||||
strcat(ds, " ");
|
||||
|
||||
char buf[16] = {0};
|
||||
if (style == 0)
|
||||
|
|
|
@ -85,17 +85,17 @@ static int honeywell_wdb_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
device = bytes[0] << 12 | bytes[1] << 4 | (bytes[2]&0xF);
|
||||
tmp = (bytes[3]&0x30) >> 4;
|
||||
switch (tmp) {
|
||||
case 0x1: class = "PIR-Motion"; break;
|
||||
case 0x2: class = "Doorbell"; break;
|
||||
default: class = "Unknown"; break;
|
||||
case 0x1: class = "PIR-Motion"; break;
|
||||
case 0x2: class = "Doorbell"; break;
|
||||
default: class = "Unknown"; break;
|
||||
}
|
||||
tmp = bytes[4]&0x3;
|
||||
tmp = bytes[4] & 0x3;
|
||||
switch (tmp) {
|
||||
case 0x0: alert = "Normal"; break;
|
||||
case 0x1:
|
||||
case 0x2: alert = "High"; break;
|
||||
case 0x3: alert = "Full"; break;
|
||||
default: alert = "Unknown"; break;
|
||||
case 0x0: alert = "Normal"; break;
|
||||
case 0x1:
|
||||
case 0x2: alert = "High"; break;
|
||||
case 0x3: alert = "Full"; break;
|
||||
default: alert = "Unknown"; break;
|
||||
}
|
||||
secret_knock = (bytes[5]&0x10) >> 4;
|
||||
relay = (bytes[5]&0x8) >> 3;
|
||||
|
|
|
@ -47,7 +47,8 @@ Payload looks like this:
|
|||
|
||||
#include "decoder.h"
|
||||
|
||||
static int infactory_crc_check(uint8_t *b) {
|
||||
static int infactory_crc_check(uint8_t *b)
|
||||
{
|
||||
uint8_t msg_crc, crc, msg[5];
|
||||
memcpy(msg, b, 5);
|
||||
msg_crc = msg[1] >> 4;
|
||||
|
@ -67,7 +68,7 @@ static int infactory_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
uint8_t *b = bitbuffer->bb[0];
|
||||
|
||||
/* Check that the last 4 bits of message are not 0 (channel number 1 - 3) */
|
||||
if (!(b[4]&0x0F))
|
||||
if (!(b[4] & 0x0F))
|
||||
return DECODE_ABORT_EARLY;
|
||||
|
||||
if (!infactory_crc_check(b))
|
||||
|
@ -132,11 +133,11 @@ NB: pulse_demod_ppm does not use .gap_limit if .tolerance is set.
|
|||
r_device infactory = {
|
||||
.name = "inFactory, nor-tec, FreeTec NC-3982-913 temperature humidity sensor",
|
||||
.modulation = OOK_PULSE_PPM,
|
||||
.sync_width = 500, // Sync pulse width (recognized, but not used)
|
||||
.short_width = 2000, // Width of a '0' gap
|
||||
.long_width = 4000, // Width of a '1' gap
|
||||
.reset_limit = 5000, // Maximum gap size before End Of Message [us]
|
||||
.tolerance = 750, // Width interval 0=[1250..2750] 1=[3250..4750], should be quite robust
|
||||
.sync_width = 500, // Sync pulse width (recognized, but not used)
|
||||
.short_width = 2000, // Width of a '0' gap
|
||||
.long_width = 4000, // Width of a '1' gap
|
||||
.reset_limit = 5000, // Maximum gap size before End Of Message [us]
|
||||
.tolerance = 750, // Width interval 0=[1250..2750] 1=[3250..4750], should be quite robust
|
||||
.decode_fn = &infactory_callback,
|
||||
.fields = output_fields,
|
||||
};
|
||||
|
|
|
@ -44,13 +44,13 @@ static int intertechno_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
fprintf(stderr, "rid = %x\n", b[6]);
|
||||
fprintf(stderr, "rid = %x\n", b[7]);
|
||||
fprintf(stderr, "ADDR Slave = %i\n", b[7] & 0x0f);
|
||||
fprintf(stderr, "ADDR Master = %i\n",( b[7] & 0xf0) >> 4);
|
||||
fprintf(stderr, "command = %i\n",( b[6] & 0x07));
|
||||
fprintf(stderr, "ADDR Master = %i\n", (b[7] & 0xf0) >> 4);
|
||||
fprintf(stderr, "command = %i\n", (b[6] & 0x07));
|
||||
}
|
||||
|
||||
sprintf(id_str, "%02x%02x%02x%02x%02x", b[0], b[1], b[2], b[3], b[4]);
|
||||
slave = b[7] & 0x0f;
|
||||
master = (b[7] & 0xf0) >> 4;
|
||||
slave = b[7] & 0x0f;
|
||||
master = (b[7] & 0xf0) >> 4;
|
||||
command = b[6] & 0x07;
|
||||
|
||||
/* clang-format off */
|
||||
|
|
|
@ -46,7 +46,7 @@ static int kerui_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
b = bitbuffer->bb[r];
|
||||
|
||||
// No need to decode/extract values for simple test
|
||||
if ( !b[0] && !b[1] && !b[2] ) {
|
||||
if (!b[0] && !b[1] && !b[2]) {
|
||||
if (decoder->verbose > 1) {
|
||||
fprintf(stderr, "%s: DECODE_FAIL_SANITY data all 0x00\n", __func__);
|
||||
}
|
||||
|
@ -58,16 +58,16 @@ static int kerui_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
b[1] = ~b[1];
|
||||
b[2] = ~b[2];
|
||||
|
||||
id = (b[0] << 12) | (b[1] << 4) | (b[2] >> 4);
|
||||
id = (b[0] << 12) | (b[1] << 4) | (b[2] >> 4);
|
||||
cmd = b[2] & 0x0F;
|
||||
switch (cmd) {
|
||||
case 0xa: cmd_str = "motion"; break;
|
||||
case 0xe: cmd_str = "open"; break;
|
||||
case 0x7: cmd_str = "close"; break;
|
||||
case 0xb: cmd_str = "tamper"; break;
|
||||
case 0x5: cmd_str = "water"; break;
|
||||
case 0xf: cmd_str = "battery"; break;
|
||||
default: cmd_str = NULL; break;
|
||||
case 0xa: cmd_str = "motion"; break;
|
||||
case 0xe: cmd_str = "open"; break;
|
||||
case 0x7: cmd_str = "close"; break;
|
||||
case 0xb: cmd_str = "tamper"; break;
|
||||
case 0x5: cmd_str = "water"; break;
|
||||
case 0xf: cmd_str = "battery"; break;
|
||||
default: cmd_str = NULL; break;
|
||||
}
|
||||
|
||||
if (!cmd_str)
|
||||
|
|
|
@ -194,7 +194,7 @@ static int lacrossetx_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
}
|
||||
|
||||
if (events)
|
||||
return events;
|
||||
return events;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ Between -17C and 0C, 'n' is 60. Below -17C, 'n' is 360.
|
|||
|
||||
static int lacrosse_breezepro_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
{
|
||||
uint8_t const preamble_pattern[] = { 0xd2, 0xaa, 0x2d, 0xd4 };
|
||||
uint8_t const preamble_pattern[] = {0xd2, 0xaa, 0x2d, 0xd4};
|
||||
|
||||
data_t *data;
|
||||
uint8_t b[11];
|
||||
|
@ -115,7 +115,7 @@ static int lacrosse_breezepro_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
chk = crc8(b, 11, 0x31, 0x00);
|
||||
if (chk) {
|
||||
if (decoder->verbose) {
|
||||
fprintf(stderr, "%s: CRC failed!\n", __func__);
|
||||
fprintf(stderr, "%s: CRC failed!\n", __func__);
|
||||
}
|
||||
return DECODE_FAIL_MIC;
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ LTV-W1:
|
|||
|
||||
static int lacrosse_r1_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
{
|
||||
uint8_t const preamble_pattern[] = { 0xd2, 0xaa, 0x2d, 0xd4 };
|
||||
uint8_t const preamble_pattern[] = {0xd2, 0xaa, 0x2d, 0xd4};
|
||||
|
||||
uint8_t b[20];
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ Sequence# 0,1,3,4,5 & 7
|
|||
|
||||
static int lacrosse_th_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
{
|
||||
uint8_t const preamble_pattern[] = { 0xd2, 0xaa, 0x2d, 0xd4 };
|
||||
uint8_t const preamble_pattern[] = {0xd2, 0xaa, 0x2d, 0xd4};
|
||||
|
||||
data_t *data;
|
||||
uint8_t b[11];
|
||||
|
@ -85,13 +85,13 @@ static int lacrosse_th_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
return DECODE_ABORT_LENGTH;
|
||||
} else if (bitbuffer->bits_per_row[0] > 290) {
|
||||
if (decoder->verbose) {
|
||||
fprintf(stderr, "%s: Packet too long: %d bits\n", __func__, bitbuffer->bits_per_row[0]);
|
||||
bitbuffer_debug(bitbuffer);
|
||||
fprintf(stderr, "%s: Packet too long: %d bits\n", __func__, bitbuffer->bits_per_row[0]);
|
||||
bitbuffer_debug(bitbuffer);
|
||||
}
|
||||
return DECODE_ABORT_LENGTH;
|
||||
} else {
|
||||
if (decoder->verbose) {
|
||||
fprintf(stderr, "%s: packet length: %d\n", __func__, bitbuffer->bits_per_row[0]);
|
||||
fprintf(stderr, "%s: packet length: %d\n", __func__, bitbuffer->bits_per_row[0]);
|
||||
}
|
||||
model_num = (bitbuffer->bits_per_row[0] < 280) ? 3 : 2;
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ static int lacrosse_th_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
chk2 = crc8(b, 8, 0x31, 0xac);
|
||||
if (chk3 != 0 && chk2 != 0) {
|
||||
if (decoder->verbose) {
|
||||
fprintf(stderr, "%s: CRC failed!\n", __func__);
|
||||
fprintf(stderr, "%s: CRC failed!\n", __func__);
|
||||
}
|
||||
return DECODE_FAIL_MIC;
|
||||
}
|
||||
|
@ -124,17 +124,17 @@ static int lacrosse_th_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
bitbuffer_debug(bitbuffer);
|
||||
}
|
||||
|
||||
id = (b[0] << 16) | (b[1] << 8) | b[2];
|
||||
flags = (b[3] & 0xf1); // masks off seq bits
|
||||
seq = (b[3] & 0x0e) >> 1;
|
||||
raw_temp = b[4] << 4 | ((b[5] & 0xf0) >> 4);
|
||||
humidity = ((b[5] & 0x0f) << 8) | b[6];
|
||||
id = (b[0] << 16) | (b[1] << 8) | b[2];
|
||||
flags = (b[3] & 0xf1); // masks off seq bits
|
||||
seq = (b[3] & 0x0e) >> 1;
|
||||
raw_temp = b[4] << 4 | ((b[5] & 0xf0) >> 4);
|
||||
humidity = ((b[5] & 0x0f) << 8) | b[6];
|
||||
|
||||
// base and/or scale adjustments
|
||||
temp_c = (raw_temp - 400) * 0.1f;
|
||||
|
||||
if (humidity < 0 || humidity > 100 || temp_c < -50 || temp_c > 70)
|
||||
return DECODE_FAIL_SANITY;
|
||||
return DECODE_FAIL_SANITY;
|
||||
|
||||
/* clang-format off */
|
||||
data = data_make(
|
||||
|
|
|
@ -52,7 +52,7 @@ LTV-WR1
|
|||
|
||||
static int lacrosse_wr1_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
{
|
||||
uint8_t const preamble_pattern[] = { 0xd2, 0xaa, 0x2d, 0xd4 };
|
||||
uint8_t const preamble_pattern[] = {0xd2, 0xaa, 0x2d, 0xd4};
|
||||
|
||||
data_t *data;
|
||||
uint8_t b[11];
|
||||
|
@ -74,7 +74,7 @@ static int lacrosse_wr1_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
return DECODE_ABORT_LENGTH;
|
||||
} else {
|
||||
if (decoder->verbose) {
|
||||
fprintf(stderr, "%s: packet length: %d\n", __func__, bitbuffer->bits_per_row[0]);
|
||||
fprintf(stderr, "%s: packet length: %d\n", __func__, bitbuffer->bits_per_row[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ static int lacrosse_wr1_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
chk = crc8(b, 11, 0x31, 0x00);
|
||||
if (chk) {
|
||||
if (decoder->verbose) {
|
||||
fprintf(stderr, "%s: CRC failed!\n", __func__);
|
||||
fprintf(stderr, "%s: CRC failed!\n", __func__);
|
||||
}
|
||||
return DECODE_FAIL_MIC;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ static int lacrosse_wr1_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
// base and/or scale adjustments
|
||||
speed_kmh = raw_wind * 0.1f;
|
||||
if (speed_kmh < 0 || speed_kmh > 200 || direction < 0 || direction > 360)
|
||||
return DECODE_FAIL_SANITY;
|
||||
return DECODE_FAIL_SANITY;
|
||||
|
||||
//rain_mm = 0.0; // dummy until we know what raw_rain1 and raw_rain2 mean
|
||||
|
||||
|
|
|
@ -79,8 +79,8 @@ static int lacrossews_detect(r_device *decoder, uint8_t *pRow, uint8_t *msg_nybb
|
|||
if (!checksum_ok) {
|
||||
if (decoder->verbose > 1) {
|
||||
fprintf(stderr,
|
||||
"LaCrosse Packet Validation Failed error: Checksum Comp. %d != Recv. %d, Parity %d\n",
|
||||
checksum, msg_nybbles[12], parity);
|
||||
"LaCrosse Packet Validation Failed error: Checksum Comp. %d != Recv. %d, Parity %d\n",
|
||||
checksum, msg_nybbles[12], parity);
|
||||
bitrow_print(msg_nybbles, LACROSSE_WS_BITLEN);
|
||||
}
|
||||
return DECODE_FAIL_MIC;
|
||||
|
|
|
@ -24,22 +24,24 @@ static int lightwave_rf_nibble_from_byte(uint8_t in)
|
|||
{
|
||||
int nibble = -1; // Default error
|
||||
switch (in) {
|
||||
case 0xF6: nibble = 0x0; break;
|
||||
case 0xEE: nibble = 0x1; break;
|
||||
case 0xED: nibble = 0x2; break;
|
||||
case 0xEB: nibble = 0x3; break;
|
||||
case 0xDE: nibble = 0x4; break;
|
||||
case 0xDD: nibble = 0x5; break;
|
||||
case 0xDB: nibble = 0x6; break;
|
||||
case 0xBE: nibble = 0x7; break;
|
||||
case 0xBD: nibble = 0x8; break;
|
||||
case 0xBB: nibble = 0x9; break;
|
||||
case 0xB7: nibble = 0xA; break;
|
||||
case 0x7E: nibble = 0xB; break;
|
||||
case 0x7D: nibble = 0xC; break;
|
||||
case 0x7B: nibble = 0xD; break;
|
||||
case 0x77: nibble = 0xE; break;
|
||||
case 0x6F: nibble = 0xF; break;
|
||||
case 0xF6: nibble = 0x0; break;
|
||||
case 0xEE: nibble = 0x1; break;
|
||||
case 0xED: nibble = 0x2; break;
|
||||
case 0xEB: nibble = 0x3; break;
|
||||
case 0xDE: nibble = 0x4; break;
|
||||
case 0xDD: nibble = 0x5; break;
|
||||
case 0xDB: nibble = 0x6; break;
|
||||
case 0xBE: nibble = 0x7; break;
|
||||
case 0xBD: nibble = 0x8; break;
|
||||
case 0xBB: nibble = 0x9; break;
|
||||
case 0xB7: nibble = 0xA; break;
|
||||
case 0x7E: nibble = 0xB; break;
|
||||
case 0x7D: nibble = 0xC; break;
|
||||
case 0x7B: nibble = 0xD; break;
|
||||
case 0x77: nibble = 0xE; break;
|
||||
case 0x6F:
|
||||
nibble = 0xF;
|
||||
break;
|
||||
// default: // Just return error
|
||||
}
|
||||
return nibble;
|
||||
|
@ -63,7 +65,7 @@ static int lightwave_rf_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
// Expand all "0" to "10" (bit stuffing)
|
||||
// row_in = 0, row_out = 1
|
||||
bitbuffer_add_row(bitbuffer);
|
||||
for (unsigned n=0; n < bitbuffer->bits_per_row[0]; ++n) {
|
||||
for (unsigned n = 0; n < bitbuffer->bits_per_row[0]; ++n) {
|
||||
if (bitrow_get_bit(bb[0], n)) {
|
||||
bitbuffer_add_bit(bitbuffer, 1);
|
||||
} else {
|
||||
|
@ -109,8 +111,8 @@ static int lightwave_rf_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
}
|
||||
return DECODE_FAIL_SANITY; // Decode error
|
||||
}
|
||||
for (unsigned m=0; m<4; ++m) { // Add nibble one bit at a time...
|
||||
bitbuffer_add_bit(bitbuffer, (nibble & (8 >> m)) >> (3-m));
|
||||
for (unsigned m = 0; m < 4; ++m) { // Add nibble one bit at a time...
|
||||
bitbuffer_add_bit(bitbuffer, (nibble & (8 >> m)) >> (3 - m));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ static int markisol_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
if (bitbuffer->bits_per_row[i] == 41 || bitbuffer->bits_per_row[i] == 42) {
|
||||
uint8_t *b = bitbuffer->bb[i];
|
||||
for (int j = 0; j < 5; ++j) {
|
||||
buf[j] = (b[j] << 1) + (b[j+1] >> 7); // shift stream to discard spurious first bit
|
||||
buf[j] = (b[j] << 1) + (b[j + 1] >> 7); // shift stream to discard spurious first bit
|
||||
buf[j] = ~reverse8(buf[j]);
|
||||
cksum += buf[j];
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ static int markisol_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
int address = (buf[0] << 8) | buf[1];
|
||||
int channel = buf[2] & 0xf;
|
||||
int control = ((buf[2] >> 4) & ~2) | ((buf[3] & 0x10) >> 3);
|
||||
int zone = ((buf[2] & 0x20) >> 5) + ((buf[3] & 0x80) >> 6) + 1;
|
||||
int zone = ((buf[2] & 0x20) >> 5) + ((buf[3] & 0x80) >> 6) + 1;
|
||||
// buf[3] seems to be always 0x01, 0x11, 0x81, 0x91
|
||||
// ... so there are 6 bits that seem constant (for my remotes)
|
||||
|
||||
|
@ -125,13 +125,13 @@ static char *output_fields[] = {
|
|||
// rtl_433 -f 433900000 -X 'n=name,m=OOK_PWM,s=368,l=704,r=10000,g=10000,t=0,y=5628'
|
||||
|
||||
r_device markisol = {
|
||||
.name = "Markisol, E-Motion, BOFU, Rollerhouse, BF-30x, BF-415 curtain remote",
|
||||
.modulation = OOK_PULSE_PWM,
|
||||
.short_width = 368,
|
||||
.long_width = 704,
|
||||
.sync_width = 5628,
|
||||
.gap_limit = 2000,
|
||||
.reset_limit = 2000,
|
||||
.decode_fn = &markisol_decode,
|
||||
.fields = output_fields,
|
||||
.name = "Markisol, E-Motion, BOFU, Rollerhouse, BF-30x, BF-415 curtain remote",
|
||||
.modulation = OOK_PULSE_PWM,
|
||||
.short_width = 368,
|
||||
.long_width = 704,
|
||||
.sync_width = 5628,
|
||||
.gap_limit = 2000,
|
||||
.reset_limit = 2000,
|
||||
.decode_fn = &markisol_decode,
|
||||
.fields = output_fields,
|
||||
};
|
||||
|
|
|
@ -69,11 +69,11 @@ static int maverick_et73_sensor_callback(r_device *decoder, bitbuffer_t *bitbuff
|
|||
device = bytes[0];
|
||||
|
||||
if (decoder->verbose) {
|
||||
fprintf(stderr,"maverick_et73_raw_data:");
|
||||
fprintf(stderr, "maverick_et73_raw_data:");
|
||||
bitrow_print(bytes, 48);
|
||||
}
|
||||
|
||||
temp1_raw = (bytes[1] << 4) | ((bytes[2] & 0xf0) );
|
||||
temp1_raw = (bytes[1] << 4) | ((bytes[2] & 0xf0));
|
||||
temp2_raw = ((bytes[2] & 0x0f) << 8) | bytes[3];
|
||||
|
||||
temp1_c = temp1_raw * 0.1f;
|
||||
|
|
|
@ -13,7 +13,7 @@ static int mebus433_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
{
|
||||
bitrow_t *bb = bitbuffer->bb;
|
||||
int16_t temp;
|
||||
int8_t hum;
|
||||
int8_t hum;
|
||||
uint8_t address;
|
||||
uint8_t channel;
|
||||
uint8_t battery;
|
||||
|
@ -30,7 +30,7 @@ static int mebus433_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
channel = ((bb[1][1] & 0x30) >> 4) + 1;
|
||||
// Always 0?
|
||||
unknown1 = (bb[1][1] & 0x40) >> 6;
|
||||
battery = bb[1][1] & 0x80;
|
||||
battery = bb[1][1] & 0x80;
|
||||
|
||||
// Upper 4 bits are stored in nibble 1, lower 8 bits are stored in nibble 2
|
||||
// upper 4 bits of nibble 1 are reserved for other usages.
|
||||
|
@ -38,7 +38,7 @@ static int mebus433_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
temp = temp >> 4;
|
||||
// lower 4 bits of nibble 3 and upper 4 bits of nibble 4 contains
|
||||
// humidity as decimal value
|
||||
hum = (bb[1][3] << 4 | bb[1][4] >> 4);
|
||||
hum = (bb[1][3] << 4 | bb[1][4] >> 4);
|
||||
|
||||
// Always 0b1111?
|
||||
unknown2 = (bb[1][3] & 0xf0) >> 4;
|
||||
|
|
|
@ -78,10 +78,10 @@ static int missil_ml0757_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
return DECODE_ABORT_EARLY; // Tail bits not 1111
|
||||
|
||||
// Read fields from sensor data
|
||||
id = b[0];
|
||||
flags = b[1];
|
||||
f12bit = (int16_t)((b[2] << 4) | (b[3] >> 4)) & 0xFFF;
|
||||
f8bit = (((b[3] & 0x0F) << 4) | (b[4] >> 4)) & 0xFF;
|
||||
id = b[0];
|
||||
flags = b[1];
|
||||
f12bit = (int16_t)((b[2] << 4) | (b[3] >> 4)) & 0xFFF;
|
||||
f8bit = (((b[3] & 0x0F) << 4) | (b[4] >> 4)) & 0xFF;
|
||||
|
||||
// Parse flags
|
||||
flag_bat = flags & MISSIL_ML0757_FLAG_BAT;
|
||||
|
@ -98,10 +98,10 @@ static int missil_ml0757_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
|
||||
// Parse wind speed
|
||||
switch (f8bit) {
|
||||
case 0x00: wind_kph = 0.0f; break;
|
||||
case 0x80: wind_kph = 1.4f; break;
|
||||
case 0xC0: wind_kph = 2.8f; break;
|
||||
default: wind_kph = (f8bit + 2) * 1.4f; break;
|
||||
case 0x00: wind_kph = 0.0f; break;
|
||||
case 0x80: wind_kph = 1.4f; break;
|
||||
case 0xC0: wind_kph = 2.8f; break;
|
||||
default: wind_kph = (f8bit + 2) * 1.4f; break;
|
||||
}
|
||||
|
||||
if (flag_rwp) { // Rainwall and wind
|
||||
|
|
|
@ -64,17 +64,17 @@ Data layout:
|
|||
* require at least 3 repeated packets.
|
||||
*
|
||||
*/
|
||||
#define MYDEVICE_BITLEN 68
|
||||
#define MYDEVICE_STARTBYTE 0xAA
|
||||
#define MYDEVICE_MINREPEATS 3
|
||||
#define MYDEVICE_MSG_TYPE 0x10
|
||||
#define MYDEVICE_CRC_POLY 0x07
|
||||
#define MYDEVICE_CRC_INIT 0x00
|
||||
#define MYDEVICE_BITLEN 68
|
||||
#define MYDEVICE_STARTBYTE 0xAA
|
||||
#define MYDEVICE_MINREPEATS 3
|
||||
#define MYDEVICE_MSG_TYPE 0x10
|
||||
#define MYDEVICE_CRC_POLY 0x07
|
||||
#define MYDEVICE_CRC_INIT 0x00
|
||||
|
||||
static int new_template_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
{
|
||||
data_t *data;
|
||||
int r; // a row index
|
||||
int r; // a row index
|
||||
uint8_t *b; // bits of a row
|
||||
int parity;
|
||||
uint8_t r_crc, c_crc;
|
||||
|
@ -181,13 +181,13 @@ static int new_template_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
// parity check: odd parity on bits [0 .. 67]
|
||||
// i.e. 8 bytes and a nibble.
|
||||
parity = b[0] ^ b[1] ^ b[2] ^ b[3] ^ b[4] ^ b[5] ^ b[6] ^ b[7]; // parity as byte
|
||||
parity = (parity >> 4) ^ (parity & 0xF); // fold to nibble
|
||||
parity ^= b[8] >> 4; // add remaining nibble
|
||||
parity = (parity >> 2) ^ (parity & 0x3); // fold to 2 bits
|
||||
parity = (parity >> 1) ^ (parity & 0x1); // fold to 1 bit
|
||||
parity = (parity >> 4) ^ (parity & 0xF); // fold to nibble
|
||||
parity ^= b[8] >> 4; // add remaining nibble
|
||||
parity = (parity >> 2) ^ (parity & 0x3); // fold to 2 bits
|
||||
parity = (parity >> 1) ^ (parity & 0x1); // fold to 1 bit
|
||||
|
||||
if (!parity) {
|
||||
//Enable with -vv (verbose decoders)
|
||||
// Enable with -vv (verbose decoders)
|
||||
if (decoder->verbose) {
|
||||
fprintf(stderr, "%s: parity check failed\n", __func__);
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ static int new_template_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
* Check message integrity (Checksum example)
|
||||
*/
|
||||
if (((b[0] + b[1] + b[2] + b[3] - b[4]) & 0xFF) != 0) {
|
||||
//Enable with -vv (verbose decoders)
|
||||
// Enable with -vv (verbose decoders)
|
||||
if (decoder->verbose) {
|
||||
fprintf(stderr, "%s: checksum error\n", __func__);
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ static int new_template_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
r_crc = b[7];
|
||||
c_crc = crc8(b, MYDEVICE_BITLEN / 8, MYDEVICE_CRC_POLY, MYDEVICE_CRC_INIT);
|
||||
if (r_crc != c_crc) {
|
||||
//Enable with -vv (verbose decoders)
|
||||
// Enable with -vv (verbose decoders)
|
||||
if (decoder->verbose) {
|
||||
fprintf(stderr, "%s: bad CRC: calculated %02x, received %02x\n",
|
||||
__func__, c_crc, r_crc);
|
||||
|
@ -227,9 +227,9 @@ static int new_template_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
* Now that message "envelope" has been validated,
|
||||
* start parsing data.
|
||||
*/
|
||||
msg_type = b[1];
|
||||
msg_type = b[1];
|
||||
sensor_id = b[2] << 8 | b[3];
|
||||
value = b[4] << 8 | b[5];
|
||||
value = b[4] << 8 | b[5];
|
||||
|
||||
if (msg_type != MYDEVICE_MSG_TYPE) {
|
||||
/*
|
||||
|
|
|
@ -109,7 +109,7 @@ static int oil_standard_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
// End of frame is the last half-bit repeated additional 4 times
|
||||
|
||||
unsigned bitpos = 0;
|
||||
int events = 0;
|
||||
int events = 0;
|
||||
|
||||
// Find a preamble with enough bits after it that it could be a complete packet
|
||||
while ((bitpos = bitbuffer_search(bitbuffer, 0, bitpos, preamble_pattern0, 16)) + 78 <=
|
||||
|
|
|
@ -22,19 +22,19 @@ static int oil_watchman_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
uint8_t const preamble_pattern[] = {0xe0};
|
||||
|
||||
// End of frame is 00xxxxxx or 11xxxxxx depending on final data bit
|
||||
uint8_t const postamble_pattern[2] = { 0x00, 0xc0 };
|
||||
uint8_t const postamble_pattern[2] = {0x00, 0xc0};
|
||||
|
||||
uint8_t *b;
|
||||
uint32_t unit_id;
|
||||
uint16_t depth = 0;
|
||||
uint16_t depth = 0;
|
||||
uint16_t binding_countdown = 0;
|
||||
uint8_t flags;
|
||||
uint8_t maybetemp;
|
||||
double temperature;
|
||||
data_t *data;
|
||||
unsigned bitpos = 0;
|
||||
unsigned bitpos = 0;
|
||||
bitbuffer_t databits = {0};
|
||||
int events = 0;
|
||||
int events = 0;
|
||||
|
||||
// Find a preamble with enough bits after it that it could be a complete packet
|
||||
while ((bitpos = bitbuffer_search(bitbuffer, 0, bitpos, preamble_pattern, 6)) + 136 <=
|
||||
|
@ -67,7 +67,7 @@ static int oil_watchman_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
|
||||
// Not entirely sure what this is but it might be inversely
|
||||
// proportional to temperature.
|
||||
maybetemp = b[5] >> 2;
|
||||
maybetemp = b[5] >> 2;
|
||||
temperature = (double)(145.0 - 5.0 * maybetemp) / 3.0;
|
||||
if (flags & 1)
|
||||
// When binding, the countdown counts up from 0x51 to 0x5a
|
||||
|
@ -111,11 +111,11 @@ static char *output_fields[] = {
|
|||
};
|
||||
|
||||
r_device oil_watchman = {
|
||||
.name = "Watchman Sonic / Apollo Ultrasonic / Beckett Rocket oil tank monitor",
|
||||
.modulation = FSK_PULSE_PCM,
|
||||
.short_width = 1000,
|
||||
.long_width = 1000, // NRZ
|
||||
.reset_limit = 4000,
|
||||
.decode_fn = &oil_watchman_callback,
|
||||
.fields = output_fields,
|
||||
.name = "Watchman Sonic / Apollo Ultrasonic / Beckett Rocket oil tank monitor",
|
||||
.modulation = FSK_PULSE_PCM,
|
||||
.short_width = 1000,
|
||||
.long_width = 1000, // NRZ
|
||||
.reset_limit = 4000,
|
||||
.decode_fn = &oil_watchman_callback,
|
||||
.fields = output_fields,
|
||||
};
|
||||
|
|
|
@ -32,7 +32,7 @@ Data is transmitted with 6 bytes row:
|
|||
|
||||
static int opus_xt300_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
{
|
||||
int ret = 0;
|
||||
int ret = 0;
|
||||
int fail_code = 0;
|
||||
int row;
|
||||
int chk;
|
||||
|
@ -63,8 +63,8 @@ static int opus_xt300_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
}
|
||||
chk = add_bytes(b + 1, 4); // sum bytes 1-4
|
||||
chk = chk & 0xFF;
|
||||
if (chk != 0 && chk != b[5] ) {
|
||||
fail_code = DECODE_FAIL_MIC;
|
||||
if (chk != 0 && chk != b[5]) {
|
||||
fail_code = DECODE_FAIL_MIC;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ static int oregon_scientific_sl109h_callback(r_device *decoder, bitbuffer_t *bit
|
|||
|
||||
// No need to decode/extract values for simple test
|
||||
// check id channel temperature humidity value not zero
|
||||
if ( !msg[0] && !msg[1] && !msg[2] && !msg[3] ) {
|
||||
if (!msg[0] && !msg[1] && !msg[2] && !msg[3]) {
|
||||
if (decoder->verbose > 1) {
|
||||
fprintf(stderr, "%s: DECODE_FAIL_SANITY data all 0x00\n", __func__);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ static int oregon_scientific_sl109h_callback(r_device *decoder, bitbuffer_t *bit
|
|||
humidity = 10 * (b[0] & 0x0f) + (b[1] >> 4);
|
||||
|
||||
temp_raw = (int16_t)((b[1] & 0x0f) << 12) | (b[2] << 4); // uses sign-extend
|
||||
temp_c = (temp_raw >> 4) * 0.1f;
|
||||
temp_c = (temp_raw >> 4) * 0.1f;
|
||||
|
||||
// reduce false positives by checking specified sensor range, this isn't great...
|
||||
if (temp_c < -20 || temp_c > 60) {
|
||||
|
|
|
@ -47,7 +47,7 @@ static int proflame2_mc(bitbuffer_t *bitbuffer, unsigned row, unsigned start, ui
|
|||
{
|
||||
uint8_t *b = bitbuffer->bb[row];
|
||||
unsigned pos = start;
|
||||
for (int f = 0; ; ++f) {
|
||||
for (int f = 0;; ++f) {
|
||||
if (bitbuffer->bits_per_row[row] - pos < 26)
|
||||
return f;
|
||||
// expect sync and start bit of "1110"
|
||||
|
|
|
@ -159,11 +159,11 @@ static int radiohead_ask_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
}
|
||||
data_len = msg_len - RH_ASK_HEADER_LEN - 3;
|
||||
if (data_len <= 0)
|
||||
return DECODE_FAIL_SANITY;
|
||||
return DECODE_FAIL_SANITY;
|
||||
|
||||
header_to = rh_payload[1];
|
||||
header_from = rh_payload[2];
|
||||
header_id = rh_payload[3];
|
||||
header_to = rh_payload[1];
|
||||
header_from = rh_payload[2];
|
||||
header_id = rh_payload[3];
|
||||
header_flags = rh_payload[4];
|
||||
|
||||
// Format data
|
||||
|
@ -201,12 +201,12 @@ static int sensible_living_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
return msg_len; // pass error code on
|
||||
}
|
||||
|
||||
house_id = rh_payload[1];
|
||||
module_id = (rh_payload[2] << 8) | rh_payload[3];
|
||||
sensor_type = rh_payload[4];
|
||||
sensor_count = rh_payload[5];
|
||||
alarms = rh_payload[6];
|
||||
sensor_value = (rh_payload[7] << 8) | rh_payload[8];
|
||||
house_id = rh_payload[1];
|
||||
module_id = (rh_payload[2] << 8) | rh_payload[3];
|
||||
sensor_type = rh_payload[4];
|
||||
sensor_count = rh_payload[5];
|
||||
alarms = rh_payload[6];
|
||||
sensor_value = (rh_payload[7] << 8) | rh_payload[8];
|
||||
battery_voltage = (rh_payload[9] << 8) | rh_payload[10];
|
||||
|
||||
/* clang-format off */
|
||||
|
|
|
@ -39,7 +39,7 @@ With fresh batteries and button pressed:
|
|||
|
||||
#include "decoder.h"
|
||||
|
||||
static int rftech_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
static int rftech_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
{
|
||||
int r = bitbuffer_find_repeated_row(bitbuffer, 3, 24);
|
||||
|
||||
|
@ -48,12 +48,12 @@ With fresh batteries and button pressed:
|
|||
uint8_t *b = bitbuffer->bb[r];
|
||||
|
||||
int sensor_id = b[0];
|
||||
float temp_c = (b[1] & 0x7f) + (b[2] & 0x0f) * 0.1f;
|
||||
float temp_c = (b[1] & 0x7f) + (b[2] & 0x0f) * 0.1f;
|
||||
if (b[1] & 0x80)
|
||||
temp_c = -temp_c;
|
||||
|
||||
int battery = (b[2] & 0x80) == 0x80;
|
||||
int button = (b[2] & 0x60) != 0;
|
||||
int button = (b[2] & 0x60) != 0;
|
||||
|
||||
/* clang-format off */
|
||||
data_t *data = data_make(
|
||||
|
|
|
@ -37,12 +37,12 @@ int rubicson_crc_check(uint8_t *b);
|
|||
int rubicson_crc_check(uint8_t *b)
|
||||
{
|
||||
uint8_t tmp[5];
|
||||
tmp[0] = b[0]; // Byte 0 is nibble 0 and 1
|
||||
tmp[1] = b[1]; // Byte 1 is nibble 2 and 3
|
||||
tmp[2] = b[2]; // Byte 2 is nibble 4 and 5
|
||||
tmp[3] = b[3]&0xf0; // Byte 3 is nibble 6 and 0-padding
|
||||
tmp[4] = (b[3]&0x0f)<<4 | // CRC is nibble 7 and 8
|
||||
(b[4]&0xf0)>>4;
|
||||
tmp[0] = b[0]; // Byte 0 is nibble 0 and 1
|
||||
tmp[1] = b[1]; // Byte 1 is nibble 2 and 3
|
||||
tmp[2] = b[2]; // Byte 2 is nibble 4 and 5
|
||||
tmp[3] = b[3] & 0xf0; // Byte 3 is nibble 6 and 0-padding
|
||||
tmp[4] = (b[3] & 0x0f) << 4 | // CRC is nibble 7 and 8
|
||||
(b[4] & 0xf0) >> 4;
|
||||
|
||||
return crc8(tmp, 5, 0x31, 0x6c) == 0;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ static int scmplus_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
return DECODE_ABORT_EARLY;
|
||||
}
|
||||
|
||||
if ( (bitbuffer->bits_per_row[0] - sync_index) < 128) {
|
||||
if ((bitbuffer->bits_per_row[0] - sync_index) < 128) {
|
||||
return DECODE_ABORT_LENGTH;
|
||||
}
|
||||
|
||||
|
@ -122,27 +122,27 @@ static int scmplus_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
char *meter_type;
|
||||
|
||||
switch (b[3] & 0x0f) {
|
||||
case 4:
|
||||
case 5:
|
||||
case 7:
|
||||
case 8:
|
||||
meter_type = "Electric";
|
||||
break;
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 9:
|
||||
case 12:
|
||||
meter_type = "Gas";
|
||||
break;
|
||||
case 3:
|
||||
case 11:
|
||||
case 13:
|
||||
meter_type = "Water";
|
||||
break;
|
||||
default:
|
||||
meter_type = "unknown";
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
case 7:
|
||||
case 8:
|
||||
meter_type = "Electric";
|
||||
break;
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 9:
|
||||
case 12:
|
||||
meter_type = "Gas";
|
||||
break;
|
||||
case 3:
|
||||
case 11:
|
||||
case 13:
|
||||
meter_type = "Water";
|
||||
break;
|
||||
default:
|
||||
meter_type = "unknown";
|
||||
break;
|
||||
}
|
||||
|
||||
// fprintf(stderr, "meter_type = %s\n", meter_type);
|
||||
|
|
|
@ -309,7 +309,7 @@ static int secplus_v1_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
we now have values for rolling & fixed
|
||||
next we extract status info stored in the value for 'fixed'
|
||||
*/
|
||||
int switch_id = fixed % 3;
|
||||
int switch_id = fixed % 3;
|
||||
int id;
|
||||
int id0 = (fixed / 3) % 3;
|
||||
int id1 = (int)(fixed / 9) % 3;
|
||||
|
@ -323,7 +323,7 @@ static int secplus_v1_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
if (id1 == 0) {
|
||||
// pad_id = (fixed // 3**3) % (3**7) 27 3^72187
|
||||
pad_id = (fixed / 27) % 2187;
|
||||
id = pad_id;
|
||||
id = pad_id;
|
||||
// pin = (fixed // 3**10) % (3**9) 3^10= 59049 3^9=19683
|
||||
pin = (fixed / 59049) % 19683;
|
||||
|
||||
|
@ -348,7 +348,7 @@ static int secplus_v1_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
}
|
||||
else {
|
||||
remote_id = (int)fixed / 27;
|
||||
id = remote_id;
|
||||
id = remote_id;
|
||||
if (switch_id == 1)
|
||||
button = "left";
|
||||
else if (switch_id == 0)
|
||||
|
|
|
@ -76,7 +76,6 @@ static int _decode_v2_half(bitbuffer_t *bits, uint8_t roll_array[], bitbuffer_t
|
|||
unsigned int start_pos = 2; //
|
||||
uint8_t buffy[10];
|
||||
|
||||
|
||||
uint8_t part_id = (bits->bb[0][0] >> 6);
|
||||
|
||||
if (verbose) {
|
||||
|
@ -306,7 +305,6 @@ static int secplus_v2_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
if (fixed_1.bits_per_row[0] > 1 && fixed_2.bits_per_row[0] > 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Do we have what we need ??
|
||||
|
@ -344,7 +342,7 @@ static int secplus_v2_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
}
|
||||
|
||||
// Max value = 2^28 (268435456)
|
||||
if ( rolling_temp >= 0x10000000 ) {
|
||||
if (rolling_temp >= 0x10000000) {
|
||||
return DECODE_FAIL_SANITY;
|
||||
}
|
||||
|
||||
|
@ -352,7 +350,6 @@ static int secplus_v2_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
rolling_total = reverse32(rolling_temp);
|
||||
rolling_total = rolling_total >> 4;
|
||||
|
||||
|
||||
// Assemble "fixed" data part
|
||||
uint64_t fixed_total = 0;
|
||||
uint8_t *bb;
|
||||
|
@ -415,6 +412,6 @@ r_device secplus_v2 = {
|
|||
.tolerance = 50,
|
||||
.gap_limit = 1500,
|
||||
.reset_limit = 9000,
|
||||
.decode_fn = &secplus_v2_callback,
|
||||
.fields = output_fields,
|
||||
.decode_fn = &secplus_v2_callback,
|
||||
.fields = output_fields,
|
||||
};
|
||||
|
|
|
@ -39,7 +39,7 @@ static int sharp_spc775_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
|
||||
data_t *data;
|
||||
uint8_t b[6];
|
||||
int length_match = 0;
|
||||
int length_match = 0;
|
||||
int preamble_match = 0;
|
||||
|
||||
// Invert data for processing
|
||||
|
@ -61,11 +61,11 @@ static int sharp_spc775_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
if (!preamble_match)
|
||||
return DECODE_FAIL_SANITY;
|
||||
|
||||
int id = b[1]; // changes on each power cycle
|
||||
int battery_low = (b[2] & 0x80); // High bit is low battery indicator
|
||||
int temp_raw = (int16_t)(((b[2] & 0x0f) << 12) | (b[3] << 4)); // uses sign-extend
|
||||
float temp_c = (temp_raw >> 4) * 0.1f; // Convert sign extended int to float
|
||||
int humidity = b[4]; // Simple 0-100 RH
|
||||
int id = b[1]; // changes on each power cycle
|
||||
int battery_low = (b[2] & 0x80); // High bit is low battery indicator
|
||||
int temp_raw = (int16_t)(((b[2] & 0x0f) << 12) | (b[3] << 4)); // uses sign-extend
|
||||
float temp_c = (temp_raw >> 4) * 0.1f; // Convert sign extended int to float
|
||||
int humidity = b[4]; // Simple 0-100 RH
|
||||
int chk_digest = b[5];
|
||||
|
||||
uint8_t chk_calc = xor_bytes(b, 5);
|
||||
|
|
|
@ -11,16 +11,15 @@
|
|||
|
||||
#include "decoder.h"
|
||||
|
||||
|
||||
static int silvercrest_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
{
|
||||
uint8_t const cmd_lu_tab[16] = {2,3,0,1,4,5,7,6,0xC,0xD,0xF,0xE,8,9,0xB,0xA};
|
||||
uint8_t const cmd_lu_tab[16] = {2, 3, 0, 1, 4, 5, 7, 6, 0xC, 0xD, 0xF, 0xE, 8, 9, 0xB, 0xA};
|
||||
|
||||
uint8_t *b; // bits of a row
|
||||
uint8_t cmd;
|
||||
data_t *data;
|
||||
|
||||
if (bitbuffer->bits_per_row[1] !=33)
|
||||
if (bitbuffer->bits_per_row[1] != 33)
|
||||
return DECODE_ABORT_LENGTH;
|
||||
|
||||
/* select second row, first might be bad */
|
||||
|
@ -28,7 +27,7 @@ static int silvercrest_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
if ((b[0] == 0x7c) && (b[1] == 0x26)) {
|
||||
cmd = b[2] & 0xF;
|
||||
// Validate button
|
||||
if ((b[3]&0xF) != cmd_lu_tab[cmd])
|
||||
if ((b[3] & 0xF) != cmd_lu_tab[cmd])
|
||||
return DECODE_ABORT_EARLY;
|
||||
|
||||
/* clang-format off */
|
||||
|
|
|
@ -164,12 +164,12 @@ static int ss_sensor_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
// Require two identical rows.
|
||||
int row = bitbuffer_find_repeated_row(bitbuffer, 2, 90);
|
||||
if (row < 0)
|
||||
return DECODE_ABORT_EARLY;
|
||||
return DECODE_ABORT_EARLY;
|
||||
|
||||
// The row must start with 0xcc5f (0x33a0 inverted).
|
||||
uint8_t *b = bitbuffer->bb[row];
|
||||
if (b[0] != 0xcc || b[1] != 0x5f)
|
||||
return DECODE_ABORT_EARLY;
|
||||
return DECODE_ABORT_EARLY;
|
||||
|
||||
bitbuffer_invert(bitbuffer);
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ static int smoke_gs558_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
if (r < 0)
|
||||
return DECODE_ABORT_EARLY;
|
||||
|
||||
if (bitbuffer->bits_per_row[r] > 4*8)
|
||||
if (bitbuffer->bits_per_row[r] > 4 * 8)
|
||||
return DECODE_ABORT_LENGTH;
|
||||
|
||||
b = bitbuffer->bb[r];
|
||||
|
@ -99,7 +99,7 @@ static int smoke_gs558_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
id = ((b[2] & 0x0f) << 11) | (b[1] << 3) | (b[0] >> 5); // 15 bits
|
||||
|
||||
if (id == 0 || id == 0x7fff)
|
||||
return DECODE_FAIL_SANITY; // reject min/max to reduce false positives
|
||||
return DECODE_FAIL_SANITY; // reject min/max to reduce false positives
|
||||
|
||||
sprintf(code_str, "%02x%02x%02x", b[2], b[1], b[0]);
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ static int somfy_rts_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
|
||||
// descramble
|
||||
for (int i = 6; i > 0; i--)
|
||||
b[i] = b[i] ^ b[i-1];
|
||||
b[i] = b[i] ^ b[i - 1];
|
||||
|
||||
// calculate and verify checksum
|
||||
chksum_calc = xor_bytes(b, 7);
|
||||
|
|
|
@ -76,8 +76,8 @@ static int tfa_303196_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
if (b[0] != 0xa8)
|
||||
return DECODE_FAIL_SANITY;
|
||||
|
||||
uint16_t digest = (b[4] << 8) | (b[5]);
|
||||
int chk = lfsr_digest16(b, 4, 0x8810, 0x22d0) ^ digest;
|
||||
uint16_t digest = (b[4] << 8) | (b[5]);
|
||||
int chk = lfsr_digest16(b, 4, 0x8810, 0x22d0) ^ digest;
|
||||
|
||||
//bitrow_printf(b, 48, "TFA-303196 (%08x %04x %04x): ", chk_data, digest, session);
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ static int tfa_303221_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
bitbuffer_invert(bitbuffer);
|
||||
b = bitbuffer->bb[row];
|
||||
|
||||
device = b[0];
|
||||
device = b[0];
|
||||
|
||||
// Sanity Check
|
||||
if (device == 0)
|
||||
|
|
|
@ -40,7 +40,6 @@ L - lsfr, byte reflected reverse galois with 0x31 key and generator
|
|||
|
||||
#include "decoder.h"
|
||||
|
||||
|
||||
static int tfa_marbella_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
{
|
||||
data_t *data;
|
||||
|
@ -48,7 +47,7 @@ static int tfa_marbella_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
unsigned int serialnr, counter;
|
||||
unsigned bitpos = 0;
|
||||
uint8_t msg[11], ic;
|
||||
char serialnr_str[6*2 + 1];
|
||||
char serialnr_str[6 * 2 + 1];
|
||||
|
||||
uint8_t const preamble_pattern[] = {0xaa, 0x2d, 0xd4};
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ static int tfa_pool_thermometer_decode(r_device *decoder, bitbuffer_t *bitbuffer
|
|||
b = bitbuffer->bb[row];
|
||||
|
||||
checksum_rx = ((b[0] & 0xF0) >> 4);
|
||||
checksum = ((b[0] & 0x0F) +
|
||||
checksum = ((b[0] & 0x0F) +
|
||||
(b[1] >> 4) +
|
||||
(b[1] & 0x0F) +
|
||||
(b[2] >> 4) +
|
||||
|
@ -77,7 +77,6 @@ static int tfa_pool_thermometer_decode(r_device *decoder, bitbuffer_t *bitbuffer
|
|||
|
||||
decoder_output_data(decoder, data);
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
static char *output_fields[] = {
|
||||
|
|
|
@ -82,8 +82,6 @@ static int thermopro_tp12_sensor_callback(r_device *decoder, bitbuffer_t *bitbuf
|
|||
// or long-press its power button, it pairs with the first device ID it hears.
|
||||
device = bytes[0];
|
||||
|
||||
|
||||
|
||||
temp1_raw = ((bytes[2] & 0xf0) << 4) | bytes[1];
|
||||
temp2_raw = ((bytes[2] & 0x0f) << 8) | bytes[3];
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@ static int tpms_abarth124_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsi
|
|||
int status;
|
||||
int checksum;
|
||||
|
||||
|
||||
bitbuffer_manchester_decode(bitbuffer, row, bitpos, &packet_bits, 72);
|
||||
|
||||
// make sure we decoded the expected number of bits
|
||||
|
@ -62,7 +61,7 @@ static int tpms_abarth124_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsi
|
|||
// check checksum (checksum8 xor)
|
||||
checksum = xor_bytes(b, 9);
|
||||
if (checksum != 0) {
|
||||
return 0; //DECODE_FAIL_MIC;
|
||||
return 0; // DECODE_FAIL_MIC;
|
||||
}
|
||||
|
||||
sprintf(flags, "%02x", b[4]);
|
||||
|
|
|
@ -72,20 +72,20 @@ static int tpms_ave_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsigned r
|
|||
|
||||
switch (mode) {
|
||||
case 0:
|
||||
ratio = 2.352f;
|
||||
ratio = 2.352f;
|
||||
offset = 47.0f;
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
ratio = 2.352f;
|
||||
ratio = 2.352f;
|
||||
offset = 0.0f;
|
||||
break;
|
||||
case 2:
|
||||
ratio = 5.491f;
|
||||
ratio = 5.491f;
|
||||
offset = 18.2f;
|
||||
break;
|
||||
case 3:
|
||||
ratio = 5.491f;
|
||||
ratio = 5.491f;
|
||||
offset = 0.0f;
|
||||
break;
|
||||
}
|
||||
|
@ -123,8 +123,8 @@ static int tpms_ave_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
|
||||
int row;
|
||||
unsigned bitpos;
|
||||
int ret = 0;
|
||||
int events = 0;
|
||||
int ret = 0;
|
||||
int events = 0;
|
||||
|
||||
for (row = 0; row < bitbuffer->num_rows; ++row) {
|
||||
bitpos = 0;
|
||||
|
|
|
@ -48,7 +48,7 @@ static int tpms_citroen_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsign
|
|||
bitbuffer_manchester_decode(bitbuffer, row, bitpos, &packet_bits, 88);
|
||||
|
||||
// fprintf(stderr, "%s : bits %d\n", __func__, packet_bits.bits_per_row[0]);
|
||||
if ( packet_bits.bits_per_row[0] < 80) {
|
||||
if (packet_bits.bits_per_row[0] < 80) {
|
||||
return DECODE_FAIL_SANITY; // sanity check failed
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ static int tpms_citroen_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsign
|
|||
return DECODE_ABORT_EARLY; // sanity check failed
|
||||
}
|
||||
|
||||
crc = b[1]^b[2]^b[3]^b[4]^b[5]^b[6]^b[7]^b[8]^b[9];
|
||||
crc = b[1] ^ b[2] ^ b[3] ^ b[4] ^ b[5] ^ b[6] ^ b[7] ^ b[8] ^ b[9];
|
||||
if (crc != 0) {
|
||||
return DECODE_FAIL_MIC; // bad checksum
|
||||
}
|
||||
|
@ -67,10 +67,10 @@ static int tpms_citroen_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsign
|
|||
sprintf(state_str, "%02x", state);
|
||||
id = (unsigned)b[1] << 24 | b[2] << 16 | b[3] << 8 | b[4];
|
||||
sprintf(id_str, "%08x", id);
|
||||
flags = b[5]>>4;
|
||||
repeat = b[5]&0x0f;
|
||||
pressure = b[6];
|
||||
temperature = b[7];
|
||||
flags = b[5] >> 4;
|
||||
repeat = b[5] & 0x0f;
|
||||
pressure = b[6];
|
||||
temperature = b[7];
|
||||
maybe_battery = b[8];
|
||||
|
||||
/* clang-format off */
|
||||
|
|
|
@ -82,9 +82,9 @@ static int tpms_elantra2012_decode(r_device *decoder, bitbuffer_t *bitbuffer, un
|
|||
pressure_kpa = b[0] + 60;
|
||||
temperature_c = b[1] - 50;
|
||||
|
||||
storage = (b[6] & 0x04) >> 2;
|
||||
storage = (b[6] & 0x04) >> 2;
|
||||
battery_low = (b[6] & 0x02) >> 1;
|
||||
triggered = (b[6] & 0x01) >> 0;
|
||||
triggered = (b[6] & 0x01) >> 0;
|
||||
|
||||
/* clang-format off */
|
||||
data = data_make(
|
||||
|
|
|
@ -61,13 +61,13 @@ static int tpms_ford_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsigned
|
|||
sprintf(code_str, "%06x", code);
|
||||
|
||||
/* range seems to have different formulas */
|
||||
psibits = (((b[6]&0x20)<<3) | b[4]);
|
||||
psibits = (((b[6] & 0x20) << 3) | b[4]);
|
||||
if (psibits < 90)
|
||||
pressure_psi = 0.3 + psibits * 0.25f; // BdyCM + FORScan
|
||||
pressure_psi = 0.3 + psibits * 0.25f; // BdyCM + FORScan
|
||||
else
|
||||
pressure_psi = 6.8 + psibits * 0.2122727273;
|
||||
pressure_psi = 6.8 + psibits * 0.2122727273;
|
||||
temperature_c = b[5] - 56; // approximate
|
||||
if (b[6] & 0x40) // temperature scale mode?
|
||||
if (b[6] & 0x40) // temperature scale mode?
|
||||
temperature_c = (b[5] ^ 0x80) - 56;
|
||||
|
||||
/* clang-format off */
|
||||
|
|
|
@ -62,13 +62,13 @@ static int tpms_jansite_solar_decode(r_device *decoder, bitbuffer_t *bitbuffer,
|
|||
b = packet_bits.bb[0];
|
||||
|
||||
/* Check for sync */
|
||||
if ((b[0]<<8 | b[1]) != 0xdd33) {
|
||||
if ((b[0] << 8 | b[1]) != 0xdd33) {
|
||||
return DECODE_FAIL_SANITY;
|
||||
}
|
||||
|
||||
/* Check crc */
|
||||
uint16_t crc_calc = crc16(&b[2], 7, 0x8005, 0x0000);
|
||||
if ( ((b[9]<<8) | b[10]) != crc_calc) {
|
||||
if (((b[9] << 8) | b[10]) != crc_calc) {
|
||||
fprintf(stderr, "CRC mismatch %04x vs %02x %02x\n", crc_calc, b[9], b[10]);
|
||||
return DECODE_FAIL_MIC;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ static int tpms_pmv107j_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsign
|
|||
int crc;
|
||||
|
||||
start_pos = bitbuffer_differential_manchester_decode(bitbuffer, row, bitpos, &packet_bits, 70); // 67 bits expected
|
||||
if (start_pos - bitpos < 67*2) {
|
||||
if (start_pos - bitpos < 67 * 2) {
|
||||
return 0;
|
||||
}
|
||||
if (decoder->verbose > 1)
|
||||
|
@ -59,15 +59,15 @@ static int tpms_pmv107j_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsign
|
|||
return 0;
|
||||
}
|
||||
|
||||
id = b[0] << 26| b[1] << 18 | b[2] << 10 | b[3] << 2 | b[4] >> 6; // realigned bits 6 - 34
|
||||
status = b[4] & 0x3f; // status bits and 0 filler
|
||||
battery_low = (b[4] & 0x20) >> 5;
|
||||
counter = (b[4] & 0x18) >> 3;
|
||||
failed = b[4] & 0x01;
|
||||
pressure1 = b[5];
|
||||
pressure2 = b[6] ^ 0xff;
|
||||
temp = b[7];
|
||||
pressure_kpa = (pressure1 - 40.0) * 2.48;
|
||||
id = b[0] << 26 | b[1] << 18 | b[2] << 10 | b[3] << 2 | b[4] >> 6; // realigned bits 6 - 34
|
||||
status = b[4] & 0x3f; // status bits and 0 filler
|
||||
battery_low = (b[4] & 0x20) >> 5;
|
||||
counter = (b[4] & 0x18) >> 3;
|
||||
failed = b[4] & 0x01;
|
||||
pressure1 = b[5];
|
||||
pressure2 = b[6] ^ 0xff;
|
||||
temp = b[7];
|
||||
pressure_kpa = (pressure1 - 40.0) * 2.48;
|
||||
temperature_c = temp - 40.0;
|
||||
|
||||
if (pressure1 != pressure2) {
|
||||
|
@ -108,7 +108,7 @@ static int tpms_pmv107j_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
int events = 0;
|
||||
|
||||
// Find a preamble with enough bits after it that it could be a complete packet
|
||||
while ((bitpos = bitbuffer_search(bitbuffer, 0, bitpos, preamble_pattern, 6)) + 67*2 <=
|
||||
while ((bitpos = bitbuffer_search(bitbuffer, 0, bitpos, preamble_pattern, 6)) + 67 * 2 <=
|
||||
bitbuffer->bits_per_row[0]) {
|
||||
ret = tpms_pmv107j_decode(decoder, bitbuffer, 0, bitpos + 6);
|
||||
if (ret > 0)
|
||||
|
|
|
@ -53,7 +53,7 @@ static int tpms_porsche_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsign
|
|||
// Checksum is CRC-16 poly 0x1021 init 0xffff over 8 bytes
|
||||
int checksum = crc16(b, 10, 0x1021, 0xffff);
|
||||
if (checksum != 0) {
|
||||
return 0; //DECODE_FAIL_MIC;
|
||||
return 0; // DECODE_FAIL_MIC;
|
||||
}
|
||||
|
||||
int id = (unsigned)b[0] << 24 | b[1] << 16 | b[2] << 8 | b[3];
|
||||
|
|
|
@ -54,7 +54,7 @@ static int tpms_renault_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsign
|
|||
flags = b[0] >> 2;
|
||||
sprintf(flags_str, "%02x", flags);
|
||||
|
||||
id = b[5]<<16 | b[4]<<8 | b[3]; // little-endian
|
||||
id = b[5] << 16 | b[4] << 8 | b[3]; // little-endian
|
||||
sprintf(id_str, "%06x", id);
|
||||
|
||||
pressure_raw = (b[0] & 0x03) << 8 | b[1];
|
||||
|
|
|
@ -51,10 +51,10 @@ static int tpms_toyota_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsigne
|
|||
return 0;
|
||||
}
|
||||
|
||||
id = (unsigned)b[0] << 24 | b[1] << 16 | b[2] << 8 | b[3];
|
||||
status = (b[4] & 0x80) | (b[6] & 0x7f); // status bit and 0 filler
|
||||
id = (unsigned)b[0] << 24 | b[1] << 16 | b[2] << 8 | b[3];
|
||||
status = (b[4] & 0x80) | (b[6] & 0x7f); // status bit and 0 filler
|
||||
pressure1 = (b[4] & 0x7f) << 1 | b[5] >> 7;
|
||||
temp = (b[5] & 0x7f) << 1 | b[6] >> 7;
|
||||
temp = (b[5] & 0x7f) << 1 | b[6] >> 7;
|
||||
pressure2 = b[7] ^ 0xff;
|
||||
|
||||
if (pressure1 != pressure2) {
|
||||
|
|
|
@ -63,7 +63,7 @@ static int tpms_truck_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsigned
|
|||
|
||||
int chk = xor_bytes(b, 9);
|
||||
if (chk != 0) {
|
||||
return 0; //DECODE_FAIL_MIC;
|
||||
return 0; // DECODE_FAIL_MIC;
|
||||
}
|
||||
|
||||
int state = packet_bits.bb[0][0] >> 4; // fixed 0xa? could be sync
|
||||
|
|
|
@ -31,14 +31,13 @@ All bytes are sent with least significant bit FIRST (1000 0111 = 0xE1)
|
|||
|
||||
*/
|
||||
|
||||
|
||||
#include "decoder.h"
|
||||
|
||||
static int validate_checksum(r_device *decoder, uint8_t *b, int from, int to, int cs_from, int cs_to)
|
||||
{
|
||||
// Fields cs_from and cs_to hold the 2-byte checksum as signed int
|
||||
int expected = (b[cs_from] << 8) | b[cs_to];
|
||||
int calculated = add_bytes(&b[from], to-from+1);
|
||||
int expected = (b[cs_from] << 8) | b[cs_to];
|
||||
int calculated = add_bytes(&b[from], to - from + 1);
|
||||
int chk = (calculated + expected) & 0xffff;
|
||||
|
||||
if (chk) {
|
||||
|
|
|
@ -77,7 +77,7 @@ static int visonic_powercode_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
|
||||
lrc = xor_bytes(msg, 5);
|
||||
if (((lrc >> 4) ^ (lrc & 0xf)) != 0)
|
||||
return DECODE_FAIL_MIC;
|
||||
return DECODE_FAIL_MIC;
|
||||
|
||||
// debug
|
||||
if (decoder->verbose > 1) {
|
||||
|
|
|
@ -28,7 +28,7 @@ long-long (0 0 by the demod) not used (1 per protocol).
|
|||
static int waveman_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
{
|
||||
data_t *data;
|
||||
uint8_t *b = bitbuffer->bb[0];
|
||||
uint8_t *b = bitbuffer->bb[0];
|
||||
uint8_t nb[3] = {0}; // maps a pair of bits to two states, 1 0 -> 1 and 1 1 -> 0
|
||||
char id_str[2];
|
||||
int i;
|
||||
|
@ -37,7 +37,7 @@ static int waveman_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
|
||||
/* Reject codes of wrong length */
|
||||
if (25 != bitbuffer->bits_per_row[0])
|
||||
return DECODE_ABORT_LENGTH;
|
||||
return DECODE_ABORT_LENGTH;
|
||||
|
||||
/*
|
||||
* Catch the case triggering false positive for other transmitters.
|
||||
|
|
|
@ -75,7 +75,7 @@ static int wg_pb12v1_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
// Nibble 5,6,7 contains 12 bits of temperature
|
||||
// Temperature, scaled by 10, offset by -40 C.
|
||||
temp_raw = ((b[1] & 0x0F) << 8) | b[2];
|
||||
temp_c = ((float)temp_raw * 0.1) - 40;
|
||||
temp_c = ((float)temp_raw * 0.1) - 40;
|
||||
|
||||
/* clang-format off */
|
||||
data = data_make(
|
||||
|
|
|
@ -72,7 +72,7 @@ static int wssensor_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
if (decoder->verbose) {
|
||||
fprintf(stderr, "Hyundai WS SENZOR received raw data:\n");
|
||||
bitbuffer_print(bitbuffer);
|
||||
fprintf(stderr, "Sensor ID = %01d = 0x%02x\n", sensor_id, sensor_id);
|
||||
fprintf(stderr, "Sensor ID = %01d = 0x%02x\n", sensor_id, sensor_id);
|
||||
fprintf(stderr, "Bitstream HEX = ");
|
||||
bitrow_print(b, 24);
|
||||
fprintf(stderr, "Battery OK = %0d\n", battery_status);
|
||||
|
|
|
@ -29,7 +29,6 @@ WT0124 Pool Thermometer decoder.
|
|||
|
||||
#include "decoder.h"
|
||||
|
||||
|
||||
static int wt1024_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
{
|
||||
data_t *data;
|
||||
|
@ -39,30 +38,29 @@ static int wt1024_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
float temp_c;
|
||||
uint8_t channel;
|
||||
|
||||
if (bitbuffer->bits_per_row[1] !=49)
|
||||
if (bitbuffer->bits_per_row[1] != 49)
|
||||
return DECODE_ABORT_LENGTH;
|
||||
|
||||
|
||||
/* select row after preamble */
|
||||
b = bitbuffer->bb[1];
|
||||
|
||||
/* Validate constant */
|
||||
if (b[0]>>4 != 0x5) {
|
||||
if (b[0] >> 4 != 0x5) {
|
||||
return DECODE_ABORT_EARLY;
|
||||
}
|
||||
|
||||
/* Validate checksum */
|
||||
if ((b[0]^b[1]^b[2]^b[3]) != b[4])
|
||||
if ((b[0] ^ b[1] ^ b[2] ^ b[3]) != b[4])
|
||||
return DECODE_FAIL_MIC;
|
||||
|
||||
/* Get rid */
|
||||
sensor_rid = (b[0]&0x0F)<<4 | (b[1]&0x0F);
|
||||
sensor_rid = (b[0] & 0x0F) << 4 | (b[1] & 0x0F);
|
||||
|
||||
/* Get temperature */
|
||||
temp_c = ((((b[1] & 0xF) << 8) | b[2]) - 0x990) * 0.1f;
|
||||
|
||||
/* Get channel */
|
||||
channel = ((b[3]>>4) & 0x3);
|
||||
channel = ((b[3] >> 4) & 0x3);
|
||||
|
||||
/* unk */
|
||||
value = b[5];
|
||||
|
|
|
@ -76,7 +76,7 @@ static int wt450_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
return DECODE_ABORT_LENGTH;
|
||||
}
|
||||
|
||||
if (b[0]>>4 != 0xC) {
|
||||
if (b[0] >> 4 != 0xC) {
|
||||
if (decoder->verbose)
|
||||
bitbuffer_printf(bitbuffer, "%s: wrong preamble\n", __func__);
|
||||
return DECODE_ABORT_EARLY;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue