Strange error when compiling using xively library

Dear users!

I have a strange error when compiling even the official example “datastream upload”. Strange as it only happens on one of my computers.

#include <SPI.h>
#include <Ethernet.h>
#include <HttpClient.h>
#include <Xively.h>

// MAC address for your Ethernet shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// Your Xively key to let you upload data
char xivelyKey[] = "YOUR_XIVELY_API_KEY";

// Analog pin which we're monitoring (0 and 1 are used by the Ethernet shield)
int sensorPin = 2;

// Define the strings for our datastream IDs
char sensorId[] = "sensor_reading";
XivelyDatastream datastreams[] = {
  XivelyDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT),
};
// Finally, wrap the datastreams into a feed
XivelyFeed feed(15552, datastreams, 1 /* number of datastreams */);

EthernetClient client;
XivelyClient xivelyclient(client);

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  
  Serial.println("Starting single datastream upload to Xively...");
  Serial.println();

  while (Ethernet.begin(mac) != 1)
  {
    Serial.println("Error getting IP address via DHCP, trying again...");
    delay(15000);
  }
}

void loop() {
  int sensorValue = analogRead(sensorPin);
  datastreams[0].setFloat(sensorValue);

  Serial.print("Read sensor value ");
  Serial.println(datastreams[0].getFloat());

  Serial.println("Uploading it to Xively");
  int ret = xivelyclient.put(feed, xivelyKey);
  Serial.print("xivelyclient.put returned ");
  Serial.println(ret);

  Serial.println();
  delay(15000);
}

It is strange as on my desktop pc (using old win xp, arduino 1.6.8) it compiles without error.

However when I try to compile on my new laptop (win 10 arduino 1.6.9) I got this warning:

C:\Program Files (x86)\Arduino\libraries\xively_arduino\XivelyClient.cpp: In member function ‘int XivelyClient::get(XivelyFeed&, const char*)’:

C:\Program Files (x86)\Arduino\libraries\xively_arduino\XivelyClient.cpp:122:26: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

http.find(",");

^

I’ve installed the same libraries on both computers.

As a last idea, (i thought that maybe the library has been updated recently) I’ve copied the library folder directly from the PC and copied to the laptop, but the error remained.

Anyone has some useful hints?

This is the referenced function from XivelyClient.cpp:

int XivelyClient::get(XivelyFeed& aFeed, const char* aApiKey)
{
  HttpClient http(_client);
  char path[30];
  buildPath(path, aFeed.id(), "csv");
  http.beginRequest();
  int ret = http.get("api.xively.com", path);
  if (ret == 0)
  {
    http.sendHeader("X-ApiKey", aApiKey);
    http.sendHeader("User-Agent", "Xively-Arduino-Lib/1.0");    
    http.endRequest();

    ret = http.responseStatusCode();
    if ((ret < 200) || (ret > 299))
    {
      // It wasn't a successful response, ensure it's -ve so the error is easy to spot
      if (ret > 0)
      {
        ret = ret * -1;
      }
    }
    else
    {
      http.skipResponseHeaders();
      // Now we need to run through each line, looking to see if it matches one
      // of the given datastreams.
      // So that we don't use any more memory than necessary, we'll keep track
      // of which character we're up to in the ID string, and have a bit-field
      // of the remaining datastreams that match.  This limits us (if we use
      // and unsigned long) to 32 datastreams in a feed, but that's probably ok
      int idIdx = 0;
      unsigned long idBitfield = 0;
      for (int i =0; i < aFeed.size(); i++)
      {
        idBitfield |= 1 << i;
      }
      // As long as we've got bitfields to read
// FIXME Need to time out if this hangs for too long
      while ((http.available() || http.connected()))
      {
        if (http.available())
        {
          char next = http.read();
          switch (next)
          {
          case ',':
            // We've reached the end of the ID string, see if it matches any of the
            // datastreams in the feed
            // But first skip the updated time, to get to the value
            http.find(",");
            for (int i =0; i < aFeed.size(); i++)
            {
              if ((idBitfield & 1<<i) && (aFeed[i].idLength() == idIdx))
              {
                // We've found a matching datastream
                // FIXME cope with any errors returned
                aFeed[i].updateValue(http);
                // When we get here we'll be at the end of the line, but if aFeed[i]
                // was a string or buffer type, we'll have consumed the '\n'
                next = '\n';
              }
            }
            // Need to run to the end of the line regardless now
            // And deliberately drop through into the next case
            while ((next != '\r')  && (next != '\n') && (http.available() || http.connected()))
            {
              next = http.read();
            }
          case '\r':
          case '\n':
            // We've hit the end of the line, reset everything
            idIdx = 0;
            for (int i =0; i < aFeed.size(); i++)
            {
              idBitfield |= 1 << i;
            }
            break;
          default:
            // Next character of the ID string
            for (int i =0; i < aFeed.size(); i++)
            {
              if (!(idBitfield & 1<<i) || (aFeed[i].idChar(idIdx) != next))
              {
                idBitfield &= ~(1<<i);
              }
              // else we're still matching
            }
            idIdx++; // onto the next character in the ID
            break;
          };
        }
      }
      delay(10);
    }
    http.stop();
  }
  return ret;
}

but the error remained.

What error? The only "error" you posted was a warning that could be fixed.

Dear PaulS,

Yes, you are right. Indeed, I forgot to mention, that it is only a "warning", however, if I compile with the laptop (and the warning), than I get a -3 as ret (i.e. timeout) and no data are transmitted to xively. If I compile on the PC (without warning) I got a result of 200, and the data arrives to the xively server.

So it may seem to be a warning only , but actually the compled sketch dows not work. That was the reason behing using error, instead of warning.

Could you help me how to fix it Paul?