seos_service.h 1.2 KB

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