From fdbcb1f7463cb766f90bd29dd715485ba9d88524 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期三, 06 九月 2023 17:55:03 +0800
Subject: [PATCH] Merge branch 'wxr-2.0' into Dev-Branch
---
HDL_ON/UI/UI2/FuntionControlView/HisenseTV /Send.cs | 83 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 83 insertions(+), 0 deletions(-)
diff --git a/HDL_ON/UI/UI2/FuntionControlView/HisenseTV /Send.cs b/HDL_ON/UI/UI2/FuntionControlView/HisenseTV /Send.cs
index 9f0a66a..525e5e4 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/HisenseTV /Send.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/HisenseTV /Send.cs
@@ -1,5 +1,8 @@
锘縰sing System;
using System.Collections.Generic;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
using HDL_ON.DAL.Server;
using HDL_ON.Entity;
using HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock;
@@ -26,6 +29,46 @@
return sendMethod;
}
+
+ }
+ /// <summary>
+ /// 鎵撳紑娴蜂俊鐢佃
+ /// </summary>
+ /// <param name="deviceMac">鐢佃mac</param>
+ public void Open(string deviceMac)
+ {
+ CommonMethod.Current.SunThread(() =>
+ {
+ // 鍒涘缓UdpClient瀹炰緥
+ UdpClient udpClient = new UdpClient();
+ try
+ {
+ // 璁剧疆鍙戦�佸拰鎺ユ敹鏁版嵁鐨処P鍜岀鍙�
+ IPEndPoint iPEndPoint = new IPEndPoint(IPAddress.Parse("255.255.255.255"), 9);
+ // 鍙戦�佹暟鎹�
+ //byte[] data = System.Text.Encoding.ASCII.GetBytes("Hello, UDP Server!");
+ byte[] data = StrToToHexByte(deviceMac);
+ for (int i = 0; i < 16; i++)
+ {
+ udpClient.Send(data, data.Length, iPEndPoint);
+ //Console.WriteLine("鏁版嵁宸插彂閫�");
+ }
+ //// 鎺ユ敹鏁版嵁
+ //IPEndPoint remoteEP = new IPEndPoint(IPAddress.Any, 0);
+ //byte[] receivedData = udpClient.Receive(ref remoteEP);
+ //string receivedMessage = System.Text.Encoding.ASCII.GetString(receivedData);
+ //Console.WriteLine("鎺ユ敹鍒扮殑鏁版嵁锛�" + receivedMessage);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("鍙戠敓閿欒锛�" + e.Message);
+ }
+ finally
+ {
+ // 鍏抽棴UdpClient杩炴帴
+ udpClient.Close();
+ }
+ }, TipType.none);
}
@@ -65,6 +108,46 @@
{ IsBackground = true }.Start();
}
+ /// <summary>
+ /// 灏�16杩涘埗鐨勫瓧绗︿覆杞负byte[]
+ /// </summary>
+ /// <param name="hexDeviceMacString"></param>
+ /// <returns></returns>
+ private byte[] StrToToHexByte(string hexDeviceMacString)
+ {
+ if (string.IsNullOrEmpty(hexDeviceMacString))
+ {
+ return new byte[] { };
+ }
+ hexDeviceMacString = hexDeviceMacString.Replace(" ", "").Replace("_","");
+ if ((hexDeviceMacString.Length % 2) != 0) {
+ return new byte[] { };
+ }
+ byte[] returnBytes = new byte[hexDeviceMacString.Length / 2];
+ for (int i = 0; i < returnBytes.Length; i++)
+ returnBytes[i] = Convert.ToByte(hexDeviceMacString.Substring(i * 2, 2), 16);
+ return returnBytes;
+ }
+
+ /// <summary>
+ /// 浜岃繘鍒舵暟缁勮浆鍗佸叚杩涘埗瀛楃涓�
+ /// </summary>
+ /// <param name="btyes"></param>
+ /// <returns></returns>
+ private string Byte2hex(byte[] btyes)
+ {
+ StringBuilder sb = new StringBuilder(btyes.Length * 2);
+ for (int i = 0; i < btyes.Length; i++)
+ {
+ int hight = ((btyes[i] >> 4) & 0x0f);
+ int low = btyes[i] & 0x0f;
+ sb.Append(hight > 9 ? (char)((hight - 10) + 'a') : (char)(hight + '0'));
+ sb.Append(low > 9 ? (char)((low - 10) + 'a') : (char)(low + '0'));
+ }
+ return sb.ToString();
+ }
+
+
/// <summary>
///璇锋眰鏈嶅姟鍣紙涓庝綇瀹呮湁鍏�:渚嬪锛沨omeId锛�
--
Gitblit v1.8.0