bt.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. /** Disconnect from Central
  29. *
  30. * @param bt Bt instance
  31. */
  32. void bt_disconnect(Bt* bt);
  33. /** Set callback for Bluetooth status change notification
  34. *
  35. * @param bt Bt instance
  36. * @param callback BtStatusChangedCallback instance
  37. * @param context pointer to context
  38. */
  39. void bt_set_status_changed_callback(Bt* bt, BtStatusChangedCallback callback, void* context);
  40. /** Forget bonded devices
  41. * @note Leads to wipe ble key storage and deleting bt.keys
  42. *
  43. * @param bt Bt instance
  44. */
  45. void bt_forget_bonded_devices(Bt* bt);
  46. #ifdef __cplusplus
  47. }
  48. #endif