Skip to content

Commit caf5142

Browse files
committed
Add first alpha version of SensingKit-iOS
1 parent 5fa6511 commit caf5142

31 files changed

+2918
-4
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,4 @@ General Public License ever published by the Free Software Foundation.
162162
whether future versions of the GNU Lesser General Public License shall
163163
apply, that proxy's public statement of acceptance of any version is
164164
permanent authorization for you to choose that version for the
165-
Library.
165+
Library.

README.md

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,38 @@
1-
SensingKit-iOS
2-
==============
1+
# SensingKit-iOS Library
32

4-
An iOS library that provides Continuous Sensing functionality to your applications.
3+
An iOS library that provides Continuous Sensing functionality to your applications. For more information, please refer to the [project website](http://www.sensingkit.org).
4+
5+
6+
## Configuring the Library
7+
Coming soon…
8+
9+
## How to Use this Library
10+
Coming soon…
11+
12+
## License
13+
14+
```
15+
#!text
16+
Copyright (c) 2014. Queen Mary University of London
17+
Kleomenis Katevas, [email protected]
18+
19+
This file is part of SensingKit-iOS library.
20+
For more information, please visit http://www.sensingkit.org
21+
22+
SensingKit-iOS is free software: you can redistribute it and/or modify
23+
it under the terms of the GNU Lesser General Public License as published by
24+
the Free Software Foundation, either version 3 of the License, or
25+
(at your option) any later version.
26+
27+
SensingKit-iOS is distributed in the hope that it will be useful,
28+
but WITHOUT ANY WARRANTY; without even the implied warranty of
29+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30+
GNU Lesser General Public License for more details.
31+
32+
You should have received a copy of the GNU Lesser General Public License
33+
along with SensingKit-iOS. If not, see <http://www.gnu.org/licenses/>.
34+
```
35+
36+
This library is available under the GNU Lesser General Public License 3.0, allowing to use the library in your applications.
37+
38+
If you want to help with the open source project, contact [email protected]

SensingKit.xcodeproj/project.pbxproj

Lines changed: 519 additions & 0 deletions
Large diffs are not rendered by default.

SensingKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "0510"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "CFBB413519B92514002AE1A9"
18+
BuildableName = "libSensingKit.a"
19+
BlueprintName = "SensingKit"
20+
ReferencedContainer = "container:SensingKit.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
27+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
28+
shouldUseLaunchSchemeArgsEnv = "YES"
29+
buildConfiguration = "Debug">
30+
<Testables>
31+
<TestableReference
32+
skipped = "NO">
33+
<BuildableReference
34+
BuildableIdentifier = "primary"
35+
BlueprintIdentifier = "CFBB414519B92514002AE1A9"
36+
BuildableName = "SensingKitTests.xctest"
37+
BlueprintName = "SensingKitTests"
38+
ReferencedContainer = "container:SensingKit.xcodeproj">
39+
</BuildableReference>
40+
</TestableReference>
41+
</Testables>
42+
</TestAction>
43+
<LaunchAction
44+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
45+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
46+
launchStyle = "0"
47+
useCustomWorkingDirectory = "NO"
48+
buildConfiguration = "Debug"
49+
ignoresPersistentStateOnLaunch = "NO"
50+
debugDocumentVersioning = "YES"
51+
allowLocationSimulation = "YES">
52+
<AdditionalOptions>
53+
</AdditionalOptions>
54+
</LaunchAction>
55+
<ProfileAction
56+
shouldUseLaunchSchemeArgsEnv = "YES"
57+
savedToolIdentifier = ""
58+
useCustomWorkingDirectory = "NO"
59+
buildConfiguration = "Release"
60+
debugDocumentVersioning = "YES">
61+
</ProfileAction>
62+
<AnalyzeAction
63+
buildConfiguration = "Debug">
64+
</AnalyzeAction>
65+
<ArchiveAction
66+
buildConfiguration = "Release"
67+
revealArchiveInOrganizer = "YES">
68+
</ArchiveAction>
69+
</Scheme>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>SchemeUserState</key>
6+
<dict>
7+
<key>SensingKit.xcscheme</key>
8+
<dict>
9+
<key>orderHint</key>
10+
<integer>0</integer>
11+
</dict>
12+
</dict>
13+
<key>SuppressBuildableAutocreation</key>
14+
<dict>
15+
<key>CFBB413519B92514002AE1A9</key>
16+
<dict>
17+
<key>primary</key>
18+
<true/>
19+
</dict>
20+
<key>CFBB414519B92514002AE1A9</key>
21+
<dict>
22+
<key>primary</key>
23+
<true/>
24+
</dict>
25+
</dict>
26+
</dict>
27+
</plist>

SensingKit/GZIP.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// GZIP.h
3+
//
4+
// Version 1.0.2
5+
//
6+
// Created by Nick Lockwood on 03/06/2012.
7+
// Copyright (C) 2012 Charcoal Design
8+
//
9+
// Distributed under the permissive zlib License
10+
// Get the latest version from here:
11+
//
12+
// https://github.com/nicklockwood/GZIP
13+
//
14+
// This software is provided 'as-is', without any express or implied
15+
// warranty. In no event will the authors be held liable for any damages
16+
// arising from the use of this software.
17+
//
18+
// Permission is granted to anyone to use this software for any purpose,
19+
// including commercial applications, and to alter it and redistribute it
20+
// freely, subject to the following restrictions:
21+
//
22+
// 1. The origin of this software must not be misrepresented; you must not
23+
// claim that you wrote the original software. If you use this software
24+
// in a product, an acknowledgment in the product documentation would be
25+
// appreciated but is not required.
26+
//
27+
// 2. Altered source versions must be plainly marked as such, and must not be
28+
// misrepresented as being the original software.
29+
//
30+
// 3. This notice may not be removed or altered from any source distribution.
31+
//
32+
33+
34+
#import <Foundation/Foundation.h>
35+
36+
37+
@interface NSData (GZIP)
38+
39+
- (NSData *)gzippedDataWithCompressionLevel:(float)level;
40+
- (NSData *)gzippedData;
41+
- (NSData *)gunzippedData;
42+
43+
@end

SensingKit/GZIP.m

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
//
2+
// GZIP.m
3+
//
4+
// Version 1.0.2
5+
//
6+
// Created by Nick Lockwood on 03/06/2012.
7+
// Copyright (C) 2012 Charcoal Design
8+
//
9+
// Distributed under the permissive zlib License
10+
// Get the latest version from here:
11+
//
12+
// https://github.com/nicklockwood/GZIP
13+
//
14+
// This software is provided 'as-is', without any express or implied
15+
// warranty. In no event will the authors be held liable for any damages
16+
// arising from the use of this software.
17+
//
18+
// Permission is granted to anyone to use this software for any purpose,
19+
// including commercial applications, and to alter it and redistribute it
20+
// freely, subject to the following restrictions:
21+
//
22+
// 1. The origin of this software must not be misrepresented; you must not
23+
// claim that you wrote the original software. If you use this software
24+
// in a product, an acknowledgment in the product documentation would be
25+
// appreciated but is not required.
26+
//
27+
// 2. Altered source versions must be plainly marked as such, and must not be
28+
// misrepresented as being the original software.
29+
//
30+
// 3. This notice may not be removed or altered from any source distribution.
31+
//
32+
33+
34+
#import "GZIP.h"
35+
#import <zlib.h>
36+
37+
38+
static const NSUInteger ChunkSize = 16384;
39+
40+
41+
@implementation NSData (GZIP)
42+
43+
- (NSData *)gzippedDataWithCompressionLevel:(float)level
44+
{
45+
if ([self length])
46+
{
47+
z_stream stream;
48+
stream.zalloc = Z_NULL;
49+
stream.zfree = Z_NULL;
50+
stream.opaque = Z_NULL;
51+
stream.avail_in = (uint)[self length];
52+
stream.next_in = (Bytef *)[self bytes];
53+
stream.total_out = 0;
54+
stream.avail_out = 0;
55+
56+
int compression = (level < 0.0f)? Z_DEFAULT_COMPRESSION: (int)(roundf(level * 9));
57+
if (deflateInit2(&stream, compression, Z_DEFLATED, 31, 8, Z_DEFAULT_STRATEGY) == Z_OK)
58+
{
59+
NSMutableData *data = [NSMutableData dataWithLength:ChunkSize];
60+
while (stream.avail_out == 0)
61+
{
62+
if (stream.total_out >= [data length])
63+
{
64+
data.length += ChunkSize;
65+
}
66+
stream.next_out = (uint8_t *)[data mutableBytes] + stream.total_out;
67+
stream.avail_out = (uInt)([data length] - stream.total_out);
68+
deflate(&stream, Z_FINISH);
69+
}
70+
deflateEnd(&stream);
71+
data.length = stream.total_out;
72+
return data;
73+
}
74+
}
75+
return nil;
76+
}
77+
78+
- (NSData *)gzippedData
79+
{
80+
return [self gzippedDataWithCompressionLevel:-1.0f];
81+
}
82+
83+
- (NSData *)gunzippedData
84+
{
85+
if ([self length])
86+
{
87+
z_stream stream;
88+
stream.zalloc = Z_NULL;
89+
stream.zfree = Z_NULL;
90+
stream.avail_in = (uint)[self length];
91+
stream.next_in = (Bytef *)[self bytes];
92+
stream.total_out = 0;
93+
stream.avail_out = 0;
94+
95+
NSMutableData *data = [NSMutableData dataWithLength:(NSUInteger)([self length] * 1.5)];
96+
if (inflateInit2(&stream, 47) == Z_OK)
97+
{
98+
int status = Z_OK;
99+
while (status == Z_OK)
100+
{
101+
if (stream.total_out >= [data length])
102+
{
103+
data.length += [self length] * 0.5;
104+
}
105+
stream.next_out = (uint8_t *)[data mutableBytes] + stream.total_out;
106+
stream.avail_out = (uInt)([data length] - stream.total_out);
107+
status = inflate (&stream, Z_SYNC_FLUSH);
108+
}
109+
if (inflateEnd(&stream) == Z_OK)
110+
{
111+
if (status == Z_STREAM_END)
112+
{
113+
data.length = stream.total_out;
114+
return data;
115+
}
116+
}
117+
}
118+
}
119+
return nil;
120+
}
121+
122+
@end

SensingKit/KKBatterySensing.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//
2+
// KKBatterySensing.h
3+
// CrowdSensingApp
4+
//
5+
// Copyright (c) 2014. Queen Mary University of London
6+
// Kleomenis Katevas, [email protected]
7+
//
8+
// This file is part of SensingKit-iOS library.
9+
// For more information, please visit http://www.sensingkit.org
10+
//
11+
// SensingKit-iOS is free software: you can redistribute it and/or modify
12+
// it under the terms of the GNU Lesser General Public License as published by
13+
// the Free Software Foundation, either version 3 of the License, or
14+
// (at your option) any later version.
15+
//
16+
// SensingKit-iOS is distributed in the hope that it will be useful,
17+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
// GNU Lesser General Public License for more details.
20+
//
21+
// You should have received a copy of the GNU Lesser General Public License
22+
// along with SensingKit-iOS. If not, see <http://www.gnu.org/licenses/>.
23+
//
24+
25+
#import <Foundation/Foundation.h>
26+
27+
@protocol KKBatterySensingDelegate <NSObject>
28+
29+
- (void)batteryLevelChanged:(UIDeviceBatteryState)state level:(CGFloat)level;
30+
- (void)batteryStateChanged:(UIDeviceBatteryState)state level:(CGFloat)level;
31+
32+
@end
33+
34+
@interface KKBatterySensing : NSObject
35+
36+
@property (weak, nonatomic) id <KKBatterySensingDelegate> delegate;
37+
38+
@property (nonatomic, readonly) CGFloat batteryLevel;
39+
@property (nonatomic, readonly) UIDeviceBatteryState batteryState;
40+
41+
- (void)startBatterySensing;
42+
- (void)stopBatterySensing;
43+
44+
@end

0 commit comments

Comments
 (0)