--- smsdaemon/SmsPdu.cpp 2008/06/11 21:18:04 60 +++ smsdaemon/SmsPdu.cpp 2008/06/12 11:05:18 61 @@ -43,6 +43,12 @@ } } + if ((input.length() % 2) == 1) + { + current |= 0xF0; + result.push_back(current); + } + return result; } @@ -61,6 +67,13 @@ return os.str(); } +std::string Encode8to7bit(vector vec) +{ + string result; + + return result; +} + vector Encode7to8bit(std::string str) { vector buf; @@ -92,16 +105,19 @@ { bool multipart = allowMultipart && message.length() > 160; - const unsigned char UHDI = multipart ? 0x40 : 0; + const unsigned char UDHI = multipart ? 0x40 : 0; srand(time(0)); - unsigned char csms_ref = rand() % 256; + unsigned char csms_ref = rand() % 128; int part_count; + + const int PDU_LEN = 153; + if (multipart) { - part_count = message.length() / 153; - if (message.length() % 153) + part_count = message.length() / PDU_LEN; + if (message.length() % PDU_LEN) part_count++; } else @@ -115,7 +131,7 @@ vector pdu; pdu.push_back(0x00); // use SMSC from phone - pdu.push_back( 0x01|UHDI ); // first octet -- no timeout + pdu.push_back( 0x01|UDHI ); // first octet -- no timeout pdu.push_back(0x00); // TP-MR message reference pdu.push_back(to.length() ); //length of phone nr pdu.push_back(0x91); // type of address (international nr + ISDN/telephone range) - else try 0x81 @@ -124,20 +140,21 @@ pdu.insert( pdu.end(), phone.begin(), phone.end()); pdu.push_back(0x00); // Protocol identifier - pdu.push_back(0x00); // Data coding scheme + pdu.push_back(0x00); // Data coding scheme string message_part; if (multipart) { - message_part = message.substr(0,153); - message.erase(0,153); + message_part = message.substr(0, PDU_LEN); + message.erase(0, PDU_LEN); - pdu.push_back( message_part.length()+5 ); //UserDataLength - pdu.push_back( 0x00 ); // UDH[0] - pdu.push_back( 0x03 ); // UDH[1] = UDH_LEN - pdu.push_back( csms_ref ); //UDH[2] + pdu.push_back( message_part.length()+ 6 ); //UserDataLength + pdu.push_back( 0x05 ); // UDH Len + pdu.push_back( 0x00 ); // UDH Element Identifier + pdu.push_back( 0x03 ); // UDH element length + pdu.push_back( csms_ref ); // csms_ref reference pdu.push_back( part_count ); - pdu.push_back( partnr ); + pdu.push_back( partnr+1 ); } else