std::string HueConnector::transmit(std::string target, std::string payload)
{
std::cout << "Transmitting to " << target << " " << payload << endl;
- CURL *curl;
- CURLcode res;
+ CURL *curl = NULL;
+ CURLcode res = CURLE_OK;
struct curl_slist *headers = NULL; /* http headers to send with request */
/* set content type */
headers = curl_slist_append(headers, "Accept: application/json");
res = curl_easy_perform(curl);
/* Check for errors */
if (res != CURLE_OK)
+ {
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
+ }
/* always cleanup */
curl_easy_cleanup(curl);
std::string HueConnector::read(std::string target)
{
std::cout << "Reading from to " << target << endl;
- CURL *curl;
- CURLcode res;
+ CURL *curl = NULL;
+ CURLcode res = CURLE_OK;
struct curl_slist *headers = NULL; /* http headers to send with request */
/* set content type */
headers = curl_slist_append(headers, "Accept: application/json");