/********************************************************************* * @fn zclCC_RegisterCmdCallbacks * * @brief Register an applications command callbacks * * @param endpoint - application's endpoint * @param callbacks - pointer to the callback record. * * @return ZSuccess if successful. ZMemError if not able to allocate */ ZStatus_t zclCC_RegisterCmdCallbacks( uint8 endpoint, zclCC_AppCallbacks_t *callbacks ) { zclCCCBRec_t *pNewItem; zclCCCBRec_t *pLoop; // Register as a ZCL Plugin if ( !zclCCPluginRegisted ) { zcl_registerPlugin( ZCL_CLUSTER_ID_GEN_COMMISSIONING, ZCL_CLUSTER_ID_GEN_COMMISSIONING, zclCC_HdlIncoming ); zclCCPluginRegisted = TRUE; } // Fill in the new profile list pNewItem = osal_mem_alloc( sizeof( zclCCCBRec_t ) ); if ( pNewItem == NULL ) { return ( ZMemError ); } pNewItem->next = (zclCCCBRec_t *)NULL; pNewItem->endpoint = endpoint; pNewItem->CBs = callbacks; // Find spot in list if ( zclCCCBs == NULL ) { zclCCCBs = pNewItem; } else { // Look for end of list pLoop = zclCCCBs; while ( pLoop->next != NULL ) { pLoop = pLoop->next; } // Put new item at end of list pLoop->next = pNewItem; } return ( ZSuccess ); }
/********************************************************************* * @fn zclElectricalMeasurement_RegisterCmdCallbacks * * @brief Register applications command callbacks * * @param endpoint - application's endpoint * @param callbacks - pointer to the callback record. * * @return ZMemError if not able to allocate */ ZStatus_t zclElectricalMeasurement_RegisterCmdCallbacks( uint8 endpoint, zclElectricalMeasurement_AppCallbacks_t *callbacks ) { zclElectricalMeasurementCBRec_t *pNewItem; zclElectricalMeasurementCBRec_t *pLoop; // Register as a ZCL Plugin if ( zclElectricalMeasurementPluginRegisted == FALSE ) { zcl_registerPlugin( ZCL_CLUSTER_ID_HA_ELECTRICAL_MEASUREMENT, ZCL_CLUSTER_ID_HA_ELECTRICAL_MEASUREMENT, zclElectricalMeasurement_HdlIncoming ); zclElectricalMeasurementPluginRegisted = TRUE; } // Fill in the new profile list pNewItem = zcl_mem_alloc( sizeof( zclElectricalMeasurementCBRec_t ) ); if ( pNewItem == NULL ) { return ( ZMemError ); } pNewItem->next = (zclElectricalMeasurementCBRec_t *)NULL; pNewItem->endpoint = endpoint; pNewItem->CBs = callbacks; // Find spot in list if ( zclElectricalMeasurementCBs == NULL ) { zclElectricalMeasurementCBs = pNewItem; } else { // Look for end of list pLoop = zclElectricalMeasurementCBs; while ( pLoop->next != NULL ) pLoop = pLoop->next; // Put new item at end of list pLoop->next = pNewItem; } return ( ZSuccess ); }
/********************************************************************* * @fn zclApplianceStatistics_RegisterCmdCallbacks * * @brief Register applications command callbacks * * @param endpoint - application's endpoint * @param callbacks - pointer to the callback record. * * @return ZMemError if not able to allocate */ ZStatus_t zclApplianceStatistics_RegisterCmdCallbacks( uint8 endpoint, zclApplianceStatistics_AppCallbacks_t *callbacks ) { zclApplianceStatisticsCBRec_t *pNewItem; zclApplianceStatisticsCBRec_t *pLoop; // Register as a ZCL Plugin if ( zclApplianceStatisticsPluginRegisted == FALSE ) { zcl_registerPlugin( ZCL_CLUSTER_ID_HA_APPLIANCE_STATISTICS, ZCL_CLUSTER_ID_HA_APPLIANCE_STATISTICS, zclApplianceStatistics_HdlIncoming ); zclApplianceStatisticsPluginRegisted = TRUE; } // Fill in the new profile list pNewItem = zcl_mem_alloc( sizeof( zclApplianceStatisticsCBRec_t ) ); if ( pNewItem == NULL ) { return ( ZMemError ); } pNewItem->next = (zclApplianceStatisticsCBRec_t *)NULL; pNewItem->endpoint = endpoint; pNewItem->CBs = callbacks; // Find spot in list if ( zclApplianceStatisticsCBs == NULL ) { zclApplianceStatisticsCBs = pNewItem; } else { // Look for end of list pLoop = zclApplianceStatisticsCBs; while ( pLoop->next != NULL ) pLoop = pLoop->next; // Put new item at end of list pLoop->next = pNewItem; } return ( ZSuccess ); }
/********************************************************************* * @fn zclPartition_RegisterCmdCallbacks * * @brief Register applications command callbacks * * @param endpoint - application's endpoint * @param callbacks - pointer to the callback record. * * @return ZMemError if not able to allocate */ ZStatus_t zclPartition_RegisterCmdCallbacks( uint8 endpoint, zclPartition_AppCallbacks_t *callbacks ) { zclPartitionCBRec_t *pNewItem; zclPartitionCBRec_t *pLoop; // Register as a ZCL Plugin if ( zclPartitionPluginRegisted == FALSE ) { zcl_registerPlugin( ZCL_CLUSTER_ID_GEN_PARTITION, ZCL_CLUSTER_ID_GEN_PARTITION, zclPartition_HdlIncoming ); zclPartitionPluginRegisted = TRUE; } // Fill in the new profile list pNewItem = zcl_mem_alloc( sizeof( zclPartitionCBRec_t ) ); if ( pNewItem == NULL ) { return ( ZMemError ); // memory error } pNewItem->next = (zclPartitionCBRec_t *)NULL; pNewItem->endpoint = endpoint; pNewItem->CBs = callbacks; // Find spot in list if ( zclPartitionCBs == NULL ) { zclPartitionCBs = pNewItem; } else { // Look for end of list pLoop = zclPartitionCBs; while ( pLoop->next != NULL ) pLoop = pLoop->next; // Put new item at end of list pLoop->next = pNewItem; } return ( ZSuccess ); }
/********************************************************************* * @fn zclLighting_RegisterCmdCallbacks * * @brief Register an applications command callbacks * * @param endpoint - application's endpoint * @param callbacks - pointer to the callback record. * * @return ZMemError if not able to allocate */ ZStatus_t zclLighting_RegisterCmdCallbacks( uint8 endpoint, zclLighting_AppCallbacks_t *callbacks ) { zclLightingCBRec_t *pNewItem; zclLightingCBRec_t *pLoop; // Register as a ZCL Plugin if ( zclLightingPluginRegisted == FALSE ) { zcl_registerPlugin( ZCL_CLUSTER_ID_LIGHTING_COLOR_CONTROL, ZCL_CLUSTER_ID_LIGHTING_BALLAST_CONFIG, zclLighting_HdlIncoming ); zclLightingPluginRegisted = TRUE; } // Fill in the new profile list pNewItem = osal_mem_alloc( sizeof( zclLightingCBRec_t ) ); if ( pNewItem == NULL ) return (ZMemError); pNewItem->next = (zclLightingCBRec_t *)NULL; pNewItem->endpoint = endpoint; pNewItem->CBs = callbacks; // Find spot in list if ( zclLightingCBs == NULL ) { zclLightingCBs = pNewItem; } else { // Look for end of list pLoop = zclLightingCBs; while ( pLoop->next != NULL ) pLoop = pLoop->next; // Put new item at end of list pLoop->next = pNewItem; } return ( ZSuccess ); }
/********************************************************************* * @fn zclMS_RegisterCmdCallbacks * * @brief Register an applications command callbacks * * @param endpoint - application's endpoint * @param callbacks - pointer to the callback record. * * @return ZMemError if not able to allocate */ ZStatus_t zclMS_RegisterCmdCallbacks( uint8 endpoint, zclMS_AppCallbacks_t *callbacks ) { zclMSCBRec_t *pNewItem; zclMSCBRec_t *pLoop; // Register as a ZCL Plugin if ( !zclMSPluginRegisted ) { zcl_registerPlugin( ZCL_MS_LOGICAL_CLUSTER_ID_ILLUMINANCE_MEASUREMENT, ZCL_MS_LOGICAL_CLUSTER_ID_OCCUPANCY_SENSING, zclMS_HdlIncoming ); zclMSPluginRegisted = TRUE; } // Fill in the new profile list pNewItem = osal_mem_alloc( sizeof( zclMSCBRec_t ) ); if ( pNewItem == NULL ) return (ZMemError); pNewItem->next = (zclMSCBRec_t *)NULL; pNewItem->endpoint = endpoint; pNewItem->CBs = callbacks; // Find spot in list if ( zclMSCBs == NULL ) { zclMSCBs = pNewItem; } else { // Look for end of list pLoop = zclMSCBs; while ( pLoop->next != NULL ) pLoop = pLoop->next; // Put new item at end of list pLoop->next = pNewItem; } return ( ZSuccess ); }
void zclEnergyHarvester_Init( byte task_id ) { zclEnergyHarvester_TaskID = task_id; // This app is part of the Home Automation Profile zclHA_Init( &zclSampleLight_SimpleDesc ); // Register for a test endpoint afRegister( &testEp ); zcl_registerPlugin( ZCL_CLUSTER_ID_MS_ILLUMINANCE_MEASUREMENT, ZCL_CLUSTER_ID_MS_ALL, zclEnergyHarvester_HdlIncoming ); ZDO_RegisterForZDOMsg( zclEnergyHarvester_TaskID, End_Device_Bind_rsp ); #if DEV_TYPE == COORDINATOR ZDO_RegisterForZDOMsg( zclEnergyHarvester_TaskID, Device_annce ); #else adc_Init(); // Configure signal from off-chip timer to be wake-up signal GPIODirModeSet( GPIO_B_BASE, GPIO_PIN_3 , GPIO_DIR_MODE_IN ); // Configure deep sleep in power mode 3, woken up by off-chip timer SysCtrlDeepSleepSetting(); SysCtrlPowerModeSet( SYS_CTRL_PM_3 ); GPIODirModeSet( GPIO_B_BASE, GPIO_PIN_4 , GPIO_DIR_MODE_IN ); HWREG( SYS_CTRL_IWE ) = 0x02; GPIOPowIntTypeSet( GPIO_B_BASE, GPIO_PIN_4, GPIO_POW_RISING_EDGE ); GPIOPowIntClear( GPIO_B_BASE, GPIO_PIN_4 ); GPIOPowIntEnable( GPIO_B_BASE, GPIO_PIN_4 ); // Done with off-chip timer acknowledge GPIOPinWrite( GPIO_B_BASE, GPIO_PIN_5, GPIO_PIN_5 ); #endif }