完善对讲功能
This commit is contained in:
parent
597ff218a9
commit
62b95c6d88
BIN
star_lock/images/main/icon_lockDetail_hangUp.png
Normal file
BIN
star_lock/images/main/icon_lockDetail_hangUp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
BIN
star_lock/images/main/icon_lockDetail_monitoringAnswerCalls.png
Normal file
BIN
star_lock/images/main/icon_lockDetail_monitoringAnswerCalls.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
BIN
star_lock/images/main/icon_lockDetail_monitoringUnTalkback.png
Normal file
BIN
star_lock/images/main/icon_lockDetail_monitoringUnTalkback.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
@ -127,8 +127,6 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
|
|||||||
|
|
||||||
initAliyunPush();
|
initAliyunPush();
|
||||||
|
|
||||||
// playLocalAudio();
|
|
||||||
|
|
||||||
// Uint8List uint8List = Uint8List.fromList([]);
|
// Uint8List uint8List = Uint8List.fromList([]);
|
||||||
// CallTalk talkClass = CallTalk();
|
// CallTalk talkClass = CallTalk();
|
||||||
// talkClass.getAVData(uint8List, 90);
|
// talkClass.getAVData(uint8List, 90);
|
||||||
@ -192,9 +190,3 @@ Future _setCommonServices() async {
|
|||||||
// Get.log(PlatformInfoService.to.info.version);
|
// Get.log(PlatformInfoService.to.info.version);
|
||||||
}
|
}
|
||||||
|
|
||||||
//播放本地音频
|
|
||||||
void playLocalAudio() async {
|
|
||||||
final audioPlayer = AudioPlayer();
|
|
||||||
audioPlayer.setReleaseMode(ReleaseMode.loop);
|
|
||||||
await audioPlayer.play(AssetSource('ring1.mp3'));
|
|
||||||
}
|
|
||||||
|
|||||||
@ -17,6 +17,15 @@ class LockMonitoringLogic extends BaseGetXController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 收到接听状态
|
||||||
|
StreamSubscription? _getUDPStatusRefreshUIEvent;
|
||||||
|
void _getUDPStatusRefreshUIAction() {
|
||||||
|
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
||||||
|
_getTVDataRefreshUIEvent = eventBus.on<GetUDPStatusRefreshUI>().listen((event) {
|
||||||
|
state.udpStatus.value = event.udpStatus;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onReady() {
|
void onReady() {
|
||||||
// TODO: implement onReady
|
// TODO: implement onReady
|
||||||
@ -24,6 +33,7 @@ class LockMonitoringLogic extends BaseGetXController {
|
|||||||
print("onReady()");
|
print("onReady()");
|
||||||
|
|
||||||
_getTVDataRefreshUIAction();
|
_getTVDataRefreshUIAction();
|
||||||
|
_getUDPStatusRefreshUIAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -38,6 +48,7 @@ class LockMonitoringLogic extends BaseGetXController {
|
|||||||
// TODO: implement onClose
|
// TODO: implement onClose
|
||||||
print("锁详情界面销毁了");
|
print("锁详情界面销毁了");
|
||||||
_getTVDataRefreshUIEvent!.cancel();
|
_getTVDataRefreshUIEvent!.cancel();
|
||||||
|
_getUDPStatusRefreshUIEvent!.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2,9 +2,15 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:network_info_plus/network_info_plus.dart';
|
||||||
|
|
||||||
import '../../../../appRouters.dart';
|
import '../../../../appRouters.dart';
|
||||||
import '../../../../app_settings/app_colors.dart';
|
import '../../../../app_settings/app_colors.dart';
|
||||||
|
import '../../../../talk/udp/udp_manage.dart';
|
||||||
|
import '../../../../talk/udp/udp_senderManage.dart';
|
||||||
|
import '../../../../tools/showTFView.dart';
|
||||||
|
import '../../../../tools/storage.dart';
|
||||||
|
import '../../../../tools/toast.dart';
|
||||||
import 'lockMonitoring_logic.dart';
|
import 'lockMonitoring_logic.dart';
|
||||||
|
|
||||||
class LockMonitoringPage extends StatefulWidget {
|
class LockMonitoringPage extends StatefulWidget {
|
||||||
@ -142,19 +148,97 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget bottomBottomBtnWidget() {
|
Widget bottomBottomBtnWidget() {
|
||||||
return Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
|
return Row(
|
||||||
bottomBtnItemWidget("images/main/icon_lockDetail_monitoringTalkback.png",
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
"点击对讲", Colors.white, () {}),
|
children: [
|
||||||
bottomBtnItemWidget("images/main/icon_lockDetail_monitoringUnlock.png",
|
Obx(() => bottomBtnItemWidget(getAnswerBtnImg(), getAnswerBtnName(), Colors.white, () async {
|
||||||
"长按开锁", AppColors.mainColor, () {})
|
var userMobileIP = await NetworkInfo().getWifiIP();
|
||||||
|
var userMobile = await Storage.getMobile();
|
||||||
|
|
||||||
|
// 刚进来是接听状态,然后改为长按对讲
|
||||||
|
UDPSenderManage.sendMainProtocol(
|
||||||
|
command: 150,
|
||||||
|
commandTypeIsCalling: 1,
|
||||||
|
subCommand: 6,
|
||||||
|
lockID: UDPManage().lockId,
|
||||||
|
lockIP: UDPManage().host,
|
||||||
|
userMobile: userMobile,
|
||||||
|
userMobileIP: userMobileIP,
|
||||||
|
endData: []);
|
||||||
|
})),
|
||||||
|
bottomBtnItemWidget("images/main/icon_lockDetail_hangUp.png", "挂断", Colors.red, () async {
|
||||||
|
var userMobileIP = await NetworkInfo().getWifiIP();
|
||||||
|
var userMobile = await Storage.getMobile();
|
||||||
|
|
||||||
|
// 挂断
|
||||||
|
UDPSenderManage.sendMainProtocol(
|
||||||
|
command: 150,
|
||||||
|
commandTypeIsCalling: 1,
|
||||||
|
subCommand: 30,
|
||||||
|
lockID: UDPManage().lockId,
|
||||||
|
lockIP: UDPManage().host,
|
||||||
|
userMobile: userMobile,
|
||||||
|
userMobileIP: userMobileIP,
|
||||||
|
endData: []);
|
||||||
|
}),
|
||||||
|
bottomBtnItemWidget("images/main/icon_lockDetail_monitoringUnlock.png", "开锁", AppColors.mainColor, () {
|
||||||
|
showDeletPasswordAlertDialog(context);
|
||||||
|
})
|
||||||
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getAnswerBtnImg(){
|
||||||
|
switch (state.udpStatus.value) {
|
||||||
|
case 8:
|
||||||
|
{
|
||||||
|
return "images/main/icon_lockDetail_monitoringUnTalkback.png";
|
||||||
|
}
|
||||||
|
case 9:
|
||||||
|
{
|
||||||
|
return "images/main/icon_lockDetail_monitoringTalkback.png";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return "images/main/icon_lockDetail_monitoringAnswerCalls.png";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String getAnswerBtnName(){
|
||||||
|
switch (state.udpStatus.value) {
|
||||||
|
case 8:
|
||||||
|
{
|
||||||
|
return "长按说话";
|
||||||
|
}
|
||||||
|
case 9:
|
||||||
|
{
|
||||||
|
return "松开发送";
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return "接听";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Widget bottomBtnItemWidget(
|
Widget bottomBtnItemWidget(
|
||||||
String iconUrl, String name, Color backgroundColor, Function() onClick) {
|
String iconUrl, String name, Color backgroundColor, Function() onClick) {
|
||||||
var wh = 80.w;
|
var wh = 80.w;
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: onClick,
|
onTap: onClick,
|
||||||
|
onLongPress: (){
|
||||||
|
print("onLongPress");
|
||||||
|
if(state.udpStatus.value == 8){
|
||||||
|
state.udpStatus.value = 9;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLongPressUp: () {
|
||||||
|
print("onLongPressUp");
|
||||||
|
if(state.udpStatus.value == 9){
|
||||||
|
state.udpStatus.value = 8;
|
||||||
|
}
|
||||||
|
},
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 140.h,
|
height: 140.h,
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -178,4 +262,43 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
|
|||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showDeletPasswordAlertDialog(BuildContext context) {
|
||||||
|
showDialog(
|
||||||
|
barrierDismissible:false,
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return ShowTFView(
|
||||||
|
title: "请输入开锁密码",
|
||||||
|
tipTitle: "",
|
||||||
|
controller: state.passwordTF,
|
||||||
|
sureClick: () async {
|
||||||
|
//发送删除锁请求
|
||||||
|
if (state.passwordTF.text.isEmpty) {
|
||||||
|
Toast.show(msg: "请输入开锁密码");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var userMobileIP = await NetworkInfo().getWifiIP();
|
||||||
|
var userMobile = await Storage.getMobile();
|
||||||
|
|
||||||
|
// 开锁
|
||||||
|
UDPSenderManage.sendMainProtocol(
|
||||||
|
command: 150,
|
||||||
|
commandTypeIsCalling: 1,
|
||||||
|
subCommand: 10,
|
||||||
|
lockID: UDPManage().lockId,
|
||||||
|
lockIP: UDPManage().host,
|
||||||
|
userMobile: userMobile,
|
||||||
|
userMobileIP: userMobileIP,
|
||||||
|
endData: []);
|
||||||
|
Get.back();
|
||||||
|
},
|
||||||
|
cancelClick: () {
|
||||||
|
Get.back();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,13 @@
|
|||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
class LockMonitoringState {
|
class LockMonitoringState {
|
||||||
var isOpenVoice = false.obs;
|
|
||||||
|
|
||||||
|
var isOpenVoice = false.obs;
|
||||||
|
var udpStatus = 0.obs; //0:初始状态 1:等待监视 2: 3:监视中 4:呼叫成功 5:主角通话中 6:被叫通话 8:被叫通话中 9:长按说话
|
||||||
|
var passwordTF = TextEditingController();
|
||||||
var listData = <int>[].obs;
|
var listData = <int>[].obs;
|
||||||
|
|
||||||
Uint8List imageData = Uint8List.fromList([
|
Uint8List imageData = Uint8List.fromList([
|
||||||
|
|||||||
@ -57,6 +57,7 @@ class CallTalk {
|
|||||||
// 用你的711音频数据替换这里的Uint8List
|
// 用你的711音频数据替换这里的Uint8List
|
||||||
Uint8List rawData = G711Decoder().decodeG711uLaw(bb);
|
Uint8List rawData = G711Decoder().decodeG711uLaw(bb);
|
||||||
_playRawData(rawData);
|
_playRawData(rawData);
|
||||||
|
print('收到音频数据了');
|
||||||
}
|
}
|
||||||
// 视频数据
|
// 视频数据
|
||||||
else {
|
else {
|
||||||
|
|||||||
@ -16,7 +16,7 @@ class UDPMainProtocolCommand extends UDPSenderProtocol {
|
|||||||
String? lockIP;
|
String? lockIP;
|
||||||
String? userMobile;
|
String? userMobile;
|
||||||
String? userMobileIP;
|
String? userMobileIP;
|
||||||
List<int>? data;
|
List<int>? endData;
|
||||||
|
|
||||||
UDPMainProtocolCommand({
|
UDPMainProtocolCommand({
|
||||||
this.command,
|
this.command,
|
||||||
@ -26,7 +26,7 @@ class UDPMainProtocolCommand extends UDPSenderProtocol {
|
|||||||
this.lockIP,
|
this.lockIP,
|
||||||
this.userMobile,
|
this.userMobile,
|
||||||
this.userMobileIP,
|
this.userMobileIP,
|
||||||
this.data,
|
this.endData,
|
||||||
}) : super(CommandUDPType.heart);
|
}) : super(CommandUDPType.heart);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -12,36 +12,39 @@ import 'udp_senderManage.dart';
|
|||||||
|
|
||||||
class UdpHelp{
|
class UdpHelp{
|
||||||
|
|
||||||
|
Timer? timer;
|
||||||
openUDP() async {
|
openUDP() async {
|
||||||
// 从服务器获取ip跟端口
|
// 从服务器获取ip跟端口
|
||||||
var entity = await ApiRepository.to.getWifiLockServiceIpAndPort();
|
var entity = await ApiRepository.to.getWifiLockServiceIpAndPort();
|
||||||
if(entity.errorCode! == 0){
|
if(entity.errorCode! == 0){
|
||||||
UDPManage();
|
UDPManage();
|
||||||
// UDPManage().initUdp();
|
// UDPManage().initUdp();
|
||||||
// UDPManage().host = entity.data!.serviceList![0].serviceIp!;
|
UDPManage().port = int.parse(entity.data!.serviceList![0].port!);
|
||||||
// UDPManage().port = int.parse(entity.data!.serviceList![0].port!);
|
|
||||||
|
|
||||||
var serversList = <int>[];
|
var serversList = <int>[];
|
||||||
for(int i = 0; i<entity.data!.serviceList!.length; i++){
|
for(int i = 0; i<entity.data!.serviceList!.length; i++){
|
||||||
var item = entity.data!.serviceList![i];
|
var item = entity.data!.serviceList![i];
|
||||||
if(item.serviceIp!.contains("192")){
|
if(item.serviceIp!.contains("192")){
|
||||||
|
UDPManage().host = entity.data!.serviceList![0].serviceIp!;
|
||||||
var itemList = item.serviceIp!.split(".");
|
var itemList = item.serviceIp!.split(".");
|
||||||
for (var element in itemList) {
|
for (var element in itemList) {
|
||||||
serversList.add(int.parse(element));
|
serversList.add(int.parse(element));
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
List<InternetAddress> addresses = await InternetAddress.lookup(item.serviceIp!);
|
List<InternetAddress> addresses = await InternetAddress.lookup(item.serviceIp!);
|
||||||
|
UDPManage().host = addresses.first.address;
|
||||||
var itemList = addresses.first.address.split(".");
|
var itemList = addresses.first.address.split(".");
|
||||||
for (var element in itemList) {
|
for (var element in itemList) {
|
||||||
serversList.add(int.parse(element));
|
serversList.add(int.parse(element));
|
||||||
}
|
}
|
||||||
print('Resolved google.com to address: ${addresses.first.address} serversList:${serversList}');
|
print('Resolved google.com to address: ${addresses.first.address} serversList:$serversList');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer timer = Timer.periodic(1.seconds, (timer) async {
|
var mobile = await Storage.getMobile();
|
||||||
|
timer = Timer.periodic(1.seconds, (timer) async {
|
||||||
UDPSenderManage.sendHeart(
|
UDPSenderManage.sendHeart(
|
||||||
userName: await Storage.getMobile(),
|
userName: mobile,
|
||||||
ipList: serversList,
|
ipList: serversList,
|
||||||
tokenStr: "b989fa15f75c2ac02718b7c9bb64f80e",
|
tokenStr: "b989fa15f75c2ac02718b7c9bb64f80e",
|
||||||
);
|
);
|
||||||
@ -49,11 +52,15 @@ class UdpHelp{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getWifiLockServiceIpAndPort() async {
|
// Future<void> getWifiLockServiceIpAndPort() async {
|
||||||
var entity = await ApiRepository.to.getWifiLockServiceIpAndPort();
|
// var entity = await ApiRepository.to.getWifiLockServiceIpAndPort();
|
||||||
if(entity.errorCode! == 0){
|
// if(entity.errorCode! == 0){
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
dispose(){
|
||||||
|
timer!.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
@ -31,16 +30,18 @@ class UDPManage{
|
|||||||
|
|
||||||
StreamSubscription<EventSendModel>? _streamSubscription;
|
StreamSubscription<EventSendModel>? _streamSubscription;
|
||||||
RawDatagramSocket? _udpSocket;
|
RawDatagramSocket? _udpSocket;
|
||||||
String host = '47.106.143.213';
|
// String host = '47.106.143.213';
|
||||||
int port = 8056;
|
// int port = 8056;
|
||||||
// String? _mIp = '';
|
// String? _mIp = '';
|
||||||
// String host = '';
|
String host = '';
|
||||||
// int port = 0;
|
int port = 0;
|
||||||
|
String lockId = '';// 锁id 通过锁id来判断是哪把锁发对讲过来
|
||||||
|
|
||||||
void initUdp() async {
|
void initUdp() async {
|
||||||
var listAddress = InternetAddress.lookup(host!);
|
var listAddress = InternetAddress.lookup(host!);
|
||||||
listAddress.then((list) {
|
listAddress.then((list) {
|
||||||
list.forEach((element) {
|
list.forEach((element) {
|
||||||
|
// print('Udp ----> element.address:${element.address} element.host:${element.host}');
|
||||||
host = element.address;
|
host = element.address;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -52,6 +53,7 @@ class UDPManage{
|
|||||||
print('❌ Udp ----> _port == 0');
|
print('❌ Udp ----> _port == 0');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
print('Udp ----> host:$host port:$port');
|
||||||
var addressIListenFrom = InternetAddress.anyIPv4;
|
var addressIListenFrom = InternetAddress.anyIPv4;
|
||||||
int portIListenOn = 62288;
|
int portIListenOn = 62288;
|
||||||
RawDatagramSocket.bind(addressIListenFrom, portIListenOn).then((RawDatagramSocket socket){
|
RawDatagramSocket.bind(addressIListenFrom, portIListenOn).then((RawDatagramSocket socket){
|
||||||
|
|||||||
@ -1,5 +1,10 @@
|
|||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
import 'package:star_lock/talk/udp/udp_manage.dart';
|
||||||
|
|
||||||
|
import '../../blue/io_tool/io_tool.dart';
|
||||||
|
import '../../tools/eventBusEventManage.dart';
|
||||||
import '../../tools/toast.dart';
|
import '../../tools/toast.dart';
|
||||||
import '../call/callTalk.dart';
|
import '../call/callTalk.dart';
|
||||||
import 'udp_talkClass.dart';
|
import 'udp_talkClass.dart';
|
||||||
@ -14,7 +19,7 @@ class CommandUDPReciverManager {
|
|||||||
if (dataSize < 4) {
|
if (dataSize < 4) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
print("appDataReceiveUDPData:$data");
|
// print("appReceiveUDPData:$data");
|
||||||
|
|
||||||
Uint8List data1 = Uint8List.fromList(data);
|
Uint8List data1 = Uint8List.fromList(data);
|
||||||
if (data1.length == 1) {
|
if (data1.length == 1) {
|
||||||
@ -26,6 +31,7 @@ class CommandUDPReciverManager {
|
|||||||
if (data[6] == 4) {
|
if (data[6] == 4) {
|
||||||
if (data[7] == 2) {
|
if (data[7] == 2) {
|
||||||
// print("心跳包反馈 在线状态");
|
// print("心跳包反馈 在线状态");
|
||||||
|
|
||||||
} else if (data[7] == 3) {
|
} else if (data[7] == 3) {
|
||||||
[Toast.show(msg: "您已在其他设备登录")];
|
[Toast.show(msg: "您已在其他设备登录")];
|
||||||
}
|
}
|
||||||
@ -42,6 +48,11 @@ class CommandUDPReciverManager {
|
|||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
//被叫
|
//被叫
|
||||||
|
// lockId
|
||||||
|
var lockId = data.sublist(9, 29);
|
||||||
|
var lockIdStr = utf8String(lockId);
|
||||||
|
UDPManage().lockId = lockIdStr;
|
||||||
|
|
||||||
UDPTalkClass().beCallW(data: data);
|
UDPTalkClass().beCallW(data: data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -51,6 +62,10 @@ class CommandUDPReciverManager {
|
|||||||
if ((data[7] & 0x3) == 2) {
|
if ((data[7] & 0x3) == 2) {
|
||||||
//被叫 接听反馈
|
//被叫 接听反馈
|
||||||
print("接听反馈");
|
print("接听反馈");
|
||||||
|
UDPTalkClass().status = 8;
|
||||||
|
// 停止声音
|
||||||
|
UDPTalkClass().stopLocalAudio();
|
||||||
|
eventBus.fire(GetUDPStatusRefreshUI(UDPTalkClass().status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -77,21 +92,29 @@ class CommandUDPReciverManager {
|
|||||||
case 10:
|
case 10:
|
||||||
{
|
{
|
||||||
//开门反馈
|
//开门反馈
|
||||||
|
print("appReceiveUDPData:$data");
|
||||||
if ((data[7] & 0x3) == 2) {
|
if ((data[7] & 0x3) == 2) {
|
||||||
print("开门成功");
|
print("开门成功");
|
||||||
} else {}
|
Toast.show(msg: "开门成功");
|
||||||
|
} else {
|
||||||
|
print("开门失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 30:
|
case 30:
|
||||||
{
|
{
|
||||||
//开门反馈
|
// 挂断
|
||||||
if ((data[7] & 0x3) == 1) {
|
if ((data[7] & 0x3) == 1) {
|
||||||
//对方结束对讲
|
// 对方结束对讲
|
||||||
print("对方结束对讲");
|
print("对方结束对讲");
|
||||||
} else {
|
} else {
|
||||||
//结束对讲反馈
|
//结束对讲反馈
|
||||||
print("结束对讲反馈");
|
print("结束对讲反馈");
|
||||||
}
|
}
|
||||||
|
UDPTalkClass().status = 0;
|
||||||
|
Get.back();
|
||||||
|
UDPTalkClass().stopLocalAudio();
|
||||||
|
eventBus.fire(GetUDPStatusRefreshUI(UDPTalkClass().status));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 140:
|
case 140:
|
||||||
|
|||||||
@ -24,7 +24,7 @@ class UDPSenderManage {
|
|||||||
String? lockIP,
|
String? lockIP,
|
||||||
String? userMobile,
|
String? userMobile,
|
||||||
String? userMobileIP,
|
String? userMobileIP,
|
||||||
List<int>? data,
|
List<int>? endData,
|
||||||
CommandUDPSendCallBack? callBack}) {
|
CommandUDPSendCallBack? callBack}) {
|
||||||
CommandUDPSenderManager().managerSendData(command: UDPMainProtocolCommand(
|
CommandUDPSenderManager().managerSendData(command: UDPMainProtocolCommand(
|
||||||
command: command,
|
command: command,
|
||||||
@ -34,7 +34,7 @@ class UDPSenderManage {
|
|||||||
lockIP: lockIP,
|
lockIP: lockIP,
|
||||||
userMobile: userMobile,
|
userMobile: userMobile,
|
||||||
userMobileIP: userMobileIP,
|
userMobileIP: userMobileIP,
|
||||||
data: data,
|
endData: endData,
|
||||||
), callBack: callBack);
|
), callBack: callBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:audioplayers/audioplayers.dart';
|
||||||
import 'package:fast_gbk/fast_gbk.dart';
|
import 'package:fast_gbk/fast_gbk.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@ -21,11 +22,12 @@ class UDPTalkClass{
|
|||||||
|
|
||||||
UDPTalkClass._init();
|
UDPTalkClass._init();
|
||||||
|
|
||||||
var status = 0;// 0空闲
|
var status = 0; //0:初始状态 1:等待监视 2: 3:监视中 4:呼叫成功 5:主角通话中 6:被叫通话 8:被叫通话中
|
||||||
var remoteEquid;// 手机号
|
var remoteEquid;// 手机号
|
||||||
late Timer timer;
|
late Timer timer;
|
||||||
// 该字段是为了判断是否跳转到接听界面 挂断或者退出接听界面要记得变更状态
|
// 该字段是为了判断是否跳转到接听界面 挂断或者退出接听界面要记得变更状态
|
||||||
var isBeCall = false;
|
var isBeCall = false;
|
||||||
|
final audioPlayer = AudioPlayer();
|
||||||
|
|
||||||
beCallW({List<int>? data, String? ip, int? port}) async {
|
beCallW({List<int>? data, String? ip, int? port}) async {
|
||||||
// print("beCall");
|
// print("beCall");
|
||||||
@ -70,6 +72,7 @@ class UDPTalkClass{
|
|||||||
Get.toNamed(Routers.lockMonitoringPage, arguments: {
|
Get.toNamed(Routers.lockMonitoringPage, arguments: {
|
||||||
"lockId": "111"
|
"lockId": "111"
|
||||||
});
|
});
|
||||||
|
playLocalAudio();
|
||||||
}else{
|
}else{
|
||||||
// 忙
|
// 忙
|
||||||
|
|
||||||
@ -111,4 +114,16 @@ class UDPTalkClass{
|
|||||||
return equid;
|
return equid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//播放本地音频
|
||||||
|
void playLocalAudio() async {
|
||||||
|
audioPlayer.setReleaseMode(ReleaseMode.loop);
|
||||||
|
await audioPlayer.play(AssetSource('ring1.mp3'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 停止播放本地音频
|
||||||
|
void stopLocalAudio() async {
|
||||||
|
audioPlayer.setReleaseMode(ReleaseMode.loop);
|
||||||
|
await audioPlayer.stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -60,4 +60,10 @@ class LockSetChangeSetRefreshLockDetailWithType{
|
|||||||
class GetTVDataRefreshUI{
|
class GetTVDataRefreshUI{
|
||||||
List<int> tvList;
|
List<int> tvList;
|
||||||
GetTVDataRefreshUI(this.tvList);
|
GetTVDataRefreshUI(this.tvList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 获取到UDP接收状态然后刷新界面
|
||||||
|
class GetUDPStatusRefreshUI{
|
||||||
|
int udpStatus;
|
||||||
|
GetUDPStatusRefreshUI(this.udpStatus);
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ class Storage {
|
|||||||
if (data != null && data.isNotEmpty) {
|
if (data != null && data.isNotEmpty) {
|
||||||
uid = LoginData.fromJson(jsonDecode(data)).uid.toString();
|
uid = LoginData.fromJson(jsonDecode(data)).uid.toString();
|
||||||
}
|
}
|
||||||
print("pubUid:$uid");
|
// print("pubUid:$uid");
|
||||||
return uid;
|
return uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ class Storage {
|
|||||||
if (data != null && data.isNotEmpty) {
|
if (data != null && data.isNotEmpty) {
|
||||||
mobile = LoginData.fromJson(jsonDecode(data)).mobile.toString();
|
mobile = LoginData.fromJson(jsonDecode(data)).mobile.toString();
|
||||||
}
|
}
|
||||||
print("pubUserId:$mobile");
|
// print("mobile:$mobile");
|
||||||
return mobile;
|
return mobile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user