Skip to content

File tree

9 files changed

+185
-5
lines changed

9 files changed

+185
-5
lines changed

Source/LinkSDKDemo/Base.lproj/Main.storyboard

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,77 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17506" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="y8H-OK-A7C">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19158" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="y8H-OK-A7C">
33
<device id="retina6_1" orientation="portrait" appearance="light"/>
44
<dependencies>
55
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17505"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19141"/>
77
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
88
<capability name="System colors in document resources" minToolsVersion="11.0"/>
99
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1010
</dependencies>
1111
<scenes>
12+
<!--显示所有设备-->
13+
<scene sceneID="iPc-G8-UL8">
14+
<objects>
15+
<viewController id="MPm-JF-Z42" customClass="TIoTAllDevicesVC" sceneMemberID="viewController">
16+
<view key="view" contentMode="scaleToFill" id="2xt-tK-U6d">
17+
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
18+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
19+
<subviews>
20+
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="AccessToken" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="rIJ-KM-7a5">
21+
<rect key="frame" x="20" y="108" width="374" height="34"/>
22+
<fontDescription key="fontDescription" type="system" pointSize="14"/>
23+
<textInputTraits key="textInputTraits"/>
24+
</textField>
25+
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="platformId" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="eRM-jE-uTO">
26+
<rect key="frame" x="20" y="150" width="374" height="34"/>
27+
<fontDescription key="fontDescription" type="system" pointSize="14"/>
28+
<textInputTraits key="textInputTraits"/>
29+
</textField>
30+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="DGk-mY-evA">
31+
<rect key="frame" x="20" y="192" width="110" height="31"/>
32+
<state key="normal" title="Button"/>
33+
<buttonConfiguration key="configuration" style="plain" title="显示所有设备"/>
34+
<connections>
35+
<action selector="showAllDevices:" destination="MPm-JF-Z42" eventType="touchUpInside" id="i82-el-R1e"/>
36+
</connections>
37+
</button>
38+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PK7-GK-96b">
39+
<rect key="frame" x="20" y="231" width="374" height="100"/>
40+
<constraints>
41+
<constraint firstAttribute="height" constant="100" id="IvC-Q3-NKP"/>
42+
</constraints>
43+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
44+
<nil key="textColor"/>
45+
<nil key="highlightedColor"/>
46+
</label>
47+
</subviews>
48+
<viewLayoutGuide key="safeArea" id="Olt-a1-ZEP"/>
49+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
50+
<constraints>
51+
<constraint firstItem="rIJ-KM-7a5" firstAttribute="top" secondItem="Olt-a1-ZEP" secondAttribute="top" constant="20" id="4c6-ij-j0j"/>
52+
<constraint firstItem="Olt-a1-ZEP" firstAttribute="trailing" secondItem="eRM-jE-uTO" secondAttribute="trailing" constant="20" id="E1j-UJ-Fg5"/>
53+
<constraint firstItem="PK7-GK-96b" firstAttribute="top" secondItem="DGk-mY-evA" secondAttribute="bottom" constant="8" symbolic="YES" id="G31-RI-Tsc"/>
54+
<constraint firstItem="Olt-a1-ZEP" firstAttribute="trailing" secondItem="rIJ-KM-7a5" secondAttribute="trailing" constant="20" id="SY6-G8-ay5"/>
55+
<constraint firstItem="eRM-jE-uTO" firstAttribute="leading" secondItem="Olt-a1-ZEP" secondAttribute="leading" constant="20" id="Ws5-Ak-0Iw"/>
56+
<constraint firstItem="eRM-jE-uTO" firstAttribute="top" secondItem="rIJ-KM-7a5" secondAttribute="bottom" constant="8" symbolic="YES" id="bGU-Hz-S5w"/>
57+
<constraint firstItem="rIJ-KM-7a5" firstAttribute="leading" secondItem="Olt-a1-ZEP" secondAttribute="leading" constant="20" id="bhX-Vz-AJD"/>
58+
<constraint firstItem="DGk-mY-evA" firstAttribute="leading" secondItem="Olt-a1-ZEP" secondAttribute="leading" constant="20" id="iQg-u7-Le9"/>
59+
<constraint firstItem="DGk-mY-evA" firstAttribute="top" secondItem="eRM-jE-uTO" secondAttribute="bottom" constant="8" symbolic="YES" id="p84-0o-c5l"/>
60+
<constraint firstItem="Olt-a1-ZEP" firstAttribute="trailing" secondItem="PK7-GK-96b" secondAttribute="trailing" constant="20" id="z7J-57-4BZ"/>
61+
<constraint firstItem="PK7-GK-96b" firstAttribute="leading" secondItem="Olt-a1-ZEP" secondAttribute="leading" constant="20" id="zFN-4F-153"/>
62+
</constraints>
63+
</view>
64+
<navigationItem key="navigationItem" title="显示所有设备" id="RhH-1t-3eE"/>
65+
<connections>
66+
<outlet property="accessTokenTextField" destination="rIJ-KM-7a5" id="JMi-Ml-2cO"/>
67+
<outlet property="devicesLabel" destination="PK7-GK-96b" id="WNq-fV-X9u"/>
68+
<outlet property="platformIdTextField" destination="eRM-jE-uTO" id="MtJ-Ux-fUO"/>
69+
</connections>
70+
</viewController>
71+
<placeholder placeholderIdentifier="IBFirstResponder" id="xLe-q2-Bxi" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
72+
</objects>
73+
<point key="canvasLocation" x="2719" y="-575"/>
74+
</scene>
1275
<!--HomeVC-->
1376
<scene sceneID="tne-QT-ifu">
1477
<objects>
@@ -62,6 +125,11 @@
62125
</constraints>
63126
</view>
64127
<navigationItem key="navigationItem" id="rNG-xC-J5Q">
128+
<barButtonItem key="leftBarButtonItem" title="显示所有设备" id="Ogv-Rk-i0H">
129+
<connections>
130+
<segue destination="MPm-JF-Z42" kind="push" id="B7E-ca-K63"/>
131+
</connections>
132+
</barButtonItem>
65133
<barButtonItem key="rightBarButtonItem" title="添加" id="XXa-Cp-TKq">
66134
<connections>
67135
<segue destination="6ts-Uc-m2S" kind="push" id="nki-hN-WlU"/>
@@ -453,10 +521,10 @@
453521
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
454522
</systemColor>
455523
<systemColor name="systemBrownColor">
456-
<color red="0.63529411759999999" green="0.51764705879999995" blue="0.36862745099999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
524+
<color red="0.63529411764705879" green="0.51764705882352946" blue="0.36862745098039218" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
457525
</systemColor>
458526
<systemColor name="systemTealColor">
459-
<color red="0.35294117647058826" green="0.78431372549019607" blue="0.98039215686274506" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
527+
<color red="0.18823529411764706" green="0.69019607843137254" blue="0.7803921568627451" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
460528
</systemColor>
461529
<systemColor name="systemYellowColor">
462530
<color red="1" green="0.80000000000000004" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// TIoTAllDevicesVC.h
3+
// TIoTAllDevicesVC
4+
//
5+
// Created by whalensun on 2021/9/14.
6+
// Copyright © 2021 Tencent. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
NS_ASSUME_NONNULL_BEGIN
12+
13+
@interface TIoTAllDevicesVC : UIViewController
14+
15+
@end
16+
17+
NS_ASSUME_NONNULL_END
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//
2+
// TIoTAllDevicesVC.m
3+
// TIoTAllDevicesVC
4+
//
5+
// Created by whalensun on 2021/9/14.
6+
// Copyright © 2021 Tencent. All rights reserved.
7+
//
8+
9+
#import "TIoTAllDevicesVC.h"
10+
11+
@interface TIoTAllDevicesVC ()
12+
13+
@property (weak, nonatomic) IBOutlet UITextField *accessTokenTextField;
14+
@property (weak, nonatomic) IBOutlet UITextField *platformIdTextField;
15+
@property (weak, nonatomic) IBOutlet UILabel *devicesLabel;
16+
17+
@end
18+
19+
@implementation TIoTAllDevicesVC
20+
21+
- (void)viewDidLoad {
22+
[super viewDidLoad];
23+
// Do any additional setup after loading the view.
24+
}
25+
26+
- (IBAction)showAllDevices:(UIButton *)sender {
27+
[self.view endEditing:YES];
28+
[[TIoTCoreDeviceSet shared] getVirtualBindDeviceListWithAccessToken:self.accessTokenTextField.text platformId:self.platformIdTextField.text offset:0 limit:0 success:^(id _Nonnull responseObject) {
29+
30+
DDLogVerbose(@"getVirtualBindDeviceList==%@",responseObject);
31+
NSArray *devicesArr = [responseObject objectForKey:@"VirtualBindDeviceList"];
32+
if (devicesArr) {
33+
NSString *content = @"";
34+
for (NSDictionary *device in devicesArr) {
35+
content = [content stringByAppendingString:[NSString stringWithFormat:@"%@\n", [device objectForKey:@"DeviceName"]]];
36+
}
37+
self.devicesLabel.text = content;
38+
} else {
39+
[MBProgressHUD showError:@"没有设备"];
40+
}
41+
42+
} failure:^(NSString * _Nullable reason, NSError * _Nullable error,NSDictionary *dic) {
43+
if (dic) {
44+
[MBProgressHUD showError:[NSString stringWithFormat:@"code: %@, msg: %@", [dic objectForKey:@"code"], [dic objectForKey:@"msg"]]];
45+
}
46+
}];
47+
}
48+
49+
50+
@end

