Additional documentation and examples can be found at:
More...
|
static err | ecl::hm10_sync< Uart, Serial >::init () |
| Initializes BT module. More...
|
|
static err | ecl::hm10_sync< Uart, Serial >::set_pin (uint32_t pin) |
| Sets pin code for connecting to the bluetooth device. More...
|
|
static err | ecl::hm10_sync< Uart, Serial >::get_pin (uint32_t &pin) |
| Gets pin code from the device. More...
|
|
static err | ecl::hm10_sync< Uart, Serial >::set_immediate (bool state=true) |
| Sets immediate mode of operation. More...
|
|
static err | ecl::hm10_sync< Uart, Serial >::get_immediate (bool &state) |
| Gets immediate mode state. More...
|
|
static err | ecl::hm10_sync< Uart, Serial >::disconnect () |
| Send disconnect command. More...
|
|
static err | ecl::hm10_sync< Uart, Serial >::data_send (const uint8_t *buf, size_t &sz) |
| Sends data to the module. More...
|
|
static err | ecl::hm10_sync< Uart, Serial >::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...
|
|
Additional documentation and examples can be found at:
◆ init()
template<class Uart , class Serial >
Initializes BT module.
- Returns
- Status of operation.
- Return values
-
◆ set_pin()
template<class Uart , class Serial >
Sets pin code for connecting to the bluetooth device.
Sends AT+PASS command.
- Parameters
-
[in] | pin | PIN to set. Must be in a range of 000000-999999 |
- Returns
- Status of operation.
- Return values
-
◆ get_pin()
template<class Uart , class Serial >
Gets pin code from the device.
Sends AT+PASS? command.
- Warning
- In case of error, content of pin argument is undefined.
- Parameters
-
[out] | pin | PIN set for current device. |
- Return values
-
◆ set_immediate()
template<class Uart , class Serial >
Sets immediate mode of operation.
- Precondition
- Module in the master mode.
Sends AT+IMME command. Immediate mode controls how module behaves after power reset. If immediate mode is set, then module will be listening to commands and will not start any connection attempt.. Otherwise, module will operate immediately, (assuming a previous connection has been applied)
- Warning
- Immediate mode setting is preserved between module power cycles.
- Parameters
-
[in] | state | New state of immediate mode: true - enables immediate mode, false - disables it. |
- Return values
-
◆ get_immediate()
template<class Uart , class Serial >
Gets immediate mode state.
- Precondition
- Module in the master mode.
Sends AT+IMME? command.
- See also
- set_immediate()
- Parameters
-
[out] | state | Current state of immediate mode: true - immediate mode is enabled. false - immediate mode is disabled. |
- Return values
-
◆ disconnect()
template<class Uart , class Serial >
Send disconnect command.
sends AT command. HM-10 will disconnect from any device.
- Return values
-
◆ data_send()
template<class Uart , class Serial >
Sends data to the module.
- Warning
- It is possible that no one has connected to the device yet.
-
Data that is sent to unconnected module will be lost.
Call blocks until all data will be sent.
- Parameters
-
[in] | buf | Buffer to send. |
[in,out] | sz | Size of buffer as input, bytes written as output. |
- Returns
- Status of operation.
- Return values
-
◆ data_recv()
template<class Uart , class Serial >
err ecl::hm10_sync< Uart, Serial >::data_recv |
( |
uint8_t * |
buf, |
|
|
size_t & |
sz, |
|
|
std::chrono::milliseconds |
ms = std::chrono::milliseconds::max() |
|
) |
| |
|
static |
Receives data from the module with given timeout.
- Parameters
-
[out] | buf | Buffer to store incoming data. |
[in,out] | sz | Size of the buffer as input, bytes effectively written as output. |
[in] | ms | Optional. Defines overall time to wait for incoming data. Defaults to infinite time. |
- Returns
- Status of operation.
- Return values
-
err::timedout | Buffer was not filled completely before timeout hit. It is still possible that some data was transferred. Check |
- Parameters
-
sz | to understand how many bytes are there. |
- Return values
-
err::ok | Whole buffer was populated before timeout reached. |