serial_service.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #define SERIAL_SVC_DATA_LEN_MAX (486)
  5. #define SERIAL_SVC_CHAR_VALUE_LEN_MAX (243)
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. typedef enum {
  10. SerialServiceRpcStatusNotActive = 0UL,
  11. SerialServiceRpcStatusActive = 1UL,
  12. } SerialServiceRpcStatus;
  13. typedef enum {
  14. SerialServiceEventTypeDataReceived,
  15. SerialServiceEventTypeDataSent,
  16. SerialServiceEventTypesBleResetRequest,
  17. } SerialServiceEventType;
  18. typedef struct {
  19. uint8_t* buffer;
  20. uint16_t size;
  21. } SerialServiceData;
  22. typedef struct {
  23. SerialServiceEventType event;
  24. SerialServiceData data;
  25. } SerialServiceEvent;
  26. typedef uint16_t (*SerialServiceEventCallback)(SerialServiceEvent event, void* context);
  27. void serial_svc_start();
  28. void serial_svc_set_callbacks(
  29. uint16_t buff_size,
  30. SerialServiceEventCallback callback,
  31. void* context);
  32. void serial_svc_set_rpc_status(SerialServiceRpcStatus status);
  33. void serial_svc_notify_buffer_is_empty();
  34. void serial_svc_stop();
  35. bool serial_svc_is_started();
  36. bool serial_svc_update_tx(uint8_t* data, uint16_t data_len);
  37. #ifdef __cplusplus
  38. }
  39. #endif