Commit ac9763e7b82944aa3387d9653048214433639e05
1 parent
211744a9
fix:ota file to run
Showing
12 changed files
with
426 additions
and
325 deletions
HDFwear.xcodeproj/project.pbxproj
... | ... | @@ -280,7 +280,6 @@ |
280 | 280 | 6CFEEBC02773353700621863 /* BOReferenceVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CFEEBBF2773353700621863 /* BOReferenceVC.swift */; }; |
281 | 281 | 6CFEEBC22773354500621863 /* HRReferenceVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CFEEBC12773354500621863 /* HRReferenceVC.swift */; }; |
282 | 282 | 6CFEEBC42773355700621863 /* SleepReferenceVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CFEEBC32773355700621863 /* SleepReferenceVC.swift */; }; |
283 | - 84067DB52B5E67DC0030E30E /* OTA in Resources */ = {isa = PBXBuildFile; fileRef = 84067DB42B5E67DC0030E30E /* OTA */; }; | |
284 | 283 | 844959782B48EF900029E2E0 /* BluetoothManager+Deprecated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844959772B48EF900029E2E0 /* BluetoothManager+Deprecated.swift */; }; |
285 | 284 | 845ADEA12B551C8E00C3AD73 /* NewStepModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845ADEA02B551C8E00C3AD73 /* NewStepModel.swift */; }; |
286 | 285 | 8473FB622B4BF1A200409148 /* TaskManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8473FB612B4BF1A200409148 /* TaskManager.swift */; }; |
... | ... | @@ -288,6 +287,10 @@ |
288 | 287 | 847672B82B074E43007DC2DE /* NewBeiDouContactModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847672B72B074E43007DC2DE /* NewBeiDouContactModel.swift */; }; |
289 | 288 | 8477B04C2B5A243B0018ADA8 /* NewExerciseRealtimeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8477B04B2B5A243B0018ADA8 /* NewExerciseRealtimeModel.swift */; }; |
290 | 289 | 8477B04E2B5A79EE0018ADA8 /* NewExerciseModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8477B04D2B5A79EE0018ADA8 /* NewExerciseModel.swift */; }; |
290 | + 84792A222B5FACAC00851211 /* LETransceiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 84792A1F2B5FACAB00851211 /* LETransceiver.m */; }; | |
291 | + 84792A232B5FACAC00851211 /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = 84792A202B5FACAB00851211 /* Utils.m */; }; | |
292 | + 84792A242B5FACAC00851211 /* RemoteStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 84792A1D2B5FACAB00851211 /* RemoteStatus.m */; }; | |
293 | + 84792A252B5FACAC00851211 /* OTAManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 84792A1B2B5FACAB00851211 /* OTAManager.m */; }; | |
291 | 294 | 847AF36E2B4CF35F00E3456E /* NewSleepModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847AF36D2B4CF35F00E3456E /* NewSleepModel.swift */; }; |
292 | 295 | 847B88EF2B5780CA00851EE7 /* NewIntensiveTimeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847B88EE2B5780CA00851EE7 /* NewIntensiveTimeModel.swift */; }; |
293 | 296 | 84DA399D2B4D3A5B008D34A9 /* NewGpsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84DA399C2B4D3A5B008D34A9 /* NewGpsModel.swift */; }; |
... | ... | @@ -663,7 +666,6 @@ |
663 | 666 | 6CFEEBBF2773353700621863 /* BOReferenceVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BOReferenceVC.swift; sourceTree = "<group>"; }; |
664 | 667 | 6CFEEBC12773354500621863 /* HRReferenceVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HRReferenceVC.swift; sourceTree = "<group>"; }; |
665 | 668 | 6CFEEBC32773355700621863 /* SleepReferenceVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SleepReferenceVC.swift; sourceTree = "<group>"; }; |
666 | - 84067DB42B5E67DC0030E30E /* OTA */ = {isa = PBXFileReference; lastKnownFileType = folder; path = OTA; sourceTree = "<group>"; }; | |
667 | 669 | 844959772B48EF900029E2E0 /* BluetoothManager+Deprecated.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BluetoothManager+Deprecated.swift"; sourceTree = "<group>"; }; |
668 | 670 | 845ADE9F2B5507FA00C3AD73 /* 20240126ReadMe.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = 20240126ReadMe.md; sourceTree = "<group>"; }; |
669 | 671 | 845ADEA02B551C8E00C3AD73 /* NewStepModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewStepModel.swift; sourceTree = "<group>"; }; |
... | ... | @@ -672,6 +674,14 @@ |
672 | 674 | 847672B72B074E43007DC2DE /* NewBeiDouContactModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewBeiDouContactModel.swift; sourceTree = "<group>"; }; |
673 | 675 | 8477B04B2B5A243B0018ADA8 /* NewExerciseRealtimeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewExerciseRealtimeModel.swift; sourceTree = "<group>"; }; |
674 | 676 | 8477B04D2B5A79EE0018ADA8 /* NewExerciseModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewExerciseModel.swift; sourceTree = "<group>"; }; |
677 | + 84792A1B2B5FACAB00851211 /* OTAManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OTAManager.m; sourceTree = "<group>"; }; | |
678 | + 84792A1C2B5FACAB00851211 /* Utils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Utils.h; sourceTree = "<group>"; }; | |
679 | + 84792A1D2B5FACAB00851211 /* RemoteStatus.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RemoteStatus.m; sourceTree = "<group>"; }; | |
680 | + 84792A1E2B5FACAB00851211 /* OTAManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OTAManager.h; sourceTree = "<group>"; }; | |
681 | + 84792A1F2B5FACAB00851211 /* LETransceiver.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LETransceiver.m; sourceTree = "<group>"; }; | |
682 | + 84792A202B5FACAB00851211 /* Utils.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Utils.m; sourceTree = "<group>"; }; | |
683 | + 84792A212B5FACAC00851211 /* RemoteStatus.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteStatus.h; sourceTree = "<group>"; }; | |
684 | + 84792A272B5FADE500851211 /* LETransceiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LETransceiver.h; sourceTree = "<group>"; }; | |
675 | 685 | 847AF36D2B4CF35F00E3456E /* NewSleepModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewSleepModel.swift; sourceTree = "<group>"; }; |
676 | 686 | 847B88EE2B5780CA00851EE7 /* NewIntensiveTimeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewIntensiveTimeModel.swift; sourceTree = "<group>"; }; |
677 | 687 | 847D1C4A2B009FAC0097A96E /* 20231111ReadMe.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = 20231111ReadMe.md; sourceTree = "<group>"; }; |
... | ... | @@ -1082,6 +1092,7 @@ |
1082 | 1092 | 6C0AE83A279166B10064D377 /* InfoPlist.strings */, |
1083 | 1093 | 6C42EFD427686AF20008F82A /* test.m */, |
1084 | 1094 | 6C42EFD327686AF20008F82A /* test.h */, |
1095 | + 84792A262B5FAD5300851211 /* OTA */, | |
1085 | 1096 | 6C0AE834279164EB0064D377 /* Info.plist */, |
1086 | 1097 | 6C411EBF275DE22A009B2E02 /* HDFwear-Bridging-Header.h */, |
1087 | 1098 | 6C6F40302743450A00F9473C /* Assets.xcassets */, |
... | ... | @@ -1127,7 +1138,6 @@ |
1127 | 1138 | 6C6F405E27434B8D00F9473C /* Tools */ = { |
1128 | 1139 | isa = PBXGroup; |
1129 | 1140 | children = ( |
1130 | - 84067DB42B5E67DC0030E30E /* OTA */, | |
1131 | 1141 | 6C411EDE275DE737009B2E02 /* BluetoothManager.swift */, |
1132 | 1142 | 844959772B48EF900029E2E0 /* BluetoothManager+Deprecated.swift */, |
1133 | 1143 | 6C1F987E279BF0AA00C0C3BA /* BluetoothManager+Set.swift */, |
... | ... | @@ -1311,6 +1321,21 @@ |
1311 | 1321 | path = RunScript; |
1312 | 1322 | sourceTree = "<group>"; |
1313 | 1323 | }; |
1324 | + 84792A262B5FAD5300851211 /* OTA */ = { | |
1325 | + isa = PBXGroup; | |
1326 | + children = ( | |
1327 | + 84792A272B5FADE500851211 /* LETransceiver.h */, | |
1328 | + 84792A1F2B5FACAB00851211 /* LETransceiver.m */, | |
1329 | + 84792A1E2B5FACAB00851211 /* OTAManager.h */, | |
1330 | + 84792A1B2B5FACAB00851211 /* OTAManager.m */, | |
1331 | + 84792A212B5FACAC00851211 /* RemoteStatus.h */, | |
1332 | + 84792A1D2B5FACAB00851211 /* RemoteStatus.m */, | |
1333 | + 84792A1C2B5FACAB00851211 /* Utils.h */, | |
1334 | + 84792A202B5FACAB00851211 /* Utils.m */, | |
1335 | + ); | |
1336 | + path = OTA; | |
1337 | + sourceTree = "<group>"; | |
1338 | + }; | |
1314 | 1339 | B2AF587C2A14C1C70080B464 /* LaunchSetting */ = { |
1315 | 1340 | isa = PBXGroup; |
1316 | 1341 | children = ( |
... | ... | @@ -1467,7 +1492,6 @@ |
1467 | 1492 | 6C34958827A12DB000F792AA /* DailCell.xib in Resources */, |
1468 | 1493 | 6CE7E3E62782AA8300D6B374 /* Localizable.strings in Resources */, |
1469 | 1494 | 6C228BB3279261340078B22E /* ContactCell.xib in Resources */, |
1470 | - 84067DB52B5E67DC0030E30E /* OTA in Resources */, | |
1471 | 1495 | 6C9CAC3A278C2A4D00787CA6 /* Motion.storyboard in Resources */, |
1472 | 1496 | 6CC6E57727716BA9006C01A7 /* CustomProgress.xib in Resources */, |
1473 | 1497 | 6C1B7E9927B794B300DB9D1C /* NFCCell.xib in Resources */, |
... | ... | @@ -1589,6 +1613,7 @@ |
1589 | 1613 | 6C5CD63627785971003747E1 /* WeChatSportVC.swift in Sources */, |
1590 | 1614 | 6CA4F8EB27DC71F300B8E726 /* DailSyncSubVC.swift in Sources */, |
1591 | 1615 | 6C41D0BF275F5DAD00747BE4 /* LoaderLineFadeAnimation.swift in Sources */, |
1616 | + 84792A252B5FACAC00851211 /* OTAManager.m in Sources */, | |
1592 | 1617 | 6C6505C32798FB030043DB7A /* LTTableViewProtocal.swift in Sources */, |
1593 | 1618 | 6C80835527F697C400C13EB2 /* PermissionSettingVC.swift in Sources */, |
1594 | 1619 | 6CD70CFC27D5A75300687095 /* PayDetailVC.swift in Sources */, |
... | ... | @@ -1596,6 +1621,7 @@ |
1596 | 1621 | 6C6DF2DF274F39AC00EF6B8D /* MotionRecordVC.swift in Sources */, |
1597 | 1622 | 6C9F1C742779547F00F9220D /* SystemAuth.swift in Sources */, |
1598 | 1623 | 6C6F408D2743837900F9473C /* MotionCell.swift in Sources */, |
1624 | + 84792A232B5FACAC00851211 /* Utils.m in Sources */, | |
1599 | 1625 | 6C33CC5E27E182C30081AB98 /* DialLocalVC.swift in Sources */, |
1600 | 1626 | 6C42EFD527686AF20008F82A /* test.m in Sources */, |
1601 | 1627 | 6C260111277C68D800EE0B4B /* LaunchViewController.swift in Sources */, |
... | ... | @@ -1684,6 +1710,7 @@ |
1684 | 1710 | 6C6DF2D9274F391B00EF6B8D /* TrainViewController.swift in Sources */, |
1685 | 1711 | 6C6F40852743831900F9473C /* TrainCell.swift in Sources */, |
1686 | 1712 | 6C41D0CA275F5DB500747BE4 /* LoaderButton.swift in Sources */, |
1713 | + 84792A222B5FACAC00851211 /* LETransceiver.m in Sources */, | |
1687 | 1714 | 6CC6E57527716B94006C01A7 /* CustomProgress.swift in Sources */, |
1688 | 1715 | 6C5B545F27759D6B007F7901 /* SettingCell3.swift in Sources */, |
1689 | 1716 | 6C2EE97E2780250D0051413A /* StepReportCell.swift in Sources */, |
... | ... | @@ -1706,6 +1733,7 @@ |
1706 | 1733 | 6C5CD634277851AB003747E1 /* APPRemindVC.swift in Sources */, |
1707 | 1734 | 6C228BB2279261340078B22E /* ContactCell.swift in Sources */, |
1708 | 1735 | 6C1B7EAD27B7977000DB9D1C /* NFCCardVC.swift in Sources */, |
1736 | + 84792A242B5FACAC00851211 /* RemoteStatus.m in Sources */, | |
1709 | 1737 | 6C6F409027438FBE00F9473C /* Config.swift in Sources */, |
1710 | 1738 | 6CB5416D27E0694C00BAEBD0 /* DialStyleCell.swift in Sources */, |
1711 | 1739 | 6C6505C02798FB030043DB7A /* LTAdvancedManager.swift in Sources */, |
... | ... | @@ -2230,6 +2258,32 @@ |
2230 | 2258 | "$(PROJECT_DIR)/HDFwear/3rd/RTKOTASDK", |
2231 | 2259 | ); |
2232 | 2260 | GENERATE_INFOPLIST_FILE = YES; |
2261 | + HEADER_SEARCH_PATHS = ( | |
2262 | + "$(inherited)", | |
2263 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking/AFNetworking.framework/Headers\"", | |
2264 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers\"", | |
2265 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/Charts/Charts.framework/Headers\"", | |
2266 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/HCKalmanFilter/HCKalmanFilter.framework/Headers\"", | |
2267 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/HandyJSON/HandyJSON.framework/Headers\"", | |
2268 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift/IQKeyboardManagerSwift.framework/Headers\"", | |
2269 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/JTAppleCalendar/JTAppleCalendar.framework/Headers\"", | |
2270 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/Kingfisher/Kingfisher.framework/Headers\"", | |
2271 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/MBProgressHUD/MBProgressHUD.framework/Headers\"", | |
2272 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh/MJRefresh.framework/Headers\"", | |
2273 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/Realm/Realm.framework/Headers\"", | |
2274 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/RealmSwift/RealmSwift.framework/Headers\"", | |
2275 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/SCIndexView/SCIndexView.framework/Headers\"", | |
2276 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/SSZipArchive/SSZipArchive.framework/Headers\"", | |
2277 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers\"", | |
2278 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/Surge/Surge.framework/Headers\"", | |
2279 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/SwiftDate/SwiftDate.framework/Headers\"", | |
2280 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/TZImagePickerController/TZImagePickerController.framework/Headers\"", | |
2281 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/YYText/YYText.framework/Headers\"", | |
2282 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/swiftScan/swiftScan.framework/Headers\"", | |
2283 | + "\"${PODS_ROOT}/Headers/Public\"", | |
2284 | + "\"${PODS_ROOT}/Headers/Public/mob_sharesdk\"", | |
2285 | + "\"${PODS_XCFRAMEWORKS_BUILD_DIR}/Realm/Headers\"", | |
2286 | + ); | |
2233 | 2287 | INFOPLIST_FILE = HDFwear/Info.plist; |
2234 | 2288 | INFOPLIST_KEY_CFBundleDisplayName = YTWatch; |
2235 | 2289 | INFOPLIST_KEY_NFCReaderUsageDescription = "ๆไปฌ้่ฆๆจ็NFCๆ้็จไบๆซๆNFCๆ ็ญพ"; |
... | ... | @@ -2300,6 +2354,7 @@ |
2300 | 2354 | PRODUCT_BUNDLE_IDENTIFIER = com.jason668.test1; |
2301 | 2355 | PRODUCT_NAME = "$(TARGET_NAME)"; |
2302 | 2356 | PROVISIONING_PROFILE_SPECIFIER = ""; |
2357 | + SHARED_PRECOMPS_DIR = "$(OBJROOT)/SharedPrecompiledHeaders"; | |
2303 | 2358 | SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; |
2304 | 2359 | SUPPORTS_MACCATALYST = NO; |
2305 | 2360 | SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; |
... | ... | @@ -2309,6 +2364,7 @@ |
2309 | 2364 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; |
2310 | 2365 | SWIFT_VERSION = 5.0; |
2311 | 2366 | TARGETED_DEVICE_FAMILY = 1; |
2367 | + USER_HEADER_SEARCH_PATHS = "$(OBJROOT)"; | |
2312 | 2368 | }; |
2313 | 2369 | name = Debug; |
2314 | 2370 | }; |
... | ... | @@ -2339,6 +2395,32 @@ |
2339 | 2395 | "$(PROJECT_DIR)/HDFwear/3rd/Share/ShareSDK", |
2340 | 2396 | ); |
2341 | 2397 | GENERATE_INFOPLIST_FILE = YES; |
2398 | + HEADER_SEARCH_PATHS = ( | |
2399 | + "$(inherited)", | |
2400 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/AFNetworking/AFNetworking.framework/Headers\"", | |
2401 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers\"", | |
2402 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/Charts/Charts.framework/Headers\"", | |
2403 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/HCKalmanFilter/HCKalmanFilter.framework/Headers\"", | |
2404 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/HandyJSON/HandyJSON.framework/Headers\"", | |
2405 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/IQKeyboardManagerSwift/IQKeyboardManagerSwift.framework/Headers\"", | |
2406 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/JTAppleCalendar/JTAppleCalendar.framework/Headers\"", | |
2407 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/Kingfisher/Kingfisher.framework/Headers\"", | |
2408 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/MBProgressHUD/MBProgressHUD.framework/Headers\"", | |
2409 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/MJRefresh/MJRefresh.framework/Headers\"", | |
2410 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/Realm/Realm.framework/Headers\"", | |
2411 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/RealmSwift/RealmSwift.framework/Headers\"", | |
2412 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/SCIndexView/SCIndexView.framework/Headers\"", | |
2413 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/SSZipArchive/SSZipArchive.framework/Headers\"", | |
2414 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers\"", | |
2415 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/Surge/Surge.framework/Headers\"", | |
2416 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/SwiftDate/SwiftDate.framework/Headers\"", | |
2417 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/TZImagePickerController/TZImagePickerController.framework/Headers\"", | |
2418 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/YYText/YYText.framework/Headers\"", | |
2419 | + "\"${PODS_CONFIGURATION_BUILD_DIR}/swiftScan/swiftScan.framework/Headers\"", | |
2420 | + "\"${PODS_ROOT}/Headers/Public\"", | |
2421 | + "\"${PODS_ROOT}/Headers/Public/mob_sharesdk\"", | |
2422 | + "\"${PODS_XCFRAMEWORKS_BUILD_DIR}/Realm/Headers\"", | |
2423 | + ); | |
2342 | 2424 | INFOPLIST_FILE = HDFwear/Info.plist; |
2343 | 2425 | INFOPLIST_KEY_CFBundleDisplayName = YTWatch; |
2344 | 2426 | INFOPLIST_KEY_NFCReaderUsageDescription = "ๆไปฌ้่ฆๆจ็NFCๆ้็จไบๆซๆNFCๆ ็ญพ"; |
... | ... | @@ -2404,6 +2486,7 @@ |
2404 | 2486 | PRODUCT_BUNDLE_IDENTIFIER = com.jason668.test1; |
2405 | 2487 | PRODUCT_NAME = "$(TARGET_NAME)"; |
2406 | 2488 | PROVISIONING_PROFILE_SPECIFIER = ""; |
2489 | + SHARED_PRECOMPS_DIR = "$(OBJROOT)/SharedPrecompiledHeaders"; | |
2407 | 2490 | SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; |
2408 | 2491 | SUPPORTS_MACCATALYST = NO; |
2409 | 2492 | SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; |
... | ... | @@ -2412,6 +2495,7 @@ |
2412 | 2495 | SWIFT_OBJC_BRIDGING_HEADER = "HDFwear/HDFwear-Bridging-Header.h"; |
2413 | 2496 | SWIFT_VERSION = 5.0; |
2414 | 2497 | TARGETED_DEVICE_FAMILY = 1; |
2498 | + USER_HEADER_SEARCH_PATHS = "$(OBJROOT)"; | |
2415 | 2499 | }; |
2416 | 2500 | name = Release; |
2417 | 2501 | }; | ... | ... |
HDFwear/HDFwear-Bridging-Header.h
1 | 1 | // |
2 | 2 | // Use this file to import your target's public headers that you would like to expose to Swift. |
3 | 3 | // |
4 | - | |
4 | +#import "OTAManager.h" | |
5 | +#import "LETransceiver.h" | |
5 | 6 | #import "MTKBleManager.h" |
6 | 7 | #import "FmpGattClient.h" |
7 | 8 | #import "test.h" |
... | ... | @@ -16,4 +17,3 @@ |
16 | 17 | #import <ShareSDKExtension/ShareSDK+Extension.h> |
17 | 18 | //#import "MASmoothPathTool.h" |
18 | 19 | //#import "LxxPlaySound.h" |
19 | -#import "Tools/OTA/OTAManager.h" | ... | ... |
HDFwear/Tools/OTA/LETransceiver.h renamed to HDFwear/OTA/LETransceiver.h
... | ... | @@ -16,16 +16,16 @@ NS_ASSUME_NONNULL_BEGIN |
16 | 16 | #define KeyWriteCharacteristicUUID @"kWriteCharacteristicUUID" |
17 | 17 | #define KeyIndicateCharacteristicUUID @"kIndicateCharacteristicUUID" |
18 | 18 | |
19 | -@protocol LEConnctionDelegate <NSObject> | |
20 | - | |
21 | -@required | |
22 | -- (void)onFoundPeripheral:(CBPeripheral *) peripheral advertisementData:(NSDictionary *) advertisementData; | |
23 | - | |
24 | -@optional | |
25 | -- (void)onConnectedPeripheral:(CBPeripheral *) peripheral; | |
26 | -- (void)onDisconnectedPeripheral:(CBPeripheral *) peripheral; | |
27 | - | |
28 | -@end | |
19 | +//@protocol LEConnctionDelegate <NSObject> | |
20 | +// | |
21 | +//@required | |
22 | +//- (void)onFoundPeripheral:(CBPeripheral *) peripheral advertisementData:(NSDictionary *) advertisementData; | |
23 | +// | |
24 | +//@optional | |
25 | +//- (void)onConnectedPeripheral:(CBPeripheral *) peripheral; | |
26 | +//- (void)onDisconnectedPeripheral:(CBPeripheral *) peripheral; | |
27 | +// | |
28 | +//@end | |
29 | 29 | |
30 | 30 | @protocol LEDataDelegate <NSObject> |
31 | 31 | |
... | ... | @@ -37,20 +37,24 @@ NS_ASSUME_NONNULL_BEGIN |
37 | 37 | |
38 | 38 | @interface LETransceiver : NSObject<CBPeripheralDelegate, CBCentralManagerDelegate> |
39 | 39 | |
40 | -@property (weak, nonatomic) id<LEConnctionDelegate> connectionDelegate; | |
40 | +//@property (weak, nonatomic) id<LEConnctionDelegate> connectionDelegate; | |
41 | 41 | @property (weak, nonatomic) id<LEDataDelegate> dataDelegate; |
42 | 42 | |
43 | -- (void)setUUIDs:(NSDictionary *) uuids; | |
43 | +//- (void)setUUIDs:(NSDictionary *) uuids; | |
44 | 44 | |
45 | -- (void)scanStart; | |
46 | -- (void)scanStop; | |
45 | +//- (void)scanStart; | |
46 | +//- (void)scanStop; | |
47 | 47 | |
48 | -- (void)connect:(CBPeripheral *)peripheral; | |
49 | -- (void)disconnect:(CBPeripheral *)peripheral; | |
48 | +//- (void)connect:(CBPeripheral *)peripheral; | |
49 | +//- (void)disconnect:(CBPeripheral *)peripheral; | |
50 | 50 | |
51 | 51 | - (void)write:(NSData *) data; |
52 | 52 | - (void)write:(NSData *) data index:(int) i; |
53 | 53 | |
54 | +// for BluetoothManager to call | |
55 | +@property (weak, nonatomic) CBCentralManager *centralManager; | |
56 | +- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error; | |
57 | + | |
54 | 58 | @end |
55 | 59 | |
56 | 60 | NS_ASSUME_NONNULL_END | ... | ... |
HDFwear/OTA/LETransceiver.m
0 โ 100644
1 | +// | |
2 | +// LETransceiver.m | |
3 | +// ActsBluetoothSpeed | |
4 | +// | |
5 | +// Created by inidhu on 2019/3/15. | |
6 | +// Copyright ยฉ 2019 Actions. All rights reserved. | |
7 | +// | |
8 | + | |
9 | +#import "LETransceiver.h" | |
10 | +#import <UIKit/UIKit.h> | |
11 | + | |
12 | +#define BLE_UUID_SERVICE @"e49a25f8-f69a-11e8-8eb2-f2801f1b9fd1" | |
13 | +#define BLE_UUID_SERVICE_WRITE @"e49a25e0-f69a-11e8-8eb2-f2801f1b9fd1" | |
14 | +#define BLE_UUID_SERVICE_READ @"e49a28e1-f69a-11e8-8eb2-f2801f1b9fd1" | |
15 | + | |
16 | +#define KeyWriteServiceUUID @"kWriteServiceUUID" | |
17 | +#define KeyIndicateServiceUUID @"kIndicateServiceUUID" | |
18 | +#define KeyWriteCharacteristicUUID @"kWriteCharacteristicUUID" | |
19 | +#define KeyIndicateCharacteristicUUID @"kIndicateCharacteristicUUID" | |
20 | + | |
21 | +@implementation LETransceiver { | |
22 | + NSString *writeServiceUUID; | |
23 | + NSString *writeCharacteristicUUID; | |
24 | + NSString *indicateServiceUUID; | |
25 | + NSString *indicateCharacteristicUUID; | |
26 | + | |
27 | +// CBCharacteristicWriteType writeType; | |
28 | + | |
29 | + CBPeripheral *connectedPeripheral; | |
30 | + CBCharacteristic *characteristicWrite; | |
31 | + CBCharacteristic *characteristicIndicate; | |
32 | + | |
33 | + NSTimer *connectTimer; | |
34 | + BOOL isReadyToSendWrite; | |
35 | + | |
36 | + | |
37 | +} | |
38 | + | |
39 | +- (id) init { | |
40 | + self = [super init]; | |
41 | + if (self) { | |
42 | + NSDictionary *uuids = [NSDictionary dictionaryWithObjectsAndKeys:BLE_UUID_SERVICE, KeyWriteServiceUUID, BLE_UUID_SERVICE_WRITE, KeyWriteCharacteristicUUID, BLE_UUID_SERVICE, KeyIndicateServiceUUID, BLE_UUID_SERVICE_READ, KeyIndicateCharacteristicUUID, nil]; | |
43 | + [self setUUIDs:uuids]; | |
44 | + } | |
45 | +// writeType = CBCharacteristicWriteWithoutResponse; | |
46 | +// centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil]; | |
47 | + | |
48 | + return self; | |
49 | +} | |
50 | + | |
51 | +- (void)setUUIDs:(NSDictionary *) uuids { | |
52 | + NSArray *keys = [uuids allKeys]; | |
53 | + for (NSString *key in keys) { | |
54 | + if ([key isEqualToString:KeyWriteServiceUUID]) { | |
55 | + writeServiceUUID = [[uuids objectForKey:KeyWriteServiceUUID] uppercaseString]; | |
56 | + } else if ([key isEqualToString:KeyIndicateServiceUUID]) { | |
57 | + indicateServiceUUID = [[uuids objectForKey:KeyIndicateServiceUUID] uppercaseString]; | |
58 | + } else if ([key isEqualToString:KeyWriteCharacteristicUUID]) { | |
59 | + writeCharacteristicUUID = [[uuids objectForKey:KeyWriteCharacteristicUUID] uppercaseString]; | |
60 | + } else if ([key isEqualToString:KeyIndicateCharacteristicUUID]) { | |
61 | + indicateCharacteristicUUID = [[uuids objectForKey:KeyIndicateCharacteristicUUID] uppercaseString]; | |
62 | + } | |
63 | + } | |
64 | +} | |
65 | + | |
66 | +//- (void)scanStart { | |
67 | +// NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO], CBCentralManagerScanOptionAllowDuplicatesKey, nil]; | |
68 | +// /* | |
69 | +// NSMutableArray *servicesUUID = [[NSMutableArray alloc] init]; | |
70 | +// if (writeServiceUUID) | |
71 | +// [servicesUUID addObject:writeServiceUUID]; | |
72 | +// if (indicateServiceUUID) | |
73 | +// [servicesUUID addObject:indicateServiceUUID]; | |
74 | +// */ | |
75 | +// [centralManager scanForPeripheralsWithServices:nil options:options]; | |
76 | +//} | |
77 | + | |
78 | +//- (void)scanStop { | |
79 | +// [centralManager stopScan]; | |
80 | +//} | |
81 | + | |
82 | +//- (void)connect:(CBPeripheral *)peripheral { | |
83 | +// [self scanStop]; | |
84 | +// | |
85 | +// [centralManager connectPeripheral:peripheral options:@{CBConnectPeripheralOptionNotifyOnConnectionKey:@YES}]; | |
86 | +// | |
87 | +// if (connectTimer) { | |
88 | +// [connectTimer invalidate]; | |
89 | +// } | |
90 | +// connectTimer = [NSTimer scheduledTimerWithTimeInterval:20.0 target:self selector:@selector(connectTimeout:) userInfo:peripheral repeats:NO]; | |
91 | +//} | |
92 | + | |
93 | +//- (void)disconnect:(CBPeripheral *)peripheral { | |
94 | +// if (![self isPeripheralConnected:peripheral]) { | |
95 | +// return; | |
96 | +// } | |
97 | +// | |
98 | +// NSLog(@"disconnect %@", peripheral.name); | |
99 | +// [centralManager cancelPeripheralConnection:peripheral]; | |
100 | +//} | |
101 | + | |
102 | +//- (BOOL) isPeripheralConnected:(CBPeripheral *) peripheral { | |
103 | +// if (IOS_VERSION >= 7.0) { | |
104 | +// if (peripheral.state == CBPeripheralStateConnected) { | |
105 | +// return YES; | |
106 | +// } | |
107 | +// } else { | |
108 | +//#ifndef __IPHONE_7_0 | |
109 | +// if (peripheral.isConnected) { | |
110 | +// return YES; | |
111 | +// } | |
112 | +//#endif | |
113 | +// } | |
114 | +// return NO; | |
115 | +//} | |
116 | + | |
117 | +- (NSUInteger) getMtuForType:(CBCharacteristicWriteType) type { | |
118 | + return [connectedPeripheral maximumWriteValueLengthForType:type]; | |
119 | +} | |
120 | + | |
121 | +- (void)write:(NSData *) data { | |
122 | + if (characteristicWrite) { | |
123 | + NSUInteger mtu = [self getMtuForType:CBCharacteristicWriteWithoutResponse]; | |
124 | + NSLog(@"writeData mtu: %ld, %@", mtu, data); | |
125 | + for (NSUInteger index = 0; index < data.length; index += mtu) { | |
126 | + NSUInteger len = (data.length - index) > mtu ? mtu : (data.length - index); | |
127 | + NSData *value = [data subdataWithRange:NSMakeRange(index, len)]; | |
128 | + [connectedPeripheral writeValue:value forCharacteristic:characteristicWrite type:CBCharacteristicWriteWithoutResponse]; | |
129 | + NSLog(@"writeValue: %@", value); | |
130 | + } | |
131 | + } | |
132 | +} | |
133 | + | |
134 | +- (void)write:(NSData *) data index:(int) i { | |
135 | + if (characteristicWrite) { | |
136 | + NSUInteger mtu = [self getMtuForType:CBCharacteristicWriteWithoutResponse]; | |
137 | + NSLog(@"i writeData mtu: %ld, %@", mtu, data); | |
138 | + | |
139 | + for (NSUInteger index = 0; index < data.length; index += mtu) { | |
140 | + NSUInteger len = (data.length - index) > mtu ? mtu : (data.length - index); | |
141 | + NSData *value = [data subdataWithRange:NSMakeRange(index, len)]; | |
142 | + if(i != 0 && i % 62 == 0) { | |
143 | + NSData *value2 = [value subdataWithRange:NSMakeRange(0, 1)]; | |
144 | + NSData *value3 = [value subdataWithRange:NSMakeRange(1, value.length - 1)]; | |
145 | + [connectedPeripheral writeValue:value2 forCharacteristic:characteristicWrite type:CBCharacteristicWriteWithResponse]; | |
146 | + [connectedPeripheral writeValue:value3 forCharacteristic:characteristicWrite type:CBCharacteristicWriteWithoutResponse]; | |
147 | + } else { | |
148 | + [connectedPeripheral writeValue:value forCharacteristic:characteristicWrite type:CBCharacteristicWriteWithoutResponse]; | |
149 | + } | |
150 | + NSLog(@"writeValue: %@", value); | |
151 | + } | |
152 | + } | |
153 | +} | |
154 | + | |
155 | +//- (void)connectTimeout:(NSTimer *)timer { | |
156 | +// CBPeripheral *peripheral = (CBPeripheral *)[timer userInfo]; | |
157 | +// [self disconnect:peripheral]; | |
158 | +//} | |
159 | + | |
160 | +#pragma mark -- CBCentralManagerDelegate | |
161 | +//- (void)centralManagerDidUpdateState:(CBCentralManager *)central { | |
162 | +// NSString *messtoshow; | |
163 | +// switch (central.state) { | |
164 | +// case CBManagerStatePoweredOn:{ | |
165 | +// messtoshow=[NSString stringWithFormat:@"CBCentralManagerStatePoweredOn"]; | |
166 | +// [self scanStart]; | |
167 | +// break; | |
168 | +// } | |
169 | +// case CBManagerStateUnknown: | |
170 | +// { | |
171 | +// messtoshow=[NSString stringWithFormat:@"State unknown, update imminent"]; | |
172 | +// break; | |
173 | +// } | |
174 | +// case CBManagerStateResetting: | |
175 | +// { | |
176 | +// messtoshow=[NSString stringWithFormat:@"The connection with the system service was momentarily lost, update imminent."]; | |
177 | +// break; | |
178 | +// } | |
179 | +// case CBManagerStateUnsupported: | |
180 | +// { | |
181 | +// messtoshow=[NSString stringWithFormat:@"The platform doesn't support Bluetooth Low Energy"]; | |
182 | +// break; | |
183 | +// } | |
184 | +// case CBManagerStateUnauthorized: | |
185 | +// { | |
186 | +// messtoshow=[NSString stringWithFormat:@"The app is not authorized to use Bluetooth Low Energy"]; | |
187 | +// break; | |
188 | +// } | |
189 | +// case CBManagerStatePoweredOff: | |
190 | +// { | |
191 | +// [self disconnect:connectedPeripheral]; | |
192 | +// | |
193 | +// messtoshow=[NSString stringWithFormat:@"Bluetooth is currently powered off"]; | |
194 | +// break; | |
195 | +// } | |
196 | +// default: | |
197 | +// break; | |
198 | +// } | |
199 | +// NSLog(@"%@",messtoshow); | |
200 | +//} | |
201 | + | |
202 | +//- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI{ | |
203 | +//// NSLog(@"didDiscoverPeripheral: %@", peripheral); | |
204 | +// | |
205 | +// if(_connectionDelegate && [_connectionDelegate respondsToSelector:@selector(onFoundPeripheral:advertisementData:)]) { | |
206 | +// [_connectionDelegate onFoundPeripheral:peripheral advertisementData:advertisementData]; | |
207 | +// } | |
208 | +//} | |
209 | + | |
210 | +//- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral{ | |
211 | +// NSLog(@"didConnectPeripheral: %@", peripheral.name); | |
212 | +// | |
213 | +// peripheral.delegate = self; | |
214 | +// [peripheral discoverServices:nil]; | |
215 | +//} | |
216 | + | |
217 | +//- (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error{ | |
218 | +// NSLog(@"Fail to connect: %@", peripheral.name); | |
219 | +//} | |
220 | + | |
221 | +//- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error{ | |
222 | +// NSLog(@"didDisconnectPeripheral %@, error: %@",peripheral, error); | |
223 | +// | |
224 | +// connectedPeripheral = nil; | |
225 | +// characteristicWrite = nil; | |
226 | +// characteristicIndicate = nil; | |
227 | +// if(_connectionDelegate && [_connectionDelegate respondsToSelector:@selector(onDisconnectedPeripheral:)]) { | |
228 | +// [_connectionDelegate onDisconnectedPeripheral:peripheral]; | |
229 | +// } | |
230 | +//} | |
231 | + | |
232 | +#pragma mark -- CBPeripheralDelegate | |
233 | +//- (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error{ | |
234 | +// NSLog(@"didDiscoverServices: %@", peripheral.name); | |
235 | +// if (error) { | |
236 | +// NSLog(@"Error discovering service:%@", [error localizedDescription]); | |
237 | +// return; | |
238 | +// } | |
239 | +// | |
240 | +// for (CBService *service in peripheral.services) { | |
241 | +// | |
242 | +// NSLog(@"service: %@", service); | |
243 | +// [peripheral discoverCharacteristics:nil forService:service]; | |
244 | +// } | |
245 | +// | |
246 | +//} | |
247 | + | |
248 | +- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error{ | |
249 | + NSLog(@"didDiscoverCharacteristicsForService: %@, %@", peripheral.name, service.UUID.UUIDString); | |
250 | + if (error) { | |
251 | + NSLog(@"Error didDiscoverCharacteristicsForService:%@",[error localizedDescription]); | |
252 | + return; | |
253 | + } | |
254 | + | |
255 | + NSLog(@"UUID: %@, %@, %@", service.UUID.UUIDString, writeServiceUUID, indicateServiceUUID); | |
256 | + if ([service.UUID.UUIDString isEqualToString:writeServiceUUID]) { | |
257 | + for (CBCharacteristic *characteristic in service.characteristics) { | |
258 | + NSLog(@"DiscoverCharacteristics: %@", characteristic.UUID); | |
259 | + | |
260 | + if ([characteristic.UUID.UUIDString isEqualToString:writeCharacteristicUUID]) | |
261 | + characteristicWrite = characteristic; | |
262 | + } | |
263 | + } | |
264 | + | |
265 | + if ([service.UUID.UUIDString isEqualToString:indicateServiceUUID]) { | |
266 | + for (CBCharacteristic *characteristic in service.characteristics) { | |
267 | + NSLog(@"DiscoverCharacteristics: %@", characteristic.UUID); | |
268 | + | |
269 | + if ([characteristic.UUID.UUIDString isEqualToString:indicateCharacteristicUUID]) { | |
270 | + [peripheral setNotifyValue:YES forCharacteristic:characteristic]; | |
271 | + characteristicIndicate = characteristic; | |
272 | + } | |
273 | + } | |
274 | + } | |
275 | + | |
276 | + | |
277 | + if (characteristicWrite && characteristicIndicate) { | |
278 | + connectedPeripheral = peripheral; | |
279 | + [connectTimer invalidate]; | |
280 | + | |
281 | +// if(_connectionDelegate && [_connectionDelegate respondsToSelector:@selector(onConnectedPeripheral:)]) { | |
282 | +// [_connectionDelegate onConnectedPeripheral:peripheral]; | |
283 | +// } | |
284 | + } | |
285 | +} | |
286 | + | |
287 | +- (void)peripheral:(CBPeripheral *)peripheral didReadRSSI:(NSNumber *)RSSI error:(nullable NSError *)error { | |
288 | + | |
289 | +} | |
290 | + | |
291 | +- (void)peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error { | |
292 | + | |
293 | + if (error) { | |
294 | + NSLog(@"%@,%@,Error didWriteValueForCharacteristic:%@",characteristic.UUID,[characteristic value], [error localizedDescription]); | |
295 | + return; | |
296 | + } | |
297 | + | |
298 | +} | |
299 | + | |
300 | +- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error { | |
301 | + if (error) { | |
302 | + NSLog(@"Error didUpdateValueForCharacteristic:%@", [error localizedDescription]); | |
303 | + return; | |
304 | + } | |
305 | + NSLog(@"didUpdateValueForCharacteristic: %@ %@", characteristic.UUID, characteristic.value); | |
306 | + | |
307 | + if (_dataDelegate && [_dataDelegate respondsToSelector:@selector(onDataReceive:)]) { | |
308 | + [_dataDelegate onDataReceive:[characteristic value]]; | |
309 | + } | |
310 | +} | |
311 | + | |
312 | +@end | ... | ... |
HDFwear/Tools/OTA/OTAManager.h renamed to HDFwear/OTA/OTAManager.h
HDFwear/Tools/OTA/OTAManager.m renamed to HDFwear/OTA/OTAManager.m
HDFwear/Tools/OTA/RemoteStatus.h renamed to HDFwear/OTA/RemoteStatus.h
HDFwear/Tools/OTA/RemoteStatus.m renamed to HDFwear/OTA/RemoteStatus.m
HDFwear/Tools/OTA/Utils.h renamed to HDFwear/OTA/Utils.h
HDFwear/Tools/OTA/Utils.m renamed to HDFwear/OTA/Utils.m
HDFwear/Tools/BluetoothManager.swift
... | ... | @@ -145,6 +145,9 @@ class BluetoothManager: NSObject { |
145 | 145 | |
146 | 146 | private var contactArray: [ContactModel] = [] |
147 | 147 | |
148 | + //ota | |
149 | + var transceiver = LETransceiver() | |
150 | + var otaManager = OTAManager() | |
148 | 151 | |
149 | 152 | //mergeData |
150 | 153 | var totalBytes: [UInt8] = [] |
... | ... | @@ -221,6 +224,7 @@ class BluetoothManager: NSObject { |
221 | 224 | peripheralDic = [:] |
222 | 225 | deviceArray = [] |
223 | 226 | centralManger = CBCentralManager(delegate: self, queue: nil) |
227 | + | |
224 | 228 | manger?.startScanning() |
225 | 229 | //mClientProfileDic __NSDictionaryM * 1 key/value pair 0x0000000281a694c0 |
226 | 230 | } | ... | ... |
HDFwear/Tools/OTA/LETransceiver.m deleted
1 | -// | |
2 | -// LETransceiver.m | |
3 | -// ActsBluetoothSpeed | |
4 | -// | |
5 | -// Created by inidhu on 2019/3/15. | |
6 | -// Copyright ยฉ 2019 Actions. All rights reserved. | |
7 | -// | |
8 | - | |
9 | -#import "LETransceiver.h" | |
10 | -#import <UIKit/UIKit.h> | |
11 | - | |
12 | - | |
13 | -@implementation LETransceiver { | |
14 | - NSString *writeServiceUUID; | |
15 | - NSString *writeCharacteristicUUID; | |
16 | - NSString *indicateServiceUUID; | |
17 | - NSString *indicateCharacteristicUUID; | |
18 | - | |
19 | - CBCharacteristicWriteType writeType; | |
20 | - CBCentralManager *centralManager; | |
21 | - | |
22 | - CBPeripheral *connectedPeripheral; | |
23 | - CBCharacteristic *characteristicWrite; | |
24 | - CBCharacteristic *characteristicIndicate; | |
25 | - | |
26 | - NSTimer *connectTimer; | |
27 | - BOOL isReadyToSendWrite; | |
28 | - | |
29 | - | |
30 | -} | |
31 | - | |
32 | -- (id) init { | |
33 | - self = [super init]; | |
34 | - | |
35 | - writeType = CBCharacteristicWriteWithoutResponse; | |
36 | - | |
37 | - centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil]; | |
38 | - | |
39 | - return self; | |
40 | -} | |
41 | - | |
42 | -- (void)setUUIDs:(NSDictionary *) uuids { | |
43 | - NSArray *keys = [uuids allKeys]; | |
44 | - for (NSString *key in keys) { | |
45 | - if ([key isEqualToString:KeyWriteServiceUUID]) { | |
46 | - writeServiceUUID = [[uuids objectForKey:KeyWriteServiceUUID] uppercaseString]; | |
47 | - } else if ([key isEqualToString:KeyIndicateServiceUUID]) { | |
48 | - indicateServiceUUID = [[uuids objectForKey:KeyIndicateServiceUUID] uppercaseString]; | |
49 | - } else if ([key isEqualToString:KeyWriteCharacteristicUUID]) { | |
50 | - writeCharacteristicUUID = [[uuids objectForKey:KeyWriteCharacteristicUUID] uppercaseString]; | |
51 | - } else if ([key isEqualToString:KeyIndicateCharacteristicUUID]) { | |
52 | - indicateCharacteristicUUID = [[uuids objectForKey:KeyIndicateCharacteristicUUID] uppercaseString]; | |
53 | - } | |
54 | - } | |
55 | -} | |
56 | - | |
57 | -- (void)scanStart { | |
58 | - NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO], CBCentralManagerScanOptionAllowDuplicatesKey, nil]; | |
59 | - /* | |
60 | - NSMutableArray *servicesUUID = [[NSMutableArray alloc] init]; | |
61 | - if (writeServiceUUID) | |
62 | - [servicesUUID addObject:writeServiceUUID]; | |
63 | - if (indicateServiceUUID) | |
64 | - [servicesUUID addObject:indicateServiceUUID]; | |
65 | - */ | |
66 | - [centralManager scanForPeripheralsWithServices:nil options:options]; | |
67 | -} | |
68 | - | |
69 | -- (void)scanStop { | |
70 | - [centralManager stopScan]; | |
71 | -} | |
72 | - | |
73 | -- (void)connect:(CBPeripheral *)peripheral { | |
74 | - [self scanStop]; | |
75 | - | |
76 | - [centralManager connectPeripheral:peripheral options:@{CBConnectPeripheralOptionNotifyOnConnectionKey:@YES}]; | |
77 | - | |
78 | - if (connectTimer) { | |
79 | - [connectTimer invalidate]; | |
80 | - } | |
81 | - connectTimer = [NSTimer scheduledTimerWithTimeInterval:20.0 target:self selector:@selector(connectTimeout:) userInfo:peripheral repeats:NO]; | |
82 | -} | |
83 | - | |
84 | -- (void)disconnect:(CBPeripheral *)peripheral { | |
85 | - if (![self isPeripheralConnected:peripheral]) { | |
86 | - return; | |
87 | - } | |
88 | - | |
89 | - NSLog(@"disconnect %@", peripheral.name); | |
90 | - [centralManager cancelPeripheralConnection:peripheral]; | |
91 | -} | |
92 | - | |
93 | -- (BOOL) isPeripheralConnected:(CBPeripheral *) peripheral { | |
94 | - if (IOS_VERSION >= 7.0) { | |
95 | - if (peripheral.state == CBPeripheralStateConnected) { | |
96 | - return YES; | |
97 | - } | |
98 | - } else { | |
99 | -#ifndef __IPHONE_7_0 | |
100 | - if (peripheral.isConnected) { | |
101 | - return YES; | |
102 | - } | |
103 | -#endif | |
104 | - } | |
105 | - return NO; | |
106 | -} | |
107 | - | |
108 | -- (NSUInteger) getMtuForType:(CBCharacteristicWriteType) type { | |
109 | - return [connectedPeripheral maximumWriteValueLengthForType:type]; | |
110 | -} | |
111 | - | |
112 | -- (void)write:(NSData *) data { | |
113 | - if (characteristicWrite) { | |
114 | - NSUInteger mtu = [self getMtuForType:CBCharacteristicWriteWithoutResponse]; | |
115 | - NSLog(@"writeData mtu: %ld, %@", mtu, data); | |
116 | - for (NSUInteger index = 0; index < data.length; index += mtu) { | |
117 | - NSUInteger len = (data.length - index) > mtu ? mtu : (data.length - index); | |
118 | - NSData *value = [data subdataWithRange:NSMakeRange(index, len)]; | |
119 | - [connectedPeripheral writeValue:value forCharacteristic:characteristicWrite type:CBCharacteristicWriteWithoutResponse]; | |
120 | - NSLog(@"writeValue: %@", value); | |
121 | - } | |
122 | - } | |
123 | -} | |
124 | - | |
125 | -- (void)write:(NSData *) data index:(int) i { | |
126 | - if (characteristicWrite) { | |
127 | - NSUInteger mtu = [self getMtuForType:CBCharacteristicWriteWithoutResponse]; | |
128 | - NSLog(@"i writeData mtu: %ld, %@", mtu, data); | |
129 | - | |
130 | - for (NSUInteger index = 0; index < data.length; index += mtu) { | |
131 | - NSUInteger len = (data.length - index) > mtu ? mtu : (data.length - index); | |
132 | - NSData *value = [data subdataWithRange:NSMakeRange(index, len)]; | |
133 | - if(i != 0 && i % 62 == 0) { | |
134 | - NSData *value2 = [value subdataWithRange:NSMakeRange(0, 1)]; | |
135 | - NSData *value3 = [value subdataWithRange:NSMakeRange(1, value.length - 1)]; | |
136 | - [connectedPeripheral writeValue:value2 forCharacteristic:characteristicWrite type:CBCharacteristicWriteWithResponse]; | |
137 | - [connectedPeripheral writeValue:value3 forCharacteristic:characteristicWrite type:CBCharacteristicWriteWithoutResponse]; | |
138 | - } else { | |
139 | - [connectedPeripheral writeValue:value forCharacteristic:characteristicWrite type:CBCharacteristicWriteWithoutResponse]; | |
140 | - } | |
141 | - NSLog(@"writeValue: %@", value); | |
142 | - } | |
143 | - } | |
144 | -} | |
145 | - | |
146 | -- (void)connectTimeout:(NSTimer *)timer { | |
147 | - CBPeripheral *peripheral = (CBPeripheral *)[timer userInfo]; | |
148 | - [self disconnect:peripheral]; | |
149 | -} | |
150 | - | |
151 | -#pragma mark -- CBCentralManagerDelegate | |
152 | -- (void)centralManagerDidUpdateState:(CBCentralManager *)central { | |
153 | - NSString *messtoshow; | |
154 | - switch (central.state) { | |
155 | - case CBManagerStatePoweredOn:{ | |
156 | - messtoshow=[NSString stringWithFormat:@"CBCentralManagerStatePoweredOn"]; | |
157 | - [self scanStart]; | |
158 | - break; | |
159 | - } | |
160 | - case CBManagerStateUnknown: | |
161 | - { | |
162 | - messtoshow=[NSString stringWithFormat:@"State unknown, update imminent"]; | |
163 | - break; | |
164 | - } | |
165 | - case CBManagerStateResetting: | |
166 | - { | |
167 | - messtoshow=[NSString stringWithFormat:@"The connection with the system service was momentarily lost, update imminent."]; | |
168 | - break; | |
169 | - } | |
170 | - case CBManagerStateUnsupported: | |
171 | - { | |
172 | - messtoshow=[NSString stringWithFormat:@"The platform doesn't support Bluetooth Low Energy"]; | |
173 | - break; | |
174 | - } | |
175 | - case CBManagerStateUnauthorized: | |
176 | - { | |
177 | - messtoshow=[NSString stringWithFormat:@"The app is not authorized to use Bluetooth Low Energy"]; | |
178 | - break; | |
179 | - } | |
180 | - case CBManagerStatePoweredOff: | |
181 | - { | |
182 | - [self disconnect:connectedPeripheral]; | |
183 | - | |
184 | - messtoshow=[NSString stringWithFormat:@"Bluetooth is currently powered off"]; | |
185 | - break; | |
186 | - } | |
187 | - default: | |
188 | - break; | |
189 | - } | |
190 | - NSLog(@"%@",messtoshow); | |
191 | -} | |
192 | - | |
193 | -- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI{ | |
194 | -// NSLog(@"didDiscoverPeripheral: %@", peripheral); | |
195 | - | |
196 | - if(_connectionDelegate && [_connectionDelegate respondsToSelector:@selector(onFoundPeripheral:advertisementData:)]) { | |
197 | - [_connectionDelegate onFoundPeripheral:peripheral advertisementData:advertisementData]; | |
198 | - } | |
199 | -} | |
200 | - | |
201 | -- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral{ | |
202 | - NSLog(@"didConnectPeripheral: %@", peripheral.name); | |
203 | - | |
204 | - peripheral.delegate = self; | |
205 | - [peripheral discoverServices:nil]; | |
206 | -} | |
207 | - | |
208 | -- (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error{ | |
209 | - NSLog(@"Fail to connect: %@", peripheral.name); | |
210 | -} | |
211 | - | |
212 | -- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error{ | |
213 | - NSLog(@"didDisconnectPeripheral %@, error: %@",peripheral, error); | |
214 | - | |
215 | - connectedPeripheral = nil; | |
216 | - characteristicWrite = nil; | |
217 | - characteristicIndicate = nil; | |
218 | - if(_connectionDelegate && [_connectionDelegate respondsToSelector:@selector(onDisconnectedPeripheral:)]) { | |
219 | - [_connectionDelegate onDisconnectedPeripheral:peripheral]; | |
220 | - } | |
221 | -} | |
222 | - | |
223 | -#pragma mark -- CBPeripheralDelegate | |
224 | -- (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error{ | |
225 | - NSLog(@"didDiscoverServices: %@", peripheral.name); | |
226 | - if (error) { | |
227 | - NSLog(@"Error discovering service:%@", [error localizedDescription]); | |
228 | - return; | |
229 | - } | |
230 | - | |
231 | - for (CBService *service in peripheral.services) { | |
232 | - | |
233 | - NSLog(@"service: %@", service); | |
234 | - [peripheral discoverCharacteristics:nil forService:service]; | |
235 | - } | |
236 | - | |
237 | -} | |
238 | - | |
239 | -- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error{ | |
240 | - NSLog(@"didDiscoverCharacteristicsForService: %@, %@", peripheral.name, service.UUID.UUIDString); | |
241 | - if (error) { | |
242 | - NSLog(@"Error didDiscoverCharacteristicsForService:%@",[error localizedDescription]); | |
243 | - return; | |
244 | - } | |
245 | - | |
246 | - NSLog(@"UUID: %@, %@, %@", service.UUID.UUIDString, writeServiceUUID, indicateServiceUUID); | |
247 | - if ([service.UUID.UUIDString isEqualToString:writeServiceUUID]) { | |
248 | - for (CBCharacteristic *characteristic in service.characteristics) { | |
249 | - NSLog(@"DiscoverCharacteristics: %@", characteristic.UUID); | |
250 | - | |
251 | - if ([characteristic.UUID.UUIDString isEqualToString:writeCharacteristicUUID]) | |
252 | - characteristicWrite = characteristic; | |
253 | - } | |
254 | - } | |
255 | - | |
256 | - if ([service.UUID.UUIDString isEqualToString:indicateServiceUUID]) { | |
257 | - for (CBCharacteristic *characteristic in service.characteristics) { | |
258 | - NSLog(@"DiscoverCharacteristics: %@", characteristic.UUID); | |
259 | - | |
260 | - if ([characteristic.UUID.UUIDString isEqualToString:indicateCharacteristicUUID]) { | |
261 | - [peripheral setNotifyValue:YES forCharacteristic:characteristic]; | |
262 | - characteristicIndicate = characteristic; | |
263 | - } | |
264 | - } | |
265 | - } | |
266 | - | |
267 | - | |
268 | - if (characteristicWrite && characteristicIndicate) { | |
269 | - connectedPeripheral = peripheral; | |
270 | - [connectTimer invalidate]; | |
271 | - | |
272 | - if(_connectionDelegate && [_connectionDelegate respondsToSelector:@selector(onConnectedPeripheral:)]) { | |
273 | - [_connectionDelegate onConnectedPeripheral:peripheral]; | |
274 | - } | |
275 | - } | |
276 | -} | |
277 | - | |
278 | -- (void)peripheral:(CBPeripheral *)peripheral didReadRSSI:(NSNumber *)RSSI error:(nullable NSError *)error { | |
279 | - | |
280 | -} | |
281 | - | |
282 | -- (void)peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error { | |
283 | - | |
284 | - if (error) { | |
285 | - NSLog(@"%@,%@,Error didWriteValueForCharacteristic:%@",characteristic.UUID,[characteristic value], [error localizedDescription]); | |
286 | - return; | |
287 | - } | |
288 | - | |
289 | -} | |
290 | - | |
291 | -- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error { | |
292 | - if (error) { | |
293 | - NSLog(@"Error didUpdateValueForCharacteristic:%@", [error localizedDescription]); | |
294 | - return; | |
295 | - } | |
296 | - NSLog(@"didUpdateValueForCharacteristic: %@ %@", characteristic.UUID, characteristic.value); | |
297 | - | |
298 | - if (_dataDelegate && [_dataDelegate respondsToSelector:@selector(onDataReceive:)]) { | |
299 | - [_dataDelegate onDataReceive:[characteristic value]]; | |
300 | - } | |
301 | -} | |
302 | - | |
303 | -@end |