Skip to content

Commit 22e354e

Browse files
authored
Merge pull request #12 from SensingKit/next
Release 0.5.0
2 parents 5143aaa + 780bd33 commit 22e354e

File tree

96 files changed

+2504
-1357
lines changed

Some content is hidden

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

96 files changed

+2504
-1357
lines changed

CHANGELOG.md

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

3+
### 0.5.0 (March 2, 2017)
4+
- Added error handling support using NSError.
5+
- Updated Eddystone Scanner into latest version.
6+
- Changed library into a dynamic framework.
7+
- Added CocoaPod support.
8+
- Added support for iOS 10.
9+
- Improved SensingKit API.
10+
- Updated SensingKit Documentation.
11+
312
### 0.4.2 (November 27, 2015)
413
- Fixed a bug were sensor configuration was not updated.
514

ESSEddystone/AUTHORS

100755100644
File mode changed.

ESSEddystone/CONTRIBUTORS

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ Roy Want <roywant@google.com>
1717
Giovanni Ortuno <ortuno@google.com>
1818
Dave Smith <smith@wiresareobsolete.com>
1919
Christopher Dro <casheghian@gmail.com>
20-
20+
Shuichi Tsutsumi <shuichi0526@gmail.com>

ESSEddystone/ESSBeaconScanner.h

100755100644
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
- (void)beaconScanner:(ESSBeaconScanner *)scanner
3030
didUpdateBeacon:(id)beaconInfo;
3131

32+
- (void)beaconScanner:(ESSBeaconScanner *)scanner
33+
didFindURL:(NSURL *)url;
34+
3235
@end
3336

3437
@interface ESSBeaconScanner : NSObject

ESSEddystone/ESSBeaconScanner.m

