123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466 |
- #include "ZComDef.h"
- #include "OSAL.h"
- #include "zcl.h"
- #include "zcl_general.h"
- #include "zcl_ms.h"
- #if defined ( INTER_PAN )
- #include "stub_aps.h"
- #endif
- typedef struct zclMSCBRec
- {
- struct zclMSCBRec *next;
- uint8 endpoint;
- zclMS_AppCallbacks_t *CBs;
- } zclMSCBRec_t;
- static zclMSCBRec_t *zclMSCBs = (zclMSCBRec_t *)NULL;
- static uint8 zclMSPluginRegisted = FALSE;
- static ZStatus_t zclMS_HdlIncoming( zclIncoming_t *pInMsg );
- static ZStatus_t zclMS_HdlInSpecificCommands( zclIncoming_t *pInMsg );
- static zclMS_AppCallbacks_t *zclMS_FindCallbacks( uint8 endpoint );
- static ZStatus_t zclMS_ProcessIn_IlluminanceMeasurementCmds( zclIncoming_t *pInMsg );
- static ZStatus_t zclMS_ProcessIn_IlluminanceLevelSensingCmds( zclIncoming_t *pInMsg );
- static ZStatus_t zclMS_ProcessIn_TemperatureMeasurementCmds( zclIncoming_t *pInMsg );
- static ZStatus_t zclMS_ProcessIn_PressureMeasurementCmds( zclIncoming_t *pInMsg );
- static ZStatus_t zclMS_ProcessIn_FlowMeasurementCmds( zclIncoming_t *pInMsg );
- static ZStatus_t zclMS_ProcessIn_RelativeHumidityCmds( zclIncoming_t *pInMsg );
- static ZStatus_t zclMS_ProcessIn_OccupancySensingCmds( zclIncoming_t *pInMsg );
- ZStatus_t zclMS_RegisterCmdCallbacks( uint8 endpoint, zclMS_AppCallbacks_t *callbacks )
- {
- zclMSCBRec_t *pNewItem;
- zclMSCBRec_t *pLoop;
-
- if ( !zclMSPluginRegisted )
- {
- zcl_registerPlugin( ZCL_CLUSTER_ID_MS_ILLUMINANCE_MEASUREMENT,
- ZCL_CLUSTER_ID_MS_OCCUPANCY_SENSING,
- zclMS_HdlIncoming );
- zclMSPluginRegisted = TRUE;
- }
-
- pNewItem = osal_mem_alloc( sizeof( zclMSCBRec_t ) );
- if ( pNewItem == NULL )
- return (ZMemError);
- pNewItem->next = (zclMSCBRec_t *)NULL;
- pNewItem->endpoint = endpoint;
- pNewItem->CBs = callbacks;
-
- if ( zclMSCBs == NULL )
- {
- zclMSCBs = pNewItem;
- }
- else
- {
-
- pLoop = zclMSCBs;
- while ( pLoop->next != NULL )
- pLoop = pLoop->next;
-
- pLoop->next = pNewItem;
- }
- return ( ZSuccess );
- }
- static zclMS_AppCallbacks_t *zclMS_FindCallbacks( uint8 endpoint )
- {
- zclMSCBRec_t *pCBs;
-
- pCBs = zclMSCBs;
- while ( pCBs )
- {
- if ( pCBs->endpoint == endpoint )
- return ( pCBs->CBs );
- pCBs = pCBs->next;
- }
- return ( (zclMS_AppCallbacks_t *)NULL );
- }
- static ZStatus_t zclMS_HdlIncoming( zclIncoming_t *pInMsg )
- {
- ZStatus_t stat = ZSuccess;
- #if defined ( INTER_PAN )
- if ( StubAPS_InterPan( pInMsg->msg->srcAddr.panId, pInMsg->msg->srcAddr.endPoint ) )
- return ( stat );
- #endif
- if ( zcl_ClusterCmd( pInMsg->hdr.fc.type ) )
- {
-
- if ( pInMsg->hdr.fc.manuSpecific == 0 )
- {
- stat = zclMS_HdlInSpecificCommands( pInMsg );
- }
- else
- {
-
- stat = ZFailure;
- }
- }
- else
- {
-
- stat = ZFailure;
- }
- return ( stat );
- }
- static ZStatus_t zclMS_HdlInSpecificCommands( zclIncoming_t *pInMsg )
- {
- ZStatus_t stat = ZSuccess;
- zclMS_AppCallbacks_t *pCBs;
-
-
- pCBs = (void*)zclMS_FindCallbacks( pInMsg->msg->endPoint );
- if ( pCBs == NULL )
- return ( ZFailure );
-
- switch ( pInMsg->msg->clusterId )
- {
- case ZCL_CLUSTER_ID_MS_ILLUMINANCE_MEASUREMENT:
- stat = zclMS_ProcessIn_IlluminanceMeasurementCmds( pInMsg );
- break;
- case ZCL_CLUSTER_ID_MS_ILLUMINANCE_LEVEL_SENSING_CONFIG:
- stat = zclMS_ProcessIn_IlluminanceLevelSensingCmds( pInMsg );
- break;
- case ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT:
- stat = zclMS_ProcessIn_TemperatureMeasurementCmds( pInMsg );
- break;
- case ZCL_CLUSTER_ID_MS_PRESSURE_MEASUREMENT:
- stat = zclMS_ProcessIn_PressureMeasurementCmds( pInMsg );
- break;
- case ZCL_CLUSTER_ID_MS_FLOW_MEASUREMENT:
- stat = zclMS_ProcessIn_FlowMeasurementCmds( pInMsg );
- break;
- case ZCL_CLUSTER_ID_MS_RELATIVE_HUMIDITY:
- stat = zclMS_ProcessIn_RelativeHumidityCmds( pInMsg );
- break;
-
- case ZCL_CLUSTER_ID_MS_OCCUPANCY_SENSING:
- stat = zclMS_ProcessIn_OccupancySensingCmds( pInMsg );
- break;
- default:
- stat = ZFailure;
- break;
- }
- return ( stat );
- }
- static ZStatus_t zclMS_ProcessIn_IlluminanceMeasurementCmds( zclIncoming_t *pInMsg )
- {
- ZStatus_t stat = ZFailure;
-
-
-
- (void)pInMsg;
- if ( stat != ZFailure )
- zclMS_FindCallbacks( 0 );
- return ( stat );
- }
- static ZStatus_t zclMS_ProcessIn_IlluminanceLevelSensingCmds( zclIncoming_t *pInMsg )
- {
- ZStatus_t stat = ZSuccess;
- uint8 cmdID;
- cmdID = pInMsg->hdr.commandID;
- switch ( cmdID )
- {
- default:
- stat = ZFailure;
- break;
- }
- return ( stat );
- }
- static ZStatus_t zclMS_ProcessIn_TemperatureMeasurementCmds( zclIncoming_t *pInMsg )
- {
- ZStatus_t stat = ZSuccess;
- uint8 cmdID;
- cmdID = pInMsg->hdr.commandID;
- switch ( cmdID )
- {
- default:
- stat = ZFailure;
- break;
- }
- return ( stat );
- }
- static ZStatus_t zclMS_ProcessIn_PressureMeasurementCmds( zclIncoming_t *pInMsg )
- {
- ZStatus_t stat = ZSuccess;
- uint8 cmdID;
- cmdID = pInMsg->hdr.commandID;
- switch ( cmdID )
- {
- default:
- stat = ZFailure;
- break;
- }
- return ( stat );
- }
- static ZStatus_t zclMS_ProcessIn_FlowMeasurementCmds( zclIncoming_t *pInMsg )
- {
- ZStatus_t stat = ZSuccess;
- uint8 cmdID;
- cmdID = pInMsg->hdr.commandID;
- switch ( cmdID )
- {
- default:
- stat = ZFailure;
- break;
- }
- return ( stat );
- }
- static ZStatus_t zclMS_ProcessIn_RelativeHumidityCmds( zclIncoming_t *pInMsg )
- {
- ZStatus_t stat = ZSuccess;
- uint8 cmdID;
- cmdID = pInMsg->hdr.commandID;
- switch ( cmdID )
- {
- default:
- stat = ZFailure;
- break;
- }
- return ( stat );
- }
- static ZStatus_t zclMS_ProcessIn_OccupancySensingCmds( zclIncoming_t *pInMsg )
- {
- ZStatus_t stat = ZSuccess;
- uint8 cmdID;
- cmdID = pInMsg->hdr.commandID;
- switch ( cmdID )
- {
- default:
- stat = ZFailure;
- break;
- }
- return ( stat );
- }
|