/*******************************************************************************
 * @fn      zclSS_Send_IAS_ACE_GetZoneInformationResponseCmd
 *
 * @brief   Call to send out Get Zone Information Response Cmd (IAS ACE Cluster)
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   zoneID - 8 bit value from 0 to 255
 * @param   zoneType - 16 bit
 * @param   ieeeAddress - pointer to 64 bit address ( 8bytes*8)
 *
 * @return  ZStatus_t
 */
ZStatus_t zclSS_Send_IAS_ACE_GetZoneInformationResponseCmd( uint8 srcEP, afAddrType_t *dstAddr,
        uint8 zoneID, uint16 zoneType, uint8 *ieeeAddress,
        uint8 disableDefaultRsp, uint8 seqNum )
{
    uint8 *buf;
    uint8 len = 11; // zoneID (1) + zoneType (2) + zoneAddress (8)
    ZStatus_t stat;

    buf = osal_mem_alloc( len );

    if ( buf )
    {
        buf[0] = zoneID;
        buf[1] = LO_UINT16( zoneType);
        buf[2] = HI_UINT16( zoneType);
        osal_cpyExtAddr( &buf[3], ieeeAddress );

        stat = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SS_IAS_ACE,
                                COMMAND_SS_IAS_ACE_GET_ZONE_INFORMATION_RESPONSE, TRUE,
                                ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0, seqNum, len, buf );
        osal_mem_free( buf );
    }
    else
        stat = ZMemError;

    return ( stat );
}
Ejemplo n.º 2
0
/*******************************************************************************
 * @fn      zclPI_Send_MatchProtocolAddrRsp
 *
 * @brief   Call to send out a Match Protocol Address Response. This response
 *          is sent back upon receipt of a Match Protocol Address command to
 *          indicate that the Protocol Address was successfully matched.
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   ieeeAddr - device address
 * @param   len - length of protocol address
 * @param   protocolAddr - protocol address
 * @param   disableDefaultRsp - whether to disable the Default Response command
 * @param   seqNum - sequence number
 *
 * @return  ZStatus_t
 */
ZStatus_t zclPI_Send_MatchProtocolAddrRsp( uint8 srcEP, afAddrType_t *dstAddr,
                                           uint8 *ieeeAddr, uint8 len, uint8 *protocolAddr, 
                                           uint8 disableDefaultRsp, uint8 seqNum )
{
  uint8 *buf;
  uint8 msgLen = Z_EXTADDR_LEN + 1 + len; // IEEE Address + 1 for length field
  ZStatus_t stat;

  buf = osal_mem_alloc( msgLen ); // 1 for length field
  if ( buf )
  {
    // Copy over IEEE Address
    osal_cpyExtAddr( buf, ieeeAddr );

    // Copy over Protocol Address
    buf[8] = len;
    osal_memcpy( &(buf[9]), protocolAddr, len );

    stat = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_PI_GENERIC_TUNNEL,
                            COMMAND_PI_GENERIC_TUNNEL_MATCH_PROTOCOL_ADDR_RSP, TRUE, 
                            ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0, seqNum,
                            msgLen, buf );
    osal_mem_free( buf );
  }
  else
  {
    stat = ZMemError;
  }
  
  return ( stat );
}
Ejemplo n.º 3
0
/*******************************************************************************
 * @fn      zclPI_Send_AdvertiseProtocolAddrCmd
 *
 * @brief   Call to send out an Advertise Protocol Address Command. This command
 *          is sent out typically upon startup or whenever the Protocol Address
 *          attribute changes. It is typically multicast to a group of inter-
 *          communicating Generic Tunnel clusters.
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   len - length of protocol address
 * @param   protocolAddr - protocol address
 * @param   disableDefaultRsp - whether to disable the Default Response command
 * @param   seqNum - sequence number
 *
 * @return  ZStatus_t
 */
ZStatus_t zclPI_Send_AdvertiseProtocolAddrCmd( uint8 srcEP, afAddrType_t *dstAddr,
                                               uint8 len, uint8 *protocolAddr, 
                                               uint8 disableDefaultRsp, uint8 seqNum )
{
  uint8 *buf;
  ZStatus_t stat;

  buf = osal_mem_alloc( len+1 ); // 1 for length field
  if ( buf )
  {  
    buf[0] = len;
    osal_memcpy( &(buf[1]), protocolAddr, len );

    stat = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_PI_GENERIC_TUNNEL,
                            COMMAND_PI_GENERIC_TUNNEL_ADVERTISE_PROTOCOL_ADDR, TRUE, 
                            ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0, seqNum,
                            (len+1), buf );
    osal_mem_free( buf );
  }
  else
  {
    stat = ZMemError;
  }
  
  return ( stat );
}
Ejemplo n.º 4
0
/*******************************************************************************
 * @fn      zclPI_Send_11073TransferAPDUCmd
 *
 * @brief   Call to send out an 11073 Transfer APDU Command. This command is 
 *          used when an 11073 network layer wishes to transfer an 11073 APDU 
 *          across a ZigBee tunnel to another 11073 network layer.
 *
 *          The most stringent reliability characteristic of a given transport
 *          technology is “Best” reliability. Note - For ZigBee, this corresponds
 *          to use of APS-ACKs.
 *
 *          The least stringent reliability characteristic of a given transport
 *          technology is “Good” reliability. Note - For ZigBee, this corresponds
 *          to no use of APS-ACKs.
 *
 *          Note: This command shall always be transmitted with the Disable Default 
 *          Response bit in the ZCL frame control field set to 1.
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   len - length of APDU
 * @param   apdu - APDU to be sent
 * @param   seqNum - sequence number
 *
 * @return  ZStatus_t
 */
