|
发表于 2025-1-7 23:41:16
|
显示全部楼层
const GATEWAY = {
api: 'http://192.168.1.204/route.cgi?api=request', // 可以改成网关内网ip
id: 'xxxx', // 网关查看:本地iot账号
userId: 'xxxx', // 网关查看:远程iot账号
authUsername: 'admin',
authPassword: 123456,
};
function b64EncodeUnicode(str) {
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
function(match, p1) {
return String.fromCharCode('0x' + p1);
}));
}
fetch(GATEWAY.api, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'authorization': 'Basic ' + b64EncodeUnicode(GATEWAY.authUsername + ':' + GATEWAY.authPassword)
},
body: JSON.stringify({
"fromDev": GATEWAY.userId,
"toDev": GATEWAY.id,
"data": {
"cmd": "on", // 取值看https://github.com/dnakeyun/DNKS ... ders/SDKInterface.h
"action": "ctrlDev",
"devNo":21, // 即deviceNum
"devCh":2, // 即设备deviceChannel
"uuid": "需抓包设备列表" // on用deviceUid off用devicePuid
}
})}
);
// 安装i尚家登录并抓包
// iot信息,使用alibabacloud-iot-device-sdk可以控制
https://smart.ishanghome.com/smartHome/v1/account/login
// 设备列表
https://smart.ishanghome.com/sma ... teway/list?mac=xxxx
我这里是很老的网关,进度很艰难,如果有楼主的网关会方便很多。 |
|