为什么我无法获得广告包或任何信息?

时间:2017-07-11 14:17:39

标签: bluetooth-lowenergy tizen tizen-web-app

通过扫描芯片做广告:为什么芯片无法广播数据。我们通过Service uuid - tizen web模块扫描芯片。是平台问题吗?

SDK:Tizen Wearable 2.3.2

平台:Web API

Samsung Gear S2,Version2.3.2

代码说明:扫描后的芯片调用广告()没有得到任何信息。所以我们在用户按下连接按钮时调用advertise()。这是演示代码。

//button for connet
function connect() {
var contentText = document.querySelector('#content-text-connect');

console.log("" + contentText.innerHTML);

adapter.startScan(onDeviceFound);

console.log("start scanning");

advertise();

}

function onDeviceFound(device) {

var d_name = device.name + "";
console.log("Found device-" + d_name);

if (d_name !== null && (d_name.substring(0, 11) === "FreeXip BGM")) {

    remoteDevice = device;

    console.error("Found device name: " + device.name);

    adapter.stopScan();
    console.log("connectSuccess - stop scanning");


    //advertise();

    connectToChip(remoteDevice);

  }
}
function advertise(){

   var advertiseData = new tizen.BluetoothLEAdvertiseData(
            {
              includeName: true,
              serviceuuids: ["0bd51666-e7cb-469b-8e4d-2742f1ba77cc"]  /* 180F is 16bit Battery Service UUID   */
            });
    var connectable = true;
    var adapter = tizen.bluetooth.getLEAdapter();

    adapter.startAdvertise(advertiseData, "ADVERTISE",
            function onstate(state)
            {
              console.log("Advertising configured: " + state);
              alert("Advertising configured="+state);
            },

            function(error)
            {
              console.log("startAdvertise() failed: " + error.message);
              alert("startAdvertise() failed="+ error.message);
            },

            "LOW_LATENCY", connectable);
  }
}
[![Output when we run this code][1]][1]

参考:() Tizen Dev guidelines

任何建议都会很棒。谢谢:))

1 个答案:

答案 0 :(得分:0)

您想通过Web API获取其他设备的BLE广告包吗?

您可以在以下参考指南中看到 Discovering Bluetooth Low Energy Devices

您发布的参考文献是natvie指南,您的目标不明确。

以下是关于蓝牙,Tizen 2.3.2的Web API参考。我建议您查看API文档,然后重试。 Bluetooth API

祝你好运:)