-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathFluxtreamUploaderCpp.mm
71 lines (55 loc) · 2.65 KB
/
FluxtreamUploaderCpp.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// FluxtreamUploaderCpp.mm
//
// Created by rsargent on 10/23/12.
// Copyright (c) 2012 rsargent. All rights reserved.
//
#include "FluxtreamUploaderCpp.h"
#import "FluxtreamUploaderObjc.h"
FluxtreamUploaderCpp::FluxtreamUploaderCpp() {
fluxtreamUploaderObjc = (void*) CFBridgingRetain([[FluxtreamUploaderObjc alloc] init]);
}
FluxtreamUploaderCpp::~FluxtreamUploaderCpp() {
CFBridgingRelease(fluxtreamUploaderObjc);
fluxtreamUploaderObjc = NULL;
}
#define getUploader() ((__bridge FluxtreamUploaderObjc*) fluxtreamUploaderObjc)
std::string FluxtreamUploaderCpp::getUsername() {
return std::string([getUploader().username cStringUsingEncoding:NSUTF8StringEncoding]);
}
void FluxtreamUploaderCpp::setUsername(const std::string &username) {
getUploader().username = [NSString stringWithUTF8String:username.c_str()];
}
void FluxtreamUploaderCpp::setPassword(const std::string &password) {
getUploader().password = [NSString stringWithUTF8String:password.c_str()];
}
void FluxtreamUploaderCpp::addChannel(const std::string &channelName) {
[getUploader() addChannel: [NSString stringWithUTF8String: channelName.c_str()]];
}
void FluxtreamUploaderCpp::addSample(double time, double ch0) {
[getUploader() addSample:time ch0:ch0];
}
void FluxtreamUploaderCpp::addSample(double time, double ch0, double ch1) {
[getUploader() addSample:time ch0:ch0 ch1:ch1];
}
void FluxtreamUploaderCpp::addSample(double time, double ch0, double ch1, double ch2) {
[getUploader() addSample:time ch0:ch0 ch1:ch1 ch2:ch2];
}
void FluxtreamUploaderCpp::addSample(double time, double ch0, double ch1, double ch2, double ch3) {
[getUploader() addSample:time ch0:ch0 ch1:ch1 ch2:ch2 ch3:ch3];
}
void FluxtreamUploaderCpp::addSample(double time, double ch0, double ch1, double ch2, double ch3, double ch4) {
[getUploader() addSample:time ch0:ch0 ch1:ch1 ch2:ch2 ch3:ch3 ch4:ch4];
}
// Samples are queued when added, then uploaded in batches to minimize communication overhead
// and save battery life. The batching behavior can be controlled by setting the
// "maximum upload age" and "maximum upload sample count", below
//
// Maximum upload age is the maximum age a sample can be, in seconds, before
// upload is automatically triggered. Default is 30 seconds. 0 means send everything immediately.
void setMaximumUploadAge(double maxAge);
double getMaximumUploadAge();
// Maximum upload sample count is the maximum number of samples that can be uploaded in a single batch.
// (If the queue becomes larger than this count, its contents will be uploaded in multiple batches)
void setMaximumUploadSampleCount(int maximumUploadSampleCount);
int getMaximumUploadSampleCount();