src/connectivity/bluetooth/core/bt-host/gap/bredr_connection_manager.cc
// This procedure can continue to operate independently of the existence of an
// BrEdrConnectionManager instance, which will begin to disable Page Scan as it shuts down.
This procedure can continue to operate independently of the existence of an
BrEdrConnectionManager instance, which will begin to disable Page Scan as it shuts down.
This procedure can continue to operate independently of the existence of an BrEdrConnectionManager instance which will begin to disable Page Scan as it shuts down .
void SetPageScanEnabled(bool enabled, fxl::WeakPtr<hci::Transport> hci,
                        async_dispatcher_t* dispatcher, hci::StatusCallback cb) {
  ZX_DEBUG_ASSERT(cb);
  auto read_enable = hci::CommandPacket::New(hci::kReadScanEnable);
  auto finish_enable_cb = [enabled, hci, finish_cb = std::move(cb)](
                              auto, const hci::EventPacket& event) mutable {
    if (hci_is_error(event, WARN, "gap-bredr", "read scan enable failed")) {
      finish_cb(event.ToStatus());
      return;
    }
    auto params = event.return_params<hci::ReadScanEnableReturnParams>();
    uint8_t scan_type = params->scan_enable;
    if (enabled) {
      scan_type |= static_cast<uint8_t>(hci::ScanEnableBit::kPage);
    } else {
      scan_type &= ~static_cast<uint8_t>(hci::ScanEnableBit::kPage);
    }
    auto write_enable =
        hci::CommandPacket::New(hci::kWriteScanEnable, sizeof(hci::WriteScanEnableCommandParams));
    write_enable->mutable_payload<hci::WriteScanEnableCommandParams>()->scan_enable = scan_type;
    hci->command_channel()->SendCommand(
        std::move(write_enable),
        [cb = std::move(finish_cb)](auto, const hci::EventPacket& event) { cb(event.ToStatus()); });
  };
  hci->command_channel()->SendCommand(std::move(read_enable), std::move(finish_enable_cb));
}
void SetPageScanEnabled ( bool enabled , fxl :: WeakPtr < hci :: Transport > hci , async_dispatcher_t * dispatcher , hci :: StatusCallback cb ) { ZX_DEBUG_ASSERT ( cb ) ; auto read_enable = hci :: CommandPacket :: New ( hci :: kReadScanEnable ) ; auto finish_enable_cb = [ enabled , hci , finish_cb = std :: move ( cb ) ] ( auto , const hci :: EventPacket & event ) mutable { if ( hci_is_error ( event , WARN , " " , " " ) ) { finish_cb ( event . ToStatus ( ) ) ; return ; } auto params = event . return_params < hci :: ReadScanEnableReturnParams > ( ) ; uint8_t scan_type = params -> scan_enable ; if ( enabled ) { scan_type |= static_cast < uint8_t > ( hci :: ScanEnableBit :: kPage ) ; } else { scan_type &= ~ static_cast < uint8_t > ( hci :: ScanEnableBit :: kPage ) ; } auto write_enable = hci :: CommandPacket :: New ( hci :: kWriteScanEnable , sizeof ( hci :: WriteScanEnableCommandParams ) ) ; write_enable -> mutable_payload < hci :: WriteScanEnableCommandParams > ( ) -> scan_enable = scan_type ; hci -> command_channel ( ) -> SendCommand ( std :: move ( write_enable ) , [ cb = std :: move ( finish_cb ) ] ( auto , const hci :: EventPacket & event ) { cb ( event . ToStatus ( ) ) ; } ) ; } ; hci -> command_channel ( ) -> SendCommand ( std :: move ( read_enable ) , std :: move ( finish_enable_cb ) ) ; }
This procedure can continue to operate independently of the existence of an
BrEdrConnectionManager instance, which will begin to disable Page Scan as it shuts down.
This procedure can continue to operate independently of the existence of an BrEdrConnectionManager instance which will begin to disable Page Scan as it shuts down .