ZStatus_t zclPI_Send_11073TransferAPDUCmd( uint8 srcEP, afAddrType_t *dstAddr,
                                           uint16 len, uint8 *apdu, uint8 seqNum )
{
  uint8 *buf;
  ZStatus_t stat;

  buf = osal_mem_alloc( len+2 ); // 2 for length field (long octet string)
  if ( buf )
  {  
    buf[0] = LO_UINT16( len );
    buf[1] = HI_UINT16( len );
    osal_memcpy( &(buf[2]), apdu, len );

    // This command shall always be transmitted with the Disable Default 
    // Response bit in the ZCL frame control field set to 1.
    stat = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_PI_11073_PROTOCOL_TUNNEL,
                            COMMAND_PI_11073_TUNNEL_TRANSFER_APDU, TRUE, 
                            ZCL_FRAME_CLIENT_SERVER_DIR, TRUE, 0, seqNum, (len+2), buf );
    osal_mem_free( buf );
  }
  else
  {
    stat = ZMemError;
  }
  
  return ( stat );
}
/*********************************************************************
 * @fn      zclSS_Send_IAS_ACE_GetZoneIDMapResponseCmd
 *
 * @brief   Call to send out a Get Zone ID Map Response Cmd  ( IAS ACE Cluster )
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   zoneIDMap - pointer to an array of 16 uint16
 *
 * @return  ZStatus_t
 */
ZStatus_t zclSS_Send_IAS_ACE_GetZoneIDMapResponseCmd( uint8 srcEP, afAddrType_t *dstAddr,
        uint16 *zoneIDMap, uint8 disableDefaultRsp, uint8 seqNum )
{
    uint8 *buf;
    uint8 *pIndex;
    uint8 j,len = 32;
    ZStatus_t stat;

    buf = osal_mem_alloc( len );

    if ( buf )
    {
        pIndex = buf;

        for( j = 0; j < 16; j++ )
        {
            *pIndex++  = LO_UINT16( *zoneIDMap   );
            *pIndex++  = HI_UINT16( *zoneIDMap++ );
        }

        stat = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SS_IAS_ACE,
                                COMMAND_SS_IAS_ACE_GET_ZONE_ID_MAP_RESPONSE, TRUE,
                                ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0, seqNum, len, buf );
        osal_mem_free( buf );
    }
    else
        stat = ZMemError;

    return ( stat );

}
/*********************************************************************
 * @fn      zclSS_Send_IAS_ACE_BypassCmd
 *
 * @brief   Call to send out a Bypass Command  ( IAS ACE Cluster )
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   numberOfZones - one byte
 * @param   bypassBuf - zone IDs array of 256 entries one byte each
 *
 * @return  ZStatus_t
 */
ZStatus_t zclSS_Send_IAS_ACE_BypassCmd( uint8 srcEP, afAddrType_t *dstAddr,
                                        uint8 numberOfZones, uint8 *bypassBuf,
                                        uint8 disableDefaultRsp, uint8 seqNum )
{
    uint8 *buf;
    uint8 *pBuf;
    uint8 len = 1 + numberOfZones;
    ZStatus_t stat;

    buf = osal_mem_alloc( len );
    if ( buf )
    {
        pBuf = buf;

        *pBuf++ = numberOfZones;
        osal_memcpy( pBuf, bypassBuf, numberOfZones );

        stat = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SS_IAS_ACE,
                                COMMAND_SS_IAS_ACE_BYPASS, TRUE,
                                ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0, seqNum, len, buf );
        osal_mem_free( buf );
    }
    else
        stat = ZFailure;

    return ( stat );
}
Ejemplo n.º 7
0
/*******************************************************************************
 * @fn      zclPI_Send_11073ConnectReq
 *
 * @brief   Call to send out an 11073 Connect Request Command. This command
 *          is generated when a Data Management device wishes to connect to
 *          an 11073 agent device. This may be in response to receiving a 
 *          connect status notification command from that agent device with
 *          the connect status field set to RECONNECT_REQUEST.
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   connectCtrl - connect control
 * @param   idleTimeout - inactivity time (in minutes) which Data Management device
 *                        will wait w/o receiving any data before it disconnects
 * @param   managerAddr - IEEE address (64-bit) of Data Management device 
 *                        transmitting this frame
 * @param   managerEP - source endpoint from which Data Management device is
                        transmitting this frame
 * @param   disableDefaultRsp - whether to disable the Default Response command
 * @param   seqNum - sequence number
 *
 * @return  ZStatus_t
 */
