src/connectivity/wlan/drivers/third_party/broadcom/brcmfmac/sim/sim_fw.cc
void SimFirmware::ScanNextChannel() {
  switch (scan_state_.state) {
    case ScanState::STOPPED:
      // We may see this event if a scan was cancelled -- just ignore it
      return;
    case ScanState::HOME:
      // We don't yet support intermittent scanning
      return;
    case ScanState::SCANNING:
      if (scan_state_.channel_index >= scan_state_.opts->channels.size()) {
        // Scanning complete
        if (scan_state_.opts->is_active) {
          memcpy(pfn_mac_addr_.byte, mac_addr_.data(), ETH_ALEN);
        }
        hw_.DisableRx();

        scan_state_.state = ScanState::STOPPED;
        scan_state_.opts->on_done_fn();
        scan_state_.opts = nullptr;
      } else {
        // Scan next channel
        uint16_t chanspec = scan_state_.opts->channels[scan_state_.channel_index++];
        wlan_channel_t channel;
        chanspec_to_channel(&d11_inf_, chanspec, &channel);
        hw_.SetChannel(channel);
        if (scan_state_.opts->is_active) {
          hw_.TxProbeRequest(pfn_mac_addr_);
        }
        std::function<void()>* callback = new std::function<void()>;
        *callback = std::bind(&SimFirmware::ScanNextChannel, this);
        hw_.RequestCallback(callback, scan_state_.opts->dwell_time);
      }
  }
}
// If a scan is in progress, switch to the next channel.
If a scan is in progress, switch to the next channel.
If a scan is in progress switch to the next channel .
void SimFirmware::ScanNextChannel() {
  switch (scan_state_.state) {
    case ScanState::STOPPED:
      return;
    case ScanState::HOME:
      return;
    case ScanState::SCANNING:
      if (scan_state_.channel_index >= scan_state_.opts->channels.size()) {
        if (scan_state_.opts->is_active) {
          memcpy(pfn_mac_addr_.byte, mac_addr_.data(), ETH_ALEN);
        }
        hw_.DisableRx();
        scan_state_.state = ScanState::STOPPED;
        scan_state_.opts->on_done_fn();
        scan_state_.opts = nullptr;
      } else {
        uint16_t chanspec = scan_state_.opts->channels[scan_state_.channel_index++];
        wlan_channel_t channel;
        chanspec_to_channel(&d11_inf_, chanspec, &channel);
        hw_.SetChannel(channel);
        if (scan_state_.opts->is_active) {
          hw_.TxProbeRequest(pfn_mac_addr_);
        }
        std::function<void()>* callback = new std::function<void()>;
        *callback = std::bind(&SimFirmware::ScanNextChannel, this);
        hw_.RequestCallback(callback, scan_state_.opts->dwell_time);
      }
  }
}
void SimFirmware :: ScanNextChannel ( ) { switch ( scan_state_ . state ) { case ScanState :: STOPPED : return ; case ScanState :: HOME : return ; case ScanState :: SCANNING : if ( scan_state_ . channel_index >= scan_state_ . opts -> channels . size ( ) ) { if ( scan_state_ . opts -> is_active ) { memcpy ( pfn_mac_addr_ . byte , mac_addr_ . data ( ) , ETH_ALEN ) ; } hw_ . DisableRx ( ) ; scan_state_ . state = ScanState :: STOPPED ; scan_state_ . opts -> on_done_fn ( ) ; scan_state_ . opts = nullptr ; } else { uint16_t chanspec = scan_state_ . opts -> channels [ scan_state_ . channel_index ++ ] ; wlan_channel_t channel ; chanspec_to_channel ( & d11_inf_ , chanspec , & channel ) ; hw_ . SetChannel ( channel ) ; if ( scan_state_ . opts -> is_active ) { hw_ . TxProbeRequest ( pfn_mac_addr_ ) ; } std :: function < void ( ) > * callback = new std :: function < void ( ) > ; * callback = std :: bind ( & SimFirmware :: ScanNextChannel , this ) ; hw_ . RequestCallback ( callback , scan_state_ . opts -> dwell_time ) ; } } }
If a scan is in progress, switch to the next channel.
If a scan is in progress switch to the next channel .
// We may see this event if a scan was cancelled -- just ignore it // We don't yet support intermittent scanning // Scanning complete // Scan next channel