2017-08-28 9 views
1

広告データはiPhone用の判読可能な形式ですが、アンドロイド用の10進数形式です。アンドロイドの広告パケットを読み、解釈する方法。BLE Ionicから広告データを読む方法

this.scanner = this.ble.scan(["00EDSE-0000-00AE-9VVQ-9125475145125"], 1).subscribe((response) => { 
       console.log("success scan.." + JSON.stringify(response)); 
       this.ble.connect(response.id).subscribe((response) => { 
       this.toast.show("Successfully paired", '2000', 'bottom').subscribe((toast) => { 
        console.log(toast); 
        this.spinnerDialog.hide(); 
       }); 

答えて

0

Android広告データはArrayBufferとして受信されます。

bufferがあなたの advertisingプロパティ responseオブジェクトである
let stringResult = String.fromCharCode.apply(null, new Uint8Array(buffer)); 

:あなたはJavaScriptのString.fromCharCodemethodを使用して人間が読める文字列に変換する必要があります。 BLE hereのイオンネイティブドキュメントを見つけることができます。

関連する問題