Skip to content

Commit e9d08bf

Browse files
authored
Merge pull request #91 from LoopKit/dev
Release 2.0
2 parents b3e15bf + b9e714a commit e9d08bf

File tree

110 files changed

+5162
-2785
lines changed

Some content is hidden

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

110 files changed

+5162
-2785
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ profile
1818
DerivedData
1919
*.hmap
2020
*.ipa
21+
project.xcworkspace
2122

2223
# Bundler
2324
.bundle
@@ -32,3 +33,4 @@ Carthage
3233
#
3334

3435
Pods/
36+

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: objective-c
2-
osx_image: xcode9
2+
osx_image: xcode9.3
33

44
# cache: cocoapods
55
# podfile: Example/Podfile
@@ -12,5 +12,7 @@ script:
1212
# Build cocoapods example project
1313
# - set -o pipefail && xcodebuild -workspace Example/xDripG5.xcworkspace -scheme xDripG5-Example -sdk iphonesimulator -destination name="iPhone SE" ONLY_ACTIVE_ARCH=NO | xcpretty
1414
# Build Travis project and run tests
15-
- xcodebuild -project xDripG5.xcodeproj -scheme xDripG5 -sdk iphonesimulator11.0 build -destination name="iPhone SE" test
15+
- xcodebuild -project CGMBLEKit.xcodeproj -scheme CGMBLEKit build -destination name="iPhone SE" test
16+
- xcodebuild -project CGMBLEKit.xcodeproj -scheme "CGMBLEKit Example" build -destination name="iPhone SE"
17+
- xcodebuild -project CGMBLEKit.xcodeproj -scheme ResetTransmitter build -destination name="iPhone SE"
1618
# - pod lib lint

Example/xDripG5/AppDelegate.swift renamed to CGMBLEKit Example/AppDelegate.swift

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,44 @@
77
//
88

99
import UIKit
10-
import xDripG5
10+
import CGMBLEKit
1111
import CoreBluetooth
1212

