Skip to content
Open
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
added "repeatTransmit" parameter to codesend
  • Loading branch information
Christian Frenzl committed Nov 17, 2018
commit f598173199cd80726cfd2d297476db6ea5b631f9
6 changes: 5 additions & 1 deletion RPi_utils/codesend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,30 @@ 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 repeatTransmit = 0;

// 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] [repeatTransmit]\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("repeatTransmit\t- How often to repeat the code. Defaults to 10.\n");
return -1;
}

// Change protocol and pulse length accroding to parameters
int code = atoi(argv[1]);
if (argc >= 3) protocol = atoi(argv[2]);
if (argc >= 4) pulseLength = atoi(argv[3]);
if (argc >= 5) repeatTransmit = atoi(argv[4]);

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

mySwitch.send(code, 24);
Expand Down