Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dc27b22b authored by Ying Hsu's avatar Ying Hsu Committed by Ying Hsu
Browse files

floss: Reset BT controller on HW error event

This patche restarts Floss daemon upon receiving a HW error event
from the BT controller. During the restart, it will send an
HW reset command to clear the error state of the BT controller.

Bug: 316275783
Tag: #floss
Test: mmm packages/modules/Bluetooth
Test: manual test with `hcitool cmd 3f 4e`
Flag: EXEMPT, floss only change

Change-Id: I137bc8017c9afacffd16d9e98f5ef32a74663953
parent ebe3489f
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -16,6 +16,10 @@

#include "hci/hci_layer.h"

#ifdef TARGET_FLOSS
#include <signal.h>
#endif

#include "common/bind.h"
#include "common/init_flags.h"
#include "common/stop_watch.h"
@@ -443,7 +447,15 @@ struct HciLayer::impl {
  void on_hardware_error(EventView event) {
    HardwareErrorView event_view = HardwareErrorView::Create(event);
    ASSERT(event_view.IsValid());
#ifdef TARGET_FLOSS
    LOG_WARN("Hardware Error Event with code 0x%02x", event_view.GetHardwareCode());
    // Sending SIGINT to process the exception from BT controller.
    // The Floss daemon will be restarted. HCI reset during restart will clear the
    // error state of the BT controller.
    kill(getpid(), SIGINT);
#else
    LOG_ALWAYS_FATAL("Hardware Error Event with code 0x%02x", event_view.GetHardwareCode());
#endif
  }

  void on_le_meta_event(EventView event) {