Created
August 14, 2015 07:21
-
-
Save KazuyukiEguchi/c3cb246385abab3417d5 to your computer and use it in GitHub Desktop.
Windows 10 で、 iBeacon 互換信号を送信するプログラムを書いてみた。 ref: http://qiita.com/KazuyukiEguchi/items/1fe83273d310ce9e85ce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Runtime.InteropServices.WindowsRuntime; | |
using Windows.Devices.Bluetooth.Advertisement; | |
using Windows.UI.Xaml.Controls; | |
// 空白ページのアイテム テンプレートについては、http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 を参照してください | |
namespace Beacon | |
{ | |
/// <summary> | |
/// それ自体で使用できる空白ページまたはフレーム内に移動できる空白ページ。 | |
/// </summary> | |
public sealed partial class MainPage : Page | |
{ | |
private BluetoothLEAdvertisementPublisher publisher; | |
public MainPage() | |
{ | |
this.InitializeComponent(); | |
publisher = new BluetoothLEAdvertisementPublisher(); | |
var manufacturerData = new BluetoothLEManufacturerData(); | |
manufacturerData.CompanyId = 0x004c; | |
byte[] dataArray = new byte[] { | |
// お決まり | |
0x02, 0x15, | |
// UUID | |
0x01, 0x02, 0x03, 0x04, | |
0x05, 0x06, 0x07, 0x08, | |
0x09, 0x0a, 0x0b, 0x0c, | |
0x0d, 0x0e, 0x0f, 0x10, | |
// Major | |
0x01, 0x00, | |
// Minor | |
0x00, 0x01, | |
// TX power | |
0xc5 | |
}; | |
manufacturerData.Data = dataArray.AsBuffer(); | |
publisher.Advertisement.ManufacturerData.Add(manufacturerData); | |
publisher.Start(); | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Package | |
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" | |
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" | |
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" | |
IgnorableNamespaces="uap mp"> | |
<Identity | |
Name="24b7dfd7-6161-46e5-b890-b18e31e6e39d" | |
Publisher="CN=kazuyuki" | |
Version="1.0.0.0" /> | |
<mp:PhoneIdentity PhoneProductId="24b7dfd7-6161-46e5-b890-b18e31e6e39d" PhonePublisherId="00000000-0000-0000-0000-000000000000"/> | |
<Properties> | |
<DisplayName>Beacon</DisplayName> | |
<PublisherDisplayName>kazuyuki</PublisherDisplayName> | |
<Logo>Assets\StoreLogo.png</Logo> | |
</Properties> | |
<Dependencies> | |
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" /> | |
</Dependencies> | |
<Resources> | |
<Resource Language="x-generate"/> | |
</Resources> | |
<Applications> | |
<Application Id="App" | |
Executable="$targetnametoken$.exe" | |
EntryPoint="Beacon.App"> | |
<uap:VisualElements | |
DisplayName="Beacon" | |
Square150x150Logo="Assets\Square150x150Logo.png" | |
Square44x44Logo="Assets\Square44x44Logo.png" | |
Description="Beacon" | |
BackgroundColor="transparent"> | |
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/> | |
<uap:SplashScreen Image="Assets\SplashScreen.png" /> | |
</uap:VisualElements> | |
</Application> | |
</Applications> | |
<Capabilities> | |
<DeviceCapability Name="bluetooth" /> | |
</Capabilities> | |
</Package> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment