1 /* 2 * Copyright (c) 2021 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_STATE_MACHINE_H 17 #define LNN_STATE_MACHINE_H 18 19 #include "common_list.h" 20 #include "message_handler.h" 21 #include "lnn_state_machine_struct.h" 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 int32_t LnnFsmInit(FsmStateMachine *fsm, SoftBusLooper *looper, char *name, FsmDeinitCallback cb); 28 int32_t LnnFsmDeinit(FsmStateMachine *fsm); 29 30 int32_t LnnFsmAddState(FsmStateMachine *fsm, FsmState *state); 31 32 int32_t LnnFsmStart(FsmStateMachine *fsm, FsmState *initialState); 33 int32_t LnnFsmStop(FsmStateMachine *fsm); 34 35 int32_t LnnFsmPostMessage(FsmStateMachine *fsm, uint32_t msgType, void *data); 36 int32_t LnnFsmPostMessageDelay(FsmStateMachine *fsm, uint32_t msgType, void *data, uint64_t delayMillis); 37 38 int32_t LnnFsmRemoveMessageByType(FsmStateMachine *fsm, int32_t what); 39 40 /* msgType value should not be 0 */ 41 int32_t LnnFsmRemoveMessage(FsmStateMachine *fsm, int32_t msgType); 42 int32_t LnnFsmRemoveMessageSpecific(FsmStateMachine *fsm, 43 int32_t (*customFunc)(const SoftBusMessage*, void*), void *args); 44 45 int32_t LnnFsmTransactState(FsmStateMachine *fsm, FsmState *state); 46 47 #ifdef __cplusplus 48 } 49 #endif 50 51 #endif 52