2 Usage: ./send <systemCode> <unitCode> <command>
3 Command is 0 for OFF and 1 for ON
6 #include "../rc-switch/RCSwitch.h"
10 int main(int argc, char *argv[]) {
13 output PIN is hardcoded for testing purposes
14 see https://projects.drogon.net/raspberry-pi/wiringpi/pins/
15 for pin mapping of the raspberry pi GPIO connector
18 const char* code[6] = { "00000", "10000", "01000", "00100", "00010", "00001" };
21 printf("Sending 433 MHz remote plug control codes, hardcoded on wiringpi pin %d.\n", PIN);
22 printf("Usage: %s <systemCode> <unitCode> <command> [pulseLength]\n", argv[0]);
23 printf("systemCode - First five settings of Type A 10 pole DIP switch, e.g. 11111\n");
24 printf("unitCode - Switch number [1 .. 5] or [10000 .. 00001]\n");
25 printf("command - 0 for OFF and 1 for ON\n");
26 printf("pulseLength - optional pulse length\n");
30 char* systemCode = argv[1];
32 if (strlen(argv[2]) == 5) {
34 } else if (atoi(argv[2]) > 0 and atoi(argv[2]) < 6) {
35 unitCode = code[atoi(argv[2])];
39 int command = atoi(argv[3]);
41 if (wiringPiSetup () == -1) return 1;
42 printf("sending systemCode[%s] unitCode[%s] command[%i]\n", systemCode, unitCode, command);
43 RCSwitch mySwitch = RCSwitch();
45 mySwitch.setPulseLength(atoi(argv[4]));
46 mySwitch.enableTransmit(PIN);
50 mySwitch.switchOn(systemCode, unitCode);
53 mySwitch.switchOff(systemCode, unitCode);
56 printf("command[%i] is unsupported\n", command);