--- smsdaemon/SmsPdu.cpp 2008/06/12 15:16:12 66 +++ smsdaemon/SmsPdu.cpp 2008/06/12 18:54:24 68 @@ -21,37 +21,38 @@ { -vector BcdEncode(string input) -{ - char buf[2] = " "; - vector result; - unsigned char current; - for (unsigned int i=0; i vec) { ostringstream os; @@ -67,13 +68,38 @@ return os.str(); } -std::string Encode8to7bit(vector vec) +std::string Decode8to7bit(vector input) { string result; + int shift = 0; + for (unsigned int i=0; i0) ? input.at(i-1) : 0; + + current <<= shift; + + prev >>= (8-shift); + + unsigned char byte = current | prev; + byte &= 0x7F; + + result.append(1, byte); + + if (shift == 6) + result.append(1, input.at(i) >> 1); + + shift = (shift+1) % 7; + + } + return result; } + + + vector Encode7to8bit(std::string str) { vector buf; @@ -142,7 +168,8 @@ pdu.push_back(to.length() ); //length of phone nr pdu.push_back(0x81); // type of address (international nr + ISDN/telephone range) - else try 0x81 - vector phone = BcdEncode(to); + + string phone = EncodePhonenr(to); pdu.insert( pdu.end(), phone.begin(), phone.end()); pdu.push_back(0x00); // Protocol identifier