Making code cross platform

There are also other “flags” the rather focus on available features instead of platform
e.g.

#if Wiring_WiFi 
// WiFi specific stuff
#elif Wiring_Cellular
// Cellular specific stuff
#else
// or
#define HAL_PLATFORM_WIFI (1)
#define HAL_PLATFORM_CELLULAR (1) 
#define HAL_PLATFORM_MESH (1)

I also use this to abstract away WiFi or Cellular specifics

#if Wiring_WiFi 
  #define RADIO WiFi
#elif Wiring_Cellular
  #define RADIO Cellular
#else
...
  // somewhere in code
  RADIO.connect();
  waitUntil(RADIO.ready);

Here you can find some of the defined platforms and features


2 Likes