Photon offline mode

Hi guys
I'm trying to make my photon run a code without the need to connect to wifi, I tried :

boolean connectToCloud = false;

at the top of my code but, I get the following error

../wiring/inc/spark_wiring_system.h:458:55: redefinition of 'SystemClass SystemMode'

this is the raw:

Processing  commov_rx.ino
Checking library LiquidCrystal...
Checking library Adafruit_MCP23017...
Checking library neopixel...
Checking library RFM69-Particle...
Installing library neopixel 1.0.0 to lib/neopixel ...
Installing library RFM69-Particle 0.0.5 to lib/RFM69-Particle ...
Installing library LiquidCrystal 0.0.3 to lib/LiquidCrystal ...
Installing library Adafruit_MCP23017 1.0.2 to lib/Adafruit_MCP23017 ...
Library neopixel 1.0.0 installed.
Library LiquidCrystal 0.0.3 installed.
Library Adafruit_MCP23017 1.0.2 installed.
Library RFM69-Particle 0.0.5 installed.
make -C ../modules/photon/user-part all
make[1]: Entering directory '/firmware/modules/photon/user-part'
make -C ../../../user 
make[2]: Entering directory '/firmware/user'
Building cpp file: src/commov_rx.cpp
Invoking: ARM GCC CPP Compiler
mkdir -p ../build/target/user/platform-6-msrc/
arm-none-eabi-gcc -DSTM32_DEVICE -DSTM32F2XX -DPLATFORM_THREADING=1 -DPLATFORM_ID=6 -DPLATFORM_NAME=photon -DUSBD_VID_SPARK=0x2B04 -DUSBD_PID_DFU=0xD006 -DUSBD_PID_CDC=0xC006 -DSPARK_PLATFORM -g3 -gdwarf-2 -Os -mcpu=cortex-m3 -mthumb -DINCLUDE_PLATFORM=1 -DPRODUCT_ID=6 -DPRODUCT_FIRMWARE_VERSION=65535 -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -DSYSTEM_VERSION_STRING=1.4.3 -DRELEASE_BUILD -I./inc -I../wiring/inc -I../system/inc -I../third_party/miniz/miniz -I../services/inc -I../third_party/nanopb/nanopb -I../communication/inc -I../hal/inc -I../hal/shared -I../hal/src/photon -I../hal/src/stm32f2xx -I../hal/src/stm32 -I../hal/src/photon/api -I../hal/src/photon/include -I../hal/src/photon/wiced/security/BESL/host/WICED/ -I../hal/src/photon/wiced/security/BESL/include -I../hal/src/photon/wiced/security/BESL -I../hal/src/photon/wiced/security/BESL/crypto -I../hal/src/photon/wiced/WWD/include/ -I../hal/src/photon/wiced/platform/include/ -I../hal/src/photon/wiced/platform/GCC/ -I../hal/src/photon/wiced/security/BESL/supplicant/ -I../hal/src/photon/libraries/crypto -I../hal/src/photon/libraries/daemons/DNS_redirect -I../platform/shared/inc -I../platform/MCU/STM32F2xx/STM32_USB_Host_Driver/inc -I../platform/MCU/STM32F2xx/STM32_USB_OTG_Driver/inc -I../platform/MCU/STM32F2xx/STM32_StdPeriph_Driver/inc -I../platform/MCU/STM32F2xx/STM32_USB_Device_Driver/inc -I../platform/MCU/STM32F2xx/SPARK_Firmware_Driver/inc -I../platform/MCU/shared/STM32/inc -I../platform/MCU/STM32F2xx/CMSIS/Include -I../platform/MCU/STM32F2xx/CMSIS/Device/ST/Include -I../dynalib/inc -Isrc -I./libraries -Ilib/LiquidCrystal/src -Ilib/RFM69-Particle/src -Ilib/Adafruit_MCP23017/src -Ilib/neopixel/src -I. -MD -MP -MF ../build/target/user/platform-6-msrc/commov_rx.o.d -ffunction-sections -fdata-sections -Wall -Wno-switch -Wno-error=deprecated-declarations -fmessage-length=0 -fno-strict-aliasing -DSPARK=1 -DPARTICLE=1 -Wundef -DSTART_DFU_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -DBOOTLOADER_SDK_3_3_0_PARTICLE -DPARTICLE_DCT_COMPATIBILITY -DSPARK_PLATFORM_NET=BCM9WCDUSI09 -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc  -DLOG_INCLUDE_SOURCE_INFO=1 -DPARTICLE_USER_MODULE -DUSER_FIRMWARE_IMAGE_SIZE=0x20000 -DUSER_FIRMWARE_IMAGE_LOCATION=0x80A0000 -DMODULAR_FIRMWARE=1 -DMODULE_VERSION=6 -DMODULE_FUNCTION=5 -DMODULE_INDEX=1 -DMODULE_DEPENDENCY=4,2,1405 -DMODULE_DEPENDENCY2=0,0,0 -D_WINSOCK_H -D_GNU_SOURCE -DLOG_MODULE_CATEGORY="\"app\""  -fno-exceptions -fno-rtti -fcheck-new -std=gnu++14 -c -o ../build/target/user/platform-6-msrc/commov_rx.o src/commov_rx.cpp
In file included from ../wiring/inc/spark_wiring.h:50:0,
                 from ./inc/application.h:40,
                 from src/commov_rx.cpp:1:
