1.6 Getting Starting - Selecting Cloud Server

In this section we'll show you how to point your devices and applications to the Canopy Cloud Service server of your choice.

Hosted Service

Hosted Deployments

The Canopy team offers free and premium hosted deployments of the Canopy Cloud Service.

Configuring Cloud Server

You can configure Canopy libraries to communicate with any running instance of the Canopy Cloud Service.

Embedded (libcanopy) Server Selection

To point device firmware to a particular server, add this to the beginning of your program (before canopy_sync) is called:

    canopy_set_opt(ctx, CANOPY_CLOUD_HOST, "mycanopyserver.com");

If your server is running on non-standard ports, you can use:

    canopy_set_opt(ctx, 
        CANOPY_CLOUD_HOST, "mycanopyserver.com",
        CANOPY_HTTP_PORT, "8080",
        CANOPY_HTTPS_PORT, "8081",
        CANOPY_WS_PORT, "1234",
        CANOPY_WSS_PORT, "9090",
    );

Application (canopy.js) Server Selection

To point your Javascript application to a particular server, use the following initialization code:

// Initialize Canopy Javascript Client
var canopy = new CanopyClient({
     "cloud-host": "mycanopyserver.com",
});

If the server is running on non-standard ports, use:

// Initialize Canopy Javascript Client
var canopy = new CanopyClient({
     "cloud-host": "mycanopyserver.com",
     "http-port" : 8080,
     "https-port" : 8081, 
     "ws-port" : 1234,
     "wss-port" : 9090
});

Using sandbox.canopy.link

By default the server sandbox.canopy.link is used by all Canopy libraries. Without configuring anything, you can remotely manage your Canopy-enabled devices by going to: http://sandbox.canopy.link

Explicitly Pointing libcanopy To sandbox.canopy.link

If for some reason you would like to explicitly configure your software to point to sandbox.canopy.link, you can configure libcanopy with the following code (although it is unnecessary because sandbox.canopy.link is used by default).

    canopy_set_opt(ctx, CANOPY_CLOUD_HOST, "sandbox.canopy.link");

This option must be configured before the first call to canopy_sync. For example:

#include <canopy.h>

int main(void) {
    CanopyContext ctx;
    CanopyResultEnum result;

    ctx = canopy_init_context();
    if (!ctx) {
        canopy_write_error(ctx, stderr, "Failed to create context.");
        return -1;
    }

    result = canopy_set_opt(ctx,
        CANOPY_CLOUD_HOST, "sandbox.canopy.link",
        CANOPY_DEVICE_UUID, "",
        CANOPY_DEVICE_SECRET_KEY, ""
    );
    if (result != CANOPY_SUCCESS) {
        canopy_write_error(ctx, stderr, "Failed to configure context");
        return -1;
    }

    ...

Explicitly Pointing canopy.js To sandbox.canopy.link

Likewise, you can explicitly point canopy.js to sandbox.canopy.link with the following code. Again, this is unnecessary because sandbox.canopy.link is used by default.

// Initialize Canopy Javascript Client
var canopy = new CanopyClient({
     "cloud-host": "sandbox.canopy.link",
});

Using ccs.canopy.link

The Canopy team operates a deployment of the Canopy Cloud Service on the ccs.canopy.link domain. This is a production-ready deployment that is free for limited usage, with upgrades available for heavy usage.

Creating an Account on ccs.canopy.link

The ccs.canopy.link deployment requires that you create a Device Maker Account before your devices and applications can use it.

To create an account, go to: http://ccs.canopy.link

Generating Device IDs

The ccs.canopy.link deployment requires that each device has a pre-registered UUID and Secret Key. You can generate and register these values by going to: http://ccs.canopy.link/mgr/gen_devices

Embedded Development: Pointing libcanopy to ccs.canopy.link

To point libcanopy to ccs.canopy.link, set the CANOPY_CLOUD_HOST option appropriately:

    canopy_set_opt(ctx, CANOPY_CLOUD_HOST, "ccs.canopy.link");

This option must be configured before the first call to canopy_sync. For example:

#include <canopy.h>

int main(void) {
    CanopyContext ctx;
    CanopyResultEnum result;

    ctx = canopy_init_context();
    if (!ctx) {
        canopy_write_error(ctx, stderr, "Failed to create context.");
        return -1;
    }

    result = canopy_set_opt(ctx,
        CANOPY_CLOUD_HOST, "ccs.canopy.link",
        CANOPY_DEVICE_UUID, "",
        CANOPY_DEVICE_SECRET_KEY, ""
    );
    if (result != CANOPY_SUCCESS) {
        canopy_write_error(ctx, stderr, "Failed to configure context");
        return -1;
    }

    ...

The CANOPY_DEVICE_UUID and CANOPY_DEVICE_SECRET_KEY values must match the pre-registered values for your device.

Application Development: Pointing canopy.js to ccs.canopy.link

To point your application using canopy.js to ccs.canopy.link, use the following initialization code:

// Initialize Canopy Javascript Client
var canopy = new CanopyClient({
     "cloud-host": "ccs.canopy.link",
});