forked from denschu/rcswitch-pi
-
Notifications
You must be signed in to change notification settings - Fork 2
/
sendRev.cpp
44 lines (36 loc) · 1.05 KB
/
sendRev.cpp
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
41
42
43
44
/*
Example for REV outlets.
Usage: ./sendRev <systemCode> <unitCode> <command>
Command is 0 for OFF and 1 for ON
*/
#include <stdlib.h>
#include <stdio.h>
#include "RCSwitch.h"
int main(int argc, char *argv[]) {
/*
output PIN is hardcoded for testing purposes
see https://projects.drogon.net/raspberry-pi/wiringpi/pins/
for pin mapping of the raspberry pi GPIO connector
*/
int PIN = 0;
char* sGroup = argv[1];
int nDevice = atoi(argv[2]);
int command = atoi(argv[3]);
if (wiringPiSetup () == -1) return 1;
printf("sending sGroup[%s] nDevice[%i] command[%i]\n", sGroup, nDevice, command);
RCSwitch mySwitch = RCSwitch();
mySwitch.enableTransmit(PIN);
//mySwitch.setPulseLength(360);
switch(command) {
case 1:
mySwitch.switchOn(sGroup[0], nDevice);
break;
case 0:
mySwitch.switchOff(sGroup[0], nDevice);
break;
default:
printf("command[%i] is unsupported\n", command);
return -1;
}
return 0;
}