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 /** Maximum value of the service status. */ 51 SERVIE_STATUS_MAX, 52 }; 53 54 /** 55 * @brief Defines the service status struct. 56 * The HDF uses this struct to notify the service module of the service status. 57 */ 58 struct ServiceStatus { 59 /** Service name */ 60 const char* serviceName; 61 /** Device type */ 62 uint16_t deviceClass; 63 /** Service status */ 64 uint16_t status; 65 /** Service information */ 66 const char *info; 67 }; 68 69 /** 70 * @brief Defines the function for service status listening. 71 * 72 * @param listener Indicates the pointer to the service status listener. 73 * @param status Indicates the pointer to the service status obtained. 74 */ 75 typedef void (*OnServiceStatusReceived)(struct ServiceStatusListener *listener, struct ServiceStatus *status); 76 77 /** 78 * @brief Defines the service status listener struct. 79 */ 80 struct ServiceStatusListener { 81 /** Callback invoked to return the service status */ 82 OnServiceStatusReceived callback; 83 /** 84 * Pointer to the private parameter of the service module. 85 * The service module can pass this parameter to the callback to convert 86 * the HDF service status to the required type. 87 */ 88 void *priv; 89 }; 90 91 #ifdef __cplusplus 92 } 93 #endif /* __cplusplus */ 94 #endif /* HDF_SERVICE_STATUS_H */