MCPcopy Create free account
hub / github.com/RangeNetworks/openbts / SMSCBSendMessage

Function SMSCBSendMessage

Control/SMSCB.cpp:79–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77
78
79void SMSCBSendMessage(sqlite3* DB, sqlite3_stmt* stmt, GSM::CBCHLogicalChannel* CBCH)
80{
81 // Get the message parameters.
82 // These column numbers need to line up with the argeuments to the SELEECT.
83 unsigned GS = (unsigned)sqlite3_column_int(stmt,0);
84 unsigned messageCode = (unsigned)sqlite3_column_int(stmt,1);
85 unsigned updateNumber = (unsigned)sqlite3_column_int(stmt,2);
86 unsigned messageID = (unsigned)sqlite3_column_int(stmt,3);
87 char* messageText = strdup((const char*)sqlite3_column_text(stmt,4));
88 unsigned languageCode = (unsigned)sqlite3_column_int(stmt,5);
89 unsigned sendCount = (unsigned)sqlite3_column_int(stmt,6);
90 unsigned rowid = (unsigned)sqlite3_column_int(stmt,7);
91 // Done with the database entry.
92 // Finalize ASAP to unlock the database.
93 sqlite3_finalize(stmt);
94
95 // Figure out how many pages to send.
96 const unsigned maxLen = 40*15;
97 unsigned messageLen = strlen((const char*)messageText);
98 if (messageLen>maxLen) {
99 LOG(ALERT) << "SMSCB message ID " << messageID << " to long; truncating to " << maxLen << " char.";
100 messageLen = maxLen;
101 }
102 unsigned numPages = messageLen / 40;
103 if (messageLen % 40) numPages++;
104 unsigned mp = 0;
105
106 LOG(INFO) << "sending message ID=" << messageID << " code=" << messageCode << " in " << numPages << " pages: " << messageText;
107
108 // Break into pages and send each page.
109 for (unsigned page=0; page<numPages; page++) {
110 // Encode the mesage into pages.
111 // We use UCS2 encoding for the message,
112 // even though the input text is ASCII for now.
113 char thisPage[82];
114 unsigned dp = 0;
115 int codingScheme;
116 if (false) { // in case anybody wants to make the encoding selectable
117 codingScheme = 0x11; // UCS2
118 thisPage[dp++] = languageCode >> 8;
119 thisPage[dp++] = languageCode & 0x0ff;
120 while (dp<82 && mp<messageLen) {
121 thisPage[dp++] = 0;
122 thisPage[dp++] = messageText[mp++];
123 }
124 while (dp<82) { thisPage[dp++] = 0; thisPage[dp++]='\r'; }
125 } else {
126 // 03.38 section 5
127 codingScheme = 0x10; // 7'
128 int buf = 0;
129 int shift = 0;
130 // The spec (above) says to put this language stuff in, but it doesn't work on my samsung galaxy y.
131 // encode7(languageCode >> 8, shift, dp, buf, thisPage);
132 // encode7(languageCode & 0xFF, shift, dp, buf, thisPage);
133 // encode7('\r', shift, dp, buf, thisPage);
134 while (dp<81 && mp<messageLen) {
135 encode7(messageText[mp++], shift, dp, buf, thisPage);
136 }

Callers 1

SMSCBSenderMethod · 0.85

Calls 7

encode7Function · 0.85
L3SMSCBSerialNumberClass · 0.85
L3SMSCBContentClass · 0.85
l2sendmMethod · 0.45

Tested by

no test coverage detected