2020-12-10 17:25:20 +03:00
|
|
|
#pragma once
|
2021-03-11 12:31:07 +03:00
|
|
|
|
2021-09-10 00:11:32 +03:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-03-11 12:31:07 +03:00
|
|
|
typedef struct Bt Bt;
|
2021-09-10 00:11:32 +03:00
|
|
|
|
2021-12-15 20:39:06 +03:00
|
|
|
typedef enum {
|
2022-01-03 01:36:42 +03:00
|
|
|
BtStatusUnavailable,
|
2021-12-15 20:39:06 +03:00
|
|
|
BtStatusOff,
|
|
|
|
BtStatusAdvertising,
|
|
|
|
BtStatusConnected,
|
|
|
|
} BtStatus;
|
|
|
|
|
2021-12-08 14:28:01 +03:00
|
|
|
typedef enum {
|
|
|
|
BtProfileSerial,
|
|
|
|
BtProfileHidKeyboard,
|
|
|
|
} BtProfile;
|
|
|
|
|
2021-12-15 20:39:06 +03:00
|
|
|
typedef void (*BtStatusChangedCallback)(BtStatus status, void* context);
|
|
|
|
|
|
|
|
/** Change BLE Profile
|
2021-12-08 14:28:01 +03:00
|
|
|
* @note Call of this function leads to 2nd core restart
|
|
|
|
*
|
|
|
|
* @param bt Bt instance
|
|
|
|
* @param profile BtProfile
|
|
|
|
*
|
|
|
|
* @return true on success
|
|
|
|
*/
|
|
|
|
bool bt_set_profile(Bt* bt, BtProfile profile);
|
|
|
|
|
2022-06-09 12:07:42 +03:00
|
|
|
/** Disconnect from Central
|
|
|
|
*
|
|
|
|
* @param bt Bt instance
|
|
|
|
*/
|
|
|
|
void bt_disconnect(Bt* bt);
|
|
|
|
|
2021-12-15 20:39:06 +03:00
|
|
|
/** Set callback for Bluetooth status change notification
|
|
|
|
*
|
|
|
|
* @param bt Bt instance
|
|
|
|
* @param callback BtStatusChangedCallback instance
|
|
|
|
* @param context pointer to context
|
|
|
|
*/
|
|
|
|
void bt_set_status_changed_callback(Bt* bt, BtStatusChangedCallback callback, void* context);
|
|
|
|
|
2022-01-21 20:32:03 +03:00
|
|
|
/** Forget bonded devices
|
|
|
|
* @note Leads to wipe ble key storage and deleting bt.keys
|
|
|
|
*
|
|
|
|
* @param bt Bt instance
|
|
|
|
*/
|
|
|
|
void bt_forget_bonded_devices(Bt* bt);
|
|
|
|
|
2021-09-10 00:11:32 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|