Enable ZigBee eventing in Plugin Interface through to IoTivity.
[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 callback will be called when a resource' representation has changed.
58  *
59  */
60 typedef void (* PIObserveNotificationUpdate)(struct PIPluginBase * plugin,
61                                             const char * uri);
62
63 /**
64  *
65  * This function type is used by the radio's mapping implementation against IoTivity.
66  * The mapping implementation must implement this function to handle GET & PUT requests.
67  *
68  */
69 typedef OCEntityHandlerResult (* PIProcessRequest) (struct PIPluginBase * plugin,
70                                                     OCEntityHandlerRequest *ehRequest,
71                                                     OCRepPayload **payload);
72
73 /**
74  * Parameter list for a plugin.
75  */
76 typedef struct PIPluginBase
77 {
78     /** The type of plugin this represents. */
79     PIPluginType type;
80
81     /** The file location which represents the interface of the plugin.  */
82     const char * comPort;
83
84     /** Linked list of plugins. */
85     struct PIPluginBase * next;
86
87     /** Callback to be used when a new resource has been found. */
88     PINewResourceFound NewResourceFoundCB;
89
90     /** Callback to be used when an Observation update has occurred. */
91     PIObserveNotificationUpdate ObserveNotificationUpdate;
92
93     /** Function Pointer to be invoked upon an incoming IoTivity request. */
94     PIProcessRequest processEHRequest;
95
96     /** All resources which exist within the context of this plugin. */
97     struct PIResourceBase * resourceList;
98
99     // Any other common internal properties between plugins can be placed here.
100 } PIPluginBase;
101
102 /**
103  * The inherite plugin type to be associated with the ZigBee radio and its
104  * implementation.
105  */
106 // Note: Although ZigBee has no new members for it's Plugin Type, other radio
107 // implementations should follow this paradigm where each radio type has
108 // inherited from the PIPluginBase type.
109 typedef struct
110 {
111     PIPluginBase header;
112 } PIPlugin_Zigbee;
113
114 /**
115  * Parameter list for a new OCResource. This will be handed up in the
116  * PINewResource callback.
117  */
118 typedef struct
119 {
120     OCResourceHandle resourceHandle;
121     const char *resourceTypeName;
122     const char *resourceInterfaceName;
123     char *uri;
124     OCEntityHandler entityHandler;
125     void* callbackParam;
126     uint8_t resourceProperties;
127 } PIResource;
128
129 /**
130  *  Header for all PIResources.
131  */
132 typedef struct PIResourceBase
133 {
134     PIResource piResource;
135     struct PIResourceBase * next; // Linked list of resources.
136     PIPluginBase * plugin; // Context this resource exists.
137 } PIResourceBase;
138
139 typedef struct
140 {
141 // Todo: This needs to map nicely to a struct that's defined in Zigbee_wrapper
142     uint8_t placeholder;
143 // Todo: This struct will be refactored once Zigbee_Wrapper is finished.
144 } PIZigbeeProfile;
145
146 /**
147  * Parameter list for a resource. Abstraction of PIResource.
148  */
149 typedef struct
150 {
151     PIResourceBase header;
152     char * eui;
153     char * nodeId;
154     char * endpointId;
155     char * clusterId;
156 } PIResource_Zigbee;
157
158 #ifdef __cplusplus
159 }
160 #endif // __cplusplus
161
162 #endif /* PLUGINTRANSLATORTYPES_H_ */