Loading...
Searching...
No Matches
serial_service.h
1#pragma once
2
3#include <stdint.h>
4#include <stdbool.h>
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
10/*
11 * Serial service. Implements RPC over BLE, with flow control.
12 */
13
14#define BLE_SVC_SERIAL_DATA_LEN_MAX (486)
15#define BLE_SVC_SERIAL_CHAR_VALUE_LEN_MAX (243)
16
17typedef enum {
18 SerialServiceEventTypeDataReceived,
19 SerialServiceEventTypeDataSent,
20 SerialServiceEventTypesBleResetRequest,
21} SerialServiceEventType;
22
23typedef struct {
24 uint8_t* buffer;
25 uint16_t size;
27
28typedef struct {
29 SerialServiceEventType event;
32
33typedef uint16_t (*SerialServiceEventCallback)(SerialServiceEvent event, void* context);
34
36
37BleServiceSerial* ble_svc_serial_start(void);
38
39void ble_svc_serial_stop(BleServiceSerial* service);
40
41void ble_svc_serial_set_callbacks(
42 BleServiceSerial* service,
43 uint16_t buff_size,
44 SerialServiceEventCallback callback,
45 void* context);
46
47void ble_svc_serial_set_rpc_active(BleServiceSerial* service, bool active);
48
49void ble_svc_serial_notify_buffer_is_empty(BleServiceSerial* service);
50
51bool ble_svc_serial_update_tx(BleServiceSerial* service, uint8_t* data, uint16_t data_len);
52
53#ifdef __cplusplus
54}
55#endif
Definition serial_service.c:64
Definition serial_service.h:23
Definition serial_service.h:28