Skip to content

Commit a3f2742

Browse files
committed
Merge pull request #4 from SensingKit/next
v0.4.0
2 parents 73f0b3d + 22233a2 commit a3f2742

File tree

102 files changed

+4465
-1012
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+4465
-1012
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ profile
1616
*.moved-aside
1717
DerivedData
1818
.idea/
19+
Documentation

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
### 0.4.0 (October 11, 2015)
4+
- Added Documentation using appledoc generator.
5+
- Added support for iOS 9.
6+
- Added support for iOS 9 App Slicing.
7+
- Added support for Swift 2 language
8+
- Updated SensingKit-iOS API.
9+
- Added Configuration for all sensors.
10+
- Added support for Microphone sensor.
11+
- Added currentPace and currentCadence in PedometerData (iOS 9 only)
12+
- SensorModules have been renamed into Sensors.
13+
- Activity sensor has been renamed into MotionActivity.
14+
315
### 0.3.0 (August 29, 2015)
416
- Added support for Pedometer sensor.
517
- Added support for Altimeter sensor.

README.md

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,40 @@ An iOS library that provides Continuous Sensing functionality to your applicatio
55

66
## Supported Sensors
77

8-
The following sensor modules are currently supported in SensingKit-Android, (listed in [SKSensorModuleType](SensingKit/SKSensorModuleType.h) enum):
8+
The following mobile sensors are currently supported in SensingKit-iOS, (listed in [SKSensorType](SensingKit/SKSensorType.h) enum):
99

1010
- Accelerometer
1111
- Gyroscope
1212
- Magnetometer
1313
- Device Motion (senses Attitude, Gravity, User Acceleration, Magnetic Field, Rotation)
14-
- Activity
14+
- Motion Activity
1515
- Pedometer
1616
- Altimeter
1717
- Battery
1818
- Location
1919
- iBeacon™ Proximity
2020
- Eddystone™ Proximity
21+
- Microphone
2122

2223

2324
## Configuring the Library
2425

