-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
63 lines (60 loc) · 1.74 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"use strict"
var application = require("application");
var startPort = new pfdfoods.foodservice.ashleycao.bluetoothspp.BluetoothSPP();
var context = application.android.context;
var BTReader = (function () {
function BTReader(){
this._result="";
}
//find Device Massage:
//Bluetooth is unable: "No bluetooth adapter available"
//Device not match: "Device Name doesn't match"
//No connected devices: "Cannot find any connected device"
BTReader.prototype.findDevice = function (deviceName) {
var message = startPort.findBT(deviceName);
return message;
};
//Critical step: build connction
BTReader.prototype.buildConnection = function () {
var ifsuccess = startPort.openBT();
return ifsuccess;
};
BTReader.prototype.loopThread = function () {
var scanResult = startPort.loopThread();
return scanResult;
};
// check socket and inputStream
BTReader.prototype.checkSocketStream = function () {
var checkresult = startPort.checkConnected();
return checkresult;
};
//Get connected devices
BTReader.prototype.getPairDevice = function () {
var deviceList = startPort.getPairDevice();
return deviceList;
};
//Readin input stream
BTReader.prototype.buildInputStream = function () {
startPort.buildInputStream();
};
//closeBTconnection
BTReader.prototype.stopLoop = function () {
startPort.closeReader();
};
//closeBTconnection
BTReader.prototype.closeConnection = function () {
startPort.closeConnection();
};
//Check connectedStock
BTReader.prototype.connectStatus = function () {
var result = startPort.checkDeviceConnected();
return result;
};
//get socket
BTReader.prototype.btScocket = function () {
var socket = startPort.getStocket();
return socket;
};
return BTReader;
}());
exports.BTReader = BTReader;