Loading...
Searching...
No Matches
gap.h
1#pragma once
2
3#include <stdint.h>
4#include <stdbool.h>
5
6#include <furi_hal_version.h>
7
8#define GAP_MAC_ADDR_SIZE (6)
9
10/*
11 * GAP helpers - background thread that handles BLE GAP events and advertising.
12 */
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18typedef enum {
19 GapEventTypeConnected,
20 GapEventTypeDisconnected,
21 GapEventTypeStartAdvertising,
22 GapEventTypeStopAdvertising,
23 GapEventTypePinCodeShow,
24 GapEventTypePinCodeVerify,
25 GapEventTypeUpdateMTU,
26 GapEventTypeBeaconStart,
27 GapEventTypeBeaconStop,
28} GapEventType;
29
30typedef union {
31 uint32_t pin_code;
32 uint16_t max_packet_size;
34
35typedef struct {
36 GapEventType type;
37 GapEventData data;
38} GapEvent;
39
40typedef bool (*GapEventCallback)(GapEvent event, void* context);
41
42typedef enum {
43 GapStateUninitialized,
44 GapStateIdle,
45 GapStateStartingAdv,
46 GapStateAdvFast,
47 GapStateAdvLowPower,
48 GapStateConnected,
49} GapState;
50
51typedef enum {
52 GapPairingNone,
53 GapPairingPinCodeShow,
54 GapPairingPinCodeVerifyYesNo,
55} GapPairing;
56
57typedef struct {
58 uint16_t conn_interval;
59 uint16_t slave_latency;
60 uint16_t supervisor_timeout;
62
63typedef struct {
64 uint16_t conn_int_min;
65 uint16_t conn_int_max;
66 uint16_t slave_latency;
67 uint16_t supervisor_timeout;
69
70typedef struct {
71 uint16_t adv_service_uuid;
72 uint16_t appearance_char;
73 bool bonding_mode;
74 GapPairing pairing_method;
75 uint8_t mac_address[GAP_MAC_ADDR_SIZE];
78} GapConfig;
79
80bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context);
81
82void gap_start_advertising(void);
83
84void gap_stop_advertising(void);
85
86GapState gap_get_state(void);
87
88void gap_thread_stop(void);
89
90void gap_emit_ble_beacon_status_event(bool active);
91
92#ifdef __cplusplus
93}
94#endif
Version HAL API.
#define FURI_HAL_VERSION_DEVICE_NAME_LENGTH
BLE symbol + "Flipper " + name.
Definition furi_hal_version.h:20
Definition gap.h:70
Definition gap.h:57
Definition gap.h:63
Definition gap.h:35
Definition gap.h:30