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,
|
|
|
|
} BleEventType;
|
|
|
|
|
|
|
|
typedef union {
|
|
|
|
uint32_t pin_code;
|
|
|
|
} 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
|