【发布时间】:2016-11-27 04:02:47
【问题描述】:
我在英特尔 XDK 中使用蓝牙低功耗 (BLE) 概念创建了一个应用程序,使用 cordova-plugin-ble-central 插件来获取他们的信息。现在只得到了 deviceID、RSSI 值。
我正在尝试使用 Cordova 插件 (https://github.com/don/cordova-plugin-ble-central) 从 Beacon 设备获取电池电量、温度以及一些相关服务。但我无法连接我的设备。
当我在设备中运行我的应用程序时,它只返回“未找到外围设备 ID”。我的代码是
onConnect = function() {
alert('onconnect start');
// TODO check if we have the battery service
// TODO check if the battery service can notify us
//ble.startNotification(deviceId, battery.service,battery.level, app.onBatteryLevelChange, app.onError);
batteryStateButton.dataset.deviceId = deviceId;
disconnectButton.dataset.deviceId = deviceId;
app.showDetailPage();
alert('onconnect end');
};
ble.connect(deviceId, onConnect, app.onError);
当我使用上述代码时,没有收到“onconnect start”警报。 在我的插件代码中
connect: function (device_id, success, failure) {
alert(device_id);
var successWrapper = function(peripheral) {
alert('successWrapper');
convertToNativeJS(peripheral);
success(peripheral);
};
cordova.exec(successWrapper, failure, 'BLE', 'connect', [device_id]);
},
仅从插件获取设备 ID 警报。我也尝试从我的手机配对到设备,收到一些错误“无法与 deviceid 通信”。请问有什么建议吗?
【问题讨论】:
标签: android cordova bluetooth intel-xdk bluetooth-lowenergy