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 */ 15 16 /** 17 * @addtogroup PanSensor 18 * @{ 19 * 20 * @brief Provides standard open APIs for you to use common capabilities of sensors. 21 * 22 * For example, you can call these APIs to obtain sensor information, 23 * subscribe to or unsubscribe from sensor data, enable or disable a sensor, 24 * and set the sensor data reporting mode. 25 * 26 * @since 5 27 */ 28 29 /** 30 * @file sensor_agent.h 31 * 32 * @brief Declares common APIs for sensor management, such as APIs for subscribing to 33 * and obtaining sensor data, enabling a sensor, and setting the sensor data reporting mode. 34 * 35 * @since 5 36 */ 37 38 #ifndef SENSOR_AGENT_H 39 #define SENSOR_AGENT_H 40 41 #include "medical_native_type.h" 42 43 #ifdef __cplusplus 44 #if __cplusplus 45 extern "C" { 46 #endif 47 #endif 48 49 /** 50 * @brief Obtains information about all sensors in the system. 51 * 52 * @param sensorInfo Indicates the double pointer to the information about all sensors in the system. 53 * For details, see {@link MedicalSensorInfo}. 54 * @param count Indicates the pointer to the total number of sensors in the system. 55 * @return Returns <b>0</b> if the information is obtained; returns a non-zero value otherwise. 56 * 57 * @since 5 58 */ 59 int32_t GetAllSensors(MedicalSensorInfo **sensorInfo, int32_t *count); 60 /** 61 * @brief Subscribes to sensor data. The system will report the obtained sensor data to the subscriber. 62 * 63 * @param sensorTypeId Indicates the ID of a sensor type. For details, see {@link SensorTypeId}. 64 * @param user Indicates the pointer to the sensor subscriber that requests sensor data. For details, 65 * see {@link MedicalSensorUser}. A subscriber can obtain data from only one sensor. 66 * @return Returns <b>0</b> if the subscription is successful; returns a non-zero value otherwise. 67 * 68 * @since 5 69 */ 70 int32_t SubscribeSensor(int32_t sensorTypeId, const MedicalSensorUser *user); 71 /** 72 * @brief Unsubscribes from sensor data. 73 * 74 * @param sensorTypeId Indicates the ID of a sensor type. For details, see {@link SensorTypeId}. 75 * @param user Indicates the pointer to the sensor subscriber that requests sensor data. 76 * For details, see {@link MedicalSensorUser}. A subscriber can obtain data from only one sensor. 77 * @return Returns <b>0</b> if the unsubscription is successful; returns a non-zero value otherwise. 78 * 79 * @since 5 80 */ 81 int32_t UnsubscribeSensor(int32_t sensorTypeId, const MedicalSensorUser *user); 82 /** 83 * @brief Sets the data sampling interval and data reporting interval for the specified sensor. 84 * 85 * @param sensorTypeId Indicates the ID of a sensor type. For details, see {@link SensorTypeId}. 86 * @param user Indicates the pointer to the sensor subscriber that requests sensor data. 87 * For details, see {@link MedicalSensorUser}. A subscriber can obtain data from only one sensor. 88 * @param samplingInterval Indicates the sensor data sampling interval to set, in nanoseconds. 89 * @param reportInterval Indicates the sensor data reporting interval, in nanoseconds. 90 * @return Returns <b>0</b> if the setting is successful; returns a non-zero value otherwise. 91 * 92 * @since 5 93 */ 94 int32_t SetBatch(int32_t sensorTypeId, const MedicalSensorUser *user, int64_t samplingInterval, int64_t reportInterval); 95 /** 96 * @brief Enables the sensor that has been subscribed to. The subscriber can obtain the sensor data 97 * only after the sensor is enabled. 98 * 99 * @param sensorTypeId Indicates the ID of a sensor type. For details, see {@link SensorTypeId}. 100 * @param user Indicates the pointer to the sensor subscriber that requests sensor data. 101 * For details, see {@link MedicalSensorUser}. A subscriber can obtain data from only one sensor. 102 * @return Returns <b>0</b> if the sensor is successfully enabled; returns a non-zero value otherwise. 103 * 104 * @since 5 105 */ 106 int32_t ActivateSensor(int32_t sensorTypeId, const MedicalSensorUser *user); 107 /** 108 * @brief Disables an enabled sensor. 109 * 110 * @param sensorTypeId Indicates the ID of a sensor type. For details, see {@link SensorTypeId}. 111 * @param user Indicates the pointer to the sensor subscriber that requests sensor data. 112 * For details, see {@link MedicalSensorUser}. A subscriber can obtain data from only one sensor. 113 * @return Returns <b>0</b> if the sensor is successfully disabled; returns a non-zero value otherwise. 114 * 115 * @since 5 116 */ 117 int32_t DeactivateSensor(int32_t sensorTypeId, const MedicalSensorUser *user); 118 /** 119 * @brief Sets the data reporting mode for the specified sensor. 120 * 121 * @param sensorTypeId Indicates the ID of a sensor type. For details, see {@link SensorTypeId}. 122 * @param user Indicates the pointer to the sensor subscriber that requests sensor data. 123 * For details, see {@link MedicalSensorUser}. A subscriber can obtain data from only one sensor. 124 * @param mode Indicates the data reporting mode to set. For details, see {@link SensorMode}. 125 * @return Returns <b>0</b> if the sensor data reporting mode is successfully set; returns a non-zero value otherwise. 126 * 127 * @since 5 128 */ 129 int32_t SetMode(int32_t sensorTypeId, const MedicalSensorUser *user, int32_t mode); 130 131 int32_t SetOption(int32_t sensorTypeId, const MedicalSensorUser *user, int32_t option); 132 133 #ifdef __cplusplus 134 #if __cplusplus 135 } 136 #endif 137 #endif 138 #endif /* SENSOR_AGENT_H */ 139 /** @} */