Imported Upstream version 1.2.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
40 #include <coap/utlist.h>
41
42 // TODO: Use OICThread instead of pthread directly.
43 // TODO: Use OICMutex instead of mutex directly.
44 #include <pthread.h>
45
46 typedef struct TWSock
47 {
48     PIPlugin_Zigbee * plugin; // Handle
49     char * eui; // The associated Zigbee radio's EUI.
50     int fd;
51     char * buffer;
52     /** 'queue' MUST BE ACCESSED THREAD SAFE **/
53     TWEntry * queue;
54     pthread_mutex_t mutex; // TODO: Use OIC_MUTEX instead.
55     pthread_cond_t  queueCV;
56     bool isActive;
57     /** 'queue' MUST BE ACCESSED THREAD SAFE **/
58     pthread_t threadHandle;
59     pthread_attr_t threadAttr;
60     struct TWSock * next;
61 } TWSock;
62
63 TWResultCode TWAddTWSock(TWSock * sock, PIPlugin_Zigbee * plugin, const char * fileLoc);
64
65 TWSock * TWGetSock(PIPlugin_Zigbee * plugin);
66
67 TWResultCode TWDeleteTWSock(TWSock * sock);
68
69 TWResultCode TWDeleteAllTWSock();
70
71 TWResultCode TWFreeQueue(PIPlugin_Zigbee * plugin);
72
73 #ifdef __cplusplus
74 }
75 #endif // __cplusplus
76
77 #endif /* TWSOCKETLIST_H_ */