如何阅读BLE Ionic的广告数据

时间:2017-08-28 11:03:35

标签: android cordova ionic-framework bluetooth-lowenergy

广告数据是iPhone的可读格式,但它是十进制格式的Android。如何阅读和解释Android的广告包。

 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();
                });

1 个答案:

答案 0 :(得分:0)

Android广告数据以ArrayBuffer收到。您需要使用javascripts Public Class BaseClass Public Property Initial As Integer Public Property Coeficient As Integer Public Property Multiplier As Integer = Coeficient * Initial Public Sub New() Me.New(0, 1) ' default initialization End Sub Public Sub New(ByVal Value1 As Integer, ByVal Value2 As Integer) Me.Initial = Value1 Me.Coeficient = Value2 End Sub End Class Public Class DerivedClass Inherits BaseClass Public Sub New() MyBase.New() End Sub Public Sub New(ByVal Value As Integer) MyBase.New(Value, 3) 'sets the coeficient to 3 and the Initial whatever is passed to it End Sub End Class Public Class TestClas Public Sub TestDerivedClass() Dim d As New DerivedClass(5) Dim result As Integer = d.Multiplier MsgBox(result) ' should be 15, but is not, because Multiplier need to be re-initialized somehow End Sub End Class method将其转换为人类可读的字符串:

String.fromCharCode

let stringResult = String.fromCharCode.apply(null, new Uint8Array(buffer)); buffer对象的advertising属性。您可以找到BLE here的离子原生文档。