100755100644
Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ @interface ESSBeaconScanner () <CBCentralManagerDelegate> {
3939
* Then, the next time we see a UID frame for that Eddystone, we can add the most recently seen
4040
* telemetry frame to the sighting.
4141
*/
42-
NSMutableDictionary *_deviceIDCache;
42+
NSMutableDictionary *_tlmCache;
4343

4444
/**
4545
* Beacons we've seen already. If we see an Eddystone and notice that we've seen it before, we
@@ -63,7 +63,7 @@ @implementation ESSBeaconScanner
6363
- (instancetype)init {
6464
if ((self = [super init]) != nil) {
6565
_onLostTimeout = 15.0;
66-
_deviceIDCache = [NSMutableDictionary dictionary];
66+
_tlmCache = [NSMutableDictionary dictionary];
6767
_seenEddystoneCache = [NSMutableDictionary dictionary];
6868
_beaconOperationsQueue = dispatch_queue_create(kBeaconsOperationQueueName, NULL);
6969
_centralManager = [[CBCentralManager alloc] initWithDelegate:self
@@ -107,35 +107,51 @@ - (void)centralManagerDidUpdateState:(CBCentralManager *)central {
107107

108108
// This will be called from the |beaconsOperationQueue|.
109109
- (void)centralManager:(CBCentralManager *)central
110-
didDiscoverPeripheral:(CBPeripheral *)peripheral
111-
advertisementData:(NSDictionary *)advertisementData
112-
RSSI:(NSNumber *)RSSI {
113-
110+
didDiscoverPeripheral:(CBPeripheral *)peripheral
111+
advertisementData:(NSDictionary *)advertisementData
112+
RSSI:(NSNumber *)RSSI {
114113
NSDictionary *serviceData = advertisementData[CBAdvertisementDataServiceDataKey];
114+
NSData *beaconServiceData = serviceData[[ESSBeaconInfo eddystoneServiceID]];
115+
116+
ESSFrameType frameType = [ESSBeaconInfo frameTypeForFrame:beaconServiceData];
115117

116118
// If it's a telemetry (TLM) frame, then save it into our cache so that the next time we get a
117119
// UID frame (i.e. an Eddystone "sighting"), we can include the telemetry with it.
118-
ESSFrameType frameType = [ESSBeaconInfo frameTypeForFrame:serviceData];
119120
if (frameType == kESSEddystoneTelemetryFrameType) {
120-
_deviceIDCache[peripheral.identifier] = [ESSBeaconInfo telemetryDataForFrame:serviceData];
121-
} else if (frameType == kESSEddystoneUIDFrameType) {
121+
_tlmCache[peripheral.identifier] = beaconServiceData;
122+
} else if (frameType == kESSEddystoneURLFrameType) {
123+
NSURL *url = [ESSBeaconInfo parseURLFromFrameData:beaconServiceData];
124+
125+
// Report the sighted URL frame.
126+
if ([_delegate respondsToSelector:@selector(beaconScanner:didFindURL:)]) {
127+
[_delegate beaconScanner:self didFindURL:url];
128+
}
129+
} else if (frameType == kESSEddystoneUIDFrameType
130+
|| frameType == kESSEddystoneEIDFrameType) {
122131
CBUUID *eddystoneServiceUUID = [ESSBeaconInfo eddystoneServiceID];
123132
NSData *eddystoneServiceData = serviceData[eddystoneServiceUUID];
124133

125134
// If we have telemetry data for this Eddystone, include it in the construction of the
126135
// ESSBeaconInfo object. Otherwise, nil is fine.
127-
NSData *telemetry = _deviceIDCache[peripheral.identifier];
136+
NSData *telemetry = _tlmCache[peripheral.identifier];
128137

129-
ESSBeaconInfo *beaconInfo = [ESSBeaconInfo beaconInfoForUIDFrameData:eddystoneServiceData
130-
telemetry:telemetry
131-
RSSI:RSSI];
138+
ESSBeaconInfo *beaconInfo;
139+
if (frameType == kESSEddystoneUIDFrameType) {
140+
beaconInfo = [ESSBeaconInfo beaconInfoForUIDFrameData:eddystoneServiceData
141+
telemetry:telemetry
142+
RSSI:RSSI];
143+
} else {
144+
beaconInfo = [ESSBeaconInfo beaconInfoForEIDFrameData:eddystoneServiceData
145+
telemetry:telemetry
146+
RSSI:RSSI];
147+
}
132148

133-
if (beaconInfo != nil) {
149+
if (beaconInfo) {
134150
// NOTE: At this point you can choose whether to keep or get rid of the telemetry data. You
135151
// can either opt to include it with every single beacon sighting for this beacon, or
136152
// delete it until we get a new / "fresh" TLM frame. We'll treat it as "report it only
137153
// when you see it", so we'll delete it each time.
138-
[_deviceIDCache removeObjectForKey:peripheral.identifier];
154+
[_tlmCache removeObjectForKey:peripheral.identifier];
139155

140156
// If we haven't seen this Eddystone before, fire a beaconScanner:didFindBeacon: and mark it
141157
// as seen.

ESSEddystone/ESSEddystone.h

100755100644
Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@
1717

1818
typedef NS_ENUM(NSUInteger, ESSBeaconType) {
1919
kESSBeaconTypeEddystone = 1,
20+
kESSBeaconTypeEddystoneEID = 2,
2021
};
2122

2223
typedef NS_ENUM(NSUInteger, ESSFrameType) {
2324
kESSEddystoneUnknownFrameType = 0,
24-
kESSEddystoneUIDFrameType = 1,
25+
kESSEddystoneUIDFrameType,
26+
kESSEddystoneURLFrameType,
27+
kESSEddystoneEIDFrameType,
2528
kESSEddystoneTelemetryFrameType,
2629
};
2730

@@ -33,8 +36,7 @@ typedef NS_ENUM(NSUInteger, ESSFrameType) {
3336
@interface ESSBeaconID : NSObject <NSCopying>
3437

3538
/**
36-
* Currently there's only the Eddystone format, but we'd like to leave the door open to other
37-
* possibilities, so let's have a beacon type here in the info.
39+
* The type of the beacon. Currently only a couple of types are supported.
3840
*/
3941
@property(nonatomic, assign, readonly) ESSBeaconType beaconType;
4042

@@ -59,7 +61,6 @@ typedef NS_ENUM(NSUInteger, ESSFrameType) {
5961
*/
6062
@property(nonatomic, strong, readonly) NSNumber *RSSI;
6163

62-
6364
/**
6465
* The beaconID for this Eddystone. All beacons have an ID.
6566
*/
@@ -77,28 +78,35 @@ typedef NS_ENUM(NSUInteger, ESSFrameType) {
7778
*/
7879
@property(nonatomic, strong, readonly) NSNumber *txPower;
7980

80-
8181
/**
8282
* The scanner has seen a frame for an Eddystone. We'll need to know what type of Eddystone frame
8383
* it is, as there are a few types.
8484
*/
85-
+ (ESSFrameType)frameTypeForFrame:(NSDictionary *)advFrameList;
85+
+ (ESSFrameType)frameTypeForFrame:(NSData *)frameData;
8686

8787
/**
88-
* Given some advertisement data that we have already verified is a TLM frame (using
89-
* frameTypeForFrame:), return the actual telemetry data for that frame.
88+
* Given the service data for a frame we know to be a UID frame, an RSSI sighting,
89+
* and -- optionally -- telemetry data (if we've seen it), create a new ESSBeaconInfo object to
90+
* represent this Eddystone
9091
*/
91-
+ (NSData *)telemetryDataForFrame:(NSDictionary *)advFrameList;
92+
+ (instancetype)beaconInfoForUIDFrameData:(NSData *)UIDFrameData
93+
telemetry:(NSData *)telemetry
94+
RSSI:(NSNumber *)initialRSSI;
9295

9396
/**
9497
* Given the service data for a frame we know to be a UID frame, an RSSI sighting,
9598
* and -- optionally -- telemetry data (if we've seen it), create a new ESSBeaconInfo object to
9699
* represent this Eddystone
97100
*/
98-
+ (instancetype)beaconInfoForUIDFrameData:(NSData *)UIDFrameData
101+
+ (instancetype)beaconInfoForEIDFrameData:(NSData *)EIDFrameData
99102
telemetry:(NSData *)telemetry
100103
RSSI:(NSNumber *)initialRSSI;
101104

105+
/**
106+
* If we're given a URL frame, extract the URL from it.
107+
*/
108+
+ (NSURL *)parseURLFromFrameData:(NSData *)URLFrameData;
109+
102110
/**
103111
* Convenience method to save everybody from creating these things all the time.
104112
*/

0 commit comments

Comments
 (0)