Source/SDK/LinkCore/QCAPISets/Other/TIoTCoreRequestAction.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ FOUNDATION_EXPORT NSString *const AppGetProductInfo;//扫一扫落地页面显
108108
FOUNDATION_EXPORT NSString *const AppGetGatewayBindDeviceList;//网关设备列表
109109
FOUNDATION_EXPORT NSString *const AppBindSubDeviceInFamily;//绑定子设备
110110

111+
FOUNDATION_EXPORT NSString *const AppGetVirtualBindDeviceList;//APP拉用户绑定设备列表
112+
111113
//MARK: 设备定时
112114

113115
FOUNDATION_EXPORT NSString *const AppGetTimerList;//获取定时任务列表

Source/SDK/LinkCore/QCAPISets/Other/TIoTCoreRequestAction.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ @implementation TIoTCoreRequestAction
9898
NSString *const AppGetGatewayBindDeviceList = @"AppGetGatewayBindDeviceList";
9999
NSString *const AppBindSubDeviceInFamily = @"AppBindSubDeviceInFamily";
100100

101+
NSString *const AppGetVirtualBindDeviceList = @"AppGetVirtualBindDeviceList";//APP拉用户绑定设备列表
102+
101103
//===============设备定时
102104

103105
NSString *const AppGetTimerList = @"AppGetTimerList";//获取定时任务列表

