本文整理汇总了TypeScript中ionic-native.BluetoothSerial类的典型用法代码示例。如果您正苦于以下问题:TypeScript BluetoothSerial类的具体用法?TypeScript BluetoothSerial怎么用?TypeScript BluetoothSerial使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BluetoothSerial类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:tspeu,项目名称:testBluetooth-ionic2,代码行数:15,代码来源:bluethooth-component.ts
示例2: bledeviceChanged
bledeviceChanged(value) {
this.blescan = false;
this.datastream = [];
if (this.platform.is('mobile')) {
BluetoothSerial.connect(value).then(
value => {
this.datastream.push("connect ok:" + JSON.stringify(value));
console.log(value);
this.watcher = BluetoothSerial.subscribe('\n').subscribe(
(data) => {
this.datastream.push("subscribe data:" + JSON.stringify(data));
this.userData.setBluetoothData(data);
console.log("subscribe data" + data);
},
(err) => {
this.datastream.push("subscribe err:" + JSON.stringify(data));
console.log("subscribeRaw err:" + data);
}
);
},
err => {
this.datastream.push("connect err:" + JSON.stringify(err));
console.error(err);
}
);
} 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);
}
}
开发者ID:maxamillion32,项目名称:fleetany-mobile,代码行数:31,代码来源:bluetooth.ts
示例3:
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);
});
});
开发者ID:maxamillion32,项目名称:fleetany-mobile,代码行数:9,代码来源:bluetooth.ts
示例4: 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++);
}
}
开发者ID:maxamillion32,项目名称:fleetany-mobile,代码行数:19,代码来源:bluetooth.ts
示例5: bleToggleMobile
bleToggleMobile(value) {
if (value) {
BluetoothSerial.list().then(
value => {
if (value.length > 0) {
this.devices = value;
} else {
this.userData.showToast('No bluetooth device paired!', 'Error!', this.nav);
}
//this.datastream.push("list ok:" + JSON.stringify(value));
console.log(value);
},
err => {
this.datastream.push("list err:" + JSON.stringify(err));
console.error(err);
}
);
} else {
if (this.watcher) {
this.watcher.unsubscribe();
this.watcher = null;
}
}
}
开发者ID:maxamillion32,项目名称:fleetany-mobile,代码行数:24,代码来源:bluetooth.ts
注:本文中的ionic-native.BluetoothSerial类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论