feat: 配置板子网络时,更新动态mac
This commit is contained in:
@@ -51,7 +51,7 @@ public class DataController : ControllerBase
|
||||
public DateTime? BoardExpireTime { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// 获取本机IP地址(优先选择与实验板同网段的IP)
|
||||
/// </summary>
|
||||
/// <returns>本机IP地址</returns>
|
||||
@@ -60,7 +60,7 @@ public class DataController : ControllerBase
|
||||
try
|
||||
{
|
||||
var boardIpSegments = BOARD_IP.Split('.').Take(3).ToArray();
|
||||
|
||||
|
||||
// 优先选择与实验板IP前三段相同的IP
|
||||
var sameSegmentIP = System.Net.NetworkInformation.NetworkInterface
|
||||
.GetAllNetworkInterfaces()
|
||||
@@ -278,7 +278,7 @@ public class DataController : ControllerBase
|
||||
return NotFound("没有可用的实验板");
|
||||
|
||||
var boardInfo = boardOpt.Value;
|
||||
if (!(await Arp.CheckOrAddAsync(boardInfo.IpAddr, boardInfo.MacAddr, GetLocalIPAddress().ToString())))
|
||||
if (!(await ArpClient.CheckOrAddAsync(boardInfo.IpAddr, boardInfo.MacAddr, GetLocalIPAddress().ToString())))
|
||||
{
|
||||
logger.Error($"无法配置ARP,实验板可能会无法连接");
|
||||
}
|
||||
@@ -346,7 +346,7 @@ public class DataController : ControllerBase
|
||||
return NotFound("未找到对应的实验板");
|
||||
|
||||
var boardInfo = ret.Value.Value;
|
||||
if (!(await Arp.CheckOrAddAsync(boardInfo.IpAddr, boardInfo.MacAddr, GetLocalIPAddress().ToString())))
|
||||
if (!(await ArpClient.CheckOrAddAsync(boardInfo.IpAddr, boardInfo.MacAddr, GetLocalIPAddress().ToString())))
|
||||
{
|
||||
logger.Error($"无法配置ARP,实验板可能会无法连接");
|
||||
}
|
||||
@@ -490,4 +490,3 @@ public class DataController : ControllerBase
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -380,7 +380,7 @@ public class DebuggerController : ControllerBase
|
||||
}
|
||||
|
||||
var rawData = dataResult.Value;
|
||||
logger.Debug($"rawData: {BitConverter.ToString(rawData)}");
|
||||
// logger.Debug($"rawData: {BitConverter.ToString(rawData)}");
|
||||
int depth = (int)config.captureDepth;
|
||||
int portDataLen = 4 * depth;
|
||||
int portNum = (int)config.totalPortNum;
|
||||
@@ -413,8 +413,7 @@ public class DebuggerController : ControllerBase
|
||||
}
|
||||
var channelBytes = new byte[4 * depth];
|
||||
Buffer.BlockCopy(channelUintArr, 0, channelBytes, 0, channelBytes.Length);
|
||||
channelBytes = Common.Number.ReverseBytes(channelBytes, 4).Value;
|
||||
logger.Debug($"{channel.name} HexData: {BitConverter.ToString(channelBytes)}");
|
||||
// logger.Debug($"{channel.name} HexData: {BitConverter.ToString(channelBytes)}");
|
||||
var base64 = Convert.ToBase64String(channelBytes);
|
||||
channelDataList.Add(new ChannelCaptureData { name = channel.name, data = base64 });
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ public class NetConfigController : ControllerBase
|
||||
// 固定的实验板IP,端口,MAC地址
|
||||
private const string BOARD_IP = "169.254.109.0";
|
||||
private const int BOARD_PORT = 1234;
|
||||
private const string BOARD_MAC = "12:34:56:78:9a:bc";
|
||||
|
||||
|
||||
// 本机网络信息
|
||||
private readonly IPAddress _localIP;
|
||||
private readonly byte[] _localMAC;
|
||||
@@ -33,14 +32,14 @@ public class NetConfigController : ControllerBase
|
||||
// 初始化本机IP地址
|
||||
_localIP = GetLocalIPAddress();
|
||||
_localIPString = _localIP?.ToString() ?? "未知";
|
||||
|
||||
|
||||
// 初始化本机MAC地址
|
||||
_localMAC = GetLocalMACAddress();
|
||||
_localMACString = _localMAC != null ? BitConverter.ToString(_localMAC).Replace("-", ":") : "未知";
|
||||
|
||||
|
||||
// 获取本机网络接口名称
|
||||
_localInterface = GetLocalNetworkInterface();
|
||||
|
||||
|
||||
logger.Info($"NetConfigController 初始化完成 - 本机IP: {_localIPString}, 本机MAC: {_localMACString}, 接口: {_localInterface}");
|
||||
}
|
||||
|
||||
@@ -53,7 +52,7 @@ public class NetConfigController : ControllerBase
|
||||
try
|
||||
{
|
||||
var boardIpSegments = BOARD_IP.Split('.').Take(3).ToArray();
|
||||
|
||||
|
||||
// 优先选择与实验板IP前三段相同的IP
|
||||
var sameSegmentIP = System.Net.NetworkInformation.NetworkInterface
|
||||
.GetAllNetworkInterfaces()
|
||||
@@ -130,7 +129,7 @@ public class NetConfigController : ControllerBase
|
||||
{
|
||||
try
|
||||
{
|
||||
return await Arp.CheckOrAddAsync(BOARD_IP, BOARD_MAC, _localInterface);
|
||||
return await ArpClient.UpdateArpEntryAsync(BOARD_IP);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user