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.
Diff: src/Helium.cpp
- Revision:
- 17:f38730193da3
- Parent:
- 14:af7682f4e610
- Child:
- 18:c735140666d1
--- a/src/Helium.cpp Thu Jul 06 13:31:43 2017 -0700 +++ b/src/Helium.cpp Fri Jul 07 21:34:49 2017 -0700 @@ -12,8 +12,8 @@ helium_serial_getc(void * param, uint8_t * ch) { BufferedSerial * serial = (BufferedSerial *)param; - int val = serial->getc(); - *ch = val; + int val = serial->getc(); + *ch = val; return val >= 0; } @@ -32,7 +32,8 @@ wait_us(us); } -Helium::Helium(PinName tx, PinName rx) : serial(tx, rx, 9600) +Helium::Helium(PinName tx, PinName rx) + : serial(tx, rx, 9600) { helium_init(&_ctx, (void *)&serial); } @@ -116,13 +117,12 @@ _channel_id = -1; if (helium_status_OK == status) { - status = poll(token, &_channel_id, HELIUM_POLL_RETRIES_5S); + status = poll_result(token, &_channel_id); } if (result) { - *result = - status == helium_status_OK && _channel_id > 0 ? 0 : _channel_id; + *result = status == helium_status_OK && _channel_id > 0 ? 0 : _channel_id; } return status; @@ -142,13 +142,28 @@ int status = send(data, len, &token); if (helium_status_OK == status) { - status = poll(token, result, HELIUM_POLL_RETRIES_5S); + status = poll_result(token, result); } return status; } int -Channel::poll(uint16_t token, int8_t * result, uint32_t retries) +Channel::poll_result(uint16_t token, int8_t * result, uint32_t retries) { return helium_channel_poll_result(&_helium->_ctx, token, result, retries); } + +int +Channel::poll_data(uint16_t channel_id, + void * data, + size_t len, + size_t * used, + uint32_t retries) +{ + return helium_channel_poll_data(&_helium->_ctx, + channel_id, + data, + len, + used, + retries); +}