unity 使用蓝牙通讯(PC版,非安卓)
BlueTooth in pc with unity
最近接到的需求是在unity里面开发蓝牙功能,其实一开始我并不慌,因为据我所知,unity有丰富的插件可以使用,但是问题随之而来
1.unity里面无法直接与蓝牙通讯(后来找到了开启runtime一类的东西,但是我找了半天也没找到在哪里可以打开)
2.引入dll通过dll与蓝牙通讯,包括去微软的官网下载c++编译,但是编译过程中种种问题.而我对于c++这一套也不精通.也是放弃了
3.github上找到一个封装好的BLE的一个 这是网址 但是在我的测试中发现 会有搜不到我的蓝牙设备的问题.并且即使连上了,发出的消息也没有回应.所以也是放弃了
于是只能通过一个比较笨的办法,将蓝牙通讯在winform中或者是wpf中,然后将unity程序放在winform或者是wpf的容器中,二者通过udp协议连接传输数据.最后的效果如下:
那么如果是这种办法,那就变得简单的多了.winform开发不在话下.unity也是我熟悉的.其中winform支持原生开发,也就是说不用下载任何dll与插件,用到的只是windows.winmd,而这个windows系统是自带的.
将winmd类型文件引入后,编写开发工具类:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Devices.Bluetooth;
using Windows.Devices.Bluetooth.Advertisement;
using Windows.Devices.Bluetooth.GenericAttributeProfile;
using Windows.Devices.Enumeration;
using Windows.Foundation;
using Windows.Networking;
using Windows.Networking.Proximity;
using Windows.Networking.Sockets;
using Windows.Security.Cryptography;
using Windows.Storage.Streams;namespace Bluetooth
{internal class BleCore{private Boolean asyncLock = false;/// <summary>/// 搜索蓝牙设备对象/// </summary>private BluetoothLEAdvertisementWatcher watcher;/// <summary>/// 当前连接的蓝牙设备/// </summary>public BluetoothLEDevice CurrentDevice { get; set; }/// <summary>/// 特性通知类型通知启用/// </summary>private const GattClientCharacteristicConfigurationDescriptorValue CHARACTERISTIC_NOTIFICATION_TYPE = GattClientCharacteristicConfigurationDescriptorValue.Notify;/// <summary>/// 存储检测到的设备/// </summary>private List<BluetoothLEDevice> DeviceList = new List<BluetoothLEDevice>();/// <summary>/// 搜索蓝牙设备委托/// </summary>public delegate void DeviceScanEvent(BluetoothLEDevice bluetoothLEDevice);/// <summary>/// 搜索蓝牙事件/// </summary>public event DeviceScanEvent DeviceScan;/// <summary>/// 提示信息委托/// </summary>public delegate void MessAgeLogEvent(MsgType type, string message, byte[] data = null);/// <summary>/// 提示信息事件/// </summary>public event MessAgeLogEvent MessAgeLog;/// <summary>/// 接收通知委托/// </summary>public delegate void ReceiveNotificationEvent(GattCharacteristic sender, byte[] data);/// <summary>/// 接收通知事件/// </summary>public event ReceiveNotificationEvent ReceiveNotification;/// <summary>/// 获取服务委托/// </summary>public delegate void DeviceFindServiceEvent(DeviceService deviceService);/// <summary>/// 获取服务事件/// </summary>public event DeviceFindServiceEvent DeviceFindService;/// <summary>/// 蓝牙状态委托/// </summary>public delegate void DeviceConnectionStatusEvent(BluetoothConnectionStatus status);/// <summary>/// 蓝牙状态事件/// </summary>public event DeviceConnectionStatusEvent DeviceConnectionStatus;/// <summary>/// 当前连接的蓝牙Mac/// </summary>private string CurrentDeviceMAC { get; set; }public BleCore(){}/// <summary>/// 搜索蓝牙设备/// </summary>public void StartBleDeviceWatcher(){watcher = new BluetoothLEAdvertisementWatcher();watcher.ScanningMode = BluetoothLEScanningMode.Active;//只有在接收到数值大于等于 -80 的情况下才激活监视器watcher.SignalStrengthFilter.InRangeThresholdInDBm = -80;// 如果数值低于 -90(用户离开),则停止监测watcher.SignalStrengthFilter.OutOfRangeThresholdInDBm = -90;// 注册回调函数,以便在我们看到广播时触发(执行)相关操作watcher.Received += OnAdvertisementReceived;// 等待 5 秒钟以确保设备确实超出范围watcher.SignalStrengthFilter.OutOfRangeTimeout = TimeSpan.FromMilliseconds(5000);watcher.SignalStrengthFilter.SamplingInterval = TimeSpan.FromMilliseconds(2000);// starting watching for advertisementsthis.DeviceList.Clear();watcher.Start();string msg = "开始搜索蓝牙设备...";this.MessAgeLog(MsgType.NotifyTxt, msg);}/// <summary>/// 停止搜索蓝牙/// </summary>public void StopBleDeviceWatcher(){this.watcher.Stop();}private void OnAdvertisementReceived(BluetoothLEAdvertisementWatcher watcher, BluetoothLEAdvertisementReceivedEventArgs eventArgs){//this.MessAgeChanged(MsgType.NotifyTxt, "发现设备FR_NAME:"+ eventArgs.Advertisement.LocalName + "BT_ADDR: " + eventArgs.BluetoothAddress);BluetoothLEDevice.FromBluetoothAddressAsync(eventArgs.BluetoothAddress).Completed = (asyncInfo, asyncStatus) =>{if (asyncStatus == AsyncStatus.Completed){if (asyncInfo.GetResults() != null){BluetoothLEDevice currentDevice = asyncInfo.GetResults();Boolean contain = false;foreach (BluetoothLEDevice device in DeviceList)//过滤重复的设备{if (device.BluetoothAddress == currentDevice.BluetoothAddress){contain = true;}}if (!contain){byte[] _Bytes1 = BitConverter.GetBytes(currentDevice.BluetoothAddress);Array.Reverse(_Bytes1);this.DeviceList.Add(currentDevice);string str;if (currentDevice.DeviceInformation.Name != ""){str = "发现设备:" + currentDevice.DeviceInformation.Name + " - MAC: \r\n" +BitConverter.ToString(_Bytes1, 2, 6).Replace('-', ':').ToUpper() + " - ID: /r/n" + currentDevice.DeviceInformation.Id;}//舍弃没有名字的设备(匿名设备)else{// str = "发现设备:" + BitConverter.ToString(_Bytes1, 2, 6).Replace('-', ':').ToUpper();return;}this.MessAgeLog(MsgType.NotifyTxt, str);this.DeviceScan(currentDevice);}}}};}/// <summary>/// 匹配/// </summary>/// <param name="Device"></param>public void StartMatching(BluetoothLEDevice Device){this.CurrentDevice?.Dispose();this.CurrentDevice = Device;Connect();FindService();}/// <summary>/// 获取蓝牙服务/// </summary>public async void FindService(){this.MessAgeLog(MsgType.NotifyTxt, "开始获取服务列表");this.CurrentDevice.GetGattServicesAsync().Completed = async (asyncInfo, asyncStatus) =>{if (asyncStatus == AsyncStatus.Completed){var services = asyncInfo.GetResults().Services;//this.MessAgeChanged(MsgType.NotifyTxt, "GattServices size=" + services.Count);foreach (GattDeviceService ser in services){FindCharacteristic(ser);}}};}/// <summary>/// 获取特性/// </summary>public async void FindCharacteristic(GattDeviceService gattDeviceService){IAsyncOperation<GattCharacteristicsResult> result = gattDeviceService.GetCharacteristicsAsync();result.Completed = async (asyncInfo, asyncStatus) =>{if (asyncStatus == AsyncStatus.Completed){var characters = asyncInfo.GetResults().Characteristics;List<GattCharacteristic> characteristics = new List<GattCharacteristic>();foreach (GattCharacteristic characteristic in characters){characteristics.Add(characteristic);this.MessAgeLog(MsgType.NotifyTxt, "服务UUID:" + gattDeviceService.Uuid.ToString() + " --- 特征UUID:" + characteristic.Uuid.ToString());}DeviceService deviceService = new DeviceService();deviceService.gattDeviceService = gattDeviceService;deviceService.gattCharacteristic = characteristics;this.DeviceFindService(deviceService);}};}/// <summary>/// 获取操作/// </summary>/// <returns></returns>public async Task SetNotify(GattCharacteristic gattCharacteristic){GattCharacteristic CurrentNotifyCharacteristic;if ((gattCharacteristic.CharacteristicProperties & GattCharacteristicProperties.Notify) != 0){CurrentNotifyCharacteristic = gattCharacteristic;CurrentNotifyCharacteristic.ProtectionLevel = GattProtectionLevel.Plain;CurrentNotifyCharacteristic.ValueChanged += Characteristic_ValueChanged;await this.EnableNotifications(CurrentNotifyCharacteristic);}}/// <summary>/// 连接蓝牙/// </summary>/// <returns></returns>private async Task Connect(){byte[] _Bytes1 = BitConverter.GetBytes(this.CurrentDevice.BluetoothAddress);Array.Reverse(_Bytes1);this.CurrentDeviceMAC = BitConverter.ToString(_Bytes1, 2, 6).Replace('-', ':').ToLower();string msg = "正在连接设备:" + this.CurrentDeviceMAC.ToUpper() + " ...";this.MessAgeLog(MsgType.NotifyTxt, msg);this.CurrentDevice.ConnectionStatusChanged += this.CurrentDevice_ConnectionStatusChanged;}/// <summary>/// 搜索到的蓝牙设备/// </summary>/// <returns></returns>private async Task Matching(string Id){try{BluetoothLEDevice.FromIdAsync(Id).Completed = async (asyncInfo, asyncStatus) =>{if (asyncStatus == AsyncStatus.Completed){BluetoothLEDevice bleDevice = asyncInfo.GetResults();this.DeviceList.Add(bleDevice);this.DeviceScan(bleDevice);this.CurrentDevice = bleDevice;FindService();}};}catch (Exception e){string msg = "没有发现设备" + e.ToString();this.MessAgeLog(MsgType.NotifyTxt, msg);this.StartBleDeviceWatcher();}}/// <summary>/// 主动断开连接/// </summary>/// <returns></returns>public void Dispose(){CurrentDeviceMAC = null;CurrentDevice?.Dispose();CurrentDevice = null;MessAgeLog(MsgType.NotifyTxt, "主动断开连接");}private void CurrentDevice_ConnectionStatusChanged(BluetoothLEDevice sender, object args){this.DeviceConnectionStatus(sender.ConnectionStatus);if (sender.ConnectionStatus == BluetoothConnectionStatus.Disconnected && CurrentDeviceMAC != null){string msg = "设备已断开,自动重连...";MessAgeLog(MsgType.NotifyTxt, msg);if (!asyncLock){asyncLock = true;this.CurrentDevice.Dispose();this.CurrentDevice = null;SelectDeviceFromIdAsync(CurrentDeviceMAC);}}else{string msg = "设备已连接!";MessAgeLog(MsgType.NotifyTxt, msg);}}/// <summary>/// 按MAC地址直接组装设备ID查找设备/// </summary>public async Task SelectDeviceFromIdAsync(string MAC){CurrentDeviceMAC = MAC;CurrentDevice = null;BluetoothAdapter.GetDefaultAsync().Completed = async (asyncInfo, asyncStatus) =>{if (asyncStatus == AsyncStatus.Completed){BluetoothAdapter mBluetoothAdapter = asyncInfo.GetResults();byte[] _Bytes1 = BitConverter.GetBytes(mBluetoothAdapter.BluetoothAddress);//ulong转换为byte数组Array.Reverse(_Bytes1);string macAddress = BitConverter.ToString(_Bytes1, 2, 6).Replace('-', ':').ToLower();string Id = "BluetoothLE#BluetoothLE" + macAddress + "-" + MAC;await Matching(Id);}};}/// <summary>/// 设置特征对象为接收通知对象/// </summary>/// <param name="characteristic"></param>/// <returns></returns>public async Task EnableNotifications(GattCharacteristic characteristic){if (CurrentDevice.ConnectionStatus != BluetoothConnectionStatus.Connected){this.MessAgeLog(MsgType.NotifyTxt, "蓝牙未连接!");return;}characteristic.WriteClientCharacteristicConfigurationDescriptorAsync(CHARACTERISTIC_NOTIFICATION_TYPE).Completed = async (asyncInfo, asyncStatus) =>{Console.WriteLine("asyncStatus:" + asyncStatus);if (asyncStatus == AsyncStatus.Completed){GattCommunicationStatus status = asyncInfo.GetResults();asyncLock = false;string msg = "Notify(" + characteristic.Uuid.ToString() + "):" + status;this.MessAgeLog(MsgType.NotifyTxt, msg);}else{Console.WriteLine(asyncInfo.ErrorCode.ToString());}};}/// <summary>/// 接受到蓝牙数据/// </summary>private void Characteristic_ValueChanged(GattCharacteristic characteristic, GattValueChangedEventArgs args){byte[] data;CryptographicBuffer.CopyToByteArray(args.CharacteristicValue, out data);string str = System.Text.Encoding.UTF8.GetString(data);this.ReceiveNotification(characteristic, data);this.MessAgeLog(MsgType.BleData, "收到数据(" + characteristic.Uuid.ToString() + "):" + str);}/// <summary>/// 发送数据接口/// </summary>/// <returns></returns>public async Task Write(GattCharacteristic writeCharacteristic, byte[] data){if (writeCharacteristic != null){string str = "发送数据(" + writeCharacteristic.Uuid.ToString() + "):" + BitConverter.ToString(data);this.MessAgeLog(MsgType.BleData, str, data);IAsyncOperation<GattCommunicationStatus> async = writeCharacteristic.WriteValueAsync(CryptographicBuffer.CreateFromByteArray(data), GattWriteOption.WriteWithResponse);async.Completed = async (asyncInfo, asyncStatus) =>{if (asyncStatus == AsyncStatus.Completed){this.MessAgeLog(MsgType.BleData, "数据发送成功!");}else{this.MessAgeLog(MsgType.BleData, "数据发送失败:" + asyncInfo.ErrorCode.ToString());}};}}}public enum MsgType{NotifyTxt,BleData,BleDevice}public class DeviceService{public GattDeviceService gattDeviceService;public List<GattCharacteristic> gattCharacteristic;}
}
然后对于页面的按钮进行赋值,并将unity开发的exe放在合适的位置,其中通讯部分只需要简单的通讯即可,不需要考虑什么分包问题.因为本机通讯很稳定.
winform部分的udp:
using System;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;namespace VincentUDP
{public class UdpServer{private UdpClient udpClient;private IPEndPoint remoteEndPoint;public void Init(){int port = 8888; // 选择一个端口udpClient = new UdpClient();remoteEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), port); // 目标IP和端口}public void Send(byte[] message){// byte[] data = Encoding.UTF8.GetBytes(message);udpClient.Send(message, message.Length, remoteEndPoint);}public void Close(){udpClient.Close();}}
}
unity接收部分:
using System;
using System.Collections;
using System.Net;
using System.Net.Sockets;
using UnityEngine;public class RecvUDPMsg : MonoBehaviour
{private UdpClient udpClient;//消息队列private Queue queue = new Queue();private void Start(){// 初始化UDP客户端udpClient = new UdpClient(8888); // 监听的端口StartReceiving();}private void StartReceiving(){udpClient.BeginReceive(ReceiveCallback, null);}private void ReceiveCallback(IAsyncResult ar){IPEndPoint remoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);byte[] receivedBytes = udpClient.EndReceive(ar, ref remoteIpEndPoint);// string receivedText = Encoding.UTF8.GetString(receivedBytes);//Debug.Log("Received: " + receivedText);queue.Enqueue(receivedBytes);// 继续监听StartReceiving();}private void OnDestroy(){// 关闭UDP客户端udpClient.Close();}
}
那么最后的运行如下:
最后附上下载地址: 点击这里
PS:如果下载不了(非csdn会员)请私信我.
相关文章:
unity 使用蓝牙通讯(PC版,非安卓)
BlueTooth in pc with unity 最近接到的需求是在unity里面开发蓝牙功能,其实一开始我并不慌,因为据我所知,unity有丰富的插件可以使用,但是问题随之而来 1.unity里面无法直接与蓝牙通讯(后来找到了开启runtime一类的东西,但是我找了半天也没找到在哪里可以打开) 2.引入dll通过d…...
Feign 重试策略调整:优化微服务通信的稳定性
在微服务架构中,服务之间的通信是常见的场景。然而,网络问题、服务不稳定或临时故障都可能导致通信失败。Feign 是一个流行的声明式 REST 客户端,广泛用于微服务间的通信。通过合理调整 Feign 的重试策略,可以显著提高系统的稳定性…...
Nacos源码—5.Nacos配置中心实现分析一
大纲 1.关于Nacos配置中心的几个问题 2.Nacos如何整合SpringBoot读取远程配置 3.Nacos加载读取远程配置数据的源码分析 4.客户端如何感知远程配置数据的变更 5.集群架构下节点间如何同步配置数据 1.关于Nacos配置中心的几个问题 问题一:SpringBoot项目启动时如…...
【spring】Spring、Spring MVC、Spring Boot、Spring Cloud?
这些都是 Spring 家族的重要组成部分,但它们各自定位不同、功能层级不同,可以用一张表格和简要说明来帮你快速理解: 一、四者概念和区别表格 名称功能定位主要用途/核心功能是否依赖其他部分Spring基础框架(核心)IOC、…...
RDD的处理过程
1. 创建RDD 通过SparkContext的parallelize方法从本地集合创建RDD。 从外部存储(如HDFS、本地文件系统)加载数据创建RDD。 通过对已有RDD进行转换操作生成新的RDD。 2. 转换操作(Transformation) 对RDD进行操作(如…...
Vue3 中当组件嵌套层级较深导致 ref 无法直接获取子组件实例时,可以通过 provide/inject + 回调函数的方式实现子组件方法传递到父组件
需求:vue3中使用defineExposeref调用子组件方法报错不是一个function 思路:由于组件嵌套层级太深导致ref失效,通过provide/inject 回调函数来实现多层穿透 1. 父组件提供「方法注册函数」 父组件通过 provide 提供一个用于接收子组件方法…...
如何在Ubuntu上安装NVIDIA显卡驱动?
作者:算力魔方创始人/英特尔创新大使刘力 一,前言 对于使用NVIDIA显卡的Ubuntu用户来说,正确安装显卡驱动是获得最佳图形性能的关键。与Windows系统不同,Linux系统通常不会自动安装专有显卡驱动。本文将详细介绍在Ubuntu系统上安…...
Linux 修改bond后网关不生效的问题
1.前言 bond原本是OK的,但是某个同事变更后,发现网关路由存在问题 #查看路由,默认网关信息,发现没有配置的网关信息 ip route show #排查/etc/sysconfig/network-script/下面的ifcfg-* 文件没有问题 1.重启network 服务 systemct…...
chili调试笔记13 工程图模块 mesh渲染 mesh共享边显示实现
把模型投影到工程图要用什么模块当工程图的画板,最后要导出dxf的 three是怎么读取他的3d数据的 mesh不是三角形吗怎么渲染出四边形面的 我想看到三角形的边怎么设置 ai让我干嘛我就干嘛 static getAllEdges(face: { positions: Float32Array; indices: Uint16Array …...
Eclipse 插件开发 5 编辑器
Eclipse 插件开发 5 编辑器 1 编辑器描述2 自定义编辑器2.1 注册插件(plugin.xml)2.2 继承 EditorPart2.3 实现 IEditorInput2.4 打开编辑器 1 编辑器描述 Eclipse 的 UI 基于 Workbench(工作台)模型,Editor Area 是 Workbench 的核心区域之…...
Java消息队列性能优化实践:从理论到实战
Java消息队列性能优化实践:从理论到实战 1. 引言 在现代分布式系统架构中,消息队列(Message Queue,MQ)已经成为不可或缺的中间件组件。它不仅能够实现系统间的解耦,还能提供异步通信、流量削峰等重要功能…...
Android学习总结之Binder篇
一、Binder 跨进程通信底层实现 Q1:Binder 如何实现一次完整的跨进程方法调用?请描述内核态与用户态交互流程 高频错误:仅回答 “通过 AIDL 生成代码”,未涉及 Binder 驱动三层协作模型 满分答案(附内核交互流程图&a…...
very_easy_sql(SSRF+SQL注入)
题目有一行提示: you are not an inner user, so we can not let you have identify~(你不是内部用户,所以我们不能让你进行身份验证)联想到可能存在SSRF漏洞,一般情况下,SSRF攻击的目标是外网无法访问的内…...
MCP认证全解析:从零到微软认证专家
MCP认证全解析:从零到微软认证专家 什么是MCP认证? Microsoft Certified Professional(MCP)是由微软官方颁发的技术认证,旨在验证IT从业者在微软技术栈(如Azure、Windows Server、SQL Server等࿰…...
leetcode刷题日记——反转链表
[ 题目描述 ]: [ 思路 ]: 题目要求将链表中指定位置的部分进行翻转反转的部分,其实可以看做使用头插法插入链表运行如下: struct ListNode* reverseBetween(struct ListNode* head, int left, int right) {struct ListNode te…...
【day04】Fibonacci数列 | 单词搜索 | 杨辉三角
1.Fibonacci数列 题目链接: Fibonacci数列_牛客题霸_牛客网 解题思路: 求斐波那契数列的过程中,判断⼀下:何时n会在两个fib数之间。 #include <bits/stdc.h>using namespace std;#define int long longsigned main() {i…...
win11指定Microsoft Print To PDF的输出路径(电子书djvu转pdf输出路径)
首先,看一张效果图 前面都是废话,解决方法看最后,看最后 Microsoft Print To PDF功能作为Windows操作系统内置的一项便捷工具,为用户提供了将任何可打印内容高效转换为PDF格式的能力。本文深入探讨了Microsoft Print To PDF的工作…...
第3章 数据和C
目录 3.1 示例程序3.2 变量与常量数据3.3 数据:数据类型关键字3.4 C数据类型3.4.1 int类型3.4.2 其它整数类型3.4.3 使用字符:char类型3.4.4 _Bool类型3.4.5 可移植的类型:inttypes.h3.4.6 float、double和long double类型3.4.7 复数和虚数类…...
迁移学习:如何加速模型训练和提高性能
📌 友情提示: 本文内容由银河易创AI(https://ai.eaigx.com)创作平台的gpt-4-turbo模型生成,旨在提供技术参考与灵感启发。文中观点或代码示例需结合实际情况验证,建议读者通过官方文档或实践进一步确认其准…...
Kotlin zip 函数的作用和使用场景
1. zip 函数的作用 zip 是 Kotlin 集合操作中的一个函数,用于将两个集合按照索引一一配对,生成一个新的 List<Pair<T, R>> 集合。 作用:将两个集合的元素按位置组合成键值对(Pair)。返回值:一…...
通用分布式锁组件
Redisson的分布式锁使用并不复杂,基本步骤包括: 1)创建锁对象 2)尝试获取锁 3)处理业务 4)释放锁 但是,除了第3步以外,其它都是非业务代码,对业务的侵入较多&#x…...
FastDFS,分布式文件存储系统,介绍+配置+工具类
FastDFS 什么是分布式文件存储系统 随着文件逐渐增多,单台计算机已经存储不下这么多数据,需要用多台计算机存储不同的数据或进行备份,这样就需要有一个管理系统管理不同的计算机节点,这就是分布式管理系统。 使用分布式管理系统的…...
查询nvidia边缘设备的软硬件版本jetson_release
通过jetson_release命令可查询nvidia边缘设备的软硬件版本 nvidianvidia-desktop:~/leo/test_onnx$ jetson_release Software part of jetson-stats 4.2.12 - (c) 2024, Raffaello Bonghi Model: NVIDIA Orin Nano Developer Kit - Jetpack 5.1.1 [L4T 35.3.1] NV Power Mode[…...
[学习]RTKLib详解:ppp.c与ppp_ar.c
文章目录 RTKLib详解:ppp.c与ppp_ar.cPart A: ppp.c一、整体作用与工作流程二、核心函数说明1. pppos2. res_ppp3. tide_solid4. prectrop5. corrmeas6. udbias_ppp 三、数学原理补充四、代码特点 Part B: ppp_ar.c一、整体作用与工作流程分析二、函数功…...
ntdll!LdrpSnapThunk函数分析之LdrpNameToOrdinal函数返回之后得到函数地址
第一部分: OrdinalNumber LdrpNameToOrdinal( ImportString, ExportDirectory->NumberOfNames, DllBase, NameTableBase, …...
LeetCode 267:回文排列 II —— Swift 解法全解析
文章目录 摘要描述题解答案题解代码分析统计字符频率判断是否可能构成回文构建半边字符数组回溯生成半边排列 示例测试及结果时间复杂度空间复杂度实际使用场景:回文排列在真实项目里能干啥?文本处理、数据清洗类系统游戏开发:名字合法性验证…...
【渗透测试】命令执行漏洞的原理、利用方式、防范措施
文章目录 命令执行漏洞的原理、利用方式、防范措施一、原理**1. 定义与触发条件****2. 攻击链流程图** 二、利用方式**1. 利用手法与分类**(1) 系统命令注入(2) 代码执行漏洞(3) 框架漏洞利用 **2. 案例** 三、防范措施**1. 输入过滤与验证****2. 禁用危险函数****3. 安全开发*…...
旧版谷歌浏览器Chrome v116.0.5845.141下载
63位和32位均有: https://bbs.pcbeta.com/forum.php?modviewthread&tid1978299 https://www.31du.cn/open/google-chrome-v116-0-5845-141.html v116.0.5845.141的win32位版本: https://www.cr173.com/soft/435106.html v116.0.5845.97版本&…...
行业洞察| 当大模型开始协同工作:多智能体系统的崛起与挑战
你有没有想过,如果一群AI智能体拉了个工作群,它们会聊些什么? 程序员AI:“这段代码我来写!” 产品经理AI:“需求还没说完呢!” 辩论家AI:“我觉得这个方案不行!” 吃瓜…...
The Action Replay Process
Preface A commonly used inequality − x > ln ( 1 − x ) , 0 < x < 1 -x > \ln(1 - x), \quad 0 < x < 1 −x>ln(1−x),0<x<1 Proof: Let f ( x ) ln ( 1 − x ) x f(x) \ln(1 - x) x f(x)ln(1−x)x, for 0 < x < 1 0 < …...
Python基于Django的病人信息管理系统及安全策略分析(附源码,文档说明)
博主介绍:✌IT徐师兄、7年大厂程序员经历。全网粉丝15W、csdn博客专家、掘金/华为云//InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战✌ 🍅文末获取源码联系🍅 👇🏻 精彩专栏推荐订阅👇dz…...
YOLOv1:开创实时目标检测新纪元
一、引言 在计算机视觉领域,目标检测一直是重要的研究方向,广泛应用于自动驾驶、安防监控、智能机器人等场景。2016年,Joseph Redmon等人提出的YOLO(You Only Look Once)v1模型,以其端到端、单阶段、实时性…...
【今日三题】跳台阶扩展问题(找规律) / 包含不超过两种字符的最长子串 / 字符串的排列(回溯—全排列)
⭐️个人主页:小羊 ⭐️所属专栏:Linux 很荣幸您能阅读我的文章,诚请评论指点,欢迎欢迎 ~ 目录 跳台阶扩展问题(找规律)包含不超过两种字符的最长子串(字符串哈希)字符串的排列(回溯—全排列) 跳台阶扩展问题(找规律) 跳台阶扩…...
MySQL 中常见的日志
1. MySQL 中常见的日志有哪些? MySQL 主要包含以下几种日志: 错误日志(Error Log):记录 MySQL 服务器的启动和停止过程中的信息,以及运行过程中出现的错误或警告信息。默认情况下,错误日志文件…...
ubuntu nobel + qt5.15.2 设置qss语法识别正确
问题展示 解决步骤 首选项里面的高亮怎么编辑选择都没用。如果已经有generic-highlighter和css.xml,直接修改css.xml文件最直接! 在generic-highlighter目录下找到css.xml文件,位置是:/opt/Qt/Tools/QtCreator/share/qtcreator/…...
线程池技术
线程池基本概念 线程池就是在任务还没有到来前,预先创建一定数量的线程放入空闲列表。这些线程都是处于阻塞状态,不消耗CPU,但占用较小的内存空间。 当新任务到来时,缓冲池选择一个空线程,把任务传入此线程中运行&…...
matlab App自动化安装和卸载
这个是文件mlappinstall安装和卸载的使用函数,并且包括运行函数。File must be a toolbox file (*.mlappinstall) Package and Share Apps — Functions matlab.apputil.createCreate or modify app project file interactively using the Package App dialog box…...
MATLAB技巧——命令行输入的绘图,中文是正常的,到了脚本(m文件)里面就变成乱码的解决方法
文章目录 文件编码(根本性措施)字体设置使用 sprintf 或 text 函数系统语言设置示例代码 使用mlx方法 总结 在 M A T L A B MATLAB MATLAB中,中文字符在命令行和脚本中的显示问题通常与字符编码设置有关。以下是一些可能导致中文乱码的原因及…...
使用OpenCV 和 Dlib 实现人脸融合技术
文章目录 引言一、技术概述二、环境准备三、关键代码解析1. 人脸关键点定义2. 获取人脸掩模3. 计算仿射变换矩阵4. 检测并提取人脸关键点5. 颜色校正 四、完整流程五、效果展示六、总结 引言 本文将介绍如何使用Python、OpenCV和dlib库实现人脸融合技术,将一张人脸…...
Codeforces Round 1022 (Div. 2)
Problem - A - Codeforces 看这数据量,算出每个排列来,是不现实的,需要找找规律 来看找规律代码 #include <bits/stdc.h> using namespace std;int main() {int t;cin >> t;while (t--){int n;cin >> n;vector<int&g…...
uniapp 震动功能实现
项目场景: 提示:这里简述项目相关背景: 在项目中有时候需要一些功能,比如震动 描述 提示:这里描述项目中遇到的问题: 在移动应用中,震动反馈是提升用户体验的重要方式。uniapp 提供了两种震…...
uniapp 搭配 uCharts
在插件市场导入插件到项目中 <view class"charts-box-main"> <qiun-data-charts type"area" :opts"opts" :chartData"chartData" /> </view> data(&#…...
Kubernetes(k8s)学习笔记(八)--KubeSphere定制化安装
1执行下面的命令修改上一篇中yaml文件来实现定制化安装devops kubectl edit cm -n kubesphere-system ks-installer 主要是将devops几个配置由False改为True 然后使用下面的命令查看安装日志 kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l …...
阿里云codeup以及本地gitclone+http
cmd命令行乱码问题、解决 chcp 65001 git代码提交 git add . git commit -m init git push origin master...
Spring Boot 多数据源事务管理
在 Spring Boot 中,当需要操作多个数据源时,事务管理会变得更加复杂。因为默认的 DataSourceTransactionManager 只支持单数据源事务,跨数据源的事务需要使用 分布式事务(Distributed Transaction) 或 柔性事务&#x…...
4.系统定时器基本定时器
目录 系统定时器 系统定时器(systick)--内核 系统定时器结构 系统滴答定时器寄存器--内核 定时周期的确定公式 配置滴答定时器 系统定时器应用 应用1.定时器构造时间点任务,解决while循环阻塞问题 应用2.定时器构造精准的ms延时 应…...
lvgl多语言设置
搭建开发环境 安装node.js 安装node.js,点击进入官网地址 安装lv_i18n lv_i18n项目地址:Github:https://github.com/lvgl/lv_i18ngit运行命令安装lv_i18n:npm i lv_i18n -g。测试命令:lv_i18n -h 搭建过程报错 …...
ICode国际青少年编程竞赛—Python—4级训练场—复杂嵌套循环
ICode国际青少年编程竞赛—Python—4级训练场—复杂嵌套循环 icode练习时遇到卡顿没有思路时怎么办,题目也很难找到不会的那道题~针对这个问题,我们开发了通过“步数”、“积木行数”来快速定位到你不会的题目~ 题目会持续更新…...
【Windows】怎么解决Win 10家庭版WMI Provider Host占用CPU过高的问题?-篇一【2025.05.07】
本文面向两种用户,普通小白和windows开发程序员。 对于小白,目标就是阻止wmi对资源的高占用。解决方法有以下几步: 查出谁在调用这个wmiprvse.exe winR 组合键打开运行,输入命令services.msc,回车或确认。 找到如下蓝色…...
Matlab 多策略改进蜣螂优化算法及其在CEC2017性能
1、内容简介 Matlab214-多策略改进蜣螂优化算法及其在CEC2017性能 可以交流、咨询、答疑 2、内容说明 对蜣螂优化算法(Dung Beetle Algorithm,DBA)进行多种策略改进,以提高其在CEC2017基准测试中的表现。 蜣螂优化算法是一种仿…...