1 /* 2 * Copyright (c) 2023 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 LNN_DECISION_CENTER_H 17 #define LNN_DECISION_CENTER_H 18 19 #include <stdint.h> 20 #include <stdbool.h> 21 22 typedef enum { 23 STATE_TYPE_BLE_SWITCH_ON = 0, 24 STATE_TYPE_BLE_SWITCH_OFF, 25 STATE_TYPE_BLE_DISCOVERY, 26 STATE_TYPE_AR_MOVE_RIDING, 27 STATE_TYPE_AR_MOVE_RUN_FAST, 28 STATE_TYPE_AR_CLIMBING_MOUNT, 29 STATE_TYPE_AR_MOVE_RUN_FOR_HEALTH, 30 STATE_TYPE_AR_MOVE_WALK_FOR_HEALTH, 31 STATE_TYPE_AR_MOVE_VEHICLE, 32 STATE_TYPE_AR_MOVE_VE_TRAIN, 33 STATE_TYPE_AR_MOVE_VE_UNKNOWN, 34 STATE_TYPE_AR_MOVE_STATIONARY, 35 STATE_TYPE_AR_VE_BUS, 36 STATE_TYPE_AR_VE_CAR, 37 STATE_TYPE_AR_VE_METRO, 38 STATE_TYPE_AR_VE_HIGH_SPEED_RAIL, 39 STATE_TYPE_AR_VE_AUTO, 40 STATE_TYPE_AR_VE_RAIL, 41 STATE_TYPE_AR_MOVE_ON_FOOT, 42 STATE_TYPE_AR_MOVE_ELEVATOR, 43 STATE_TYPE_AR_MOVE_DRIVER, 44 STATE_TYPE_AR_FAST_WALK, 45 STATE_TYPE_AR_STOP_VEHICLE, 46 STATE_TYPE_AR_MOVE_WALK_SLOW, 47 STATE_TYPE_AR_MOVE_TILT, 48 STATE_TYPE_AR_MOVE_END, 49 STATE_TYPE_AR_MOVE_IN_OUT_DOOR, 50 STATE_TYPE_MOTION_SHAKE, 51 STATE_TYPE_MOTION_TAP, 52 STATE_TYPE_MOTION_TILT_LR, 53 STATE_TYPE_MOTION_ROTATION, 54 STATE_TYPE_MOTION_TAKE_OFF, 55 STATE_TYPE_MOTION_HEAD_DOWN, 56 STATE_TYPE_MOTION_PUT_DOWN, 57 STATE_TYPE_MOTION_SIDE_GRIP, 58 STATE_TYPE_MOTION_MOVE, 59 STATE_TYPE_MAX_NUM, 60 } StatePacks; 61 62 typedef enum { 63 DC_VERSION_1_0 = 0, 64 DC_VERSION_MAX_NUM, 65 } DecisionCenterVersion; 66 67 typedef enum { 68 DC_TARGET_ENERGY = 0x0001, 69 DC_TARGET_EFFICIENCY = 0x0010, 70 DC_TARGET_LATENCY = 0x0100, 71 DC_TARGET_ROBUSTNESS = 0x1000 72 } DcTargetType; 73 74 typedef enum { 75 TASK_BLE_HEARTBEAT = 0, 76 TASK_BLE_LOW_LATENCY = 1, 77 TASK_NUM, 78 } SupportTaskType; 79 80 typedef enum { 81 TASK_CONVEX_SYSTEM = 0, 82 TASK_RULE_SYSTEM = 1, 83 TASK_ML_SYSTEM = 2, 84 TASK_LOGIC_SYSTEM = 3, 85 TASK_SYSTEM_NUM, 86 } DcSupportTaskSystem; 87 88 typedef struct { 89 int32_t serviceUuid; 90 uint8_t taskId; 91 uint8_t taskType; 92 uint8_t target; 93 uint8_t preferredSystem; 94 uint8_t limitType; 95 int32_t limitValue; // Unit: Milliseconds/Times/None 96 int32_t (*optimizeStrategy)(void *); 97 } DcTask; 98 99 typedef struct { 100 int64_t timestamp; 101 int32_t stateType; 102 int32_t stateValue; 103 } DcEvent; 104 105 typedef enum { 106 DC_LIMIT_PERSISTENT = 0, 107 DC_LIMIT_TIMES = 1, 108 DC_LIMIT_DURATION = 2, 109 DC_LIMIT_NUM 110 } DcLimitType; 111 112 typedef struct { 113 uint32_t type; 114 union { 115 struct DcBleParam { 116 uint16_t advMinInterval; 117 uint16_t advMaxInterval; 118 uint16_t scanInterval; 119 uint16_t scanWindow; 120 } ble; 121 } info; 122 struct HeartbeatImplPolicy *next; 123 } BleHeartbeatConfig; 124 125 int32_t LnnInitDecisionCenter(uint32_t version); 126 void LnnDeinitDecisionCenter(void); 127 int32_t LnnDcSubscribe(DcTask *task); 128 int32_t LnnDcUnsubscribe(DcTask *task); 129 void LnnDcDispatchEvent(DcEvent *dcEvnet); 130 131 #endif 132