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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...