bt.h 1.2 KB

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