1 /*
2  * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 /**
10  * @addtogroup Core
11  * @{
12  *
13  * @brief Provides Hardware Driver Foundation (HDF) APIs.
14  *
15  * The HDF implements driver framework capabilities such as driver loading, service management,
16  * and driver message model. You can develop drivers based on the HDF.
17  *
18  * @since 1.0
19  */
20 
21 /**
22  * @file hdf_service_status.h
23  *
24  * @brief Defines data structs for the service status and service status listener callback.
25  *
26  * @since 1.0
27  */
28 
29 #ifndef HDF_SERVICE_STATUS_H
30 #define HDF_SERVICE_STATUS_H
31 
32 #include "hdf_types.h"
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif /* __cplusplus */
37 
38 struct ServiceStatusListener;
39 
40 /**
41  * @brief Enumerates the service status.
42  */
43 enum ServiceStatusType {
44     /** The service is started. */
45     SERVIE_STATUS_START,
46     /** The service status changes. */
47     SERVIE_STATUS_CHANGE,
48     /** The service is stopped. */
49     SERVIE_STATUS_STOP,
50     /** register service listener status. */
51     SERVIE_STATUS_REGISTER,
52     /** Maximum value of the service status. */
53     SERVIE_STATUS_MAX,
54 };
55 
56 /**
57  * @brief Defines the service status struct.
58  * The HDF uses this struct to notify the service module of the service status.
59  */
60 struct ServiceStatus {
61     /** Service name */
62     const char* serviceName;
63     /** Device type */
64     uint16_t deviceClass;
65     /** Service status */
66     uint16_t status;
67     /** Service information */
68     const char *info;
69 };
70 
71 /**
72  * @brief Defines the function for service status listening.
73  *
74  * @param listener Indicates the pointer to the service status listener.
75  * @param status Indicates the pointer to the service status obtained.
76  */
77 typedef void (*OnServiceStatusReceived)(struct ServiceStatusListener *listener, struct ServiceStatus *status);
78 
79 /**
80  * @brief Defines the service status listener struct.
81  */
82 struct ServiceStatusListener {
83     /** Callback invoked to return the service status */
84     OnServiceStatusReceived callback;
85     /**
86      * Pointer to the private parameter of the service module.
87      * The service module can pass this parameter to the callback to convert
88      * the HDF service status to the required type.
89      */
90     void *priv;
91 };
92 
93 #ifdef __cplusplus
94 }
95 #endif /* __cplusplus */
96 #endif /* HDF_SERVICE_STATUS_H */