An mbed wrapper around the helium-client to communicate with the Helium Atom

Helium for ARM mbed

This code repository exposes an mbed library for the Helium Atom module. The Helium Atom makes it easy to securely connect IoT devices and applications to back-end IoT services.

Getting Started

See a getting started guide on the Helium site.

Supported Boards

The Helium mbed client should work with any mbed board with an available serial port.

Example Setup

Example applications can be found in the mbed Helium team.

Getting Help

If you have any questions or ideas about how to use this code - or any part of Helium - head over to the Helium Community Slack. We're standing by to help.

Contributing

Want to contribute to helium-mbed? That's awesome!

Please see CONTRIBUTING.md in this repository for details.

Revision:
17:f38730193da3
Parent:
14:af7682f4e610
Child:
18:c735140666d1
--- a/src/Helium.h	Thu Jul 06 13:31:43 2017 -0700
+++ b/src/Helium.h	Fri Jul 07 21:34:49 2017 -0700
@@ -6,9 +6,9 @@
 #ifndef HELIUM_H
 #define HELIUM_H
 
-#include "mbed.h"
 #include "BufferedSerial.h"
 #include "helium-client/helium-client.h"
+#include "mbed.h"
 
 /**
  * \class Helium
@@ -67,18 +67,8 @@
      *
      * @see Helium#connect()
      */
-    int connect(struct connection * connection, uint32_t retries);
-
-    /** Short form connect to the Helium Network.
-     *
-     * This is the recommended connect call. It assumes no connection
-     * state and tries to connect for up to a 5 seconds.
-     *
-     */
-    int connect()
-    {
-        return connect(NULL, HELIUM_POLL_RETRIES_5S);
-    }
+    int connect(struct connection * connection = NULL,
+                uint32_t            retries    = HELIUM_POLL_RETRIES_5S);
 
     /** Check if the Atom is connected to the network
      *
@@ -99,22 +89,12 @@
      *
      * @see Helium::sleep() for the easy version.
      */
-    int sleep(struct connection * connection);
+    int sleep(struct connection * connection = NULL);
 
-    /** Disconnect the Atom and put it to sleep.
-     *
-     * This is the convenience version of sleep. A subsequent connect
-     * call will go through a normal connect cycle.
-     *
-     */
-    int  sleep()
-    {
-        return sleep(NULL);
-    }
 
   private:
     struct helium_ctx _ctx;
-    BufferedSerial serial;
+    BufferedSerial    serial;
 
     friend class Channel;
 };
@@ -208,10 +188,35 @@
      * that the token represents.
      *
      * @param token The token to check for
-     * @param result The out parameter for the result of the given request token
+     * @param result[out] The result of the given request token
      * @param retries The number of times to retry
      */
-    int poll(uint16_t token, int8_t * result, uint32_t retries);
+    int poll_result(uint16_t token,
+                    int8_t * result,
+                    uint32_t retries = HELIUM_POLL_RETRIES_5S);
+
+    /** Poll for data on a channel.
+     *
+     * This polls the Helium Atom for the given number of retries for
+     * any data on a given `channel`.
+     *
+     * If successful the result will be helium_status_OK and the given
+     * `data` buffer will be filled with the received data. The `used`
+     * out parameter will be set to the number of bytes read. Note
+     * that the maximum number of bytes that can be sent is set by
+     * HELIUM_MAX_DATA_SIZE.
+     *
+     * @param channel_id The channel to check for
+     * @param[out] data The data buffer to fill with received data
+     * @param len The available length of the data buffer
+     * @param[out] used On success the number of bytes used up in data
+     * @param retries The number of times to retry
+     */
+    int poll_data(uint16_t channel_id,
+                  void *   data,
+                  size_t   len,
+                  size_t * used,
+                  uint32_t retries = HELIUM_POLL_RETRIES_5S);
 
   private:
     Helium * _helium;