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>
|
|
|
|
|
2021-12-08 11:28:01 +00:00
|
|
|
#include <furi-hal-version.h>
|
|
|
|
|
|
|
|
#define GAP_MAC_ADDR_SIZE (6)
|
|
|
|
|
2021-09-13 11:25:37 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-10-12 16:41:42 +00:00
|
|
|
typedef enum {
|
2022-01-02 22:36:42 +00:00
|
|
|
GapEventTypeConnected,
|
|
|
|
GapEventTypeDisconnected,
|
|
|
|
GapEventTypeStartAdvertising,
|
|
|
|
GapEventTypeStopAdvertising,
|
|
|
|
GapEventTypePinCodeShow,
|
|
|
|
GapEventTypePinCodeVerify,
|
|
|
|
GapEventTypeUpdateMTU,
|
|
|
|
} GapEventType;
|
2021-10-12 16:41:42 +00:00
|
|
|
|
|
|
|
typedef union {
|
|
|
|
uint32_t pin_code;
|
2021-11-21 14:47:54 +00:00
|
|
|
uint16_t max_packet_size;
|
2022-01-02 22:36:42 +00:00
|
|
|
} GapEventData;
|
2021-10-12 16:41:42 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2022-01-02 22:36:42 +00:00
|
|
|
GapEventType type;
|
|
|
|
GapEventData data;
|
|
|
|
} GapEvent;
|
2021-10-12 16:41:42 +00:00
|
|
|
|
2022-01-02 22:36:42 +00:00
|
|
|
typedef bool(*GapEventCallback) (GapEvent event, void* context);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint8_t type;
|
|
|
|
uint8_t mac[6];
|
|
|
|
} GapAddress;
|
|
|
|
|
|
|
|
typedef void(*GapScanCallback) (GapAddress address, void* context);
|
2021-10-12 16:41:42 +00:00
|
|
|
|
2021-09-13 11:25:37 +00:00
|
|
|
typedef enum {
|
2022-01-02 22:36:42 +00:00
|
|
|
GapStateUninitialized,
|
2021-09-13 11:25:37 +00:00
|
|
|
GapStateIdle,
|
2021-12-08 11:28:01 +00:00
|
|
|
GapStateStartingAdv,
|
2021-09-13 11:25:37 +00:00
|
|
|
GapStateAdvFast,
|
|
|
|
GapStateAdvLowPower,
|
|
|
|
GapStateConnected,
|
|
|
|
} GapState;
|
|
|
|
|
2021-12-08 11:28:01 +00:00
|
|
|
typedef enum {
|
2022-01-02 22:36:42 +00:00
|
|
|
GapPairingNone,
|
2021-12-08 11:28:01 +00:00
|
|
|
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;
|
|
|
|
|
2022-01-02 22:36:42 +00:00
|
|
|
bool gap_init(GapConfig* config, GapEventCallback 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
|
|
|
|
2021-12-08 11:28:01 +00:00
|
|
|
void gap_thread_stop();
|
|
|
|
|
2022-01-02 22:36:42 +00:00
|
|
|
void gap_start_scan(GapScanCallback callback, void* context);
|
|
|
|
|
|
|
|
void gap_stop_scan();
|
|
|
|
|
2021-09-13 11:25:37 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|