本文整理汇总了C++中DataContainer::getAlertServiceInstance方法的典型用法代码示例。如果您正苦于以下问题:C++ DataContainer::getAlertServiceInstance方法的具体用法?C++ DataContainer::getAlertServiceInstance怎么用?C++ DataContainer::getAlertServiceInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataContainer
的用法示例。
在下文中一共展示了DataContainer::getAlertServiceInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gatt_service_disconnected
void gatt_service_disconnected(const char *bdaddr, const char *service, int instance, int reason, void *userData)
{
Q_UNUSED(userData)
Q_UNUSED(instance)
Q_UNUSED(reason)
QString bdaddr_str = QString(bdaddr);
QString service_str = QString(service);
qDebug() << QString("XXXX gatt_service_disconnected: bdaddr:%1 : %2 - %3").arg(bdaddr_str).arg(service_str).arg(parse_service_uuid(service));
DataContainer *dc = DataContainer::getInstance();
if (instance == dc->getLinkLossServiceInstance()) {
qDebug() << "XXXX reacting to link loss service disconnection";
link_loss_connected = false;
dc->setLinkLossServiceInstance(0);
_handler->emitSignalLostLink();
}
if (instance == dc->getTxPowerServiceInstance()) {
qDebug() << "XXXX reacting to tx power service disconnection";
tx_power_connected = false;
dc->setTxPowerServiceInstance(0);
}
if (instance == dc->getAlertServiceInstance()) {
qDebug() << "XXXX reacting to immediate alert service disconnection";
immediate_alert_connected = false;
dc->setAlertServiceInstance(0);
}
}
示例2: sendAlertRequest
void BluetoothHandler::sendAlertRequest()
{
if (!immediate_alert_connected) {
qDebug() << "XXXX not yet connected to the immediate alert service so ignoring alert request from user";
return;
}
qDebug() << "XXXX BluetoothHandler::sendAlertRequest()";
uint8_t level[] = { 0 };
switch (_alertLevel) {
case BluetoothHandler::Off:
level[0] = 0;
break;
case BluetoothHandler::Mild:
level[0] = 1;
break;
case BluetoothHandler::High:
level[0] = 2;
break;
default:
level[0] = 0;
break;
}
errno= 0;
DataContainer* dc = DataContainer::getInstance();
int alert_service_instance = dc->getAlertServiceInstance();
uint16_t alert_level_value_handle = dc->getImmediateAlertLevelValueHandle();
qDebug() << "XXXX setting immediate alert service alert level with bt_gatt_write_value_noresp. alert_service_instance=" << alert_service_instance;
if (bt_gatt_write_value_noresp(alert_service_instance, alert_level_value_handle, 0, level, sizeof(level)) == EOK) {
qDebug() << "XXXX BluetoothHandler::sendAlertRequest() - value written successfully";
} else {
qDebug() << "XXXX BluetoothHandler::sendAlertRequest() - errno=(" << errno<< ") :" << strerror(errno);
}
}