ZStatus_t zclPI_Send_11073ConnectReq( uint8 srcEP, afAddrType_t *dstAddr,
                                      uint8 connectCtrl, uint16 idleTimeout,
                                      uint8 *managerAddr, uint8 managerEP, 
                                      uint8 disableDefaultRsp, uint8 seqNum )
{
  uint8 *buf;
  uint8 msgLen = 1 + 2 + Z_EXTADDR_LEN + 1; // connect ctrl + idle timeout + IEEE Address + manager EP
  ZStatus_t stat;

  buf = osal_mem_alloc( msgLen );
  if ( buf )
  {
    buf[0] = connectCtrl;
    buf[1] = LO_UINT16( idleTimeout );
    buf[2] = HI_UINT16( idleTimeout );
    osal_memcpy( &(buf[3]), managerAddr, Z_EXTADDR_LEN );
    buf[11] = managerEP;

    stat = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_PI_11073_PROTOCOL_TUNNEL,
                            COMMAND_PI_11073_TUNNEL_CONNECT_REQ, TRUE, 
                            ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0, seqNum,
                            msgLen, buf );
    osal_mem_free( buf );
  }
  else
  {
    stat = ZMemError;
  }
  
  return ( stat );
}
Ejemplo n.º 8
0
/*********************************************************************
 * @fn      zclApplianceStatistics_Send_LogNotification
 *
 * @brief   Request sent to client for Log Notification.
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   pPayload:
 *          timeStamp - timestamp of the notification
 *          logID - identifies uniquely the log information contained in log payload
 *          logLength - indicates the length in bytes of log payload
 *          logPayload - variable length payload
 * @param   disableDefaultRsp - whether to disable the Default Response command
 * @param   seqNum - sequence number
 *
 * @return  ZStatus_t
 */
ZStatus_t zclApplianceStatistics_Send_LogNotification( uint8 srcEP, afAddrType_t *dstAddr,
                                                       zclCmdApplianceStatisticsLogNotificationPayload_t *pPayload,
                                                       uint8 disableDefaultRsp, uint8 seqNum )
{
  uint8 *pZclPayload;      // OTA ZCL Payload
  uint16 zclPayloadLen;
  ZStatus_t status;

  // convert from Native to OTA format
  pZclPayload = zclApplianceStatistics_LogNotification_NativeToOta( pPayload , &zclPayloadLen );
  if( !pZclPayload )
  {
    return ZFailure;  // no memory
  }

  // sent over the air
  status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_HA_APPLIANCE_STATISTICS,
                          COMMAND_APPLIANCE_STATISTICS_LOG_NOTIFICATION, TRUE,
                          ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0, seqNum, zclPayloadLen, pZclPayload );

  // done with packet
  zcl_mem_free( pZclPayload );

  return status;
}
Ejemplo n.º 9
0
static void sendGroupViewResponse( afAddrType_t *dstAddr,
                 uint8 status, aps_Group_t *grp, uint8 disableDefaultRsp ){
	uint8 *buf;
 	uint8 len;

 	len = 1 + 2; // Status + Group ID

 	if ( status == ZCL_STATUS_SUCCESS )
    	len += grp->name[0] + 1;  // String + 1 for length

 	buf = osal_mem_alloc( len );
 	if ( buf ) {
		buf[0] = status;
 		buf[1] = LO_UINT16( grp->ID );
 		buf[2] = HI_UINT16( grp->ID );

 		if ( status == ZCL_STATUS_SUCCESS ){
			buf[3] = grp->name[0]; // string length
      		osal_memcpy( &buf[4], (&grp->name[1]), grp->name[0] );
    	}

   		zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_GEN_GROUPS,
                            COMMAND_GROUP_VIEW_RSP, TRUE, ZCL_FRAME_SERVER_CLIENT_DIR,
                            disableDefaultRsp, 0, seqNum, len, buf );
    	osal_mem_free( buf );
  	}
 }
Ejemplo n.º 10
0
/*********************************************************************
 * @fn      zclClosures_WCSendProgramSetpointRequest
 *
 * @brief   Call to send out a Program Setpoint Request Command
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   cmd - Command ID for COMMAND_CLOSURES_PROGRAM_SETPOINT
 * @param   disableDefaultRsp - decides default response is necessary or not
 * @param   seqNum - sequence number of the command packet
 * @param   programSetpoint - contains payload information
 * 
 * @return  ZStatus_t
 */
