Skip to content

Commit dcd792a

Browse files
committed
Add gateway by mdns TXT
1 parent 39af8b3 commit dcd792a

File tree

7 files changed

+159
-30
lines changed

7 files changed

+159
-30
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [1.0.5+73]
2+
3+
* Add gateway by mdns TXT
4+
15
## [1.0.5+72]
26

37
* airkiss

lib/commPages/findmDNSClientList.dart

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import 'package:oktoast/oktoast.dart';
77
import 'package:openiothub_api/openiothub_api.dart';
88
import 'package:openiothub_common_pages/openiothub_common_pages.dart';
99
import 'package:openiothub_constants/openiothub_constants.dart';
10+
import 'package:openiothub_grpc_api/google/protobuf/wrappers.pb.dart';
11+
import 'package:openiothub_grpc_api/proto/manager/common.pb.dart';
1012
import 'package:openiothub_grpc_api/proto/manager/gatewayManager.pb.dart';
1113
import 'package:openiothub_grpc_api/proto/manager/serverManager.pb.dart';
1214
import 'package:openiothub_grpc_api/proto/mobile/mobile.pb.dart';
@@ -137,6 +139,11 @@ class _FindmDNSClientListPageState extends State<FindmDNSClientListPage> {
137139
);
138140
return InkWell(
139141
onTap: () {
142+
// 对于mdns含有添加信息的,直接在本页面使用api添加
143+
if (pair.info.containsKey("run_id") && !pair.info["run_id"]!.isEmpty) {
144+
_addToMyAccount(pair.info["run_id"]!, pair.info["server_host"]);
145+
return;
146+
}
140147
//直接打开内置web浏览器浏览页面
141148
Navigator.of(context).push(MaterialPageRoute(builder: (context) {
142149
// return Text("${pair.iP}:${pair.port}");
@@ -196,6 +203,38 @@ class _FindmDNSClientListPageState extends State<FindmDNSClientListPage> {
196203
}));
197204
}
198205

206+
//已经确认过可以添加,添加到我的账号
207+
void _addToMyAccount(String gatewayId, String? host) async {
208+
try {
209+
// TODO 可以搞一个确认步骤,确认后添加
210+
// 使用扫描的Gateway ID构建一个GatewayInfo用于服务器添加
211+
GatewayInfo gatewayInfo = GatewayInfo(
212+
gatewayUuid: gatewayId,
213+
// 服务器的UUID变主机地址,或者都可以
214+
serverUuid: host,
215+
name: "Gateway-${DateTime.now().minute}",
216+
description: "Gateway-${DateTime.now()}");
217+
OperationResponse operationResponse =
218+
await GatewayManager.AddGateway(gatewayInfo);
219+
//将网关映射到本机
220+
if (operationResponse.code == 0) {
221+
// TODO 从服务器获取连接JWT
222+
StringValue openIoTHubJwt =
223+
await GatewayManager.GetOpenIoTHubJwtByGatewayUuid(gatewayId);
224+
await _addToMySessionList(
225+
openIoTHubJwt.value,
226+
"Gateway-${DateTime.now()}",
227+
"Gateway-${DateTime.now()} form scan QR code");
228+
} else {
229+
showToast(
230+
"Response: ${operationResponse.msg}");
231+
}
232+
} catch (exception) {
233+
showToast(
234+
"Failed: ${exception}");
235+
}
236+
}
237+
199238
Future<void> _addGateway() async {
200239
List<DropdownMenuItem<String>> l = await _listAvailableServer();
201240
String? value = l.first.value;

lib/commPages/serverInfo.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,13 @@ class _ServerInfoPageState extends State<ServerInfoPage> {
161161
Text(OpenIoTHubCommonLocalizations.of(context).for_everyone_to_use),
162162
Switch(
163163
value: _is_public,
164-
onChanged: (bool newVal) {
165-
setState(() {
166-
_is_public = newVal;
167-
});
168-
})
164+
onChanged: null,
165+
// TODO 服务器不可公开
166+
// onChanged: (bool newVal) {
167+
// setState(() {
168+
// _is_public = newVal;
169+
// });}
170+
)
169171
],
170172
),
171173
TextButton(

lib/commPages/servers.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,14 @@ class ServerPagesState extends State<ServerPages> {
239239
Text(OpenIoTHubCommonLocalizations.of(context).for_everyone_to_use),
240240
Switch(
241241
value: _is_public,
242-
onChanged: (bool newVal) {
243-
state(() {
244-
_is_public = newVal;
245-
});
246-
})
242+
onChanged: null,
243+
// TODO 服务器不可公开
244+
// onChanged: (bool newVal) {
245+
// state(() {
246+
// _is_public = newVal;
247+
// });
248+
// }
249+
)
247250
],
248251
),
249252
],

