Skip to content
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

Enhanced support #1

Merged
merged 2 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions RPi_utils/RFSniffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ int main(int argc, char *argv[]) {

if (mySwitch.available()) {

int value = mySwitch.getReceivedValue();
unsigned long value = mySwitch.getReceivedValue();

if (value == 0) {
printf("Unknown encoding\n");
} else {

printf("Received %i\n", mySwitch.getReceivedValue() );
printf("Received %lu\n", mySwitch.getReceivedValue() );
}

fflush(stdout);
Expand Down
12 changes: 8 additions & 4 deletions RPi_utils/codesend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,33 @@ int main(int argc, char *argv[]) {
// Parse the first parameter to this command as an integer
int protocol = 0; // A value of 0 will use rc-switch's default value
int pulseLength = 0;
int bitLength = 24;

// If no command line argument is given, print the help text
if (argc == 1) {
printf("Usage: %s decimalcode [protocol] [pulselength]\n", argv[0]);
printf("Usage: %s decimalcode [protocol] [pulselength] [bitlength]\n", argv[0]);
printf("decimalcode\t- As decoded by RFSniffer\n");
printf("protocol\t- According to rc-switch definitions\n");
printf("pulselength\t- pulselength in microseconds\n");
printf("bitlength\t- bit length\n");
return -1;
}

// Change protocol and pulse length accroding to parameters
int code = atoi(argv[1]);
char *eptr;
unsigned long code = strtoul(argv[1], &eptr, 10);
if (argc >= 3) protocol = atoi(argv[2]);
if (argc >= 4) pulseLength = atoi(argv[3]);
if (argc >= 5) bitLength = atoi(argv[4]);

if (wiringPiSetup () == -1) return 1;
printf("sending code[%i]\n", code);
printf("sending code[%lu]\n", code);
RCSwitch mySwitch = RCSwitch();
if (protocol != 0) mySwitch.setProtocol(protocol);
if (pulseLength != 0) mySwitch.setPulseLength(pulseLength);
mySwitch.enableTransmit(PIN);

mySwitch.send(code, 24);
mySwitch.send(code, bitLength);

return 0;

Expand Down