43 |
} |
} |
44 |
} |
} |
45 |
|
|
46 |
|
if ((input.length() % 2) == 1) |
47 |
|
{ |
48 |
|
current |= 0xF0; |
49 |
|
result.push_back(current); |
50 |
|
} |
51 |
|
|
52 |
return result; |
return result; |
53 |
} |
} |
54 |
|
|
67 |
return os.str(); |
return os.str(); |
68 |
} |
} |
69 |
|
|
70 |
|
std::string Encode8to7bit(vector<unsigned char> vec) |
71 |
|
{ |
72 |
|
string result; |
73 |
|
|
74 |
|
return result; |
75 |
|
} |
76 |
|
|
77 |
vector<unsigned char> Encode7to8bit(std::string str) |
vector<unsigned char> Encode7to8bit(std::string str) |
78 |
{ |
{ |
79 |
vector<unsigned char> buf; |
vector<unsigned char> buf; |
105 |
{ |
{ |
106 |
bool multipart = allowMultipart && message.length() > 160; |
bool multipart = allowMultipart && message.length() > 160; |
107 |
|
|
108 |
const unsigned char UHDI = multipart ? 0x40 : 0; |
const unsigned char UDHI = multipart ? 0x40 : 0; |
109 |
|
|
110 |
srand(time(0)); |
srand(time(0)); |
111 |
unsigned char csms_ref = rand() % 256; |
unsigned char csms_ref = rand() % 128; |
112 |
|
|
113 |
int part_count; |
int part_count; |
114 |
|
|
115 |
|
const int PDU_LEN = 153; |
116 |
|
|
117 |
if (multipart) |
if (multipart) |
118 |
{ |
{ |
119 |
part_count = message.length() / 153; |
part_count = message.length() / PDU_LEN; |
120 |
if (message.length() % 153) |
if (message.length() % PDU_LEN) |
121 |
part_count++; |
part_count++; |
122 |
} |
} |
123 |
else |
else |
131 |
vector<unsigned char> pdu; |
vector<unsigned char> pdu; |
132 |
|
|
133 |
pdu.push_back(0x00); // use SMSC from phone |
pdu.push_back(0x00); // use SMSC from phone |
134 |
pdu.push_back( 0x01|UHDI ); // first octet -- no timeout |
pdu.push_back( 0x01|UDHI ); // first octet -- no timeout |
135 |
pdu.push_back(0x00); // TP-MR message reference |
pdu.push_back(0x00); // TP-MR message reference |
136 |
pdu.push_back(to.length() ); //length of phone nr |
pdu.push_back(to.length() ); //length of phone nr |
137 |
pdu.push_back(0x91); // type of address (international nr + ISDN/telephone range) - else try 0x81 |
pdu.push_back(0x91); // type of address (international nr + ISDN/telephone range) - else try 0x81 |
140 |
pdu.insert( pdu.end(), phone.begin(), phone.end()); |
pdu.insert( pdu.end(), phone.begin(), phone.end()); |
141 |
|
|
142 |
pdu.push_back(0x00); // Protocol identifier |
pdu.push_back(0x00); // Protocol identifier |
143 |
pdu.push_back(0x00); // Data coding scheme |
pdu.push_back(0x00); // Data coding scheme |
144 |
|
|
145 |
string message_part; |
string message_part; |
146 |
if (multipart) |
if (multipart) |
147 |
{ |
{ |
148 |
message_part = message.substr(0,153); |
message_part = message.substr(0, PDU_LEN); |
149 |
message.erase(0,153); |
message.erase(0, PDU_LEN); |
150 |
|
|
151 |
pdu.push_back( message_part.length()+5 ); //UserDataLength |
pdu.push_back( message_part.length()+ 7 ); //UserDataLength |
152 |
pdu.push_back( 0x00 ); // UDH[0] |
pdu.push_back( 0x06 ); // UDH Len |
153 |
pdu.push_back( 0x03 ); // UDH[1] = UDH_LEN |
pdu.push_back( 0x00 ); // UDH Element Identifier |
154 |
pdu.push_back( csms_ref ); //UDH[2] |
pdu.push_back( 0x03 ); // UDH element length |
155 |
|
pdu.push_back( csms_ref ); // csms_ref reference |
156 |
pdu.push_back( part_count ); |
pdu.push_back( part_count ); |
157 |
pdu.push_back( partnr ); |
pdu.push_back( partnr+1 ); |
158 |
|
pdu.push_back( 0x00); |
159 |
|
|
160 |
} |
} |
161 |
else |
else |