I am trying to compare a text value returned from the Bridge and can't seem to understand the type of data being returned, or how to compare it to a text string (or character array?) for analysis.
At the moment, I am send a value through the Bridge using:
value.put("c_weather",'Clear')
Where the c_weather value is reading a value from an internet source. Since this value is weather related, it might change length and name. In this example the internet has returned "Clear", but it might also return something much longer, like "Partly Sunny" or "Mostly Cloudy".
I can get the value to come across the Bridge, but I can't seem to figure out how to compare c_weather to a text string(?) to do something with it. Here is what I'm trying in the sketch:
#include <Process.h>
#include <Bridge.h>
//Variables for Current Conditions
char c_weather[20];
void setup() {
Bridge.begin();
Serial.begin(9600);
}
void loop() {
//Run the Python Code to generate values
Process variables;
variables.runShellCommand("python /mnt/sda1/arduino/www/WU_Variables.py");
//Get Variables from the Bridge
Bridge.get("c_weather", c_weather, 20);
Serial.println(c_weather);
//Get Current Condition Icon
if (c_weather == ("Clear\r")) //Clear - this value isn't matching!!!!!
{
strip.setPixelColor(10, 255, 255, 0);
}
if (c_weather == "Overcast\n") //Overcast
{
strip.setPixelColor(56, 255, 255, 0);
}
strip.show();
}
}
I've given another example of "Overcast" to try and compare, in order to show that I want to read the data, compare it to a value, and then do something if it matches.
I believe that the data is coming over the Bridge as a character array, but I can't be sure. I assigned c_weather as a character with a size of 20 to be able to handle some of the longer weather description. When I serial.print the value it works, so I must be using the wrong format to read and compare the data. The \n and \r were used to check for an end of string, hoping that would work, but I don't think that matters because I'm not reading the value in correctly for the comparison to start in the first place.
Thanks for any help!