Used to compile, but will not now without any changes

I use a photon to control the under & in cabinet lights in my kitchen. I haven’t touched the code in over a year because i haven’t had a need to. It used to compile just fine, now I’m getting an error code I do not understand. Google is not being much help in resolving the error so I’m hoping someone here will be able to.
The error I’m getting is:
“…/wiring/inc/spark_wiring_cloud.h:85:25: call of overloaded ‘_variable(const char [6], const IPAddress&)’ is ambiguous”
The RAW output of the error is:
Processing countertop-lights.ino
Checking library neopixel…
Installing library neopixel 1.0.0 to lib/neopixel …
Library neopixel 1.0.0 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/countertop-lights.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=0.7.0 -DRELEASE_BUILD -I./inc -I…/wiring/inc -I…/system/inc -I…/services/inc -I…/communication/src -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…/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/neopixel/src -I. -MD -MP -MF …/build/target/user/platform-6-msrc/countertop-lights.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=5 -DMODULE_FUNCTION=5 -DMODULE_INDEX=1 -DMODULE_DEPENDENCY=4,2,207 -DMODULE_DEPENDENCY2=0,0,0 -D_WINSOCK_H -D_GNU_SOURCE -DLOG_MODULE_CATEGORY="“app”" -fno-exceptions -fno-rtti -fcheck-new -std=gnu++11 -c -o …/build/target/user/platform-6-msrc/countertop-lights.o src/countertop-lights.cpp
countertop-lights.ino: In function ‘bool motion()’:
countertop-lights.ino:157:1: warning: no return statement in function returning non-void [-Wreturn-type]
In file included from …/wiring/inc/spark_wiring.h:47:0,
from ./inc/application.h:40,
from ./inc/Particle.h:5,
from lib/neopixel/src/neopixel.h:57,
from src/countertop-lights.cpp:35:
…/wiring/inc/spark_wiring_cloud.h: In instantiation of ‘static bool CloudClass::variable(const T&, const Types& …) [with T = char [6]; Types = {IPAddress}]’:
countertop-lights.ino:101:31: required from here
…/wiring/inc/spark_wiring_cloud.h:85:25: error: call of overloaded ‘_variable(const char [6], const IPAddress&)’ is ambiguous
return _variable(name, args…);
^
…/wiring/inc/spark_wiring_cloud.h:89:24: note: candidate: static bool CloudClass::_variable(const char*, const bool&)
static inline bool _variable(const char* varKey, const bool& var)
^
…/wiring/inc/spark_wiring_cloud.h:94:24: note: candidate: static bool CloudClass::_variable(const char*, const int&)
static inline bool _variable(const char* varKey, const int& var)
^
…/wiring/inc/spark_wiring_cloud.h:101:24: note: candidate: static bool CloudClass::_variable(const char*, const int32_t&)
static inline bool _variable(const char* varKey, const int32_t& var)
^
…/wiring/inc/spark_wiring_cloud.h:107:24: note: candidate: static bool CloudClass::_variable(const char*, const uint32_t&)
static inline bool _variable(const char* varKey, const uint32_t& var)
^
…/wiring/inc/spark_wiring_cloud.h:113:17: note: candidate: static bool CloudClass::_variable(const char*, const float&)
static bool _variable(const char* varKey, const float& var)
^
…/wiring/inc/spark_wiring_cloud.h:117:24: note: candidate: static bool CloudClass::_variable(const char*, const double&)
static inline bool _variable(const char* varKey, const double& var)
^
…/wiring/inc/spark_wiring_cloud.h:122:24: note: candidate: static bool CloudClass::_variable(const char*, const String&)
static inline bool _variable(const char* varKey, const String& var)
^
…/build/module.mk:267: recipe for target ‘…/build/target/user/platform-6-msrc/countertop-lights.o’ failed
make[2]: *** […/build/target/user/platform-6-msrc/countertop-lights.o] Error 1
make[2]: Leaving directory ‘/firmware/user’
…/…/…/build/recurse.mk:11: recipe for target ‘user’ failed
make[1]: *** [user] Error 2
make[1]: Leaving directory ‘/firmware/modules/photon/user-part’
…/build/recurse.mk:11: recipe for target ‘modules/photon/user-part’ failed
make: *** [modules/photon/user-part] Error 2

It looks to be something in spark_wiring.h, which I assume is a cloud based file. Any help would be appreciated.

That's probably due to some deprecation that has come into effect with the device OS version you are targeting now.

If we could see some of your code we might be able to be more specific.

It’s kinda crude, but it does what I needed it to do. This was one of my first projects while I was trying to teach myself, so it’s probably full of waste and nowhere near optimized. Full code included below. A the time, I was using the latest OS version, 0.8.0-rc2. I see the default is now 1.31. I tried to compile based on several versions and get the same error no matter the target version I select.

#include <neopixel.h>
#include "application.h"
#include "neopixel/neopixel.h"

// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_COUNT 128           //led strip
#define PIXEL_PIN D0
#define PIXEL_TYPE SK6812RGBW     //led strip

#define RED 0,255,0,0
#define GREEN 255,0,0,0
#define BLUE 0,0,255,0
#define WHITE 0,0,0,255
#define CYAN 150,10,70,0
#define PEACH 50,200,5,0
#define PURPLE 0,180,180,0
#define REDORANGE 50,250,0,0
#define OFF 0,0,0,0

#define ONE_DAY_MILLIS (24 * 60 * 60 * 1000)
unsigned long lastSync = millis();

Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);