ZStatus_t zclClosures_WCSendProgramSetpointRequest( uint8 srcEP, afAddrType_t *dstAddr,
                                                    uint8 cmd, uint8 disableDefaultRsp, 
                                                    uint8 seqNum, programSetpointPayload_t *programSetpoint )
{
  uint8 buf[ZCL_WC_PROGRAMSETPOINTREQ_VER1_PAYLOADLEN];
  uint8 len;
  
  if( programSetpoint->version == programSetpointVersion1 )
  {
    buf[0] = programSetpoint->setpointType;
    buf[1] = programSetpoint->setpointIndex;
    buf[2] = LO_UINT16( programSetpoint->setpointValue );
    buf[3] = HI_UINT16( programSetpoint->setpointValue );
    
    len = ZCL_WC_PROGRAMSETPOINTREQ_VER1_PAYLOADLEN;
  }
  else if( programSetpoint->version == programSetpointVersion2 )
  {
    buf[0] = programSetpoint->setpointIndex;
    
    len = ZCL_WC_PROGRAMSETPOINTREQ_VER2_PAYLOADLEN;
  }
  else
  {
    return( ZFailure );
  }
  return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_CLOSURES_WINDOW_COVERING,
                          cmd, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR,
                          disableDefaultRsp, 0, seqNum, len, buf );
}
Ejemplo n.º 11
0
/*********************************************************************
 * @fn      zclClosures_WCSimpleRequest
 *
 * @brief   Call to send out a Window Covering command with no payload 
 *          as Up/Open, Down/Close or Stop
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   cmd - Command ID
 * @param   disableDefaultRsp - decides default response is necessary or not
 * @param   seqNum - sequence number of the command packet
 * 
 * @return  ZStatus_t
 */
ZStatus_t zclClosures_WCSimpleRequest( uint8 srcEP, afAddrType_t *dstAddr,
                                       uint8 cmd, uint8 disableDefaultRsp, uint8 seqNum )
{
  return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_CLOSURES_WINDOW_COVERING,
                          cmd, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR,
                          disableDefaultRsp, 0, seqNum, 0, NULL );
}
Ejemplo n.º 12
0
/*********************************************************************
 * @fn      zclClosures_SendDoorLockRequest
 *
 * @brief   Call to send out a Door Lock/ Door Unlock Request Command
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   cmd - either COMMAND_DOOR_LOCK or COMMAND_DOOR_UNLOCK
 * @param   clusterID - cluster whose commands and attributes lock and unlock 
                        the door
 * @param   disableDefaultRsp - decides default response is necessary or not
 * @param   seqNum - sequence number of the command packet
 * 
 * @return  ZStatus_t
 */
ZStatus_t zclClosures_SendDoorLockRequest( uint8 srcEP, afAddrType_t *dstAddr,
                                       uint8 cmd, uint16 clusterID,
                                       uint8 disableDefaultRsp, uint8 seqNum )
{
  return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_CLOSURES_DOOR_LOCK,
                          cmd, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR,
                          disableDefaultRsp, 0, seqNum, 0, NULL );
}
Ejemplo n.º 13
0
/*********************************************************************
 * @fn      zclElectricalMeasurement_Send_GetProfileInfo
 *
 * @brief   Call to send out Electrical Measurement Get Profile info command from ZED to ZR/ZC. The Rsp
 *          will indicate the parameters of the device's profile.
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   disableDefaultRsp - whether to disable the Default Response command
 * @param   seqNum - sequence number
 *
 * @return  ZStatus_t
 */
ZStatus_t zclElectricalMeasurement_Send_GetProfileInfo( uint8 srcEP, afAddrType_t *dstAddr,
                                                        uint8 disableDefaultRsp, uint8 seqNum )
{
  // no paylod
  return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_HA_ELECTRICAL_MEASUREMENT,
                          COMMAND_ELECTRICAL_MEASUREMENT_GET_PROFILE_INFO, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR,
                          disableDefaultRsp, 0, seqNum, 0, NULL);
}
Ejemplo n.º 14
0
/*********************************************************************
 * @fn      zclHVAC_SendGetRelayStatusLog
 *
 * @brief   Call to send out a Get Relay Status Log Command
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   seqNum - transaction sequence number
 *
 * @return  ZStatus_t
 */
ZStatus_t zclHVAC_SendGetRelayStatusLog( uint8 srcEP, afAddrType_t *dstAddr,
                                         uint8 disableDefaultRsp, uint8 seqNum )
{
  // no payload

  return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_HVAC_THERMOSTAT,
                          COMMAND_THERMOSTAT_GET_RELAY_STATUS_LOG, TRUE,
                          ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0, seqNum, 0, 0 );
}
Ejemplo n.º 15
0
/*********************************************************************
 * @fn      zclHVAC_SendClearWeeklySchedule
 *
 * @brief   Call to send out a Clear Weekly Schedule Command
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   seqNum - transaction sequence number
 *
 * @return  ZStatus_t
 */
