1 /* 2 * Copyright (c) 2022 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 PNP_MESSAGE_REPORT_H 17 #define PNP_MESSAGE_REPORT_H 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 #define PNP_REPORT_MSG_LEN_MAX 32 24 #define PNP_REPORT_RESERVED 255 25 26 enum PnpReportType { 27 DEVICE_PULG, 28 EVENT_REPORT, 29 REPORT_TYPE_INVALID 30 }; 31 32 enum PnpReportEventId { 33 CAPTURE_THRESHOLD = 0, 34 LOAD_ADAPTER, 35 SERVICE_STATUS, 36 }; 37 38 enum PnpServiceStatus { 39 SERVICE_INVALID = 0, 40 SERVICE_ENABLE, 41 SERVICE_INIT, 42 }; 43 44 enum DevPlugState { 45 HDF_AUDIO_DEVICE_OFFLINE = 0, 46 HDF_AUDIO_DEVICE_ONLINE, 47 }; 48 49 enum DevPlugDevType { 50 DEV_PRIMARY = 0, 51 DEV_USB, 52 DEV_A2DP, 53 }; 54 55 enum AdapterLoadStatus { 56 LOAD_SUCCESS = 0, 57 LOAD_FAILURE = 1, 58 }; 59 60 struct PnpReportDevPlugMsg { 61 uint8_t eventType; 62 uint8_t state; 63 uint8_t deviceType; 64 uint8_t deviceCap; 65 uint8_t id; 66 }; 67 68 struct PnpReportEventMsg { 69 uint8_t eventType; 70 uint8_t eventId; 71 uint8_t eventValue; 72 uint8_t deviceType; 73 uint8_t reserve; /* Reserved fields are not used for the time being */ 74 }; 75 76 struct PnpReportMsg { 77 enum PnpReportType reportType; 78 union { 79 struct PnpReportDevPlugMsg devPlugMsg; 80 struct PnpReportEventMsg eventMsg; 81 }; 82 }; 83 84 int32_t PnpReportMsgDeSerialize(uint8_t *msgStr, enum PnpReportType msgType, struct PnpReportMsg *pnpReportMsg); 85 char *PnpReportMsgSerialize(struct PnpReportMsg *pnpReportMsg); 86 87 #ifdef __cplusplus 88 } 89 #endif 90 #endif /* PNP_MESSAGE_REPORT_H */ 91 92