本文整理汇总了C++中DataContainer::getTxPowerServiceInstance方法的典型用法代码示例。如果您正苦于以下问题:C++ DataContainer::getTxPowerServiceInstance方法的具体用法?C++ DataContainer::getTxPowerServiceInstance怎么用?C++ DataContainer::getTxPowerServiceInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataContainer
的用法示例。
在下文中一共展示了DataContainer::getTxPowerServiceInstance方法的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: readTxPowerLevel
void readTxPowerLevel()
{
DataContainer* dc = DataContainer::getInstance();
uint8_t *tx_power_level;
tx_power_level = (uint8_t*) malloc(sizeof(uint8_t));
// The Transmit Power Level characteristic represents the current transmit power level in dBm, and the level ranges from -100 dBm to +20 dBm to a
// resolution of 1 dBm.
//
// Units of dBm are decibels relative to 1 mW of power, hence, 0 dBm 1 mW.
// 1/100 mW is -20 dBm and 100 mW is +20 dBm. Powers less than 1 mW are always negative dBm values, and powers greater than
// 1 mW are always positive.
errno= 0;
int result = bt_gatt_read_value(dc->getTxPowerServiceInstance(), dc->getTxPowerLevelValueHandle(), 0, tx_power_level, sizeof(uint8_t), 0);
if (result < 0) {
qDebug() << "XXXX bt_gatt_read_value - errno=(" << errno<< ") :" << strerror(errno);
}
int power_level_dbm = *tx_power_level;
if (power_level_dbm > 128) {
power_level_dbm = 255 - power_level_dbm;
}
dc->setTxPowerLevel(power_level_dbm);
free(tx_power_level);
qDebug() << "XXXX read TX power level. result=" << result << " : tx_power_level=" << *tx_power_level << " : power_level_dbm=" << power_level_dbm;
}