bt.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. typedef struct Bt Bt;
  8. typedef enum {
  9. BtStatusUnavailable,
  10. BtStatusOff,
  11. BtStatusAdvertising,
  12. BtStatusConnected,
  13. } BtStatus;
  14. typedef enum {
  15. BtProfileSerial,
  16. BtProfileHidKeyboard,
  17. } BtProfile;
  18. typedef void (*BtStatusChangedCallback)(BtStatus status, void* context);
  19. /** Change BLE Profile
  20. * @note Call of this function leads to 2nd core restart
  21. *
  22. * @param bt Bt instance
  23. * @param profile BtProfile
  24. *
  25. * @return true on success
  26. */
  27. bool bt_set_profile(Bt* bt, BtProfile profile);
  28. /** Set callback for Bluetooth status change notification
  29. *
  30. * @param bt Bt instance
  31. * @param callback BtStatusChangedCallback instance
  32. * @param context pointer to context
  33. */
  34. void bt_set_status_changed_callback(Bt* bt, BtStatusChangedCallback callback, void* context);
  35. /** Forget bonded devices
  36. * @note Leads to wipe ble key storage and deleting bt.keys
  37. *
  38. * @param bt Bt instance
  39. */
  40. void bt_forget_bonded_devices(Bt* bt);
  41. #ifdef __cplusplus
  42. }
  43. #endif