int  ledPin = D7;                                            // pin D7 using internal LED as indicator
int  pirPin = D4;                                            // choose the input pin (for pir sensor)
int  ldrPin = A2;                                            // pin for analog reading of LDR
int  pirState = LOW;                                         // we start, assuming no motion detected
int  pirValue = 0;                                           // variable for reading the pin status
int  calTime = 15;                                           // the time we give the sensor to calibrate (10-60 secs according to the datasheet)
int  ldrValue;                                               // int to store LDR pin Readings
int  Freq (25);                                              // how often to check for motion
bool Day;// = 0;
bool Night;//= 1;
int  waitTime = (3*60*1000);                                 // amount of time without motion before turning lights off
bool Motion = 0;
bool lightOn = 0;
int  i;
void Color(int G, int R, int B, int W);


//***********************************************************************************************************

void setup()
{
    strip.begin();
    strip.setBrightness(0);
    strip.show();
    pinMode(pirPin, INPUT_PULLDOWN);
    pinMode(ledPin, OUTPUT);
    for(int v = 0; v < calTime; v++)
    {
        delay(1000);
        //Particle.publish("CALIBRATING SENSOR");
    }
    delay(50);
    //Particle.publish("SENSOR CALIBRATED. PROGRAM RUNNING");

} // end of void setup

//***********************************************************************************************************

void loop() {
    // PRINT THE DEVICE'S IP ADDRESS IN
// THE FORMAT 192.168.0.10
IPAddress myIP = WiFi.localIP();
Particle.variable("IPAdd",myIP);
//Serial.println(myIP);    // prints the device's IP address
    
    // Request time synchronization from the Particle Cloud
    if (millis() - lastSync > ONE_DAY_MILLIS) 
    {
    Particle.syncTime();
    //Particle.publish("Time Synced");
    lastSync = millis();
    }
    
    // Main Operational Code
    motion();
    for(int t=0; t<waitTime; t = (t + Freq))
    {
        if (t < waitTime)
        {
            motion();
            if (Motion == 1)
            {
                TurnLEDon();
                //Particle.publish("LIGHTS ON");
                t = 0;
                delay(Freq);
            }
            else
            {
                if (t >= (waitTime - Freq))
                {
                    TurnLEDoff();
                    //Particle.publish("LIGHTS OFF");
                }
                else
                {
                    delay(Freq);
                }
            }
        }
    }

} // end of void loop

//***********************************************************************************************************

bool motion()
// motion detection
{
    pirValue = digitalRead(pirPin);
    if (pirValue == HIGH)
    {
        Motion = TRUE;
    }
    else
    {
        Motion = FALSE;
    }
} // end bool motion

//***********************************************************************************************************

void IsLightOn(){
// Determine if LED's are currently on
// Queries the internal LED pin to see if the LED's have been turned on or not

    digitalRead(ledPin);
    if (ledPin == HIGH)
    {
        lightOn = TRUE;
    }
    else if (ledPin == LOW)
    {
        lightOn = FALSE;    
    }
    //return; // lightOn;
} // end bool IsLightOn

//***********************************************************************************************************

void TurnLEDon()
{
    digitalWrite(ledPin, HIGH);                             // turn internal LED on
    lightOn = TRUE;
    DayNight();
    if (Day == 1)
    {
        Color(WHITE);                                       // choose daytime color
        strip.setBrightness(255);
    }
    else
    {
        Color(REDORANGE);                                   // choose night time color  //REDORANGE normally
        strip.setBrightness(175);
    }
    strip.show();
} // end TurnLEDon

//***********************************************************************************************************

void TurnLEDoff()
{
    digitalWrite(ledPin, LOW);                              // turn internal LED on
    lightOn = FALSE;
    Color(OFF);
    strip.setBrightness(0);
    strip.show();
} // end TurnLEDoff

//***********************************************************************************************************

void Color(int G, int R, int B, int W)
//void Color(int R, int G, int B)
//turn led's on with specified color
{
    for(int f=0; f < PIXEL_COUNT; f++)
    {
        strip.setPixelColor(f, G,R,B,W);
        //strip.setPixelColor(f, R,G,B);
    }
    strip.show();
} // end color loop

//***********************************************************************************************************

void DayNight()
{
    pinMode(ldrPin, INPUT);                                 // read from LDR
    int sval = 0;
    ldrValue = 0;
    for (int p = 0; p < 5; p++)
    {
        sval = (sval + analogRead(ldrPin));                 
        delay(10);
    }
    ldrValue = (sval / 5);                                  // average
    Serial.println(ldrValue);
    Particle.variable("LightValue: ", ldrValue);
    if (ldrValue >300)
    {
        Day = 1;
        Night = 0;
    }
    else
    {
        Day = 0;
        Night = 1;
    }
} // end DayNight

//***********************************************************************************************************

Particle.variable() has no business in loop() (nor in any other function but setup()) and it must have a global variable as base.
The name of a variable should also not contain blanks nor be longer than 12 characters.
Most importantly this is your breaking error

Particle.variable() can only register strings, int or double variables. IPAddress is not a valid type. It may have worked since there was implicit casting into a string, but stricter rules also enforce better codeing practices.

For Particle.publish() you should always provide a scope - preferably PRIVATE.

Your bool motion() should also return a bool - currently you don't return anything at all.

1 Like

Thanks. I thought I had all the Particle.publish removed since they were just for initial testing. It’s working now since removing the IPAddress reference which I don’t even remember why I had in there.