我正在使用Tizen
的 Wearable SDK 创建表盘,虽然我可以使用blueAdapter = tizen.bluetooth.getDefaultAdapter();
and检索蓝牙的电源状态bluetoothPowered = blueAdapter.powered;
,但我宁愿使用蓝牙监听器而不是不断调用blueAdapter.powered
.
我遇到的问题是,虽然我从 Tizen 的Bluetooth API
网页直接复制并粘贴了示例代码(尽管我确实更改了适配器的名称,见下文),但我收到以下错误:'undefined' is not a function (evaluating 'blueAdapter.setChangeListener(changeListener)')
.
这是我正在使用的代码:
var blueAdapter = tizen.bluetooth.getDefaultAdapter();
var changeListener = {
onstatechanged: function(powered) {
console.log ("Power state is changed into: " + powered);
},
onnamechanged: function( name) {
console.log("Name is changed to: " + name);
},
onvisibilitychanged: function(visible) {
console.log("Visibility is changed into: " + visible);
}
};
blueAdapter.setChangeListener(changeListener);
不确定它是否有帮助,但我正在使用以下内容privileges
:
http://tizen.org/privilege/bluetooth.admin
http://tizen.org/privilege/bluetooth.gap
任何帮助,将不胜感激。