1/* 2 * Copyright (C) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import { BaseBean } from './BaseBean.js'; 17 18export class PayloadProtect extends Object implements BaseBean { 19 // reserve for encrypt and decrypt 20 private _channelId: number; //uint32_t 21 private _commandFlag: number; //uint32_t 22 private _checkSum: number; // uint8_t enable it will be lose about 20% speed 23 private _vCode: number; //uint8_t 24 25 constructor(channelId: number, commandFlag: number, checkSum: number, vCode: number) { 26 super(); 27 this._channelId = channelId; 28 this._commandFlag = commandFlag; 29 this._checkSum = checkSum; 30 this._vCode = vCode; 31 } 32 33 getDataView(): DataView { 34 return new DataView(new ArrayBuffer(24)); 35 } 36 37 get channelId(): number { 38 return this._channelId; 39 } 40 41 set channelId(value: number) { 42 this._channelId = value; 43 } 44 45 get commandFlag(): number { 46 return this._commandFlag; 47 } 48 49 set commandFlag(value: number) { 50 this._commandFlag = value; 51 } 52 53 get checkSum(): number { 54 return this._checkSum; 55 } 56 57 set checkSum(value: number) { 58 this._checkSum = value; 59 } 60 61 get vCode(): number { 62 return this._vCode; 63 } 64 65 set vCode(value: number) { 66 this._vCode = value; 67 } 68 69 toString(): string { 70 return ( 71 'channelId: ' + 72 this._channelId + 73 ' commandFlag: ' + 74 this._commandFlag + 75 ' checkSum: ' + 76 this._checkSum + 77 ' vCode: ' + 78 this._vCode 79 ); 80 } 81} 82