Skip to content

Commit

Permalink
Exit with failure on: Failed to set scan parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
William C Bonner committed Jun 10, 2024
1 parent f2486aa commit f7cdf83
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if (POLICY CMP0115)
endif()

project (GoveeBTTempLogger
VERSION 2.20240312.0
VERSION 2.20240610.0
DESCRIPTION "Listen and log Govee Thermometer Bluetooth Low Energy Advertisments"
HOMEPAGE_URL https://github.com/wcbonner/GoveeBTTempLogger
)
Expand Down
19 changes: 16 additions & 3 deletions goveebttemplogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3065,6 +3065,7 @@ int main(int argc, char **argv)
WriteSVGIndex(LogDirectory, SVGIndexFilename);
exit(EXIT_SUCCESS);
}
int ExitValue = EXIT_SUCCESS;
///////////////////////////////////////////////////////////////////////////////////////////////
if (ConsoleVerbosity > 0)
{
Expand Down Expand Up @@ -3238,7 +3239,9 @@ int main(int argc, char **argv)
}
}
auto btRVal = bt_LEScan(BlueToothDevice_Handle, true, BT_WhiteList);
if (btRVal >= 0)
if (btRVal < 0)
ExitValue = EXIT_FAILURE;
else
{
// Save the current HCI filter (Host Controller Interface)
struct hci_filter original_filter;
Expand Down Expand Up @@ -3534,7 +3537,12 @@ int main(int argc, char **argv)
else
GoveeLastDownload.insert(std::pair<bdaddr_t, time_t>(info->bdaddr, DownloadTime));
}
bt_LEScan(BlueToothDevice_Handle, true, BT_WhiteList);
btRVal = bt_LEScan(BlueToothDevice_Handle, true, BT_WhiteList);
if (btRVal < 0)
{
bRun = false; // rely on inetd to restart entire process
ExitValue = EXIT_FAILURE;
}
}
}
}
Expand Down Expand Up @@ -3586,6 +3594,11 @@ int main(int argc, char **argv)
if (ConsoleVerbosity > 0)
std::cout << "[" << getTimeISO8601() << "] No recent Bluetooth LE Advertisments! (> " << MaxMinutesBetweenBluetoothAdvertisments << " Minutes)" << std::endl;
btRVal = bt_LEScan(BlueToothDevice_Handle, true, BT_WhiteList);
if (btRVal < 0)
{
bRun = false; // rely on inetd to restart entire process
ExitValue = EXIT_FAILURE;
}
}
}
setsockopt(BlueToothDevice_Handle, SOL_HCI, HCI_FILTER, &original_filter, sizeof(original_filter));
Expand Down Expand Up @@ -3670,5 +3683,5 @@ int main(int argc, char **argv)
}
///////////////////////////////////////////////////////////////////////////////////////////////
std::cerr << ProgramVersionString << " (exiting)" << std::endl;
return(EXIT_SUCCESS);
return(ExitValue);
}

0 comments on commit f7cdf83

Please sign in to comment.