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>
|
|
|
|
|
2021-12-08 14:28:01 +03:00
|
|
|
#include <furi-hal-version.h>
|
|
|
|
|
|
|
|
#define GAP_MAC_ADDR_SIZE (6)
|
|
|
|
|
2021-09-13 14:25:37 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-10-12 19:41:42 +03:00
|
|
|
typedef enum {
|
|
|
|
BleEventTypeConnected,
|
|
|
|
BleEventTypeDisconnected,
|
|
|
|
BleEventTypeStartAdvertising,
|
|
|
|
BleEventTypeStopAdvertising,
|
|
|
|
BleEventTypePinCodeShow,
|
2021-12-08 14:28:01 +03:00
|
|
|
BleEventTypePinCodeVerify,
|
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;
|
|
|
|
|
2021-12-08 14:28:01 +03:00
|
|
|
typedef bool(*BleEventCallback) (BleEvent event, void* context);
|
2021-10-12 19:41:42 +03:00
|
|
|
|
2021-09-13 14:25:37 +03:00
|
|
|
typedef enum {
|
|
|
|
GapStateIdle,
|
2021-12-08 14:28:01 +03:00
|
|
|
GapStateStartingAdv,
|
2021-09-13 14:25:37 +03:00
|
|
|
GapStateAdvFast,
|
|
|
|
GapStateAdvLowPower,
|
|
|
|
GapStateConnected,
|
|
|
|
} GapState;
|
|
|
|
|
2021-12-08 14:28:01 +03:00
|
|
|
typedef enum {
|
|
|
|
GapPairingPinCodeShow,
|
|
|
|
GapPairingPinCodeVerifyYesNo,
|
|
|
|
} GapPairing;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint16_t adv_service_uuid;
|
|
|
|
uint16_t appearance_char;
|
|
|
|
bool bonding_mode;
|
|
|
|
GapPairing pairing_method;
|
|
|
|
uint8_t mac_address[GAP_MAC_ADDR_SIZE];
|
|
|
|
char adv_name[FURI_HAL_VERSION_DEVICE_NAME_LENGTH];
|
|
|
|
} GapConfig;
|
|
|
|
|
|
|
|
bool gap_init(GapConfig* config, 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
|
|
|
|
2021-12-08 14:28:01 +03:00
|
|
|
void gap_thread_stop();
|
|
|
|
|
2021-09-13 14:25:37 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|