2021-09-13 14:25:37 +03:00
|
|
|
#pragma once
|
|
|
|
|
2021-10-12 19:41:42 +03:00
|
|
|
#include <stdint.h>
|
2021-09-13 14:25:37 +03:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-10-12 19:41:42 +03:00
|
|
|
typedef enum {
|
|
|
|
BleEventTypeConnected,
|
|
|
|
BleEventTypeDisconnected,
|
|
|
|
BleEventTypeStartAdvertising,
|
|
|
|
BleEventTypeStopAdvertising,
|
|
|
|
BleEventTypePinCodeShow,
|
2021-11-21 17:47:54 +03:00
|
|
|
BleEventTypeUpdateMTU,
|
2021-10-12 19:41:42 +03:00
|
|
|
} BleEventType;
|
|
|
|
|
|
|
|
typedef union {
|
|
|
|
uint32_t pin_code;
|
2021-11-21 17:47:54 +03:00
|
|
|
uint16_t max_packet_size;
|
2021-10-12 19:41:42 +03:00
|
|
|
} BleEventData;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
BleEventType type;
|
|
|
|
BleEventData data;
|
|
|
|
} BleEvent;
|
|
|
|
|
|
|
|
typedef void(*BleEventCallback) (BleEvent event, void* context);
|
|
|
|
|
2021-09-13 14:25:37 +03:00
|
|
|
typedef enum {
|
|
|
|
GapStateIdle,
|
|
|
|
GapStateAdvFast,
|
|
|
|
GapStateAdvLowPower,
|
|
|
|
GapStateConnected,
|
|
|
|
} GapState;
|
|
|
|
|
2021-10-12 19:41:42 +03:00
|
|
|
bool gap_init(BleEventCallback on_event_cb, void* context);
|
2021-09-13 14:25:37 +03:00
|
|
|
|
2021-09-15 19:58:32 +03:00
|
|
|
void gap_start_advertising();
|
|
|
|
|
|
|
|
void gap_stop_advertising();
|
|
|
|
|
|
|
|
GapState gap_get_state();
|
2021-09-13 14:25:37 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|