@@ -475,6 +475,58 @@ static unsigned int siwx91x_on_scan(sl_wifi_event_t event, sl_wifi_scan_result_t
475
475
return 0 ;
476
476
}
477
477
478
+ static int
479
+ siwx91x_configure_scan_dwell_time (sl_wifi_scan_type_t scan_type , uint16_t dwell_time_active ,
480
+ uint16_t dwell_time_passive ,
481
+ sl_wifi_advanced_scan_configuration_t * advanced_scan_config )
482
+ {
483
+ int ret = 0 ;
484
+
485
+ if (dwell_time_active && (dwell_time_active < 5 || dwell_time_active > 1000 )) {
486
+ LOG_ERR ("Invalid active scan dwell time" );
487
+ return - EINVAL ;
488
+ }
489
+
490
+ if (dwell_time_passive && (dwell_time_passive < 10 || dwell_time_passive > 1000 )) {
491
+ LOG_ERR ("Invalid passive scan dwell time" );
492
+ return - EINVAL ;
493
+ }
494
+
495
+ switch (scan_type ) {
496
+ case SL_WIFI_SCAN_TYPE_ACTIVE :
497
+ if (!dwell_time_active ) {
498
+ dwell_time_active = SL_WIFI_DEFAULT_ACTIVE_CHANNEL_SCAN_TIME ;
499
+ }
500
+ ret = sl_si91x_configure_timeout (SL_SI91X_CHANNEL_ACTIVE_SCAN_TIMEOUT ,
501
+ dwell_time_active );
502
+ break ;
503
+ case SL_WIFI_SCAN_TYPE_PASSIVE :
504
+ if (!dwell_time_passive ) {
505
+ dwell_time_passive = SL_WIFI_DEFAULT_PASSIVE_CHANNEL_SCAN_TIME ;
506
+ }
507
+ ret = sl_si91x_configure_timeout (SL_SI91X_CHANNEL_PASSIVE_SCAN_TIMEOUT ,
508
+ dwell_time_passive );
509
+ break ;
510
+ case SL_WIFI_SCAN_TYPE_ADV_SCAN :
511
+ __ASSERT (advanced_scan_config , "advanced_scan_config cannot be NULL" );
512
+
513
+ if (!dwell_time_active ) {
514
+ dwell_time_active = CONFIG_WIFI_SILABS_SIWX91X_ADV_ACTIVE_SCAN_DURATION ;
515
+ }
516
+ advanced_scan_config -> active_channel_time = dwell_time_active ;
517
+
518
+ if (!dwell_time_passive ) {
519
+ dwell_time_passive = CONFIG_WIFI_SILABS_SIWX91X_ADV_PASSIVE_SCAN_DURATION ;
520
+ }
521
+ advanced_scan_config -> passive_channel_time = dwell_time_passive ;
522
+ break ;
523
+ default :
524
+ break ;
525
+ }
526
+
527
+ return ret ;
528
+ }
529
+
478
530
static int siwx91x_scan (const struct device * dev , struct wifi_scan_params * z_scan_config ,
479
531
scan_result_cb_t cb )
480
532
{
@@ -510,6 +562,11 @@ static int siwx91x_scan(const struct device *dev, struct wifi_scan_params *z_sca
510
562
}
511
563
512
564
if (sidev -> state == WIFI_STATE_COMPLETED ) {
565
+ siwx91x_configure_scan_dwell_time (SL_WIFI_SCAN_TYPE_ADV_SCAN ,
566
+ z_scan_config -> dwell_time_active ,
567
+ z_scan_config -> dwell_time_passive ,
568
+ & advanced_scan_config );
569
+
513
570
ret = sl_wifi_set_advanced_scan_configuration (& advanced_scan_config );
514
571
if (ret != SL_STATUS_OK ) {
515
572
LOG_ERR ("advanced scan configuration failed with status %x" , ret );
@@ -522,8 +579,20 @@ static int siwx91x_scan(const struct device *dev, struct wifi_scan_params *z_sca
522
579
} else {
523
580
if (z_scan_config -> scan_type == WIFI_SCAN_TYPE_ACTIVE ) {
524
581
sl_scan_config .type = SL_WIFI_SCAN_TYPE_ACTIVE ;
582
+ ret = siwx91x_configure_scan_dwell_time (SL_WIFI_SCAN_TYPE_ACTIVE ,
583
+ z_scan_config -> dwell_time_active ,
584
+ z_scan_config -> dwell_time_passive ,
585
+ NULL );
525
586
} else {
526
587
sl_scan_config .type = SL_WIFI_SCAN_TYPE_PASSIVE ;
588
+ ret = siwx91x_configure_scan_dwell_time (SL_WIFI_SCAN_TYPE_PASSIVE ,
589
+ z_scan_config -> dwell_time_active ,
590
+ z_scan_config -> dwell_time_passive ,
591
+ NULL );
592
+ }
593
+ if (ret != SL_STATUS_OK ) {
594
+ LOG_ERR ("Failed to configure timeout" );
595
+ return - EINVAL ;
527
596
}
528
597
}
529
598
0 commit comments