1/*
2 * Copyright (c) 2021-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
16var battery = require("@system.battery");
17battery.BatterySOC({
18    success: function(data) {
19        console.log('success get battery Soc:' + data.batterySoc);
20    },
21    fail: function(data, code) {
22        console.log('fail to get battery Soc code:' + code + ', data: ' + data);
23    },
24});
25
26battery.ChargingStatus({
27    success: function(data) {
28        console.log('success get ChargingStatus:' + data.chargingStatus);
29    },
30    fail: function(data, code) {
31        console.log('fail to get battery ChargingStatus code:' + code + ', data: ' + data);
32    },
33});
34
35battery.HealthStatus({
36    success: function(data) {
37        console.log('success get battery HealthStatus:' + data.healthStatus);
38    },
39    fail: function(data, code) {
40        console.log('fail to get battery HealthStatus code:' + code + ', data: ' + data);
41    },
42});
43
44battery.PluggedType({
45    success: function(data) {
46        console.log('success get battery PluggedType:' + data.pluggedType);
47    },
48    fail: function(data, code) {
49        console.log('fail to get battery PluggedType code:' + code + ', data: ' + data);
50    },
51});
52
53battery.Voltage({
54    success: function(data) {
55        console.log('success get battery Voltage:' + data.voltage);
56    },
57    fail: function(data, code) {
58        console.log('fail to get battery Voltage code:' + code + ', data: ' + data);
59    },
60});
61
62battery.Technology({
63    success: function(data) {
64        console.log('success get battery Technology:' + data.technology);
65    },
66    fail: function(data, code) {
67        console.log('fail to get battery Technology code:' + code + ', data: ' + data);
68    },
69});
70
71battery.Temperature({
72    success: function(data) {
73        console.log('success get battery Temperature:' + data.temperature);
74    },
75    fail: function(data, code) {
76        console.log('fail to get battery Temperature code:' + code + ', data: ' + data);
77    },
78});
79