Skip to content

Commit

Permalink
Merge remote-tracking branch 'xkonni/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	send.cpp
  • Loading branch information
tillepille authored and tillepille committed Mar 25, 2016
2 parents 0483112 + 7081c10 commit 471272b
Show file tree
Hide file tree
Showing 2 changed files with 440 additions and 141 deletions.
144 changes: 3 additions & 141 deletions send.cpp
Original file line number Diff line number Diff line change
@@ -1,149 +1,11 @@
/*
Usage: ./send <command>
SystemCodeType is 1 for default and 2 for switches with 10 Bits 123456ABCD
Command is 0 for OFF and 1 for ON
* Usage: ./send <systemCode> <unitCode> <command>
* Command is 0 for OFF and 1 for ON
*/

#include "RCSwitch.h"
#include <stdlib.h>
#include <stdio.h>
<<<<<<< HEAD
#include <string.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 systemCodeType = atoi(argv[1]);
char* systemCode = argv[2];
int unitCode = atoi(argv[3]);
int command = atoi(argv[4]);
int PIN = 0; //GPIO-Pin 17
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.switchOffBinary(systemCode, unitCode);
break;
}
case 1:
{
printf("on\n");
mySwitch.switchOnBinary(systemCode, unitCode);
break;
}
default:
{
printf("command[%i] is unsupported\n", command);
return -1;
}
}
break;
}
case 2:
{
printf("computing systemcode for Intertechno Type B house[%s] unit[%i] ... ",systemCode, unitCode);
char pSystemCode[14];
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 sequence unknown, aborting!\n");
return -1;
}
}
return 0;
=======
#include <string>
#include <getopt.h>
//#include <iostream>
Expand Down Expand Up @@ -338,5 +200,5 @@ int main(int argc, char *argv[]) {
} else {
printUsage();
return -1;
>>>>>>> xkonni/master
}
}
Loading

0 comments on commit 471272b

Please sign in to comment.