lib/user/accountSecurityPage.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ class _AccountSecurityPageState extends State<AccountSecurityPage> {
186186
builder: (_) => AlertDialog(
187187
title: Text("${OpenIoTHubCommonLocalizations.of(context).modify}:$type"),
188188
scrollable: true,
189-
content: SizedBox.expand(
189+
content: SizedBox(
190+
height: 100,
190191
child: ListView(
191192
children: <Widget>[
192193
TextField(

pubspec.lock

Lines changed: 98 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ packages:
99
url: "https://pub.flutter-io.cn"
1010
source: hosted
1111
version: "82.0.0"
12+
after_layout:
13+
dependency: transitive
14+
description:
15+
name: after_layout
16+
sha256: "95a1cb2ca1464f44f14769329fbf15987d20ab6c88f8fc5d359bd362be625f29"
17+
url: "https://pub.flutter-io.cn"
18+
source: hosted
19+
version: "1.2.0"
1220
airkiss_dart:
1321
dependency: "direct main"
1422
description:
@@ -21,18 +29,26 @@ packages:
2129
dependency: transitive
2230
description:
2331
name: analyzer
24-
sha256: f4c21c94eb4623b183c1014a470196b3910701bea9b926e6c91270d756e6fc60
32+
sha256: "13c1e6c6fd460522ea840abec3f677cc226f5fec7872c04ad7b425517ccf54f7"
33+
url: "https://pub.flutter-io.cn"
34+
source: hosted
35+
version: "7.4.4"
36+
animations:
37+
dependency: transitive
38+
description:
39+
name: animations
40+
sha256: d3d6dcfb218225bbe68e87ccf6378bbb2e32a94900722c5f81611dad089911cb
2541
url: "https://pub.flutter-io.cn"
2642
source: hosted
27-
version: "7.4.1"
43+
version: "2.0.11"
2844
archive:
2945
dependency: transitive
3046
description:
3147
name: archive
32-
sha256: a7f37ff061d7abc2fcf213554b9dcaca713c5853afa5c065c44888bc9ccaf813
48+
sha256: "2fde1607386ab523f7a36bb3e7edb43bd58e6edaf2ffb29d8a6d578b297fdbbd"
3349
url: "https://pub.flutter-io.cn"
3450
source: hosted
35-
version: "4.0.6"
51+
version: "4.0.7"
3652
args:
3753
dependency: transitive
3854
description:
@@ -45,10 +61,10 @@ packages:
4561
dependency: transitive
4662
description:
4763
name: asn1lib
48-
sha256: e8953f3698626f6f40c32da22c3348b2c6383e0db224402c53c8b8f3215b1e85
64+
sha256: "0511d6be23b007e95105ae023db599aea731df604608978dada7f9faf2637623"
4965
url: "https://pub.flutter-io.cn"
5066
source: hosted
51-
version: "1.6.3"
67+
version: "1.6.4"
5268
async:
5369
dependency: transitive
5470
description:
@@ -257,6 +273,14 @@ packages:
257273
url: "https://pub.flutter-io.cn"
258274
source: hosted
259275
version: "3.0.0"
276+
contextmenu:
277+
dependency: transitive
278+
description:
279+
name: contextmenu
280+
sha256: e0c7d60e2fc9f316f5b03f5fe2c0f977d65125345d1a1f77eea02be612e32d0c
281+
url: "https://pub.flutter-io.cn"
282+
source: hosted
283+
version: "3.0.0"
260284
convert:
261285
dependency: transitive
262286
description:
@@ -454,6 +478,14 @@ packages:
454478
description: flutter
455479
source: sdk
456480
version: "0.0.0"
481+
flutter_breadcrumb:
482+
dependency: transitive
483+
description:
484+
name: flutter_breadcrumb
485+
sha256: "1531680034def621878562ad763079933dabe9f9f5d5add5a094190edc33259b"
486+
url: "https://pub.flutter-io.cn"
487+
source: hosted
488+
version: "1.0.1"
457489
flutter_cache_manager:
458490
dependency: transitive
459491
description:
@@ -585,10 +617,10 @@ packages:
585617
dependency: transitive
586618
description:
587619
name: google_identity_services_web
588-
sha256: "55580f436822d64c8ff9a77e37d61f5fb1e6c7ec9d632a43ee324e2a05c3c6c9"
620+
sha256: "5d187c46dc59e02646e10fe82665fc3884a9b71bc1c90c2b8b749316d33ee454"
589621
url: "https://pub.flutter-io.cn"
590622
source: hosted
591-
version: "0.3.3"
623+
version: "0.3.3+1"
592624
googleapis_auth:
593625
dependency: transitive
594626
description:
@@ -625,10 +657,10 @@ packages:
625657
dependency: transitive
626658
description:
627659
name: html
628-
sha256: "9475be233c437f0e3637af55e7702cbbe5c23a68bd56e8a5fa2d426297b7c6c8"
660+
sha256: "6d1264f2dffa1b1101c25a91dff0dc2daee4c18e87cd8538729773c073dbf602"
629661
url: "https://pub.flutter-io.cn"
630662
source: hosted
631-
version: "0.15.5+1"
663+
version: "0.15.6"
632664
http:
633665
dependency: transitive
634666
description:
@@ -857,10 +889,10 @@ packages:
857889
dependency: "direct main"
858890
description:
859891
name: network_info_plus
860-
sha256: "08f4166bbb77da9e407edef6322a33f87b18c0ca46483fb25606cb3d2bfcdd2a"
892+
sha256: f926b2ba86aa0086a0dfbb9e5072089bc213d854135c1712f1d29fc89ba3c877
861893
url: "https://pub.flutter-io.cn"
862894
source: hosted
863-
version: "6.1.3"
895+
version: "6.1.4"
864896
network_info_plus_platform_interface:
865897
dependency: transitive
866898
description:
@@ -921,10 +953,10 @@ packages:
921953
dependency: "direct main"
922954
description:
923955
name: openiothub_plugin
924-
sha256: a86ff776971572ca82f17a78276e5fb24afe67740d74f6b2154392afa0d52fde
956+
sha256: "2c32baf0f5cd21e1b101ed490e878fc06973e23d8220f8e1d543e59531a678d8"
925957
url: "https://pub.flutter-io.cn"
926958
source: hosted
927-
version: "1.0.2+38"
959+
version: "1.0.2+45"
928960
package_config:
929961
dependency: transitive
930962
description:
@@ -1021,6 +1053,14 @@ packages:
10211053
url: "https://pub.flutter-io.cn"
10221054
source: hosted
10231055
version: "2.3.0"
1056+
pedantic:
1057+
dependency: transitive
1058+
description:
1059+
name: pedantic
1060+
sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602"
1061+
url: "https://pub.flutter-io.cn"
1062+
source: hosted
1063+
version: "1.11.1"
10241064
permission_handler:
10251065
dependency: "direct main"
10261066
description:
@@ -1470,10 +1510,10 @@ packages:
14701510
dependency: transitive
14711511
description:
14721512
name: url_launcher_web
1473-
sha256: "3ba963161bd0fe395917ba881d320b9c4f6dd3c4a233da62ab18a5025c85f1e9"
1513+
sha256: "4bd2b7b4dc4d4d0b94e5babfffbca8eac1a126c7f3d6ecbc1a11013faa3abba2"
14741514
url: "https://pub.flutter-io.cn"
14751515
source: hosted
1476-
version: "2.4.0"
1516+
version: "2.4.1"
14771517
url_launcher_windows:
14781518
dependency: transitive
14791519
description:
@@ -1522,6 +1562,46 @@ packages:
15221562
url: "https://pub.flutter-io.cn"
15231563
source: hosted
15241564
version: "2.1.4"
1565+
video_player:
1566+
dependency: transitive
1567+
description:
1568+
name: video_player
1569+
sha256: "7d78f0cfaddc8c19d4cb2d3bebe1bfef11f2103b0a03e5398b303a1bf65eeb14"
1570+
url: "https://pub.flutter-io.cn"
1571+
source: hosted
1572+
version: "2.9.5"
1573+
video_player_android:
1574+
dependency: transitive
1575+
description:
1576+
name: video_player_android
1577+
sha256: ae7d4f1b41e3ac6d24dd9b9d5d6831b52d74a61bdd90a7a6262a33d8bb97c29a
1578+
url: "https://pub.flutter-io.cn"
1579+
source: hosted
1580+
version: "2.8.2"
1581+
video_player_avfoundation:
1582+
dependency: transitive
1583+
description:
1584+
name: video_player_avfoundation
1585+
sha256: "9ee764e5cd2fc1e10911ae8ad588e1a19db3b6aa9a6eb53c127c42d3a3c3f22f"
1586+
url: "https://pub.flutter-io.cn"
1587+
source: hosted
1588+
version: "2.7.1"
1589+
video_player_platform_interface:
1590+
dependency: transitive
1591+
description:
1592+
name: video_player_platform_interface
1593+
sha256: df534476c341ab2c6a835078066fc681b8265048addd853a1e3c78740316a844
1594+
url: "https://pub.flutter-io.cn"
1595+
source: hosted
1596+
version: "6.3.0"
1597+
video_player_web:
1598+
dependency: transitive
1599+
description:
1600+
name: video_player_web
1601+
sha256: e8bba2e5d1e159d5048c9a491bb2a7b29c535c612bb7d10c1e21107f5bd365ba
1602+
url: "https://pub.flutter-io.cn"
1603+
source: hosted
1604+
version: "2.3.5"
15251605
vm_service:
15261606
dependency: transitive
15271607
description:
@@ -1574,10 +1654,10 @@ packages:
15741654
dependency: transitive
15751655
description:
15761656
name: webview_flutter_android
1577-
sha256: "5c3b6f992d123084903ec091b84f021c413a92a9af49038e4564a1b26c8452cf"
1657+
sha256: "6b0eae02b7604954b80ee9a29507ac38f5de74b712faa6fee33abc1cdedc1b21"
15781658
url: "https://pub.flutter-io.cn"
15791659
source: hosted
1580-
version: "4.4.1"
1660+
version: "4.4.2"
15811661
webview_flutter_platform_interface:
15821662
dependency: transitive
15831663
description:

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: openiothub_common_pages
22
description: openiothub_common_pages
3-
version: 1.0.5+72
3+
version: 1.0.5+73
44
homepage: https://github.com/OpenIoTHub
55

66
environment:

0 commit comments

Comments
 (0)