/[projects]/smsdaemon/SmsPdu.cpp
ViewVC logotype

Diff of /smsdaemon/SmsPdu.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 70 by torben, Fri Jun 13 07:56:57 2008 UTC revision 73 by torben, Fri Jun 13 09:09:36 2008 UTC
# Line 36  namespace SmsPdu Line 36  namespace SmsPdu
36    
37          string EncodePhonenr(string input)          string EncodePhonenr(string input)
38          {          {
39                    if ( input.at(0) == '+' )
40                            input.erase(0,1);
41    
42                  if ( (input.length() % 2) == 1)                  if ( (input.length() % 2) == 1)
43                          input.append("F");                          input.append("F");
44                  return SwitchChars(input);                  return SwitchChars(input);
# Line 78  namespace SmsPdu Line 81  namespace SmsPdu
81                  return vec;                  return vec;
82          }          }
83    
84          std::string Decode8to7bit(vector<unsigned char> input, int shift_start = 0)          std::string Decode8to7bit(vector<unsigned char> input, int shift_start)
85          {          {
86                  string result;                  string result;
87    
# Line 110  namespace SmsPdu Line 113  namespace SmsPdu
113    
114    
115    
116          vector<unsigned char> Encode7to8bit(std::string str)          vector<unsigned char> Encode7to8bit(std::string str, int shift_start)
117          {          {
118                  vector<unsigned char> buf;                  vector<unsigned char> buf;
119    
120                  int shift = 0;                  int shift = shift_start;
121                  for (unsigned int i=0; i<str.size(); ++i)                  for (unsigned int i=0; i<str.size(); ++i)
122                  {                  {
123                          unsigned char current = str.at(i) & 0x7F;                          unsigned char current = str.at(i) & 0x7F;
# Line 178  namespace SmsPdu Line 181  namespace SmsPdu
181                          pdu.push_back(to.length() ); //length of phone nr                          pdu.push_back(to.length() ); //length of phone nr
182                          pdu.push_back(0x81); // type of address (international nr  + ISDN/telephone range) - else try 0x81                          pdu.push_back(0x81); // type of address (international nr  + ISDN/telephone range) - else try 0x81
183    
184                    
185                          string phone = EncodePhonenr(to);                          vector<unsigned char> phone = HexDecodeString( EncodePhonenr(to ));
186                          pdu.insert( pdu.end(), phone.begin(), phone.end());                          pdu.insert( pdu.end(), phone.begin(), phone.end());
187    
188                          pdu.push_back(0x00); // Protocol identifier                          pdu.push_back(0x00); // Protocol identifier
189                          pdu.push_back(0x00); // Data coding scheme                          pdu.push_back(0x00); // Data coding scheme
190    
191                            int shift_start = 0;
192                          string message_part;                          string message_part;
193                          if (multipart)                          if (multipart)
194                          {                          {
# Line 199  namespace SmsPdu Line 203  namespace SmsPdu
203                                  pdu.push_back( part_count );                                  pdu.push_back( part_count );
204                                  pdu.push_back( partnr+1 );                                  pdu.push_back( partnr+1 );
205                                  pdu.push_back( 0x00);                                  pdu.push_back( 0x00);
206                                    //shift_start = 6;
207                          }                          }
208                          else                          else
209                          {                          {
# Line 216  namespace SmsPdu Line 220  namespace SmsPdu
220                                  pdu.push_back( message_part.length() ); //UserDataLength                                  pdu.push_back( message_part.length() ); //UserDataLength
221                          }                          }
222    
223                          vector<unsigned char> userData = Encode7to8bit(message_part);                          vector<unsigned char> userData = Encode7to8bit(message_part, shift_start);
224    
225                          pdu.insert( pdu.end(), userData.begin(), userData.end());                          pdu.insert( pdu.end(), userData.begin(), userData.end());
226    

Legend:
Removed from v.70  
changed lines
  Added in v.73

  ViewVC Help
Powered by ViewVC 1.1.20