M module-bluetooth/README.md => module-bluetooth/README.md +3 -3
@@ 18,6 18,9 @@ It's meant to provide interface layer for service-bluetooth like that:

<img src="./flowchart.svg">
+## Table of content
+- [Bluetooth on/off operation](./doc/bt_on_off.md)
+
# Proposal of Bluetooth settings data flow
The Bluetooth settings related data flow is directed by three main entities:
@@ 46,6 49,3 @@ Flowchart below is an example of scenario, when user opens *BluetoothWindow*, an

-# Bluetooth on/off state machine diagram
-To be able to handle all events during start up and shutting down of the Bluetooth module the following state machine has been implemented:
-
A module-bluetooth/doc/bt_on_off.md => module-bluetooth/doc/bt_on_off.md +37 -0
@@ 0,0 1,37 @@
+# Bluetooth on-off operation
+This document aims to describe the basics of the Bluetooth module power management.
+
+## Turning on the Bluetooth module
+The Bluetooth module (hereinafter referred to as BT module) is connected to the processor via UART.
+Additionally, a reset pin is available to put the BT module into a reset state, which is used in the "power on" procedure.
+UART data transfers have been made using DMA, which speeds up the data rate. To be able to properly init the BT module,
+the following steps have to be taken:
+
+- Enable and configure UART interface
+- Enable and configure DMA channels
+- Properly init the BT module
+
+Enabling and configuring UART and related DMA channels is done in the BSP (board support package) module,
+therefore there is no need to describe it here. Those BSP functions are encapsulated and used by the Bluetooth stack library.
+
+### Power on procedure
+- send `message::bluetooth::SetStatus` message with `BluetoothStatus::State::On` value
+- wait for settings change: `bluetooth::Settings::State` set to `BluetoothStatus::State::On`
+
+#### A low-level flow of what's inside
+After the `BluetoothWorker` receives `bluetooth::Command::PowerOn` (sent by `ServiceBluetooth` after receiving the state change message),
+the state machine executes driver's `init` method. After the init is done, the Bluetooth stack is prepared to be run by the `run` method of the `Driver` class -
+it's done as the next step of the init procedure. When the Bluetooth stack has been initiated, the settings holder updates the BT state in the settings.
+
+## Turning off the Bluetooth module
+Turning off the BT module is basically reversed turning on - after sending the proper message, the Bluetooth driver
+turns off the Bluetooth stack. When the Bluetooth stack is turned off, the UART with DMA channels is deinitialized and BT module is put
+to the reset state.
+
+### Power off procedure
+- send `message::bluetooth::SetStatus` message with `BluetoothStatus::State::Off` value
+- wait for settings change: `bluetooth::Settings::State` set to `BluetoothStatus::State::Off`
+
+## Bluetooth on/off state machine diagram
+To be able to handle all events during start up and shutting down of the Bluetooth module the following state machine has been implemented:
+
R module-bluetooth/bt_on_off_state_diagram.puml => module-bluetooth/doc/bt_on_off_state_diagram.puml +0 -0
R module-bluetooth/bt_on_off_state_diagram.svg => module-bluetooth/doc/bt_on_off_state_diagram.svg +0 -0