Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,26 @@ class AppDelegate: UIResponder, UIApplicationDelegate, TransmitterDelegate {
return UIApplication.shared.delegate as! AppDelegate
}

var transmitterID: String? {
didSet {
if let id = transmitterID {
transmitter = Transmitter(
id: id,
passiveModeEnabled: UserDefaults.standard.passiveModeEnabled
)
transmitter?.stayConnected = UserDefaults.standard.stayConnected
transmitter?.delegate = self

UserDefaults.standard.transmitterID = id
}
}
}

var transmitter: Transmitter?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

transmitter = Transmitter(
ID: UserDefaults.standard.transmitterID,
passiveModeEnabled: UserDefaults.standard.passiveModeEnabled
)
transmitter?.stayConnected = UserDefaults.standard.stayConnected
transmitter?.delegate = self
transmitterID = UserDefaults.standard.transmitterID

return true
}
Expand All @@ -42,7 +52,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, TransmitterDelegate {
// 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.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.

if let transmitter = transmitter , !transmitter.stayConnected {
if let transmitter = transmitter, !transmitter.stayConnected {
transmitter.stopScanning()
}
}
Expand Down Expand Up @@ -73,24 +83,24 @@ class AppDelegate: UIResponder, UIApplicationDelegate, TransmitterDelegate {
}()

func transmitter(_ transmitter: Transmitter, didError error: Error) {
if let vc = window?.rootViewController as? TransmitterDelegate {
DispatchQueue.main.async {
DispatchQueue.main.async {
if let vc = self.window?.rootViewController as? TransmitterDelegate {
vc.transmitter(transmitter, didError: error)
}
}
}

func transmitter(_ transmitter: Transmitter, didRead glucose: Glucose) {
if let vc = window?.rootViewController as? TransmitterDelegate {
DispatchQueue.main.async {
DispatchQueue.main.async {
if let vc = self.window?.rootViewController as? TransmitterDelegate {
vc.transmitter(transmitter, didRead: glucose)
}
}
}

func transmitter(_ transmitter: Transmitter, didReadUnknownData data: Data) {
if let vc = window?.rootViewController as? TransmitterDelegate {
DispatchQueue.main.async {
DispatchQueue.main.async {
if let vc = self.window?.rootViewController as? TransmitterDelegate {
vc.transmitter(transmitter, didReadUnknownData: data)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Expand Down Expand Up @@ -30,6 +40,16 @@
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
Expand Down Expand Up @@ -64,6 +84,11 @@
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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">
<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">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand Down
File renamed without changes.
13 changes: 8 additions & 5 deletions Example/xDripG5/Info.plist → CGMBLEKit Example/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
Expand All @@ -15,9 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.4.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
Expand All @@ -32,15 +30,20 @@
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>bluetooth-le</string>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,10 @@ class ViewController: UIViewController, TransmitterDelegate, UITextFieldDelegate
if let text = textField.text {
let newString = text.replacingCharacters(in: range.rangeOfString(text), with: string)

if newString.characters.count > 6 {
if newString.count > 6 {
return false
} else if newString.characters.count == 6 {
AppDelegate.sharedDelegate.transmitter?.ID = newString
UserDefaults.standard.transmitterID = newString

} else if newString.count == 6 {
AppDelegate.sharedDelegate.transmitterID = newString
textField.text = newString

textField.resignFirstResponder()
Expand All @@ -86,7 +84,7 @@ class ViewController: UIViewController, TransmitterDelegate, UITextFieldDelegate
}

func textFieldDidEndEditing(_ textField: UITextField) {
if textField.text?.characters.count != 6 {
if textField.text?.count != 6 {
textField.text = UserDefaults.standard.transmitterID
}
}
Expand All @@ -102,6 +100,7 @@ class ViewController: UIViewController, TransmitterDelegate, UITextFieldDelegate
// MARK: - TransmitterDelegate

func transmitter(_ transmitter: Transmitter, didError error: Error) {
print("Transmitter Error: \(error)")
titleLabel.text = NSLocalizedString("Error", comment: "Title displayed during error response")

subtitleLabel.text = "\(error)"
Expand Down Expand Up @@ -129,8 +128,8 @@ class ViewController: UIViewController, TransmitterDelegate, UITextFieldDelegate

private extension NSRange {
func rangeOfString(_ string: String) -> Range<String.Index> {
let startIndex = string.characters.index(string.startIndex, offsetBy: location)
let endIndex = string.characters.index(startIndex, offsetBy: length)
let startIndex = string.index(string.startIndex, offsetBy: location)
let endIndex = string.index(startIndex, offsetBy: length)
return startIndex..<endIndex
}
}
Expand Down
6 changes: 0 additions & 6 deletions Example/Podfile

This file was deleted.

16 changes: 0 additions & 16 deletions Example/Podfile.lock

This file was deleted.

Loading