Add BLE ETCP links and GATT invitations for desktop and Android
Attach packet drivers to initially empty ETCP connections. Share BLE neighbor tracking and group fallback between desktop and Android in cgathui_common. Deliver join links through a dedicated Write/Indicate characteristic with independent fragmentation queues, application acknowledgements, deduplication and bounded retries. Merge LAN/BLE discovery and add a separate Bluetooth invitation reception setting to both clients. Validation: 230 core tests, BLE transport/BlueZ/UI tests, ASAN/UBSAN, Linux GUI and Android builds, and Windows backend cross-compilation. Physical Android/Linux invitation exchange passed with either GATT initiator. The Android-initiated run also verified all 32 ETCP packets of 1500 bytes; the desktop-initiated load run reached 7/32 within its 45-second time limit.
This commit is contained in:
1 parent
9ca4e52c24
commit
f016d494b2
52 files changed
+2472
-440
No files matched your search
@@ -2,6 +2,11 @@
|
||||
#include "../transport/utun_node.h"
|
||||
#include "../transport/config_updater.h"
|
||||
#include "../transport/node_config.h"
|
||||
#include "../transport/gui_bridge.h"
|
||||
#include "../../../src/chat/chat_setting.h"
|
||||
#include "../../../lib/debug_config.h"
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QCheckBox>
|
||||
#include <QCoreApplication>
|
||||
#include <QLabel>
|
||||
@@ -15,14 +20,30 @@ BluetoothSettingsPage::BluetoothSettingsPage(const QString& path, UtunNode* node
|
||||
m_enabled = new QCheckBox(QCoreApplication::translate("ChatGui", "Enable Bluetooth"), this);
|
||||
m_advertise = new QCheckBox(QCoreApplication::translate("ChatGui", "Advertise this device"), this);
|
||||
m_incoming = new QCheckBox(QCoreApplication::translate("ChatGui", "Allow incoming Bluetooth connections"), this);
|
||||
m_invites = new QCheckBox(QCoreApplication::translate("ChatGui", "Receive invitations over Bluetooth"), this);
|
||||
m_invites->setObjectName("bluetoothInvites");
|
||||
struct chat_setting_state settings = {};
|
||||
QFile file(path);
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream input(&file); QString section;
|
||||
while (!input.atEnd()) {
|
||||
const QString line = input.readLine().trimmed();
|
||||
if (line.startsWith('[') && line.endsWith(']')) section = line.mid(1, line.size() - 2);
|
||||
if (section == "chatserver" && line.section('=', 0, 0).trimmed() == "bluetooth_invites_enabled") {
|
||||
const QByteArray value = line.section('=', 1).section('#', 0, 0).section(';', 0, 0).trimmed().toUtf8();
|
||||
chat_setting_set_state(&settings, "bluetooth_invites_enabled", value.constData());
|
||||
}
|
||||
}
|
||||
} else DEBUG_WARN(DEBUG_CATEGORY_CONFIG, "Bluetooth settings read failed path=%s: %s", qPrintable(path), qPrintable(file.errorString()));
|
||||
m_invites->setChecked(chat_setting_get_int_state(&settings, "bluetooth_invites_enabled", 0));
|
||||
m_enabled->setObjectName("bluetoothEnabled"); m_advertise->setObjectName("bluetoothAdvertise");
|
||||
m_incoming->setObjectName("bluetoothIncoming");
|
||||
NodeConfig config(path);
|
||||
const int flags = config.exists() && config.load() ? config.bluetoothFlags() : 0;
|
||||
m_enabled->setChecked(flags & 1); m_advertise->setChecked(flags & 2); m_incoming->setChecked(flags & 4);
|
||||
auto permissions = [this](bool enabled) { m_advertise->setEnabled(enabled); m_incoming->setEnabled(enabled); };
|
||||
auto permissions = [this](bool enabled) { m_advertise->setEnabled(enabled); m_incoming->setEnabled(enabled); m_invites->setEnabled(enabled); };
|
||||
connect(m_enabled, &QCheckBox::toggled, this, permissions); permissions(flags & 1);
|
||||
layout->addWidget(m_enabled); layout->addWidget(m_advertise); layout->addWidget(m_incoming);
|
||||
layout->addWidget(m_enabled); layout->addWidget(m_advertise); layout->addWidget(m_incoming); layout->addWidget(m_invites);
|
||||
auto* note = new QLabel(QCoreApplication::translate("ChatGui",
|
||||
"Nearby VibeChat devices can see your node ID and name when advertising is enabled. Bluetooth must also be enabled in system settings."), this);
|
||||
note->setWordWrap(true); layout->addWidget(note);
|
||||
@@ -55,6 +76,9 @@ void BluetoothSettingsPage::refresh() {
|
||||
bool BluetoothSettingsPage::save() {
|
||||
const int flags = (m_enabled->isChecked() ? 1 : 0) | (m_advertise->isChecked() ? 2 : 0) | (m_incoming->isChecked() ? 4 : 0);
|
||||
if (!config_update_option(m_path, "gui", "bluetooth_flags", QString::number(flags))) return false;
|
||||
if (!config_update_option(m_path, "chatserver", "bluetooth_invites_enabled", m_invites->isChecked() ? "1" : "0")) return false;
|
||||
if (gui_bridge_is_uasync_ready() && gui_bridge_get_inst())
|
||||
gui_bridge_post_setting(GUI_SETTING_CHAT, "bluetooth_invites_enabled", m_invites->isChecked() ? "1" : "0");
|
||||
if (m_node && m_node->isRunning()) m_node->setBluetoothFlags(flags);
|
||||
return true;
|
||||
}
|
||||
Reference in new issue
Block a user