mirror of
https://github.com/formtapez/ZigUP.git
synced 2025-02-23 09:34:50 +01:00
implemented LED control
This commit is contained in:
14
README.md
14
README.md
@@ -15,7 +15,7 @@ CC2530 based multi-purpose ZigBee Relais, Switch, Sensor and Router
|
|||||||
* Input for S0-Bus impulses from power-, water- or gas-meters. Count-Value will be reported via ZigBee)
|
* Input for S0-Bus impulses from power-, water- or gas-meters. Count-Value will be reported via ZigBee)
|
||||||
* Output for one normal LED or up to 10 WS2812B/Neopixel RGB-LEDs (controllable via ZigBee)
|
* Output for one normal LED or up to 10 WS2812B/Neopixel RGB-LEDs (controllable via ZigBee)
|
||||||
* Analog input to measure voltages of up to 32 Volt. (Voltage will be reported via ZigBee)
|
* Analog input to measure voltages of up to 32 Volt. (Voltage will be reported via ZigBee)
|
||||||
|
* Fully equipped debug-port to allow CC Debugger flashing and packet sniffing
|
||||||
|
|
||||||
# Connection diagrams
|
# Connection diagrams
|
||||||
|
|
||||||
@@ -41,5 +41,13 @@ CC2530 based multi-purpose ZigBee Relais, Switch, Sensor and Router
|
|||||||
|
|
||||||
# Flashing with CC Debugger
|
# Flashing with CC Debugger
|
||||||
1. Get **SmartRF Flash Programmer v1.12.8 (not v2.x!)** from https://www.ti.com/tool/flash-programmer
|
1. Get **SmartRF Flash Programmer v1.12.8 (not v2.x!)** from https://www.ti.com/tool/flash-programmer
|
||||||
2. Select "Program CCxxxx..." and "System-on-Chip" tab
|
2. Connect CC Debugger to the Debug-Port of ZigUP with an 1:1 cable.
|
||||||
3. Load HEX-File and perform "Erase, program and verify" action
|
3. Select "Program CCxxxx..." and "System-on-Chip" tab
|
||||||
|
4. Load HEX-File and perform "Erase, program and verify" action
|
||||||
|
|
||||||
|
# Packet Sniffing using CC Debugger
|
||||||
|
1. Get **PACKET-SNIFFER v2.18.1 (not SNIFFER-2 v1.x!)** from http://www.ti.com/tool/PACKET-SNIFFER
|
||||||
|
2. Connect CC Debugger to the Debug-Port of ZigUP with an 1:1 cable.
|
||||||
|
3. Select protocol "IEEE 802.15.4/ZigBee" and click "Start"
|
||||||
|
4. Change radio channel and click "Start"
|
||||||
|
5. Re-flash ZigUP firmware when you are done. Because it was replaced by a sniffer-firmware.
|
||||||
|
|||||||
@@ -1493,6 +1493,7 @@
|
|||||||
<state>xZCL_LEVEL_CTRL</state>
|
<state>xZCL_LEVEL_CTRL</state>
|
||||||
<state>ZCL_DIAGNOSTIC</state>
|
<state>ZCL_DIAGNOSTIC</state>
|
||||||
<state>FEATURE_SYSTEM_STATS</state>
|
<state>FEATURE_SYSTEM_STATS</state>
|
||||||
|
<state>ZCL_DOORLOCK</state>
|
||||||
</option>
|
</option>
|
||||||
<option>
|
<option>
|
||||||
<name>CCPreprocFile</name>
|
<name>CCPreprocFile</name>
|
||||||
@@ -4722,6 +4723,12 @@
|
|||||||
<file>
|
<file>
|
||||||
<name>$PROJ_DIR$\..\Source\ws2812.h</name>
|
<name>$PROJ_DIR$\..\Source\ws2812.h</name>
|
||||||
</file>
|
</file>
|
||||||
|
<file>
|
||||||
|
<name>$PROJ_DIR$\..\..\..\..\..\Components\stack\zcl\zcl_closures.c</name>
|
||||||
|
</file>
|
||||||
|
<file>
|
||||||
|
<name>$PROJ_DIR$\..\..\..\..\..\Components\stack\zcl\zcl_closures.h</name>
|
||||||
|
</file>
|
||||||
<file>
|
<file>
|
||||||
<name>$PROJ_DIR$\..\..\..\..\..\Components\stack\zcl\zcl_lighting.c</name>
|
<name>$PROJ_DIR$\..\..\..\..\..\Components\stack\zcl\zcl_lighting.c</name>
|
||||||
</file>
|
</file>
|
||||||
|
|||||||
@@ -11,4 +11,4 @@ extern uint16 zclZigUPSeqNum;
|
|||||||
|
|
||||||
extern volatile uint32 S0;
|
extern volatile uint32 S0;
|
||||||
extern volatile uint8 STATE_LIGHT;
|
extern volatile uint8 STATE_LIGHT;
|
||||||
extern volatile uint8 STATE_LED;
|
extern volatile uint8 STATE_LED;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "zcl_lighting.h"
|
#include "zcl_lighting.h"
|
||||||
|
#include "zcl_closures.h"
|
||||||
#include "zcl_zigup.h"
|
#include "zcl_zigup.h"
|
||||||
#include "zcl.h"
|
#include "zcl.h"
|
||||||
#include "zcl_ha.h"
|
#include "zcl_ha.h"
|
||||||
@@ -112,11 +113,11 @@ void zclZigUP_Reporting(void)
|
|||||||
*/
|
*/
|
||||||
static zclGeneral_AppCallbacks_t zclZigUP_CmdCallbacks =
|
static zclGeneral_AppCallbacks_t zclZigUP_CmdCallbacks =
|
||||||
{
|
{
|
||||||
zclZigUP_BasicResetCB, // Basic Cluster Reset command
|
zclZigUP_BasicResetCB, // Basic Cluster Reset command
|
||||||
zclZigUP_IdentifyCB, // Identify command
|
zclZigUP_IdentifyCB, // Identify command
|
||||||
NULL, // Identify Trigger Effect command
|
NULL, // Identify Trigger Effect command
|
||||||
zclZigUP_IdentifyQueryRspCB, // Identify Query Response command
|
zclZigUP_IdentifyQueryRspCB, // Identify Query Response command
|
||||||
zclZigUP_OnOffCB, // On/Off cluster commands
|
zclZigUP_OnOffCB, // On/Off cluster commands
|
||||||
NULL, // On/Off cluster enhanced command Off with Effect
|
NULL, // On/Off cluster enhanced command Off with Effect
|
||||||
NULL, // On/Off cluster enhanced command On with Recall Global Scene
|
NULL, // On/Off cluster enhanced command On with Recall Global Scene
|
||||||
NULL, // On/Off cluster enhanced command On with Timed Off
|
NULL, // On/Off cluster enhanced command On with Timed Off
|
||||||
@@ -124,65 +125,97 @@ static zclGeneral_AppCallbacks_t zclZigUP_CmdCallbacks =
|
|||||||
NULL, // Group Response commands
|
NULL, // Group Response commands
|
||||||
#endif
|
#endif
|
||||||
#ifdef ZCL_SCENES
|
#ifdef ZCL_SCENES
|
||||||
NULL, // Scene Store Request command
|
NULL, // Scene Store Request command
|
||||||
NULL, // Scene Recall Request command
|
NULL, // Scene Recall Request command
|
||||||
NULL, // Scene Response command
|
NULL, // Scene Response command
|
||||||
#endif
|
#endif
|
||||||
#ifdef ZCL_ALARMS
|
#ifdef ZCL_ALARMS
|
||||||
NULL, // Alarm (Response) commands
|
NULL, // Alarm (Response) commands
|
||||||
#endif
|
#endif
|
||||||
#ifdef SE_UK_EXT
|
#ifdef SE_UK_EXT
|
||||||
NULL, // Get Event Log command
|
NULL, // Get Event Log command
|
||||||
NULL, // Publish Event Log command
|
NULL, // Publish Event Log command
|
||||||
#endif
|
#endif
|
||||||
NULL, // RSSI Location command
|
NULL, // RSSI Location command
|
||||||
NULL // RSSI Location Response command
|
NULL // RSSI Location Response command
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static zclLighting_AppCallbacks_t zclZigUP_LightingCmdCBs =
|
static zclLighting_AppCallbacks_t zclZigUP_LightingCmdCBs =
|
||||||
{
|
{
|
||||||
NULL, //Move To Hue Command
|
NULL, // Move To Hue Command
|
||||||
NULL, //Move Hue Command
|
NULL, // Move Hue Command
|
||||||
NULL, //Step Hue Command
|
NULL, // Step Hue Command
|
||||||
NULL, //Move To Saturation Command
|
NULL, // Move To Saturation Command
|
||||||
NULL, //Move Saturation Command
|
NULL, // Move Saturation Command
|
||||||
NULL, //Step Saturation Command
|
NULL, // Step Saturation Command
|
||||||
NULL, //Move To Hue And Saturation Command
|
NULL, // Move To Hue And Saturation Command
|
||||||
zclZigUP_MoveToColorCB, // Move To Color Command
|
zclZigUP_MoveToColorCB, // Move To Color Command
|
||||||
NULL, // Move Color Command
|
NULL, // Move Color Command
|
||||||
NULL, // STEP To Color Command
|
NULL, // STEP To Color Command
|
||||||
NULL, // Move To Color Temperature Command
|
NULL, // Move To Color Temperature Command
|
||||||
NULL,// Enhanced Move To Hue
|
NULL, // Enhanced Move To Hue
|
||||||
NULL, // Enhanced Move Hue;
|
NULL, // Enhanced Move Hue;
|
||||||
NULL, // Enhanced Step Hue;
|
NULL, // Enhanced Step Hue;
|
||||||
NULL, // Enhanced Move To Hue And Saturation;
|
NULL, // Enhanced Move To Hue And Saturation;
|
||||||
NULL, // Color Loop Set Command
|
NULL, // Color Loop Set Command
|
||||||
NULL, // Stop Move Step;
|
NULL, // Stop Move Step;
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
zclColor_MoveToHueCB, //Move To Hue Command
|
|
||||||
zclColor_MoveHueCB, //Move Hue Command
|
|
||||||
zclColor_StepHueCB, //Step Hue Command
|
|
||||||
zclColor_MoveToSaturationCB, //Move To Saturation Command
|
|
||||||
zclColor_MoveSaturationCB, //Move Saturation Command
|
|
||||||
zclColor_StepSaturationCB, //Step Saturation Command
|
|
||||||
zclColor_MoveToHueAndSaturationCB, //Move To Hue And Saturation Command
|
|
||||||
zclColor_MoveToColorCB, // Move To Color Command
|
|
||||||
zclColor_MoveColorCB, // Move Color Command
|
|
||||||
zclColor_StepColorCB, // STEP To Color Command
|
|
||||||
NULL, // Move To Color Temperature Command
|
|
||||||
zclColor_EnhMoveToHueCB,// Enhanced Move To Hue
|
|
||||||
zclColor_MoveEnhHueCB, // Enhanced Move Hue;
|
|
||||||
zclColor_StepEnhHueCB, // Enhanced Step Hue;
|
|
||||||
zclColor_MoveToEnhHueAndSaturationCB, // Enhanced Move To Hue And Saturation;
|
|
||||||
zclColor_SetColorLoopCB, // Color Loop Set Command
|
|
||||||
zclColor_StopCB, // Stop Move Step;
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static zclClosures_DoorLockAppCallbacks_t zclZigUP_DoorLockCmdCallbacks =
|
||||||
|
{
|
||||||
|
zclZigUP_DoorLockCB, // DoorLock cluster command
|
||||||
|
zclZigUP_DoorLockRspCB, // DoorLock Response
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* @fn zclZigUP_Init
|
* @fn zclZigUP_Init
|
||||||
*
|
*
|
||||||
@@ -210,6 +243,9 @@ void zclZigUP_Init( byte task_id )
|
|||||||
|
|
||||||
// Register the ZCL Lighting Cluster Library callback functions
|
// Register the ZCL Lighting Cluster Library callback functions
|
||||||
zclLighting_RegisterCmdCallbacks( ZIGUP_ENDPOINT, &zclZigUP_LightingCmdCBs );
|
zclLighting_RegisterCmdCallbacks( ZIGUP_ENDPOINT, &zclZigUP_LightingCmdCBs );
|
||||||
|
|
||||||
|
// Register the ZCL DoorLock Cluster Library callback function
|
||||||
|
zclClosures_RegisterDoorLockCmdCallbacks( ZIGUP_ENDPOINT, &zclZigUP_DoorLockCmdCallbacks );
|
||||||
|
|
||||||
// Register the application's attribute list
|
// Register the application's attribute list
|
||||||
zcl_registerAttrList( ZIGUP_ENDPOINT, zclZigUP_NumAttributes, zclZigUP_Attrs );
|
zcl_registerAttrList( ZIGUP_ENDPOINT, zclZigUP_NumAttributes, zclZigUP_Attrs );
|
||||||
@@ -558,6 +594,66 @@ ZStatus_t zclZigUP_MoveToColorCB( zclCCMoveToColor_t *pCmd )
|
|||||||
return ( ZSuccess );
|
return ( ZSuccess );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
* @fn zclZigUP_DoorLockCB
|
||||||
|
*
|
||||||
|
* @brief Callback from the ZCL General Cluster Library when
|
||||||
|
* it received an Door Lock cluster Command for this application.
|
||||||
|
*
|
||||||
|
* @param pInMsg - process incoming message
|
||||||
|
* @param pInCmd - PIN/RFID code of command
|
||||||
|
*
|
||||||
|
* @return ZStatus_t
|
||||||
|
*/
|
||||||
|
static ZStatus_t zclZigUP_DoorLockCB ( zclIncoming_t *pInMsg, zclDoorLock_t *pInCmd )
|
||||||
|
{
|
||||||
|
// LED OFF - Lock the door
|
||||||
|
if ( pInMsg->hdr.commandID == COMMAND_CLOSURES_LOCK_DOOR )
|
||||||
|
{
|
||||||
|
LED(0);
|
||||||
|
zclClosures_SendDoorLockStatusResponse( pInMsg->msg->endPoint, &pInMsg->msg->srcAddr, COMMAND_CLOSURES_LOCK_DOOR, ZCL_STATUS_SUCCESS, TRUE, pInMsg->hdr.transSeqNum );
|
||||||
|
}
|
||||||
|
|
||||||
|
// LED ON - Unlock the door
|
||||||
|
else if ( pInMsg->hdr.commandID == COMMAND_CLOSURES_UNLOCK_DOOR )
|
||||||
|
{
|
||||||
|
LED(1);
|
||||||
|
zclClosures_SendDoorLockStatusResponse( pInMsg->msg->endPoint, &pInMsg->msg->srcAddr, COMMAND_CLOSURES_UNLOCK_DOOR, ZCL_STATUS_SUCCESS, TRUE, pInMsg->hdr.transSeqNum );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toggle the door
|
||||||
|
else if ( pInMsg->hdr.commandID == COMMAND_CLOSURES_TOGGLE_DOOR )
|
||||||
|
{
|
||||||
|
LED(!STATE_LED);
|
||||||
|
zclClosures_SendDoorLockStatusResponse( pInMsg->msg->endPoint, &pInMsg->msg->srcAddr, COMMAND_CLOSURES_TOGGLE_DOOR, ZCL_STATUS_SUCCESS, TRUE, pInMsg->hdr.transSeqNum );
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ( ZCL_STATUS_FAILURE ); // invalid command
|
||||||
|
}
|
||||||
|
|
||||||
|
return ( ZCL_STATUS_CMD_HAS_RSP );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
* @fn zclZigUP_DoorLockRspCB
|
||||||
|
*
|
||||||
|
* @brief Callback from the ZCL General Cluster Library when
|
||||||
|
* it received an Door Lock response for this application.
|
||||||
|
*
|
||||||
|
* @param cmd - Command ID
|
||||||
|
* @param srcAddr - Requestor's address
|
||||||
|
* @param transSeqNum - Transaction sequence number
|
||||||
|
* @param status - status response from server's door lock cmd
|
||||||
|
*
|
||||||
|
* @return ZStatus_t
|
||||||
|
*/
|
||||||
|
static ZStatus_t zclZigUP_DoorLockRspCB ( zclIncoming_t *pInMsg, uint8 status )
|
||||||
|
{
|
||||||
|
return ( ZCL_STATUS_SUCCESS );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ extern "C"
|
|||||||
#include "zcl.h"
|
#include "zcl.h"
|
||||||
#include "zcl_general.h"
|
#include "zcl_general.h"
|
||||||
#include "zcl_lighting.h"
|
#include "zcl_lighting.h"
|
||||||
|
#include "zcl_closures.h"
|
||||||
|
|
||||||
#define ZIGUP_ENDPOINT 8
|
#define ZIGUP_ENDPOINT 8
|
||||||
|
|
||||||
#define LIGHT_OFF 0x00
|
#define LIGHT_OFF 0x00
|
||||||
@@ -57,7 +58,8 @@ static void zclZigUP_IdentifyCB( zclIdentify_t *pCmd );
|
|||||||
static void zclZigUP_IdentifyQueryRspCB( zclIdentifyQueryRsp_t *pRsp );
|
static void zclZigUP_IdentifyQueryRspCB( zclIdentifyQueryRsp_t *pRsp );
|
||||||
static void zclZigUP_OnOffCB( uint8 cmd );
|
static void zclZigUP_OnOffCB( uint8 cmd );
|
||||||
ZStatus_t zclZigUP_MoveToColorCB( zclCCMoveToColor_t *pCmd );
|
ZStatus_t zclZigUP_MoveToColorCB( zclCCMoveToColor_t *pCmd );
|
||||||
|
static ZStatus_t zclZigUP_DoorLockCB ( zclIncoming_t *pInMsg, zclDoorLock_t *pInCmd );
|
||||||
|
static ZStatus_t zclZigUP_DoorLockRspCB ( zclIncoming_t *pInMsg, uint8 status );
|
||||||
|
|
||||||
static void zclZigUP_ProcessIdentifyTimeChange( void );
|
static void zclZigUP_ProcessIdentifyTimeChange( void );
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include "zcl_zigup.h"
|
#include "zcl_zigup.h"
|
||||||
|
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
#define ZIGUP_DEVICE_VERSION 0
|
#define ZIGUP_DEVICE_VERSION 0
|
||||||
#define ZIGUP_FLAGS 0
|
#define ZIGUP_FLAGS 0
|
||||||
|
|
||||||
@@ -180,7 +182,7 @@ CONST zclAttrRec_t zclZigUP_Attrs[] =
|
|||||||
ATTRID_ON_OFF,
|
ATTRID_ON_OFF,
|
||||||
ZCL_DATATYPE_BOOLEAN,
|
ZCL_DATATYPE_BOOLEAN,
|
||||||
ACCESS_CONTROL_READ,
|
ACCESS_CONTROL_READ,
|
||||||
(void *)&zclZigUP_OnOff
|
(void *)&zclZigUP_OnOff // TODO
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user