首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从BLE Ionic读取广告数据

如何从BLE Ionic读取广告数据
EN

Stack Overflow用户
提问于 2017-08-28 19:03:35
回答 1查看 1.1K关注 0票数 2

广告数据在iPhone上是可读的格式,但在安卓上是十进制格式。如何阅读和解释android的广告包。

代码语言:javascript
复制
 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();
                });
EN

回答 1

Stack Overflow用户

发布于 2017-08-28 20:25:14

Android广告数据以ArrayBuffer的形式接收。您需要使用javascripts String.fromCharCode method将其转换为人类可读的字符串

代码语言:javascript
复制
let stringResult = String.fromCharCode.apply(null, new Uint8Array(buffer));

其中bufferresponse对象的advertising属性。您可以找到BLE here的离子原生文档。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45917469

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档