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 P2PLINK_LOOP_H 17 #define P2PLINK_LOOP_H 18 19 #include <stdint.h> 20 21 #ifdef __cplusplus 22 #if __cplusplus 23 extern "C" { 24 #endif 25 #endif 26 27 typedef enum { 28 P2PLOOP_MSG_PROC, 29 P2PLOOP_MSG_TEST, 30 START_NEGOTIATION, 31 CONN_REQUEST_TIME_OUT, 32 WAIT_CONN_TIME_OUT, 33 MAGICLINK_CONN_GROUP_TIME_OUT, 34 MAGICLINK_CREATE_GROUP_TIME_OUT, 35 MAGICLINK_ON_GROUP_CHANGED, 36 CONN_REQUEST_FAILED, 37 MAGICLINK_ON_CONNECTED, 38 CONN_REQUEST, 39 CONN_RESPONSE, 40 CONN_RESPONSE_FAILED, 41 P2PLOOP_CONNINGDEV_TIMER, 42 P2PLOOP_P2PAUTHCHAN_OK, 43 P2PLOOP_BROADCAST_GROUPSTATE_CHANGED, 44 P2PLOOP_BROADCAST_P2PSTATE_CHANGED, 45 P2PLOOP_BROADCAST_CONN_STATE, 46 P2PLOOP_INTERFACE_ROLE_CONFICT, 47 P2PLOOP_INTERFACE_LOOP_DISCONNECT, 48 P2PLOOP_INTERFACE_LOOP_CONNECT, 49 P2PLOOP_OPEN_AUTH_CHAN, 50 P2PLOOP_OPEN_DISCONNECTING_TIMEOUT, 51 P2PLOOP_AUTH_CHANNEL_CLOSED, 52 WAIT_ROLE_NEG_TIME_OUT, 53 DHCP_TIME_OUT, 54 } P2pLoopMsg; 55 56 typedef void (*P2pLoopProcessFunc)(P2pLoopMsg msgType, void *para); 57 58 int32_t P2pLoopInit(void); 59 int32_t P2pLoopProc(P2pLoopProcessFunc callback, void *para, P2pLoopMsg msgType); // para: no use local variable 60 int32_t P2pLoopProcDelay(P2pLoopProcessFunc callback, void *para, uint64_t delayMillis, P2pLoopMsg msgType); 61 int32_t P2pLoopProcDelayDel(P2pLoopProcessFunc callback, P2pLoopMsg msgType); 62 63 #ifdef __cplusplus 64 #if __cplusplus 65 } 66 #endif /* __cplusplus */ 67 #endif /* __cplusplus */ 68 #endif /* P2PLINK_LOOP_H */ 69 70