first commit
This commit is contained in:
commit
eab090470e
213
.gitignore
vendored
Normal file
213
.gitignore
vendored
Normal file
@ -0,0 +1,213 @@
|
||||
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/macos,windows,linux,swift,c
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,windows,linux,swift,c
|
||||
|
||||
### C ###
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.ko
|
||||
*.obj
|
||||
*.elf
|
||||
|
||||
# Linker output
|
||||
*.ilk
|
||||
*.map
|
||||
*.exp
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
*.la
|
||||
*.lo
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
*.idb
|
||||
*.pdb
|
||||
|
||||
# Kernel Module Compile Results
|
||||
*.mod*
|
||||
*.cmd
|
||||
.tmp_versions/
|
||||
modules.order
|
||||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
|
||||
### Linux ###
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
### macOS ###
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
### Swift ###
|
||||
# Xcode
|
||||
#
|
||||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||
|
||||
## User settings
|
||||
xcuserdata/
|
||||
|
||||
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
|
||||
*.xcscmblueprint
|
||||
*.xccheckout
|
||||
|
||||
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
|
||||
build/
|
||||
DerivedData/
|
||||
*.moved-aside
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
|
||||
## Obj-C/Swift specific
|
||||
*.hmap
|
||||
|
||||
## App packaging
|
||||
*.ipa
|
||||
*.dSYM.zip
|
||||
*.dSYM
|
||||
|
||||
## Playgrounds
|
||||
timeline.xctimeline
|
||||
playground.xcworkspace
|
||||
|
||||
# Swift Package Manager
|
||||
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
|
||||
# Packages/
|
||||
# Package.pins
|
||||
# Package.resolved
|
||||
# *.xcodeproj
|
||||
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
|
||||
# hence it is not needed unless you have added a package configuration file to your project
|
||||
# .swiftpm
|
||||
|
||||
.build/
|
||||
|
||||
# CocoaPods
|
||||
# We recommend against adding the Pods directory to your .gitignore. However
|
||||
# you should judge for yourself, the pros and cons are mentioned at:
|
||||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
||||
# Pods/
|
||||
# Add this line if you want to avoid checking in source code from the Xcode workspace
|
||||
# *.xcworkspace
|
||||
|
||||
# Carthage
|
||||
# Add this line if you want to avoid checking in source code from Carthage dependencies.
|
||||
# Carthage/Checkouts
|
||||
|
||||
Carthage/Build/
|
||||
|
||||
# Accio dependency management
|
||||
Dependencies/
|
||||
.accio/
|
||||
|
||||
# fastlane
|
||||
# It is recommended to not store the screenshots in the git repo.
|
||||
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
|
||||
# For more information about the recommended setup visit:
|
||||
# https://docs.fastlane.tools/best-practices/source-control/#source-control
|
||||
|
||||
fastlane/report.xml
|
||||
fastlane/Preview.html
|
||||
fastlane/screenshots/**/*.png
|
||||
fastlane/test_output
|
||||
|
||||
# Code Injection
|
||||
# After new code Injection tools there's a generated folder /iOSInjectionProject
|
||||
# https://github.com/johnno1962/injectionforxcode
|
||||
|
||||
iOSInjectionProject/
|
||||
|
||||
### Windows ###
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/macos,windows,linux,swift,c
|
||||
354
PillTracker/PillTracker.xcodeproj/project.pbxproj
Normal file
354
PillTracker/PillTracker.xcodeproj/project.pbxproj
Normal file
@ -0,0 +1,354 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 50;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
504389FD25B3B4EF008C4BC0 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 504389FC25B3B4EF008C4BC0 /* AppDelegate.swift */; };
|
||||
504389FF25B3B4EF008C4BC0 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 504389FE25B3B4EF008C4BC0 /* SceneDelegate.swift */; };
|
||||
50438A0125B3B4EF008C4BC0 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50438A0025B3B4EF008C4BC0 /* ViewController.swift */; };
|
||||
50438A0425B3B4EF008C4BC0 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 50438A0225B3B4EF008C4BC0 /* Main.storyboard */; };
|
||||
50438A0625B3B4F0008C4BC0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 50438A0525B3B4F0008C4BC0 /* Assets.xcassets */; };
|
||||
50438A0925B3B4F0008C4BC0 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 50438A0725B3B4F0008C4BC0 /* LaunchScreen.storyboard */; };
|
||||
50438A1225B3B50E008C4BC0 /* SimpleBluetoothIO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50438A1125B3B50E008C4BC0 /* SimpleBluetoothIO.swift */; };
|
||||
50438A1525B3B52A008C4BC0 /* NSData+int8.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50438A1425B3B52A008C4BC0 /* NSData+int8.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
504389F925B3B4EF008C4BC0 /* PillTracker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PillTracker.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
504389FC25B3B4EF008C4BC0 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
504389FE25B3B4EF008C4BC0 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
|
||||
50438A0025B3B4EF008C4BC0 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
|
||||
50438A0325B3B4EF008C4BC0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||
50438A0525B3B4F0008C4BC0 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
50438A0825B3B4F0008C4BC0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
50438A0A25B3B4F0008C4BC0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
50438A1125B3B50E008C4BC0 /* SimpleBluetoothIO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimpleBluetoothIO.swift; sourceTree = "<group>"; };
|
||||
50438A1425B3B52A008C4BC0 /* NSData+int8.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSData+int8.swift"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
504389F625B3B4EF008C4BC0 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
504389F025B3B4EF008C4BC0 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
504389FB25B3B4EF008C4BC0 /* PillTracker */,
|
||||
504389FA25B3B4EF008C4BC0 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
504389FA25B3B4EF008C4BC0 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
504389F925B3B4EF008C4BC0 /* PillTracker.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
504389FB25B3B4EF008C4BC0 /* PillTracker */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
504389FC25B3B4EF008C4BC0 /* AppDelegate.swift */,
|
||||
504389FE25B3B4EF008C4BC0 /* SceneDelegate.swift */,
|
||||
50438A0025B3B4EF008C4BC0 /* ViewController.swift */,
|
||||
50438A0225B3B4EF008C4BC0 /* Main.storyboard */,
|
||||
50438A0525B3B4F0008C4BC0 /* Assets.xcassets */,
|
||||
50438A0725B3B4F0008C4BC0 /* LaunchScreen.storyboard */,
|
||||
50438A0A25B3B4F0008C4BC0 /* Info.plist */,
|
||||
50438A1125B3B50E008C4BC0 /* SimpleBluetoothIO.swift */,
|
||||
50438A1425B3B52A008C4BC0 /* NSData+int8.swift */,
|
||||
);
|
||||
path = PillTracker;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
504389F825B3B4EF008C4BC0 /* PillTracker */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 50438A0D25B3B4F0008C4BC0 /* Build configuration list for PBXNativeTarget "PillTracker" */;
|
||||
buildPhases = (
|
||||
504389F525B3B4EF008C4BC0 /* Sources */,
|
||||
504389F625B3B4EF008C4BC0 /* Frameworks */,
|
||||
504389F725B3B4EF008C4BC0 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = PillTracker;
|
||||
productName = PillTracker;
|
||||
productReference = 504389F925B3B4EF008C4BC0 /* PillTracker.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
504389F125B3B4EF008C4BC0 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 1230;
|
||||
LastUpgradeCheck = 1230;
|
||||
TargetAttributes = {
|
||||
504389F825B3B4EF008C4BC0 = {
|
||||
CreatedOnToolsVersion = 12.3;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 504389F425B3B4EF008C4BC0 /* Build configuration list for PBXProject "PillTracker" */;
|
||||
compatibilityVersion = "Xcode 9.3";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = 504389F025B3B4EF008C4BC0;
|
||||
productRefGroup = 504389FA25B3B4EF008C4BC0 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
504389F825B3B4EF008C4BC0 /* PillTracker */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
504389F725B3B4EF008C4BC0 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
50438A0925B3B4F0008C4BC0 /* LaunchScreen.storyboard in Resources */,
|
||||
50438A0625B3B4F0008C4BC0 /* Assets.xcassets in Resources */,
|
||||
50438A0425B3B4EF008C4BC0 /* Main.storyboard in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
504389F525B3B4EF008C4BC0 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
50438A0125B3B4EF008C4BC0 /* ViewController.swift in Sources */,
|
||||
504389FD25B3B4EF008C4BC0 /* AppDelegate.swift in Sources */,
|
||||
50438A1225B3B50E008C4BC0 /* SimpleBluetoothIO.swift in Sources */,
|
||||
504389FF25B3B4EF008C4BC0 /* SceneDelegate.swift in Sources */,
|
||||
50438A1525B3B52A008C4BC0 /* NSData+int8.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
50438A0225B3B4EF008C4BC0 /* Main.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
50438A0325B3B4EF008C4BC0 /* Base */,
|
||||
);
|
||||
name = Main.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
50438A0725B3B4F0008C4BC0 /* LaunchScreen.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
50438A0825B3B4F0008C4BC0 /* Base */,
|
||||
);
|
||||
name = LaunchScreen.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
50438A0B25B3B4F0008C4BC0 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.3;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
50438A0C25B3B4F0008C4BC0 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.3;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
50438A0E25B3B4F0008C4BC0 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = 36JR976L6Y;
|
||||
INFOPLIST_FILE = PillTracker/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = mh.smt.PillTracker;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
50438A0F25B3B4F0008C4BC0 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = 36JR976L6Y;
|
||||
INFOPLIST_FILE = PillTracker/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = mh.smt.PillTracker;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
504389F425B3B4EF008C4BC0 /* Build configuration list for PBXProject "PillTracker" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
50438A0B25B3B4F0008C4BC0 /* Debug */,
|
||||
50438A0C25B3B4F0008C4BC0 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
50438A0D25B3B4F0008C4BC0 /* Build configuration list for PBXNativeTarget "PillTracker" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
50438A0E25B3B4F0008C4BC0 /* Debug */,
|
||||
50438A0F25B3B4F0008C4BC0 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 504389F125B3B4EF008C4BC0 /* Project object */;
|
||||
}
|
||||
7
PillTracker/PillTracker.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
7
PillTracker/PillTracker.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
36
PillTracker/PillTracker/AppDelegate.swift
Normal file
36
PillTracker/PillTracker/AppDelegate.swift
Normal file
@ -0,0 +1,36 @@
|
||||
//
|
||||
// AppDelegate.swift
|
||||
// PillTracker
|
||||
//
|
||||
// Created by Max Hunt on 16/01/2021.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
@main
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
// Override point for customization after application launch.
|
||||
return true
|
||||
}
|
||||
|
||||
// MARK: UISceneSession Lifecycle
|
||||
|
||||
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
|
||||
// Called when a new scene session is being created.
|
||||
// Use this method to select a configuration to create the new scene with.
|
||||
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
|
||||
// Called when the user discards a scene session.
|
||||
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
|
||||
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "60x60"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "60x60"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "76x76"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "76x76"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "83.5x83.5"
|
||||
},
|
||||
{
|
||||
"idiom" : "ios-marketing",
|
||||
"scale" : "1x",
|
||||
"size" : "1024x1024"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
6
PillTracker/PillTracker/Assets.xcassets/Contents.json
Normal file
6
PillTracker/PillTracker/Assets.xcassets/Contents.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
25
PillTracker/PillTracker/Base.lproj/LaunchScreen.storyboard
Normal file
25
PillTracker/PillTracker/Base.lproj/LaunchScreen.storyboard
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||
<dependencies>
|
||||
<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">
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="53" y="375"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
||||
150
PillTracker/PillTracker/Base.lproj/Main.storyboard
Normal file
150
PillTracker/PillTracker/Base.lproj/Main.storyboard
Normal file
@ -0,0 +1,150 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
|
||||
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="System colors in document resources" minToolsVersion="11.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="tne-QT-ifu">
|
||||
<objects>
|
||||
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="PillTracker" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gsL-Nw-5C6">
|
||||
<rect key="frame" x="161" y="145" width="91" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<state key="normal" title="TOGGLE LED"/>
|
||||
<connections>
|
||||
<action selector="ledToggleButtonDown:" destination="BYZ-38-t0r" eventType="touchDown" id="NOl-I1-AC1"/>
|
||||
<action selector="ledToggleButtonUp:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Ocb-Oy-hor"/>
|
||||
</connections>
|
||||
</button>
|
||||
<switch opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="dHC-eT-3y1">
|
||||
<rect key="frame" x="217" y="44" width="49" height="31"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
</switch>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Debug" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="l2I-9J-rAh">
|
||||
<rect key="frame" x="151" y="49" width="58" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" white="0.63153754340000001" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Pills remaining:" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eKc-uP-L0m">
|
||||
<rect key="frame" x="78" y="494" width="131" height="24"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="20"/>
|
||||
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Pills consumed: " textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="llf-Dy-Aua">
|
||||
<rect key="frame" x="67" y="444" width="142" height="24"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="20"/>
|
||||
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="?" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SZM-0X-3rS">
|
||||
<rect key="frame" x="235" y="444" width="29" height="24"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="20"/>
|
||||
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="?" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Sjf-mb-Bwa">
|
||||
<rect key="frame" x="235" y="494" width="29" height="24"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="20"/>
|
||||
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="egw-kZ-OI5">
|
||||
<rect key="frame" x="155" y="317" width="102" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<state key="normal" title="Debug: update"/>
|
||||
<connections>
|
||||
<action selector="forcePillRefresh:" destination="BYZ-38-t0r" eventType="touchUpInside" id="UQT-N9-laF"/>
|
||||
</connections>
|
||||
</button>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Total pills" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="enT-hS-KDW">
|
||||
<rect key="frame" x="127" y="402" width="82" height="24"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="20"/>
|
||||
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="?" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="RoE-tt-hdb">
|
||||
<rect key="frame" x="235" y="402" width="29" height="24"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="20"/>
|
||||
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Detached" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UOg-gg-xCf">
|
||||
<rect key="frame" x="171" y="782" width="74" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" white="0.63153754340000001" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Not Connected" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IPv-5Y-fpG">
|
||||
<rect key="frame" x="107" y="735" width="201" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" white="0.63153754340000001" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="null" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ypx-xB-OqG">
|
||||
<rect key="frame" x="179" y="562" width="58" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" white="0.63153754340000001" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="QDW-f0-1g2">
|
||||
<rect key="frame" x="335" y="831" width="49" height="31"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<connections>
|
||||
<action selector="RefreshChanged:" destination="BYZ-38-t0r" eventType="valueChanged" id="5eH-SA-DZc"/>
|
||||
</connections>
|
||||
</switch>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Refresh" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SfF-TU-dkj">
|
||||
<rect key="frame" x="261" y="836" width="59" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" white="0.63153754340000001" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="cStatus" destination="IPv-5Y-fpG" id="nH6-UX-SMS"/>
|
||||
<outlet property="ledToggleButton" destination="gsL-Nw-5C6" id="JNW-T2-MJi"/>
|
||||
<outlet property="pillsAttached" destination="UOg-gg-xCf" id="z89-7E-zte"/>
|
||||
<outlet property="pillsConsumed" destination="SZM-0X-3rS" id="Iek-P9-4eb"/>
|
||||
<outlet property="pillsRemaining" destination="Sjf-mb-Bwa" id="U9l-SY-3Yc"/>
|
||||
<outlet property="pillsTotal" destination="RoE-tt-hdb" id="puK-A1-8MY"/>
|
||||
<outlet property="refreshToggle" destination="QDW-f0-1g2" id="RHw-cM-TJw"/>
|
||||
<outlet property="statusLabel" destination="Ypx-xB-OqG" id="n3K-B9-bWz"/>
|
||||
<outlet property="virtualButton" destination="dHC-eT-3y1" id="4Rz-rc-aYk"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="122" y="119"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<systemColor name="systemBackgroundColor">
|
||||
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</systemColor>
|
||||
</resources>
|
||||
</document>
|
||||
68
PillTracker/PillTracker/Info.plist
Normal file
68
PillTracker/PillTracker/Info.plist
Normal file
@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UIApplicationSceneManifest</key>
|
||||
<dict>
|
||||
<key>UIApplicationSupportsMultipleScenes</key>
|
||||
<false/>
|
||||
<key>UISceneConfigurations</key>
|
||||
<dict>
|
||||
<key>UIWindowSceneSessionRoleApplication</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>UISceneConfigurationName</key>
|
||||
<string>Default Configuration</string>
|
||||
<key>UISceneDelegateClassName</key>
|
||||
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
|
||||
<key>UISceneStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<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>
|
||||
<key>NSBluetoothAlwaysUsageDescription</key>
|
||||
<string>For Pill Detection</string>
|
||||
</dict>
|
||||
</plist>
|
||||
19
PillTracker/PillTracker/NSData+int8.swift
Normal file
19
PillTracker/PillTracker/NSData+int8.swift
Normal file
@ -0,0 +1,19 @@
|
||||
//
|
||||
// NSData+int8.swift
|
||||
// PillTracker
|
||||
//
|
||||
// Created by Max Hunt on 16/01/2021.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
extension Data {
|
||||
static func dataWithValue(value: Int8) -> Data {
|
||||
var variableValue = value
|
||||
return Data(buffer: UnsafeBufferPointer(start: &variableValue, count: 1))
|
||||
}
|
||||
|
||||
func int8Value() -> Int8 {
|
||||
return Int8(bitPattern: self[0])
|
||||
}
|
||||
}
|
||||
52
PillTracker/PillTracker/SceneDelegate.swift
Normal file
52
PillTracker/PillTracker/SceneDelegate.swift
Normal file
@ -0,0 +1,52 @@
|
||||
//
|
||||
// SceneDelegate.swift
|
||||
// PillTracker
|
||||
//
|
||||
// Created by Max Hunt on 16/01/2021.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
|
||||
var window: UIWindow?
|
||||
|
||||
|
||||
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
||||
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
|
||||
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
|
||||
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
|
||||
guard let _ = (scene as? UIWindowScene) else { return }
|
||||
}
|
||||
|
||||
func sceneDidDisconnect(_ scene: UIScene) {
|
||||
// Called as the scene is being released by the system.
|
||||
// This occurs shortly after the scene enters the background, or when its session is discarded.
|
||||
// Release any resources associated with this scene that can be re-created the next time the scene connects.
|
||||
// The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
|
||||
}
|
||||
|
||||
func sceneDidBecomeActive(_ scene: UIScene) {
|
||||
// Called when the scene has moved from an inactive state to an active state.
|
||||
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
|
||||
}
|
||||
|
||||
func sceneWillResignActive(_ scene: UIScene) {
|
||||
// Called when the scene will move from an active state to an inactive state.
|
||||
// This may occur due to temporary interruptions (ex. an incoming phone call).
|
||||
}
|
||||
|
||||
func sceneWillEnterForeground(_ scene: UIScene) {
|
||||
// Called as the scene transitions from the background to the foreground.
|
||||
// Use this method to undo the changes made on entering the background.
|
||||
}
|
||||
|
||||
func sceneDidEnterBackground(_ scene: UIScene) {
|
||||
// Called as the scene transitions from the foreground to the background.
|
||||
// Use this method to save data, release shared resources, and store enough scene-specific state information
|
||||
// to restore the scene back to its current state.
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
125
PillTracker/PillTracker/SimpleBluetoothIO.swift
Normal file
125
PillTracker/PillTracker/SimpleBluetoothIO.swift
Normal file
@ -0,0 +1,125 @@
|
||||
//
|
||||
// SimpleBluetoothIO.swift
|
||||
// PillTracker
|
||||
//
|
||||
// Created by Max Hunt on 16/01/2021.
|
||||
//
|
||||
|
||||
import CoreBluetooth
|
||||
|
||||
protocol SimpleBluetoothIODelegate: class {
|
||||
func simpleBluetoothIO(simpleBluetoothIO: SimpleBluetoothIO, didReceiveValue value: Int8)
|
||||
func simpleBluetoothIO(simpleBluetoothIO: SimpleBluetoothIO, didConnect value: Bool)
|
||||
func simpleBluetoothIO(simpleBluetoothIO: SimpleBluetoothIO, didDisconnect value: Bool)
|
||||
}
|
||||
|
||||
class SimpleBluetoothIO: NSObject {
|
||||
let serviceUUID: String
|
||||
weak var delegate: SimpleBluetoothIODelegate?
|
||||
|
||||
var centralManager: CBCentralManager!
|
||||
var connectedPeripheral: CBPeripheral?
|
||||
var targetService: CBService?
|
||||
var writableCharacteristic: CBCharacteristic?
|
||||
var connected = false
|
||||
|
||||
init(serviceUUID: String, delegate: SimpleBluetoothIODelegate?) {
|
||||
self.serviceUUID = serviceUUID
|
||||
self.delegate = delegate
|
||||
|
||||
super.init()
|
||||
|
||||
centralManager = CBCentralManager(delegate: self, queue: nil)
|
||||
|
||||
}
|
||||
|
||||
func writeValue(value: Int8) {
|
||||
guard let peripheral = connectedPeripheral, let characteristic = writableCharacteristic else {
|
||||
return
|
||||
}
|
||||
|
||||
let data = Data.dataWithValue(value: value)
|
||||
peripheral.writeValue(data, for: characteristic, type: .withResponse)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension SimpleBluetoothIO: CBCentralManagerDelegate {
|
||||
func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {
|
||||
peripheral.discoverServices(nil)
|
||||
self.connected = true
|
||||
print("Connected! With \(peripheral.name)")
|
||||
delegate?.simpleBluetoothIO(simpleBluetoothIO: self, didConnect: true)
|
||||
}
|
||||
|
||||
func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
|
||||
connectedPeripheral = peripheral
|
||||
if (peripheral.name != "[TV] Samsung Q7 Series (55)" && peripheral.name != "MacDeMax"){
|
||||
print("Discovered \(peripheral.name)")
|
||||
}
|
||||
if (peripheral.name != nil) {
|
||||
if(((peripheral.name?.contains("PILL_TRACKER"))!))
|
||||
{
|
||||
if let connectedPeripheral = connectedPeripheral {
|
||||
connectedPeripheral.delegate = self
|
||||
centralManager.connect(connectedPeripheral, options: nil)
|
||||
}
|
||||
centralManager.stopScan()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func centralManagerDidUpdateState(_ central: CBCentralManager) {
|
||||
if central.state == .poweredOn {
|
||||
// centralManager.scanForPeripherals(withServices: [CBUUID(string: serviceUUID)], options: nil)
|
||||
centralManager.scanForPeripherals(withServices: nil, options: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension SimpleBluetoothIO: CBPeripheralDelegate {
|
||||
func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) {
|
||||
guard let services = peripheral.services else {
|
||||
return
|
||||
}
|
||||
|
||||
targetService = services.first
|
||||
if let service = services.first {
|
||||
targetService = service
|
||||
peripheral.discoverCharacteristics(nil, for: service)
|
||||
}
|
||||
}
|
||||
|
||||
func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) {
|
||||
guard let characteristics = service.characteristics else {
|
||||
return
|
||||
}
|
||||
|
||||
for characteristic in characteristics {
|
||||
if characteristic.properties.contains(.write) || characteristic.properties.contains(.writeWithoutResponse) {
|
||||
writableCharacteristic = characteristic
|
||||
}
|
||||
peripheral.setNotifyValue(true, for: characteristic)
|
||||
}
|
||||
}
|
||||
|
||||
func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
|
||||
guard let data = characteristic.value, let delegate = delegate else {
|
||||
return
|
||||
}
|
||||
|
||||
delegate.simpleBluetoothIO(simpleBluetoothIO: self, didReceiveValue: data.int8Value())
|
||||
}
|
||||
|
||||
func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) {
|
||||
print("Disconnected: \(peripheral.name)")
|
||||
print("Restarting scan...")
|
||||
centralManager.scanForPeripherals(withServices: nil, options: nil)
|
||||
delegate?.simpleBluetoothIO(simpleBluetoothIO: self, didDisconnect: true)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
122
PillTracker/PillTracker/ViewController.swift
Normal file
122
PillTracker/PillTracker/ViewController.swift
Normal file
@ -0,0 +1,122 @@
|
||||
//
|
||||
// ViewController.swift
|
||||
// PillTracker
|
||||
//
|
||||
// Created by Max Hunt on 16/01/2021.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class ViewController: UIViewController {
|
||||
var simpleBluetoothIO: SimpleBluetoothIO!
|
||||
|
||||
@IBOutlet var virtualButton:UISwitch!
|
||||
@IBOutlet weak var ledToggleButton: UIButton!
|
||||
@IBOutlet weak var statusLabel: UILabel!
|
||||
@IBOutlet weak var cStatus: UILabel!
|
||||
@IBOutlet weak var pillsConsumed: UILabel!
|
||||
@IBOutlet weak var pillsRemaining: UILabel!
|
||||
@IBOutlet weak var pillsTotal: UILabel!
|
||||
@IBOutlet weak var pillsAttached: UILabel!
|
||||
@IBOutlet weak var refreshToggle: UISwitch!
|
||||
|
||||
let totalPills: Int = 6
|
||||
let updateFreq: Float = 2.0
|
||||
weak var timer: Timer?
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
overrideUserInterfaceStyle = .light
|
||||
simpleBluetoothIO = SimpleBluetoothIO(serviceUUID: "4fafc201-1fb5-459e-8fcc-c5c9c331914b", delegate: self)
|
||||
// startTimer()
|
||||
|
||||
}
|
||||
|
||||
deinit {
|
||||
stopTimer()
|
||||
}
|
||||
|
||||
func sendUpdateCommand(){
|
||||
print("Sending update command...")
|
||||
simpleBluetoothIO.writeValue(value: 51)
|
||||
}
|
||||
|
||||
func startTimer() {
|
||||
timer?.invalidate() // just in case you had existing `Timer`, `invalidate` it before we lose our reference to it
|
||||
timer = Timer.scheduledTimer(withTimeInterval: TimeInterval(updateFreq), repeats: true) { [weak self] _ in
|
||||
self?.sendUpdateCommand()
|
||||
}
|
||||
}
|
||||
|
||||
func stopTimer() {
|
||||
timer?.invalidate()
|
||||
}
|
||||
|
||||
@IBAction func ledToggleButtonDown(_ sender: UIButton) {
|
||||
simpleBluetoothIO.writeValue(value:49)
|
||||
}
|
||||
|
||||
@IBAction func ledToggleButtonUp(_ sender: UIButton) {
|
||||
simpleBluetoothIO.writeValue(value: 50)
|
||||
}
|
||||
|
||||
@IBAction func forcePillRefresh(_ sender: UIButton) {
|
||||
self.sendUpdateCommand()
|
||||
}
|
||||
@IBAction func RefreshChanged(_ sender: Any) {
|
||||
if self.refreshToggle.isOn {
|
||||
startTimer()
|
||||
} else {
|
||||
stopTimer()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension ViewController: SimpleBluetoothIODelegate {
|
||||
func simpleBluetoothIO(simpleBluetoothIO: SimpleBluetoothIO, didReceiveValue value: Int8) {
|
||||
self.statusLabel.text = String(value)
|
||||
print(value)
|
||||
if value == 98 {
|
||||
//view.backgroundColor = UIColor.yellow
|
||||
virtualButton.setOn(true, animated: true)
|
||||
} else if value == 99 {
|
||||
//view.backgroundColor = UIColor.black
|
||||
virtualButton.setOn(false, animated: true)
|
||||
} else if value == 55 {
|
||||
self.pillsConsumed.text = "X"
|
||||
self.pillsRemaining.text = "X"
|
||||
self.pillsTotal.text = "X"
|
||||
self.pillsAttached.text = "Detached"
|
||||
self.pillsAttached.textColor = UIColor.red
|
||||
} else {
|
||||
let remainingPills = Int(value)
|
||||
let usedPills = self.totalPills - remainingPills
|
||||
self.pillsConsumed.text = String(usedPills)
|
||||
self.pillsRemaining.text = String(remainingPills)
|
||||
self.pillsTotal.text = String(self.totalPills)
|
||||
self.pillsAttached.text = "Attached"
|
||||
self.pillsAttached.textColor = UIColor.green
|
||||
}
|
||||
}
|
||||
|
||||
func simpleBluetoothIO(simpleBluetoothIO: SimpleBluetoothIO, didConnect value: Bool) {
|
||||
print("VC: connect: \(value)")
|
||||
self.cStatus.text = "Connected!"
|
||||
self.cStatus.textColor = UIColor.green
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
|
||||
print("Sending update commend")
|
||||
self.sendUpdateCommand()
|
||||
}
|
||||
}
|
||||
|
||||
func simpleBluetoothIO(simpleBluetoothIO: SimpleBluetoothIO, didDisconnect value: Bool) {
|
||||
print("VC: disconnect: \(value)")
|
||||
self.cStatus.text = "Disconnected..."
|
||||
self.cStatus.textColor = UIColor.red
|
||||
self.pillsAttached.text = "Detached"
|
||||
self.pillsAttached.textColor = UIColor.red
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
167
embedded/main/main.ino
Normal file
167
embedded/main/main.ino
Normal file
@ -0,0 +1,167 @@
|
||||
#include <BLEDevice.h>
|
||||
#include <BLEUtils.h>
|
||||
#include <BLEServer.h>
|
||||
|
||||
// See the following for generating UUIDs:
|
||||
// https://www.uuidgenerator.net/
|
||||
|
||||
#define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
|
||||
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"
|
||||
|
||||
#define LED_PIN 2
|
||||
#define BTN_PIN 5
|
||||
|
||||
#define PILL_1_PIN 25
|
||||
#define PILL_2_PIN 13
|
||||
#define PILL_3_PIN 12
|
||||
#define PILL_4_PIN 26
|
||||
#define PILL_5_PIN 27
|
||||
#define PILL_6_PIN 14
|
||||
#define DETECT_PIN 18
|
||||
|
||||
|
||||
int deviceConnected = false;
|
||||
|
||||
int waitingForUpdate = 0;
|
||||
|
||||
|
||||
class MyCallbacks: public BLECharacteristicCallbacks {
|
||||
void onConnect(BLEServer* pServer) {
|
||||
deviceConnected = true;
|
||||
Serial.println("device connected");
|
||||
};
|
||||
|
||||
void onDisconnect(BLEServer* pServer) {
|
||||
deviceConnected = false;
|
||||
Serial.println("device disconnected");
|
||||
}
|
||||
void onWrite(BLECharacteristic *pCharacteristic) {
|
||||
std::string value = pCharacteristic->getValue();
|
||||
|
||||
if (value.length() > 0) {
|
||||
Serial.print("*********");
|
||||
Serial.print(value.c_str());
|
||||
Serial.print("-");
|
||||
Serial.print(atoi(value.c_str()));
|
||||
Serial.print("-");
|
||||
if(atoi(value.c_str())==1)
|
||||
{
|
||||
digitalWrite(LED_PIN,HIGH);
|
||||
Serial.print("LEDON");
|
||||
}
|
||||
else if (atoi(value.c_str())==2)
|
||||
{
|
||||
digitalWrite(LED_PIN,LOW);
|
||||
Serial.print("LEDOFF");
|
||||
}
|
||||
else if (atoi(value.c_str())==3)
|
||||
{
|
||||
Serial.print("UPDATE_PILL_TRACK");
|
||||
waitingForUpdate = 1;
|
||||
}
|
||||
else {
|
||||
Serial.println();
|
||||
Serial.println(atoi(value.c_str()));
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
Serial.println("*********");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
BLECharacteristic *pCharacteristic;
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
pinMode(LED_PIN,OUTPUT);
|
||||
|
||||
pinMode(PILL_1_PIN,INPUT_PULLUP);
|
||||
pinMode(PILL_2_PIN,INPUT_PULLUP);
|
||||
pinMode(PILL_3_PIN,INPUT_PULLUP);
|
||||
pinMode(PILL_4_PIN,INPUT_PULLUP);
|
||||
pinMode(PILL_5_PIN,INPUT_PULLUP);
|
||||
pinMode(PILL_6_PIN,INPUT_PULLUP);
|
||||
|
||||
pinMode(BTN_PIN,INPUT_PULLUP);
|
||||
pinMode(DETECT_PIN,INPUT_PULLUP);
|
||||
|
||||
|
||||
digitalWrite(LED_PIN,LOW);
|
||||
Serial.println("1- Download and install an BLE scanner app in your phone");
|
||||
Serial.println("2- Scan for BLE devices in the app");
|
||||
Serial.println("3- Connect to MyESP32");
|
||||
Serial.println("4- Go to CUSTOM CHARACTERISTIC in CUSTOM SERVICE and write something");
|
||||
Serial.println("5- See the magic =)");
|
||||
|
||||
BLEDevice::init("PILL_TRACKER");
|
||||
BLEServer *pServer = BLEDevice::createServer();
|
||||
|
||||
BLEService *pService = pServer->createService(SERVICE_UUID);
|
||||
|
||||
pCharacteristic= pService->createCharacteristic(
|
||||
CHARACTERISTIC_UUID,
|
||||
BLECharacteristic::PROPERTY_READ |
|
||||
BLECharacteristic::PROPERTY_WRITE |
|
||||
BLECharacteristic::PROPERTY_NOTIFY
|
||||
);
|
||||
|
||||
pCharacteristic->setCallbacks(new MyCallbacks());
|
||||
|
||||
pCharacteristic->setValue("Hello World");
|
||||
pService->start();
|
||||
|
||||
BLEAdvertising *pAdvertising = pServer->getAdvertising();
|
||||
pAdvertising->start();
|
||||
}
|
||||
int prevVal = LOW;
|
||||
int prevVal2 = LOW;
|
||||
|
||||
int getPillCount() {
|
||||
int totalIntact = 0;
|
||||
if(digitalRead(DETECT_PIN) == LOW) {
|
||||
Serial.println("PROBE_ATTACHED");
|
||||
if(digitalRead(PILL_1_PIN) == LOW){totalIntact++;Serial.println("25:FULL");}
|
||||
if(digitalRead(PILL_2_PIN) == LOW){totalIntact++;Serial.println("13:FULL");}
|
||||
if(digitalRead(PILL_3_PIN) == LOW){totalIntact++;Serial.println("12:FULL");}
|
||||
if(digitalRead(PILL_4_PIN) == LOW){totalIntact++;Serial.println("26:FULL");}
|
||||
if(digitalRead(PILL_5_PIN) == LOW){totalIntact++;Serial.println("27:FULL");}
|
||||
if(digitalRead(PILL_6_PIN) == LOW){totalIntact++;Serial.println("14:FULL");}
|
||||
}
|
||||
else {
|
||||
Serial.println("PROBE_DETACHED");
|
||||
totalIntact = 55;
|
||||
}
|
||||
return totalIntact;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
|
||||
int currentVal = digitalRead(BTN_PIN);
|
||||
if(currentVal!=prevVal)
|
||||
{
|
||||
prevVal=currentVal;
|
||||
if(currentVal==HIGH)
|
||||
{
|
||||
int value = 99;
|
||||
pCharacteristic->setValue((uint8_t*)&value, 4);
|
||||
pCharacteristic->notify();
|
||||
}
|
||||
else
|
||||
{
|
||||
int value = 98;
|
||||
pCharacteristic->setValue((uint8_t*)&value, 4);
|
||||
pCharacteristic->notify();
|
||||
}
|
||||
}
|
||||
|
||||
if(waitingForUpdate == 1){
|
||||
Serial.println("**********************************");
|
||||
Serial.println("**************UPDATE AND SEND PILL COUNT********************");
|
||||
Serial.println("**********************************");
|
||||
waitingForUpdate = 0;
|
||||
int value = getPillCount();
|
||||
pCharacteristic->setValue((uint8_t*)&value, 4);
|
||||
pCharacteristic->notify();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user