Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- Marc Nijdam 
- Date:
- 2017-07-06
- Revision:
- 4:03dac69c22c5
- Parent:
- 3:8e6494dda270
- Child:
- 6:65411183b48a
File content as of revision 4:03dac69c22c5:
/*
 * Copyright 2017, Helium Systems, Inc.
 * All Rights Reserved. See LICENSE.txt for license information
 */
#include "mbed.h"
#include "Helium.h"
#include <inttypes.h>
void report_status(int status)
{
    if (helium_status_OK == status) {
        printf("Succeeded\n");
    } else {
        printf("Failed (status %d)\n", status);
    }
}
void report_status_result(int status, int result)
{
    if (helium_status_OK == status) {
        if (result == 0) {
            printf("Succeeded\n");
        } else {
            printf("Failed - %d", result);
        }
    } else {
        printf("Failed (status %d)\n", status);
    }
}
#if defined(TARGET_K64F)
Helium helium(D9, D7); // TX:D9, RX:D7
#elif defined(TARGET_WIZwiki_W7500)
Helium helium(D1, D0);
#else
#error Please define helium with serial tx/rx
#endif
Channel channel(&helium);
int main()
{
    printf("Starting\n");
    printf("Info - ");
    struct helium_info info;
    int status = helium.info(&info);
    if (helium_status_OK == status) {
        printf("%" PRIx64 " - ", info.mac);
    }
    report_status(status);
    printf("Connecting - ");
    status = helium.connect();
    report_status(status);
    printf("Creating Channel - ");
    int8_t result;
    status = channel.begin("Helium Cloud MQTT", &result);
    report_status(status);
    printf("Sending - ");
    const char *data = "Hello Helium";
    status = channel.send(data, strlen(data), &result);
    report_status_result(status, result);
}