Added Telegesis & Zigbee Wrappers, mapping logic, and plugin interface.
[platform/upstream/iotivity.git] / plugins / include / internal / plugintranslatortypes.h
1 //******************************************************************
2 //
3 // Copyright 2014 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 /**
23  * @file
24  *
25  * This file contains the definition, types and APIs for all operations
26  * required to translate plugin's respective devices to an OCResource.
27  */
28
29 #ifndef PLUGINTRANSLATORTYPES_H_
30 #define PLUGINTRANSLATORTYPES_H_
31
32 #include "plugintypes.h"
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif // __cplusplus
37
38 #define PI_ZIGBEE_PREFIX "/zb"
39
40 // Forward definitions to support inter-linking between structs in this file
41 // and the following callback.
42 // Note: If there are issues with either of the following two structs, please
43 //       manually check these structs and their uses for valid operation.
44 struct PIPluginBase;
45 struct PIResourceBase;
46
47 /**
48  *
49  * This callback will be called when a new resource is created by radio wrapper.
50  *
51  */
52 typedef void (* PINewResourceFound)(struct PIPluginBase * plugin,
53                                     struct PIResourceBase *newResource);
54
55 /**
56  *
57  * This function type is used by the radio's mapping implementation against IoTivity.
58  * The mapping implementation must implement this function to handle GET & PUT requests.
59  *
60  */
61 typedef OCEntityHandlerResult (* PIProcessRequest) (struct PIPluginBase * plugin,
62                                                     OCEntityHandlerRequest *ehRequest,
63                                                     OCRepPayload **payload);
64
65 /**
66  * Parameter list for a plugin.
67  */
68 typedef struct PIPluginBase
69 {
70     /** The type of plugin this represents. */
71     PIPluginType type;
72
73     /** The file location which represents the interface of the plugin.  */
74     char * comPort;
75
76     /** Linked list of plugins. */
77     struct PIPluginBase * next;
78
79     /** Callback to be used when a new resource has been found. */
80     PINewResourceFound NewResourceFoundCB;
81
82     /** Function Pointer to be invoked upon an incoming IoTivity request. */
83     PIProcessRequest processEHRequest;
84
85     /** All resources which exist within the context of this plugin. */
86     struct PIResourceBase * resourceList;
87
88     // Any other common internal properties between plugins can be placed here.
89 } PIPluginBase;
90
91 /**
92  * The inherite plugin type to be associated with the ZigBee radio and its
93  * implementation.
94  */
95 // Note: Although ZigBee has no new members for it's Plugin Type, other radio
96 // implementations should follow this paradigm where each radio type has
97 // inherited from the PIPluginBase type.
98 typedef struct
99 {
100     PIPluginBase header;
101 } PIPlugin_Zigbee;
102
103 /**
104  * Parameter list for a new OCResource. This will be handed up in the
105  * PINewResource callback.
106  */
107 typedef struct
108 {
109     OCResourceHandle resourceHandle;
110     char *resourceTypeName;
111     char *resourceInterfaceName;
112     char *uri;
113     OCEntityHandler entityHandler;
114     void* callbackParam;
115     uint8_t resourceProperties;
116 } PIResource;
117
118 /**
119  *  Header for all PIResources.
120  */
121 typedef struct PIResourceBase
122 {
123     PIResource piResource;
124     struct PIResourceBase * next; // Linked list of resources.
125     PIPluginBase * plugin; // Context this resource exists.
126 } PIResourceBase;
127
128 typedef struct
129 {
130 // Todo: This needs to map nicely to a struct that's defined in Zigbee_wrapper
131     uint8_t placeholder;
132 // Todo: This struct will be refactored once Zigbee_Wrapper is finished.
133 } PIZigbeeProfile;
134
135 /**
136  * Parameter list for a resource. Abstraction of PIResource.
137  */
138 typedef struct
139 {
140     PIResourceBase header;
141     char * eui;
142     char * nodeId;
143     char * endpointId;
144     char * clusterId;
145 } PIResource_Zigbee;
146
147 #ifdef __cplusplus
148 }
149 #endif // __cplusplus
150
151 #endif /* PLUGINTRANSLATORTYPES_H_ */