iOS
SDK Integretion
Flow Diagram
Environment
- iOS 9.0 or above, Xcode 9.0 or above.
- Need apply dbay account,in order to perform authentication.
Integration Steps
- Download alg-ios-v1.0.zip.
- Copy
libs/DBAlgorithm.framework
to your project
Permissions
Privacy - Bluetooth Always Usage Description
Privacy - Bluetooth Peripheral Usage Description
How to call method(s)
- Import
<DBAlgorithm/DBAlgorithm.h>
then use[DBAlgorithmCalculate sharedInstance]
to call method(s).
Init Method
-(void)startWithToken: accountId: completion:^(DBErrorCode code);
Parameter | Type | Description |
---|---|---|
token | String | Unique token, provided by deepbay team |
accountId | String | Unique accountId, provided by deepbay team |
completion | Block | 2 callback parameters: 1. DBErrorCodeSuccess call SDK after success;2. DBErrorCodeInvalidUser return error message when init unsuccessfully |
Auth
-(BOOL)isCanUseSDK;
Close
Call close method when finish.
-(void)close;
Add Device Method
-(int)addDevice:(NSString *)deviceName;
Parameter | Type | Description |
---|---|---|
deviceName | String | Headband Device Name |
Result | Type | Description |
---|---|---|
deviceIndex | Int | Device SN Number |
Delete Device
-(void)deleteDevice:(NSString *)deviceName;
Note: delete target device need add before, or the algorithm will be caculted error
Parameter | Type | Description |
---|---|---|
deviceName | String | Headband Device Name |
Swith to Turn On/Off Original Data
-(void)setRawDataSwitch:(BOOL)isOpenRaw;
Parameter | Type | Description |
---|---|---|
isOpenRaw | BOOL | If turn on or off original data |
Call Algorithm Method(s)
-(void)parseRawString:(NSString )raw deviceIndex:(int)deviceIndex eegCompletion:(void(^)(DBEegModel ))eegCompletion completion:(void(^)(DBAlgorithmModel *))completion;
Parameter | Type | Description |
---|---|---|
raw | String | Bluetooth hexadecimal string per frame |
deviceIndex | Int | Device SN Number |
Result | Type | Description |
---|---|---|
eegCompletion | DBEegModel | Is return data successfully |
completion | DBAlgorithmModel | Result from algorithm |
@interface DBEegModel : DBModel
@property (nonatomic) BOOL detectOK;
@property (nonatomic) BOOL haveSecTime;
@property (nonatomic) NSArray * af7Eegs;
@property (nonatomic) NSArray * af8Eegs;
@property (nonatomic) NSArray * af7Leadoffs;
@property (nonatomic) NSArray * af8Leadoffs;
@property (nonatomic) NSNumber * counter;
@property (nonatomic) NSNumber * flag;
@property (nonatomic) NSNumber * index;
@end
@interface DBAlgorithmModel : DBModel
@property (nonatomic) double mindfulness;
@property (nonatomic) int focus;
@property (nonatomic) int stress;
@property (nonatomic) int fatigue;
@property (nonatomic) int relax;
@property (nonatomic) double emotion;
-(int)getSignalQuailty:(DBSignalQuailtyType)type;// Get signal quality indicators from AF7 and AF8 (signal description: 0 stands for good signal quality,1 stands for poor signal quality)
-(DBAlgorithmEnergyModel *)getEnergy;// Get original data
@end
/**
Original Data Model
*/
@interface DBAlgorithmEnergyModel : DBModel
@property (nonatomic) double alpha;
@property (nonatomic) double beta;
@property (nonatomic) double delta;
@property (nonatomic) double gamma;
-(double)getMindfullness;
@end
More about data specification, please ref to
Mindfulness Indicators Radar Map Scores
-(void)getMindfullnessScore:(NSArray )array completion:(void(^)(DBRadarModel ))completion;
Parameter | Type | Description |
---|---|---|
tbrs | Array | Data array from algorithm |
Result | Type | Description |
---|---|---|
completion | DBRadarModel | Result from algorithm |
@interface DBRadarModel : DBModel
@property (nonatomic) int stability; // Mindfulness Stability
@property (nonatomic) float percent; // Mindfulness Percentage
@property (nonatomic) int score; // Mindfulness Score
@property (nonatomic) float potential; // Mindfulness Potential
@end