如何解决BLE广告是间歇性的,而不是恒定的
using System;
using System.Linq;
using Windows.Devices.Bluetooth.Advertisement;
using Windows.Storage.Streams;
using System.Diagnostics;
using System.Text;
using System.Runtime.InteropServices;
namespace App
{
class Program
{
static void Main(string[] args)
{
string s = "FACADEDEADBEEFDEAFDEFACEFEEDACED";
byte[] se = new byte[16];
for(int i = 0;i<32;i+=2)
{
se[i/2] = Convert.ToByte(s.Substring(i,2),16);
Debug.WriteLine(se[i/2]);
}
Debug.WriteLine(BitConverter.ToString(se).Replace("-",""));
BluetoothLEAdvertisementPublisher p = new BluetoothLEAdvertisementPublisher();
DataWriter d = new DataWriter();
d.WriteBytes(se);
p.Advertisement.ManufacturerData.Add(new BluetoothLEManufacturerData(0x118,d.DetachBuffer()));
p.Start();
while (Console.ReadKey().Key != ConsoleKey.Escape)
{
Debug.WriteLine(p.Status);
}
p.Stop();
}
}
}
嗨,我的代码有问题。它应该不断广播广告包,但是当我使用NRF Connect扫描它时,它只存在不到一秒钟的时间。带有Microsoft公司标识符的广告包通常会出现在大多数时间,但是当我的程序正在发送的包出现时却没有被检测到。我认为有些Windows进程正在广播广告包,该广告包干扰了我的程序尝试发送的广告包。如果是这样,它是什么,我该如何暂时禁用它?如果没有,我需要怎么做才能使其不断广播?我正在使用带有Windows.SDK.Contracts程序包的.net控制台应用程序来访问UWP API。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。