Show Bluetooth addresses in the desktop device list
This commit is contained in:
1 parent
eeb2373599
commit
f87f70489a
2 files changed
+9
-3
No files matched your search
@@ -94,8 +94,14 @@ DesktopBleSnapshot DesktopBle::snapshot() {
|
||||
const size_t count = ble_etcp_neighbors(m_driver, peers, BLE_NEIGHBORS_MAX);
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
const auto& peer = peers[i];
|
||||
m_snapshot.peers.append(QStringLiteral("%1 · %2 · %3 dBm").arg(QString::fromUtf8(peer.identity.name),
|
||||
QString::number(peer.identity.node_id, 16).rightJustified(16, '0'),
|
||||
QString address = QString::fromUtf8(peer.endpoint.id);
|
||||
if (address.contains(QStringLiteral("/dev_"))) address = address.section(QStringLiteral("/dev_"), -1).replace('_', ':');
|
||||
else if (address.size() > 12 && address.at(12) == '/') {
|
||||
address = address.left(12);
|
||||
for (int offset = 10; offset >= 2; offset -= 2) address.insert(offset, ':');
|
||||
}
|
||||
m_snapshot.peers.append(QStringLiteral("%1 · %2 · %3 · %4 dBm").arg(QString::fromUtf8(peer.identity.name),
|
||||
QString::number(peer.identity.node_id, 16).rightJustified(16, '0'), address.toUpper(),
|
||||
peer.rssi == 127 ? QStringLiteral("?") : QString::number(peer.rssi)));
|
||||
}
|
||||
m_snapshot.connections = m_connections.size();
|
||||
|
||||
@@ -12,7 +12,7 @@ struct DesktopBleSnapshot {
|
||||
int flags = 0; // 1: транспорт, 2: объявление node_id/имени, 4: входящие подключения
|
||||
ble_state state = BLE_CLOSED, advertising = BLE_CLOSED;
|
||||
QString reason, advertisingReason; // Последние причины изменения состояния backend.
|
||||
QStringList peers; // Свежие объявления: имя, node_id, RSSI; не более 64 узлов.
|
||||
QStringList peers; // Свежие объявления: имя, node_id, Bluetooth-адрес, RSSI; не более 64 узлов.
|
||||
int connections = 0; // Готовые GATT-сессии.
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user