Skip to content

Commit

Permalink
RCSwitch: add send from r10r
Browse files Browse the repository at this point in the history
* Removed trailing whitespaces, retabbed, reformatted
* Updated Makefile
* Added some more files to gitignore
  • Loading branch information
xkonni committed Nov 7, 2012
1 parent 5e45bd3 commit 20c1ac4
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
test
send
daemon
*.o
*.swp
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ DESCRIPTION = "RCSwitch on Raspberry Pi"
LICENSE = "GPL"
VERSION = 1.0

CC = g++
CFLAGS += -lwiringPi
CXXFLAGS += -Wall
CXXFLAGS += -lwiringPi

default: daemon

daemon: daemon.cpp
$(CC) -Wall daemon.cpp RCSwitch.cpp -o daemon $(CFLAGS)
daemon: RCSwitch.o daemon.o
$(CXX) $+ -o $@ $(CXXFLAGS) $(LDFLAGS)

test: test.cpp
$(CC) -Wall test.cpp RCSwitch.cpp -o test $(CFLAGS)
send: RCSwitch.o send.o
$(CXX) $+ -o $@ $(CXXFLAGS) $(LDFLAGS)

clean:
rm -f test daemon
rm -f *.o send daemon
39 changes: 39 additions & 0 deletions send.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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;
printf("sending systemCode[%s] unitCode[%i] command[%i]\n", systemCode, unitCode, command);
RCSwitch mySwitch = RCSwitch();
mySwitch.enableTransmit(PIN);

switch(command) {
case 1:
mySwitch.switchOn(systemCode, unitCode);
break;
case 0:
mySwitch.switchOff(systemCode, unitCode);
break;
default:
printf("command[%i] is unsupported\n", command);
return -1;
}
return 0;
}

0 comments on commit 20c1ac4

Please sign in to comment.