本文整理汇总了TypeScript中ionic-native.BluetoothSerial.isConnected方法的典型用法代码示例。如果您正苦于以下问题:TypeScript BluetoothSerial.isConnected方法的具体用法?TypeScript BluetoothSerial.isConnected怎么用?TypeScript BluetoothSerial.isConnected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ionic-native.BluetoothSerial
的用法示例。
在下文中一共展示了BluetoothSerial.isConnected方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: ngOnInit
ngOnInit(){
//this.bluetoothSerial.connect(macAddress_or_uuid, connectSuccess, connectFailure);
/* BluetoothSerial.startScan([]).subscribe(device => {
this.devices.push(device);
});
*/
BluetoothSerial.available();
BluetoothSerial.isConnected();
BluetoothSerial.isEnabled();
BluetoothSerial.enable();
BluetoothSerial.showBluetoothSettings();
}
示例2: sendData
sendData() {
if (this.counter > 9) this.counter = 1;
if (this.platform.is('mobile')) {
BluetoothSerial.isConnected().then((result) => {
var counter = (this.counter++).toString() + '\n';
BluetoothSerial.write(counter).then((data) => {
this.datastream.push(JSON.stringify(data));
this.userData.setBluetoothData(data);
this.datastream.push("write data:" + JSON.stringify(data) + this.counter);
console.log("write data" + data);
});
});
} else {
var data = '{\"id\":\"0000000001\",\"pr\":127,\"tp\":22.0,\"ba\":2.95}\r\n';
this.datastream.push(JSON.stringify(data));
this.userData.setBluetoothData(data);
this.datastream.push("write data:" + this.counter++);
}
}