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,
|
2021-11-21 14:47:54 +00:00
|
|
|
BleEventTypeUpdateMTU,
|
2021-10-12 16:41:42 +00:00
|
|
|
} BleEventType;
|
|
|
|
|
|
|
|
typedef union {
|
|
|
|
uint32_t pin_code;
|
2021-11-21 14:47:54 +00:00
|
|
|
uint16_t max_packet_size;
|
2021-10-12 16:41:42 +00:00
|
|
|
} 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
|