Example

Loading...
Searching...
No Matches
CDevice.h
Go to the documentation of this file.
1// Copyright. 2019 - 2024 PSBD. All rights reserved.
2
3#pragma once
4
5#include "Capsule/CDefinesPrivate.h"
6#include "Capsule/CDeviceLocator.h"
7#include "Capsule/CEEGTimedData.h"
8#include "Capsule/CMEMSTimedData.h"
9#include "Capsule/CPPGTimedData.h"
10#include "Capsule/CResistances.h"
11
12#include <stdbool.h>
13
14#ifdef __cplusplus
15 extern "C" {
16#endif
17
23 CLC_CLASS_WN(DevicePrivate, clCDevice);
24
25 typedef enum clCDeviceMode {
26 clC_DM_Resistance,
27 clC_DM_Idle,
28 clC_DM_PowerDown,
29 clC_DM_Signal,
30 clC_DM_StartMEMS,
31 clC_DM_StopMEMS,
32 clC_DM_StartPPG,
33 clC_DM_StopPPG,
34 clC_DM_SignalAndResist
35} clCDeviceMode;
36
40 typedef enum clCDeviceConnectionState {
41 clC_SE_Disconnected = 0,
42 clC_SE_Connected = 1,
43 clC_SE_UnsupportedConnection = 2,
44} clCDeviceConnectionState;
45
53 CL_DLL clCDevice clCDeviceLocator_CreateDevice(clCDeviceLocator locator, const char* deviceID) NOEXCEPT;
54
58 CLC_STRUCT(clCDeviceDelegate);
59 typedef void (*clCDeviceHandler)(clCDevice);
60 CL_DLL void clCDeviceDelegate_Set(clCDeviceDelegate delegate,
61 clCDeviceHandler callback) NOEXCEPT;
62
66 CLC_STRUCT(clCDeviceDelegateResistances);
67 typedef void (*clCDeviceHandlerResistances)(clCDevice, clCResistances);
68 CL_DLL void
69 clCDeviceDelegateResistances_Set(clCDeviceDelegateResistances delegate,
70 clCDeviceHandlerResistances callback) NOEXCEPT;
74 CLC_STRUCT(clCDeviceDelegateMEMSData);
75 typedef void (*clCDeviceHandlerMEMSData)(clCDevice, clCMEMSTimedData);
76 CL_DLL void
77 clCDeviceDelegateMEMSData_Set(clCDeviceDelegateMEMSData delegate,
78 clCDeviceHandlerMEMSData callback) NOEXCEPT;
82 CLC_STRUCT(clCDeviceDelegatePPGData);
83 typedef void (*clCDeviceHandlerPPGData)(clCDevice, clCPPGTimedData);
84 CL_DLL void
85 clCDeviceDelegatePPGData_Set(clCDeviceDelegatePPGData delegate,
86 clCDeviceHandlerPPGData callback) NOEXCEPT;
90 CLC_STRUCT(clCDeviceDelegateEEGData);
91 typedef void (*clCDeviceHandlerEEGData)(clCDevice, clCEEGTimedData);
92 CL_DLL void
93 clCDeviceDelegateEEGData_Set(clCDeviceDelegateEEGData delegate,
94 clCDeviceHandlerEEGData callback) NOEXCEPT;
98 typedef unsigned char clCUChar;
99 CLC_STRUCT(clCDeviceDelegateUChar);
100 typedef void (*clCDeviceHandlerUChar)(clCDevice, clCUChar);
101 CL_DLL void clCDeviceDelegateBatteryCharge_Set(clCDeviceDelegateUChar delegate,
102 clCDeviceHandlerUChar callback) NOEXCEPT;
103
104 CLC_STRUCT(clCDeviceDelegateMode);
105 typedef void (*clCDeviceHandlerMode)(clCDevice, clCDeviceMode);
106 CL_DLL void clCDeviceDelegateMode_Set(clCDeviceDelegateMode delegate,
107 clCDeviceHandlerMode callback) NOEXCEPT;
113 CLC_STRUCT(clCDeviceDelegateDeviceConnectionState);
114 typedef void (*clCDeviceHandlerDeviceConnectionState)(clCDevice, clCDeviceConnectionState);
115 CL_DLL clCDeviceDelegateDeviceConnectionState
116 clCDevice_GetOnConnectionStateChangedEvent(clCDevice device) NOEXCEPT;
117
121 CLC_STRUCT(clCDeviceDelegateConnectionState);
122 typedef void (*clCDeviceHandlerConnectionState)(clCDevice, clCDeviceConnectionState);
123 CL_DLL void clCDeviceDelegateConnectionState_Set(clCDeviceDelegateDeviceConnectionState delegate,
124 clCDeviceHandlerConnectionState callback) NOEXCEPT;
125
132 CL_DLL void clCDevice_Connect(clCDevice device) NOEXCEPT;
139 CL_DLL void clCDevice_Disconnect(clCDevice device) NOEXCEPT;
146 CL_DLL clCUChar clCDevice_GetBatteryCharge(clCDevice device) NOEXCEPT;
152 CL_DLL bool clCDevice_FirmwareVersionReceived(clCDevice device) NOEXCEPT;
159 CL_DLL clCString clCDevice_GetFirmwareVersion(clCDevice device, clCError* error) NOEXCEPT;
166 CL_DLL void clCDevice_SwitchMode(clCDevice device, clCDeviceMode mode) NOEXCEPT;
167 CL_DLL clCDeviceMode clCDevice_GetMode(clCDevice device) NOEXCEPT;
168
174 CL_DLL bool clCDevice_IsConnected(clCDevice device) NOEXCEPT;
181 CL_DLL clCDeviceInfo clCDevice_GetInfo(clCDevice device) NOEXCEPT;
187 CLC_STRUCT_WN(DeviceChannelNames, clCDeviceChannelNames);
188 CL_DLL clCDeviceChannelNames clCDevice_GetChannelNames(clCDevice device) NOEXCEPT;
189
190 CL_DLL int32_t clCDevice_GetChannelsCount(clCDeviceChannelNames deviceChannels) NOEXCEPT;
191
192 CL_DLL int32_t clCDevice_GetChannelIndexByName(clCDeviceChannelNames deviceChannels,
193 const char* channelName) NOEXCEPT;
194
195 CL_DLL clCString clCDevice_GetChannelNameByIndex(clCDeviceChannelNames deviceChannels,
196 int32_t channelIndex) NOEXCEPT;
202 CL_DLL clCDeviceDelegateResistances
203 clCDevice_GetOnResistancesEvent(clCDevice device) NOEXCEPT;
209 CL_DLL clCDeviceDelegateMEMSData
210 clCDevice_GetOnMEMSDataEvent(clCDevice device) NOEXCEPT;
216 CL_DLL clCDeviceDelegatePPGData
217 clCDevice_GetOnPPGDataEvent(clCDevice device) NOEXCEPT;
218
224 CL_DLL clCDeviceDelegateEEGData
225 clCDevice_GetOnEEGDataEvent(clCDevice device) NOEXCEPT;
226
232 CL_DLL clCDeviceDelegateUChar clCDevice_GetOnBatteryChargeEvent(clCDevice device) NOEXCEPT;
233 CL_DLL clCDeviceDelegateMode clCDevice_GetOnModeSwitchedEvent(clCDevice device) NOEXCEPT;
239 CL_DLL void clCDevice_Release(clCDevice device) NOEXCEPT;
240
241#ifdef __cplusplus
242}
243#endif
CDefinesPrivate.h
CLC_STRUCT
#define CLC_STRUCT(Name)
Definition CDefinesPrivate.h:24
NOEXCEPT
#define NOEXCEPT
Definition CDefinesPrivate.h:52
CL_DLL
#define CL_DLL
Definition CDefinesPrivate.h:21
CLC_CLASS_WN
#define CLC_CLASS_WN(Wrapped, Name)
Definition CDefinesPrivate.h:54
CLC_STRUCT_WN
#define CLC_STRUCT_WN(Wrapped, Name)
Definition CDefinesPrivate.h:58
clCDeviceDelegateConnectionState_Set
CL_DLL void clCDeviceDelegateConnectionState_Set(clCDeviceDelegateDeviceConnectionState delegate, clCDeviceHandlerConnectionState callback) NOEXCEPT
clCDevice_GetBatteryCharge
CL_DLL clCUChar clCDevice_GetBatteryCharge(clCDevice device) NOEXCEPT
Get device battery charge.
clCDeviceHandlerMode
void(* clCDeviceHandlerMode)(clCDevice, clCDeviceMode)
Definition CDevice.h:105
clCDeviceConnectionState
clCDeviceConnectionState
Device connection state.
Definition CDevice.h:40
clC_SE_Connected
@ clC_SE_Connected
Definition CDevice.h:42
clC_SE_UnsupportedConnection
@ clC_SE_UnsupportedConnection
Definition CDevice.h:43
clC_SE_Disconnected
@ clC_SE_Disconnected
Definition CDevice.h:41
clCDeviceHandlerConnectionState
void(* clCDeviceHandlerConnectionState)(clCDevice, clCDeviceConnectionState)
Definition CDevice.h:122
clCDevice_GetOnPPGDataEvent
CL_DLL clCDeviceDelegatePPGData clCDevice_GetOnPPGDataEvent(clCDevice device) NOEXCEPT
clCDevice_Release
CL_DLL void clCDevice_Release(clCDevice device) NOEXCEPT
clCDeviceDelegateResistances_Set
CL_DLL void clCDeviceDelegateResistances_Set(clCDeviceDelegateResistances delegate, clCDeviceHandlerResistances callback) NOEXCEPT
clCDevice_IsConnected
CL_DLL bool clCDevice_IsConnected(clCDevice device) NOEXCEPT
clCDeviceHandlerDeviceConnectionState
void(* clCDeviceHandlerDeviceConnectionState)(clCDevice, clCDeviceConnectionState)
Definition CDevice.h:114
clCDeviceHandlerPPGData
void(* clCDeviceHandlerPPGData)(clCDevice, clCPPGTimedData)
Definition CDevice.h:83
clCDeviceDelegatePPGData_Set
CL_DLL void clCDeviceDelegatePPGData_Set(clCDeviceDelegatePPGData delegate, clCDeviceHandlerPPGData callback) NOEXCEPT
clCDeviceHandlerUChar
void(* clCDeviceHandlerUChar)(clCDevice, clCUChar)
Definition CDevice.h:100
clCDeviceDelegateMEMSData_Set
CL_DLL void clCDeviceDelegateMEMSData_Set(clCDeviceDelegateMEMSData delegate, clCDeviceHandlerMEMSData callback) NOEXCEPT
clCDevice_GetOnConnectionStateChangedEvent
CL_DLL clCDeviceDelegateDeviceConnectionState clCDevice_GetOnConnectionStateChangedEvent(clCDevice device) NOEXCEPT
clCDeviceLocator_CreateDevice
CL_DLL clCDevice clCDeviceLocator_CreateDevice(clCDeviceLocator locator, const char *deviceID) NOEXCEPT
clCUChar
unsigned char clCUChar
Definition CDevice.h:98
clCDevice_GetChannelNames
CL_DLL clCDeviceChannelNames clCDevice_GetChannelNames(clCDevice device) NOEXCEPT
clCDeviceHandlerEEGData
void(* clCDeviceHandlerEEGData)(clCDevice, clCEEGTimedData)
Definition CDevice.h:91
clCDevice_Connect
CL_DLL void clCDevice_Connect(clCDevice device) NOEXCEPT
clCDevice_GetInfo
CL_DLL clCDeviceInfo clCDevice_GetInfo(clCDevice device) NOEXCEPT
clCDevice_GetOnResistancesEvent
CL_DLL clCDeviceDelegateResistances clCDevice_GetOnResistancesEvent(clCDevice device) NOEXCEPT
clCDevice_GetOnModeSwitchedEvent
CL_DLL clCDeviceDelegateMode clCDevice_GetOnModeSwitchedEvent(clCDevice device) NOEXCEPT
clCDevice_GetFirmwareVersion
CL_DLL clCString clCDevice_GetFirmwareVersion(clCDevice device, clCError *error) NOEXCEPT
Get device's firmware version.
clCDevice_GetChannelNameByIndex
CL_DLL clCString clCDevice_GetChannelNameByIndex(clCDeviceChannelNames deviceChannels, int32_t channelIndex) NOEXCEPT
clCDevice_GetOnBatteryChargeEvent
CL_DLL clCDeviceDelegateUChar clCDevice_GetOnBatteryChargeEvent(clCDevice device) NOEXCEPT
clCDeviceMode
clCDeviceMode
Definition CDevice.h:25
clC_DM_Resistance
@ clC_DM_Resistance
Definition CDevice.h:26
clC_DM_Idle
@ clC_DM_Idle
Definition CDevice.h:27
clC_DM_Signal
@ clC_DM_Signal
Definition CDevice.h:29
clC_DM_StartMEMS
@ clC_DM_StartMEMS
Definition CDevice.h:30
clC_DM_StartPPG
@ clC_DM_StartPPG
Definition CDevice.h:32
clC_DM_SignalAndResist
@ clC_DM_SignalAndResist
Definition CDevice.h:34
clC_DM_StopPPG
@ clC_DM_StopPPG
Definition CDevice.h:33
clC_DM_PowerDown
@ clC_DM_PowerDown
Definition CDevice.h:28
clC_DM_StopMEMS
@ clC_DM_StopMEMS
Definition CDevice.h:31
clCDevice_Disconnect
CL_DLL void clCDevice_Disconnect(clCDevice device) NOEXCEPT
clCDevice_FirmwareVersionReceived
CL_DLL bool clCDevice_FirmwareVersionReceived(clCDevice device) NOEXCEPT
Check if capsule has read firmware version.
clCDeviceHandlerResistances
void(* clCDeviceHandlerResistances)(clCDevice, clCResistances)
Definition CDevice.h:67
clCDeviceDelegateMode_Set
CL_DLL void clCDeviceDelegateMode_Set(clCDeviceDelegateMode delegate, clCDeviceHandlerMode callback) NOEXCEPT
clCDevice_GetOnMEMSDataEvent
CL_DLL clCDeviceDelegateMEMSData clCDevice_GetOnMEMSDataEvent(clCDevice device) NOEXCEPT
clCDevice_SwitchMode
CL_DLL void clCDevice_SwitchMode(clCDevice device, clCDeviceMode mode) NOEXCEPT
Switch device from signal to resistance mode or switch the device off.
clCDevice_GetChannelIndexByName
CL_DLL int32_t clCDevice_GetChannelIndexByName(clCDeviceChannelNames deviceChannels, const char *channelName) NOEXCEPT
clCDevice_GetMode
CL_DLL clCDeviceMode clCDevice_GetMode(clCDevice device) NOEXCEPT
clCDevice_GetOnEEGDataEvent
CL_DLL clCDeviceDelegateEEGData clCDevice_GetOnEEGDataEvent(clCDevice device) NOEXCEPT
clCDeviceHandlerMEMSData
void(* clCDeviceHandlerMEMSData)(clCDevice, clCMEMSTimedData)
Definition CDevice.h:75
clCDeviceDelegate_Set
CL_DLL void clCDeviceDelegate_Set(clCDeviceDelegate delegate, clCDeviceHandler callback) NOEXCEPT
clCDeviceHandler
void(* clCDeviceHandler)(clCDevice)
Definition CDevice.h:59
clCDevice_GetChannelsCount
CL_DLL int32_t clCDevice_GetChannelsCount(clCDeviceChannelNames deviceChannels) NOEXCEPT
clCDeviceDelegateBatteryCharge_Set
CL_DLL void clCDeviceDelegateBatteryCharge_Set(clCDeviceDelegateUChar delegate, clCDeviceHandlerUChar callback) NOEXCEPT
clCDeviceDelegateEEGData_Set
CL_DLL void clCDeviceDelegateEEGData_Set(clCDeviceDelegateEEGData delegate, clCDeviceHandlerEEGData callback) NOEXCEPT
CDeviceLocator.h
CEEGTimedData.h
clCError
clCError
Capsule error.
Definition CError.h:8
CMEMSTimedData.h
CPPGTimedData.h
CResistances.h