1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //******************************************************************
25 * This file contains the definition, types and APIs for all operations
26 * required to translate plugin's respective devices to an OCResource.
29 #ifndef PLUGINTRANSLATORTYPES_H_
30 #define PLUGINTRANSLATORTYPES_H_
32 #include "plugintypes.h"
38 #define PI_ZIGBEE_PREFIX "/zb"
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.
45 struct PIResourceBase;
49 * This callback will be called when a new resource is created by radio wrapper.
52 typedef void (* PINewResourceFound)(struct PIPluginBase * plugin,
53 struct PIResourceBase *newResource);
57 * This callback will be called when a resource' representation has changed.
60 typedef void (* PIObserveNotificationUpdate)(struct PIPluginBase * plugin,
61 OCResourceHandle resourceHandle);
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.
69 typedef OCEntityHandlerResult (* PIProcessRequest) (struct PIPluginBase * plugin,
70 OCEntityHandlerRequest *ehRequest,
71 OCRepPayload **payload);
74 * Parameter list for a plugin.
76 typedef struct PIPluginBase
78 /** The type of plugin this represents. */
81 /** The file location which represents the interface of the plugin. */
84 /** Linked list of plugins. */
85 struct PIPluginBase * next;
87 /** Callback to be used when a new resource has been found. */
88 PINewResourceFound NewResourceFoundCB;
90 /** Callback to be used when an Observation update has occurred. */
91 PIObserveNotificationUpdate ObserveNotificationUpdate;
93 /** Function Pointer to be invoked upon an incoming IoTivity request. */
94 PIProcessRequest processEHRequest;
96 /** All resources which exist within the context of this plugin. */
97 struct PIResourceBase * resourceList;
99 // Any other common internal properties between plugins can be placed here.
103 * The inherite plugin type to be associated with the ZigBee radio and its
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.
115 * Parameter list for a new OCResource. This will be handed up in the
116 * PINewResource callback.
120 OCResourceHandle resourceHandle;
121 const char *resourceTypeName;
122 const char *resourceInterfaceName;
124 OCEntityHandler entityHandler;
126 uint8_t resourceProperties;
130 * Header for all PIResources.
132 typedef struct PIResourceBase
134 PIResource piResource;
135 struct PIResourceBase * next; // Linked list of resources.
136 PIPluginBase * plugin; // Context this resource exists.
141 // Todo: This needs to map nicely to a struct that's defined in Zigbee_wrapper
143 // Todo: This struct will be refactored once Zigbee_Wrapper is finished.
147 * Parameter list for a resource. Abstraction of PIResource.
151 PIResourceBase header;
160 #endif // __cplusplus
162 #endif /* PLUGINTRANSLATORTYPES_H_ */