Specifying chars as unsigned where needed
This commit is contained in:
parent
47eac0a356
commit
0b6bc13466
2 changed files with 25 additions and 25 deletions
|
@ -23,7 +23,7 @@ int ProtocolIkea::methods() const {
|
||||||
|
|
||||||
std::string ProtocolIkea::getStringForMethod(int method, unsigned char level, Controller *) {
|
std::string ProtocolIkea::getStringForMethod(int method, unsigned char level, Controller *) {
|
||||||
const char B1[] = {84, 84, 0};
|
const char B1[] = {84, 84, 0};
|
||||||
const char B0[] = {170, 0};
|
const unsigned char B0[] = {170, 0};
|
||||||
|
|
||||||
int intSystem = this->getIntParameter(L"system", 1, 16)-1;
|
int intSystem = this->getIntParameter(L"system", 1, 16)-1;
|
||||||
int intFadeStyle = TelldusCore::comparei(this->getStringParameter(L"fade", L"true"), L"true");
|
int intFadeStyle = TelldusCore::comparei(this->getStringParameter(L"fade", L"true"), L"true");
|
||||||
|
@ -86,13 +86,13 @@ std::string ProtocolIkea::getStringForMethod(int method, unsigned char level, Co
|
||||||
else
|
else
|
||||||
checksum1++;
|
checksum1++;
|
||||||
} else {
|
} else {
|
||||||
strChannels.append(B0);
|
strChannels.append(reinterpret_cast<const char *>(B0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strReturn.append(strChannels); // System + Units
|
strReturn.append(strChannels); // System + Units
|
||||||
|
|
||||||
strReturn.append(checksum1 %2 == 0 ? B1 : B0); // 1st checksum
|
strReturn.append(checksum1 %2 == 0 ? B1 : reinterpret_cast<const char *>(B0)); // 1st checksum
|
||||||
strReturn.append(checksum2 %2 == 0 ? B1 : B0); // 2nd checksum
|
strReturn.append(checksum2 %2 == 0 ? B1 : reinterpret_cast<const char *>(B0)); // 2nd checksum
|
||||||
|
|
||||||
int intLevel = 0;
|
int intLevel = 0;
|
||||||
if (level <= 12) {
|
if (level <= 12) {
|
||||||
|
@ -138,12 +138,12 @@ std::string ProtocolIkea::getStringForMethod(int method, unsigned char level, Co
|
||||||
else
|
else
|
||||||
checksum2++;
|
checksum2++;
|
||||||
} else {
|
} else {
|
||||||
strReturn.append(B0);
|
strReturn.append(reinterpret_cast<const char *>(B0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
strReturn.append(checksum1 %2 == 0 ? B1 : B0); // 1st checksum
|
strReturn += checksum1 %2 == 0 ? B1 : reinterpret_cast<const char *>(B0); // 1st checksum
|
||||||
strReturn.append(checksum2 %2 == 0 ? B1 : B0); // 2nd checksum
|
strReturn += checksum2 %2 == 0 ? B1 : reinterpret_cast<const char *>(B0); // 2nd checksum
|
||||||
|
|
||||||
strReturn.append("+");
|
strReturn.append("+");
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ int ProtocolX10::methods() const {
|
||||||
std::string ProtocolX10::getStringForMethod(int method, unsigned char data, Controller *controller) {
|
std::string ProtocolX10::getStringForMethod(int method, unsigned char data, Controller *controller) {
|
||||||
const unsigned char S = 59, L = 169;
|
const unsigned char S = 59, L = 169;
|
||||||
const char B0[] = {S, S, 0};
|
const char B0[] = {S, S, 0};
|
||||||
const char B1[] = {S, L, 0};
|
const unsigned char B1[] = {S, L, 0};
|
||||||
const unsigned char START_CODE[] = {'S', 255, 1, 255, 1, 255, 1, 100, 255, 1, 180, 0};
|
const unsigned char START_CODE[] = {'S', 255, 1, 255, 1, 255, 1, 100, 255, 1, 180, 0};
|
||||||
const unsigned char STOP_CODE[] = {S, 0};
|
const unsigned char STOP_CODE[] = {S, 0};
|
||||||
|
|
||||||
|
@ -42,73 +42,73 @@ std::string ProtocolX10::getStringForMethod(int method, unsigned char data, Cont
|
||||||
|
|
||||||
for( int i = 0; i < 4; ++i ) {
|
for( int i = 0; i < 4; ++i ) {
|
||||||
if (intHouse & 1) {
|
if (intHouse & 1) {
|
||||||
strReturn.append(B1);
|
strReturn.append(reinterpret_cast<const char *>(B1));
|
||||||
strComplement.append(B0);
|
strComplement.append(B0);
|
||||||
} else {
|
} else {
|
||||||
strReturn.append(B0);
|
strReturn.append(B0);
|
||||||
strComplement.append(B1);
|
strComplement.append(reinterpret_cast<const char *>(B1));
|
||||||
}
|
}
|
||||||
intHouse >>= 1;
|
intHouse >>= 1;
|
||||||
}
|
}
|
||||||
strReturn.append( B0 );
|
strReturn.append( B0 );
|
||||||
strComplement.append( B1 );
|
strComplement.append( reinterpret_cast<const char *>(B1) );
|
||||||
|
|
||||||
if (intCode >= 8) {
|
if (intCode >= 8) {
|
||||||
strReturn.append(B1);
|
strReturn.append(reinterpret_cast<const char *>(B1));
|
||||||
strComplement.append(B0);
|
strComplement.append(B0);
|
||||||
} else {
|
} else {
|
||||||
strReturn.append(B0);
|
strReturn.append(B0);
|
||||||
strComplement.append(B1);
|
strComplement.append(reinterpret_cast<const char *>(B1));
|
||||||
}
|
}
|
||||||
|
|
||||||
strReturn.append( B0 );
|
strReturn.append( B0 );
|
||||||
strComplement.append( B1 );
|
strComplement.append( reinterpret_cast<const char *>(B1) );
|
||||||
strReturn.append( B0 );
|
strReturn.append( B0 );
|
||||||
strComplement.append( B1 );
|
strComplement.append( reinterpret_cast<const char *>(B1) );
|
||||||
|
|
||||||
strReturn.append( strComplement );
|
strReturn.append( strComplement );
|
||||||
strComplement = "";
|
strComplement = "";
|
||||||
|
|
||||||
strReturn.append( B0 );
|
strReturn.append( B0 );
|
||||||
strComplement.append( B1 );
|
strComplement.append( reinterpret_cast<const char *>(B1) );
|
||||||
|
|
||||||
if (intCode >> 2 & 1) { // Bit 2 of intCode
|
if (intCode >> 2 & 1) { // Bit 2 of intCode
|
||||||
strReturn.append(B1);
|
strReturn.append(reinterpret_cast<const char *>(B1));
|
||||||
strComplement.append(B0);
|
strComplement.append(B0);
|
||||||
} else {
|
} else {
|
||||||
strReturn.append(B0);
|
strReturn.append(B0);
|
||||||
strComplement.append(B1);
|
strComplement.append(reinterpret_cast<const char *>(B1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (method == TELLSTICK_TURNON) {
|
if (method == TELLSTICK_TURNON) {
|
||||||
strReturn.append(B0);
|
strReturn.append(B0);
|
||||||
strComplement.append(B1);
|
strComplement.append(reinterpret_cast<const char *>(B1));
|
||||||
} else if (method == TELLSTICK_TURNOFF) {
|
} else if (method == TELLSTICK_TURNOFF) {
|
||||||
strReturn.append(B1);
|
strReturn.append(reinterpret_cast<const char *>(B1));
|
||||||
strComplement.append(B0);
|
strComplement.append(B0);
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intCode & 1) { // Bit 0 of intCode
|
if (intCode & 1) { // Bit 0 of intCode
|
||||||
strReturn.append(B1);
|
strReturn.append(reinterpret_cast<const char *>(B1));
|
||||||
strComplement.append(B0);
|
strComplement.append(B0);
|
||||||
} else {
|
} else {
|
||||||
strReturn.append(B0);
|
strReturn.append(B0);
|
||||||
strComplement.append(B1);
|
strComplement.append(reinterpret_cast<const char *>(B1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intCode >> 1 & 1) { // Bit 1 of intCode
|
if (intCode >> 1 & 1) { // Bit 1 of intCode
|
||||||
strReturn.append(B1);
|
strReturn.append(reinterpret_cast<const char *>(B1));
|
||||||
strComplement.append(B0);
|
strComplement.append(B0);
|
||||||
} else {
|
} else {
|
||||||
strReturn.append(B0);
|
strReturn.append(B0);
|
||||||
strComplement.append(B1);
|
strComplement.append(reinterpret_cast<const char *>(B1));
|
||||||
}
|
}
|
||||||
|
|
||||||
for( int i = 0; i < 3; ++i ) {
|
for( int i = 0; i < 3; ++i ) {
|
||||||
strReturn.append( B0 );
|
strReturn.append( B0 );
|
||||||
strComplement.append( B1 );
|
strComplement.append( reinterpret_cast<const char *>(B1) );
|
||||||
}
|
}
|
||||||
|
|
||||||
strReturn.append( strComplement );
|
strReturn.append( strComplement );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue