Files
2026-09-14 12:43:38 +02:00

42 lines
1.3 KiB
C++
Executable File

//compile with -lwiringPi
//g++ -pthread ../../wiringPi/433Utils/rc-switch/RCSwitch.o sendRC_Schlafzimmer.cpp -o sendRC_Schlafzimmer -lwiringPi
#include "/home/lucas/wiringPi/433Utils/rc-switch/RCSwitch.h"
#include <stdlib.h>
extern "C" {
#include <wiringPi.h>
}
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;
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;//G17
// Parse the first parameter to this command as an integer
int protocol = 2; // A value of 0 will use rc-switch's default value
int pulseLength = 0;
int length = 24;
string arg=string(argv[1]);
// Change protocol and pulse length accroding to parameters
int code=0;
if(arg.compare("OFF")==0) code=891819008;
else if(arg.compare("ON")==0) code=958927872;
if (wiringPiSetup () == -1) return 1;
cout << "Switching " << arg << endl;
RCSwitch mySwitch = RCSwitch();
if (protocol != 0) mySwitch.setProtocol(protocol);
if (pulseLength != 0) mySwitch.setPulseLength(pulseLength);
mySwitch.enableTransmit(PIN);
mySwitch.send(code, length);
return 0;
}