The following steps show how Zigbee CIE and IAS device work:
1. ZC (act as CIE) enable permit join to allow IAS Zone device to join.
2. ZC does binding to IAS zone.
3. ZC sends a write attribute request to the joined IAS zone device to write the CIE IEEE Address attribute.
4. The joined IAS Zone device sends an IAS Zone Enrollment request to ZC (the CIE).
5. IAS zone device can send IAS Zone status report to ZC (the CIE) and ZC (the CIE) can receive IAS Zone report.
Showing posts with label Z-Stack. Show all posts
Showing posts with label Z-Stack. Show all posts
Wednesday, May 6, 2020
Monday, April 13, 2020
How to use two endpoints in SIMPLELINK-CC13X2-26X2-SDK Z-Stack.
The following steps show you how to use two endpoints in SIMPLELINK-CC13X2-26X2-SDK Z-Stack zed_sw example.
1. Define a new SAMPLESW_ENDPOINT2 as 9 in zcl_samplesw.h.
#define SAMPLESW_ENDPOINT2 9
2. Define a new zclSampleSwEp2Desc in zcl_samplesw.c.
static endPointDesc_t zclSampleSwEp2Desc = {0};
3. Clone zclSampleSwEp2_Attrs, zclSampleSwEp2_InClusterList, and zclSampleSwEp2_OutClusterList from zclSampleSw_Attrs, zclSampleSw_InClusterList, and zclSampleSw_OutClusterList in zcl_samplesw_data.c.
4. Define a new zclSampleSwEp2_SimpleDesc in zcl_samplesw_data.c.
#define ZCLSAMPLESWEp2_MAX_INCLUSTERS ( sizeof( zclSampleSwEp2_InClusterList ) / sizeof( zclSampleSwEp2_InClusterList[0] ))
#define ZCLSAMPLESWEp2_MAX_OUTCLUSTERS ( sizeof( zclSampleSwEp2_OutClusterList ) / sizeof( zclSampleSwEp2_OutClusterList[0] ))
SimpleDescriptionFormat_t zclSampleSwEp2_SimpleDesc =
{
SAMPLESW_ENDPOINT2, // int Endpoint;
ZCL_HA_PROFILE_ID, // uint16_t AppProfId[2];
ZCL_HA_DEVICEID_ON_OFF_LIGHT_SWITCH,// uint16_t AppDeviceId[2];
SAMPLESW_DEVICE_VERSION, // int AppDevVer:4;
SAMPLESW_FLAGS, // int AppFlags:4;
ZCLSAMPLESWEp2_MAX_INCLUSTERS, // byte AppNumInClusters;
(cId_t *)zclSampleSwEp2_InClusterList, // byte *pAppInClusterList;
ZCLSAMPLESWEp2_MAX_OUTCLUSTERS, // byte AppNumInClusters;
(cId_t *)zclSampleSwEp2_OutClusterList // byte *pAppInClusterList;
};
5. Register the new SAMPLESW_ENDPOINT2 and zclSampleSwEp2Desc in zclSampleSw_Init().
//Register Endpoint 2
zclSampleSwEp2Desc.endPoint = SAMPLESW_ENDPOINT2;
zclSampleSwEp2Desc.simpleDesc = &zclSampleSwEp2_SimpleDesc;
zclport_registerEndpoint(appServiceTaskId, &zclSampleSwEp2Desc);
6. Clone zclSampleSwEp2_CmdCallbacks (remember to implement your own callbacks for SAMPLESW_ENDPOINT2) from zclSampleSw_CmdCallbacks in zcl_samplesw.c and register zclSampleSwEp2_CmdCallbacks using zclGeneral_RegisterCmdCallbacks().
zclGeneral_RegisterCmdCallbacks( SAMPLESW_ENDPOINT2, &zclSampleSwEp2_CmdCallbacks );
7. Define zclSampleSwEp2_NumAttributes in zcl_samplesw_data.c.
uint8_t CONST zclSampleSwEp2_NumAttributes = ( sizeof(zclSampleSwEp2_Attrs) / sizeof(zclSampleSwEp2_Attrs[0]) );
8. Register attributes for SAMPLESW_ENDPOINT2 using zcl_registerAttrList() in .
zcl_registerAttrList( SAMPLESW_ENDPOINT, zclSampleSwEp2_NumAttributes, zclSampleSwEp2_Attrs );
9. Build and test your application for two active endpoints.
1. Define a new SAMPLESW_ENDPOINT2 as 9 in zcl_samplesw.h.
#define SAMPLESW_ENDPOINT2 9
2. Define a new zclSampleSwEp2Desc in zcl_samplesw.c.
static endPointDesc_t zclSampleSwEp2Desc = {0};
3. Clone zclSampleSwEp2_Attrs, zclSampleSwEp2_InClusterList, and zclSampleSwEp2_OutClusterList from zclSampleSw_Attrs, zclSampleSw_InClusterList, and zclSampleSw_OutClusterList in zcl_samplesw_data.c.
4. Define a new zclSampleSwEp2_SimpleDesc in zcl_samplesw_data.c.
#define ZCLSAMPLESWEp2_MAX_INCLUSTERS ( sizeof( zclSampleSwEp2_InClusterList ) / sizeof( zclSampleSwEp2_InClusterList[0] ))
#define ZCLSAMPLESWEp2_MAX_OUTCLUSTERS ( sizeof( zclSampleSwEp2_OutClusterList ) / sizeof( zclSampleSwEp2_OutClusterList[0] ))
SimpleDescriptionFormat_t zclSampleSwEp2_SimpleDesc =
{
SAMPLESW_ENDPOINT2, // int Endpoint;
ZCL_HA_PROFILE_ID, // uint16_t AppProfId[2];
ZCL_HA_DEVICEID_ON_OFF_LIGHT_SWITCH,// uint16_t AppDeviceId[2];
SAMPLESW_DEVICE_VERSION, // int AppDevVer:4;
SAMPLESW_FLAGS, // int AppFlags:4;
ZCLSAMPLESWEp2_MAX_INCLUSTERS, // byte AppNumInClusters;
(cId_t *)zclSampleSwEp2_InClusterList, // byte *pAppInClusterList;
ZCLSAMPLESWEp2_MAX_OUTCLUSTERS, // byte AppNumInClusters;
(cId_t *)zclSampleSwEp2_OutClusterList // byte *pAppInClusterList;
};
5. Register the new SAMPLESW_ENDPOINT2 and zclSampleSwEp2Desc in zclSampleSw_Init().
//Register Endpoint 2
zclSampleSwEp2Desc.endPoint = SAMPLESW_ENDPOINT2;
zclSampleSwEp2Desc.simpleDesc = &zclSampleSwEp2_SimpleDesc;
zclport_registerEndpoint(appServiceTaskId, &zclSampleSwEp2Desc);
6. Clone zclSampleSwEp2_CmdCallbacks (remember to implement your own callbacks for SAMPLESW_ENDPOINT2) from zclSampleSw_CmdCallbacks in zcl_samplesw.c and register zclSampleSwEp2_CmdCallbacks using zclGeneral_RegisterCmdCallbacks().
zclGeneral_RegisterCmdCallbacks( SAMPLESW_ENDPOINT2, &zclSampleSwEp2_CmdCallbacks );
7. Define zclSampleSwEp2_NumAttributes in zcl_samplesw_data.c.
uint8_t CONST zclSampleSwEp2_NumAttributes = ( sizeof(zclSampleSwEp2_Attrs) / sizeof(zclSampleSwEp2_Attrs[0]) );
8. Register attributes for SAMPLESW_ENDPOINT2 using zcl_registerAttrList() in .
zcl_registerAttrList( SAMPLESW_ENDPOINT, zclSampleSwEp2_NumAttributes, zclSampleSwEp2_Attrs );
9. Build and test your application for two active endpoints.
Monday, May 6, 2019
How to check APS ack in TI Z-Stack
The following steps show you how to check APS ack in TI Z-Stack using ON/OFF cluster toggle command in SampleSwitch example.
1. Setup OnOffOptions and use zcl_registerClusterOptionList in zclSampleSw_Init to register receiving APS ack on ZCL_CLUSTER_ID_GEN_ON_OFF cluster command.
zclOptionRec_t OnOffOptions[] =
{
{
ZCL_CLUSTER_ID_GEN_ON_OFF, ( AF_EN_SECURITY | AF_ACK_REQUEST ),
},
};
ZStatus_t status = zcl_registerClusterOptionList ( SAMPLESW_ENDPOINT, 1,
OnOffOptions );
2. Add "case AF_DATA_CONFIRM_CMD:..." in SYS_EVENT_MSG case of zclSampleSw_event_loop
uint16 zclSampleSw_event_loop( uint8 task_id, uint16 events )
{
...
if ( events & SYS_EVENT_MSG )
{
while ( (MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( zclSampleSw_TaskID )) )
{
switch ( MSGpkt->hdr.event )
{
case AF_DATA_CONFIRM_CMD:
afDataConfirm_t *SWafDataConfirm;
SWafDataConfirm = (afDataConfirm_t *)MSGpkt;
rcv_aps_ack_trans_id=SWafDataConfirm->transID;
// You can use rcv_aps_ack_trans_id to check if it matches to APS_Counter when you send toggle command with zclGeneral_SendOnOff_CmdToggle
break;
...
1. Setup OnOffOptions and use zcl_registerClusterOptionList in zclSampleSw_Init to register receiving APS ack on ZCL_CLUSTER_ID_GEN_ON_OFF cluster command.
zclOptionRec_t OnOffOptions[] =
{
{
ZCL_CLUSTER_ID_GEN_ON_OFF, ( AF_EN_SECURITY | AF_ACK_REQUEST ),
},
};
ZStatus_t status = zcl_registerClusterOptionList ( SAMPLESW_ENDPOINT, 1,
OnOffOptions );
2. Add "case AF_DATA_CONFIRM_CMD:..." in SYS_EVENT_MSG case of zclSampleSw_event_loop
uint16 zclSampleSw_event_loop( uint8 task_id, uint16 events )
{
...
if ( events & SYS_EVENT_MSG )
{
while ( (MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( zclSampleSw_TaskID )) )
{
switch ( MSGpkt->hdr.event )
{
case AF_DATA_CONFIRM_CMD:
afDataConfirm_t *SWafDataConfirm;
SWafDataConfirm = (afDataConfirm_t *)MSGpkt;
rcv_aps_ack_trans_id=SWafDataConfirm->transID;
// You can use rcv_aps_ack_trans_id to check if it matches to APS_Counter when you send toggle command with zclGeneral_SendOnOff_CmdToggle
break;
...
Sunday, July 29, 2018
660 Zigbee devices in the same Zigbee network!
660 Zigbee devices in the same Zigbee network now!!! This time, we have total 660 Zigbee devices, including 130 ZRs (Smart Plugs) and 530 ZEDs (PIR motion sensors, Door Contact sensors, and Smoke Detectors), joined to a single Zigbee network. The solution is based on TI CC2530.
Wednesday, March 29, 2017
Build TI Z-Stack Linux Home Gateway reference design for x86 Linux
The following steps show you hot to build TI Z-Stack Linux Home Gateway reference design for x86 Linux.
1. Download Z-Stack_Linux_Gateway-1.0.1-src-linux-installer.run from http://www.ti.com/tool/z-stack-archive.
2. Setup a 32 bit Ubuntu and run Z-Stack_Linux_Gateway-1.0.1-src-linux-installer.run to extract Z-Stack Linux Gateway source code to your Linux Home folder\Z-Stack_Linux_Gateway-1.0.1-src
3. Revise the build script package_builder_bbb (in red) under “your Linux Home folder\Z-Stack_Linux_Gateway-1.0.1-src\Source\scripts\”
...
#Target platform:
#export TARGET_PLATFORM="BEAGLEBONE_BLACK"
export TARGET_PLATFORM="x86"
...
cd $NPI_SOURCE/Projects/tools/LinuxHost
make clean
make create_output
#make arch-all-armBeagleBone CC_armBeagleBone=$COMPILER |& tee -a $MAKE_LOG_FILE
make $BUILD_TYPE |& tee -a $MAKE_LOG_FILE
...
# *** Copy resources ***********************************************************************************
#cp $NPI_SOURCE/Projects/tools/LinuxHost/out/NPI_lnx_armBeagleBone_server $BINARIES_SERVERS_DIR/NPI_lnx_${PLATFORM_SUBSTRING}_server
cp $NPI_SOURCE/Projects/tools/LinuxHost/out/NPI_lnx_${PLATFORM_SUBSTRING}_server $BINARIES_SERVERS_DIR/NPI_lnx_${PLATFORM_SUBSTRING}_server
4.a Install protobuf by doing the following two apt-get install
sudo apt-get install protobuf-c-compiler
sudo apt-get install protobuf-compiler
4.b Create a new folder "tools" and export TCLIB to it using the following lines:
cd ~
mkdir tools
export TCLIB=~/tools/
5. Switch to your Linux Home folder\Z-Stack_Linux_Gateway-1.0.1-src\Source\ and run ./build_all
6. The output will be at "your Linux Home folder\Z-Stack_Linux_Gateway-1.0.1-src\Source\ERROR_out\z-stack_linux_gateway_x86_binaries.tar". The build error is due to the lack of comparison file but the output binaries still work on x86 environment.
7. Copy and untar “z-stack_linux_gateway_x86_binaries.tar” to your working directory on x86 (called). Please follow the (Z-Stack Linux Gateway User Guide.pdf, Chap 6.3) to start the application. Please note you have to specify x86 when you run zigbeeHAgw like "sudo ./zigbeeHAgw x86"
8. If you run it successfully, you will see the results like the following screen shot.
1. Download Z-Stack_Linux_Gateway-1.0.1-src-linux-installer.run from http://www.ti.com/tool/z-stack-archive.
2. Setup a 32 bit Ubuntu and run Z-Stack_Linux_Gateway-1.0.1-src-linux-installer.run to extract Z-Stack Linux Gateway source code to your Linux Home folder\Z-Stack_Linux_Gateway-1.0.1-src
3. Revise the build script package_builder_bbb (in red) under “your Linux Home folder\Z-Stack_Linux_Gateway-1.0.1-src\Source\scripts\”
...
#Target platform:
#export TARGET_PLATFORM="BEAGLEBONE_BLACK"
export TARGET_PLATFORM="x86"
...
cd $NPI_SOURCE/Projects/tools/LinuxHost
make clean
make create_output
#make arch-all-armBeagleBone CC_armBeagleBone=$COMPILER |& tee -a $MAKE_LOG_FILE
make $BUILD_TYPE |& tee -a $MAKE_LOG_FILE
...
# *** Copy resources ***********************************************************************************
#cp $NPI_SOURCE/Projects/tools/LinuxHost/out/NPI_lnx_armBeagleBone_server $BINARIES_SERVERS_DIR/NPI_lnx_${PLATFORM_SUBSTRING}_server
cp $NPI_SOURCE/Projects/tools/LinuxHost/out/NPI_lnx_${PLATFORM_SUBSTRING}_server $BINARIES_SERVERS_DIR/NPI_lnx_${PLATFORM_SUBSTRING}_server
4.a Install protobuf by doing the following two apt-get install
sudo apt-get install protobuf-c-compiler
sudo apt-get install protobuf-compiler
4.b Create a new folder "tools" and export TCLIB to it using the following lines:
cd ~
mkdir tools
export TCLIB=~/tools/
5. Switch to your Linux Home folder\Z-Stack_Linux_Gateway-1.0.1-src\Source\ and run ./build_all
6. The output will be at "your Linux Home folder\Z-Stack_Linux_Gateway-1.0.1-src\Source\ERROR_out\z-stack_linux_gateway_x86_binaries.tar". The build error is due to the lack of comparison file but the output binaries still work on x86 environment.
7. Copy and untar “z-stack_linux_gateway_x86_binaries.tar” to your working directory on x86 (called
8. If you run it successfully, you will see the results like the following screen shot.
Wednesday, February 15, 2017
Conversion between RSSI and LQI in Z-Stack
Z-Stack uses the following formula to convert RSSI and LQI.
LinkQuality = [255* (RSSI-MIN_ED)]/[MAX_ED-MIN_ED]
Therefore with simple algebra
RSSI = MIN_ED+LinkQuality*( MAX_ED-MIN_ED)/255
Default values for MIN_ED and MAX_ED are -87 and 10 respectively.
Then, maybe you can convert RSSI to distance...
LinkQuality = [255* (RSSI-MIN_ED)]/[MAX_ED-MIN_ED]
Therefore with simple algebra
RSSI = MIN_ED+LinkQuality*( MAX_ED-MIN_ED)/255
Default values for MIN_ED and MAX_ED are -87 and 10 respectively.
Then, maybe you can convert RSSI to distance...
Friday, February 10, 2017
Use ZTool + Z-Stack 3.0 ZNP to set up a basic Zigbee 3.0 network
The following steps show you how to use ZTool + Z-Stack 3.0 ZNP to set up Zigbee 3.0 network:
1. You have to prepare two CC253x EVBs (CC2530DK, CC2531EMK, or CC2538EM) and run Z-Stack ZNP 3.0 FW on it.
2. You can run the following MT commands (TX in red) to setup Zigbee 3.0 coordinator.
10:36:58.53 COM1 SYS_OSAL_NV_WRITE (0x2109) --> Write startup option to clear NV when reset
Id: 0x0003
Offset: 0x00
Len: 0x01
Value: . (0x03)
10:36:58.55 COM1 SYS_OSAL_NV_WRITE_SRSP (0x6109)
Status: SUCCESS (0x0)
10:37:06.11 COM1 SYS_RESET (0x4100) --> Do reset to clear NV
Type: 0x00 (HARD RESET) (0x0)
10:37:08.18 COM1 SYS_RESET_RESPONSE (0x4180)
Reason: 0x02
TransportRev: 0x02
Product: 0x00
MajorRel: 0x02
MinorRel: 0x07
HwRev: 0x00
10:37:42.94 COM1 SYS_OSAL_NV_WRITE (0x2109) --> Write ZCD_NV_LOGICAL_TYPE to 0 which means coordinator
Id: 0x0087
Offset: 0x00
Len: 0x01
Value: . (0x00)
10:37:42.97 COM1 SYS_OSAL_NV_WRITE_SRSP (0x6109)
Status: SUCCESS (0x0)
10:38:32.55 COM1 APP_CNF_BDB_SET_CHANNEL (0x2F08) --> Set Primary channel mask to channel 13 only
isPrimary: TRUE (0x1)
Channel: CHNL_0x00002000 (0x2000)
1 0:38:32.55 COM1 APP_CNF_BDB_SET_CHANNEL_SRSP (0x6F08)
Status: SUCCESS (0x0)
10:38:34.43 COM1 APP_CNF_BDB_SET_CHANNEL (0x2F08) --> Set Secondary channel to 0x0 to disable secondary channel mask
isPrimary: FALSE (0x0)
Channel: NONE (0x0)
10:49:01.44 COM1 APP_CNF_BDB_SET_CHANNEL_SRSP (0x6F08)
Status: SUCCESS (0x0)
10:38:45.58 COM1 APP_CNF_BDB_START_COMMISSIONING (0x2F05) --> Start commissioning using network formation as parameter to start coordinator
CommissioningMode: (0x04) Network Formation (0x4)
10:38:47.35 COM1 APP_CNF_BDB_START_COMMISSIONING_SRSP (0x6F05)
Status: SUCCESS (0x0)
10:38:47.35 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
State: 8 (0x8)
10:38:47.36 COM1 APP_CNF_BDB_COMMISSIONING_NOTIFICATION (0x4F80)
Status: 1 (0x1)
Commissioning Mode: 0x02 (Formation) (0x2)
Commissioning Mode: 254 (0xFE)
10:38:47.62 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
State: 8 (0x8)
10:38:47.88 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
State: 8 (0x8)
10:38:48.15 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
State: 8 (0x8)
10:38:48.41 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
State: 8 (0x8)
10:38:48.68 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
State: 8 (0x8)
10:38:48.94 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
State: 8 (0x8)
10:38:49.49 COM1 ZDO_STATE_CHANGE_IND (0x45C0)
State: 9 (0x9)
10:38:49.49 COM1 APP_CNF_BDB_COMMISSIONING_NOTIFICATION (0x4F80)
Status: 0x00 (Success) (0x0)
Commissioning Mode: 0x02 (Formation) (0x2)
Commissioning Mode: 69 (0x45)
10:39:11.49 COM1 UTIL_GET_DEVICE_INFO (0x2700) --> Get device info to confirm coordinator is setup correctly
10:39:11.5 COM1 UTIL_GET_DEVICE_INFO_RESPONSE (0x6700)
Status: SUCCESS (0x0)
IEEEAddr: 0x00124B0001025822
ShortAddress: 0x0000
DeviceType: COORDINATOR, ROUTER, END_DEVICE (0x7)
DeviceState: DEV_ZB_COORD (0x9)
NumAssocDevices: 0x00
AssocDevicesList
10:39:26.7 COM1 SYS_OSAL_NV_WRITE (0x2109) --> Write ZCD_NV_ZDO_DIRECT_CB to 1 to receive ZDO related messages
Id: 0x008F
Offset: 0x00
Len: 0x01
Value: . (0x01)
10:39:26.71 COM1 SYS_OSAL_NV_WRITE_SRSP (0x6109)
Status: SUCCESS (0x0)
10:44:16.54 COM1 APP_CNF_BDB_START_COMMISSIONING (0x2F05) --> Start commissioning using network steering as parameter to be ready for device to join
CommissioningMode: (0x02) Network Steering (0x2)
10:44:16.55 COM1 APP_CNF_BDB_START_COMMISSIONING_SRSP (0x6F05)
Status: SUCCESS (0x0)
10:44:16.56 COM1 ZDO_MGMT_PERMIT_JOIN_RSP (0x45B6)
SrcAddr: 0x0000
Status: ZDP_SUCCESS (0x0)
10:44:16.57 COM1 APP_CNF_BDB_COMMISSIONING_NOTIFICATION (0x4F80)
Status: 0x00 (Success) (0x0)
Commissioning Mode: 0x01 (Network Steering) (0x1)
Commissioning Mode: 67 (0x43)
3. You can run the following MT commands to setup Zigbee 3.0 router.
10:43:43.75 COM99 SYS_OSAL_NV_WRITE (0x2109) --> Write ZCD_NV_LOGICAL_TYPE to 1 which means router
Id: 0x0087
Offset: 0x00
Len: 0x01
Value: . (0x01)
10:43:59.35 COM1 APP_CNF_BDB_SET_CHANNEL (0x2F08) --> Set Primary channel mask to channel 13 only
isPrimary: TRUE (0x1)
Channel: CHNL_0x00002000 (0x2000)
10:43:59.35 COM1 APP_CNF_BDB_SET_CHANNEL_SRSP (0x6F08)
Status: SUCCESS (0x0)
10:44:11.43 COM1 APP_CNF_BDB_SET_CHANNEL (0x2F08) --> Set Secondary channel to 0x0 to disable secondary channel mask
isPrimary: FALSE (0x0)
Channel: NONE (0x0)
10:44:11.45 COM1 APP_CNF_BDB_SET_CHANNEL_SRSP (0x6F08)
Status: SUCCESS (0x0)
10:44:26.46 COM99 APP_CNF_BDB_START_COMMISSIONING (0x2F05) --> Start commissioning using network steering as parameter to make device to start scan Zigbee network to join
CommissioningMode: (0x02) Network Steering (0x2)
10:44:26.46 COM99 APP_CNF_BDB_START_COMMISSIONING_SRSP (0x6F05)
Status: SUCCESS (0x0)
10:44:26.56 COM99 APP_CNF_BDB_COMMISSIONING_NOTIFICATION (0x4F80)
Status: 1 (0x1)
Commissioning Mode: 0x01 (Network Steering) (0x1)
Commissioning Mode: 0 (0x0)
10:44:26.8 COM99 ZDO_STATE_CHANGE_IND (0x45C0)
State: INVALID_PARAMETER (0x2)
10:44:27.11 COM99 ZDO_STATE_CHANGE_IND (0x45C0)
State: INVALID_PARAMETER (0x2)
10:44:27.37 COM99 ZDO_STATE_CHANGE_IND (0x45C0)
State: 3 (0x3)
10:44:27.88 COM99 ZDO_STATE_CHANGE_IND (0x45C0)
State: 5 (0x5)
10:44:28.24 COM99 ZDO_STATE_CHANGE_IND (0x45C0)
State: 7 (0x7)
10:44:28.9 COM99 APP_CNF_BDB_COMMISSIONING_NOTIFICATION (0x4F80)
Status: 0x00 (Success) (0x0) --> Router joins coordinator successfully
Commissioning Mode: 0x01 (Network Steering) (0x1)
Commissioning Mode: 0 (0x0)
11:03:22.81 COM99 UTIL_GET_DEVICE_INFO (0x2700) --> Get device info to confirm router is setup correctly
11:03:22.81 COM99 UTIL_GET_DEVICE_INFO_RESPONSE (0x6700)
Status: SUCCESS (0x0)
IEEEAddr: 0x00124B0000E50127
ShortAddress: 0x4EE6
DeviceType: COORDINATOR, ROUTER, END_DEVICE (0x7)
DeviceState: DEV_ROUTER (0x7)
NumAssocDevices: 0x00
AssocDevicesList
4. On Ztool of coordinator, you should see ZDO_END_DEVICE_ANNCE_IND pops when router joins coordinator.
10:44:28.84 COM1 ZDO_END_DEVICE_ANNCE_IND (0x45C1)
SrcAddr: 0x4EE6
NwkAddr: 0x4EE6
IEEEAddr: 0x00124B0000E50127
Capabilities: 0x8E
1. You have to prepare two CC253x EVBs (CC2530DK, CC2531EMK, or CC2538EM) and run Z-Stack ZNP 3.0 FW on it.
2. You can run the following MT commands (TX in red) to setup Zigbee 3.0 coordinator.
Id: 0x0003
Offset: 0x00
Len: 0x01
Value: . (0x03)
Status: SUCCESS (0x0)
Type: 0x00 (HARD RESET) (0x0)
Reason: 0x02
TransportRev: 0x02
Product: 0x00
MajorRel: 0x02
MinorRel: 0x07
HwRev: 0x00
Id: 0x0087
Offset: 0x00
Len: 0x01
Value: . (0x00)
Status: SUCCESS (0x0)
isPrimary: TRUE (0x1)
Channel: CHNL_0x00002000 (0x2000)
1
Status: SUCCESS (0x0)
10:38:34.43 COM1 APP_CNF_BDB_SET_CHANNEL (0x2F08) --> Set Secondary channel to 0x0 to disable secondary channel mask
isPrimary: FALSE (0x0)
Channel: NONE (0x0)
10:49:01.44 COM1 APP_CNF_BDB_SET_CHANNEL_SRSP (0x6F08)
Status: SUCCESS (0x0)
CommissioningMode: (0x04) Network Formation (0x4)
Status: SUCCESS (0x0)
State: 8 (0x8)
Status: 1 (0x1)
Commissioning Mode: 0x02 (Formation) (0x2)
Commissioning Mode: 254 (0xFE)
State: 8 (0x8)
State: 8 (0x8)
State: 8 (0x8)
State: 8 (0x8)
State: 8 (0x8)
State: 8 (0x8)
State: 9 (0x9)
Status: 0x00 (Success) (0x0)
Commissioning Mode: 0x02 (Formation) (0x2)
Commissioning Mode: 69 (0x45)
Status: SUCCESS (0x0)
IEEEAddr: 0x00124B0001025822
ShortAddress: 0x0000
DeviceType: COORDINATOR, ROUTER, END_DEVICE (0x7)
DeviceState: DEV_ZB_COORD (0x9)
NumAssocDevices: 0x00
AssocDevicesList
Id: 0x008F
Offset: 0x00
Len: 0x01
Value: . (0x01)
Status: SUCCESS (0x0)
CommissioningMode: (0x02) Network Steering (0x2)
Status: SUCCESS (0x0)
SrcAddr: 0x0000
Status: ZDP_SUCCESS (0x0)
Status: 0x00 (Success) (0x0)
Commissioning Mode: 0x01 (Network Steering) (0x1)
Commissioning Mode: 67 (0x43)
3. You can run the following MT commands to setup Zigbee 3.0 router.
Id: 0x0087
Offset: 0x00
Len: 0x01
Value: . (0x01)
isPrimary: TRUE (0x1)
Channel: CHNL_0x00002000 (0x2000)
Status: SUCCESS (0x0)
10:44:11.43 COM1 APP_CNF_BDB_SET_CHANNEL (0x2F08) --> Set Secondary channel to 0x0 to disable secondary channel mask
isPrimary: FALSE (0x0)
Channel: NONE (0x0)
Status: SUCCESS (0x0)
CommissioningMode: (0x02) Network Steering (0x2)
Status: SUCCESS (0x0)
Status: 1 (0x1)
Commissioning Mode: 0x01 (Network Steering) (0x1)
Commissioning Mode: 0 (0x0)
State: INVALID_PARAMETER (0x2)
State: INVALID_PARAMETER (0x2)
State: 3 (0x3)
State: 5 (0x5)
State: 7 (0x7)
Status: 0x00 (Success) (0x0)
Commissioning Mode: 0x01 (Network Steering) (0x1)
Commissioning Mode: 0 (0x0)
Status: SUCCESS (0x0)
IEEEAddr: 0x00124B0000E50127
ShortAddress: 0x4EE6
DeviceType: COORDINATOR, ROUTER, END_DEVICE (0x7)
DeviceState: DEV_ROUTER (0x7)
NumAssocDevices: 0x00
AssocDevicesList
4. On Ztool of coordinator, you should see ZDO_END_DEVICE_ANNCE_IND pops when router joins coordinator.
SrcAddr: 0x4EE6
NwkAddr: 0x4EE6
IEEEAddr: 0x00124B0000E50127
Capabilities: 0x8E
Thursday, October 27, 2016
How to create a periodic event for CC253x/CC254x Z-Stack and BLE Stack.
The following codes show example to create a periodic event that is triggered every 5 seconds for CC253x in Z-Stack and you can do it accordingly for CC254x in BLE Stack.
1. Add "#define PERIODIC_EVT 0x0001"in your code. Please note that event define has to be an unused bit mask of uint16.
2. Put the following line at where you want to start PERIODIC_EVT
osal_start_timerEx( zcl_XXX_TaskID, PERIODIC_EVT, 10 );
2. Create PERIODIC_EVT processing in zcl_XXX_event_loop
if( events & PERIODIC_EVT )
{
//Do things that need periodic processing here!
...
osal_start_timerEx( zcl_XXX_TaskID, PERIODIC_EVT, 5000 );
return (events ^ PERIODIC_EVT);
}
1. Add "#define PERIODIC_EVT 0x0001"in your code. Please note that event define has to be an unused bit mask of uint16.
2. Put the following line at where you want to start PERIODIC_EVT
osal_start_timerEx( zcl_XXX_TaskID, PERIODIC_EVT, 10 );
2. Create PERIODIC_EVT processing in zcl_XXX_event_loop
if( events & PERIODIC_EVT )
{
//Do things that need periodic processing here!
...
osal_start_timerEx( zcl_XXX_TaskID, PERIODIC_EVT, 5000 );
return (events ^ PERIODIC_EVT);
}
Thursday, September 8, 2016
How to use two UART ports in CC2530 Z-Stack
The following steps show how to use two UART ports in CC2530 Z-Stack
1. Define HAL_UART=TRUE, HAL_UART_ISR=1, and HAL_UART_DMA=2 in compile options.
2. Initialize and use UART0 (P0_2 as RX/P0_3 as TX) as the followings:
void initUart0(halUARTCBack_t pf)
{
halUARTCfg_t uartConfig;
uartConfig.configured = TRUE;
uartConfig.baudRate = HAL_UART_BR_115200;
uartConfig.flowControl = FALSE;
uartConfig.flowControlThreshold = 48;
uartConfig.rx.maxBufSize = 128;
uartConfig.tx.maxBufSize = 128;
uartConfig.idleTimeout = 6;
uartConfig.intEnable = TRUE;
uartConfig.callBackFunc = pf;
HalUARTOpen (HAL_UART_PORT_0, &uartConfig);
}
void uart0RxCb( uint8 port, uint8 event )
{
uint8 ch;
while (Hal_UART_RxBufLen(port))
{
// Read one byte from UART to ch
HalUARTRead (port, &ch, 1);
}
}
initUart0(uart0RxCb);
//Output "UART0 output test" to P0.3
HalUARTWrite( HAL_UART_PORT_0, "UART0 output test", (byte)osal_strlen("UART0 output test"));
3. Initialize and use UART1 (P1_6 as TX/P1_7 as RX) as the followings:
void initUart1(halUARTCBack_t pf)
{
halUARTCfg_t uartConfig;
uartConfig.configured = TRUE;
uartConfig.baudRate = HAL_UART_BR_115200;
uartConfig.flowControl = FALSE;
uartConfig.flowControlThreshold = 48;
uartConfig.rx.maxBufSize = 128;
uartConfig.tx.maxBufSize = 128;
uartConfig.idleTimeout = 6;
uartConfig.intEnable = TRUE;
uartConfig.callBackFunc = pf;
HalUARTOpen (HAL_UART_PORT_1, &uartConfig);
}
void uart1RxCb( uint8 port, uint8 event )
{
uint8 ch;
while (Hal_UART_RxBufLen(port))
{
// Read one byte from UART to ch
HalUARTRead (port, &ch, 1);
}
}
initUart1(uart0RxCb);
//Output "UART1 output test" to P1.6
HalUARTWrite( HAL_UART_PORT_1, "UART1 output test", (byte)osal_strlen("UART1 output test"));
1. Define HAL_UART=TRUE, HAL_UART_ISR=1, and HAL_UART_DMA=2 in compile options.
2. Initialize and use UART0 (P0_2 as RX/P0_3 as TX) as the followings:
void initUart0(halUARTCBack_t pf)
{
halUARTCfg_t uartConfig;
uartConfig.configured = TRUE;
uartConfig.baudRate = HAL_UART_BR_115200;
uartConfig.flowControl = FALSE;
uartConfig.flowControlThreshold = 48;
uartConfig.rx.maxBufSize = 128;
uartConfig.tx.maxBufSize = 128;
uartConfig.idleTimeout = 6;
uartConfig.intEnable = TRUE;
uartConfig.callBackFunc = pf;
HalUARTOpen (HAL_UART_PORT_0, &uartConfig);
}
void uart0RxCb( uint8 port, uint8 event )
{
uint8 ch;
while (Hal_UART_RxBufLen(port))
{
// Read one byte from UART to ch
HalUARTRead (port, &ch, 1);
}
}
initUart0(uart0RxCb);
//Output "UART0 output test" to P0.3
HalUARTWrite( HAL_UART_PORT_0, "UART0 output test", (byte)osal_strlen("UART0 output test"));
3. Initialize and use UART1 (P1_6 as TX/P1_7 as RX) as the followings:
void initUart1(halUARTCBack_t pf)
{
halUARTCfg_t uartConfig;
uartConfig.configured = TRUE;
uartConfig.baudRate = HAL_UART_BR_115200;
uartConfig.flowControl = FALSE;
uartConfig.flowControlThreshold = 48;
uartConfig.rx.maxBufSize = 128;
uartConfig.tx.maxBufSize = 128;
uartConfig.idleTimeout = 6;
uartConfig.intEnable = TRUE;
uartConfig.callBackFunc = pf;
HalUARTOpen (HAL_UART_PORT_1, &uartConfig);
}
void uart1RxCb( uint8 port, uint8 event )
{
uint8 ch;
while (Hal_UART_RxBufLen(port))
{
// Read one byte from UART to ch
HalUARTRead (port, &ch, 1);
}
}
initUart1(uart0RxCb);
//Output "UART1 output test" to P1.6
HalUARTWrite( HAL_UART_PORT_1, "UART1 output test", (byte)osal_strlen("UART1 output test"));
Wednesday, August 31, 2016
How to handle end node announcement, active endpoint response, and simple descriptor response in Z-Stack for CC2530 and CC2538.
When a Zigbee device joins network, it would broadcast end node announcement with its short and IEEE address. We can register a callback event in Z-Stack to receive end node announcement and store short/IEEE address of device to a device list. Then, we usually call ZDP_ActiveEPReq to request active endpoint and register a callback event in Z-Stack to receive active endpoint response and store it to device list. Finally, we can call ZDP_SimpleDescReq to request simple descriptor and register a callback event in Z-Stack to receive simple descriptor response and store it to device list too.
The following steps show you how to handle end node announcement in Z-Stack SampleLight.
1. Add "ZDO_RegisterForZDOMsg(task_id, Device_annce);" in zclSampleLight_Init().
2. Add the following codes to process Device_annce event in zclSampleLight_ProcessZDOMsgs and you would get end node announcement information in devAnnce structure.
ZDO_DeviceAnnce_t devAnnce;
if ( pMsg->clusterID == Device_annce )
ZDO_ParseDeviceAnnce( pMsg, &devAnnce );
The following steps show you how to handle active endpoint response in Z-Stack SampleLight.
1. Add "ZDO_RegisterForZDOMsg(task_id, Active_EP_rsp);" in zclSampleLight_Init().
2. Add the following codes to process Active_EP_rsp event in zclSampleLight_ProcessZDOMsgs and you would get end node announcement information in pActiveEndpointRsp pointer of ZDO_ActiveEndpointRsp_t structure.
ZDO_ActiveEndpointRsp_t *pActiveEndpointRsp;
if ( pMsg->clusterID == Active_EP_rsp )
pActiveEndpointRsp = ZDO_ParseEPListRsp( pMsg );
The following steps show you how to handle simple descriptor response in Z-Stack SampleLight.
1. Add "ZDO_RegisterForZDOMsg(task_id, Simple_Desc_rsp);" in zclSampleLight_Init().
2. Add the following codes to process Simple_Desc_rsp event in zclSampleLight_ProcessZDOMsgs and you would get simple descriptor in simpleDescRsp structure.
ZDO_SimpleDescRsp_t simpleDescRsp;
if ( pMsg->clusterID == Simple_Desc_rsp )
ZDO_ParseSimpleDescRsp( pMsg, &simpleDescRsp );
The following steps show you how to handle end node announcement in Z-Stack SampleLight.
1. Add "ZDO_RegisterForZDOMsg(task_id, Device_annce);" in zclSampleLight_Init().
2. Add the following codes to process Device_annce event in zclSampleLight_ProcessZDOMsgs and you would get end node announcement information in devAnnce structure.
ZDO_DeviceAnnce_t devAnnce;
if ( pMsg->clusterID == Device_annce )
ZDO_ParseDeviceAnnce( pMsg, &devAnnce );
The following steps show you how to handle active endpoint response in Z-Stack SampleLight.
1. Add "ZDO_RegisterForZDOMsg(task_id, Active_EP_rsp);" in zclSampleLight_Init().
2. Add the following codes to process Active_EP_rsp event in zclSampleLight_ProcessZDOMsgs and you would get end node announcement information in pActiveEndpointRsp pointer of ZDO_ActiveEndpointRsp_t structure.
ZDO_ActiveEndpointRsp_t *pActiveEndpointRsp;
if ( pMsg->clusterID == Active_EP_rsp )
pActiveEndpointRsp = ZDO_ParseEPListRsp( pMsg );
The following steps show you how to handle simple descriptor response in Z-Stack SampleLight.
1. Add "ZDO_RegisterForZDOMsg(task_id, Simple_Desc_rsp);" in zclSampleLight_Init().
2. Add the following codes to process Simple_Desc_rsp event in zclSampleLight_ProcessZDOMsgs and you would get simple descriptor in simpleDescRsp structure.
ZDO_SimpleDescRsp_t simpleDescRsp;
if ( pMsg->clusterID == Simple_Desc_rsp )
ZDO_ParseSimpleDescRsp( pMsg, &simpleDescRsp );
Friday, January 22, 2016
How to clone an existing Z-Stack coordinator.
The following steps are used for cloning an existing Z-Stack coordinator.
1. Enable Compiler option MT_SYS_KEY_MANAGEMENT on coordinator.
2. Use MT command to read out the following NV items from coordinator that you want to clone.
3. Turn off old coordinator.
4. Flash the same coordinator binary to the new coordinator.
5. Using MT command to write NV items data that are read out in step 2.
6. Restart new coordinator to work.
1. Enable Compiler option MT_SYS_KEY_MANAGEMENT on coordinator.
2. Use MT command to read out the following NV items from coordinator that you want to clone.
- ZCD_NV_EXTADDR(0x0001)
- ZCD_NV_BOOTCOUNTER(0x0002) – optional, If Diagnostics feature is necessary (new for HA spec.1.2)
- ZCD_NV_NIB(0x0021)
- ZCD_NV_EXTENDED_PAN_ID(0x002D)
- ZCD_NV_NWK_ACTIVE_KEY_INFO(0x003A)
- ZCD_NV_NWK_ALTERN_KEY_INFO(0x003B)
- ZCD_NV_APS_USE_EXT_PANID(0x0047)
- ZCD_NV_PRECFGKEY(0x0062)
- ZCD_NV_TCLK_TABLE_START(0x0101)
3. Turn off old coordinator.
4. Flash the same coordinator binary to the new coordinator.
5. Using MT command to write NV items data that are read out in step 2.
6. Restart new coordinator to work.
Tuesday, January 19, 2016
How to use SensorTag CC2650STK with CC-DEVPACK-DEBUGGER as ZNP and connect to Z-Stack ZTool.
The following steps show you how to use SensorTag CC2650STK with CC-DEVPACK-DEBUGGER as ZNP and connect to Z-Stack ZTool.
1. Revise the following code in Board.h (C:\ti\tirtos_simplelink_2_11_01_09\packages\ti\boards\SRF06EB\CC2650EM_7ID)
#define Board_UART_RX IOID_2 /* RF1.7 */
#define Board_UART_TX IOID_3 /* RF1.9 */
to
#define Board_UART_RX IOID_28 /* RF1.7 */
#define Board_UART_TX IOID_29 /* RF1.9 */
2. Rebuild CC2650 ZNP example and download it to CC2650STK.
3. Disconnect CC2650STK from CC-DEVPACK-DEBUGGER and connect it to restart.
4. Find COM port of XDS110 Class Application/User UART.
5. Open ZTool and select COM port of XDS110 Class Application/User UART. Remember to select Flow to None.
6. You should see CC2650STK ZNP is connected with ZTool.
1. Revise the following code in Board.h (C:\ti\tirtos_simplelink_2_11_01_09\packages\ti\boards\SRF06EB\CC2650EM_7ID)
#define Board_UART_RX IOID_2 /* RF1.7 */
#define Board_UART_TX IOID_3 /* RF1.9 */
to
#define Board_UART_RX IOID_28 /* RF1.7 */
#define Board_UART_TX IOID_29 /* RF1.9 */
2. Rebuild CC2650 ZNP example and download it to CC2650STK.
3. Disconnect CC2650STK from CC-DEVPACK-DEBUGGER and connect it to restart.
4. Find COM port of XDS110 Class Application/User UART.
5. Open ZTool and select COM port of XDS110 Class Application/User UART. Remember to select Flow to None.
6. You should see CC2650STK ZNP is connected with ZTool.
Monday, January 4, 2016
Set the Logical Device type to Coordinator and router dynamically using Z-Stack on CC2538DK
Apply the following steps to SampleLight coordinator project and I can set the Logical Device type to Coordinator and router at run time.
1. Add "uint8 dev_type=0;" as global variable in ZDApp.c.
2. Add the red part in ZDAppDetermineDeviceType.
void ZDAppDetermineDeviceType( void )
{
if (dev_type==0)
zgDeviceLogicalType = ZG_DEVICETYPE_COORDINATOR;
else if(dev_type==1)
zgDeviceLogicalType = ZG_DEVICETYPE_ROUTER;
if ( zgDeviceLogicalType ==ZG_DEVICETYPE_COORDINATOR )
{
devStartMode = MODE_HARD; // Start as a coordinator
ZDO_Config_Node_Descriptor.LogicalType = NODETYPE_COORDINATOR;
}
else
{
if (dev_type==0)
zgDeviceLogicalType = ZG_DEVICETYPE_COORDINATOR;
else if(dev_type==1)
zgDeviceLogicalType = ZG_DEVICETYPE_ROUTER;
if ( zgDeviceLogicalType ==ZG_DEVICETYPE_COORDINATOR )
{
devStartMode = MODE_HARD; // Start as a coordinator
ZDO_Config_Node_Descriptor.LogicalType = NODETYPE_COORDINATOR;
}
else
...
3. Revise the red part in ZDAppCheckForHoldKey.
void ZDAppCheckForHoldKey( void )
{
#if (defined HAL_KEY) && (HAL_KEY == TRUE)
// Get Keypad directly to see if a HOLD is needed
zdappHoldKeys = HalKeyRead();
// Hold down the SW_BYPASS_START key (see OnBoard.h)
// while booting to avoid starting up the device.
if ( zdappHoldKeys == SW_BYPASS_START )
{
// Change the device state to HOLD on start up
//devState = DEV_HOLD;
dev_type=1;
}
#endif // HAL_KEY
}
{
#if (defined HAL_KEY) && (HAL_KEY == TRUE)
// Get Keypad directly to see if a HOLD is needed
zdappHoldKeys = HalKeyRead();
// Hold down the SW_BYPASS_START key (see OnBoard.h)
// while booting to avoid starting up the device.
if ( zdappHoldKeys == SW_BYPASS_START )
{
// Change the device state to HOLD on start up
//devState = DEV_HOLD;
dev_type=1;
}
#endif // HAL_KEY
}
4. Revise the red part in ZGlobals.h
extern uint8 dev_type;
/*********************************************************************
* MACROS
*/
#if defined( BUILD_ALL_DEVICES ) && !defined( ZSTACK_DEVICE_BUILD )
#define ZSTACK_DEVICE_BUILD (DEVICE_BUILD_COORDINATOR | DEVICE_BUILD_ROUTER | DEVICE_BUILD_ENDDEVICE)
#endif
// Setup to work with the existing (old) compile flags
#if 0
#if !defined ( ZSTACK_DEVICE_BUILD )
#if defined ( ZDO_COORDINATOR )
#define ZSTACK_DEVICE_BUILD (DEVICE_BUILD_COORDINATOR)
#elif defined ( RTR_NWK )
#define ZSTACK_DEVICE_BUILD (DEVICE_BUILD_ROUTER)
#else
#define ZSTACK_DEVICE_BUILD (DEVICE_BUILD_ENDDEVICE)
#endif
#endif
#else
#define ZSTACK_DEVICE_BUILD (dev_type+1)
#endif
* MACROS
*/
#if defined( BUILD_ALL_DEVICES ) && !defined( ZSTACK_DEVICE_BUILD )
#define ZSTACK_DEVICE_BUILD (DEVICE_BUILD_COORDINATOR | DEVICE_BUILD_ROUTER | DEVICE_BUILD_ENDDEVICE)
#endif
// Setup to work with the existing (old) compile flags
#if 0
#if !defined ( ZSTACK_DEVICE_BUILD )
#if defined ( ZDO_COORDINATOR )
#define ZSTACK_DEVICE_BUILD (DEVICE_BUILD_COORDINATOR)
#elif defined ( RTR_NWK )
#define ZSTACK_DEVICE_BUILD (DEVICE_BUILD_ROUTER)
#else
#define ZSTACK_DEVICE_BUILD (DEVICE_BUILD_ENDDEVICE)
#endif
#endif
#else
#define ZSTACK_DEVICE_BUILD (dev_type+1)
#endif
5. Compile the code and download it to CC2538DK. If I turn on CC2538DK without pressing any button, it will become ZC. If I turn on CC2538DK with UP key pressed, it will become ZR.
Friday, October 23, 2015
How to do device binding from TI Ztool and CC2531 USB dongle to CC2650 SensorTag using ZDO_BIND_REQ.
The following steps show how to do device binding from TI Ztool and CC2531 USB dongle to CC2650 SensorTag using ZDO_BIND_REQ.
1. Refer to http://sunmaysky.blogspot.tw/2015/10/setup-zigbee-ha-coordinator-with-ti.html and setup Zigbee HA coordinator with TI Ztool and CC2531 USB dongle and use CC2650 SensorTag as Zigbee end device to join coordinator.
2. Use ZDO_IEEE_ADDR_REQ with ShortAddr=0 to request IEEE address of coordinator which we would need when we do binding request. In my test, it responses IEEEAddr: 0x00124B0002F1DC2B.
3. Send ZDO_BIND_REQ with DstAddr=0x65D1 (short address of CC2650STK), SrcAddress=0x124B00069F3B89 (IEEE address of CC2650STK), SrcEndPoint=9 (active endpoint of temperature cluster support in CC2650STK), ClusterID=0x0402 (Zigbee cluster temperature ID), BindAddrMode=0x03 (must use 64 Bits address mode), BindAddr=0x00124B0002F1DC2B (IEEE address of coordinator in test case),and BindEndPoint=7 (active endpoint on coordinator).
4. After sending ZDO_BIND_REQ, you would receive ZDO_BIND_RSP which shows binding success. The temperature report would be receive as AF_INCOMING_MSG.
5. The temperature is shown on latest two bytes (little endian) of AF_INCOMING_MSG data
1. Refer to http://sunmaysky.blogspot.tw/2015/10/setup-zigbee-ha-coordinator-with-ti.html and setup Zigbee HA coordinator with TI Ztool and CC2531 USB dongle and use CC2650 SensorTag as Zigbee end device to join coordinator.
2. Use ZDO_IEEE_ADDR_REQ with ShortAddr=0 to request IEEE address of coordinator which we would need when we do binding request. In my test, it responses IEEEAddr: 0x00124B0002F1DC2B.
3. Send ZDO_BIND_REQ with DstAddr=0x65D1 (short address of CC2650STK), SrcAddress=0x124B00069F3B89 (IEEE address of CC2650STK), SrcEndPoint=9 (active endpoint of temperature cluster support in CC2650STK), ClusterID=0x0402 (Zigbee cluster temperature ID), BindAddrMode=0x03 (must use 64 Bits address mode), BindAddr=0x00124B0002F1DC2B (IEEE address of coordinator in test case),and BindEndPoint=7 (active endpoint on coordinator).
4. After sending ZDO_BIND_REQ, you would receive ZDO_BIND_RSP which shows binding success. The temperature report would be receive as AF_INCOMING_MSG.
5. The temperature is shown on latest two bytes (little endian) of AF_INCOMING_MSG data
Setup Zigbee HA coordinator with TI Ztool and CC2531 USB dongle and use CC2650 SensorTag as Zigbee end device to join coordinator.
The following steps show you how to setup Zigbee HA coordinator with TI Ztool and CC2531 USB dongle and use CC2650 SensorTag as Zigbee end device to join coordinator.
1. Use CC Debugger to download CC2531ZNP-Pro-Secure_LinkKeyJoin.hex to your CC2531 USB dongle. Plug CC2531 USB dongle into USB socket of your PC and you should have it enum as a CDC Serial Port (mine is COM29 in the test.)
2. Set com port setting to 115200 Baudrate and Handshake as none
3. Press "Scan for devices" button on Ztool. If your COM port is scanned successfully in ZTool, it should looks like the following screen shot.
4. Run the attached script coordinator_light.zip to initialize coordinator from Ztool.
p.s. The script uses
Zigbee channel 11 and do remember to change ZC_Com in the script to your CC2531 virtual COM number. In my test, it is COM29.
5. Build Zigbee SensorTag (CC2650STK) to join as end device. Make sure you use -DDEFAULT_CHANLIST=0x00000800 (channel 11) in f8wconfig.cfg and set "xHOLD_AUTO_START" and "xNV_RESTORE" in ZStackCore. Set "xZCL_EZMODE" in SensorTag application. Compile SensorTag and download it to your CC2650STK.
6. Enable permit join on coordinator by sending ZDO_MGMT_PERMIT_JOIN_REQUEST with AddrMode=0x02, DstAddr=0, and Duration=255.
1. Use CC Debugger to download CC2531ZNP-Pro-Secure_LinkKeyJoin.hex to your CC2531 USB dongle. Plug CC2531 USB dongle into USB socket of your PC and you should have it enum as a CDC Serial Port (mine is COM29 in the test.)
2. Set com port setting to 115200 Baudrate and Handshake as none
3. Press "Scan for devices" button on Ztool. If your COM port is scanned successfully in ZTool, it should looks like the following screen shot.
4. Run the attached script coordinator_light.zip to initialize coordinator from Ztool.
5. Build Zigbee SensorTag (CC2650STK) to join as end device. Make sure you use -DDEFAULT_CHANLIST=0x00000800 (channel 11) in f8wconfig.cfg and set "xHOLD_AUTO_START" and "xNV_RESTORE" in ZStackCore. Set "xZCL_EZMODE" in SensorTag application. Compile SensorTag and download it to your CC2650STK.
6. Enable permit join on coordinator by sending ZDO_MGMT_PERMIT_JOIN_REQUEST with AddrMode=0x02, DstAddr=0, and Duration=255.
7.Power on CC2650STK and you should see ZDO_END_DEVICE_ANNCE_IND some seconds later.
Setup Zigbee HA coordinator with TI Ztool and CC2531 USB dongle and use CC2650 SensorTag as Zigbee end device to join coordinator.
The following steps show you how to setup Zigbee HA coordinator with TI Ztool and CC2531 USB dongle and use CC2650 SensorTag as Zigbee end device to join coordinator.
1. Use CC Debugger to download CC2531ZNP-Pro-Secure_LinkKeyJoin.hex to your CC2531 USB dongle. Plug CC2531 USB dongle into USB socket of your PC and you should have it enum as a CDC Serial Port (mine is COM29 in the test.)
2. Set com port setting to 115200 Baudrate and Handshake as none
3. Press "Scan for devices" button on Ztool. If your COM port is scanned successfully in ZTool, it should looks like the following screen shot.
4. Run the attached script coordinator_light.zip to initialize coordinator from Ztool.
p.s. The script uses
Zigbee channel 11 and do remember to change ZC_Com in the script to your CC2531 virtual COM number. In my test, it is COM29.
5. Build Zigbee SensorTag (CC2650STK) to join as end device. Make sure you use -DDEFAULT_CHANLIST=0x00000800 (channel 11) in f8wconfig.cfg and set "xHOLD_AUTO_START" and "xNV_RESTORE" in ZStackCore. Set "xZCL_EZMODE" in SensorTag application. Compile SensorTag and download it to your CC2650STK.
6. Enable permit join on coordinator by sending ZDO_MGMT_PERMIT_JOIN_REQUEST with AddrMode=0x02, DstAddr=0, and Duration=255.
1. Use CC Debugger to download CC2531ZNP-Pro-Secure_LinkKeyJoin.hex to your CC2531 USB dongle. Plug CC2531 USB dongle into USB socket of your PC and you should have it enum as a CDC Serial Port (mine is COM29 in the test.)
2. Set com port setting to 115200 Baudrate and Handshake as none
3. Press "Scan for devices" button on Ztool. If your COM port is scanned successfully in ZTool, it should looks like the following screen shot.
4. Run the attached script coordinator_light.zip to initialize coordinator from Ztool.
5. Build Zigbee SensorTag (CC2650STK) to join as end device. Make sure you use -DDEFAULT_CHANLIST=0x00000800 (channel 11) in f8wconfig.cfg and set "xHOLD_AUTO_START" and "xNV_RESTORE" in ZStackCore. Set "xZCL_EZMODE" in SensorTag application. Compile SensorTag and download it to your CC2650STK.
6. Enable permit join on coordinator by sending ZDO_MGMT_PERMIT_JOIN_REQUEST with AddrMode=0x02, DstAddr=0, and Duration=255.
7.Power on CC2650STK and you should see ZDO_END_DEVICE_ANNCE_IND some seconds later.
Wednesday, August 26, 2015
How to create a periodic event in TI Z-Stack or BLE-Stack
The following codes are example to start PERIODIC_EVT every second and you can do any periodic processing in PERIODIC_EVT.
//Put where you want to start PERIODIC_EVT
osal_start_timerEx( XXX_TaskID, SENSOR_READ_EVT, 1000 );
//For Z-Stack, create PERIODIC_EVT processing in zcl_XXX_event_loop
//For BLE-Stack, create PERIODIC_EVT processing in xxx_ProcessEvent
if( events & PERIODIC_EVT )
{
//Do things that need periodic processing here!
...
osal_start_timerEx( XXX_TaskID, PERIODIC_EVT, 1000 );
return (events ^ PERIODIC_EVT);
}
//Put where you want to start PERIODIC_EVT
osal_start_timerEx( XXX_TaskID, SENSOR_READ_EVT, 1000 );
//For Z-Stack, create PERIODIC_EVT processing in zcl_XXX_event_loop
//For BLE-Stack, create PERIODIC_EVT processing in xxx_ProcessEvent
if( events & PERIODIC_EVT )
{
//Do things that need periodic processing here!
...
osal_start_timerEx( XXX_TaskID, PERIODIC_EVT, 1000 );
return (events ^ PERIODIC_EVT);
}
Tuesday, December 30, 2014
Demostrate more than 100 ZR/ZED nodes in a single Zigbee HA 1.2 Network
More than 100 ZR/ZED node in a single Zigbee network
Wednesday, November 26, 2014
How to output PWM from CC2530/CC2541
Refer to CC253x/4x User's Guide. The following sample code can send PWM to P1_4.
PERCFG &= (~(0x20)); // Select Timer 3 Alternative 1 location
P2SEL |=0x20;
P2DIR |= 0xC0; // Give priority to Timer 1 channel2-3
P1SEL |= BV(4); // Set P1_4 to peripheral, Timer 1,channel 2
P1DIR |= BV(4);
T3CTL &= ~0x10; // Stop timer 3 (if it was running)
T3CTL |= 0x04; // Clear timer 3
T3CTL &= ~0x08; // Disable Timer 3 overflow interrupts
T3CTL |= 0x03; // Timer 3 mode = 3 - Up/Down
T3CCTL1 &= ~0x40; // Disable channel 0 interrupts
T3CCTL1 |= 0x04; // Ch0 mode = compare
T3CCTL1 |= 0x10; // Ch0 output compare mode = toggle on compare
T3CTL &= ~0xE0; // Clear Prescaler divider value
T3CTL |= 0xA0; //Set Prescaler divider value = Tick frequency /32
T3CC0 = 128; //Set ticks = 128
// Start timer
T3CTL |= 0x10;
Then, the following example shows you how you output 6.5K PWM with 50% duty cycle to P1.1 with CC2530 Timer 1.
PERCFG |= BV(6); // Select Timer 1 Alternative 2 location
P2DIR = (P2DIR & ~0xC0) | 0x80; // Give priority to Timer 1
P1SEL |= BV(1); // Set P1_1 to peripheral
T1CC0L = 0x3A; // PWM signal period
T1CC0H = 0x01;
T1CC1L = 0x9D; // PWM duty cycle
T1CC1H = 0x00;
T1CCTL1 = 0x1c;
T1CTL |= (BV(2)|0x03); // divide with 128 and to do i up-down mode
PERCFG &= (~(0x20)); // Select Timer 3 Alternative 1 location
P2SEL |=0x20;
P2DIR |= 0xC0; // Give priority to Timer 1 channel2-3
P1SEL |= BV(4); // Set P1_4 to peripheral, Timer 1,channel 2
P1DIR |= BV(4);
T3CTL &= ~0x10; // Stop timer 3 (if it was running)
T3CTL |= 0x04; // Clear timer 3
T3CTL &= ~0x08; // Disable Timer 3 overflow interrupts
T3CTL |= 0x03; // Timer 3 mode = 3 - Up/Down
T3CCTL1 &= ~0x40; // Disable channel 0 interrupts
T3CCTL1 |= 0x04; // Ch0 mode = compare
T3CCTL1 |= 0x10; // Ch0 output compare mode = toggle on compare
T3CTL &= ~0xE0; // Clear Prescaler divider value
T3CTL |= 0xA0; //Set Prescaler divider value = Tick frequency /32
T3CC0 = 128; //Set ticks = 128
// Start timer
T3CTL |= 0x10;
Then, the following example shows you how you output 6.5K PWM with 50% duty cycle to P1.1 with CC2530 Timer 1.
PERCFG |= BV(6); // Select Timer 1 Alternative 2 location
P2DIR = (P2DIR & ~0xC0) | 0x80; // Give priority to Timer 1
P1SEL |= BV(1); // Set P1_1 to peripheral
T1CC0L = 0x3A; // PWM signal period
T1CC0H = 0x01;
T1CC1L = 0x9D; // PWM duty cycle
T1CC1H = 0x00;
T1CCTL1 = 0x1c;
T1CTL |= (BV(2)|0x03); // divide with 128 and to do i up-down mode
How to do temperature monitoring using CC2530 with TI Z-Stack
The battery monitor can also be used to do some simple temperature monitoring in CC2530. When the battery monitor is connected to the internal temperature sensor instead of the supply voltage AVDD5.
The following readTemperature function provides capability to read temperature using CC2530 internal ADC and sensor. When first time call this function, you have to keep temperature at 22oC for calibration.
int8 readTemperature(void)
{
static uint16 voltageAtTemp22;
static uint8 bCalibrate=TRUE; // Calibrate the first time the temp sensor is read
uint16 value;
int8 temp;
ATEST = 0x01;
TR0 |= 0x01;
/* Clear ADC interrupt flag */
ADCIF = 0;
ADCCON3 = (HAL_ADC_REF_125V | HAL_ADC_DEC_512 | HAL_ADC_CHN_TEMP);
/* Wait for the conversion to finish */
while ( !ADCIF );
/* Get the result */
value = ADCL;
value |= ((uint16) ADCH) << 8;
// Use the 12 MSB of adcValue
value >>= 4;
/*
* These parameters are typical values and need to be calibrated
* See the datasheet for the appropriate chip for more details
* also, the math below may not be very accurate
*/
/* Assume ADC = 1480 at 25C and ADC = 4/C */
#define VOLTAGE_AT_TEMP_25 1480
#define TEMP_COEFFICIENT 4
// Calibrate for 22C the first time the temp sensor is read.
// This will assume that the demo is started up in temperature of 22C
if(bCalibrate) {
voltageAtTemp22=value;
bCalibrate=FALSE;
}
temp = 22 + ( (value - voltageAtTemp22) / TEMP_COEFFICIENT );
// Set 0C as minimum temperature, and 100C as max
if( temp >= 100)
{
return 100;
}
else if (temp <= 0) {
return 0;
}
else {
return temp;
}
}
The following readTemperature function provides capability to read temperature using CC2530 internal ADC and sensor. When first time call this function, you have to keep temperature at 22oC for calibration.
int8 readTemperature(void)
{
static uint16 voltageAtTemp22;
static uint8 bCalibrate=TRUE; // Calibrate the first time the temp sensor is read
uint16 value;
int8 temp;
ATEST = 0x01;
TR0 |= 0x01;
/* Clear ADC interrupt flag */
ADCIF = 0;
ADCCON3 = (HAL_ADC_REF_125V | HAL_ADC_DEC_512 | HAL_ADC_CHN_TEMP);
/* Wait for the conversion to finish */
while ( !ADCIF );
/* Get the result */
value = ADCL;
value |= ((uint16) ADCH) << 8;
// Use the 12 MSB of adcValue
value >>= 4;
/*
* These parameters are typical values and need to be calibrated
* See the datasheet for the appropriate chip for more details
* also, the math below may not be very accurate
*/
/* Assume ADC = 1480 at 25C and ADC = 4/C */
#define VOLTAGE_AT_TEMP_25 1480
#define TEMP_COEFFICIENT 4
// Calibrate for 22C the first time the temp sensor is read.
// This will assume that the demo is started up in temperature of 22C
if(bCalibrate) {
voltageAtTemp22=value;
bCalibrate=FALSE;
}
temp = 22 + ( (value - voltageAtTemp22) / TEMP_COEFFICIENT );
// Set 0C as minimum temperature, and 100C as max
if( temp >= 100)
{
return 100;
}
else if (temp <= 0) {
return 0;
}
else {
return temp;
}
}
Subscribe to:
Posts (Atom)