mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-12 13:27:18 +03:00
ffa3996a5e
* 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>
56 lines
1.2 KiB
C
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
|