DeviceOS 3.2.0 crashing during OTA from 3.1.0

While this has changed from time to time between Device OS versions it's best to not set pinMode() in a constructor as (in some versions) these functions themselves rely on other objects to already be instantiated which they may not be.

See here some old hint in that direction

Then a few years later the same issue reappeared (e.g. here pietteTech_DHT library does not work with latest Particle OS (redux) - #4 by ScruffR)

You can also try SYSTEM_THREAD(ENABLED).