Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / plugins / zigbee_wrapper / telegesis_wrapper / include / twsocketlist.h
1 //******************************************************************
2 //
3 // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 /**
22  * @file
23  *
24  * This API only works with:
25  *      Telegesis ETRX357
26  *      CICIE R310 B110615
27  *
28  */
29
30 #ifndef TWSOCKETLIST_H_
31 #define TWSOCKETLIST_H_
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif // __cplusplus
36
37 #include "plugintypes.h"
38 #include "telegesis_socket.h"
39 #include "utlist.h"
40
41 // TODO: Use OICThread instead of pthread directly.
42 // TODO: Use OICMutex instead of mutex directly.
43 #include <pthread.h>
44
45 typedef struct TWSock
46 {
47     PIPlugin_Zigbee * plugin; // Handle
48     char * eui; // The associated Zigbee radio's EUI.
49     int fd;
50     char * buffer;
51     /** 'queue' MUST BE ACCESSED THREAD SAFE **/
52     TWEntry * queue;
53     pthread_mutex_t mutex; // TODO: Use OIC_MUTEX instead.
54     pthread_cond_t  queueCV;
55     bool isActive;
56     /** 'queue' MUST BE ACCESSED THREAD SAFE **/
57     pthread_t threadHandle;
58     pthread_attr_t threadAttr;
59     struct TWSock * next;
60 } TWSock;
61
62 TWResultCode TWAddTWSock(TWSock * sock, PIPlugin_Zigbee * plugin, const char * fileLoc);
63
64 TWSock * TWGetSock(PIPlugin_Zigbee * plugin);
65
66 TWResultCode TWDeleteTWSock(TWSock * sock);
67
68 TWResultCode TWDeleteAllTWSock();
69
70 TWResultCode TWFreeQueue(PIPlugin_Zigbee * plugin);
71
72 #ifdef __cplusplus
73 }
74 #endif // __cplusplus
75
76 #endif /* TWSOCKETLIST_H_ */