From 30436c84b2c35982c41c33a7adfb0307884f5ee9 Mon Sep 17 00:00:00 2001 From: Bruno Randolf Date: Sat, 5 Jan 2019 18:34:13 +0000 Subject: Add setting of discoverable mode This is necessary for the advertisements to be in "LE General Discoverable Mode" which makes them visible (especially to other Linux boxes). Signed-off-by: Bruno Randolf --- src/Init.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/Init.cpp') diff --git a/src/Init.cpp b/src/Init.cpp index 915209f..c3784df 100644 --- a/src/Init.cpp +++ b/src/Init.cpp @@ -695,11 +695,12 @@ void configureAdapter() bool scFlag = info.currentSettings.isSet(HciAdapter::EHciSecureConnections) == TheServer->getEnableSecureConnection(); bool bnFlag = info.currentSettings.isSet(HciAdapter::EHciBondable) == TheServer->getEnableBondable(); bool cnFlag = info.currentSettings.isSet(HciAdapter::EHciConnectable) == TheServer->getEnableConnectable(); + bool diFlag = info.currentSettings.isSet(HciAdapter::EHciDiscoverable) == TheServer->getEnableDiscoverable(); bool adFlag = info.currentSettings.isSet(HciAdapter::EHciAdvertising) == TheServer->getEnableAdvertising(); bool anFlag = (advertisingName.length() == 0 || advertisingName == info.name) && (advertisingShortName.length() == 0 || advertisingShortName == info.shortName); // If everything is setup already, we're done - if (!pwFlag || !leFlag || !brFlag || !scFlag || !bnFlag || !cnFlag || !adFlag || !anFlag) + if (!pwFlag || !leFlag || !brFlag || !scFlag || !bnFlag || !cnFlag || !diFlag || !adFlag || !anFlag) { // We need it off to start with if (pwFlag) @@ -745,6 +746,13 @@ void configureAdapter() if (!mgmt.setConnectable(TheServer->getEnableConnectable())) { setRetry(); return; } } + // Change the Discoverable state? + if (!diFlag) + { + Logger::debug(SSTR << (TheServer->getEnableDiscoverable() ? "Enabling":"Disabling") << " Discoverable"); + if (!mgmt.setDiscoverable(TheServer->getEnableDiscoverable() ? 1 : 0, 0)) { setRetry(); return; } + } + // Change the Advertising state? if (!adFlag) { @@ -1196,4 +1204,4 @@ void runServerThread() uninit(); } -}; // namespace ggk \ No newline at end of file +}; // namespace ggk -- cgit v1.2.3