Troubles with GSM_SetIncomingSMSCallback (ca llback not firing)
Vladislav Stebluk <[email protected]>
| Newsgroups | gmane.linux.drivers.gammu |
|---|---|
| Message-ID | <[email protected]> |
Hello. I compiled the libgammu using visual studio 2013 and x64 config. When i try to receive sms message using the callback, it never fires for some reason. Can you help me? Here is a bit of my code (i'm using QT):
void SerialPortWorker::StartWorker()
{
GSM_Debug_Info *debug_info;
GSM_Config *cfg;
QString tehError = "";
QRegularExpression regex("COM(?<com>[0-9]+)");
QString name = this->_name;
QRegularExpressionMatch m = regex.match(name);
int com = m.captured("com").toInt();
if(com > 7)
{
name = "\\\\.\\" + name;
}
gsmStateMachine = GSM_AllocStateMachine();
if (gsmStateMachine == NULL)
return;
cfg = GSM_GetConfig(gsmStateMachine, 0);
char *connectionType = (char*)malloc(8);
strcpy(connectionType,"at19200");
free(cfg->Device);
QByteArray bName = name.toLatin1();
cfg->Device = strdup(bName.data());
free(cfg->Connection);
cfg->Connection = strdup(connectionType);
free(connectionType);
GSM_SetConfigNum(gsmStateMachine, 1);
this->_error = GSM_InitConnection(gsmStateMachine,1);
tehError = this->error_handler();
if(!tehError.isEmpty())
{
return;
}
char buf[100];
this->_error = GSM_GetManufacturer(gsmStateMachine,buf);
tehError = this->error_handler();
this->_manufacturer = QString::fromLatin1(buf);
this->_error = GSM_GetModel(gsmStateMachine,buf);
tehError = this->error_handler();
this->_model = QString::fromLatin1(buf);
DataStorage::_mutex.lock();
this->_index = DataStorage::_modems;
emit this->InsertRow(this->GetIndex(),this->_model,"",this->_name);
DataStorage::_modems++;
DataStorage::_mutex.unlock();
gboolean falg = TRUE;
this->_error = GSM_SetIncomingUSSD(this->gsmStateMachine,falg);
this->_error = GSM_SetIncomingCB(this->gsmStateMachine,falg);
this->_error = GSM_SetIncomingCall(this->gsmStateMachine,falg);
this->_error = GSM_SetIncomingSMS(this->gsmStateMachine,falg);
GSM_SetIncomingSMSCallback(this->gsmStateMachine,&SerialPortWorker::SmsCallback,this);
GSM_SetFastSMSSending(this->gsmStateMachine,TRUE);
QList<SmsObject> * messages = this->ReadAllSms();
if(messages!=NULL)
{
for(int row =0; row < messages->count(); row++)
{
emit TabAppendSignal(this->_index,row,messages->at(row).number,messages->at(row).text,"",messages->at(row).date);
this->_sms++;
}
delete messages;
}
}
The callback looks like this:
void SerialPortWorker::SmsCallback(GSM_StateMachine * s, GSM_SMSMessage *sms,
void *user_data)
{
qDebug() << "We got some sms!";
}
and declared like so:
private:
static void SmsCallback(GSM_StateMachine * s, GSM_SMSMessage *sms,
void *user_data);
I tried everything, the callback literally just don't fire. Is there something i'm missing from the code?? Please help!!
--
Vladislav Stebluk
VNC12Q&D
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Gammu-users mailing list - https://lists.sourceforge.net/lists/listinfo/gammu-users