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

Method SMSCBSender

Control/SMSCB.cpp:166–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164
165
166void* Control::SMSCBSender(void*)
167{
168 // Connect to the database.
169 // Just keep trying until it connects.
170 sqlite3 *DB;
171 while (!SMSCBConnectDatabase(gConfig.getStr("Control.SMSCB.Table").c_str(),&DB)) { sleep(1); }
172 LOG(NOTICE) << "SMSCB service starting";
173
174 // Get a channel.
175 GSM::CBCHLogicalChannel* CBCH = gBTS.getCBCH();
176
177 while (1) {
178 // Get the next message ready to send.
179 const char* query =
180 "SELECT"
181 " GS,MESSAGE_CODE,UPDATE_NUMBER,MSGID,MESSAGE,LANGUAGE_CODE,SEND_COUNT,ROWID"
182 " FROM SMSCB"
183 " WHERE SEND_TIME==(SELECT min(SEND_TIME) FROM SMSCB)";
184 sqlite3_stmt *stmt;
185 if (sqlite3_prepare_statement(DB,&stmt,query)) {
186 LOG(ALERT) << "Cannot access SMSCB database: " << sqlite3_errmsg(DB);
187 sleep(1);
188 continue;
189 }
190 // Send the message or sleep briefly.
191 int result = sqlite3_run_query(DB,stmt);
192 if (result==SQLITE_ROW) SMSCBSendMessage(DB,stmt,CBCH);
193 else sleep(1);
194 // Log errors.
195 if ((result!=SQLITE_ROW) && (result!=SQLITE_DONE))
196 LOG(ALERT) << "SCSCB database failure: " << sqlite3_errmsg(DB);
197 }
198 // keep the compiler from whining
199 return NULL;
200}
201
202
203// vim: ts=4 sw=4

Callers

nothing calls this directly

Calls 3

SMSCBConnectDatabaseFunction · 0.85
SMSCBSendMessageFunction · 0.85
getCBCHMethod · 0.80

Tested by

no test coverage detected