unleashed-firmware/targets/f7/ble_glue/services/serial_service.h
hedger ffa3996a5e
[FL-3867] Code formatting update (#3765)
* clang-format: AllowShortEnumsOnASingleLine: false
* clang-format: InsertNewlineAtEOF: true
* clang-format: Standard:        c++20
* clang-format: AlignConsecutiveBitFields
* clang-format: AlignConsecutiveMacros
* clang-format: RemoveParentheses: ReturnStatement
* clang-format: RemoveSemicolon: true
* Restored RemoveParentheses: Leave, retained general changes for it
* formatting: fixed logging TAGs
* Formatting update for dev

Co-authored-by: あく <alleteam@gmail.com>
2024-07-15 13:38:49 +09:00

56 lines
1.2 KiB
C

#pragma once
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Serial service. Implements RPC over BLE, with flow control.
*/
#define BLE_SVC_SERIAL_DATA_LEN_MAX (486)
#define BLE_SVC_SERIAL_CHAR_VALUE_LEN_MAX (243)
typedef enum {
SerialServiceEventTypeDataReceived,
SerialServiceEventTypeDataSent,
SerialServiceEventTypesBleResetRequest,
} SerialServiceEventType;
typedef struct {
uint8_t* buffer;
uint16_t size;
} SerialServiceData;
typedef struct {
SerialServiceEventType event;
SerialServiceData data;
} SerialServiceEvent;
typedef uint16_t (*SerialServiceEventCallback)(SerialServiceEvent event, void* context);
typedef struct BleServiceSerial BleServiceSerial;
BleServiceSerial* ble_svc_serial_start(void);
void ble_svc_serial_stop(BleServiceSerial* service);
void ble_svc_serial_set_callbacks(
BleServiceSerial* service,
uint16_t buff_size,
SerialServiceEventCallback callback,
void* context);
void ble_svc_serial_set_rpc_active(BleServiceSerial* service, bool active);
void ble_svc_serial_notify_buffer_is_empty(BleServiceSerial* service);
bool ble_svc_serial_update_tx(BleServiceSerial* service, uint8_t* data, uint16_t data_len);
#ifdef __cplusplus
}
#endif