1 /* 2 * Copyright (c) 2021 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 16 #ifndef SENSOR_SERVICE_DEF_H 17 #define SENSOR_SERVICE_DEF_H 18 19 #include <iproxy_server.h> 20 21 #include <pthread.h> 22 23 #include "feature.h" 24 #include <iunknown.h> 25 #include <log.h> 26 #include "samgr_lite.h" 27 #include "sensor_agent.h" 28 #include "sensor_agent_proxy.h" 29 #include "sensor_agent_type.h" 30 #include "service.h" 31 32 #ifdef __cplusplus 33 #if __cplusplus 34 extern "C" { 35 #endif 36 #endif 37 38 #define SENSOR_SERVICE "sensor_service" 39 #define SENSOR_FEATURE "sensor_feature" 40 41 #define SENSOR_SERVICE_ID_GetAllSensors 0 42 #define SENSOR_SERVICE_ID_ActivateSensor 1 43 #define SENSOR_SERVICE_ID_DeactivateSensor 2 44 #define SENSOR_SERVICE_ID_SetBatchs 3 45 #define SENSOR_SERVICE_ID_SubscribeSensor 4 46 #define SENSOR_SERVICE_ID_UnsubscribeSensor 5 47 #define SENSOR_SERVICE_ID_SetMode 6 48 #define SENSOR_SERVICE_ID_SetOption 7 49 #define SENSORMGR_LISTENER_NAME_LEN 8 50 51 typedef struct SensorFeatureApi { 52 INHERIT_SERVER_IPROXY; 53 int32_t (*GetAllSensors)(SensorInfo **sensorInfo, int32_t *count); 54 int32_t (*ActivateSensor)(int32_t sensorId, const SensorUser *user); 55 int32_t (*DeactivateSensor)(int32_t sensorId, const SensorUser *user); 56 int32_t (*SetBatch)(int32_t sensorId, const SensorUser *user, int64_t samplingInterval, int64_t reportInterval); 57 int32_t (*SubscribeSensor)(int32_t sensorId, const SensorUser *user); 58 int32_t (*UnsubscribeSensor)(int32_t sensorId, const SensorUser *user); 59 int32_t (*SetMode)(int32_t sensorId, const SensorUser *user, int32_t mode); 60 int32_t (*SetOption)(int32_t sensorId, const SensorUser *user, int32_t option); 61 } SensorFeatureApi; 62 63 typedef struct SensorService { 64 INHERIT_SERVICE; 65 INHERIT_IUNKNOWNENTRY(SensorFeatureApi); 66 Identity identity; 67 } SensorService; 68 69 #ifdef __cplusplus 70 #if __cplusplus 71 } 72 #endif 73 #endif 74 #endif