1/*
2 * Copyright (c) 2022 Chipsea Technologies (Shenzhen) Corp., 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 */
15import { Callback } from './basic';
16
17/**
18 * This module provides the capability to subscribe to medical data.
19 *
20 * @since 8
21 * @sysCap SystemCapability.Sensors.Medical_sensor
22 * @import import medical from '@ohos.medical'
23 * @permission ohos.permission.HEALTH_DATA
24 */
25declare namespace medical {
26    /**
27     * Subscribe to medical sensor data, If the API is called multiple times, the last call takes effect.
28     * @param type Indicate the medical type to listen for, {@code MedicalSensorType.TYPE_ID_PHOTOPLETHYSMOGRAPH}.
29     * @param options Optional parameters specifying the interval at which medical sensor data is reported, {@code Options}.
30     * @permission ohos.permission.PHOTOPLETHYSMOGRAPH
31     * @since 8
32     */
33    function on(type: MedicalSensorType.TYPE_ID_PHOTOPLETHYSMOGRAPH, callback: Callback<PpgResponse>, options?: Options): void;
34
35    /**
36     * Unsubscribe to medical sensor data once.
37     * @param type Indicate the medical sensor type to listen for, {@code MedicalSensorType}.
38     * @permission N/A
39     * @since 8
40     */
41    function off(type: MedicalSensorType.TYPE_ID_PHOTOPLETHYSMOGRAPH, callback?: Callback<PpgResponse>): void;
42
43    /**
44     * Subscribe to the medical sensor's optional parameters.
45     * @sysCap SystemCapability.Sensors.Medical_sensor
46     */
47    interface Options {
48        interval?: number; /**< Sensor event reporting event interval */
49    }
50
51    /**
52     * The type of medical sensor.
53     * @sysCap SystemCapability.Sensors.Medical_sensor
54     */
55    enum MedicalSensorType {
56        TYPE_ID_PHOTOPLETHYSMOGRAPH = 129,    /**< Photoplethysmography */
57    }
58
59    interface PpgResponse {
60        dataArray: Array<number>; /**< Acceleration x-axis component */
61    }
62 }
63
64 export default medical;