1313
@UIApplicationMain
14-
class AppDelegate: UIResponder, UIApplicationDelegate, TransmitterDelegate {
14+
class AppDelegate: UIResponder, UIApplicationDelegate, TransmitterDelegate, TransmitterCommandSource {
1515

1616
var window: UIWindow?
1717

1818
static var sharedDelegate: AppDelegate {
1919
return UIApplication.shared.delegate as! AppDelegate
2020
}
2121

22+
var transmitterID: String? {
23+
didSet {
24+
if let id = transmitterID {
25+
transmitter = Transmitter(
26+
id: id,
27+
passiveModeEnabled: UserDefaults.standard.passiveModeEnabled
28+
)
29+
transmitter?.stayConnected = UserDefaults.standard.stayConnected
30+
transmitter?.delegate = self
31+
transmitter?.commandSource = self
32+
33+
UserDefaults.standard.transmitterID = id
34+
}
35+
glucose = nil
36+
}
37+
}
38+
2239
var transmitter: Transmitter?
2340

41+
let commandQueue = CommandQueue()
42+
43+
var glucose: Glucose?
44+
2445
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
2546

26-
transmitter = Transmitter(
27-
ID: UserDefaults.standard.transmitterID,
28-
passiveModeEnabled: UserDefaults.standard.passiveModeEnabled
29-
)
30-
transmitter?.stayConnected = UserDefaults.standard.stayConnected
31-
transmitter?.delegate = self
47+
transmitterID = UserDefaults.standard.transmitterID
3248

3349
return true
3450
}
@@ -42,7 +58,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, TransmitterDelegate {
4258
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
4359
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
4460

45-
if let transmitter = transmitter , !transmitter.stayConnected {
61+
if let transmitter = transmitter, !transmitter.stayConnected {
4662
transmitter.stopScanning()
4763
}
4864
}
@@ -72,27 +88,48 @@ class AppDelegate: UIResponder, UIApplicationDelegate, TransmitterDelegate {
7288
return dateFormatter
7389
}()
7490

91+
func dequeuePendingCommand(for transmitter: Transmitter) -> Command? {
92+
return commandQueue.dequeue()
93+
}
94+
95+
func transmitter(_ transmitter: Transmitter, didFail command: Command, with error: Error) {
96+
// TODO: implement
97+
}
98+
99+
func transmitter(_ transmitter: Transmitter, didComplete command: Command) {
100+
// TODO: implement
101+
}
102+
75103
func transmitter(_ transmitter: Transmitter, didError error: Error) {
76-
if let vc = window?.rootViewController as? TransmitterDelegate {
77-
DispatchQueue.main.async {
104+
DispatchQueue.main.async {
105+
if let vc = self.window?.rootViewController as? TransmitterDelegate {
78106
vc.transmitter(transmitter, didError: error)
79107
}
80108
}
81109
}
82110

83111
func transmitter(_ transmitter: Transmitter, didRead glucose: Glucose) {
84-
if let vc = window?.rootViewController as? TransmitterDelegate {
85-
DispatchQueue.main.async {
112+
self.glucose = glucose
113+
DispatchQueue.main.async {
114+
if let vc = self.window?.rootViewController as? TransmitterDelegate {
86115
vc.transmitter(transmitter, didRead: glucose)
87116
}
88117
}
89118
}
90119

91120
func transmitter(_ transmitter: Transmitter, didReadUnknownData data: Data) {
92-
if let vc = window?.rootViewController as? TransmitterDelegate {
93-
DispatchQueue.main.async {
121+
DispatchQueue.main.async {
122+
if let vc = self.window?.rootViewController as? TransmitterDelegate {
94123
vc.transmitter(transmitter, didReadUnknownData: data)
95124
}
96125
}
97126
}
127+
128+
func transmitter(_ transmitter: Transmitter, didReadBackfill glucose: [Glucose]) {
129+
DispatchQueue.main.async {
130+
if let vc = self.window?.rootViewController as? TransmitterDelegate {
131+
vc.transmitter(transmitter, didReadBackfill: glucose)
132+
}
133+
}
134+
}
98135
}

Example/xDripG5/Assets.xcassets/AppIcon.appiconset/Contents.json renamed to CGMBLEKit Example/Assets.xcassets/AppIcon.appiconset/Contents.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
{
22
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"size" : "20x20",
6+
"scale" : "2x"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"size" : "20x20",
11+
"scale" : "3x"
12+
},
313
{
414
"idiom" : "iphone",
515
"size" : "29x29",
@@ -30,6 +40,16 @@
3040
"size" : "60x60",
3141
"scale" : "3x"
3242
},
43+
{
44+
"idiom" : "ipad",
45+
"size" : "20x20",
46+
"scale" : "1x"
47+
},
48+
{
49+
"idiom" : "ipad",
50+
"size" : "20x20",
51+
"scale" : "2x"
52+
},
3353
{
3454
"idiom" : "ipad",
3555
"size" : "29x29",
@@ -64,6 +84,11 @@
6484
"idiom" : "ipad",
6585
"size" : "83.5x83.5",
6686
"scale" : "2x"
87+
},
88+
{
89+
"idiom" : "ios-marketing",
90+
"size" : "1024x1024",
91+
"scale" : "1x"
6792
}
6893
],
6994
"info" : {

Example/xDripG5/Base.lproj/LaunchScreen.storyboard renamed to CGMBLEKit Example/Base.lproj/LaunchScreen.storyboard

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
33
<dependencies>
4-
<deployment identifier="iOS"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
6+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
67
</dependencies>
78
<scenes>
89
<!--View Controller-->
910
<scene sceneID="EHf-IW-A2E">
1011
<objects>
1112
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
12-
<layoutGuides>
13-
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
14-
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
15-
</layoutGuides>
1613
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
17-
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
14+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
1815
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
19-
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
16+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
17+
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
2018
</view>
2119
</viewController>
2220
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>

0 commit comments

Comments
 (0)