bt.h 911 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. BtStatusOff,
  10. BtStatusAdvertising,
  11. BtStatusConnected,
  12. } BtStatus;
  13. typedef enum {
  14. BtProfileSerial,
  15. BtProfileHidKeyboard,
  16. } BtProfile;
  17. typedef void (*BtStatusChangedCallback)(BtStatus status, void* context);
  18. /** Change BLE Profile
  19. * @note Call of this function leads to 2nd core restart
  20. *
  21. * @param bt Bt instance
  22. * @param profile BtProfile
  23. *
  24. * @return true on success
  25. */
  26. bool bt_set_profile(Bt* bt, BtProfile profile);
  27. /** Set callback for Bluetooth status change notification
  28. *
  29. * @param bt Bt instance
  30. * @param callback BtStatusChangedCallback instance
  31. * @param context pointer to context
  32. */
  33. void bt_set_status_changed_callback(Bt* bt, BtStatusChangedCallback callback, void* context);
  34. #ifdef __cplusplus
  35. }
  36. #endif