mirror of
https://github.com/merbanan/rtl_433.git
synced 2026-04-22 18:46:58 -04:00
Update code style
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -66,7 +66,7 @@ static uint8_t danfoss_decode_nibble(uint8_t byte) {
|
||||
}
|
||||
|
||||
|
||||
static int danfoss_CFR_callback(bitbuffer_t *bitbuffer) {
|
||||
static int danfoss_cfr_callback(bitbuffer_t *bitbuffer) {
|
||||
uint8_t bytes[NUM_BYTES]; // Decoded bytes with two 4 bit nibbles in each
|
||||
data_t *data;
|
||||
char time_str[LOCAL_TIME_BUFLEN];
|
||||
@@ -169,7 +169,7 @@ r_device danfoss_CFR = {
|
||||
.short_limit = 100, // NRZ decoding
|
||||
.long_limit = 100, // Bit width
|
||||
.reset_limit = 500, // Maximum run is 4 zeroes/ones
|
||||
.json_callback = &danfoss_CFR_callback,
|
||||
.json_callback = &danfoss_cfr_callback,
|
||||
.disabled = 0,
|
||||
.demod_arg = 0,
|
||||
.fields = output_fields
|
||||
|
||||
@@ -39,7 +39,7 @@ ft004b_callback(bitbuffer_t *bitbuffer)
|
||||
char time_str[LOCAL_TIME_BUFLEN];
|
||||
data_t *data;
|
||||
|
||||
if(bitbuffer->bits_per_row[0] != 137 && bitbuffer->bits_per_row[0] != 138) {
|
||||
if (bitbuffer->bits_per_row[0] != 137 && bitbuffer->bits_per_row[0] != 138) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -57,10 +57,10 @@ ft004b_callback(bitbuffer_t *bitbuffer)
|
||||
|
||||
local_time_str(0, time_str);
|
||||
data = data_make(
|
||||
"time", "", DATA_STRING, time_str,
|
||||
"model", "", DATA_STRING, "FT-004-B Temperature Sensor",
|
||||
"temperature_C", "Temperature", DATA_FORMAT, "%.1f", DATA_DOUBLE, temperature,
|
||||
NULL);
|
||||
"time", "", DATA_STRING, time_str,
|
||||
"model", "", DATA_STRING, "FT-004-B Temperature Sensor",
|
||||
"temperature_C", "Temperature", DATA_FORMAT, "%.1f", DATA_DOUBLE, temperature,
|
||||
NULL);
|
||||
data_acquired_handler(data);
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -14,24 +14,21 @@
|
||||
|
||||
#include "decoder.h"
|
||||
|
||||
|
||||
// Frame preamble:
|
||||
// 11001100 11001100 11001100 11001100 11001100 11111111 00000000
|
||||
// c c c c c c c c c c f f 0 0
|
||||
static const unsigned char preamble_pattern[3] = {0xcc, 0xff, 0x00};
|
||||
|
||||
|
||||
// Helper to access single bit (copied from bitbuffer.c)
|
||||
static inline int bit(const uint8_t *bytes, unsigned bit)
|
||||
{
|
||||
return bytes[bit >> 3] >> (7 - (bit & 7)) & 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Decodes the following encoding scheme:
|
||||
* 10 = 0
|
||||
* 1100 = 1
|
||||
* 1100 = 1
|
||||
*/
|
||||
unsigned ge_decode(bitbuffer_t *inbuf, unsigned row, unsigned start, bitbuffer_t *outbuf)
|
||||
{
|
||||
@@ -64,8 +61,8 @@ unsigned ge_decode(bitbuffer_t *inbuf, unsigned row, unsigned start, bitbuffer_t
|
||||
return ipos;
|
||||
}
|
||||
|
||||
char * ge_command_name(uint8_t command) {
|
||||
char * out = "0xxx";
|
||||
char *ge_command_name(uint8_t command) {
|
||||
char *out = "0xxx";
|
||||
|
||||
switch(command) {
|
||||
case 0x5a: return "change"; break;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* All bytes are sent with least significant bit FIRST (1000 0111 = 0xE1)
|
||||
*
|
||||
* 2 Bytes | 1 Byte | 5 Bytes | 1 Byte | 1 Byte | 1 Byte | 1 Byte
|
||||
* 2 Bytes | 1 Byte | 5 Bytes | 1 Byte | 1 Byte | 1 Byte | 1 Byte
|
||||
* Sync Word | Message Type | Device ID | CS Seed | Command | SUM CMD + CS | Epilogue
|
||||
*
|
||||
* Copyright (C) 2018 Adam Callis <adam.callis@gmail.com>
|
||||
@@ -16,57 +16,57 @@
|
||||
static void
|
||||
ss_get_id(char *id, uint8_t *b)
|
||||
{
|
||||
char *p = id;
|
||||
char *p = id;
|
||||
|
||||
// Change to least-significant-bit last (protocol uses least-siginificant-bit first) for hex representation:
|
||||
for (uint16_t k = 3; k <= 7; k++) {
|
||||
b[k] = reverse8(b[k]);
|
||||
sprintf(p++, "%c", (char)b[k]);
|
||||
}
|
||||
*p = '\0';
|
||||
// Change to least-significant-bit last (protocol uses least-siginificant-bit first) for hex representation:
|
||||
for (uint16_t k = 3; k <= 7; k++) {
|
||||
b[k] = reverse8(b[k]);
|
||||
sprintf(p++, "%c", (char)b[k]);
|
||||
}
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
static int
|
||||
ss_sensor_parser(bitbuffer_t *bitbuffer, int row)
|
||||
{
|
||||
char time_str[LOCAL_TIME_BUFLEN];
|
||||
data_t *data;
|
||||
uint8_t *b = bitbuffer->bb[row];
|
||||
char id[6];
|
||||
char extradata[30] = "";
|
||||
char time_str[LOCAL_TIME_BUFLEN];
|
||||
data_t *data;
|
||||
uint8_t *b = bitbuffer->bb[row];
|
||||
char id[6];
|
||||
char extradata[30] = "";
|
||||
|
||||
// each row needs to have exactly 92 bits
|
||||
if (bitbuffer->bits_per_row[row] != 92)
|
||||
return 0;
|
||||
// each row needs to have exactly 92 bits
|
||||
if (bitbuffer->bits_per_row[row] != 92)
|
||||
return 0;
|
||||
|
||||
uint8_t seq = reverse8(b[8]);
|
||||
uint8_t state = reverse8(b[9]);
|
||||
uint8_t csum = reverse8(b[10]);
|
||||
if (((seq + state) & 0xff) != csum) return 0;
|
||||
uint8_t seq = reverse8(b[8]);
|
||||
uint8_t state = reverse8(b[9]);
|
||||
uint8_t csum = reverse8(b[10]);
|
||||
if (((seq + state) & 0xff) != csum) return 0;
|
||||
|
||||
ss_get_id(id, b);
|
||||
ss_get_id(id, b);
|
||||
|
||||
if (state == 1) {
|
||||
strcpy(extradata,"Contact Open");
|
||||
} else if (state == 2) {
|
||||
strcpy(extradata,"Contact Closed");
|
||||
} else if (state == 3) {
|
||||
strcpy(extradata,"Alarm Off");
|
||||
}
|
||||
if (state == 1) {
|
||||
strcpy(extradata,"Contact Open");
|
||||
} else if (state == 2) {
|
||||
strcpy(extradata,"Contact Closed");
|
||||
} else if (state == 3) {
|
||||
strcpy(extradata,"Alarm Off");
|
||||
}
|
||||
|
||||
local_time_str(0, time_str);
|
||||
data = data_make(
|
||||
"time", "", DATA_STRING, time_str,
|
||||
"model", "", DATA_STRING, "SimpliSafe Sensor",
|
||||
"device", "Device ID", DATA_STRING, id,
|
||||
"seq", "Sequence", DATA_INT, seq,
|
||||
"state", "State", DATA_INT, state,
|
||||
"extradata", "Extra Data", DATA_STRING, extradata,
|
||||
NULL
|
||||
);
|
||||
data_acquired_handler(data);
|
||||
local_time_str(0, time_str);
|
||||
data = data_make(
|
||||
"time", "", DATA_STRING, time_str,
|
||||
"model", "", DATA_STRING, "SimpliSafe Sensor",
|
||||
"device", "Device ID", DATA_STRING, id,
|
||||
"seq", "Sequence", DATA_INT, seq,
|
||||
"state", "State", DATA_INT, state,
|
||||
"extradata", "Extra Data", DATA_STRING, extradata,
|
||||
NULL
|
||||
);
|
||||
data_acquired_handler(data);
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -92,18 +92,18 @@ ss_pinentry_parser(bitbuffer_t *bitbuffer, int row)
|
||||
|
||||
sprintf(extradata, "Disarm Pin: %x%x%x%x", digits[0], digits[1], digits[2], digits[3]);
|
||||
|
||||
local_time_str(0, time_str);
|
||||
data = data_make(
|
||||
"time", "", DATA_STRING, time_str,
|
||||
"model", "", DATA_STRING, "SimpliSafe Keypad",
|
||||
"device", "Device ID", DATA_STRING, id,
|
||||
"seq", "Sequence", DATA_INT, b[9],
|
||||
"extradata", "Extra Data", DATA_STRING, extradata,
|
||||
NULL
|
||||
);
|
||||
data_acquired_handler(data);
|
||||
local_time_str(0, time_str);
|
||||
data = data_make(
|
||||
"time", "", DATA_STRING, time_str,
|
||||
"model", "", DATA_STRING, "SimpliSafe Keypad",
|
||||
"device", "Device ID", DATA_STRING, id,
|
||||
"seq", "Sequence", DATA_INT, b[9],
|
||||
"extradata", "Extra Data", DATA_STRING, extradata,
|
||||
NULL
|
||||
);
|
||||
data_acquired_handler(data);
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -117,58 +117,58 @@ ss_keypad_commands(bitbuffer_t *bitbuffer, int row)
|
||||
|
||||
if (b[10] == 0x6a) {
|
||||
strcpy(extradata, "Arm System - Away");
|
||||
} else if (b[10] == 0xca) {
|
||||
strcpy(extradata, "Arm System - Home");
|
||||
} else if (b[10] == 0x3a) {
|
||||
strcpy(extradata, "Arm System - Cancelled");
|
||||
} else if (b[10] == 0x2a) {
|
||||
strcpy(extradata, "Keypad Panic Button");
|
||||
} else if (b[10] == 0x86) {
|
||||
strcpy(extradata, "Keypad Menu Button");
|
||||
} else {
|
||||
sprintf(extradata, "Unknown Keypad: %02x", b[10]);
|
||||
}
|
||||
} else if (b[10] == 0xca) {
|
||||
strcpy(extradata, "Arm System - Home");
|
||||
} else if (b[10] == 0x3a) {
|
||||
strcpy(extradata, "Arm System - Cancelled");
|
||||
} else if (b[10] == 0x2a) {
|
||||
strcpy(extradata, "Keypad Panic Button");
|
||||
} else if (b[10] == 0x86) {
|
||||
strcpy(extradata, "Keypad Menu Button");
|
||||
} else {
|
||||
sprintf(extradata, "Unknown Keypad: %02x", b[10]);
|
||||
}
|
||||
|
||||
ss_get_id(id, b);
|
||||
ss_get_id(id, b);
|
||||
|
||||
local_time_str(0, time_str);
|
||||
data = data_make(
|
||||
"time", "", DATA_STRING, time_str,
|
||||
"model", "", DATA_STRING, "SimpliSafe Keypad",
|
||||
"device", "", DATA_STRING, id,
|
||||
"seq", "Sequence",DATA_INT, b[9],
|
||||
"extradata", "", DATA_STRING, extradata,
|
||||
NULL
|
||||
);
|
||||
data_acquired_handler(data);
|
||||
local_time_str(0, time_str);
|
||||
data = data_make(
|
||||
"time", "", DATA_STRING, time_str,
|
||||
"model", "", DATA_STRING, "SimpliSafe Keypad",
|
||||
"device", "", DATA_STRING, id,
|
||||
"seq", "Sequence",DATA_INT, b[9],
|
||||
"extradata", "", DATA_STRING, extradata,
|
||||
NULL
|
||||
);
|
||||
data_acquired_handler(data);
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
ss_sensor_callback(bitbuffer_t *bitbuffer)
|
||||
{
|
||||
// Require two identical rows.
|
||||
int row = bitbuffer_find_repeated_row(bitbuffer, 2, 90);
|
||||
if (row < 0) return 0;
|
||||
// Require two identical rows.
|
||||
int row = bitbuffer_find_repeated_row(bitbuffer, 2, 90);
|
||||
if (row < 0) return 0;
|
||||
|
||||
// The row must start with 0xcc5f (0x33a0 inverted).
|
||||
uint8_t *b = bitbuffer->bb[row];
|
||||
if (b[0] != 0xcc || b[1] != 0x5f) return 0;
|
||||
// The row must start with 0xcc5f (0x33a0 inverted).
|
||||
uint8_t *b = bitbuffer->bb[row];
|
||||
if (b[0] != 0xcc || b[1] != 0x5f) return 0;
|
||||
|
||||
bitbuffer_invert(bitbuffer);
|
||||
bitbuffer_invert(bitbuffer);
|
||||
|
||||
if (b[2] == 0x88) {
|
||||
return ss_sensor_parser(bitbuffer, row);
|
||||
} else if (b[2] == 0x66) {
|
||||
return ss_pinentry_parser(bitbuffer, row);
|
||||
} else if (b[2] == 0x44) {
|
||||
return ss_keypad_commands(bitbuffer, row);
|
||||
} else {
|
||||
if (debug_output)
|
||||
fprintf(stderr, "Unknown Message Type: %02x\n", b[2]);
|
||||
return 0;
|
||||
}
|
||||
if (b[2] == 0x88) {
|
||||
return ss_sensor_parser(bitbuffer, row);
|
||||
} else if (b[2] == 0x66) {
|
||||
return ss_pinentry_parser(bitbuffer, row);
|
||||
} else if (b[2] == 0x44) {
|
||||
return ss_keypad_commands(bitbuffer, row);
|
||||
} else {
|
||||
if (debug_output)
|
||||
fprintf(stderr, "Unknown Message Type: %02x\n", b[2]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static char *sensor_output_fields[] = {
|
||||
|
||||
@@ -91,7 +91,7 @@ get_battery_status(uint8_t * msg)
|
||||
}
|
||||
|
||||
static int
|
||||
vaillant_vrt340_parser(bitbuffer_t *bitbuffer)
|
||||
vaillant_vrt340_callback(bitbuffer_t *bitbuffer)
|
||||
{
|
||||
bitrow_t *bb = bitbuffer->bb;
|
||||
|
||||
@@ -192,12 +192,6 @@ vaillant_vrt340_parser(bitbuffer_t *bitbuffer)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
vaillant_vrt340_callback(bitbuffer_t *bitbuffer)
|
||||
{
|
||||
return vaillant_vrt340_parser(bitbuffer);
|
||||
}
|
||||
|
||||
static char *output_fields[] = {
|
||||
"time",
|
||||
"model",
|
||||
|
||||
Reference in New Issue
Block a user