Windows 10 Bluetooth Advertisement API

时间秒杀一切 提交于 2019-12-01 10:13:13

问题


Is it possible to use an AdvertisementPublisher to send a major and minor ID when acting as a beacon, and is it also possible to use an AdvertisementWatcher to send and receive the ID?

Cheers


回答1:


Yes, do this to send:

var manufacturerData = new BluetoothLEManufacturerData();

manufacturerData.CompanyId = 0x004c;

byte[] dataArray = new byte[] {
    // last 2 bytes of Apple's iBeacon
    0x02, 0x15,
    // Proximity UUID
    0x44, 0x50, 0x3f, 0x1b,
    0xc0, 0x9c, 0x4a, 0xee,
    0x97, 0x2f, 0x75, 0x0e,
    0x9d, 0x34, 0x67, 0x84,
    // Major
    0x00, 0x01,
    // Minor
    0x00, 0x10,
    // TX power
    0xc5
};

// using System.Runtime.InteropServices.WindowsRuntime;
manufacturerData.Data = dataArray.AsBuffer();

BluetoothLEAdvertisementPublisher publisher =
    new BluetoothLEAdvertisementPublisher();

publisher.Advertisement.ManufacturerData.Add(manufacturerData);

publisher.Start();

To receive, go to this question.



来源:https://stackoverflow.com/questions/31564207/windows-10-bluetooth-advertisement-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!