Skip to content

Instantly share code, notes, and snippets.

@jmlich
Last active December 22, 2022 18:34
Show Gist options
  • Save jmlich/7841794efc5d23439bafefe5532d33b3 to your computer and use it in GitHub Desktop.
Save jmlich/7841794efc5d23439bafefe5532d33b3 to your computer and use it in GitHub Desktop.
#include <QtDebug>
#include <qofono-qt5/qofonomanager.h>
#include <qofono-qt5/qofonomodem.h>
#include <qofono-qt5/qofononetworkregistration.h>
#include <qofono-qt5/qofonosimmanager.h>
int main () {
QOfonoManager *m_omanager = new QOfonoManager();
m_omanager->getModems();
QString defaultModemPath = m_omanager->defaultModem();
qDebug() << "m_omanager->defaultModem()" << defaultModemPath;
if (defaultModemPath == "") {
qWarning() << "No modems detected";
return 1;
}
#if 0
QOfonoModem *modem = new QOfonoModem(defaultModemPath);
#else
QOfonoModem *modem = new QOfonoModem();
modem->setModemPath(defaultModemPath);
#endif
qDebug() << "modem->modemPath()" << modem->modemPath();
qDebug() << "modem->name()" << modem->name();
qDebug() << "modem->manufacturer()" << modem->manufacturer();
qDebug() << "modem->isValid()" << modem->isValid();
}
$ ./test_modem # #if 0 = using new QOfonoModem(defaultModemPath);
m_omanager->defaultModem() "/quectelqmi_0"
modem->modemPath() "/quectelqmi_0"
modem->name() ""
modem->manufacturer() "QUALCOMM INCORPORATED"
modem->isValid() true
$ ./test_modem # #if 0 = using modem->setModemPath(defaultModemPath)
m_omanager->defaultModem() "/quectelqmi_0"
modem->modemPath() "/quectelqmi_0"
modem->name() ""
modem->manufacturer() ""
modem->isValid() false
#include <QtDebug>
#include <qofono-qt5/qofonomanager.h>
#include <qofono-qt5/qofonomodem.h>
#include <qofono-qt5/qofononetworkregistration.h>
#include <qofono-qt5/qofonosimmanager.h>
int main () {
QOfonoManager *m_omanager = new QOfonoManager();
m_omanager->getModems();
QString defaultModemPath = m_omanager->defaultModem();
qDebug() << "m_omanager->defaultModem()" << defaultModemPath;
if (defaultModemPath == "") {
qWarning() << "No modems detected";
return 1;
}
QOfonoModem modem(defaultModemPath);
modem.setPowered(true);
modem.setOnline(true);
QOfonoSimManager* m_simManager = new QOfonoSimManager();
m_simManager->setModemPath(defaultModemPath);
if (!m_simManager->getPropertiesSync()) {
qWarning() << "m_simManager->getPropertiesSync returned false";
}
qDebug() << "modem.modemPath()" << modem.modemPath();
qDebug() << "modem.name()" << modem.name();
qDebug() << "modem.manufacturer()" << modem.manufacturer();
qDebug() << "modem.powered()" << modem.powered();
qDebug() << "modem.online()" << modem.online();
qDebug() << "m_simManager->isValid()" << m_simManager->isValid();
qDebug() << "m_simManager->present()" << m_simManager->present();
qDebug() << "m_simManager->pinRequired()" << m_simManager->pinRequired();
qDebug() << "modemPath" << m_simManager->modemPath();
}
m_omanager->defaultModem() "/quectelqmi_0"
m_simManager->getPropertiesSync returned false
modem.modemPath() "/quectelqmi_0"
modem.name() ""
modem.manufacturer() "QUALCOMM INCORPORATED"
modem.powered() true
modem.online() true
m_simManager->isValid() false
m_simManager->present() false
m_simManager->pinRequired() 0
modemPath "/quectelqmi_0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment