forked from r10r/rcswitch-pi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodesend.cpp
More file actions
39 lines (26 loc) · 1.02 KB
/
codesend.cpp
File metadata and controls
39 lines (26 loc) · 1.02 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
/*
'codesend' hacked from 'send' by @justy
- The provided rc_switch 'send' command uses the form systemCode, unitCode, command
which is not suitable for our purposes. Instead, we call
send(code, length); // where length is always 24 and code is simply the code
we find using the RF_sniffer.ino Arduino sketch.
Usage: ./codesend decimalcode
(Use RF_Sniffer.ino to check that RF signals are being produced by the RPi's transmitter)
*/
#include "RCSwitch.h"
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
// This pin is not the first pin on the RPi GPIO header!
// Consult https://projects.drogon.net/raspberry-pi/wiringpi/pins/
// for more information.
int PIN = 0;
// Parse the firt parameter to this command as an integer
int code = strtol(argv[1],NULL,16);
if (wiringPiSetup () == -1) return 1;
printf("sending code[%i]\n", code);
RCSwitch mySwitch = RCSwitch();
mySwitch.enableTransmit(PIN);
mySwitch.send(code, 32);
return 0;
}