2021-09-13 11:25:37 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-10-12 16:41:42 +00:00
|
|
|
#include <stdint.h>
|
2021-09-13 11:25:37 +00:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-10-12 16:41:42 +00: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 11:25:37 +00:00
|
|
|
typedef enum {
|
|
|
|
GapStateIdle,
|
|
|
|
GapStateAdvFast,
|
|
|
|
GapStateAdvLowPower,
|
|
|
|
GapStateConnected,
|
|
|
|
} GapState;
|
|
|
|
|
2021-10-12 16:41:42 +00:00
|
|
|
bool gap_init(BleEventCallback on_event_cb, void* context);
|
2021-09-13 11:25:37 +00:00
|
|
|
|
2021-09-15 16:58:32 +00:00
|
|
|
void gap_start_advertising();
|
|
|
|
|
|
|
|
void gap_stop_advertising();
|
|
|
|
|
|
|
|
GapState gap_get_state();
|
2021-09-13 11:25:37 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|