Windows 10 Bluetooth Advertisement API

后端 未结 1 900
长情又很酷
长情又很酷 2021-01-16 15:37

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 rece

1条回答
  •  情歌与酒
    2021-01-16 16:14

    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.

    0 讨论(0)
提交回复
热议问题