diff options
author | gornekich <n.gorbadey@gmail.com> | 2021-09-10 00:11:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-10 00:11:32 +0300 |
commit | 9bce160ca6aff2b139cd230aad2709e192be8117 (patch) | |
tree | 02a8fff67fcea14b7c96f64de943e90d55741112 /applications/bt | |
parent | 710f33981a39d77d94d4313b67a58284eefa4a9d (diff) |
[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>
Diffstat (limited to 'applications/bt')
-rwxr-xr-x[-rw-r--r--] | applications/bt/bt_service/bt.c | 11 | ||||
-rw-r--r-- | applications/bt/bt_service/bt.h | 13 | ||||
-rw-r--r-- | applications/bt/bt_service/bt_i.h | 7 |
3 files changed, 30 insertions, 1 deletions
diff --git a/applications/bt/bt_service/bt.c b/applications/bt/bt_service/bt.c index 785573f2..ba292021 100644..100755 --- a/applications/bt/bt_service/bt.c +++ b/applications/bt/bt_service/bt.c @@ -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; diff --git a/applications/bt/bt_service/bt.h b/applications/bt/bt_service/bt.h index b163fa69..4be69dae 100644 --- a/applications/bt/bt_service/bt.h +++ b/applications/bt/bt_service/bt.h @@ -1,3 +1,16 @@ #pragma once +#include <stdint.h> +#include <stdbool.h> + +#ifdef __cplusplus +extern "C" { +#endif + typedef struct Bt Bt; + +bool bt_update_battery_level(Bt* bt, uint8_t battery_level); + +#ifdef __cplusplus +} +#endif diff --git a/applications/bt/bt_service/bt_i.h b/applications/bt/bt_service/bt_i.h index b498e048..6c0c2bf7 100644 --- a/applications/bt/bt_service/bt_i.h +++ b/applications/bt/bt_service/bt_i.h @@ -13,11 +13,16 @@ typedef enum { BtMessageTypeUpdateStatusbar, + BtMessageTypeUpdateBatteryLevel, } BtMessageType; +typedef union { + uint8_t battery_level; +} BtMessageData; + typedef struct { BtMessageType type; - void* param; + BtMessageData data; } BtMessage; struct Bt { |