{"id":12022,"date":"2026-02-08T16:31:55","date_gmt":"2026-02-08T07:31:55","guid":{"rendered":"https:\/\/www.moonmile.net\/blog\/?p=12022"},"modified":"2026-02-08T16:34:39","modified_gmt":"2026-02-08T07:34:39","slug":"ibeacon-%e5%8f%97%e4%bf%a1%e3%81%ae%e5%ae%9f%e9%9a%9b-windows-c-%e7%89%88","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/12022","title":{"rendered":"iBeacon \u53d7\u4fe1\u306e\u5b9f\u969b Windows + C# \u7248"},"content":{"rendered":"\n<p>iBeacon \u306e\u3088\u3046\u306a BLE \u30a2\u30c9\u30d0\u30bf\u30a4\u30ba\u3084\u3001 GATT \u30b5\u30fc\u30d3\u30b9\u304c\u8272\u3005\u98db\u3093\u3067\u3044\u307e\u3059\u3001\u3068\u3044\u3046\u306e\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u305f\u3081\u306e\u30c4\u30fc\u30eb\u306f BLE \u901a\u4fe1\u30c1\u30a7\u30c3\u30af\u30c4\u30fc\u30eb\u306e\u3042\u308c\u3053\u308c <a href=\"https:\/\/www.moonmile.net\/blog\/archives\/11961\">https:\/\/www.moonmile.net\/blog\/archives\/11961<\/a> \u306b\u66f8\u3044\u305f\u308f\u3051\u3067\u3059\u304c\u3001\u3053\u308c\u3060\u3068\u30b9\u30de\u30db\u306b\u30a2\u30d7\u30ea\u3092\u5165\u308c\u3066\u3042\u3061\u3053\u3061\u63a2\u3059\u3068\u3044\u3046\u7a0b\u5ea6\u306e\u3053\u3068\u3057\u304b\u3067\u304d\u307e\u305b\u3093\u3002\u9006\u306b\u8a00\u3048\u3070\u3001\u5b9f\u9a13\u7684\u306b iBeacon \u306e UUID \u306f\u6c7a\u3081\u3066\u3042\u308b\u306e\u3067\u3001\u305d\u308c\u3060\u3051\u53d7\u4fe1\u3067\u304d\u308c\u3070\u826f\u3044\u306e\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u308c\u306f iBeacon \u3084 EN API\uff08COCOA \u306e\u30a2\u30c9\u30d0\u30bf\u30a4\u30ba\uff09\u306e\u767a\u4fe1\u30c1\u30a7\u30c3\u30af\u306b\u4f7f\u3048\u307e\u3059\u3002\u4f55\u304b\u30b9\u30de\u30db\u3084 M5Stack \u3067\u4f5c\u6210 iBeacon \u306e\u767a\u4fe1\u30c4\u30fc\u30eb\u3092\u4f5c\u3063\u305f\u3068\u304d\u306b\u3001\u672c\u5f53\u306b\u767a\u4fe1\u3067\u304d\u3066\u3044\u308b\u306e\u304b\u3001\u3042\u308b\u3044\u306f\u3001\u767a\u4fe1\u3057\u3066\u3044\u306a\u3044\u306e\u304b\uff08\u96fb\u529b\u6d88\u8cbb\u3092\u6291\u3048\u308b\u305f\u3081\u306b\u5b9a\u671f\u7684\u306b\u505c\u6b62\u3059\u308b\u5834\u5408\u3082\u3042\u308a\u307e\u3059\uff09\u3092\u78ba\u8a8d\u3059\u308b\u306e\u306b\u4f7f\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-26.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"374\" src=\"https:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-26-1024x374.png\" alt=\"\" class=\"wp-image-12023\" srcset=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-26-1024x374.png 1024w, http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-26-300x110.png 300w, http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-26-768x281.png 768w, http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-26-1536x562.png 1536w, http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-26-2048x749.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>iBeacon \u306e\u96fb\u6587\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306f\u308f\u304b\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u3053\u308c\u306b\u6cbf\u3063\u3066\u5b9f\u88c5\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>Windows \u306e\u5834\u5408\u306f\u3001BLE \u3092\u4f7f\u3046\u306e\u306b UWP \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3044\u307e\u3059\u3002\u4ee5\u524d\u306f\u8272\u3005\u9762\u5012\u3060\u3063\u305f\u306e\u3067\u3059\u304c\u3001TargetFramework \u306b &#8216;net10.0-windows10.0.22621.0&#8217; \u306e\u3088\u3046\u306b\u6307\u5b9a\u3059\u308c\u3070\u5927\u4e08\u592b\u3067\u3059\u3002\u3053\u308c\u3067 BLE \u3092\u53d7\u4fe1\u3059\u308b\u305f\u3081\u306e BluetoothLEAdvertisementWatcher \u30af\u30e9\u30b9\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing Windows.Devices.Bluetooth.Advertisement;\nusing Windows.Storage.Streams;\n\n\/\/ BLE\u306e\u30b9\u30ad\u30e3\u30ca\nBluetoothLEAdvertisementWatcher watcher;\n\nMain(args);\n\nvoid Main(string&#x5B;] args)\n{\n    Console.WriteLine(&quot;Folkbears iBeaconCheck&quot;);\n\n    watcher = new BluetoothLEAdvertisementWatcher()\n    {\n        ScanningMode = BluetoothLEScanningMode.Passive\n    };\n    \/\/ \u30b9\u30ad\u30e3\u30f3\u3057\u305f\u3068\u304d\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u3092\u8a2d\u5b9a\n    watcher.Received += Watcher_Received;\n    \/\/ \u30b9\u30ad\u30e3\u30f3\u958b\u59cb\n    watcher.Start();\n    \/\/ \u30ad\u30fc\u304c\u62bc\u3055\u308c\u308b\u307e\u3067\u5f85\u3064\n    Console.WriteLine(&quot;Press any key to continue&quot;);\n    Console.ReadLine();\n}\n\nvoid Watcher_Received(\n    BluetoothLEAdvertisementWatcher sender,\n    BluetoothLEAdvertisementReceivedEventArgs args)\n{\n    var mac = string.Join(&quot;:&quot;,\n                BitConverter.GetBytes(args.BluetoothAddress).Reverse()\n                .Select(b =&gt; b.ToString(&quot;X2&quot;))).Substring(6);\n    var rssi = args.RawSignalStrengthInDBm;\n    var time = args.Timestamp.ToString(&quot;yyyy\/MM\/dd HH:mm:ss.fff&quot;);\n    \n\n    if ( args.Advertisement.ManufacturerData.Count &gt; 0)\n    {\n        var data = args.Advertisement.ManufacturerData&#x5B;0];\n        if ( data.CompanyId == 0x004c &amp;&amp; data.Data.Length &gt;= 23)\n        {\n            byte&#x5B;] ibeacon = new byte&#x5B;data.Data.Length];\n            DataReader.FromBuffer(data.Data).ReadBytes(ibeacon);\n            if (ibeacon&#x5B;0] == 0x02 &amp;&amp; ibeacon&#x5B;1] == 0x15)\n            {\n                byte&#x5B;] uuid = ibeacon&#x5B;2..18];\n                byte&#x5B;] major = ibeacon&#x5B;18..20];\n                byte&#x5B;] minor = ibeacon&#x5B;20..22];\n                byte txpower = ibeacon&#x5B;22];\n\n                int majorvalue = major&#x5B;0] * 256 + major&#x5B;1];\n                int minorvalue = minor&#x5B;0] * 256 + minor&#x5B;1];\n                Console.WriteLine($&quot;{time} &#x5B;{tohex(uuid)}] {rssi} dBm {mac} &quot;\n                    + string.Format(&quot;{0:x04}&quot;, majorvalue) + &quot; &quot;\n                    + string.Format(&quot;{0:x04}&quot;, minorvalue) + &quot; &quot;\n                    );\n            }\n        }\n    }\n    string tohex( byte&#x5B;] data )\n    {\n        return BitConverter.ToString(data).Replace(&quot;-&quot;, &quot;&quot;).ToLower();\n    }\n}\n<\/pre><\/div>\n\n\n<p>\u30b3\u30f3\u30bd\u30fc\u30eb\u51fa\u529b\u306e\u305f\u3081\u306b\u3042\u308c\u3053\u308c\u3084\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u53d7\u4fe1\u3060\u3051\u306a\u308c\u3070\u6570\u5341\u884c\u3067\u6e08\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<p>1. BluetoothLEAdvertisementWatcher \u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u6210\u3059\u308b<br>2. ScanningMode \u30d7\u30ed\u30d1\u30c6\u30a3\u3092 Passive \u306b\u8a2d\u5b9a\u3059\u308b<br>3. Received \u30a4\u30d9\u30f3\u30c8\u306b\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u3092\u8a2d\u5b9a\u3059\u308b<br>4. Start \u30e1\u30bd\u30c3\u30c9\u3067\u30b9\u30ad\u30e3\u30f3\u3092\u958b\u59cb\u3059\u308b<\/p>\n\n\n\n<p>\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u5185\u306f<\/p>\n\n\n\n<p>1. args.Advertisement.ManufacturerData \u30d7\u30ed\u30d1\u30c6\u30a3\u3067\u3001\u30e1\u30fc\u30ab\u30fc\u56fa\u6709\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b<br>2. CompanyId \u30d7\u30ed\u30d1\u30c6\u30a3\u3067 Apple \u306e 0x004c \u304b\u78ba\u8a8d\u3059\u308b<br>3. Data \u30d7\u30ed\u30d1\u30c6\u30a3\u3067\u30c7\u30fc\u30bf\u672c\u4f53\u3092\u53d6\u5f97\u3059\u308b<br>4. iBeacon \u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306b\u6cbf\u3063\u3066\u30c7\u30fc\u30bf\u3092\u89e3\u6790\u3059\u308b<\/p>\n\n\n\n<p>iBeacon \u3092\u5224\u5225\u3059\u308b\u306e\u306f ManufacturerData \u306e\u5148\u982d\u306b\u3042\u308b<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Apple Company ID (0x004c)<\/li>\n\n\n\n<li>iBeacon Type (0x02)<\/li>\n\n\n\n<li>iBeacon Length (0x15)<\/li>\n<\/ul>\n\n\n\n<p>\u306e\u90e8\u5206\u3067\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>iBeacon \u81ea\u4f53\u306e UUID \u3092\u53d6\u5f97\u3057\u3066\u3001\u3069\u3053\u3067\u767a\u4fe1\u3055\u308c\u305f\u3082\u306e\u304b\u3092\u8a18\u9332\u3057\u3066\u3044\u304d\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u3001iBeacon \u306a\u3089\u3070\u4f55\u3067\u3082\u53d7\u4fe1\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u5927\u62b5\u306f\u76ee\u7684\u306e UUID \u3064\u307e\u308a\u3001\u65e2\u306b\u30a2\u30d7\u30ea\u304c\u77e5\u3063\u3066\u3044\u308b UUID \u3060\u3051\u3092\u53d7\u4fe1\u3059\u308b\u8a2d\u8a08\u306e\u306f\u305a\u3067\u3059\u3002<br>FolkBers \u306e\u5834\u5408\u306f\u3001\u3072\u3068\u3064\u306e UUID \u3092\u4f7f\u3063\u3066\u3001Major \u3068 Minor \u3067\u5834\u6240\u3092\u56fa\u6709ID\uff08Temp ID\uff09\u306b\u3057\u3066\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>dotnet run \u3067\u5b9f\u884c\u3059\u308b\u3068\u3001\u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u51fa\u529b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-27.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"588\" src=\"https:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-27-1024x588.png\" alt=\"\" class=\"wp-image-12024\" srcset=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-27-1024x588.png 1024w, http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-27-300x172.png 300w, http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-27-768x441.png 768w, http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-27.png 1074w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>BluetoothLEScanningMode.Passive \u3068 Active \u306e\u9055\u3044\u306f\u3001Active \u306e\u5834\u5408\u306f\u30c7\u30d0\u30a4\u30b9\u540d\u8981\u6c42\u306a\u3069\u306e\u8ffd\u52a0\u306e\u30d1\u30b1\u30c3\u30c8\u3092\u9001\u4fe1\u3059\u308b\u3053\u3068\u3067\u3059\u3002iBeacon \u306e\u5834\u5408\u306f\u53d7\u4fe1\u3060\u3051\u3067\u826f\u3044\u306e\u3067 Passive \u3067\u5341\u5206\u3067\u3059\u3002GATT \u3067\u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u3092\u3059\u308b\u3068\u304d\u306f Active \u306b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Windows \u3067\u306f Scan Window \u3092\u5909\u3048\u3089\u308c\u308b\u306e\u304b\uff1f<\/strong><\/h2>\n\n\n\n<p>BluetoothLEAdvertisementWatcher \u30af\u30e9\u30b9\u306b\u306f Scan Window \u3092\u5909\u3048\u308b\u30d7\u30ed\u30d1\u30c6\u30a3\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u306a\u306e\u3067\u3001\u53d7\u4fe1\u7cbe\u5ea6\u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u306a\u3044\u306e\u3067\u3001\u5b9f\u6e2c\u3057\u3066\u53d7\u4fe1\u72b6\u614b\u3092\u78ba\u8a8d\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3061\u306a\u307f\u306b Android \u306e\u5834\u5408\u3067\u306f SCAN_MODE_LOW_POWER \u3084 SCAN_MODE_BALANCED \u306e\u3088\u3046\u306b\u4ee3\u66ff\u3067\u3059\u304c\u30b9\u30ad\u30e3\u30f3\u983b\u5ea6\u3092\u5909\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4ee5\u524d\u3001\u30d0\u30c3\u30c6\u30ea\u30fc\u6d88\u8cbb\u3092\u6291\u3048\u308b\u305f\u3081\u306b SCAN_MODE_LOW_POWER \u3092\u4f7f\u3063\u305f\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u9045\u5ef6\u304c\u591a\u304b\u3063\u305f\u899a\u3048\u304c\u308a\u307e\u3059\u3002\u3053\u308c\u306f\u5f8c\u3067\u518d\u8a66\u9a13\u3002<\/p>\n\n\n\n<p>m5stack \u306e\u3088\u3046\u306a ESP32 \u30d9\u30fc\u30b9\u306e\u30de\u30a4\u30b3\u30f3\u3092\u4f7f\u3048\u3070\u3001\u7d30\u304b\u304f\u6307\u5b9a\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\nvoid setup() {\n  BLEDevice::init(&quot;&quot;);\n  BLEScan *scan = BLEDevice::getScan();\n  scan-&gt;setInterval(0x00A0); \/\/ 100ms \/ 0.625ms\n  scan-&gt;setWindow(0x0050);   \/\/ 50ms \/ 0.625ms\n  scan-&gt;setActiveScan(false); \/\/ \u53d7\u4fe1\u306e\u307f\u306a\u3089 false, \u30b9\u30ad\u30e3\u30f3\u5fdc\u7b54\u3082\u6b32\u3057\u3051\u308c\u3070 true\n  scan-&gt;start(0, nullptr, false); \/\/ 0=\u7121\u671f\u9650\n}\n\n<\/pre><\/div>\n\n\n<p>Scan Window \u306e\u5b9f\u9a13\u3092\u3059\u308b\u5834\u5408\u306f\u3001\u3053\u3063\u3061\u3067\u78ba\u8a8d\u3057\u305f\u307b\u3046\u304c\u826f\u3055\u305d\u3046\u3067\u3059\u3002\u3053\u308c\u306f\u5f8c\u3067\u4f5c\u6210\u3057\u3066\u307f\u307e\u3059\u3002\u78ba\u304b\u3001iBeacon \u306e\u767a\u4fe1\u6a5f\u306f\u4f5c\u3063\u3066\u307f\u305f\u3051\u3069\u3001\u53d7\u4fe1\u6a5f\u306f\u4f5c\u3063\u305f\u3053\u3068\u304c\u306a\u3044\u306e\u3067\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>iBeacon \u306e\u3088\u3046\u306a BLE \u30a2\u30c9\u30d0\u30bf\u30a4\u30ba\u3084\u3001 GATT \u30b5\u30fc\u30d3\u30b9\u304c\u8272\u3005\u98db\u3093\u3067\u3044\u307e\u3059\u3001\u3068\u3044\u3046\u306e\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u305f\u3081\u306e\u30c4\u30fc\u30eb\u306f BLE \u901a\u4fe1\u30c1\u30a7\u30c3\u30af\u30c4\u30fc\u30eb\u306e\u3042\u308c\u3053\u308c https:\/\/www.moonmile.net\/bl &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/12022\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3,110],"tags":[],"class_list":["post-12022","post","type-post","status-publish","format-standard","hentry","category-dev","category-folkbears"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/12022","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/comments?post=12022"}],"version-history":[{"count":1,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/12022\/revisions"}],"predecessor-version":[{"id":12025,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/12022\/revisions\/12025"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=12022"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=12022"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=12022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}