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.
src/BufferedSerial.h
- Committer:
- Marc Nijdam
- Date:
- 2017-09-05
- Revision:
- 23:cc2c1d1ed159
- Parent:
- 16:21b6f13fee79
File content as of revision 23:cc2c1d1ed159:
/** * \copyright Copyright 2017, Helium Systems, Inc. * All Rights Reserved. See LICENSE.txt for license information */ #include "mbed.h" #include "RingBuffer.h" #ifndef BUFFEREDSERIAL_H #define BUFFEREDSERIAL_H /** * \class BufferedSerial * * \brief Implements a buffered serial port * * This is a simple buffered serial port to work around `readable` * issues on a number of mbed implementations. Receiving on the serial * port is buffered through an interrupt handler. * * Note that writing is not buffered at this time since writing to the * serial port at speed had not been an issue so far. */ class BufferedSerial : public RawSerial { public: /** Crete a buffered serial port. * * @param tx Serial port tx pin to use * @param rx Serial port rx pin to use * @param baud The baud rate to use. Defaults to the default for the current * board */ BufferedSerial(PinName tx, PinName rx, int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE); /** Destructor */ ~BufferedSerial(); /** Sets the baud rate for the serial port * * @param baud The baud rate to set on the serial port */ void baud(int baud); /** Get a byte from the serial port buffer. * * @return a buffered byte or -1 if no bytes are available */ int getc(); /** Write a byte to the serial port * * @param ch The byte to write * @return the byte that was written */ int putc(int ch); /** Check if there are bytes to read. * * @return 1 if bytes are available, 0 otherwise */ int readable(); private: RingBuffer<uint8_t, 16> _rx_buffer; void _rx_interrupt(); }; #endif