Source/SDK/LinkCore/QCAPISets/Public/TIoTCoreDeviceSet.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ typedef NS_ENUM(NSInteger,TIotApiHost) {
104104
/// 更换设备绑定的房间
105105
- (void)modifyRoomOfDeviceWithProductId:(NSString *)productId deviceName:(NSString *)deviceName familyId:(NSString *)familyId roomId:(NSString *)roomId success:(SRHandler)success failure:(FRHandler)failure;
106106

107+
/// APP拉用户绑定设备列表
108+
- (void)getVirtualBindDeviceListWithAccessToken:(NSString *)accessToken platformId:(NSString *)platformId offset:(NSUInteger)offset limit:(NSUInteger)limit success:(SRHandler)success failure:(FRHandler)failure;
109+
107110

108111
#pragma mark - 云端定时
109112

Source/SDK/LinkCore/QCAPISets/Public/TIoTCoreDeviceSet.m

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,36 @@ - (void)modifyRoomOfDeviceWithProductId:(NSString *)productId deviceName:(NSStri
653653
}];
654654
}
655655

656+
/// APP拉用户绑定设备列表
657+
- (void)getVirtualBindDeviceListWithAccessToken:(NSString *)accessToken platformId:(NSString *)platformId offset:(NSUInteger)offset limit:(NSUInteger)limit success:(SRHandler)success failure:(FRHandler)failure
658+
{
659+
660+
if (accessToken == nil) {
661+
failure(@"accessToken参数为空",nil,@{});
662+
return;
663+
}
664+
665+
if (platformId == nil) {
666+
failure(@"platformId参数为空",nil,@{});
667+
return;
668+
}
669+
670+
NSMutableDictionary *param = [NSMutableDictionary dictionary];
671+
[param setValue:accessToken forKey:@"AccessToken"];
672+
[param setValue:platformId forKey:@"BindPlatformId"];
673+
if (limit > 0) {
674+
[param setObject:@(offset) forKey:@"Offset"];
675+
[param setObject:@(limit) forKey:@"Limit"];
676+
}
677+
678+
TIoTCoreRequestBuilder *b = [[TIoTCoreRequestBuilder alloc] initWtihAction:AppGetVirtualBindDeviceList params:param useToken:YES];
679+
[TIoTCoreRequestClient sendRequestWithBuild:b.build success:^(id _Nonnull responseObject) {
680+
success(responseObject);
681+
} failure:^(NSString * _Nonnull reason, NSError * _Nonnull error,NSDictionary *dic) {
682+
failure(reason,error,dic);
683+
}];
684+
}
685+
656686

