@@ -170,18 +170,29 @@ int ws_management_regulatory_domain_set(
170170 }
171171
172172 ws_phy_cfg_t cfg ;
173+ ws_phy_cfg_t cfg_default ;
173174 if (ws_cfg_phy_get (& cfg , NULL ) < 0 ) {
174175 return -3 ;
175176 }
176177
178+ if (ws_cfg_phy_default_set (& cfg_default ) < 0 ) {
179+ return -3 ;
180+ }
181+
177182 if (regulatory_domain != 255 ) {
178183 cfg .regulatory_domain = regulatory_domain ;
184+ } else {
185+ cfg .regulatory_domain = cfg_default .regulatory_domain ;
179186 }
180187 if (operating_mode != 255 ) {
181188 cfg .operating_mode = operating_mode ;
189+ } else {
190+ cfg .operating_mode = cfg_default .operating_mode ;
182191 }
183192 if (operating_class != 255 ) {
184193 cfg .operating_class = operating_class ;
194+ } else {
195+ cfg .operating_class = cfg_default .operating_class ;
185196 }
186197
187198 if (ws_cfg_phy_set (cur , NULL , & cfg , 0 ) < 0 ) {
@@ -334,7 +345,18 @@ int ws_management_channel_mask_set(
334345 return -2 ;
335346 }
336347
337- memcpy (cfg .fhss_channel_mask , channel_mask , sizeof (uint32_t ) * 8 );
348+ ws_fhss_cfg_t cfg_default ;
349+ if (ws_cfg_fhss_default_set (& cfg_default ) < 0 ) {
350+ return -2 ;
351+ }
352+
353+ if (channel_mask ) {
354+ memcpy (cfg .fhss_channel_mask , channel_mask , sizeof (uint32_t ) * 8 );
355+ } else {
356+ // Use the default
357+ memcpy (cfg .fhss_channel_mask , cfg_default .fhss_channel_mask , sizeof (uint32_t ) * 8 );
358+ }
359+
338360
339361 if (ws_cfg_fhss_set (cur , NULL , & cfg , 0 ) < 0 ) {
340362 return -3 ;
@@ -434,14 +456,27 @@ int ws_management_fhss_timing_configure(
434456 return -2 ;
435457 }
436458
459+ ws_fhss_cfg_t cfg_default ;
460+ if (ws_cfg_fhss_default_set (& cfg_default ) < 0 ) {
461+ return -2 ;
462+ }
463+
437464 if (fhss_uc_dwell_interval > 0 ) {
438465 cfg .fhss_uc_dwell_interval = fhss_uc_dwell_interval ;
466+ } else if (fhss_uc_dwell_interval == 0xff ) {
467+ cfg .fhss_uc_dwell_interval = cfg_default .fhss_uc_dwell_interval ;
439468 }
469+
440470 if (fhss_broadcast_interval > 0 ) {
441471 cfg .fhss_bc_interval = fhss_broadcast_interval ;
472+ } else if (fhss_broadcast_interval == 0xffff ) {
473+ cfg .fhss_bc_interval = cfg_default .fhss_bc_interval ;
442474 }
475+
443476 if (fhss_bc_dwell_interval > 0 ) {
444477 cfg .fhss_bc_dwell_interval = fhss_bc_dwell_interval ;
478+ } else if (fhss_bc_dwell_interval == 0xff ) {
479+ cfg .fhss_bc_dwell_interval = cfg_default .fhss_bc_dwell_interval ;
445480 }
446481
447482 if (ws_cfg_fhss_set (cur , NULL , & cfg , 0 ) < 0 ) {
@@ -469,12 +504,27 @@ int ws_management_fhss_unicast_channel_function_configure(
469504 return -2 ;
470505 }
471506
507+ ws_fhss_cfg_t cfg_default ;
508+ if (ws_cfg_fhss_default_set (& cfg_default ) < 0 ) {
509+ return -2 ;
510+ }
511+
472512 if (dwell_interval > 0 ) {
473513 cfg .fhss_uc_dwell_interval = dwell_interval ;
514+ } else {
515+ cfg .fhss_uc_dwell_interval = cfg_default .fhss_uc_dwell_interval ;
516+ }
517+ if (channel_function < 0xff ) {
518+ cfg .fhss_uc_channel_function = channel_function ;
519+ } else {
520+ cfg .fhss_uc_channel_function = cfg_default .fhss_uc_channel_function ;
474521 }
475522
476- cfg .fhss_uc_channel_function = channel_function ;
477- cfg .fhss_uc_fixed_channel = fixed_channel ;
523+ if (fixed_channel < 0xffff ) {
524+ cfg .fhss_uc_fixed_channel = fixed_channel ;
525+ } else {
526+ cfg .fhss_uc_fixed_channel = cfg_default .fhss_uc_fixed_channel ;
527+ }
478528
479529 if (ws_cfg_fhss_set (cur , NULL , & cfg , 0 ) < 0 ) {
480530 return -3 ;
@@ -556,16 +606,34 @@ int ws_management_fhss_broadcast_channel_function_configure(
556606 if (ws_cfg_fhss_get (& cfg , NULL ) < 0 ) {
557607 return -2 ;
558608 }
609+ ws_fhss_cfg_t cfg_default ;
610+ if (ws_cfg_fhss_default_set (& cfg_default ) < 0 ) {
611+ return -2 ;
612+ }
559613
560614 if (dwell_interval > 0 ) {
561615 cfg .fhss_bc_dwell_interval = dwell_interval ;
616+ } else {
617+ cfg .fhss_bc_dwell_interval = cfg_default .fhss_bc_dwell_interval ;
562618 }
619+
563620 if (broadcast_interval > 0 ) {
564621 cfg .fhss_bc_interval = broadcast_interval ;
622+ } else {
623+ cfg .fhss_bc_interval = cfg_default .fhss_bc_interval ;
565624 }
566625
567- cfg .fhss_bc_channel_function = channel_function ;
568- cfg .fhss_bc_fixed_channel = fixed_channel ;
626+ if (channel_function != 0xff ) {
627+ cfg .fhss_bc_channel_function = channel_function ;
628+ } else {
629+ cfg .fhss_bc_channel_function = cfg_default .fhss_bc_channel_function ;
630+ }
631+
632+ if (fixed_channel != 0xffff ) {
633+ cfg .fhss_bc_fixed_channel = fixed_channel ;
634+ } else {
635+ cfg .fhss_bc_fixed_channel = cfg_default .fhss_bc_fixed_channel ;
636+ }
569637
570638 if (ws_cfg_fhss_set (cur , NULL , & cfg , 0 ) < 0 ) {
571639 return -3 ;
@@ -652,17 +720,33 @@ int ws_management_timing_parameters_set(
652720 return -2 ;
653721 }
654722
723+ ws_timing_cfg_t cfg_default ;
724+ if (ws_cfg_timing_default_set (& cfg_default ) < 0 ) {
725+ return -2 ;
726+ }
727+
655728 if (disc_trickle_imin > 0 ) {
656729 cfg .disc_trickle_imin = disc_trickle_imin ;
730+ } else {
731+ cfg .disc_trickle_imin = cfg_default .disc_trickle_imin ;
657732 }
733+
658734 if (disc_trickle_imax > 0 ) {
659735 cfg .disc_trickle_imax = disc_trickle_imax ;
736+ } else {
737+ cfg .disc_trickle_imax = cfg_default .disc_trickle_imax ;;
660738 }
739+
661740 if (disc_trickle_k > 0 ) {
662741 cfg .disc_trickle_k = disc_trickle_k ;
742+ } else {
743+ cfg .disc_trickle_k = cfg_default .disc_trickle_k ;;
663744 }
745+
664746 if (pan_timeout > 0 ) {
665747 cfg .pan_timeout = pan_timeout ;
748+ } else {
749+ cfg .pan_timeout = cfg_default .pan_timeout ;;
666750 }
667751
668752 if (ws_cfg_timing_set (cur , NULL , & cfg , 0 ) < 0 ) {
0 commit comments