forked from xkonni/raspberry-remote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
send.cpp
49 lines (44 loc) · 1.18 KB
/
send.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
45
46
47
48
49
/*
* Usage: ./send <systemCode> <unitCode> <command>
* Command is 0 for OFF and 1 for ON
*/
#include "RCSwitch.h"
#include <stdlib.h>
#include <stdio.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* systemCode = argv[1];
int unitCode = atoi(argv[2]);
int command = atoi(argv[3]);
if (wiringPiSetup () == -1) return 1;
piHiPri(20);
printf("sending systemCode[%s] unitCode[%i] command[%i]\n", systemCode, unitCode, command);
RCSwitch mySwitch = RCSwitch();
mySwitch.setPulseLength(300);
mySwitch.enableTransmit(PIN);
switch(command) {
case 1:
mySwitch.switchOn(systemCode, unitCode);
break;
case 0:
mySwitch.switchOff(systemCode, unitCode);
break;
case 2:
// 00001 2 on binary coded
mySwitch.send("010101010001000101010001");
break;
case 3:
// 00001 2 on as TriState
mySwitch.sendTriState("FFFF0F0FFF0F");
break;
default:
printf("command[%i] is unsupported\n", command);
return -1;
}
return 0;
}