• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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{  // reserve for encrypt and decrypt
19    private _channelId: number; //uint32_t
20    private _commandFlag: number; //uint32_t
21    private _checkSum: number;// uint8_t enable it will be lose about 20% speed
22    private _vCode: number; //uint8_t
23
24    constructor(channelId: number, commandFlag: number, checkSum: number, vCode: number) {
25        super();
26        this._channelId = channelId;
27        this._commandFlag = commandFlag;
28        this._checkSum = checkSum;
29        this._vCode = vCode;
30    }
31
32    getDataView(): DataView {
33        return new DataView(new ArrayBuffer(24));
34    }
35
36    get channelId(): number {
37        return this._channelId;
38    }
39
40    set channelId(value: number) {
41        this._channelId = value;
42    }
43
44    get commandFlag(): number {
45        return this._commandFlag;
46    }
47
48    set commandFlag(value: number) {
49        this._commandFlag = value;
50    }
51
52    get checkSum(): number {
53        return this._checkSum;
54    }
55
56    set checkSum(value: number) {
57        this._checkSum = value;
58    }
59
60    get vCode(): number {
61        return this._vCode;
62    }
63
64    set vCode(value: number) {
65        this._vCode = value;
66    }
67
68    toString(): string {
69        return "channelId: " + this._channelId
70            + " commandFlag: " + this._commandFlag
71            + " checkSum: " + this._checkSum
72            + " vCode: " + this._vCode;
73    }
74}