Error flashing Code to Boron

I have this code, I have been flashing to my electrons. And the code always works. But recently, I purchased borons, and tried to flash the same code from the web IDE as I do all the time. I’m getting a weird error. I have a hunch that maybe the boron has different development parameters I didn’t consider because the code works for the electrons and not the borons. Here is my code:

const int trigPin = D2;
const int echoPin = D6;

int tempC;
int analogvalue;
int aString;
// defines variables
long duration;
double distance;

String inWord;
char inByte;
String data;
int LockLED = D1;  

void setup() {
    
    Particle.variable("distance", &distance, DOUBLE);
    Particle.variable("duration", &duration);
    Particle.variable("analogvalue", &analogvalue, INT);
    pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
    pinMode(echoPin, INPUT); // Sets the echoPin as an Input
    Serial.begin(9600); // Starts the serial communication
    
    // cloud variable
    Particle.variable("GPS", data);
    // GPS Serial
    Serial1.begin(9600);
    pinMode(LockLED, OUTPUT);
    digitalWrite(LockLED, HIGH);
    delay(2000);
    digitalWrite(LockLED, LOW);
    
    //String data = String(10);
    
  // Trigger the integration
    //Particle.publish("distance", data, PRIVATE);
  // Wait 60 seconds
    //delay(30000);

}

void loop() {

    // Clears the trigPin
    digitalWrite(trigPin, LOW);
    delayMicroseconds(2);
    // Sets the trigPin on HIGH state for 10 micro seconds
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(trigPin, LOW);
    // Reads the echoPin, returns the sound wave travel time in microseconds
    duration = pulseIn(echoPin, HIGH);
    
    //analogvalue = addition(distance + 0);
    // Calculating the distance
    distance= duration*0.034/2;
    // Prints the distance on the Serial Monitor
    Serial.print("Distance: ");
    Serial.println(distance);
    Particle.publish("distance", String(distance), PRIVATE);
    delay(30000);

    analogvalue = 129;
    
     while (Serial1.available() > 0) {
        inByte = Serial1.read();
        if (inByte == '\n') {
            // END OF LINE
           
            Serial.print("inWord: ");
            Serial.println(inWord);
            // check is data we want
            // you can change this to get any data line values
            if (inWord.startsWith("$GPRMC")) {
                // put data string in variable
                data = inWord;
                Serial.print("data: ");
                Serial.println(data);
                Particle.publish("GPS", String(data), PRIVATE);
                digitalWrite(LockLED, HIGH);
                delay(500);
                digitalWrite(LockLED, LOW);
                
                // clear the inword variable
                inWord = "";
                
                // does the GPS Receiver have lock?
                // get the char at pos 17 and test to see if it is an A i.e VALID, V = INVALID
                char lock = data.charAt(17);
                Serial.print("lock: ");
                Serial.println(lock);
                if (lock == 'A') {
                    // YES Switch on Lock LED
                    digitalWrite(LockLED, HIGH);
                } else {
                    // NO turn off lock led
                    //digitalWrite(LockLED, LOW);  
                }
                
                
            } else {
                // clear the inword variable as not the data we want
                inWord = "";
            }
            
        } else {
            // build data string
            inWord += inByte;   
        }
        
    } // end if serial
}

long microsecondsToCentimeters(long microseconds) {
   return microseconds / 29 / 2;
}

The error I get is :

../wiring/inc/spark_wiring_cloud.h:108:91: no type named 'type' in 'struct std::enable_if<false, std::nullptr_t>'
error
../wiring/inc/spark_wiring_cloud.h:435:103: no type named 'type' in 'class std::result_of<long int*()>'

I’m quite new to particle in general, so your help will be appreciated.

Have you double checked that this code actually works on Electrons with the same device OS target as your Boron?

The first indication for (years ago) deprecated syntax is here

This would be written today as

    Particle.variable("distance", distance);
    Particle.variable("duration", duration);
    Particle.variable("analogvalue", analogvalue);

BTW, on these devices int and long are actually the same thing :wink:
Also if you look at the SHOW RAW output of Web IDE compiling this code for either Boron or Electron you'd get some more elaborate info about the issue which may point you at the actual place of the problem in your code.

1 Like

Thanks man! I checked the device target issue and it does turn out it was different on the electron. My hunch is I did a particle update on the boron, but I’ve never done it on any of my five electrons. So the deprecated code works on the old electron firmware but doesn’t on the updated firmware boron. In any case, changing to the new syntax worked. and the boron was flashed. Thanks for the timely assistance!

1 Like

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