we100 前期准备

master
blak-kong 2 years ago
parent 51051e6bfb
commit 63a28dba21

@ -79,7 +79,7 @@ export default defineAppConfig({
subPackages: [
{
root: "moduleIOT",
pages: ["pages/iotCarePlan/WL200", "pages/iotCarePlan/FR200", "pages/iotCarePlan/WE200",],
pages: ["pages/iotCarePlan/WL200", "pages/iotCarePlan/FR200", "pages/iotCarePlan/WE100",],
},
{
root: "recoding",

@ -41,6 +41,9 @@ export const fr200DeviceControlCommand = {
queryDeviceStatus: {
commandType: "DeviceStatusSync",
deviceSyncCommandType: "onlySyncStatusToDevice",
// totalWorkingSeconds: 55,
// workStatus: "working",
// workMode: 'eyes',
},
/**控制设备暂停 pause暂停 working启动 end关闭*/
pause: {

@ -0,0 +1,183 @@
/**蓝牙命令合集*/
export const WE100BleCommand = {
/**发送配对码*/
match: {
commandType: "BleMatch",
bleCommandType: "SendMatchCode",
},
/**查询附属设备的配对状态*/
querySubDevice: {
commandType: "BleMatch",
bleCommandType: "QueryMatchStatus",
},
// 查询信息
InfoQuery: {
/**查询版本指令*/
versionInfo: {
commandType: "InfoQuery",
infoQueryType: "versionInfo",
otaDeviceType: "WE100",
},
/**时间同步*/
timeSync: {
commandType: "InfoQuery",
infoQueryType: "timeSync",
date: new Date(),
},
/** 查询 面膜自定义模式信息 */
facialMaskCustomModeInfo: {
commandType: "InfoQuery",
infoQueryType: "facialMaskCustomModeInfo",
},
/**
* @name 查询并设置自定义电流配方模式面膜模式
* @description 部位只是执行顺序所有部位共用三种模式 Pulling(提拉) Moisturize(滋润) Mix(混合)
* */
facialMaskCustomModeSet: {
commandType: "InfoQuery",
infoQueryType: "facialMaskCustomModeSet",
feelingTakeEffectOffline: true,
partitionConfigArray: [
{
feelingType: "Pulling",
pullingSeconds: 1.05,
moisturizeSeconds: 2.25,
},
{
feelingType: "Mix",
pullingSeconds: 1.05,
moisturizeSeconds: 2.25,
},
{
feelingType: "Mix",
pullingSeconds: 1.05,
moisturizeSeconds: 2.25,
},
{
feelingType: "Moisturize",
pullingSeconds: 1.15,
moisturizeSeconds: 0.25,
},
],
neededTotalSeconds: 900, // 设置工作时间
},
/** 离线汇总 */
offlineSummary: {
commandType: "InfoQuery",
infoQueryType: "offlineClockSummary",
},
/** 离线详情 */
offlineDetail: {
commandType: "InfoQuery",
infoQueryType: "offlineClockDetail",
dataIndex: 0,
},
/** 现在的面膜报告信息 */
currentFacialReportInfo: {
commandType: "InfoQuery",
infoQueryType: "currentFacialReportInfo",
},
/** 查询M02自定义面膜信息 */
m02MaskCustomModeInfo: {
commandType: "InfoQuery",
infoQueryType: "m02MaskCustomModeInfo",
workMode: "PreMakeup_Custom",
},
/** 查询并设置:眼雕大师自定义、妆前急救自定义面膜模式 */
m02MaskCustomModeSet: {
commandType: "InfoQuery",
infoQueryType: "m02MaskCustomModeSet",
workMode: "EyeCarving_Custom",
feelingTakeEffectOffline: "OnlyAffectOnce",
partitionConfigArray: [
{
feelingType: ["Moisturize", "EyeSculpt"],
pullingSeconds: 0.05,
moisturizeSeconds: 1.15,
eyeSculptSeconds: 6,
},
{
feelingType: ["Moisturize", "EyeSculpt"],
pullingSeconds: 0,
moisturizeSeconds: 1.15,
eyeSculptSeconds: 6,
},
{
feelingType: ["Pulling", "Moisturize"],
pullingSeconds: 1,
moisturizeSeconds: 2,
eyeSculptSeconds: 0,
},
],
neededTotalSeconds: 900, // 设置工作时间
},
},
};
/**控制设备命令合集*/
export const WE100DeviceControlCommand = {
/**控制设备暂停 pause暂停 working启动 end关闭*/
// '水光精华模式分区档位0-3-2-5离线生效' = 'workByPatitionSet',
// '自定义电流配方模式运行档位1-3-2-2离线不生效' = 'workCustom',
// '控制设备暂停' = 'pause',
// '控制设备继续工作' = 'working',
// '发送APP状态使设备同步-工作时间55秒' = 'onlySyncStatusToDevice',
// '主动查询设备的状态' = 'queryDeviceStatus',
// // m02
// '状前模式运行档位1-3-2档位离线不生效' = 'm02work1',
// '眼雕电流配方模式运行档位1-3-2档位离线生效' = 'm02workCustom2',
// standby: {
// commandType: "DeviceControl",
// workStatus: "standby",
// },
work: {
commandType: "DeviceControl",
workStatus: "working",
},
pause: {
commandType: "DeviceControl",
workStatus: "pause",
},
end: {
commandType: "DeviceControl",
workStatus: "end",
},
working2: { ...working, neededTotalSeconds: 600 }, // 设置工作十分钟
/**
* M01膜布
* WaterLightEssence: 水光精华模式
* ShapeBeautyEssence: 塑颜精华模式
* DiyFacial DIY面膜模式
* ShapeBeautyEssence_Custom 自定义电流配方模式
*
* M02膜布
* EyeCarving_Custom: 眼雕大师配方模式
* PreMakeup_Custom: 妆前急救模式
*/
// 设置工作模式
workByPatitionSet: {
commandType: "DeviceControl",
workStatus: "working",
workMode: "WaterLightEssence", // 工作模式
gearTakeEffectOffline: true, // 是否离线生效
partitionStatus: [{ gear: 0 }, { gear: 3 }, { gear: 2 }, { gear: 5 }], // 0-3-2-5挡位是官配电流模式自定义时可修改?
},
// 发送APP状态使设备同步
onlySyncStatusToDevice: {
commandType: "DeviceStatusSync",
deviceSyncCommandType: "onlySyncStatusToDevice",
totalWorkingSeconds: 55, // 同步工作时间?
workStatus: "working", // 工作状态,与程序同步
workMode: "ShapeBeautyEssence", // 模式,与程序同步
partitionStatus: [{ gear: 0 }, { gear: 3 }, { gear: 2 }, { gear: 5 }], // 挡位,与程序同步,非自定义模式或许可以不传
},
};

@ -1,100 +0,0 @@
/**蓝牙命令合集*/
export const we200BleCommand = {
/**发送配对码*/
match: {
commandType: "BleMatch",
bleCommandType: "SendMatchCode",
},
InfoQuery: {
/**查询版本指令*/
versionInfo: {
commandType: "InfoQuery",
infoQueryType: "versionInfo",
otaDeviceType: "FR200",
},
/**时间同步*/
timeSync: {
commandType: "InfoQuery",
infoQueryType: "timeSync",
date: new Date(),
},
/**查询离线记录概要*/
clockSummary: {
commandType: "InfoQuery",
infoQueryType: "offlineClockInInfo",
dataType: "summary",
},
/**查询离线明细第一条*/
clockDetail: {
commandType: "InfoQuery",
infoQueryType: "offlineClockInInfo",
dataType: "detail",
dataIndex: 0,
},
},
};
/**控制设备命令合集*/
export const we200DeviceControlCommand = {
/**查询设备状态指令*/
queryDeviceStatus: {
commandType: "DeviceStatusSync",
deviceSyncCommandType: "onlySyncStatusToDevice",
},
/**控制设备暂停 pause暂停 working启动 end关闭*/
pause: {
commandType: "DeviceControl",
workStatus: "pause",
},
standby: {
commandType: "DeviceControl",
workStatus: "standby",
},
end: {
commandType: "DeviceControl",
workStatus: "end",
},
/**
* '进入水分测试模式' = 'switchTestMode',
* '启动水分测试模式' = 'startTestMode',
*
* face: "01", 面部
* eyes: "02", 眼部
*
* nasolabialFold: "03", 法令纹Pro
* mandibularLine: "04", 下颌线Pro
* led: "05", led
* headLiftingPro: "09", 抬头纹Pro
*
* moistureTest: "06", 水分测试
* maskPenetration: "07",面膜促渗
* essence: "08", 精华模式
*
* neck: "0A", 颈纹
* partition: "11", 分区模式 废弃VM1001
* ignore: "255", 不改变/无模式
*/
// 普通工作模式
work: {
commandType: "DeviceControl",
workStatus: "working",
workMode: "ignore", // face
},
// 切换/进入水分测试
switchTestMode: {
commandType: "DeviceControl",
workStatus: "working",
workMode: "moistureTest",
testStatus: "standby",
},
// 启动水分测试
startTestMode: {
commandType: "DeviceControl",
workStatus: "working",
workMode: "moistureTest",
testStatus: "start",
},
};

@ -448,7 +448,7 @@ class IotCarePlanFR200 extends Component<any, any> {
const platform = Taro.getSystemInfoSync().platform;
if (platform !== "devtools") {
// 仅手机端初始化蓝牙
// this.init();
this.init();
}
}

@ -1,5 +0,0 @@
export default definePageConfig({
navigationBarTitleText: '首页',
enablePullDownRefresh: false,
enablePageMeta: true
})

@ -311,20 +311,6 @@ export default class BluetoothContainer {
if (this.counter < 3) {
/**
* 600
*/
const querySubDeviceArrayBuffer = this.deviceToolKitInstance.toBleCommand({
...bleCommandSamples.querySubDevice,
queryType: "WL200",
} as any);
setTimeout(() => {
console.log("发送查询附属设备指令 querySubDeviceArrayBuffer");
sendCommand({
value: querySubDeviceArrayBuffer,
});
}, 600);
/**
* 500
*/

@ -0,0 +1,418 @@
import Taro from "@tarojs/taro";
import { debounce } from "lodash";
import {
notifyBLECharacteristicValueChange,
sendCommand,
} from "@/utils/bluetoothWXAPI";
import {
WE100BleCommand,
WE100DeviceControlCommand,
} from "@/components/bluetoot/connection/we100";
/**
* @name
* @description
*/
export default class BluetoothContainer {
bluetoothInfo: any;
deviceToolKitInstance: any;
that: any;
counter: number = 0; // 初始化后,同步执行次数
constructor(bluetoothInfo: any, deviceToolKitInstance: any, that: any) {
this.bluetoothInfo = bluetoothInfo;
this.deviceToolKitInstance = deviceToolKitInstance;
this.that = that;
}
// 主动改变状态
public DeviceControl = {
/** @name 设置模式 */
workByPatitionSet: (workMode = '', gearTakeEffectOffline = false, partitionStatus = [{ gear: 0 }, { gear: 3 }, { gear: 2 }, { gear: 5 }]) => {
let sendParams: any = {
...WE100DeviceControlCommand.workByPatitionSet,
workMode: workMode, // 使用模式
gearTakeEffectOffline: gearTakeEffectOffline, // 是否离线生效
partitionStatus: partitionStatus // 默认用官配模式
};
const pauseArrayBuffer = this.deviceToolKitInstance.toBleCommand(
sendParams as any
);
sendCommand({
value: pauseArrayBuffer,
}).then(() => {
this.that.workStatus = 'pause';
this.that.resetTimer();
console.info(`发送暂停指令成功 参数为 =>`, sendParams);
});
},
/** @name 设备控制:准备 */
standby: (workMode = '') => {
let sendParams: any = {
...WE100DeviceControlCommand.pause,
workMode: workMode, // 使用模式
};
const pauseArrayBuffer = this.deviceToolKitInstance.toBleCommand(
sendParams as any
);
sendCommand({
value: pauseArrayBuffer,
}).then(() => {
this.that.workStatus = 'standby';
this.that.resetTimer();
console.info(`发送暂停指令成功 参数为 =>`, sendParams);
});
},
/** @name 设备控制:暂停 */
pause: (workMode = '') => {
let sendParams: any = {
...WE100DeviceControlCommand.pause,
workMode: workMode, // 使用模式
};
const pauseArrayBuffer = this.deviceToolKitInstance.toBleCommand(
sendParams as any
);
sendCommand({
value: pauseArrayBuffer,
}).then(() => {
this.that.workStatus = 'pause';
this.that.resetTimer();
console.info(`发送暂停指令成功 参数为 =>`, sendParams);
});
},
/** @name 设备控制:工作 */
working: (workMode = '') => {
let sendParams: any = {
...WE100DeviceControlCommand.pause,
workMode: workMode, // 使用模式
};
const pauseArrayBuffer = this.deviceToolKitInstance.toBleCommand(
sendParams as any
);
sendCommand({
value: pauseArrayBuffer,
}).then(() => {
this.that.workStatus = 'working';
this.that.resetTimer();
console.info(`发送工作指令成功 参数为 =>`, sendParams);
});
},
/** @name 设备控制:结束 */
end: (workMode = '') => {
let sendParams: any = {
...WE100DeviceControlCommand.pause,
workMode: workMode, // 使用模式
};
const pauseArrayBuffer = this.deviceToolKitInstance.toBleCommand(
sendParams as any
);
sendCommand({
value: pauseArrayBuffer,
}).then(() => {
this.that.workStatus = 'end';
this.that.resetTimer();
console.info(`发送结束指令成功 参数为 =>`, sendParams);
});
},
syncOfflineSummary: () => {
const queryOfflineSummary = this.deviceToolKitInstance.toBleCommand({
...WE100BleCommand.InfoQuery.offlineSummary
});
sendCommand({
value: queryOfflineSummary,
});
},
syncOfflineDetail: () => {
const queryOfflineDetail = this.deviceToolKitInstance.toBleCommand({
...WE100BleCommand.InfoQuery.offlineDetail
});
sendCommand({
value: queryOfflineDetail,
});
}
}
// 工作状态改变的相应
/** @name 设备响应:待机 */
private syncStandby(jsonStatus) {
console.log("上报待机", jsonStatus)
}
/** @name 设备响应:工作 */
private syncWorking(jsonStatus) {
console.log("上报工作", jsonStatus)
}
/** @name 设备响应:暂停 */
private syncPause(jsonStatus) {
console.log("上报暂停", jsonStatus)
}
/** @name 查询信息响应 */
private InfoQuery = {
/** @name 离线记录 */
syncOfflineClockSummary: function (jsonStatus) {
console.log("离线记录", jsonStatus);
},
/** @name 离线记录详情 */
syncOfflineClockDetail: function (jsonStatus) {
console.log("离线记录详情", jsonStatus);
},
/** @name 现在的面膜上报信息 */
syncCurrentFacialReportInfo: function (jsonStatus) {
console.log("现在的面膜上报信息", jsonStatus);
},
/** @name 查询响应:自定义电流配方模式面膜模式 */
syncFacialMaskCustomModeInfo: function (jsonStatus) {
console.log("查询响应:自定义电流配方模式面膜模式", jsonStatus);
},
/** @name 设置响应:自定义电流配方模式面膜模式 */
syncFacialMaskCustomModeSet: function (jsonStatus) {
console.log("设置响应:自定义电流配方模式面膜模式", jsonStatus);
},
/** @name 查询响应M02自定义面膜信息 */
syncM02MaskCustomModeInfo: function (jsonStatus) {
console.log("查询响应M02自定义面膜信息", jsonStatus);
},
/** @name 设置响应:眼雕大师自定义、妆前急救自定义面膜模式 */
syncM02MaskCustomModeSet: function (jsonStatus) {
console.log("设置响应:眼雕大师自定义、妆前急救自定义面膜模式", jsonStatus);
},
/** @name 版本信息 */
syncVersionInfo: function (jsonStatus) {
console.log("版本信息", jsonStatus);
},
/** @name 设备响应:时间同步 */
syncTimeSync: function (jsonStatus) {
console.log("时间同步", jsonStatus);
}
}
/** @name 设备响应:通用状态响应 */
private syncCommonStatus(jsonStatus) {
}
/** @name 设备响应:控制指令响应 */
private syncDeviceControl(jsonStatus) {
console.log("设备控制响应", jsonStatus);
if (jsonStatus.responseStatus == "OK") {
console.log("发送控制指令成功");
this.that.workJsonStatus = jsonStatus;
this.that.workStatus = jsonStatus.workStatus;
if (jsonStatus.battery) {
this.that.setState({
Electricity: jsonStatus.battery,
});
}
// 判断设备主动上报的关机事件
if (jsonStatus.workStatus === 'end') {
// 判断id是否一致, 一致的话则生成护理报表, 并提示
if (jsonStatus.id == this.that.WE200NursingHistory.id) {
debounce(
this.that.checkInstrumentRecord.bind(this, jsonStatus),
500
);
}
return;
}
if (jsonStatus?.workMode === this.that.state.ActiveModeItem?.modeType) {
this.that.setState({
workMode: jsonStatus?.workMode, // 仅当设备上报模式与小程序一致时,才允许改变小程序变量缓存
});
// 判断是否在isRuning(护理中)
// 仅当设备模式与小程序是否一致,才允许更改设备运行时间
if (
this.that.state.DeviceConnectStatus === 1 &&
this.that.isRuning &&
jsonStatus.workStatus !== 'end'
) {
this.that.updateDeviceSyncData(
{
totalWorkingMinutes: jsonStatus.totalWorkingMinutes,
totalWorkingSeconds: jsonStatus.totalWorkingSeconds,
},
jsonStatus
);
}
}
if (
jsonStatus.workMode === 'working' &&
this.that.isRuning
) {
const { ActiveModeItem } = this.that.state;
const item = ActiveModeItem;
if (jsonStatus.workMode !== item?.modeType) {
// clearTimeout(loadingTipsTimer);
this.that.setState({
isShowCountdown: false,
});
}
}
}
}
notifyBLECharacteristicValueChange() {
notifyBLECharacteristicValueChange({
deviceId: this.bluetoothInfo.deviceId,
servicesuuid: this.bluetoothInfo.servicesuuid,
characteristicsuuid1: this.bluetoothInfo.characteristicsuuid1,
characteristicsuuid0: this.bluetoothInfo.characteristicsuuid0,
}).then((res) => {
Taro.onBLECharacteristicValueChange((value) => {
const jsonStatus: any = this.deviceToolKitInstance.toJsonStatus(value.value);
console.log("onBLECharacteristicValueChange 订阅改变:", jsonStatus);
if (!jsonStatus || jsonStatus == null) {
return;
}
this.that.workStatus = jsonStatus.workStatus; // 记录工作状态
// end 和 endWork 都是护理结束, endWork不关机, end 关机, 对小程序而言处理流程都一样
if (jsonStatus.workStatus && jsonStatus.workStatus == "endWork") {
jsonStatus.workStatus = "end";
console.log(jsonStatus.workStatus, "护理结束");
}
switch (jsonStatus?.commandType) {
//设备配对和连接的返回
case "BleMatch":
// 蓝牙相关指令
this.that.switchBLEMatch(jsonStatus);
break;
//设备状态同步
case "DeviceStatusSync":
if (jsonStatus.battery) {
// 防止抖动
this.that.setState({
Electricity: jsonStatus.battery,
});
}
switch (jsonStatus.workStatus) {
case "standby":
//设备的待机状态 可能workMode字段为空
this.syncStandby(jsonStatus)
break;
case "pause":
this.syncPause(jsonStatus)
break;
case "working":
this.syncWorking(jsonStatus)
break;
default:
break;
}
this.syncCommonStatus(jsonStatus);
break;
//设备对控制指令的响应
case "DeviceControl":
this.syncDeviceControl(jsonStatus);
break;
// 设备对信息查询指令的响应
case "InfoQuery":
console.log("设备对信息查询指令的响应 InfoQuery", jsonStatus);
switch (jsonStatus.infoQueryType) {
// 离线记录
case "offlineClockSummary":
this.InfoQuery.syncOfflineClockSummary(jsonStatus)
break;
// 离线记录详情
case "offlineClockDetail":
this.InfoQuery.syncOfflineClockDetail(jsonStatus);
break;
// 现在的面膜报告信息
case "currentFacialReportInfo":
this.InfoQuery.syncCurrentFacialReportInfo(jsonStatus);
break;
// 查询:自定义电流配方模式面膜模式
case "facialMaskCustomModeInfo":
this.InfoQuery.syncFacialMaskCustomModeInfo(jsonStatus);
break;
// 设置:自定义电流配方模式面膜模式
case "facialMaskCustomModeSet":
this.InfoQuery.syncFacialMaskCustomModeSet(jsonStatus);
break;
// 查询M02自定义面膜信息
case "m02MaskCustomModeInfo":
this.InfoQuery.syncM02MaskCustomModeInfo(jsonStatus);
break;
// 设置:眼雕大师自定义、妆前急救自定义面膜模式
case "m02MaskCustomModeSet":
this.InfoQuery.syncM02MaskCustomModeSet(jsonStatus);
break;
// 版本信息
case "versionInfo":
this.InfoQuery.syncVersionInfo(jsonStatus);
break;
// 时间同步
case "timeSync":
this.InfoQuery.syncTimeSync(jsonStatus);
break;
default:
break;
}
break;
default:
break;
}
});
if (this.counter < 3) {
/**
* 600
*/
const querySubDeviceArrayBuffer = this.deviceToolKitInstance.toBleCommand({
...WE100BleCommand.querySubDevice,
queryType: "WE100",
} as any);
setTimeout(() => {
console.log("发送查询附属设备指令 querySubDeviceArrayBuffer");
sendCommand({
value: querySubDeviceArrayBuffer,
});
}, 600);
/**
* 500
*/
const queryDeviceArrayBuffer = this.deviceToolKitInstance.toBleCommand(
WE100BleCommand.queryDeviceStatus as any
);
setTimeout(() => {
console.log("发送查询设备电量指令");
sendCommand({
value: queryDeviceArrayBuffer,
});
}, 500);
this.counter++;
} else {
/**
* 500
*/
const queryDeviceArrayBuffer = this.deviceToolKitInstance.toBleCommand(
WE100BleCommand.queryDeviceStatus as any
);
setTimeout(() => {
console.log("发送查询设备电量指令");
sendCommand({
value: queryDeviceArrayBuffer,
});
}, 20000);
}
});
}
}
Loading…
Cancel
Save