function main() {
var ble = new BleClient('fe2342e1-d234-fee3-aae4-fe2e342211dc', 'cf3432fb-d234-fee3-aae4-fe2e342211dc');
var ret = ble.connect();
console.log('ret:', ret)
if (1 == ret) {
bleHome(ble);
}
}
function bleRelease(ble) {
var cmd = 'v';
console.log('cmd:' + cmd)
var ret = ble.send(cmd)
console.log('send ret:', ret)
}
function bleMove(ble, x, y) {
x = parseInt(x * 10000 / rsScreenWidth);
y = parseInt(y * 10000 / rsScreenHeight);
var cmd = `e${x},${y}`;
console.log('cmd:' + cmd)
var ret = ble.send(cmd)
console.log('send ret:', ret)
}
function bleClick(ble, x, y, duration) {
x = parseInt(x * 10000 / rsScreenWidth);
y = parseInt(y * 10000 / rsScreenHeight);
if (null == duration) {
duration = 200
}
var cmd = `c${x},${y},${duration}`;
console.log('cmd:' + cmd)
var ret = ble.send(cmd)
console.log('send ret:', ret)
}
// curvable为1表示模拟真人曲线滑动,0表示直线滑动,默认为1.
function bleSwipe(ble, x1, y1, x2, y2, duration, curvable) {
x1 = parseInt(x1 * 10000 / rsScreenWidth);
y1 = parseInt(y1 * 10000 / rsScreenHeight);
x2 = parseInt(x2 * 10000 / rsScreenWidth);
y2 = parseInt(y2 * 10000 / rsScreenHeight);
if (null == duration) {
duration = 500;
}
if (null == curvable) {
curvable = 1;
}
var cmd = `m${x1},${y1},${x2},${y2},${duration},${curvable}`;
console.log('cmd:' + cmd)
var ret = ble.send(cmd)
console.log('send ret:', ret)
}
function bleSelectAll(ble) {
var ret = ble.send('s')
console.log('send ret:', ret)
}
function bleCopy(ble) {
var ret = ble.send('o')
console.log('send ret:', ret)
}
function bleCut(ble) {
var ret = ble.send('t')
console.log('send ret:', ret)
}
function blePaste(ble) {
var ret = ble.send('p')
console.log('send ret:', ret)
}
function bleHome(ble) {
var ret = ble.send('h')
console.log('send ret:', ret)
}
function bleBack(ble) {
var ret = ble.send('b')
console.log('send ret:', ret)
}