2 Usage: ./codesend decimalcode [protocol] [pulselength]
3 decimalcode - As decoded by RFSniffer
4 protocol - According to rc-switch definitions
5 pulselength - pulselength in microseconds
7 'codesend' hacked from 'send' by @justy
9 - The provided rc_switch 'send' command uses the form systemCode, unitCode, command
10 which is not suitable for our purposes. Instead, we call
11 send(code, length); // where length is always 24 and code is simply the code
12 we find using the RF_sniffer.ino Arduino sketch.
14 (Use RF_Sniffer.ino to check that RF signals are being produced by the RPi's transmitter
15 or your remote control)
17 #include "../rc-switch/RCSwitch.h"
22 int main(int argc, char *argv[]) {
24 // This pin is not the first pin on the RPi GPIO header!
25 // Consult https://projects.drogon.net/raspberry-pi/wiringpi/pins/
26 // for more information.
29 // Parse the first parameter to this command as an integer
30 int protocol = 0; // A value of 0 will use rc-switch's default value
33 // If no command line argument is given, print the help text
35 printf("Usage: %s decimalcode [protocol] [pulselength]\n", argv[0]);
36 printf("decimalcode\t- As decoded by RFSniffer\n");
37 printf("protocol\t- According to rc-switch definitions\n");
38 printf("pulselength\t- pulselength in microseconds\n");
42 // Change protocol and pulse length accroding to parameters
43 int code = atoi(argv[1]);
44 if (argc >= 3) protocol = atoi(argv[2]);
45 if (argc >= 4) pulseLength = atoi(argv[3]);
47 if (wiringPiSetup () == -1) return 1;
48 printf("sending code[%i]\n", code);
49 RCSwitch mySwitch = RCSwitch();
50 if (protocol != 0) mySwitch.setProtocol(protocol);
51 if (pulseLength != 0) mySwitch.setPulseLength(pulseLength);
52 mySwitch.enableTransmit(PIN);
54 mySwitch.send(code, 24);