[FL-1721] Bluetooth refactoring (#747)

* ble-glue: add on connect \ disconnect, on send \ received callbacks
* bt: rework service with furi-hal-bt and callbacks
* bt: update battery level on connect
* ble-glue: set one callback with parameters
* bt: rework callbacks, remove unused API
* ble-glue: remove dead code
* furi-hal-bt: add documentation
* ble-glue: apply changes for f7 target
* bt: rename RpcInstance -> Rpc
* ble: add disconnection reason
* ble: don't open bt record from GAP
* bt: fix RPC session close
* Assets: separate targets for icons and protobuf

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
gornekich
2021-10-12 19:41:42 +03:00
committed by GitHub
parent 8c5813ef9b
commit 943fb1bced
16 changed files with 335 additions and 229 deletions

View File

@@ -7,6 +7,10 @@
#include <m-string.h>
#include <stdbool.h>
#include <gap.h>
#include <serial_service.h>
#define FURI_HAL_BT_PACKET_SIZE_MAX SERIAL_SVC_DATA_LEN_MAX
#ifdef __cplusplus
extern "C" {
@@ -17,10 +21,10 @@ extern "C" {
void furi_hal_bt_init();
/** Start BLE app
*
* @return true if app inited
*/
bool furi_hal_bt_init_app();
* @param event_cb - BleEventCallback instance
* @param context - pointer to context
*/
bool furi_hal_bt_init_app(BleEventCallback event_cb, void* context);
/** Start advertising
*/
@@ -48,10 +52,20 @@ void furi_hal_bt_dump_state(string_t buffer);
*/
bool furi_hal_bt_is_alive();
/** Wait for Core2 startup
*
* @return true if success, otherwise timeouted
/** Set data event callbacks
* @param on_received_cb - SerialSvcDataReceivedCallback instance
* @param on_sent_cb - SerialSvcDataSentCallback instance
* @param context - pointer to context
*/
void furi_hal_bt_set_data_event_callbacks(SerialSvcDataReceivedCallback on_received_cb, SerialSvcDataSentCallback on_sent_cb, void* context);
/** Send data through BLE
* @param data - data buffer
* @param size - data buffer size
*/
bool furi_hal_bt_tx(uint8_t* data, uint16_t size);
/** Wait for Core2 startup */
bool furi_hal_bt_wait_startup();
/** Lock shared access to flash controller