ble_serial.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. #pragma once
  8. #include <furi_ble/profile_interface.h>
  9. #include <services/serial_service.h>
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. /**
  14. * Optional arguments to pass along with profile template as
  15. * FuriHalBleProfileParams for tuning profile behavior
  16. **/
  17. typedef struct {
  18. const char* device_name_prefix; /**< Prefix for device name. Length must be less than 8 */
  19. uint16_t mac_xor; /**< XOR mask for device address, for uniqueness */
  20. } BleProfileSerialParams;
  21. #define BLE_PROFILE_SERIAL_PACKET_SIZE_MAX BLE_SVC_SERIAL_DATA_LEN_MAX
  22. /** Serial service callback type */
  23. typedef SerialServiceEventCallback FuriHalBtSerialCallback;
  24. /** Serial profile descriptor */
  25. extern const FuriHalBleProfileTemplate* ble_profile_serial;
  26. /** Send data through BLE
  27. *
  28. * @param profile Profile instance
  29. * @param data data buffer
  30. * @param size data buffer size
  31. *
  32. * @return true on success
  33. */
  34. bool ble_profile_serial_tx(FuriHalBleProfileBase* profile, uint8_t* data, uint16_t size);
  35. /** Set Serial service events callback
  36. *
  37. * @param profile Profile instance
  38. * @param buffer_size Applicaition buffer size
  39. * @param calback FuriHalBtSerialCallback instance
  40. * @param context pointer to context
  41. */
  42. void ble_profile_serial_set_event_callback(
  43. FuriHalBleProfileBase* profile,
  44. uint16_t buff_size,
  45. FuriHalBtSerialCallback callback,
  46. void* context);
  47. #ifdef __cplusplus
  48. }
  49. #endif