Added non-working function TellStick::convertSToT()

This commit is contained in:
Micke Prag 2011-02-21 11:02:33 +00:00
parent 5d413b9b99
commit 9d290f632a
2 changed files with 38 additions and 0 deletions

View file

@ -385,3 +385,39 @@ bool TelldusCore::TellStick::stillConnected() const {
return false;
#endif
}
std::string TelldusCore::TellStick::convertSToT( unsigned char t0, unsigned char t1, unsigned char t2, unsigned char t3, const std::string &data ) {
unsigned char dataByte = 0;
std::string retString = "R\1T";
retString.append(1, t0);
retString.append(1, t1);
retString.append(1, t2);
retString.append(1, t3);
if (data.length() > 255) {
return "";
}
unsigned char length = (unsigned char)data.length();
retString.append(1, length);
for (size_t i = 0; i < data.length(); ++i) {
dataByte <<= 2;
if (data.at(i) == '1') {
dataByte |= 1;
} else if (data.at(i) == '2') {
dataByte |= 2;
} else if (data.at(i) == '3') {
dataByte |= 3;
}
if ( (i+1) % 4 == 0) {
retString.append(1, dataByte);
dataByte = 0;
}
}
if (data.length() % 4 != 0) {
retString.append(1, dataByte);
}
retString.append("+");
return retString;
}

View file

@ -43,6 +43,8 @@ namespace TelldusCore {
static TellStick *findFirstDevice(int vid = 0, int pid = 0);
static TellStick *loadBy(int vid, int pid, const std::string &serial);
static std::string convertSToT( unsigned char t0, unsigned char t1, unsigned char t2, unsigned char t3, const std::string &data );
protected:
TellStick(const TellStickDescriptor &d);