../wiring/inc/spark_wiring_system.h:458:55: error: redefinition of 'SystemClass SystemMode'
 #define SYSTEM_MODE(mode)  SystemClass SystemMode(mode);
commov_rx.ino:62:1: note: in expansion of macro 'SYSTEM_MODE'
../wiring/inc/spark_wiring_system.h:458:40: note: 'SystemClass SystemMode' previously declared here
 #define SYSTEM_MODE(mode)  SystemClass SystemMode(mode);
commov_rx.ino:13:1: note: in expansion of macro 'SYSTEM_MODE'
../build/ recipe for target '../build/target/user/platform-6-msrc/commov_rx.o' failed
make[2]: *** [../build/target/user/platform-6-msrc/commov_rx.o] Error 1
make[2]: Leaving directory '/firmware/user'
../../../build/ recipe for target 'user' failed
make[1]: *** [user] Error 2
make[1]: Leaving directory '/firmware/modules/photon/user-part'
../build/ recipe for target 'modules/photon/user-part' failed
make: *** [modules/photon/user-part] Error 2

here is my code:

any ideas of how to solve this?

Thank you!

@dsn101, remove the auto-includes at the top of the file since you already have those defined. Also, you have two SYSTEM_MODE() defined, one at line 13 and the other at line 62 in the unmodified file. Remove the one at line 62 and decide if line 13 should be SEMI-AUTOMATIC or AUTOMATIC. I test compiled with Photon and DeviceOS 1.4.3. :wink:


Thank you!

It’s always good to keep the code tidy and avoiding multiple #include statements for the same header is never good style and scattering them all over the place doesn’t help keeping them in check :wink:

Consequently haveing dedicated sections in the code files for different kinds of definitions is something that helps me keeping track of things.
I 'm usually following this order

  • SYSTEM_..... macro instances as far up in the file as possible
  • includes in one place
  • #define statements together (possibly avoiding them where possible and rather use constants)
  • const declarations
  • variable definitions
  • object instances
  • forward declarations for functions (if required)
  • setup(), loop(), functions pertaining to Particle.xxxx() handlers
  • primary “business” logic functions
  • suplemental functions

Even when re-using older or (especially) when using someone else’s code, I first tidy up that code to match my “habitual” style which then makes it a lot easier for me to get a feeling for the code when reading that code in order to first understand what it’s doing before extending it to my needs. This way navigation and eventually debugging will be much more intuitive.

The first bullet in above order would have helped see the issue on first glance.

BTW, #include <Wire.h> is not needed, nor are some of the extra RFMxxxxx.h includes
one single ( :wink: ) #include <RFM69-Particle.h> will do.


@ScruffR It would be great if you could provide a sample firmware for reference :grinning:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.