theCore C++ embedded framework
ecl::hm10_sync< Uart, Serial > Class Template Reference

HM10 synchronous BT driver. More...

#include </home/travis/build/forGGe/theCore/dev/hm10/export/dev/hm10.hpp>

Static Public Member Functions

static constexpr auto cmd_timeout ()
 Defines internal timeout in milliseconds during which module has to respond to commands. More...
 
static constexpr auto retry_timeout ()
 Defines internal timeout in milliseconds between retries to send or receive data. More...
 
static err init ()
 Initializes BT module. More...
 
static err set_pin (uint32_t pin)
 Sets pin code for connecting to the bluetooth device. More...
 
static err get_pin (uint32_t &pin)
 Gets pin code from the device. More...
 
static err set_immediate (bool state=true)
 Sets immediate mode of operation. More...
 
static err get_immediate (bool &state)
 Gets immediate mode state. More...
 
static err disconnect ()
 Send disconnect command. More...
 
static err start ()
 Manually Starts communication. More...
 
static err data_send (const uint8_t *buf, size_t &sz)
 Sends data to the module. More...
 
static err data_recv (uint8_t *buf, size_t &sz, std::chrono::milliseconds ms=std::chrono::milliseconds::max())
 Receives data from the module with given timeout. More...
 

Detailed Description

template<class Uart, class Serial = ecl::serial<Uart>>
class ecl::hm10_sync< Uart, Serial >

HM10 synchronous BT driver.

This HM10 driver is simple and low-functional API to send and receive data from BT module. It lacks connection status detection and does not escape potential AT commands found in payload (yet). No flow control is used whatsoever. External protocol is required to control whether other end is ready to receive or send a data. Great advantage of this particular driver is its API. Straitforward and blocking it can be used for simple demo implementations.

Note
Driver is_not a thread safe. Using driver routine from ISR context will lead to undefined behaviour.
Template Parameters
Uartinstance of the UART platform driver.
Serialinstance attached to the UART bus to work with. Provided for mock injection in unit tests.

Member Function Documentation

◆ cmd_timeout()

template<class Uart , class Serial = ecl::serial<Uart>>
static constexpr auto ecl::hm10_sync< Uart, Serial >::cmd_timeout ( )
inlinestatic

Defines internal timeout in milliseconds during which module has to respond to commands.

◆ retry_timeout()

template<class Uart , class Serial = ecl::serial<Uart>>
static constexpr auto ecl::hm10_sync< Uart, Serial >::retry_timeout ( )
inlinestatic

Defines internal timeout in milliseconds between retries to send or receive data.

◆ start()

template<class Uart , class Serial = ecl::serial<Uart>>
static err ecl::hm10_sync< Uart, Serial >::start ( )
static

Manually Starts communication.

Precondition
Module is in immediate mode and acts like a master.
See also
set_immediate()

Sends AT+START command

Return values
err::invalModule responded with invalid data.
err::timedoutModule did not respond at all.
err::okModule now can send and receive data.

The documentation for this class was generated from the following file: