{"id":12062,"date":"2026-02-18T17:30:54","date_gmt":"2026-02-18T08:30:54","guid":{"rendered":"https:\/\/www.moonmile.net\/blog\/?p=12062"},"modified":"2026-02-18T17:30:54","modified_gmt":"2026-02-18T08:30:54","slug":"iphoneios%e3%81%a7-manufacturer-data-%e3%82%92%e5%8f%97%e4%bf%a1%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/12062","title":{"rendered":"iPhone(iOS)\u3067 Manufacturer Data \u3092\u53d7\u4fe1\u3059\u308b"},"content":{"rendered":"\n<p>\u524d\u56de\u306e\u7d9a\u304d\u3067\u3001FolkBears \u578b\u3068 Manufacturer Data \u5f62\u5f0f\u306e\u53d7\u4fe1\u6a5f\u3092 iOS \u7248\u3082\u4f5c\u3063\u3066\u3044\u304d\u307e\u3059\u3002FolkBears \u578b\u3068\u3044\u3046\u306e\u306f GATT \u30b5\u30fc\u30d3\u30b9\u3067\u63a5\u7d9a\u3059\u308b\u65b9\u5f0f\u306e\u3053\u3068\u3067\u3059\u3002\u5b9f\u969b\u306e\u3068\u3053\u308d\u306f\u3001\u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u3057\u3066 TempUserId \u3092\u53d6\u5f97\u3059\u308b\u306e\u3067\u3059\u304c\u3001\u3072\u3068\u307e\u305a\u76f8\u624b\u306e\u30c7\u30d0\u30a4\u30b9\u3092\u898b\u3064\u3051\u308b\u3068\u3053\u308d\u307e\u3067\u5b9f\u88c5\u3057\u3066\u304a\u304d\u307e\u3059\u3002\u3053\u306e\u3042\u305f\u308a\u3001\u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u578b\u3067\u63a5\u89e6\u78ba\u8a8d\u30a2\u30d7\u30ea\u3092\u4f5c\u308d\u3046\u3068\u3059\u308b\u3068\u3001TempUserId \u306e\u4ea4\u63db\u3088\u308a\u3082\u3001\u6700\u521d\u306b\u76f8\u624b\u306e\u30c7\u30d0\u30a4\u30b9\u3092\u898b\u3064\u3051\u308b\u3068\u3053\u308d\u3067\u63a5\u89e6\u9045\u5ef6\u3059\u308b\u306e\u3067\u306f\u306a\u3044\u304b\u3001\u3068\u3044\u3046\u61f8\u5ff5\u304c\u3042\u308b\u305f\u3081\u3067\u3059\u3002\u3053\u308c\u3092\u5f8c\u306b\u5b9f\u6e2c\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>GATT \u901a\u4fe1\u306e\u305f\u3081\u306b\u76f8\u624b\u30c7\u30d0\u30a4\u30b9\u306e\u767a\u898b<\/strong><\/h2>\n\n\n\n<p>centralManager.scanForPeripherals \u3092\u547c\u3073\u51fa\u3059\u3068\u304d\u306b\u3001\u91cd\u8907\u3092\u3086\u308b\u3059\u3088\u3046\u306b\u3057\u3066 CBCentralManagerScanOptionAllowDuplicatesKey = true \u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u901a\u5e38\u306f\u3001\u30da\u30ea\u30d5\u30a7\u30e9\u30eb\u306e\u767a\u898b\u306f\u4e00\u5ea6\u3060\u3051\u3067\u3088\u3044\u306e\u3067\u3059\u304c\u3001\u4eca\u56de\u306e\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u306e\u5834\u5408\u306f\u30c7\u30d0\u30a4\u30b9\u3068\u306e\u63a5\u89e6\u983b\u5ea6\u3092\u307f\u308b\u305f\u3081\u306b\u308f\u3056\u3068\u91cd\u8907\u3055\u305b\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: swift; title: ; notranslate\" title=\"\">\n    func startScanning() {\n        guard let centralManager = centralManager,\n              centralManager.state == .poweredOn,\n              !isScanning else {\n            print(&quot;Bluetooth \u304c\u5229\u7528\u3067\u304d\u306a\u3044\u304b\u3001\u65e2\u306b\u30b9\u30ad\u30e3\u30f3\u4e2d\u3067\u3059&quot;)\n            return\n        }\n        \n        peripherals.removeAll()\n        \/\/ discoveredPeripherals.removeAll()\n        \n        \/\/ \u7279\u5b9a\u306e\u30b5\u30fc\u30d3\u30b9UUID\u3067\u30b9\u30ad\u30e3\u30f3\uff08nil\u3067\u5168\u30c7\u30d0\u30a4\u30b9\uff09\n        centralManager.scanForPeripherals(withServices: &#x5B;targetServiceUUID], options: &#x5B;\n            CBCentralManagerScanOptionAllowDuplicatesKey: true \/\/ \u91cd\u8907\u3092\u8a31\u53ef\u3057\u3066\u30b9\u30ad\u30e3\u30f3\n        ])\n        \n        isScanning = true\n        scanningStatus = &quot;\u30b9\u30ad\u30e3\u30f3\u4e2d...&quot;\n        print(&quot;GATT \u30af\u30e9\u30a4\u30a2\u30f3\u30c8 \u30b9\u30ad\u30e3\u30f3\u958b\u59cb&quot;)\n    }\n\n<\/pre><\/div>\n\n\n<p>FolkBears \u672c\u4f53\u304b\u3089\u30b3\u30fc\u30c9\u3092\u629c\u304d\u51fa\u3057\u3066\u304d\u305f\u306e\u3067\u3001\u7121\u99c4\u306a\u30b3\u30fc\u30c9\u304c\u591a\u3044\u3067\u3059\u304c\u3001CBCentralManagerDelegate \u306e centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String: Any], rssi RSSI: NSNumber) \u3067\u76f8\u624b\u306e\u30c7\u30d0\u30a4\u30b9\u304c\u767a\u898b\u3057\u3066\u3044\u308b\u30a4\u30d9\u30f3\u30c8\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u6700\u5c0f\u30b3\u30fc\u30c9\u3068\u3057\u3066\u306f\u3001\u5148\u306e CBCentralManagerScanOptionAllowDuplicatesKey: true \u306e\u8a2d\u5b9a\u3068\u3001CBCentralManagerDelegate \u306e centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String: Any], rssi RSSI: NSNumber) \u306e\u5b9f\u88c5\u3060\u3051\u3067\u5341\u5206\u3067\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nextension GattClient: CBCentralManagerDelegate {\n    func centralManagerDidUpdateState(_ central: CBCentralManager) {\n        DispatchQueue.main.async {\n            switch central.state {\n            case .poweredOn:\n                self.bluetoothState = &quot;Powered On&quot;\n                print(&quot;Bluetooth \u304c\u6709\u52b9\u306b\u306a\u308a\u307e\u3057\u305f&quot;)\n            case .poweredOff:\n                self.bluetoothState = &quot;Powered Off&quot;\n                self.stopScanning()\n                self.disconnectFromPeripheral()\n                print(&quot;Bluetooth \u304c\u7121\u52b9\u3067\u3059&quot;)\n            case .resetting:\n                self.bluetoothState = &quot;Resetting&quot;\n                print(&quot;Bluetooth \u30ea\u30bb\u30c3\u30c8\u4e2d&quot;)\n            case .unauthorized:\n                self.bluetoothState = &quot;Unauthorized&quot;\n                print(&quot;Bluetooth \u4f7f\u7528\u6a29\u9650\u304c\u3042\u308a\u307e\u305b\u3093&quot;)\n            case .unsupported:\n                self.bluetoothState = &quot;Unsupported&quot;\n                print(&quot;Bluetooth \u304c\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u307e\u305b\u3093&quot;)\n            case .unknown:\n                self.bluetoothState = &quot;Unknown&quot;\n                print(&quot;Bluetooth \u72b6\u614b\u4e0d\u660e&quot;)\n            @unknown default:\n                self.bluetoothState = &quot;Unknown&quot;\n                break\n            }\n        }\n    }\n    \n    func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: &#x5B;String: Any], rssi RSSI: NSNumber) {\n        \n        let name = peripheral.name ?? advertisementData&#x5B;CBAdvertisementDataLocalNameKey] as? String ?? &quot;&quot;\n        \n        let discoveredPeripheral = DiscoveredPeripheral(\n            peripheral: peripheral,\n            name: name,\n            rssi: RSSI,\n            advertisementData: advertisementData\n        )\n        \n        DispatchQueue.main.async {\n            self.peripherals.append(discoveredPeripheral)\n            self.scanningStatus = &quot;\u767a\u898b: \\(self.peripherals.count)\u500b&quot;\n            self.onDiscover?(discoveredPeripheral, Date())\n        }\n        print(&quot;\u30da\u30ea\u30d5\u30a7\u30e9\u30eb\u767a\u898b: \\(discoveredPeripheral.displayName), RSSI: \\(RSSI)&quot;)\n    }\n    \n    func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {\n        DispatchQueue.main.async {\n            self.connectedPeripheral = peripheral\n            self.connectionStatus = &quot;\u63a5\u7d9a\u6e08\u307f&quot;\n        }\n        \n        print(&quot;\u30da\u30ea\u30d5\u30a7\u30e9\u30eb\u63a5\u7d9a\u6210\u529f: \\(peripheral.name ?? &quot;Unknown&quot;)&quot;)\n        \n        \/\/ MTU\u8981\u6c42\u3092\u5b9f\u884c\n        requestMTU(requestedMTU)\n        \n        \/\/ \u30b5\u30fc\u30d3\u30b9\u63a2\u7d22\u958b\u59cb\n        peripheral.discoverServices(&#x5B;targetServiceUUID])\n    }\n    \n    func centralManager(_ central: CBCentralManager, didFailToConnect peripheral: CBPeripheral, error: Error?) {\n        DispatchQueue.main.async {\n            self.connectionStatus = &quot;\u63a5\u7d9a\u5931\u6557&quot;\n        }\n        \n        print(&quot;\u30da\u30ea\u30d5\u30a7\u30e9\u30eb\u63a5\u7d9a\u5931\u6557: \\(error?.localizedDescription ?? &quot;Unknown error&quot;)&quot;)\n    }\n    \n    func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) {\n        DispatchQueue.main.async {\n            self.connectedPeripheral = nil\n            self.connectionStatus = &quot;\u5207\u65ad\u6e08\u307f&quot;\n            self.targetService = nil\n            self.targetCharacteristic = nil\n        }\n        \n        print(&quot;\u30da\u30ea\u30d5\u30a7\u30e9\u30eb\u5207\u65ad: \\(peripheral.name ?? &quot;Unknown&quot;)&quot;)\n    }\n}\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\"><strong>Manufacturer Data \u5f62\u5f0f\u306e\u53d7\u4fe1<\/strong><\/h2>\n\n\n\n<p>\u66f8\u304d\u65b9\u3068\u3057\u3066\u306f Android \u306e\u3068\u304d\u3068\u540c\u3058\u3067 CBCentralManagerDelegate \u3060\u3051\u3092\u4f7f\u3044\u307e\u3059\u3002 iBeacon \u306e\u3088\u3046\u306b CLLocationManager \u3068 CLBeaconRegion \u3092\u4f7f\u3044\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<p>COCOA\/EN API \u306e\u3088\u3046\u306b\u7279\u5b9a\u306e\u30c7\u30fc\u30bf\u3092\u914d\u4fe1\u3059\u308b\u5f62\u306f\u3001\u3053\u306e Manufacturer Data \u5f62\u5f0f\u3067\u3084\u308b\u306e\u304c\u4e00\u756a\u3044\u3044\u306e\u3067\u3059\u304c\u3001\u5f8c\u3067\u8a18\u4e8b\u306b\u3057\u307e\u3059\u304c iOS \u3067\u306f Manufacturer Data \u3067\u306e\u767a\u4fe1\u304c\u3067\u304d\u307e\u305b\u3093\u3002Manufacturer Data \u5f62\u5f0f\u3067\u767a\u4fe1\u3067\u304d\u308b\u306e\u306f iBeacon \u5f62\u5f0f\u3060\u3051\u3067\u3001\u5b9f\u969b\u306b\u767a\u4fe1\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u30c7\u30fc\u30bf\u90e8\u5206\u304c\u30e9\u30f3\u30c0\u30e0\u5024\uff08\uff1f\uff09\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u308c\u306f\u3001\u5b9f\u969b\u306b iOS \u7528\u306e\u767a\u4fe1\u30c4\u30fc\u30eb\u3092\u4f5c\u3063\u305f\u3068\u304d\u306b\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: swift; title: ; notranslate\" title=\"\">\nfinal class ManufacturerDataScan: NSObject, ObservableObject {\n    \/\/\/ \u53d7\u4fe1\u6642\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u3002key\u306fCompany ID(16bit)\u30920xXXXX\u3067\u8868\u8a18\u3002\n    var onManufacturerData: ((String, Data, NSNumber, CBPeripheral, Data) -&gt; Void)?\n\n    @Published var isScanning = false\n    @Published var scanningStatus = &quot;\u505c\u6b62\u4e2d&quot;\n\n    private var centralManager: CBCentralManager!\n\n    override init() {\n        super.init()\n        centralManager = CBCentralManager(delegate: self, queue: nil)\n    }\n\n    func startScan() {\n        guard centralManager.state == .poweredOn else {\n            print(&quot;ManufacturerDataScan: Bluetooth\u672a\u6e96\u5099 state=\\(centralManager.state.rawValue)&quot;)\n            return\n        }\n        guard !isScanning else { return }\n\n        centralManager.scanForPeripherals(withServices: nil, options: &#x5B;CBCentralManagerScanOptionAllowDuplicatesKey: true])\n        isScanning = true\n        scanningStatus = &quot;\u30b9\u30ad\u30e3\u30f3\u4e2d...&quot;\n    }\n\n    func stopScan() {\n        guard isScanning else { return }\n        centralManager.stopScan()\n        isScanning = false\n        scanningStatus = &quot;\u505c\u6b62\u4e2d&quot;\n    }\n}\n\nextension ManufacturerDataScan: CBCentralManagerDelegate {\n    func centralManagerDidUpdateState(_ central: CBCentralManager) {\n        switch central.state {\n        case .poweredOn:\n            print(&quot;ManufacturerDataScan: Bluetooth On&quot;)\n        case .unauthorized:\n            print(&quot;ManufacturerDataScan: unauthorized&quot;)\n        case .unsupported:\n            print(&quot;ManufacturerDataScan: unsupported&quot;)\n        case .poweredOff:\n            print(&quot;ManufacturerDataScan: Bluetooth Off&quot;)\n        default:\n            break\n        }\n    }\n\n    func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: &#x5B;String: Any], rssi RSSI: NSNumber) {\n        guard let data = advertisementData&#x5B;CBAdvertisementDataManufacturerDataKey] as? Data, !data.isEmpty else { return }\n        \/\/ Company ID\u306f\u5148\u982d2\u30d0\u30a4\u30c8Little Endian\u3067\u683c\u7d0d\u3055\u308c\u308b\n        let companyId = data.prefix(2).reduce(0) { acc, byte in (acc &lt;&lt; 8) | Int(byte) }\n        let key = String(format: &quot;0x%04X&quot;, companyId)\n        let beacon_type = data&#x5B;2]\n        let beacon_length = data&#x5B;3]\n\n\n        if ( companyId == 0xFFFF ) {\n            if ( beacon_type == 0x02 &amp;&amp; beacon_length == 0x10 ) {\n                let tempid = data.dropFirst(4)\n                onManufacturerData?(key, data, RSSI, peripheral, tempid)\n            }\n        }\n    }\n}   \n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\"><strong>\u5b9f\u884c\u3057\u305f\u69d8\u5b50<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-45.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-45.png\" alt=\"\" class=\"wp-image-12063\" srcset=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-45.png 1024w, http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-45-300x225.png 300w, http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-45-768x576.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-46.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-46.png\" alt=\"\" class=\"wp-image-12064\" srcset=\"http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-46.png 1024w, http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-46-300x225.png 300w, http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2026\/02\/image-46-768x576.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u53c2\u8003\u5148<\/strong><\/h2>\n\n\n\n<p><a href=\"https:\/\/github.com\/FolkBearsGroup\/ble-tools\/tree\/master\/folkbears-monitor-ios\">https:\/\/github.com\/FolkBearsGroup\/ble-tools\/tree\/master\/folkbears-monitor-ios<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u306e\u7d9a\u304d\u3067\u3001FolkBears \u578b\u3068 Manufacturer Data \u5f62\u5f0f\u306e\u53d7\u4fe1\u6a5f\u3092 iOS \u7248\u3082\u4f5c\u3063\u3066\u3044\u304d\u307e\u3059\u3002FolkBears \u578b\u3068\u3044\u3046\u306e\u306f GATT \u30b5\u30fc\u30d3\u30b9\u3067\u63a5\u7d9a\u3059\u308b\u65b9\u5f0f\u306e\u3053\u3068\u3067\u3059\u3002\u5b9f\u969b\u306e\u3068\u3053\u308d\u306f\u3001\u30b3\u30cd\u30af &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/12062\">\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-12062","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\/12062","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=12062"}],"version-history":[{"count":1,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/12062\/revisions"}],"predecessor-version":[{"id":12065,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/12062\/revisions\/12065"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=12062"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=12062"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=12062"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}