@@ -7,10 +7,9 @@ RadioControlTask::RadioControlTask()
77void RadioControlTask::init ()
88{
99 if (!sfr::radio::initialized) {
10- switch (sfr::radio::start_progress) {
11- case 0 :
10+ if (sfr::radio::start_progress == 0 ) {
1211#ifdef VERBOSE
13- Serial.print (F (" Radio: Initializing ... " ));
12+ Serial.println (F (" Radio: Initializing ... " ));
1413#endif
1514 // initialize SX1278 with default settings
1615 code = radio.begin (constants::radio::freq, constants::radio::bw, constants::radio::sf, constants::radio::cr,
@@ -23,10 +22,11 @@ void RadioControlTask::init()
2322 Serial.println (code);
2423#endif
2524 }
26- break ;
27- case 1 :
25+ }
26+
27+ if (sfr::radio::start_progress == 1 ) {
2828#ifdef VERBOSE
29- Serial.print (F (" Radio: Setting CRC parameter ... " ));
29+ Serial.println (F (" Radio: Setting CRC parameter ... " ));
3030#endif
3131 // set CRC parameter to true so it matches the CRC parameter on the TinyGS side
3232 code = radio.setCRC (true );
@@ -38,25 +38,22 @@ void RadioControlTask::init()
3838 Serial.println (code);
3939#endif
4040 }
41- break ;
42- case 2 :
41+
42+ if (sfr::radio::start_progress == 2 ) {
4343#ifdef VERBOSE
44- Serial.print (F (" Radio: Setting forceLDRO parameter ... " ));
44+ Serial.println (F (" Radio: Setting forceLDRO parameter ... " ));
4545#endif
46- // set forceLDRO parameter to true so it matches the forceLDRO parameter on the TinyGS side
47- code = radio.forceLDRO (true );
48- if (code == RADIOLIB_ERR_NONE) {
49- sfr::radio::start_progress++ ;
50- } else {
46+ // set forceLDRO parameter to true so it matches the forceLDRO parameter on the TinyGS side
47+ code = radio.forceLDRO (true );
48+ if (code == RADIOLIB_ERR_NONE) {
49+ sfr::radio::initialized = true ;
50+ } else {
5151#ifdef VERBOSE
52- Serial.print (F (" failed, code " ));
53- Serial.println (code);
52+ Serial.print (F (" failed, code " ));
53+ Serial.println (code);
5454#endif
55+ }
5556 }
56- break ;
57- case 3 : // completed initialization
58- sfr::radio::initialized = true ;
59- break ;
6057 }
6158 }
6259}
0 commit comments