ZStatus_t zclHVAC_SendClearWeeklySchedule( uint8 srcEP, afAddrType_t *dstAddr,
                                           uint8 disableDefaultRsp, uint8 seqNum )
{
  // no payload

  return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_HVAC_THERMOSTAT,
                          COMMAND_THERMOSTAT_CLEAR_WEEKLY_SCHEDULE, TRUE,
                          ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0, seqNum, 0, 0 );
}
Ejemplo n.º 16
0
/*********************************************************************
 * @fn      zclPartition_Send_MultipleAck
 *
 * @brief   Call to send out Poll Control CheckIn command from ZED to ZR/ZC. The Rsp
 *          will indicate whether to stay awake or go back to sleep.
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   pCmd - multi ack response
 * @param   disableDefaultRsp - whether to disable the Default Response command
 * @param   seqNum - sequence number
 *
 * @return  ZStatus_t
 */
ZStatus_t zclPartition_Send_MultipleAck( uint8 srcEP, afAddrType_t *dstAddr,
                                         zclCmdMultipleAck_t *pCmd,
                                         uint8 disableDefaultRsp, uint8 seqNum )
{
  uint8 buflen;
  uint8 NAckSize;
  uint8 offset;
  uint8 i;
  uint8 *buf;
  ZStatus_t status;

  // determine if NACKs are 1 or 2 bytes
  if ( pCmd->options & ZCL_PARTITION_OPTIONS_NACK_16BIT )
  {
    NAckSize = 2;
  }
  else
  {
    NAckSize = 1;
  }

  // create buffer large enough for multiple ACKs command
  // ACKOptions is 1 byte, FirstFrameID and NACKIds are 1 or 2 bytes depending on options
  // [ACKOptions][FirstFrameID][NACKId]...[NACKId]
  buflen = 1 + NAckSize * ( 1 + pCmd->numNAcks );
  buf = zcl_mem_alloc( buflen );
  if ( !buf )
  {
    return ( ZMemError ); // memory error
  }

  //   fill in the buffer
  buf[0] = pCmd->options;
  offset = 1;
  buf[offset++] = LO_UINT16( pCmd->firstFrameID );
  if ( NAckSize == 2 )
  {
    buf[offset++] = HI_UINT16( pCmd->firstFrameID );
  }
  for ( i = 0; i < pCmd->numNAcks ; ++i )
  {
    buf[offset++] = LO_UINT16( pCmd->pNAckID[i] );
    if ( NAckSize == 2 )
    {
      buf[offset++] = HI_UINT16( pCmd->pNAckID[i] );
    }
  }

  // send, with payload
  status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_GEN_PARTITION,
                            COMMAND_PARTITION_MULTIPLE_ACK, TRUE, ZCL_FRAME_SERVER_CLIENT_DIR,
                            disableDefaultRsp, 0, seqNum, offset, buf);

  // done, free the memory
  zcl_mem_free( buf );
  return ( status );
}
Ejemplo n.º 17
0
/*********************************************************************
 * @fn      zclApplianceStatistics_Send_LogQueueReq
 *
 * @brief   Request sent to server for Log Queue Request.
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   disableDefaultRsp - whether to disable the Default Response command
 * @param   seqNum - sequence number
 *
 * @return  ZStatus_t
 */
ZStatus_t zclApplianceStatistics_Send_LogQueueReq( uint8 srcEP, afAddrType_t *dstAddr,
                                                          uint8 disableDefaultRsp, uint8 seqNum )
{
  // no payload

  return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_HA_APPLIANCE_STATISTICS,
                          COMMAND_APPLIANCE_STATISTICS_LOG_QUEUE_REQ, TRUE,
                          ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0, seqNum, 0, 0 );
}
Ejemplo n.º 18
0
/*********************************************************************
 * @fn      zclCC_Send_ServerParamsRsp
 *
 * @brief   Call to send out a Server Parameters Response to a client request
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   pRsp - pointer to Startup Parameter Response data structure
 * @param   cmdId - Command type ( Restore, Save or Reset)
 * @param   disableDefaultRsp - disable default response
 * @param   seqNum - ZCL sequence number
 *
 * @return  ZStatus_t
 */
