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.

Committer:
Marc Nijdam
Date:
Tue Sep 05 13:56:03 2017 -0700
Revision:
23:cc2c1d1ed159
Parent:
14:af7682f4e610
Add configuration API support

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Marc Nijdam 14:af7682f4e610 1 /*
Marc Nijdam 14:af7682f4e610 2 * Copyright 2017, Helium Systems, Inc.
Marc Nijdam 14:af7682f4e610 3 * All Rights Reserved. See LICENSE.txt for license information
Marc Nijdam 14:af7682f4e610 4 */
Marc Nijdam 14:af7682f4e610 5
Marc Nijdam 14:af7682f4e610 6 #include "BufferedSerial.h"
Marc Nijdam 14:af7682f4e610 7
Marc Nijdam 14:af7682f4e610 8 BufferedSerial:: BufferedSerial(PinName tx,
Marc Nijdam 14:af7682f4e610 9 PinName rx,
Marc Nijdam 14:af7682f4e610 10 int baud)
Marc Nijdam 14:af7682f4e610 11 : RawSerial(tx, rx, baud)
Marc Nijdam 14:af7682f4e610 12 {
Marc Nijdam 14:af7682f4e610 13 this->attach(callback(this, &BufferedSerial::_rx_interrupt),
Marc Nijdam 14:af7682f4e610 14 Serial::RxIrq);
Marc Nijdam 14:af7682f4e610 15 }
Marc Nijdam 14:af7682f4e610 16
Marc Nijdam 14:af7682f4e610 17
Marc Nijdam 14:af7682f4e610 18 BufferedSerial::~BufferedSerial()
Marc Nijdam 14:af7682f4e610 19 {
Marc Nijdam 14:af7682f4e610 20 this->attach(NULL, Serial::RxIrq);
Marc Nijdam 14:af7682f4e610 21 }
Marc Nijdam 14:af7682f4e610 22
Marc Nijdam 14:af7682f4e610 23 void BufferedSerial::_rx_interrupt()
Marc Nijdam 14:af7682f4e610 24 {
Marc Nijdam 14:af7682f4e610 25 _rx_buffer.push(serial_getc(&_serial));
Marc Nijdam 14:af7682f4e610 26 }
Marc Nijdam 14:af7682f4e610 27
Marc Nijdam 14:af7682f4e610 28
Marc Nijdam 14:af7682f4e610 29 void BufferedSerial::baud(int baud)
Marc Nijdam 14:af7682f4e610 30 {
Marc Nijdam 14:af7682f4e610 31 serial_baud(&_serial, baud);
Marc Nijdam 14:af7682f4e610 32 }
Marc Nijdam 14:af7682f4e610 33
Marc Nijdam 14:af7682f4e610 34 int BufferedSerial::getc()
Marc Nijdam 14:af7682f4e610 35 {
Marc Nijdam 14:af7682f4e610 36 uint8_t ch;
Marc Nijdam 14:af7682f4e610 37 if (_rx_buffer.pop(&ch))
Marc Nijdam 14:af7682f4e610 38 {
Marc Nijdam 14:af7682f4e610 39 return ch;
Marc Nijdam 14:af7682f4e610 40 }
Marc Nijdam 14:af7682f4e610 41 return -1;
Marc Nijdam 14:af7682f4e610 42 }
Marc Nijdam 14:af7682f4e610 43
Marc Nijdam 14:af7682f4e610 44 int BufferedSerial::putc(int ch)
Marc Nijdam 14:af7682f4e610 45 {
Marc Nijdam 14:af7682f4e610 46 serial_putc(&_serial, ch);
Marc Nijdam 14:af7682f4e610 47 return ch;
Marc Nijdam 14:af7682f4e610 48 }
Marc Nijdam 14:af7682f4e610 49
Marc Nijdam 14:af7682f4e610 50
Marc Nijdam 14:af7682f4e610 51 int BufferedSerial::readable()
Marc Nijdam 14:af7682f4e610 52 {
Marc Nijdam 14:af7682f4e610 53 return _rx_buffer.available() > 0;
Marc Nijdam 14:af7682f4e610 54 }