2025-04-16 18:15:18 +08:00
|
|
|
import BLESDK from './ble'
|
|
|
|
import TASK from './taskQueue'
|
|
|
|
import { aes128Encrypt } from '@/utils/index'
|
|
|
|
|
|
|
|
export function strInsert(str, length = 2) {
|
|
|
|
if (!str || !str.length) return ''
|
|
|
|
var reg = new RegExp('\\w{1,' + length + '}', 'g')
|
|
|
|
let ma = str.match(reg)
|
|
|
|
return ma.map((item) => `0x${item}`)
|
|
|
|
}
|
|
|
|
// 10进制转16进制
|
|
|
|
export const hex = (hex) => {
|
|
|
|
hex = Number(hex)
|
|
|
|
return hex < 16 ? '0' + hex.toString(16) : String(hex.toString(16))
|
|
|
|
}
|
|
|
|
|
2025-04-18 09:09:09 +08:00
|
|
|
// 第一次握手
|
|
|
|
export function handshake1() {
|
|
|
|
let list = strInsert(`7B12EA01014775696565652d56312e302e30`)
|
|
|
|
TASK.addTask(list)
|
|
|
|
}
|
|
|
|
|
|
|
|
// 第二次握手
|
|
|
|
export function handshake2() {
|
|
|
|
let list = strInsert(`7B0EEA0101436172652079616b6b`)
|
2025-04-16 18:15:18 +08:00
|
|
|
TASK.addTask(list)
|
|
|
|
}
|
|
|
|
|
|
|
|
// 同步时间
|
|
|
|
export function asyncDate() {
|
|
|
|
const now = new Date();
|
|
|
|
const year = now.getFullYear();
|
|
|
|
const month = (now.getMonth() + 1).toString();
|
|
|
|
const day = now.getDate().toString();
|
|
|
|
const hours = now.getHours().toString();
|
|
|
|
const minutes = now.getMinutes().toString();
|
|
|
|
const seconds = now.getSeconds().toString();
|
|
|
|
const zone = (new Date().getTimezoneOffset() / 60) * -1;
|
|
|
|
let str = [
|
|
|
|
"10",
|
|
|
|
"a1",
|
|
|
|
"04",
|
|
|
|
"b2",
|
|
|
|
hex(zone & 0xff),
|
|
|
|
hex(year >> 8),
|
|
|
|
hex(year & 0xff),
|
|
|
|
hex(month),
|
|
|
|
hex(day),
|
|
|
|
hex(hours),
|
|
|
|
hex(minutes),
|
|
|
|
hex(seconds),
|
|
|
|
"00",
|
|
|
|
"00",
|
|
|
|
"00",
|
|
|
|
"00",
|
|
|
|
]
|
|
|
|
.toString()
|
|
|
|
.replaceAll(",", "");
|
|
|
|
TASK.addTask(strInsert(aes128Encrypt(str)));
|
|
|
|
}
|
|
|
|
|
2025-04-18 09:09:09 +08:00
|
|
|
// -----------------获取---------------------
|
|
|
|
export function getInitData() {
|
|
|
|
// 音源设置
|
|
|
|
TASK.addTask(strInsert(`7B05EA07B100`));
|
|
|
|
|
|
|
|
// 蓝牙开关
|
|
|
|
TASK.addTask(strInsert(`7B05EA08B100`));
|
|
|
|
|
|
|
|
// 声卡开关
|
|
|
|
TASK.addTask(strInsert(`7B05EA09B100`));
|
|
|
|
|
2025-04-21 18:27:42 +08:00
|
|
|
// 播放模式 (音乐模式)
|
2025-04-18 09:09:09 +08:00
|
|
|
TASK.addTask(strInsert(`7B05EA0AB100`));
|
|
|
|
|
|
|
|
// 超低音强度
|
|
|
|
TASK.addTask(strInsert(`7B05EA0CB100`));
|
|
|
|
|
2025-04-21 18:27:42 +08:00
|
|
|
// 音乐音量
|
|
|
|
TASK.addTask(strInsert(`7B05EA06B100`));
|
|
|
|
|
|
|
|
// 话筒音量
|
|
|
|
TASK.addTask(strInsert(`7B05EA05B100`));
|
2025-04-18 09:09:09 +08:00
|
|
|
|
2025-04-21 18:27:42 +08:00
|
|
|
// 话筒混响音量
|
2025-04-18 09:09:09 +08:00
|
|
|
TASK.addTask(strInsert(`7B05EA0EB100`));
|
|
|
|
|
2025-04-21 18:27:42 +08:00
|
|
|
// 话筒混响模式
|
|
|
|
TASK.addTask(strInsert(`7B05EA0DB100`));
|
|
|
|
|
2025-04-16 18:15:18 +08:00
|
|
|
}
|
2025-04-18 09:09:09 +08:00
|
|
|
|
2025-04-21 18:27:42 +08:00
|
|
|
|