ZStatus_t zclCC_Send_ServerParamsRsp( uint8 srcEP, afAddrType_t *dstAddr,
                                      zclCCServerParamsRsp_t *pRsp, uint8 cmdId,
                                      uint8 disableDefaultRsp, uint8 seqNum )
{ 
  return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_GEN_COMMISSIONING,
                          cmdId, TRUE, ZCL_FRAME_SERVER_CLIENT_DIR,
                          disableDefaultRsp, 0, seqNum, 
                          CC_PACKET_LEN_SERVER_RSP, &(pRsp->status) );
}
Ejemplo n.º 19
0
/*********************************************************************
 * @fn      zclElectricalMeasurement_Send_GetMeasurementProfileRsp
 *
 * @brief   Call to send out Electrical Measurement Get Measurement Profile Response. This will
 *          tell the client the appropriate parameters of the measurement profile.
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   pPayload:
 *          startTime - represents the end time of the most chronologically recent interval being requested
 *          status - table status enumeration lists the valid values returned in status field
 *          profileIntervalPeriod - time frame used to capture parameter for profiling purposes
 *          numberOfIntervalsDelivered - number of intervals the device is returning
 *          attributeID - attribute that has been profiled by the application
 *          intervals   - array of intervals that depend on numberOfIntervalsDelivered, type based on attributeID
 * @param   disableDefaultRsp - whether to disable the Default Response command
 * @param   seqNum - sequence number
 *
 * @return  ZStatus_t
 */
ZStatus_t zclElectricalMeasurement_Send_GetMeasurementProfileRsp( uint8 srcEP, afAddrType_t *dstAddr,
                                                                  zclElectricalMeasurementGetMeasurementProfileRsp_t *pPayload,
                                                                  uint8 disableDefaultRsp, uint8 seqNum )
{
  uint8 i;
  uint8 offset;
  uint8 *pBuf;    // variable length payload
  uint8 attrRtn;
  uint8 calculatedAttrLen;
  uint16 calculatedIntervalSize;
  uint16 calculatedBufLen;
  ZStatus_t status;
  zclAttrRec_t attrRec;

  // determine if attribute ID is found per EP and cluster ID
  attrRtn = zclFindAttrRec( dstAddr->endPoint, ZCL_CLUSTER_ID_HA_ELECTRICAL_MEASUREMENT, pPayload->attributeID, &attrRec );

  if ( attrRtn == TRUE )
  {
    // if found, determine length of attribute based on given type
    calculatedAttrLen = zclGetDataTypeLength( attrRec.attr.dataType );
  }

  calculatedIntervalSize = calculatedAttrLen * pPayload->numberOfIntervalsDelivered;

  // get a buffer large enough to hold the whole packet, including size of variable array
  calculatedBufLen = ( 9 + calculatedIntervalSize );

  pBuf = zcl_mem_alloc( calculatedBufLen );
  if ( !pBuf )
  {
    return ( ZMemError );  // no memory, return failure
  }

  pBuf[0] = BREAK_UINT32(pPayload->startTime, 0);
  pBuf[1] = BREAK_UINT32(pPayload->startTime, 1);
  pBuf[2] = BREAK_UINT32(pPayload->startTime, 2);
  pBuf[3] = BREAK_UINT32(pPayload->startTime, 3);
  pBuf[4] = pPayload->status;
  pBuf[5] = pPayload->profileIntervalPeriod;
  pBuf[6] = pPayload->numberOfIntervalsDelivered;
  pBuf[7] = LO_UINT16(pPayload->attributeID);
  pBuf[8] = HI_UINT16(pPayload->attributeID);
  offset = 9;
  for ( i = 0; i < calculatedIntervalSize; i++ )
  {
    pBuf[offset++] = pPayload->pIntervals[i];
  }

  status = zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_HA_ELECTRICAL_MEASUREMENT,
                            COMMAND_ELECTRICAL_MEASUREMENT_GET_MEASUREMENT_PROFILE_RSP, TRUE,
                            ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0, seqNum, calculatedBufLen, pBuf );
  zcl_mem_free( pBuf );

  return ( status );
}
/*******************************************************************************
 * @fn      zclSS_Send_IAS_ACE_ArmCmd
 *
 * @brief   Call to send out a Arm  Command  ( IAS ACE Cluster )
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   armMode -  value of armMode
 *
 * @return  ZStatus_t
 */
ZStatus_t zclSS_Send_IAS_ACE_ArmCmd( uint8 srcEP, afAddrType_t *dstAddr,
                                     uint8 armMode, uint8 disableDefaultRsp, uint8 seqNum )
{
    uint8 buf[1];

    buf[0] = armMode;

    return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SS_IAS_ACE,
                            COMMAND_SS_IAS_ACE_ARM, TRUE,
                            ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0, seqNum, 1, buf );
}
/*********************************************************************
 * @fn      zclSS_Send_IAS_ACE_GetZoneInformationCmd
 *
 * @brief   Call to send out a Get Zone Information Command ( IAS ACE Cluster )
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   zoneID - 8 bit value from 0 to 255
 *
 * @return  ZStatus_t
 */
