Separate core and photon api in software

Since the photon and core has a few difference in api, for example

     // for core
    SPARK_WLAN_Loop();
    // for photon
    Spark.process();

can I use the software to separate them, like

if(  core  ) SPARK_WLAN_Loop();
if(photon)   Spark.process();

Since your code needs to be built for the device, you can use conditional compile directives

#if (PLATFORM_ID == 6)
// Photon
#elif (PLATFORM_ID == 0)
// Core with yet to be released FW v0.4.x
#else
// Core with FW v0.3.4
#endif

See
Preprocessor #ifdef to Detect Platform Type (Core/Photon) at Compile Time

1 Like