657687
#pragma mark - 云端定时
658688

Source/SDK/LinkCore/QCFoundation/TIoTCoreRequestObject.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ - (void)postRequestWithAction:(NSString *)actionStr url:(NSURL *)url isWithoutT
197197
accessParam = [NSMutableDictionary dictionaryWithDictionary:baseAccessParam];
198198
[accessParam setValue:actionStr forKey:@"Action"];
199199
[accessParam setValue:[[NSUUID UUID] UUIDString] forKey:@"RequestId"];
200-
[accessParam setValue:[TIoTCoreUserManage shared].accessToken forKey:@"AccessToken"];
200+
if (![baseAccessParam.allKeys containsObject:@"AccessToken"]) {
201+
[accessParam setValue:[TIoTCoreUserManage shared].accessToken forKey:@"AccessToken"];
202+
}
201203

202204
}
203205

TIoTLinkKit.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
00ACEA8F26F0CC9D0055EA36 /* TIoTAllDevicesVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 00ACEA8E26F0CC9D0055EA36 /* TIoTAllDevicesVC.m */; };
1011
6D01E86B24F8EE7400234872 /* TIoTUserConfigModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D01E86824F8EE7400234872 /* TIoTUserConfigModel.m */; };
1112
6D01E86C24F8EE7400234872 /* TIoTUserRegionModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D01E86A24F8EE7400234872 /* TIoTUserRegionModel.m */; };
1213
6D06B07425603C50006361B5 /* TIoTAutoCustomTimePeriodView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D06B07325603C50006361B5 /* TIoTAutoCustomTimePeriodView.m */; };
@@ -497,6 +498,8 @@
497498
/* End PBXCopyFilesBuildPhase section */
498499

499500
/* Begin PBXFileReference section */
501+
00ACEA8D26F0CC9D0055EA36 /* TIoTAllDevicesVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TIoTAllDevicesVC.h; sourceTree = "<group>"; };
502+
00ACEA8E26F0CC9D0055EA36 /* TIoTAllDevicesVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TIoTAllDevicesVC.m; sourceTree = "<group>"; };
500503
0A58AA4A144CEE9B3B027556 /* Pods-LinkSDKDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LinkSDKDemo.release.xcconfig"; path = "Pods/Target Support Files/Pods-LinkSDKDemo/Pods-LinkSDKDemo.release.xcconfig"; sourceTree = "<group>"; };
501504
253144D80CC8A037F5D90897 /* Pods-TIoTLinkKitDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TIoTLinkKitDemo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TIoTLinkKitDemo/Pods-TIoTLinkKitDemo.debug.xcconfig"; sourceTree = "<group>"; };
502505
43EF7275574707E3B3D4F776 /* Pods_LinkSDKDemo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LinkSDKDemo.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -3139,6 +3142,8 @@
31393142
F4F3D78024938EBD005D3396 /* ControlDeviceVC.xib */,
31403143
6D50E91026B18CE300DF12A5 /* TIoTDemoWebSocketManager.h */,
31413144
6D50E91126B18CE300DF12A5 /* TIoTDemoWebSocketManager.m */,
3145+
00ACEA8D26F0CC9D0055EA36 /* TIoTAllDevicesVC.h */,
3146+
00ACEA8E26F0CC9D0055EA36 /* TIoTAllDevicesVC.m */,
31423147
);
31433148
path = Device;
31443149
sourceTree = "<group>";
@@ -3754,6 +3759,7 @@
37543759
6D9D97EA26857FA50085BCC2 /* TIoTDemoProductDetailModel.m in Sources */,
37553760
F4F3D7A224938EBE005D3396 /* ControlInfo.m in Sources */,
37563761
6D9D978C26846B280085BCC2 /* TIoTDemoPlayConfigVC.m in Sources */,
3762+
00ACEA8F26F0CC9D0055EA36 /* TIoTAllDevicesVC.m in Sources */,
37573763
6DCB3587259CD908003E03DF /* TIoTWiredDistributionNetVC.m in Sources */,
37583764
6D98FE1B25C2E6B200518AC7 /* TIoTCustomCalendarCell.m in Sources */,
37593765
F4F3265825919C6D00A4CAAB /* TIoTVIdeoQRScanDistributionNet.m in Sources */,

0 commit comments

Comments
 (0)