Spark Core Support


#1

Is there any documentation describing how to connect a Spark Core to Exosite’s platform?


GBOARD PRO 800 Support
#2

We don’t have anything official for the spark core, but the API itself is pretty simple.

Here’s a little example that I whipped up using the HttpClient library for our HTTP data API:

#include "application.h"
#include "HttpClient/HttpClient.h"

HttpClient http;
http_request_t request;
http_response_t response;
http_header_t headers[] = {
    { "X-Exosite-CIK" , "a32c85ba9dda45823be416246cf8b433baa068d7" },
    { "Accept" , "application/x-www-form-urlencoded; charset=utf-8"},
    { "Content-Type", "application/x-www-form-urlencoded; charset=utf-8" },
    { NULL, NULL } // NOTE: Always terminate headers will NULL
};

void setup() {
    Serial.begin(9600);
}

void loop() {
    Serial.println("[EXO]\tLoop");
    request.hostname = "m2.exosite.com";
    request.port = 80;
    request.path = "/api:v1/stack/alias?command&led"; // put aliases to read here
    request.body = "temp=37.42"; // put alias & value pairs to write here

    // make request
    http.post(request, response, headers);
    Serial.print("[EXO]\tResponse status: ");
    Serial.println(response.status);

    Serial.print("[EXO]\tHTTP Response Body: ");
    Serial.println(response.body);

    delay(5000);
}

Right now, it just prints the response, so you’d need to do a little bit of string trickery to get the values out. Here’s how I do it in our Relayduino example: https://github.com/exosite-garage/arduino_exosite_library/blob/master/examples/Relayduino/Relayduino.ino#L155-L186


#3

With HTTP client library I get response -1 instead of 200.
Otherwise, the library works and I manage to send data.
The hardware is Particle Electron.


#4

I assume you’re getting that from response.status? It looks like that’s just the default error that you get any time it was unable to get a HTTP status code.

I won’t have time to test anything myself any time soon, but if you want to post a serial log of what it’s printing, I might be able to help you debug.

You might also want to try the Particle forum, the code I posted above is a straight copy of the HttpClient library’s example with just the actual data changed.


#5

This is the log:

The problem is probably to TCP client library of the Electron.


#6

Yeah, could also be that there’s some problem with its connection to the internet. Hard to say from that snippet. I’d suggest going over to the Particle forum. They definitely have much more experience debugging that library than I would.


#7

Hello Patrick,
Maybe this is the problem.