Skip to content

Commit

Permalink
Merge pull request #81 from SiberaIndustries/master
Browse files Browse the repository at this point in the history
Fix data type + support variable bit lengths
  • Loading branch information
elliots authored Dec 2, 2022
2 parents 31c0ea4 + 1344495 commit 755cec1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
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

0 comments on commit 755cec1

Please sign in to comment.