From 23e46d2de44a3d49063e852a38b020e7407a78bc Mon Sep 17 00:00:00 2001 From: Paul Nettle Date: Sun, 3 Sep 2017 08:15:12 -0500 Subject: The GGK server names are no longer in Globals.h but are now configured by ggkStart() allowing an application to change them based on configuration rather than compilation. Power-off-disconnect errors hacked out of existence. A few log lines that were set to trace converted to debug log levels to reduce logspam. --- src/HciAdapter.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/HciAdapter.cpp') diff --git a/src/HciAdapter.cpp b/src/HciAdapter.cpp index 6d99d69..9000709 100644 --- a/src/HciAdapter.cpp +++ b/src/HciAdapter.cpp @@ -344,10 +344,23 @@ bool HciAdapter::filterAndValidateEvents(uint16_t commandCode, std::vectorheader.dataSize; if (dataLength > buffer.size()) { - Logger::error(SSTR << " + Not enough data for the current event"); + Logger::error(" + Not enough data for the current event"); return false; } + // !HACK! - If the device is connected, then powering off (Command Code 0x0005) returns a Device Disconnect Event (Event + // Code 0xC) rather than a Command Complete Event (0x1) like it should. + // + // We'll fake it here, converting that condition into a Command Complete Event (0x1). + if (commandCode == 0x0005 && pEvent->header.code == 0xC) + { + Logger::debug("!HACK! Converting invalid Disconect Event to Command Complete Event for power-off command"); + pEvent->header.code = 1; + buffer = {0x1, 0x0, 0x0, 0x0, 0x7, 0x0, 0x5, 0x0, 0x0, 0x2, 0x6, 0x0, 0x0}; + pEvent = reinterpret_cast(buffer.data()); + dataLength = sizeof(Header) + pEvent->header.dataSize; + } + // Check the event type if (pEvent->header.code < kMinEventType || pEvent->header.code > kMaxEventType) { -- cgit v1.2.3