/* public slots */
void ConnElement::setItemReference(ConnItemModel *model, ConnItemIndex *idx)
{
    own_model = model;
    own_index = idx;
    name = idx->getName();
    conn_Status.insert("availability", QVariant(AVAILABLE));
    conn_Status.insert("isRunning", QVariant(CLOSED));
    conn_Status.insert("initName", QVariant(name));
    idx->setData(conn_Status);
    settings.beginGroup("Connects");
    settings.beginGroup(name);
    bool atStart = settings.value("AtStart", QVariant(false)).toBool();
    settings.endGroup();
    settings.endGroup();
    buildURI();
    if ( atStart ) openConnection();
}
Esempio n. 2
0
void zigbeeZoneStatusUpdate(TWUpdate * update)
{
    if(!update)
    {
        return;
    }

    char * uri = NULL;
    OCStackResult result = buildURI(&uri,
                                    PI_ZIGBEE_PREFIX,
                                    update->nodeId,
                                    update->endpoint,
                                    ZB_IAS_ZONE_CLUSTER);
    if(result != OC_STACK_OK || !uri)
    {
        OC_LOG_V(ERROR, TAG, "Failed to build URI with result: %d", result);
        return;
    }

    (*gPlugin)->header.ObserveNotificationUpdate((PIPluginBase *)*gPlugin, uri);
    OICFree(uri);
}
Esempio n. 3
0
void foundZigbeeCallback(TWDevice *device)
{
    if(!device)
    {
        OC_LOG(ERROR, TAG, "foundZigbeeCallback: Invalid parameter.");
        return;
    }
    int count = device->endpointOfInterest->clusterList->count;
    for(int i=0; i < count; i++)
    {
        PIResource_Zigbee *piResource = (PIResource_Zigbee *) OICMalloc(sizeof(*piResource));
        if (!piResource)
        {
            OC_LOG (ERROR, TAG, "Out of memory");
            return;
        }
        piResource->header.plugin = (PIPluginBase *)gPlugin;

        OCStackResult result = buildURI(&piResource->header.piResource.uri,
                                PI_ZIGBEE_PREFIX,
                                device->nodeId,
                                device->endpointOfInterest->endpointId,
                                device->endpointOfInterest->clusterList->clusterIds[i].clusterId);

        if(result != OC_STACK_OK)
        {
            OICFree(piResource);
            return;
        }

        char * foundClusterID =
            device->endpointOfInterest->clusterList->clusterIds[i].clusterId;

        if (strcmp (foundClusterID, ZB_IAS_ZONE_CLUSTER) == 0)
        {
            piResource->header.piResource.resourceTypeName
                = getResourceTypeForIASZoneType (device);

            OCStackResult ret = TWListenForStatusUpdates (device->nodeId,
                                      device->endpointOfInterest->endpointId);

            if (ret != OC_STACK_OK)
            {
                // Just log it and move on if this fails?
                // or not create this resource at all?
                OC_LOG (ERROR, TAG, "Command to listen for status updates failed");
            }
        }
        else
        {
            piResource->header.piResource.resourceTypeName =
                    (char *) ZigBeeClusterIDToOICResourceType(foundClusterID);
        }

        if(piResource->header.piResource.resourceTypeName == NULL)
        {
            OC_LOG_V (ERROR, TAG, "unsupported clusterId : %s",
                device->endpointOfInterest->clusterList->clusterIds[i].clusterId);
            OICFree(piResource->header.piResource.uri);
            OICFree(piResource);
            continue;
        }
        piResource->header.piResource.resourceInterfaceName =
                            OC_RSRVD_INTERFACE_DEFAULT;

        piResource->header.piResource.callbackParam = NULL;
        piResource->header.piResource.resourceProperties = 0;
        piResource->eui = OICStrdup(device->eui);
        piResource->nodeId = OICStrdup(device->nodeId);
        piResource->endpointId = OICStrdup(device->endpointOfInterest->endpointId);
        piResource->clusterId =
            OICStrdup(device->endpointOfInterest->clusterList->clusterIds[i].clusterId);
        (*gPlugin)->header.NewResourceFoundCB(&(*gPlugin)->header, &piResource->header);
    }
}