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.
Diff: main.cpp
- Revision:
- 1:a843f3d9d31c
- Parent:
- 0:9c0bcd840b37
- Child:
- 2:bfe503bcf0b8
--- a/main.cpp Thu Jun 29 13:05:16 2017 -0700
+++ b/main.cpp Wed Jul 05 09:36:16 2017 -0700
@@ -5,16 +5,14 @@
#include "mbed.h"
#include "Helium.h"
-
-Helium helium(PTC17, PTC16);
-Channel channel(&helium);
+#include <inttypes.h>
void report_status(int status)
{
if (helium_status_OK == status) {
printf("Succeeded\n");
} else {
- printf("Failed\n");
+ printf("Failed (status %d)\n", status);
}
}
@@ -27,21 +25,42 @@
printf("Failed - %d", result);
}
} else {
- printf("Failed\n");
+ printf("Failed (status %d)\n", status);
}
}
+#if defined(TARGET_K64F)
+Helium helium(PTC4, PTC3); // TX:D9, RX:D7
+#else
+#error Please define helium with serial tx/rx
+#endif
+
+Channel channel(&helium);
+
int main()
{
- int status = helium.connect();
+ 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(NULL, HELIUM_POLL_RETRIES_5S * 10);
+ 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);
}