-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds x10_sec device for decoding X10 Security RF signals #671
Merged
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0773d81
Adds x10_sec device for decoding X10 Security RF signals
2e11f0b
Change to loop through buffer, formatting improvements
dd216e2
Additional formatting fixes
fcb5f3c
Fixes spacing in comments
17e9a19
Removes redundant 'else'
7563509
Removes spaces in debug output for consistency
2aba697
Cleans-up validation thanks to help from zuckschwerdt
6b664f5
Changes if -> continue to one-line for consistency
2cf231e
Removes declarations for two now unused variables
4fd01ad
Removes declaration for an used variable
27889c4
Increments MAX_PROTOCOLS from 98 to 99
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
/* | ||
* X10 Security sensor decoding for rtl_433 | ||
* | ||
* Based on code provided by Willi 'wherzig' in issue #30 (2014-04-21) | ||
* https://github.com/merbanan/rtl_433/issues/30 | ||
* Danke, Willi | ||
* | ||
* Tested with American sensors operating at 310 MHz | ||
* e.g., rtl_433 -f 310.558M | ||
* | ||
* This is pretty rudimentary, and I bet the byte value decoding, based | ||
* on limited observations, doesn't take into account bits that might | ||
* be set to indicate something like a low battery condition. | ||
* | ||
* Copyright (C) 2018 Anthony Kava | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
*/ | ||
|
||
#include "rtl_433.h" | ||
#include "data.h" | ||
#include "util.h" | ||
|
||
static int x10_sec_callback(bitbuffer_t *bitbuffer) { | ||
bitrow_t *bb = bitbuffer->bb; | ||
data_t *data; | ||
uint16_t r; /* a row index */ | ||
uint8_t *b; /* bits of a row */ | ||
uint8_t test_a; /* test 1/2 for message */ | ||
uint8_t test_b; /* test 2/2 for message */ | ||
char *event_str = "UNKNOWN"; /* human-readable event */ | ||
char x10_id_str[5] = "\0"; /* string showing hex value */ | ||
char x10_code_str[5] = "\0"; /* string showing hex value */ | ||
char time_str[LOCAL_TIME_BUFLEN]; | ||
|
||
for (r=0; r < bitbuffer->num_rows; ++r) { | ||
b = bitbuffer->bb[r]; | ||
|
||
/* looking for five bytes */ | ||
if (bitbuffer->bits_per_row[r] < 40) { | ||
continue; | ||
} | ||
|
||
/* validate what we received ... | ||
* used intermediate variables test_a and test_b to suppress | ||
* warnings generated when compiling using: | ||
* | ||
* if((b[0]^0x0f)==b[1] && (b[2]^0xff)==b[3]) | ||
*/ | ||
test_a = b[0] ^ 0x0f; | ||
test_b = b[2] ^ 0xff; | ||
if (test_a != b[1] || test_b != b[3]) { | ||
continue; | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you don't need this |
||
/* set event_str based on code received */ | ||
switch(b[2]) { | ||
case 0x04: | ||
event_str = "DS10A DOOR/WINDOW OPEN"; | ||
break; | ||
case 0x06: | ||
event_str = "KR10A KEY-FOB ARM"; | ||
break; | ||
case 0x0c: | ||
event_str = "MS10A MOTION TRIPPED"; | ||
break; | ||
case 0x46: | ||
event_str = "KR10A KEY-FOB LIGHTS-ON"; | ||
break; | ||
case 0x82: | ||
event_str = "SH624 SEC-REMOTE DISARM"; | ||
break; | ||
case 0x84: | ||
event_str = "DS10A DOOR/WINDOW CLOSED"; | ||
break; | ||
case 0x86: | ||
event_str = "KR10A KEY-FOB DISARM"; | ||
break; | ||
case 0x88: | ||
event_str = "KR15A PANIC"; | ||
break; | ||
case 0x8c: | ||
event_str = "MS10A MOTION READY"; | ||
break; | ||
case 0x98: | ||
event_str = "KR15A PANIC-3SECOND"; | ||
break; | ||
case 0xc6: | ||
event_str = "KR10A KEY-FOB LIGHTS-OFF"; | ||
break; | ||
} | ||
|
||
/* get x10_id_str, x10_code_str, and time_str ready for output */ | ||
sprintf(x10_id_str, "%02x%02x", b[0], b[4]); | ||
sprintf(x10_code_str, "%02x", b[2]); | ||
local_time_str(0, time_str); | ||
|
||
/* debug output */ | ||
if (debug_output) { | ||
fprintf(stderr, "%20s X10SEC: id = %02x%02x code=%02x event_str=%s\n", time_str, b[0], b[4], b[2], event_str); | ||
bitbuffer_print(bitbuffer); | ||
} | ||
|
||
/* build and handle data set for normal output */ | ||
data = data_make( | ||
"time", "", DATA_STRING, time_str, | ||
"model", "", DATA_STRING, "X10 Security", | ||
"id", "Device ID", DATA_STRING, x10_id_str, | ||
"code", "Code", DATA_STRING, x10_code_str, | ||
"event", "Event", DATA_STRING, event_str, | ||
NULL | ||
); | ||
data_acquired_handler(data); | ||
|
||
return 1; | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
static char *output_fields[] = { | ||
"time", | ||
"model", | ||
"id", | ||
"code", | ||
"event", | ||
NULL | ||
}; | ||
|
||
/* r_device definition */ | ||
r_device x10_sec = { | ||
.name = "X10 Security", | ||
.modulation = OOK_PULSE_PPM_RAW, /* new equivalent to OOK_PWM_D */ | ||
.short_limit = 1100, | ||
.long_limit = 2200, | ||
.reset_limit = 10000, | ||
.json_callback = &x10_sec_callback, | ||
.disabled = 1, | ||
.demod_arg = 0, | ||
.fields = output_fields | ||
}; | ||
|
||
// vim: ts=4 sts=4 sw=4 et |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this var is also unused. everything else looks perfect.