forked from r10r/rcswitch-pi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend.cpp
More file actions
40 lines (35 loc) · 1.07 KB
/
Copy pathsend.cpp
File metadata and controls
40 lines (35 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
Usage: ./send <pin> <unitCode> <command>
<pin> wiring pi pin number
<unitCode> should be 0, 1, 2, ... etc
<command> is 0 for OFF and 1 for ON
*/
#include "RCSwitch.h"
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
int PIN = atoi(argv[1]);
int unitCode = atoi(argv[2]);
int command = atoi(argv[3]);
long baseAddr = 14649346;
if (wiringPiSetup () == -1) return 1;
printf("sending on pin[%i] unitCode[%i] command[%i]\n", PIN, unitCode, command);
RCSwitch mySwitch = RCSwitch();
mySwitch.enableTransmit(PIN);
mySwitch.setPulseLength(342);
mySwitch.setRepeatTransmit(10);
switch(command) {
case 1:
mySwitch.send(baseAddr + unitCode*16 + 8, 24);
//mySwitch.switchOn(systemCode, unitCode);
break;
case 0:
mySwitch.send(baseAddr + unitCode*16, 24);
//mySwitch.switchOff(systemCode, unitCode);
break;
default:
printf("command[%i] is unsupported\n", command);
return -1;
}
return 0;
}