• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef SENSORS_ERRORS_H
17 #define SENSORS_ERRORS_H
18 
19 #include <errors.h>
20 
21 namespace OHOS {
22 namespace Sensors {
23 enum {
24     MODULE_COMMON = 0x00,
25     MODULE_SENSORS_DEVICE = 0x01,
26     MODULE_SENSOR_SERVICE = 0x02,
27     MODULE_SENSORS_UTILS = 0x03,
28     MODULE_SENSORS_NATIVE = 0X04,
29 };
30 
31 // Error code for common
32 constexpr ErrCode COMMON_ERR_OFFSET = ErrCodeOffset(SUBSYS_SENSORS, MODULE_COMMON);
33 
34 enum {
35     ERROR = -1,
36     SUCCESS = 0,
37     COMMON_ERR = COMMON_ERR_OFFSET,
38 };
39 
40 // Error code for device
41 constexpr ErrCode DEVICE_ERR_OFFSET = ErrCodeOffset(SUBSYS_SENSORS, MODULE_SENSORS_DEVICE);
42 
43 enum {
44     DEVICE_ERR = DEVICE_ERR_OFFSET,
45     DEVICE_ENABLE_SENSOR_ERR = DEVICE_ERR_OFFSET + 1,
46     DEVICE_DISABLE_SENSOR_ERR = DEVICE_ENABLE_SENSOR_ERR + 1,
47     DEVICE_RUN_COMMAND_ERR = DEVICE_DISABLE_SENSOR_ERR + 1,
48     DEVICE_SET_SENSOR_CONFIG_ERR = DEVICE_RUN_COMMAND_ERR + 1,
49     DEVICE_NOT_SUPPORT_CMD_ERR = DEVICE_SET_SENSOR_CONFIG_ERR + 1,
50 };
51 
52 // Error code for sensor service
53 constexpr ErrCode SENSOR_SERVICE_ERR_OFFSET = ErrCodeOffset(SUBSYS_SENSORS, MODULE_SENSOR_SERVICE);
54 
55 enum {
56     SENSOR_SERVICE_ERR = SENSOR_SERVICE_ERR_OFFSET,
57     CMD_TYPE_ERR = SENSOR_SERVICE_ERR + 1,
58     SENSOR_DEVICE_INIT_ERR = CMD_TYPE_ERR + 1,
59     CONNECT_SENSOR_HDF_ERR = SENSOR_DEVICE_INIT_ERR + 1,
60     SET_SENSOR_CONFIG_ERR = CONNECT_SENSOR_HDF_ERR + 1,
61     ENABLE_SENSOR_ERR = SET_SENSOR_CONFIG_ERR + 1,
62     DISABLE_SENSOR_ERR = ENABLE_SENSOR_ERR + 1,
63     RUN_COMMAND_ERR = DISABLE_SENSOR_ERR + 1,
64     GET_SENSOR_LIST_ERR = RUN_COMMAND_ERR + 1,
65     SENSOR_ENABLED_ERR = GET_SENSOR_LIST_ERR + 1,
66     UPDATE_SENSOR_CHANNEL_ERR = SENSOR_ENABLED_ERR + 1,
67     CLEAR_SENSOR_CHANNEL_ERR = UPDATE_SENSOR_CHANNEL_ERR + 1,
68     CLEAR_SENSOR_INFO_ERR = CLEAR_SENSOR_CHANNEL_ERR + 1,
69     UPDATE_SENSOR_INFO_ERR = CLEAR_SENSOR_INFO_ERR + 1,
70     CLIENT_PID_INVALID_ERR = UPDATE_SENSOR_INFO_ERR + 1,
71     DESTROY_SENSOR_CHANNEL_ERR = CLIENT_PID_INVALID_ERR + 1,
72     UPDATE_UID_ERR = DESTROY_SENSOR_CHANNEL_ERR + 1,
73     INVALID_POINTER = UPDATE_UID_ERR + 1,
74     NO_EVENT = INVALID_POINTER + 1,
75     COPY_ERR = NO_EVENT + 1,
76     REGIST_PERMISSION_CHANGED_ERR = COPY_ERR + 1,
77     DUMP_PARAM_ERR = REGIST_PERMISSION_CHANGED_ERR + 1,
78     WRITE_MSG_ERR = DUMP_PARAM_ERR + 1,
79     SET_SENSOR_MODE_ERR = WRITE_MSG_ERR + 1,
80     SET_SENSOR_OPTION_ERR = SET_SENSOR_MODE_ERR + 1,
81     REGIST_CALLBACK_ERR = SET_SENSOR_OPTION_ERR + 1,
82 };
83 
84 // Error code for Sensor uitls
85 constexpr ErrCode SENSOR_UTILS_ERR_OFFSET = ErrCodeOffset(SUBSYS_SENSORS, MODULE_SENSORS_UTILS);
86 enum {
87     SENSOR_CHANNEL_SOCKET_CREATE_ERR = SENSOR_UTILS_ERR_OFFSET,
88     SENSOR_CHANNEL_SENDFD_ERR = SENSOR_CHANNEL_SOCKET_CREATE_ERR + 1,
89     SENSOR_CHANNEL_WRITE_DESCRIPTOR_ERR = SENSOR_CHANNEL_SENDFD_ERR + 1,
90     SENSOR_CHANNEL_DUP_ERR = SENSOR_CHANNEL_WRITE_DESCRIPTOR_ERR + 1,
91     SENSOR_CHANNEL_BASIC_CHANNEL_NOT_INIT = SENSOR_CHANNEL_DUP_ERR + 1,
92     SENSOR_CHANNEL_SEND_ADDR_ERR = SENSOR_CHANNEL_BASIC_CHANNEL_NOT_INIT + 1,
93     SENSOR_CHANNEL_SEND_DATA_ERR = SENSOR_CHANNEL_SEND_ADDR_ERR + 1,
94     SENSOR_CHANNEL_RECEIVE_DATA_ERR = SENSOR_CHANNEL_SEND_DATA_ERR + 1,
95     SENSOR_CHANNEL_RECEIVE_ADDR_ERR = SENSOR_CHANNEL_RECEIVE_DATA_ERR + 1,
96     SENSOR_CHANNEL_RESTORE_CB_ERR = SENSOR_CHANNEL_RECEIVE_ADDR_ERR + 1,
97     SENSOR_CHANNEL_RESTORE_FD_ERR = SENSOR_CHANNEL_RESTORE_CB_ERR + 1,
98     SENSOR_CHANNEL_RESTORE_THREAD_ERR = SENSOR_CHANNEL_RESTORE_FD_ERR + 1,
99 };
100 // Error code for Sensor native
101 constexpr ErrCode SENSOR_NATIVE_ERR_OFFSET = ErrCodeOffset(SUBSYS_SENSORS, MODULE_SENSORS_NATIVE);
102 
103 enum {
104     SENSOR_NATIVE_SAM_ERR = SENSOR_NATIVE_ERR_OFFSET,
105     SENSOR_NATIVE_GET_SERVICE_ERR = SENSOR_NATIVE_SAM_ERR + 1,
106     SENSOR_NATIVE_REGSITER_CB_ERR = SENSOR_NATIVE_GET_SERVICE_ERR + 1,
107 };
108 }  // namespace Sensors
109 }  // namespace OHOS
110 #endif  // SENSORS_ERRORS_H
111