From 7de6791568488806c549b1b713d60119a83d10b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20N=C3=BC=C3=9Flein?= Date: Sat, 10 May 2014 23:35:38 +0200 Subject: [PATCH 1/2] step --- send.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/send.cpp b/send.cpp index 076e77c..401ed99 100644 --- a/send.cpp +++ b/send.cpp @@ -14,7 +14,7 @@ int main(int argc, char *argv[]) { see https://projects.drogon.net/raspberry-pi/wiringpi/pins/ for pin mapping of the raspberry pi GPIO connector */ - int PIN = 0; + int PIN = 1; char* systemCode = argv[1]; int unitCode = atoi(argv[2]); int command = atoi(argv[3]); From 5ae97837a548a48c4e862b8cef31a8d1b27a98a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20N=C3=BC=C3=9Flein?= Date: Sun, 11 May 2014 00:01:18 +0200 Subject: [PATCH 2/2] added Intertechno capabilities --- send.cpp | 161 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 134 insertions(+), 27 deletions(-) diff --git a/send.cpp b/send.cpp index 401ed99..9805900 100644 --- a/send.cpp +++ b/send.cpp @@ -1,39 +1,146 @@ /* - Usage: ./send + Usage: ./send + SystemCodeType is 1 for default and 2 for switches with 10 Bits 123456ABCD Command is 0 for OFF and 1 for ON */ #include "RCSwitch.h" #include #include +#include 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 = 1; - 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); + + /* + 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 = 1; // GPIO-PIN 17 + int systemCodeType = atoi(argv[1]); + char* systemCode = argv[2]; + int unitCode = atoi(argv[3]); + int command = atoi(argv[4]); + char pSystemCode[14]; + + if (wiringPiSetup () == -1) return 1; + printf("sending systemCodeType[%i] systemCode[%s] unitCode[%i] command[%i] ...\n", systemCodeType, systemCode, unitCode, command); + RCSwitch mySwitch = RCSwitch(); + printf("defining transmit PIN[%i] ... ",PIN); + mySwitch.enableTransmit(PIN); + printf("success\n"); + printf("computing system Code Type ...\n"); + switch(systemCodeType) + { + case 1: + { + printf("Switching \"default\" system[%s] unit[%i] ... ", systemCode, unitCode); + switch(command) + { + case 0: + { + printf("off\n"); + mySwitch.switchOff(systemCode, unitCode); + break; + } + case 1: + { + printf("on\n"); + mySwitch.switchOn("00011", unitCode); + break; + } + default: + { + printf("command[%i] is unsupported\n", command); + return -1; + } + } + break; + } + case 2: + { + printf("computing systemcode for Intertechno Type B house[%i] unit[%i] ... ",atoi(systemCode), unitCode); + switch(atoi(systemCode)) + { + // house/family code A=1 - P=16 + case 1: { printf("1/A ... "); strcpy(pSystemCode,"0000"); break; } + case 2: { printf("2/B ... "); strcpy(pSystemCode,"F000"); break; } + case 3: { printf("3/C ... "); strcpy(pSystemCode,"0F00"); break; } + case 4: { printf("4/D ... "); strcpy(pSystemCode,"FF00"); break; } + case 5: { printf("5/E ... "); strcpy(pSystemCode,"00F0"); break; } + case 6: { printf("6/F ... "); strcpy(pSystemCode,"F0F0"); break; } + case 7: { printf("7/G ... "); strcpy(pSystemCode,"0FF0"); break; } + case 8: { printf("8/H ... "); strcpy(pSystemCode,"FFF0"); break; } + case 9: { printf("9/I ... "); strcpy(pSystemCode,"000F"); break; } + case 10: { printf("10/J ... "); strcpy(pSystemCode,"F00F"); break; } + case 11: { printf("11/K ... "); strcpy(pSystemCode,"0F0F"); break; } + case 12: { printf("12/L ... "); strcpy(pSystemCode,"FF0F"); break; } + case 13: { printf("13/M ... "); strcpy(pSystemCode,"00FF"); break; } + case 14: { printf("14/N ... "); strcpy(pSystemCode,"F0FF"); break; } + case 15: { printf("15/O ... "); strcpy(pSystemCode,"0FFF"); break; } + case 16: { printf("16/P ... "); strcpy(pSystemCode,"FFFF"); break; } + default: + { + printf("systemCode[%s] is unsupported\n", systemCode); + return -1; + } + } + printf("got systemCode\n"); + switch(unitCode) + { + // unit/group code 01-16 + case 1: { printf("1 ... "); strcat(pSystemCode,"0000"); break; } + case 2: { printf("2 ... "); strcat(pSystemCode,"F000"); break; } + case 3: { printf("3 ... "); strcat(pSystemCode,"0F00"); break; } + case 4: { printf("4 ... "); strcat(pSystemCode,"FF00"); break; } + case 5: { printf("5 ... "); strcat(pSystemCode,"00F0"); break; } + case 6: { printf("6 ... "); strcat(pSystemCode,"F0F0"); break; } + case 7: { printf("7 ... "); strcat(pSystemCode,"0FF0"); break; } + case 8: { printf("8 ... "); strcat(pSystemCode,"FFF0"); break; } + case 9: { printf("9 ... "); strcat(pSystemCode,"000F"); break; } + case 10: { printf("10 ... "); strcat(pSystemCode,"F00F"); break; } + case 11: { printf("11 ... "); strcat(pSystemCode,"0F0F"); break; } + case 12: { printf("12 ... "); strcat(pSystemCode,"FF0F"); break; } + case 13: { printf("13 ... "); strcat(pSystemCode,"00FF"); break; } + case 14: { printf("14 ... "); strcat(pSystemCode,"F0FF"); break; } + case 15: { printf("15 ... "); strcat(pSystemCode,"0FFF"); break; } + case 16: { printf("16 ... "); strcat(pSystemCode,"FFFF"); break; } + default: + { + printf("unitCode[%i] is unsupported\n", unitCode); + return -1; + } + } + strcat(pSystemCode,"0F"); // mandatory bits + switch(command) + { + case 0: + { + strcat(pSystemCode,"F0"); + mySwitch.sendTriState(pSystemCode); + printf("sent TriState signal: pSystemCode[%s]\n",pSystemCode); + break; + } + case 1: + { + strcat(pSystemCode,"FF"); + mySwitch.sendTriState(pSystemCode); + printf("sent TriState signal: pSystemCode[%s]\n",pSystemCode); + break; + } + default: + { + printf("command[%i] is unsupported\n", command); + return -1; + } + } break; + } default: - printf("command[%i] is unsupported\n", command); - return -1; + { + printf("command sequence unknown, aborting!\n"); + return -1; + } + } + return 0; } - return 0; -}