ble_serial.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * This code is based on the Willy-JL's (https://github.com/Willy-JL) BLE fix.
  3. *
  4. * Thank you to Willy-JL for providing this code and making it available under the https://github.com/Flipper-XFW/Xtreme-Apps repository.
  5. * Your contribution has been invaluable for this project.
  6. *
  7. * Based on <targets/f7/ble_glue/profiles/serial_profile.h>
  8. * and on <lib/ble_profile/extra_profiles/hid_profile.h>
  9. */
  10. #pragma once
  11. #include <furi_ble/profile_interface.h>
  12. #include <services/serial_service.h>
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. /**
  17. * Optional arguments to pass along with profile template as
  18. * FuriHalBleProfileParams for tuning profile behavior
  19. **/
  20. typedef struct {
  21. const char* device_name_prefix; /**< Prefix for device name. Length must be less than 8 */
  22. uint16_t mac_xor; /**< XOR mask for device address, for uniqueness */
  23. } BleProfileSerialParams;
  24. #define BLE_PROFILE_SERIAL_PACKET_SIZE_MAX BLE_SVC_SERIAL_DATA_LEN_MAX
  25. /** Serial service callback type */
  26. typedef SerialServiceEventCallback FuriHalBtSerialCallback;
  27. /** Serial profile descriptor */
  28. extern const FuriHalBleProfileTemplate* const ble_profile_serial;
  29. /** Send data through BLE
  30. *
  31. * @param profile Profile instance
  32. * @param data data buffer
  33. * @param size data buffer size
  34. *
  35. * @return true on success
  36. */
  37. bool ble_profile_serial_tx(FuriHalBleProfileBase* profile, uint8_t* data, uint16_t size);
  38. /** Set Serial service events callback
  39. *
  40. * @param profile Profile instance
  41. * @param buffer_size Applicaition buffer size
  42. * @param calback FuriHalBtSerialCallback instance
  43. * @param context pointer to context
  44. */
  45. void ble_profile_serial_set_event_callback(
  46. FuriHalBleProfileBase* profile,
  47. uint16_t buff_size,
  48. FuriHalBtSerialCallback callback,
  49. void* context);
  50. #ifdef __cplusplus
  51. }
  52. #endif