Are there special libraries or header files to use with Photon during Electron code development

I’m trying not to use my Electron cellular data plan during code development, and wondered if header files are available so I can compile my Electron code will testing it using a Photon?

  bool cellReady = Cellular.ready(); // Cellular (Electron)

  bool cloudReady = Particle.connected();
  	Serial.printlnf("wifi=%s cloud=%s counter_slp=%d retainedCounter_slp=%d", (cellReady ? "on" : "off"), (cloudReady ? "on" : "off"),
			counter_slp++, retainedCounter_slp++);

	if (cellReady) {
		if (firstAvailable == 0) {
			firstAvailable = millis();
//		if (millis() - firstAvailable > 30000) {
			// After we've been up for 30 seconds, go to sleep. The delay is so the serial output gets written out before
			// sleeping.
		if (millis() - firstAvailable > 500) {
			// After we've been up for 15, go to sleep. 
			Serial.println("calling System.sleep(SLEEP_MODE_DEEP, 300)");

//			System.sleep(SLEEP_MODE_DEEP, 60 * 20, SLEEP_NETWORK_STANDBY);//20 mins or 1200 secs Sleep now,
		//	System.sleep(A7,Falling, SLEEP_NETWORK_STANDBY, 7200);
        //  System.sleep(WKP, RISING, 1320, SLEEP_NETWORK_STANDBY); // sleepForSeconds =13200 seconds = 22 min.
        //  System.sleep(WKP, RISING, 60 * 30 * 4, SLEEP_NETWORK_STANDBY); // sleepForSeconds =7200 seconds = 2 hours.
        //  System.sleep(SLEEP_MODE_DEEP, 1320, SLEEP_NETWORK_STANDBY); // sleepForSeconds =13200 seconds = 22 min. (per SfuffR @ particle)
			// The rest of the code here is not reached. SLEEP_MODE_DEEP causes the code execution to stop,
			// and when wake up occurs, it's like a reset where you start again with setup(), all variables are
			// cleared, etc.
			Serial.println("returned from sleep, should not occur");
	else {
		firstAvailable = 0;
	}// End of Sleep code

I’m getting the following error when the Target is a Photon.

eck-new -std=gnu++11 -c -o …/build/target/user/platform-6-msrc/lcdsignalstrength.o src/lcdsignalstrength.cpp
lcdsignalstrength.ino:744:1: warning: “/*” within comment [-Wcomment]
lcdsignalstrength.ino: In function ‘void system_display_rssi()’:
lcdsignalstrength.ino:771:20: error: ‘Cellular’ was not declared in this scope

The same code compiles with no errors if the Target is an Electron.

I guess I’m not sure I understand the question, but the “error” you are reporting is because on Photon you will have the WiFi object and its methods but on Electron you will have the Cellular object and its methods.

You cannot compile for a Photon and target an Electron if you are using device specific features.


Okay, Thanks. I wondered if there was a way to mock an Electron using a Photon.

Sure, the cloud (Particle object) or TCP, yes, that works fine. You just can’t use Cellular or WiFi on the opposite platform

1 Like

For such cases where you have a equivalent function for both Cellular and WiFi I use this construct

  #define RADIO Cellular
  #define RADIO WiFi


For some other calls you may need to write some sections individually.

Perfect, that should work great.