MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / stop

Function stop

Tactility/Source/bluetooth/Bluetooth.cpp:297–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295}
296
297bool stop(Device* dev) {
298 BtRadioState state;
299 if (bluetooth_get_radio_state(dev, &state) != ERROR_NONE) {
300 return false;
301 }
302
303 if (state == BT_RADIO_STATE_OFF || state == BT_RADIO_STATE_OFF_PENDING) {
304 return true;
305 }
306
307 if (bluetooth_remove_event_callback(dev, bt_event_bridge) != ERROR_NONE) {
308 LOGGER.error("Failed to remove BLE callback");
309 }
310
311 if (bluetooth_set_radio_enabled(dev, false) != ERROR_NONE) {
312 LOGGER.error("Failed to disable BT radio");
313 // Re-register bridge
314 bluetooth_add_event_callback(dev, nullptr, bt_event_bridge);
315 return false;
316 }
317
318 if (device_stop(dev) != ERROR_NONE) {
319 LOGGER.error("Failed to stop BT device");
320 return false;
321 }
322
323 return true;
324}
325
326// ---- Public API ----
327

Callers

nothing calls this directly

Calls 6

device_stopFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected