Hi guys,
I’ve been experimenting with my sparks using the HTTP client library and example to post data to a emoncms server on a Rpi successfully. Recently I’ve encountered a problem that when the core starts breathing cyan when connected to either of my computers (One on Win7 one on Win8) the computer recognises them as a serial mouse. The cursor starts jumping around the screen and randomly left or right clicking on things. The chrome browser I currently have open freezes. Then when I re-open another chrome browser, if you click on a tab it closes the tab. All of which is after I’ve disconnected the spark from the USB. The only fix I’ve come across so far is too restart the computer.
Can anyone shed some light on this?
Code:
#include "application.h"
#include "HttpClient/HttpClient.h"
/**
* Declaring the variables.
*/
unsigned int nextTime = 0; // Next time to contact the server
HttpClient http;
// Headers currently need to be set at init, useful for API keys etc.
http_header_t headers[] = {
// { "Content-Type", "application/json" },
// { "Accept" , "application/json" },
{ "Accept" , "*/*"},
{ NULL, NULL } // NOTE: Always terminate headers will NULL
};
http_request_t request;
http_response_t response;
void setup() {
Serial.begin(9600);
Serial.println("Wales");
}
void loop() {
if (millis() - nextTime > 10000UL){}
Serial.println();
Serial.println("Application>\tStart of Loop.");
Serial.println("Wales");
// Request path and body can be set at runtime or at setup.
request.ip = {192,168,xxx,xxx};
request.port = 80;
request.path = "/emoncms/input/post.json?json={power:200}&apikey=3b172c8064620d9de6dcb4550b49xxxx";
// The library also supports sending a body with your request:
// Get request
http.get(request, response, headers);
Serial.print("Application>\tResponse status: ");
Serial.println(response.status);
Serial.print("Application>\tHTTP Response Body: ");
Serial.println(response.body);
nextTime = millis() + 10000;
}