ZStatus_t zclSS_Send_IAS_ACE_GetZoneInformationCmd( uint8 srcEP, afAddrType_t *dstAddr,
        uint8 zoneID, uint8 disableDefaultRsp, uint8 seqNum )
{
    uint8 buf[1];

    buf[0] = zoneID;

    return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SS_IAS_ACE,
                            COMMAND_SS_IAS_ACE_GET_ZONE_INFORMATION, TRUE,
                            ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0, seqNum, 1, buf );
}
/*******************************************************************************
 * @fn      zclSS_Send_IAS_ACE_ArmRespponse
 *
 * @brief   Call to send out a Arm Response Command ( IAS ACE Cluster )
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   armNotification
 *
 * @return  ZStatus_t
 */
ZStatus_t zclSS_Send_IAS_ACE_ArmResponse( uint8 srcEP, afAddrType_t *dstAddr,
        uint8 armNotification, uint8 disableDefaultRsp, uint8 seqNum )
{
    uint8 buf[1];

    buf[0] = armNotification;

    return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SS_IAS_ACE,
                            COMMAND_SS_IAS_ACE_ARM_RESPONSE, TRUE,
                            ZCL_FRAME_SERVER_CLIENT_DIR, disableDefaultRsp, 0, seqNum, 1, buf );
}
/******************************************************************************
 * @fn      zclSS_Send_IAS_WD_StartWarningCmd
 *
 * @brief   Call to send out a Squawk Command  ( IAS WD Cluster )
 *
 * @param   squawk - one byte of type zclCmdSSWDSquawkPayload_t
 *
 * @return  ZStatus_t
 */
ZStatus_t zclSS_Send_IAS_WD_SquawkCmd( uint8 srcEP, afAddrType_t *dstAddr,
                                       zclCmdSSWDSquawkPayload_t *squawk,
                                       uint8 disableDefaultRsp, uint8 seqNum )
{
    uint8 buf[1];
    buf[0] = squawk->squawkbyte;

    return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SS_IAS_WD,
                            COMMAND_SS_IAS_WD_SQUAWK, TRUE,
                            ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0, seqNum, 1, buf);
}
void attributeValue(osal_event_hdr_t * hdrEvent){
	ZStatus_t status;
	struct ReqAttributeMsg * reqAttributeMsg  = (struct ReqAttributeMsg *)hdrEvent;

	usbLog(0, "Send cmd ZCL_CMD_READ to %X:%x  cluster: %X numAttr: %d", reqAttributeMsg->afAddrType.addr.shortAddr, reqAttributeMsg->afAddrType.endPoint, reqAttributeMsg->cluster,reqAttributeMsg->numAttr); 

	status = zcl_SendCommand( ENDPOINT, &reqAttributeMsg->afAddrType, reqAttributeMsg->cluster, ZCL_CMD_READ, FALSE, ZCL_FRAME_CLIENT_SERVER_DIR, FALSE, 0, 0,  reqAttributeMsg->numAttr * 2, (uint8 *)reqAttributeMsg->attrID );
	if (status != ZSuccess){
		usbSendAttributeResponseMsgError(reqAttributeMsg, status);
	}

}
/*******************************************************************************
 * @fn      zclSS_IAS_Send_ZoneStatusEnrollResponseCmd
 *
 * @brief   Call to send out a Enroll Response Command
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   responseCode -  value of  response Code
 * @param   zoneID  - index to the zone table of the CIE
 *
 * @return  ZStatus_t
 */
ZStatus_t zclSS_IAS_Send_ZoneStatusEnrollResponseCmd( uint8 srcEP, afAddrType_t *dstAddr,
        uint8 responseCode, uint8 zoneID,
        uint8 disableDefaultRsp, uint8 seqNum )
{
    uint8 buf[2];

    buf[0] = responseCode;
    buf[1] = zoneID;

    return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_SS_IAS_ZONE,
                            COMMAND_SS_IAS_ZONE_STATUS_ENROLL_RESPONSE, TRUE,
                            ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0, seqNum, 2, buf );
}
Ejemplo n.º 26
0
/*********************************************************************
 * @fn      zclClosures_SendDoorLockResponse
 *
 * @brief   Call to send out a Door Lock/ Door Unlock Response Command
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   cmd - either COMMAND_DOOR_LOCK or COMMAND_DOOR_UNLOCK
 * @param   clusterID - cluster whose commands and attributes lock and unlock 
                        the door
 * @param   disableDefaultRsp - decides default response is necessary or not
 * @param   seqNum - sequence number of the command packet
 * @param   status - status of the Door Lock/ Door Unlock Request Command
 * 
 * @return  ZStatus_t
 */