26+
You can always skip this step by downloading the released version of SensingKit-iOS from [here](https://github.com/SensingKit/SensingKit-iOS/releases).
27+
28+
In case you want to build the library yourself:
29+
2530
- Open SensingKit project in Xcode and build SensingKit library using Product -> Build.
2631

2732
- Choose the ‘Framework’ scheme from the top toolbar (or using Product -> Scheme -> Framework) and build the framework. SensingKit.framework file should be available in your desktop.
2833

29-
- Move the generated SensingKit.framework file into your new Xcode project.
3034

35+
## Using the Library
36+
37+
- First, you need to move the generated SensingKit.framework file into your new Xcode project.
3138

32-
## How to Use this Library
39+
- Since SensingKit-iOS uses Categories internally, you need to add the ’-ObjC’ flag into your project build settings. Open your project, select your project from the Project Navigator on the left and click on the app’s target. Select the Build Settings tab on the top of the screen and search for “Other Linker Flags”. Finally, click the + button and add ‘-ObjC’ as a new property on the list.
3340

34-
- Import and init SensingKit into your Activity class as shown bellow:
41+
- Import and init SensingKit as shown bellow:
3542

3643
```objectivec
3744
#import <SensingKit/SensingKitLib.h>
@@ -46,18 +53,27 @@ The following sensor modules are currently supported in SensingKit-Android, (lis
4653
```
4754

4855

49-
- Register a sensor module (e.g. a Battery sensor) as shown bellow:
56+
- Check if a sensor is available in the device:
57+
58+
```objectivec
59+
if ([self.sensingKit isSensorAvailable:Battery]) {
60+
// You can access the sensor
61+
}
62+
```
63+
64+
65+
- Register a sensor (e.g. a Battery sensor) as shown bellow:
5066
5167
```objectivec
52-
[self.sensingKit registerSensorModule:Battery];
68+
[self.sensingKit registerSensor:Battery];
5369
```
5470

5571

56-
- Subscribe a sensor data listener. You can cast the data object into the actual sensor data object in order to access all the sensor data properties:
72+
- Subscribe a sensor data handler. You can cast the data object into the actual sensor data object in order to access all the sensor data properties:
5773

5874
```objectivec
59-
[self.sensingKit subscribeSensorDataListenerToSensor:Battery
60-
withHandler:^(SKSensorModuleType moduleType, SKSensorData *sensorData) {
75+
[self.sensingKit subscribeToSensor:Battery
76+
withHandler:^(SKSensorType sensorType, SKSensorData *sensorData) {
6177

6278
SKBatteryData *batteryData = (SKBatteryData *)sensorData;
6379
NSLog(@“Battery Level: %f”, batteryData.level);

SensingKit.xcodeproj/project.pbxproj

Lines changed: 255 additions & 58 deletions
Large diffs are not rendered by default.

SensingKit/NSString+SensorType.h

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//
2+
// NSString+SKSensorType.h
3+
// SensingKit
4+
//
5+
// Copyright (c) 2014. Queen Mary University of London
6+
// Kleomenis Katevas, k.katevas@qmul.ac.uk
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+
#import "SKSensorType.h"
27+
28+
NS_ASSUME_NONNULL_BEGIN
29+
30+
/**
31+
* NSString+SKSensorType is a category responsible for converting an SKSensorType enum into string.
32+
*/
33+
@interface NSString (SKSensorType)
34+
35+
/**
36+
* Converts an SKSensorType enum into a string.
37+
* This method is useful when you want to use the sensor name in the application's User Interface. The returned string might contain spaces or special characters (such as '™'). For example, iBeacon™ Proximity sensor (enum iBeaconProximity) will be returned as "iBeacon™ Proximity".
38+
*
39+
* @param sensorType The type of the sensor.
40+
*
41+
* @return A string with the sensor name. (e.g. "iBeacon™ Proximity").
42+
*/
43+
+ (NSString *)stringWithSensorType:(SKSensorType)sensorType;
44+
45+
/**
46+
* Converts an SKSensorType enum into a non-spaced string that does not include special characters.
47+
* This method is useful when you want to use the sensor name in file or directory names. The returned string does not contain spaces or any special character (such as '™'). For example, iBeacon™ Proximity sensor (enum iBeaconProximity) will be returned as "iBeaconProximity".
48+
*
49+
* @param sensorType The type of the sensor.
50+
*
51+
* @return A non-spaced string with the sensor name. (e.g. "iBeaconProximity").
52+
*/
53+
+ (NSString *)nonspacedStringWithSensorType:(SKSensorType)sensorType;
54+
55+
@end
56+
57+
NS_ASSUME_NONNULL_END
Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// SKBeaconDeviceData.h
2+
// NSString+SensorType.h
33
// SensingKit
44
//
55
// Copyright (c) 2014. Queen Mary University of London
@@ -22,27 +22,48 @@
2222
// along with SensingKit-iOS. If not, see <http://www.gnu.org/licenses/>.
2323
//
2424

25-
#import <Foundation/Foundation.h>
26-
#import "SKSensorData.h"
27-
@import CoreLocation;
25+
#import "NSString+SensorType.h"
2826

29-
@interface SKBeaconDeviceData : SKSensorData
27+
@implementation NSString (SensorType)
3028

31-
@property (nonatomic, readonly) NSUInteger major;
32-
@property (nonatomic, readonly) NSUInteger minor;
33-
@property (nonatomic, readonly) CLLocationAccuracy accuracy;
34-
@property (nonatomic, readonly) CLProximity proximity;
35-
@property (nonatomic, readonly) NSInteger rssi;
29+
static const NSString *SENSOR_STRINGS[] = {
30+
@"Accelerometer",
31+
@"Gyroscope",
32+
@"Magnetometer",
33+
@"Device Motion",
34+
@"Motion Activity",
35+
@"Pedometer",
36+
@"Altimeter",
37+
@"Battery",
38+
@"Location",
39+
@"iBeacon™ Proximity",
40+
@"Eddystone™ Proximity",
41+
@"Microphone"
42+
};
3643

37-
- (instancetype)initWithTimestamp:(NSDate *)timestamp
38-
withMajor:(NSUInteger)major
39-
withMinor:(NSUInteger)minor
40-
withAccuracy:(CLLocationAccuracy)accuracy
41-
withProximity:(CLProximity)proximity
42-
withRssi:(NSInteger)rssi;
44+
static const NSString *NONSPACED_SENSOR_STRINGS[] = {
45+
@"Accelerometer",
46+
@"Gyroscope",
47+
@"Magnetometer",
48+
@"DeviceMotion",
49+
@"MotionActivity",
50+
@"Pedometer",
51+
@"Altimeter",
52+
@"Battery",
53+
@"Location",
54+
@"iBeaconProximity",
55+
@"EddystoneProximity",
56+
@"Microphone"
57+
};
4358

44-
+ (NSString *)csvHeader;
59+
+ (NSString *)stringWithSensorType:(SKSensorType)sensorType
60+
{
61+
return SENSOR_STRINGS[sensorType].copy;
62+
}
4563

46-
- (NSString *)proximityString;
64+
+ (NSString *)nonspacedStringWithSensorType:(SKSensorType)sensorType
65+
{
66+
return NONSPACED_SENSOR_STRINGS[sensorType].copy;
67+
}
4768

4869
@end

SensingKit/SKAbstractSensorModule.h renamed to SensingKit/SKAbstractSensor.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// SKAbstractSensorModule.h
2+
// SKAbstractSensor.h
33
// SensingKit
44
//
55
// Copyright (c) 2014. Queen Mary University of London
@@ -23,19 +23,24 @@
2323
//
2424

2525
#import <Foundation/Foundation.h>
26-
#import "SKSensorModuleType.h"
27-
#import "SKSensorDataListener.h"
26+
#import "SKSensorType.h"
27+
#import "SKSensorDataHandler.h"
28+
#import "SKConfiguration.h"
2829

29-
@interface SKAbstractSensorModule : NSObject
30+
NS_ASSUME_NONNULL_BEGIN
3031

31-
@property (nonatomic, readonly) SKSensorModuleType moduleType;
32+
@interface SKAbstractSensor : NSObject
33+
34+
@property (nonatomic, copy) SKConfiguration *configuration;
35+
36+
@property (nonatomic, readonly) SKSensorType sensorType;
3237
@property (nonatomic, readonly, getter=isSensing) BOOL sensing;
3338

34-
- (void)subscribeSensorDataListener:(SKSensorDataHandler)handler;
39+
- (void)subscribeHandler:(SKSensorDataHandler)handler;
3540

36-
- (void)unsubscribeSensorDataListener:(SKSensorDataHandler)handler;
41+
- (void)unsubscribeHandler:(SKSensorDataHandler)handler;
3742

38-
- (void)unsubscribeAllSensorDataListeners;
43+
- (void)unsubscribeAllHandlers;
3944

4045
- (void)startSensing;
4146

@@ -44,3 +49,5 @@
4449
- (void)submitSensorData:(SKSensorData *)data;
4550

4651
@end
52+
53+
NS_ASSUME_NONNULL_END

SensingKit/SKAbstractSensorModule.m renamed to SensingKit/SKAbstractSensor.m

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// SKAbstractSensorModule.m
2+
// SKAbstractSensor.m
33
// SensingKit
44
//
55
// Copyright (c) 2014. Queen Mary University of London
@@ -21,17 +21,19 @@
2121
// You should have received a copy of the GNU Lesser General Public License
2222
// along with SensingKit-iOS. If not, see <http://www.gnu.org/licenses/>.
2323
//
24-
#import "SKAbstractSensorModule.h"
24+
#import "SKAbstractSensor.h"
2525

26-
@interface SKAbstractSensorModule()
26+
27+
@interface SKAbstractSensor()
2728

2829
@property (nonatomic, strong) NSMutableArray *sensorDataListeners;
2930

3031
@end
3132

32-
@implementation SKAbstractSensorModule
3333

34-
- (void)subscribeSensorDataListener:(SKSensorDataHandler)handler
34+
@implementation SKAbstractSensor
35+
36+
- (void)subscribeHandler:(SKSensorDataHandler)handler
3537
{
3638
// Register the callback
3739
if ([self.sensorDataListeners containsObject:handler]) {
@@ -41,7 +43,7 @@ - (void)subscribeSensorDataListener:(SKSensorDataHandler)handler
4143
[self.sensorDataListeners addObject:handler];
4244
}
4345

44-
- (void)unsubscribeSensorDataListener:(SKSensorDataHandler)handler
46+
- (void)unsubscribeHandler:(SKSensorDataHandler)handler
4547
{
4648
// Unregister the callback
4749
if (![self.sensorDataListeners containsObject:handler]) {
@@ -51,7 +53,7 @@ - (void)unsubscribeSensorDataListener:(SKSensorDataHandler)handler
5153
[self.sensorDataListeners removeObject:handler];
5254
}
5355

54-
- (void)unsubscribeAllSensorDataListeners
56+
- (void)unsubscribeAllHandlers
5557
{
5658
[self.sensorDataListeners removeAllObjects];
5759
}
@@ -84,11 +86,11 @@ - (void)submitSensorData:(SKSensorData *)data
8486
{
8587
if ([self shouldPostSensorData:data]) {
8688

87-
if ([self.sensorDataListeners count]) {
89+
if (self.sensorDataListeners.count) {
8890

8991
// CallBack with data as parameter
9092
for (SKSensorDataHandler handler in self.sensorDataListeners) {
91-
handler(self.moduleType, data);
93+
handler(self.sensorType, data);
9294
}
9395

9496
}

SensingKit/SKAccelerometer.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,19 @@
2222
// along with SensingKit-iOS. If not, see <http://www.gnu.org/licenses/>.
2323
//
2424

25-
#import "SKAbstractSensorModule.h"
25+
#import "SKAbstractSensor.h"
26+
#import "SKAccelerometerConfiguration.h"
2627

27-
@interface SKAccelerometer : SKAbstractSensorModule
28+
NS_ASSUME_NONNULL_BEGIN
2829

29-
+ (BOOL)isSensorModuleAvailable;
30+
@interface SKAccelerometer : SKAbstractSensor
31+
32+
+ (BOOL)isSensorAvailable;
33+
34+
- (instancetype)init NS_UNAVAILABLE;
35+
36+
- (instancetype)initWithConfiguration:(SKAccelerometerConfiguration *)configuration NS_DESIGNATED_INITIALIZER;
3037

3138
@end
39+
40+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)