aboutsummaryrefslogtreecommitdiff
path: root/src/Mgmt.cpp
diff options
context:
space:
mode:
authorBruno Randolf <br1@einfach.org>2019-01-05 18:34:13 +0000
committerBruno Randolf <br1@einfach.org>2019-01-05 18:36:39 +0000
commit30436c84b2c35982c41c33a7adfb0307884f5ee9 (patch)
tree540f790b12ca77bac7099d0885148e11fcb54ab4 /src/Mgmt.cpp
parentImproved handling of connection counts dealing with latent disconnects on sta... (diff)
downloadgobbledegook-30436c84b2c35982c41c33a7adfb0307884f5ee9.tar.gz
gobbledegook-30436c84b2c35982c41c33a7adfb0307884f5ee9.tar.bz2
gobbledegook-30436c84b2c35982c41c33a7adfb0307884f5ee9.zip
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 <br1@einfach.org>
Diffstat (limited to 'src/Mgmt.cpp')
-rw-r--r--src/Mgmt.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/Mgmt.cpp b/src/Mgmt.cpp
index e61653e..2b80748 100644
--- a/src/Mgmt.cpp
+++ b/src/Mgmt.cpp
@@ -90,6 +90,35 @@ bool Mgmt::setName(std::string name, std::string shortName)
return true;
}
+// Sets discoverable mode
+// 0x00 disables discoverable
+// 0x01 enables general discoverable
+// 0x02 enables limited discoverable
+// Timeout is the time in seconds. For 0x02, the timeout value is required.
+bool Mgmt::setDiscoverable(uint8_t disc, uint16_t timeout)
+{
+ struct SRequest : HciAdapter::HciHeader
+ {
+ uint8_t disc;
+ uint16_t timeout;
+ } __attribute__((packed));
+
+ SRequest request;
+ request.code = Mgmt::ESetDiscoverableCommand;
+ request.controllerId = controllerIndex;
+ request.dataSize = sizeof(SRequest) - sizeof(HciAdapter::HciHeader);
+ request.disc = disc;
+ request.timeout = timeout;
+
+ if (!HciAdapter::getInstance().sendCommand(request))
+ {
+ Logger::warn(SSTR << " + Failed to set discoverable");
+ return false;
+ }
+
+ return true;
+}
+
// Set a setting state to 'newState'
//
// Many settings are set the same way, this is just a convenience routine to handle them all
@@ -202,4 +231,4 @@ std::string Mgmt::truncateShortName(const std::string &name)
return name.substr(0, kMaxAdvertisingShortNameLength);
}
-}; // namespace ggk \ No newline at end of file
+}; // namespace ggk