ZStatus_t zclClosures_SendDoorLockResponse( uint8 srcEP, afAddrType_t *dstAddr,
                                       uint8 cmd, uint16 clusterID,
                                       uint8 disableDefaultRsp, uint8 seqNum, 
                                       uint8 status )
{
  uint8 payload[DOORLOCK_RES_PAYLOAD_LEN];
  
  payload[0] = status;
  return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_CLOSURES_DOOR_LOCK,
                          cmd, TRUE, ZCL_FRAME_SERVER_CLIENT_DIR,
                          disableDefaultRsp, 0, seqNum, 
                          DOORLOCK_RES_PAYLOAD_LEN, payload );
}
Ejemplo n.º 27
0
/*********************************************************************
 * @fn      zclLighting_ColorControl_Send_MoveSaturationCmd
 *
 * @brief   Call to send out a Move Saturation Command
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   moveMode - LIGHTING_MOVE_SATURATION_STOP, LIGHTING_MOVE_SATURATION_UP,
 *                     LIGHTING_MOVE_SATURATION_DOWN
 * @param   rate - rate of movement in step/sec; step is the device's saturation of one unit
 * @param   disableDefaultRsp - whether to disable the Default Response command
 * @param   seqNum - sequence number
 *
 * @return  ZStatus_t
 */
ZStatus_t zclLighting_ColorControl_Send_MoveSaturationCmd( uint8 srcEP, afAddrType_t *dstAddr,
                                                           uint8 moveMode, uint8 rate, 
                                                           uint8 disableDefaultRsp, uint8 seqNum )
{
  uint8 buf[2];
  
  buf[0] = moveMode;
  buf[1] = rate;

  return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_LIGHTING_COLOR_CONTROL, 
                          COMMAND_LIGHTING_MOVE_SATURATION, TRUE, 
                          ZCL_FRAME_CLIENT_SERVER_DIR, disableDefaultRsp, 0, seqNum, 2, buf );
}
Ejemplo n.º 28
0
static ZStatus_t sendGroupResponse(afAddrType_t *dstAddr,
                                        uint8 cmd, uint8 status, uint16 groupID,
                                        uint8 disableDefaultRsp){
	uint8 buf[3];

	buf[0] = status;
	buf[1] = LO_UINT16( groupID );
 	buf[2] = HI_UINT16( groupID );

 	return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_GEN_GROUPS,
                          cmd, TRUE, ZCL_FRAME_SERVER_CLIENT_DIR,
                          disableDefaultRsp, 0, seqNum, 3, buf );
}
Ejemplo n.º 29
0
/*********************************************************************
 * @fn      zclClosures_WCSendGoToPercentageRequest
 *
 * @brief   Call to send out a Go to Percentage Request Command
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   cmd - Command ID e.g. COMMAND_CLOSURES_GO_TO_LIFT_PERCENTAGE
 * @param   disableDefaultRsp - decides default response is necessary or not
 * @param   seqNum - sequence number of the command packet
 * @param   percentageLiftValue - payload
 * 
 * @return  ZStatus_t
 */
ZStatus_t zclClosures_WCSendGoToPercentageRequest( uint8 srcEP, afAddrType_t *dstAddr,
                                                     uint8 cmd, uint8 disableDefaultRsp, 
                                                     uint8 seqNum, uint8 percentageValue )
{
  uint8 buf[ZCL_WC_GOTOPERCENTAGEREQ_PAYLOADLEN];

  buf[0] = percentageValue;
  
  return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_CLOSURES_WINDOW_COVERING,
                          cmd, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR,
                          disableDefaultRsp, 0, seqNum, 
                          ZCL_WC_GOTOPERCENTAGEREQ_PAYLOADLEN, buf );
}
Ejemplo n.º 30
0
/*********************************************************************
 * @fn      zclClosures_SendGoToSetpointRequest
 *
 * @brief   Call to send out a Go to Setpoint Request Command
 *
 * @param   srcEP - Sending application's endpoint
 * @param   dstAddr - where you want the message to go
 * @param   cmd - Command ID for COMMAND_CLOSURES_GO_TO_LIFT_SETPOINT 
 *                or COMMAND_CLOSURES_GO_TO_TILT_SETPOINT
 * @param   disableDefaultRsp - decides default response is necessary or not
 * @param   seqNum - sequence number of the command packet
 * @param   SetpointIndex - payload
 * 
 * @return  ZStatus_t
 */
ZStatus_t zclClosures_WCSendGoToSetpointRequest( uint8 srcEP, afAddrType_t *dstAddr,
                                               uint8 cmd, uint8 disableDefaultRsp, 
                                               uint8 seqNum, uint8 SetpointIndex )
{
  uint8 buf[ZCL_WC_GOTOSETPOINTREQ_PAYLOADLEN];

  buf[0] = SetpointIndex;
  
  return zcl_SendCommand( srcEP, dstAddr, ZCL_CLUSTER_ID_CLOSURES_WINDOW_COVERING,
                          cmd, TRUE, ZCL_FRAME_CLIENT_SERVER_DIR,
                          disableDefaultRsp, 0, seqNum, 
                          ZCL_WC_GOTOSETPOINTREQ_PAYLOADLEN, buf );
}