[FL-1722] BLE custom serial service (#685)
* ble: remove heart rate profile * ble-glue: delete dead code * ble-glue: dis refactoring * ble-glue: add battery service * broken ble_common refactoring * ble-glue: advertise 128 bit service uid * ble-glue: remove dead code * ble: advertise service 16 bit uid depending on flipper color * ble-glue: remove debug * ble: intriduce serial service * ble: serial over ble * bt: serial echo server * bt: serial service process indicate acknowledge * bt: serial service event handler update * bt: refactore battery service * bt: add battery level apdate API * power: update battery level on change * bt: refactore device information service Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
11
applications/bt/bt_service/bt.c
Normal file → Executable file
11
applications/bt/bt_service/bt.c
Normal file → Executable file
@@ -1,4 +1,5 @@
|
||||
#include "bt_i.h"
|
||||
#include "battery_service.h"
|
||||
|
||||
#define BT_SERVICE_TAG "BT"
|
||||
|
||||
@@ -43,6 +44,12 @@ Bt* bt_alloc() {
|
||||
return bt;
|
||||
}
|
||||
|
||||
bool bt_update_battery_level(Bt* bt, uint8_t battery_level) {
|
||||
BtMessage message = {
|
||||
.type = BtMessageTypeUpdateBatteryLevel, .data.battery_level = battery_level};
|
||||
return osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK;
|
||||
}
|
||||
|
||||
int32_t bt_srv() {
|
||||
Bt* bt = bt_alloc();
|
||||
furi_record_create("bt", bt);
|
||||
@@ -68,6 +75,10 @@ int32_t bt_srv() {
|
||||
if(message.type == BtMessageTypeUpdateStatusbar) {
|
||||
// Update statusbar
|
||||
view_port_enabled_set(bt->statusbar_view_port, furi_hal_bt_is_alive());
|
||||
} else if(message.type == BtMessageTypeUpdateBatteryLevel) {
|
||||
if(furi_hal_bt_is_alive()) {
|
||||
battery_svc_update_level(message.data.battery_level);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user