src/connectivity/wlan/drivers/third_party/broadcom/brcmfmac/sim/sim_fw.cc
zx_status_t SimFirmware::EscanStart(uint16_t sync_id, const brcmf_scan_params_le* params,
                                    size_t params_len) {
  auto scan_opts = std::make_unique<ScanOpts>();

  scan_opts->sync_id = sync_id;

  switch (params->scan_type) {
    case BRCMF_SCANTYPE_ACTIVE:
      scan_opts->is_active = true;
      if (params->active_time == static_cast<uint32_t>(-1)) {
        BRCMF_ERR("No active scan time in parameter\n");
        return ZX_ERR_INVALID_ARGS;
      } else {
        scan_opts->dwell_time = zx::msec(params->active_time);
      }
      break;
    case BRCMF_SCANTYPE_PASSIVE:
      scan_opts->is_active = false;
      // Determine dwell time. If specified in the request, use that value. Otherwise, if a default
      // dwell time has been specified, use that value. Otherwise, fail.
      if (params->passive_time == static_cast<uint32_t>(-1)) {
        if (default_passive_time_ == static_cast<uint32_t>(-1)) {
          BRCMF_ERR("Attempt to use default passive time, iovar hasn't been set yet\n");
          return ZX_ERR_INVALID_ARGS;
        }
        scan_opts->dwell_time = zx::msec(default_passive_time_);
      } else {
        scan_opts->dwell_time = zx::msec(params->passive_time);
      }
      break;
    default:
      BRCMF_DBG(SIM, "Invalid scan type requested: %d\n", params->scan_type);
      return ZX_ERR_INVALID_ARGS;
  }

  size_t num_channels = params->channel_num & BRCMF_SCAN_PARAMS_COUNT_MASK;

  // Configure state
  scan_opts->channels.resize(num_channels);
  std::copy(&params->channel_list[0], &params->channel_list[num_channels],
            scan_opts->channels.data());

  scan_opts->on_result_fn = std::bind(&SimFirmware::EscanResultSeen, this, std::placeholders::_1);
  scan_opts->on_done_fn = std::bind(&SimFirmware::EscanComplete, this);
  return ScanStart(std::move(scan_opts));
}
// When asked to start an escan, we will listen on each of the specified channels for the requested
// duration (dwell time). We accomplish this by setting up a future event for the next channel,
// iterating until we have scanned all channels.
When asked to start an escan, we will listen on each of the specified channels for the requested
duration (dwell time). We accomplish this by setting up a future event for the next channel,
iterating until we have scanned all channels.
When asked to start an escan we will listen on each of the specified channels for the requested duration ( dwell time ) . We accomplish this by setting up a future event for the next channel iterating until we have scanned all channels .
zx_status_t SimFirmware::EscanStart(uint16_t sync_id, const brcmf_scan_params_le* params,
                                    size_t params_len) {
  auto scan_opts = std::make_unique<ScanOpts>();
  scan_opts->sync_id = sync_id;
  switch (params->scan_type) {
    case BRCMF_SCANTYPE_ACTIVE:
      scan_opts->is_active = true;
      if (params->active_time == static_cast<uint32_t>(-1)) {
        BRCMF_ERR("No active scan time in parameter\n");
        return ZX_ERR_INVALID_ARGS;
      } else {
        scan_opts->dwell_time = zx::msec(params->active_time);
      }
      break;
    case BRCMF_SCANTYPE_PASSIVE:
      scan_opts->is_active = false;
      if (params->passive_time == static_cast<uint32_t>(-1)) {
        if (default_passive_time_ == static_cast<uint32_t>(-1)) {
          BRCMF_ERR("Attempt to use default passive time, iovar hasn't been set yet\n");
          return ZX_ERR_INVALID_ARGS;
        }
        scan_opts->dwell_time = zx::msec(default_passive_time_);
      } else {
        scan_opts->dwell_time = zx::msec(params->passive_time);
      }
      break;
    default:
      BRCMF_DBG(SIM, "Invalid scan type requested: %d\n", params->scan_type);
      return ZX_ERR_INVALID_ARGS;
  }
  size_t num_channels = params->channel_num & BRCMF_SCAN_PARAMS_COUNT_MASK;
  scan_opts->channels.resize(num_channels);
  std::copy(&params->channel_list[0], &params->channel_list[num_channels],
            scan_opts->channels.data());
  scan_opts->on_result_fn = std::bind(&SimFirmware::EscanResultSeen, this, std::placeholders::_1);
  scan_opts->on_done_fn = std::bind(&SimFirmware::EscanComplete, this);
  return ScanStart(std::move(scan_opts));
}
zx_status_t SimFirmware :: EscanStart ( uint16_t sync_id , const brcmf_scan_params_le * params , size_t params_len ) { auto scan_opts = std :: make_unique < ScanOpts > ( ) ; scan_opts -> sync_id = sync_id ; switch ( params -> scan_type ) { case BRCMF_SCANTYPE_ACTIVE : scan_opts -> is_active = true ; if ( params -> active_time == static_cast < uint32_t > ( -1 ) ) { BRCMF_ERR ( " \n " ) ; return ZX_ERR_INVALID_ARGS ; } else { scan_opts -> dwell_time = zx :: msec ( params -> active_time ) ; } break ; case BRCMF_SCANTYPE_PASSIVE : scan_opts -> is_active = false ; if ( params -> passive_time == static_cast < uint32_t > ( -1 ) ) { if ( default_passive_time_ == static_cast < uint32_t > ( -1 ) ) { BRCMF_ERR ( " \n " ) ; return ZX_ERR_INVALID_ARGS ; } scan_opts -> dwell_time = zx :: msec ( default_passive_time_ ) ; } else { scan_opts -> dwell_time = zx :: msec ( params -> passive_time ) ; } break ; default : BRCMF_DBG ( SIM , " \n " , params -> scan_type ) ; return ZX_ERR_INVALID_ARGS ; } size_t num_channels = params -> channel_num & BRCMF_SCAN_PARAMS_COUNT_MASK ; scan_opts -> channels . resize ( num_channels ) ; std :: copy ( & params -> channel_list [ 0 ] , & params -> channel_list [ num_channels ] , scan_opts -> channels . data ( ) ) ; scan_opts -> on_result_fn = std :: bind ( & SimFirmware :: EscanResultSeen , this , std :: placeholders :: _1 ) ; scan_opts -> on_done_fn = std :: bind ( & SimFirmware :: EscanComplete , this ) ; return ScanStart ( std :: move ( scan_opts ) ) ; }
When asked to start an escan, we will listen on each of the specified channels for the requested
duration (dwell time).
When asked to start an escan we will listen on each of the specified channels for the requested duration ( dwell time ) .
// Determine dwell time. If specified in the request, use that value. Otherwise, if a default // dwell time has been specified, use that value. Otherwise, fail. // Configure state