@tuya-miniapp/ark-extension-virtual-device 0.0.2 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/view/app.min.js +1 -1
- package/dist/worker/index.js +317 -113
- package/package.json +1 -1
package/dist/worker/index.js
CHANGED
|
@@ -21338,7 +21338,12 @@ var services_exports = {};
|
|
|
21338
21338
|
__export(services_exports, {
|
|
21339
21339
|
apiRequestByAtop: () => apiRequestByAtop,
|
|
21340
21340
|
apiRequestByBusinessAtop: () => apiRequestByBusinessAtop,
|
|
21341
|
+
bluetoothIsOn: () => bluetoothIsOn,
|
|
21341
21342
|
clearProjectInfo: () => clearProjectInfo,
|
|
21343
|
+
emitBleConnectStatus: () => emitBleConnectStatus,
|
|
21344
|
+
emitBluetoothState: () => emitBluetoothState,
|
|
21345
|
+
emitDarkState: () => emitDarkState,
|
|
21346
|
+
emitDeviceOnlineState: () => emitDeviceOnlineState,
|
|
21342
21347
|
emitNetworkState: () => emitNetworkState,
|
|
21343
21348
|
getDeviceInfo: () => getDeviceInfo,
|
|
21344
21349
|
getDeviceMqttInfo: () => getDeviceMqttInfo,
|
|
@@ -21497,6 +21502,170 @@ var viewLog = (message) => {
|
|
|
21497
21502
|
}));
|
|
21498
21503
|
};
|
|
21499
21504
|
|
|
21505
|
+
// worker/api/TYUniDeviceControlManager.ts
|
|
21506
|
+
var import_TYUniCode = __toESM(require_dist());
|
|
21507
|
+
|
|
21508
|
+
// worker/api/services/queryDps.ts
|
|
21509
|
+
var queryDps = async ({ deviceId, dpIds }) => {
|
|
21510
|
+
const deviceInfo2 = await getDeviceInfo({ "deviceId": deviceId });
|
|
21511
|
+
const dps = deviceInfo2?.result?.dps || {};
|
|
21512
|
+
const schema = JSON.parse(deviceInfo2?.result?.schema || "[]");
|
|
21513
|
+
JSON.parse(schema).map((item) => {
|
|
21514
|
+
const { id, code, property } = item;
|
|
21515
|
+
const { type } = property || {};
|
|
21516
|
+
if (type === "raw") {
|
|
21517
|
+
const b = Buffer.from(dps[id], "base64");
|
|
21518
|
+
dps[id] = b.toString("hex");
|
|
21519
|
+
}
|
|
21520
|
+
});
|
|
21521
|
+
const result = {};
|
|
21522
|
+
for (const dpId of dpIds) {
|
|
21523
|
+
result[dpId] = dps[dpId];
|
|
21524
|
+
}
|
|
21525
|
+
return result;
|
|
21526
|
+
};
|
|
21527
|
+
|
|
21528
|
+
// worker/api/TYUniDeviceControlManager.ts
|
|
21529
|
+
var deviceInfo = null;
|
|
21530
|
+
async function getDeviceInfo2(params) {
|
|
21531
|
+
const { deviceId } = params;
|
|
21532
|
+
if (!deviceId) {
|
|
21533
|
+
return {
|
|
21534
|
+
data: null,
|
|
21535
|
+
errorCode: import_TYUniCode.TYUniPluginError.DEVICEKIT_DEVICE_ID_INVALID.code,
|
|
21536
|
+
errorMsg: import_TYUniCode.TYUniPluginError.DEVICEKIT_DEVICE_ID_INVALID.des
|
|
21537
|
+
};
|
|
21538
|
+
}
|
|
21539
|
+
const response = await getDeviceInfo({ deviceId });
|
|
21540
|
+
const { result: devInfo } = response || {};
|
|
21541
|
+
let product = {};
|
|
21542
|
+
try {
|
|
21543
|
+
const presponse = await getProductInfo({
|
|
21544
|
+
productIds: [devInfo.productId]
|
|
21545
|
+
});
|
|
21546
|
+
const { result: productInfo } = presponse || {};
|
|
21547
|
+
product = productInfo[0] || {};
|
|
21548
|
+
} catch (e) {
|
|
21549
|
+
console.log("\u672A\u83B7\u53D6\u5230\u4EA7\u54C1\u4FE1\u606F");
|
|
21550
|
+
}
|
|
21551
|
+
if (!devInfo) {
|
|
21552
|
+
return {
|
|
21553
|
+
data: null,
|
|
21554
|
+
errorCode: import_TYUniCode.TYUniPluginError.DEVICEKIT_DEVICE_ID_INVALID.code,
|
|
21555
|
+
errorMsg: import_TYUniCode.TYUniPluginError.DEVICEKIT_DEVICE_ID_INVALID.des
|
|
21556
|
+
};
|
|
21557
|
+
}
|
|
21558
|
+
const { dps, schema } = devInfo;
|
|
21559
|
+
const objSchema = {};
|
|
21560
|
+
JSON.parse(schema).map((item) => {
|
|
21561
|
+
const { id, code, property } = item;
|
|
21562
|
+
const { type } = property || {};
|
|
21563
|
+
if (Object.keys(dps).includes(`${id}`) && type === "raw") {
|
|
21564
|
+
const b = Buffer.from(dps[id], "base64");
|
|
21565
|
+
dps[id] = b.toString("hex");
|
|
21566
|
+
}
|
|
21567
|
+
objSchema[code] = dps[id];
|
|
21568
|
+
});
|
|
21569
|
+
deviceInfo = {
|
|
21570
|
+
...devInfo,
|
|
21571
|
+
dps,
|
|
21572
|
+
dpCodes: objSchema,
|
|
21573
|
+
deviceOnline: devInfo.isOnline,
|
|
21574
|
+
icon: devInfo.iconUrl,
|
|
21575
|
+
schema: JSON.parse(devInfo.schema),
|
|
21576
|
+
capability: product.capability
|
|
21577
|
+
};
|
|
21578
|
+
return {
|
|
21579
|
+
data: deviceInfo,
|
|
21580
|
+
errorCode: 0,
|
|
21581
|
+
errorMsg: import_TYUniCode.TYUniPluginError.SUCCESS.des
|
|
21582
|
+
};
|
|
21583
|
+
}
|
|
21584
|
+
async function publishDps2(params) {
|
|
21585
|
+
const { deviceId, dps } = params;
|
|
21586
|
+
const { schema } = deviceInfo || {};
|
|
21587
|
+
schema.map((item) => {
|
|
21588
|
+
const { id, code, property } = item;
|
|
21589
|
+
const { type } = property || {};
|
|
21590
|
+
if (Object.keys(dps).includes(`${id}`) && type === "raw") {
|
|
21591
|
+
const b = Buffer.from(dps[id], "hex");
|
|
21592
|
+
dps[id] = b.toString("base64");
|
|
21593
|
+
}
|
|
21594
|
+
});
|
|
21595
|
+
try {
|
|
21596
|
+
await publishDps({ deviceId, dps });
|
|
21597
|
+
ark.runtime.sendMessage(JSON.stringify({
|
|
21598
|
+
type: "mqtt",
|
|
21599
|
+
value: dps
|
|
21600
|
+
}));
|
|
21601
|
+
return {
|
|
21602
|
+
errorCode: 0,
|
|
21603
|
+
errorMsg: import_TYUniCode.TYUniPluginError.SUCCESS.des,
|
|
21604
|
+
data: null
|
|
21605
|
+
};
|
|
21606
|
+
} catch (e) {
|
|
21607
|
+
return {
|
|
21608
|
+
errorCode: import_TYUniCode.TYUniPluginError.DEVICEKIT_PUBLISH_DPS_ERROR.code,
|
|
21609
|
+
errorMsg: import_TYUniCode.TYUniPluginError.DEVICEKIT_PUBLISH_DPS_ERROR.des,
|
|
21610
|
+
data: e
|
|
21611
|
+
};
|
|
21612
|
+
}
|
|
21613
|
+
}
|
|
21614
|
+
async function getProductInfo2(params) {
|
|
21615
|
+
try {
|
|
21616
|
+
const productInfo = await getProductInfo({
|
|
21617
|
+
productIds: [params.productId]
|
|
21618
|
+
});
|
|
21619
|
+
return {
|
|
21620
|
+
data: productInfo.result[0],
|
|
21621
|
+
errorCode: !!productInfo ? 0 : import_TYUniCode.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.code,
|
|
21622
|
+
errorMsg: !!productInfo ? import_TYUniCode.TYUniPluginError.SUCCESS.des : import_TYUniCode.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.des
|
|
21623
|
+
};
|
|
21624
|
+
} catch (e) {
|
|
21625
|
+
return {
|
|
21626
|
+
data: null,
|
|
21627
|
+
errorCode: import_TYUniCode.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.code,
|
|
21628
|
+
errorMsg: import_TYUniCode.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.des
|
|
21629
|
+
};
|
|
21630
|
+
}
|
|
21631
|
+
}
|
|
21632
|
+
async function queryDps2(params) {
|
|
21633
|
+
try {
|
|
21634
|
+
const dps = await queryDps(params);
|
|
21635
|
+
return {
|
|
21636
|
+
data: dps,
|
|
21637
|
+
errorCode: !!dps ? 0 : import_TYUniCode.TYUniPluginError.DEVICEKIT_QUERY_DPS_ERROR.code,
|
|
21638
|
+
errorMsg: !!dps ? import_TYUniCode.TYUniPluginError.SUCCESS.des : import_TYUniCode.TYUniPluginError.DEVICEKIT_QUERY_DPS_ERROR.des
|
|
21639
|
+
};
|
|
21640
|
+
} catch (e) {
|
|
21641
|
+
return {
|
|
21642
|
+
data: null,
|
|
21643
|
+
errorCode: import_TYUniCode.TYUniPluginError.DEVICEKIT_QUERY_DPS_ERROR.code,
|
|
21644
|
+
errorMsg: import_TYUniCode.TYUniPluginError.DEVICEKIT_QUERY_DPS_ERROR.des
|
|
21645
|
+
};
|
|
21646
|
+
}
|
|
21647
|
+
}
|
|
21648
|
+
function registerDeviceListListener(params) {
|
|
21649
|
+
return {
|
|
21650
|
+
data: null,
|
|
21651
|
+
errorCode: 0,
|
|
21652
|
+
errorMsg: import_TYUniCode.TYUniPluginError.SUCCESS.des
|
|
21653
|
+
};
|
|
21654
|
+
}
|
|
21655
|
+
function unregisterDeviceListListener(params) {
|
|
21656
|
+
return {
|
|
21657
|
+
data: null,
|
|
21658
|
+
errorCode: 0,
|
|
21659
|
+
errorMsg: import_TYUniCode.TYUniPluginError.SUCCESS.des
|
|
21660
|
+
};
|
|
21661
|
+
}
|
|
21662
|
+
ark.miniapp.addPluginMethod("TYUniDeviceControlManager", "getDeviceInfo", getDeviceInfo2);
|
|
21663
|
+
ark.miniapp.addPluginMethod("TYUniDeviceControlManager", "getProductInfo", getProductInfo2);
|
|
21664
|
+
ark.miniapp.addPluginMethod("TYUniDeviceControlManager", "publishDps", publishDps2);
|
|
21665
|
+
ark.miniapp.addPluginMethod("TYUniDeviceControlManager", "queryDps", queryDps2);
|
|
21666
|
+
ark.miniapp.addPluginMethod("TYUniDeviceControlManager", "registerDeviceListListener", registerDeviceListListener);
|
|
21667
|
+
ark.miniapp.addPluginMethod("TYUniDeviceControlManager", "unregisterDeviceListListener", unregisterDeviceListListener);
|
|
21668
|
+
|
|
21500
21669
|
// worker/api/services/publishDps.ts
|
|
21501
21670
|
var publishDps = async ({ deviceId, dps }) => {
|
|
21502
21671
|
const manager = DpMqttManager.getInstance();
|
|
@@ -21529,6 +21698,15 @@ var publishDps = async ({ deviceId, dps }) => {
|
|
|
21529
21698
|
const message = JSON.stringify(upData);
|
|
21530
21699
|
console.log("publish", outTopic, message);
|
|
21531
21700
|
client.publish(outTopic, message, () => {
|
|
21701
|
+
const { schema = {} } = deviceInfo || {};
|
|
21702
|
+
schema.map((item) => {
|
|
21703
|
+
const { id, property } = item;
|
|
21704
|
+
const { type } = property || {};
|
|
21705
|
+
if (Object.keys(dps).includes(`${id}`) && type === "raw") {
|
|
21706
|
+
const b = Buffer.from(dps[id], "base64");
|
|
21707
|
+
dps[id] = b.toString("hex");
|
|
21708
|
+
}
|
|
21709
|
+
});
|
|
21532
21710
|
ark.miniapp.emitPluginEvent({
|
|
21533
21711
|
name: "TYUniDeviceControlManager.onDpDataChange",
|
|
21534
21712
|
data: {
|
|
@@ -21542,17 +21720,6 @@ var publishDps = async ({ deviceId, dps }) => {
|
|
|
21542
21720
|
}
|
|
21543
21721
|
};
|
|
21544
21722
|
|
|
21545
|
-
// worker/api/services/queryDps.ts
|
|
21546
|
-
var queryDps = async ({ deviceId, dpIds }) => {
|
|
21547
|
-
const deviceInfo2 = await getDeviceInfo({ "deviceId": deviceId });
|
|
21548
|
-
const dps = deviceInfo2?.result?.dps || {};
|
|
21549
|
-
const result = {};
|
|
21550
|
-
for (const dpId of dpIds) {
|
|
21551
|
-
result[dpId] = dps[dpId];
|
|
21552
|
-
}
|
|
21553
|
-
return result;
|
|
21554
|
-
};
|
|
21555
|
-
|
|
21556
21723
|
// worker/api/services/saveProjectInfo.ts
|
|
21557
21724
|
var saveProjectInfo = async ({ deviceId, productId }) => {
|
|
21558
21725
|
await ark.storage.set(productId, JSON.stringify({
|
|
@@ -21566,7 +21733,20 @@ var saveProjectInfo = async ({ deviceId, productId }) => {
|
|
|
21566
21733
|
return { ...JSON.parse(res1), ...JSON.parse(res2) };
|
|
21567
21734
|
};
|
|
21568
21735
|
|
|
21569
|
-
// worker/api/services/
|
|
21736
|
+
// worker/api/services/mockDeviceStatus.ts
|
|
21737
|
+
var bluetoothIsOn = true;
|
|
21738
|
+
var onlineStatus = {
|
|
21739
|
+
online: true,
|
|
21740
|
+
deviceId: "",
|
|
21741
|
+
onlineType: 1
|
|
21742
|
+
};
|
|
21743
|
+
function emitDeviceOnlineState(params) {
|
|
21744
|
+
console.log("--------emitDeviceOnlineState", params);
|
|
21745
|
+
ark.miniapp.emitPluginEvent({
|
|
21746
|
+
name: "TYUniDeviceControlManager.onDeviceOnlineStatusUpdate",
|
|
21747
|
+
data: { ...onlineStatus, ...params }
|
|
21748
|
+
});
|
|
21749
|
+
}
|
|
21570
21750
|
var networkState = {
|
|
21571
21751
|
networkType: "WIFI",
|
|
21572
21752
|
signalStrength: 100,
|
|
@@ -21586,6 +21766,31 @@ function emitNetworkState(params) {
|
|
|
21586
21766
|
data: { ...networkState, ...params }
|
|
21587
21767
|
});
|
|
21588
21768
|
}
|
|
21769
|
+
var bluetoothState = {
|
|
21770
|
+
available: true
|
|
21771
|
+
};
|
|
21772
|
+
function emitBluetoothState(params) {
|
|
21773
|
+
bluetoothIsOn = params.available;
|
|
21774
|
+
ark.miniapp.emitPluginEvent({
|
|
21775
|
+
name: "TYUniPhoneBluetoothManager.bluetoothAdapterStateChange",
|
|
21776
|
+
data: { ...bluetoothState, ...params }
|
|
21777
|
+
});
|
|
21778
|
+
}
|
|
21779
|
+
var bleConnectStatus = {
|
|
21780
|
+
status: "CONNECTED"
|
|
21781
|
+
};
|
|
21782
|
+
function emitBleConnectStatus(params) {
|
|
21783
|
+
ark.miniapp.emitPluginEvent({
|
|
21784
|
+
name: "TYUniBluetoothManager.onTYBLEConnectStatusChange",
|
|
21785
|
+
data: { ...bleConnectStatus, ...params }
|
|
21786
|
+
});
|
|
21787
|
+
}
|
|
21788
|
+
function emitDarkState(params) {
|
|
21789
|
+
ark.miniapp.emitPluginEvent({
|
|
21790
|
+
name: "App.onThemeChange",
|
|
21791
|
+
data: { ...params }
|
|
21792
|
+
});
|
|
21793
|
+
}
|
|
21589
21794
|
|
|
21590
21795
|
// worker/utils/mqtt.ts
|
|
21591
21796
|
var DpMqttManager = class {
|
|
@@ -21675,6 +21880,15 @@ var startMQTT = async ({ productId }) => {
|
|
|
21675
21880
|
});
|
|
21676
21881
|
break;
|
|
21677
21882
|
case 5:
|
|
21883
|
+
const { schema = {} } = deviceInfo || {};
|
|
21884
|
+
schema.map((item) => {
|
|
21885
|
+
const { id, property } = item;
|
|
21886
|
+
const { type } = property || {};
|
|
21887
|
+
if (Object.keys(dps).includes(`${id}`) && type === "raw") {
|
|
21888
|
+
const b = Buffer.from(dps[id], "base64");
|
|
21889
|
+
dps[id] = b.toString("hex");
|
|
21890
|
+
}
|
|
21891
|
+
});
|
|
21678
21892
|
ark.miniapp.emitPluginEvent({
|
|
21679
21893
|
name: "TYUniDeviceControlManager.onDpDataChange",
|
|
21680
21894
|
data: {
|
|
@@ -21720,106 +21934,6 @@ var isJSON = (str) => {
|
|
|
21720
21934
|
}
|
|
21721
21935
|
};
|
|
21722
21936
|
|
|
21723
|
-
// worker/api/TYUniDeviceControlManager.ts
|
|
21724
|
-
var import_TYUniCode = __toESM(require_dist());
|
|
21725
|
-
var deviceInfo = null;
|
|
21726
|
-
async function getDeviceInfo2(params) {
|
|
21727
|
-
const { deviceId } = params;
|
|
21728
|
-
if (!deviceId) {
|
|
21729
|
-
return {
|
|
21730
|
-
data: null,
|
|
21731
|
-
errorCode: import_TYUniCode.TYUniPluginError.DEVICEKIT_DEVICE_ID_INVALID.code,
|
|
21732
|
-
errorMsg: import_TYUniCode.TYUniPluginError.DEVICEKIT_DEVICE_ID_INVALID.des
|
|
21733
|
-
};
|
|
21734
|
-
}
|
|
21735
|
-
const response = await getDeviceInfo({ deviceId });
|
|
21736
|
-
const { result: devInfo } = response || {};
|
|
21737
|
-
let product = {};
|
|
21738
|
-
try {
|
|
21739
|
-
const presponse = await getProductInfo({ productIds: [devInfo.productId] });
|
|
21740
|
-
const { result: productInfo } = presponse || {};
|
|
21741
|
-
product = productInfo[0] || {};
|
|
21742
|
-
} catch (e) {
|
|
21743
|
-
console.log("\u672A\u83B7\u53D6\u5230\u4EA7\u54C1\u4FE1\u606F");
|
|
21744
|
-
}
|
|
21745
|
-
if (!devInfo) {
|
|
21746
|
-
return {
|
|
21747
|
-
data: null,
|
|
21748
|
-
errorCode: import_TYUniCode.TYUniPluginError.DEVICEKIT_DEVICE_ID_INVALID.code,
|
|
21749
|
-
errorMsg: import_TYUniCode.TYUniPluginError.DEVICEKIT_DEVICE_ID_INVALID.des
|
|
21750
|
-
};
|
|
21751
|
-
}
|
|
21752
|
-
deviceInfo = {
|
|
21753
|
-
...devInfo,
|
|
21754
|
-
deviceOnline: devInfo.isOnline,
|
|
21755
|
-
icon: devInfo.iconUrl,
|
|
21756
|
-
schema: JSON.parse(devInfo.schema),
|
|
21757
|
-
capability: product.capability
|
|
21758
|
-
};
|
|
21759
|
-
return {
|
|
21760
|
-
data: deviceInfo,
|
|
21761
|
-
errorCode: 0,
|
|
21762
|
-
errorMsg: import_TYUniCode.TYUniPluginError.SUCCESS.des
|
|
21763
|
-
};
|
|
21764
|
-
}
|
|
21765
|
-
async function publishDps2(params) {
|
|
21766
|
-
const { deviceId, dps } = params;
|
|
21767
|
-
try {
|
|
21768
|
-
await publishDps({ deviceId, dps });
|
|
21769
|
-
ark.runtime.sendMessage(JSON.stringify({
|
|
21770
|
-
type: "mqtt",
|
|
21771
|
-
value: dps
|
|
21772
|
-
}));
|
|
21773
|
-
return {
|
|
21774
|
-
errorCode: 0,
|
|
21775
|
-
errorMsg: import_TYUniCode.TYUniPluginError.SUCCESS.des,
|
|
21776
|
-
data: null
|
|
21777
|
-
};
|
|
21778
|
-
} catch (e) {
|
|
21779
|
-
return {
|
|
21780
|
-
errorCode: import_TYUniCode.TYUniPluginError.DEVICEKIT_PUBLISH_DPS_ERROR.code,
|
|
21781
|
-
errorMsg: import_TYUniCode.TYUniPluginError.DEVICEKIT_PUBLISH_DPS_ERROR.des,
|
|
21782
|
-
data: e
|
|
21783
|
-
};
|
|
21784
|
-
}
|
|
21785
|
-
}
|
|
21786
|
-
async function getProductInfo2(params) {
|
|
21787
|
-
try {
|
|
21788
|
-
const productInfo = await getProductInfo({ productIds: [params.productId] });
|
|
21789
|
-
return {
|
|
21790
|
-
data: productInfo.result[0],
|
|
21791
|
-
errorCode: !!productInfo ? 0 : import_TYUniCode.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.code,
|
|
21792
|
-
errorMsg: !!productInfo ? import_TYUniCode.TYUniPluginError.SUCCESS.des : import_TYUniCode.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.des
|
|
21793
|
-
};
|
|
21794
|
-
} catch (e) {
|
|
21795
|
-
return {
|
|
21796
|
-
data: null,
|
|
21797
|
-
errorCode: import_TYUniCode.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.code,
|
|
21798
|
-
errorMsg: import_TYUniCode.TYUniPluginError.DEVICEKIT_PRODUCT_ID_INVALID.des
|
|
21799
|
-
};
|
|
21800
|
-
}
|
|
21801
|
-
}
|
|
21802
|
-
async function queryDps2(params) {
|
|
21803
|
-
try {
|
|
21804
|
-
const dps = await queryDps(params);
|
|
21805
|
-
return {
|
|
21806
|
-
data: dps,
|
|
21807
|
-
errorCode: !!dps ? 0 : import_TYUniCode.TYUniPluginError.DEVICEKIT_QUERY_DPS_ERROR.code,
|
|
21808
|
-
errorMsg: !!dps ? import_TYUniCode.TYUniPluginError.SUCCESS.des : import_TYUniCode.TYUniPluginError.DEVICEKIT_QUERY_DPS_ERROR.des
|
|
21809
|
-
};
|
|
21810
|
-
} catch (e) {
|
|
21811
|
-
return {
|
|
21812
|
-
data: null,
|
|
21813
|
-
errorCode: import_TYUniCode.TYUniPluginError.DEVICEKIT_QUERY_DPS_ERROR.code,
|
|
21814
|
-
errorMsg: import_TYUniCode.TYUniPluginError.DEVICEKIT_QUERY_DPS_ERROR.des
|
|
21815
|
-
};
|
|
21816
|
-
}
|
|
21817
|
-
}
|
|
21818
|
-
ark.miniapp.addPluginMethod("TYUniDeviceControlManager", "getDeviceInfo", getDeviceInfo2);
|
|
21819
|
-
ark.miniapp.addPluginMethod("TYUniDeviceControlManager", "getProductInfo", getProductInfo2);
|
|
21820
|
-
ark.miniapp.addPluginMethod("TYUniDeviceControlManager", "publishDps", publishDps2);
|
|
21821
|
-
ark.miniapp.addPluginMethod("TYUniDeviceControlManager", "queryDps", queryDps2);
|
|
21822
|
-
|
|
21823
21937
|
// worker/api/TYUniLocalizationManager.ts
|
|
21824
21938
|
var import_lodash = __toESM(require_lodash());
|
|
21825
21939
|
function getLangKey(params) {
|
|
@@ -21920,16 +22034,106 @@ function onBluetoothAdapterStateChange(listener) {
|
|
|
21920
22034
|
data: listener
|
|
21921
22035
|
};
|
|
21922
22036
|
}
|
|
22037
|
+
function offBluetoothAdapterStateChange(listener) {
|
|
22038
|
+
return {
|
|
22039
|
+
errorCode: 0,
|
|
22040
|
+
errorMsg: import_TYUniCode3.TYUniPluginError.SUCCESS.des,
|
|
22041
|
+
data: listener
|
|
22042
|
+
};
|
|
22043
|
+
}
|
|
21923
22044
|
function bluetoothIsPowerOn(params) {
|
|
21924
22045
|
return {
|
|
21925
|
-
data:
|
|
22046
|
+
data: bluetoothIsOn,
|
|
21926
22047
|
errorCode: 0,
|
|
21927
22048
|
errorMsg: import_TYUniCode3.TYUniPluginError.SUCCESS.des
|
|
21928
22049
|
};
|
|
21929
22050
|
}
|
|
21930
22051
|
ark.miniapp.addPluginMethod("TYUniPhoneBluetoothManager", "onBluetoothAdapterStateChange", onBluetoothAdapterStateChange);
|
|
22052
|
+
ark.miniapp.addPluginMethod("TYUniPhoneBluetoothManager", "offBluetoothAdapterStateChange", offBluetoothAdapterStateChange);
|
|
21931
22053
|
ark.miniapp.addPluginMethod("TYUniBluetoothManager", "bluetoothIsPowerOn", bluetoothIsPowerOn);
|
|
21932
22054
|
|
|
22055
|
+
// worker/api/TYUniOTAManager.ts
|
|
22056
|
+
var import_TYUniCode4 = __toESM(require_dist());
|
|
22057
|
+
async function connectTYBLEDevice(params) {
|
|
22058
|
+
return {
|
|
22059
|
+
data: { status: 0 },
|
|
22060
|
+
errorCode: 0,
|
|
22061
|
+
errorMsg: import_TYUniCode4.TYUniPluginError.SUCCESS.des
|
|
22062
|
+
};
|
|
22063
|
+
}
|
|
22064
|
+
ark.miniapp.addPluginMethod("TYUniBluetoothManager", "connectTYBLEDevice", connectTYBLEDevice);
|
|
22065
|
+
|
|
22066
|
+
// worker/api/TYUniBluetoothManager.ts
|
|
22067
|
+
var import_TYUniCode5 = __toESM(require_dist());
|
|
22068
|
+
async function onTYBLEConnectStatusChange(listener) {
|
|
22069
|
+
return {
|
|
22070
|
+
errorCode: 0,
|
|
22071
|
+
errorMsg: import_TYUniCode5.TYUniPluginError.SUCCESS.des,
|
|
22072
|
+
data: listener
|
|
22073
|
+
};
|
|
22074
|
+
}
|
|
22075
|
+
async function offTYBLEConnectStatusChange(listener) {
|
|
22076
|
+
return {
|
|
22077
|
+
errorCode: 0,
|
|
22078
|
+
errorMsg: import_TYUniCode5.TYUniPluginError.SUCCESS.des,
|
|
22079
|
+
data: listener
|
|
22080
|
+
};
|
|
22081
|
+
}
|
|
22082
|
+
function subscribeTYBLEConnectStatus(params) {
|
|
22083
|
+
return {
|
|
22084
|
+
errorCode: 0,
|
|
22085
|
+
errorMsg: import_TYUniCode5.TYUniPluginError.SUCCESS.des,
|
|
22086
|
+
data: null
|
|
22087
|
+
};
|
|
22088
|
+
}
|
|
22089
|
+
function unsubscribeTYBLEConnectStatus(params) {
|
|
22090
|
+
return {
|
|
22091
|
+
errorCode: 0,
|
|
22092
|
+
errorMsg: import_TYUniCode5.TYUniPluginError.SUCCESS.des,
|
|
22093
|
+
data: null
|
|
22094
|
+
};
|
|
22095
|
+
}
|
|
22096
|
+
ark.miniapp.addPluginMethod("TYUniOTAManager", "onTYBLEConnectStatusChange", onTYBLEConnectStatusChange);
|
|
22097
|
+
ark.miniapp.addPluginMethod("TYUniOTAManager", "offTYBLEConnectStatusChange", offTYBLEConnectStatusChange);
|
|
22098
|
+
ark.miniapp.addPluginMethod("TYUniOTAManager", "subscribeTYBLEConnectStatus", subscribeTYBLEConnectStatus);
|
|
22099
|
+
ark.miniapp.addPluginMethod("TYUniOTAManager", "unsubscribeTYBLEConnectStatus", unsubscribeTYBLEConnectStatus);
|
|
22100
|
+
|
|
22101
|
+
// worker/api/TYUniGroupControlManager.ts
|
|
22102
|
+
var import_TYUniCode6 = __toESM(require_dist());
|
|
22103
|
+
function registerGroupChange(params) {
|
|
22104
|
+
return {
|
|
22105
|
+
errorCode: 0,
|
|
22106
|
+
errorMsg: import_TYUniCode6.TYUniPluginError.SUCCESS.des,
|
|
22107
|
+
data: null
|
|
22108
|
+
};
|
|
22109
|
+
}
|
|
22110
|
+
function unRegisterGroupChange(params) {
|
|
22111
|
+
return {
|
|
22112
|
+
errorCode: 0,
|
|
22113
|
+
errorMsg: import_TYUniCode6.TYUniPluginError.SUCCESS.des,
|
|
22114
|
+
data: null
|
|
22115
|
+
};
|
|
22116
|
+
}
|
|
22117
|
+
async function getGroupInfo(params) {
|
|
22118
|
+
const { groupId } = params;
|
|
22119
|
+
const response = await apiRequestByAtop({
|
|
22120
|
+
api: "tuya.m.device.group.get",
|
|
22121
|
+
version: "2.0",
|
|
22122
|
+
params: {
|
|
22123
|
+
id: groupId
|
|
22124
|
+
}
|
|
22125
|
+
});
|
|
22126
|
+
console.log("getGroupInfo------", response);
|
|
22127
|
+
return {
|
|
22128
|
+
errorCode: 0,
|
|
22129
|
+
errorMsg: import_TYUniCode6.TYUniPluginError.SUCCESS.des,
|
|
22130
|
+
data: response?.result
|
|
22131
|
+
};
|
|
22132
|
+
}
|
|
22133
|
+
ark.miniapp.addPluginMethod("TYUniGroupControlManager", "registerGroupChange", registerGroupChange);
|
|
22134
|
+
ark.miniapp.addPluginMethod("TYUniGroupControlManager", "unRegisterGroupChange", unRegisterGroupChange);
|
|
22135
|
+
ark.miniapp.addPluginMethod("TYUniGroupControlManager", "getGroupInfo", getGroupInfo);
|
|
22136
|
+
|
|
21933
22137
|
// worker/index.ts
|
|
21934
22138
|
console.log("ServicesMap", services_default);
|
|
21935
22139
|
ark.runtime.onMessage(async (event) => {
|