Skip to content

Fix make error on newer Linux builds #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
CXXFLAGS += -Wall
CXXFLAGS += -Wall -fpermissive
CXXFLAGS += -lwiringPi

all: codesend RFSniffer

codesend: RCSwitch.o codesend.o
Expand Down
84 changes: 44 additions & 40 deletions src/RCSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ char* RCSwitch::getCodeWordB(int nAddressCode, int nChannelCode, boolean bStatus

const char* code[5] = { "FFFF", "0FFF", "F0FF", "FF0F", "FFF0" };
if (nAddressCode < 1 || nAddressCode > 4 || nChannelCode < 1 || nChannelCode > 4) {
return '\0';
sReturn[0] = '\0';
return sReturn;
}
for (int i = 0; i<4; i++) {
sReturn[nReturnPos++] = code[nAddressCode][i];
Expand Down Expand Up @@ -229,7 +230,8 @@ char* RCSwitch::getCodeWordA(char* sGroup, int nChannelCode, boolean bStatus) {
const char* code[6] = { "FFFFF", "0FFFF", "F0FFF", "FF0FF", "FFF0F", "FFFF0" };

if (nChannelCode < 1 || nChannelCode > 5) {
return '\0';
sReturn[0] = '\0';
return sReturn;
}

for (int i = 0; i<5; i++) {
Expand All @@ -238,7 +240,8 @@ char* RCSwitch::getCodeWordA(char* sGroup, int nChannelCode, boolean bStatus) {
} else if (sGroup[i] == '1') {
sReturn[nReturnPos++] = '0';
} else {
return '\0';
sReturn[0] = '\0';
return sReturn;
}
}

Expand Down Expand Up @@ -266,7 +269,8 @@ char* RCSwitch::getCodeWordC(char sFamily, int nGroup, int nDevice, boolean bSta
int nReturnPos = 0;

if ( (byte)sFamily < 97 || (byte)sFamily > 112 || nGroup < 1 || nGroup > 4 || nDevice < 1 || nDevice > 4) {
return '\0';
sReturn[0] = '\0';
return sReturn;
}

char* sDeviceGroupCode = dec2binWzerofill( (nDevice-1) + (nGroup-1)*4, 4 );
Expand Down Expand Up @@ -444,7 +448,7 @@ void RCSwitch::enableReceive(int interrupt) {
void RCSwitch::enableReceive() {
if (this->nReceiverInterrupt != -1) {
RCSwitch::nReceivedValue = NULL;
RCSwitch::nReceivedBitlength = NULL;
RCSwitch::nReceivedBitlength = NULL;
wiringPiISR(this->nReceiverInterrupt, INT_EDGE_BOTH, &handleInterrupt);
}
}
Expand Down Expand Up @@ -556,41 +560,41 @@ bool RCSwitch::receiveProtocol2(unsigned int changeCount){
return true;
}

}

void RCSwitch::handleInterrupt() {

static unsigned int duration;
static unsigned int changeCount;
static unsigned long lastTime;
static unsigned int repeatCount;

long time = micros();
duration = time - lastTime;

if (duration > 5000 && duration > RCSwitch::timings[0] - 200 && duration < RCSwitch::timings[0] + 200) {
repeatCount++;
changeCount--;

if (repeatCount == 2) {
if (receiveProtocol1(changeCount) == false){
if (receiveProtocol2(changeCount) == false){
//failed
}
}
repeatCount = 0;
}
changeCount = 0;
} else if (duration > 5000) {
changeCount = 0;
}

if (changeCount >= RCSWITCH_MAX_CHANGES) {
changeCount = 0;
repeatCount = 0;
}
RCSwitch::timings[changeCount++] = duration;
lastTime = time;
}
void RCSwitch::handleInterrupt() {
static unsigned int duration;
static unsigned int changeCount;
static unsigned long lastTime;
static unsigned int repeatCount;
long time = micros();
duration = time - lastTime;
if (duration > 5000 && duration > RCSwitch::timings[0] - 200 && duration < RCSwitch::timings[0] + 200) {
repeatCount++;
changeCount--;
if (repeatCount == 2) {
if (receiveProtocol1(changeCount) == false){
if (receiveProtocol2(changeCount) == false){
//failed
}
}
repeatCount = 0;
}
changeCount = 0;
} else if (duration > 5000) {
changeCount = 0;
}
if (changeCount >= RCSWITCH_MAX_CHANGES) {
changeCount = 0;
repeatCount = 0;
}
RCSwitch::timings[changeCount++] = duration;
lastTime = time;
}

/**
Expand Down