beegee-tokyo / SX126x-Arduino

Arduino library to use Semtech SX126x LoRa chips and modules to communicate
MIT License
235 stars 64 forks source link

Compilation of the latest version fails due to out-of-scope variable #128

Closed TheGoncaloSilva closed 4 months ago

TheGoncaloSilva commented 4 months ago

Greetings,

The modifications introduced in version 2.0.25 of this library generate an out-of-scope variable error during compilation. The exact code is this one:

{
            m_callbacks->lmh_conf_result(mcpsConfirm->AckReceived);
            // Workaround, reset MAC state
            // Workaround for DR reset when ADR is active
            int8_t preserve_dr = LoRaMacParams.ChannelsDatarate;
            lmh_reset_mac();
            LoRaMacParams.ChannelsDatarate = preserve_dr;
        }
        break;
    }

I'm using PlatformIO to build my project and this error is generated. Rolling back to version 2.0.25 solves the issue, since only this lines of code were changed.

Logs

.pio/libdeps/rak4631/SX126x-Arduino/src/mac/LoRaMacHelper.cpp: In function 'void McpsConfirm(McpsConfirm_t*)':
.pio/libdeps/rak4631/SX126x-Arduino/src/mac/LoRaMacHelper.cpp:407:25: error: 'LoRaMacParams' was not declared in this scope
    int8_t preserve_dr = LoRaMacParams.ChannelsDatarate;
                         ^~~~Compiling .pio/build/rak4631/lib263/SX126x-Arduino/mac/region/RegionIN865.cpp.o
~~~~~~~~~
.pio/libdeps/rak4631/SX126x-Arduino/src/mac/LoRaMacHelper.cpp:407:25: note: suggested alternative: 'sLoRaMacParams'
    int8_t preserve_dr = LoRaMacParams.ChannelsDatarate;
                         ^~~~~~~~~~~~~
                         sLoRaMacParams
*** [.pio/build/rak4631/lib263/SX126x-Arduino/mac/LoRaMacHelper.cpp.o] Error 1

Thx, Gonçalo

beegee-tokyo commented 4 months ago

Added missing header file and forward declaration. ==> V2.0.26