static const char* OIC_ON_OFF_ATTRIBUTE = "value";
static const char* OIC_COLOUR_TEMPERATURE_ATTRIBUTE = "colourspacevalue";
-PIPlugin_Zigbee ** gPlugin = NULL;
-
typedef enum
{
ZB_NULL, // No Data
AttributeList *attributeList,
OCRepPayload *payload);
-const char * getResourceTypeForIASZoneType(TWDevice *device)
+const char * getResourceTypeForIASZoneType(TWDevice *device, PIPluginBase* plugin)
{
if (!device)
{
ZB_IAS_ZONE_TYPE_ATTRIBUTE_ID,
&IASZoneType,
&length,
- *gPlugin
+ (PIPlugin_Zigbee*)plugin
);
if (ret != OC_STACK_OK || !IASZoneType)
return OC_STACK_NO_MEMORY;
}
-void foundZigbeeCallback(TWDevice *device)
+void foundZigbeeCallback(TWDevice *device, PIPlugin_Zigbee* plugin)
{
if (!device)
{
OC_LOG(ERROR, TAG, "Out of memory");
return;
}
- piResource->header.plugin = (PIPluginBase *)gPlugin;
+ piResource->header.plugin = (PIPluginBase *)plugin;
OCStackResult result = buildURI(&piResource->header.piResource.uri,
PI_ZIGBEE_PREFIX,
if (strcmp(foundClusterID, ZB_IAS_ZONE_CLUSTER) == 0)
{
piResource->header.piResource.resourceTypeName
- = getResourceTypeForIASZoneType(device);
+ = getResourceTypeForIASZoneType (device, (PIPluginBase *)plugin);
OCStackResult ret = TWListenForStatusUpdates(device->nodeId,
device->endpointOfInterest->endpointId,
- *gPlugin);
+ plugin);
if (ret != OC_STACK_OK)
{
piResource->endpointId = OICStrdup(device->endpointOfInterest->endpointId);
piResource->clusterId =
OICStrdup(device->endpointOfInterest->clusterList->clusterIds[i].clusterId);
- (*gPlugin)->header.NewResourceFoundCB(&(*gPlugin)->header, &piResource->header);
+ plugin->header.NewResourceFoundCB(&(plugin)->header, &piResource->header);
}
}
-void zigbeeZoneStatusUpdate(TWUpdate * update)
+void zigbeeZoneStatusUpdate(TWUpdate * update, PIPlugin_Zigbee* plugin)
{
if (!update)
{
return;
}
- (*gPlugin)->header.ObserveNotificationUpdate((PIPluginBase *)*gPlugin, uri);
+ plugin->header.ObserveNotificationUpdate((PIPluginBase *)plugin, uri);
OICFree(uri);
}
((*plugin)->header).resourceList = NULL;
((*plugin)->header).processEHRequest = ProcessEHRequest;
- gPlugin = plugin;
- OCStackResult result = TWInitialize(*gPlugin, comPort);
+ OCStackResult result = TWInitialize(*plugin, comPort);
if (result != OC_STACK_OK)
{
return result;
}
- return TWSetStatusUpdateCallback(zigbeeZoneStatusUpdate, *gPlugin);
+ return TWSetStatusUpdateCallback(zigbeeZoneStatusUpdate, *plugin);
}
OCStackResult ZigbeeDiscover(PIPlugin_Zigbee * plugin)
attributeList.list[i].zigBeeAttribute,
&outVal,
&outValLength,
- *gPlugin);
+ (PIPlugin_Zigbee *)plugin);
if (stackResult != OC_STACK_OK || !outVal)
{
char eui[SIZE_EUI];
} TWEnrollee;
-typedef void (*TWDeviceFoundCallback)(TWDevice* device);
-typedef void (*TWEnrollmentSucceedCallback)(TWEnrollee* enrollee);
-typedef void (*TWDeviceStatusUpdateCallback)(TWUpdate* update);
-typedef void (*TWDeviceNodeIdChangedCallback)(const char* eui, const char* nodeId);
+typedef void (*TWDeviceFoundCallback)(TWDevice* device, PIPlugin_Zigbee* plugin);
+typedef void (*TWEnrollmentSucceedCallback)(TWEnrollee* enrollee, PIPlugin_Zigbee* plugin);
+typedef void (*TWDeviceStatusUpdateCallback)(TWUpdate* update, PIPlugin_Zigbee* plugin);
+typedef void (*TWDeviceNodeIdChangedCallback)(const char* eui, const char* nodeId,
+ PIPlugin_Zigbee* plugin);
/**
*
if (ctx->g_DeviceFoundCallback != NULL)
{
OC_LOG(INFO, TAG, "Found a match node -- invoke callback");
- ctx->g_DeviceFoundCallback(ctx->g_WIPDevice);
+ ctx->g_DeviceFoundCallback(ctx->g_WIPDevice, ctx->g_plugin);
}
ret = TW_RESULT_OK;
}
if (ctx->g_EndDeviceNodeIdChangedCallback != NULL)
{
ctx->g_EndDeviceNodeIdChangedCallback(tokens[TOKEN_PJOIN_RESPONSE_IEEE_ADDRESS],
- tokens[TOKEN_PJOIN_RESPONSE_NODEID]);
+ tokens[TOKEN_PJOIN_RESPONSE_NODEID],
+ ctx->g_plugin);
}
ret = TW_RESULT_OK;
if (ctx->g_EnrollmentSucceedCallback != NULL)
{
OC_LOG_V(INFO, TAG, "Enrolled - Invoke callback");
- ctx->g_EnrollmentSucceedCallback(&enrollee);
+ ctx->g_EnrollmentSucceedCallback(&enrollee, ctx->g_plugin);
}
ret = TW_RESULT_OK;
if (ctx->g_DeviceStatusUpdateCallback != NULL)
{
OC_LOG(INFO, TAG, "device status update - invoke callback");
- ctx->g_DeviceStatusUpdateCallback(&update);
+ ctx->g_DeviceStatusUpdateCallback(&update, ctx->g_plugin);
OC_LOG(INFO, TAG, "device status update - callback done");
}
ret = TW_RESULT_OK;