seos_service.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /*
  8. * Seos service. Implements RPC over BLE, with flow control.
  9. */
  10. #define BLE_SVC_SEOS_DATA_LEN_MAX (486)
  11. #define BLE_SVC_SEOS_CHAR_VALUE_LEN_MAX (243)
  12. typedef enum {
  13. SeosServiceEventTypeDataReceived,
  14. SeosServiceEventTypeDataSent,
  15. SeosServiceEventTypesBleResetRequest,
  16. } SeosServiceEventType;
  17. typedef struct {
  18. uint8_t* buffer;
  19. uint16_t size;
  20. } SeosServiceData;
  21. typedef struct {
  22. SeosServiceEventType event;
  23. SeosServiceData data;
  24. } SeosServiceEvent;
  25. typedef uint16_t (*SeosServiceEventCallback)(SeosServiceEvent event, void* context);
  26. typedef struct BleServiceSeos BleServiceSeos;
  27. BleServiceSeos* ble_svc_seos_start(void);
  28. void ble_svc_seos_stop(BleServiceSeos* service);
  29. void ble_svc_seos_set_callbacks(
  30. BleServiceSeos* service,
  31. uint16_t buff_size,
  32. SeosServiceEventCallback callback,
  33. void* context);
  34. void ble_svc_seos_set_rpc_active(BleServiceSeos* service, bool active);
  35. void ble_svc_seos_notify_buffer_is_empty(BleServiceSeos* service);
  36. bool ble_svc_seos_update_tx(BleServiceSeos* service, uint8_t* data, uint16_t data_len);
  37. #ifdef __cplusplus
  38. }
  39. #endif