Part Number:CC2652POther Parts Discussed in Thread:Z-STACK
Protocol stack initialization; First, I use the editor as the official CCS, open the official Z-stack routine, delete the official application layer, and configure the Z-stack initialization according to the official API. Can't it be configured like this way? This is done according to the official API
The configuration is as follows:
staticvoidzclGenericApp_Init(void )
{
//RegisterEndpoint
//Register one or more Zigbee Device Endpoints by calling Zstackapi_AfRegisterReq().
zclGenericAppEpDesc.endPoint = GENERICAPP_ENDPOINT;
zclGenericAppEpDesc.simpleDesc = &zclGenericApp_SimpleDesc;
zclport_registerEndpoint(appServiceTaskId, &zclGenericAppEpDesc);//Zstackapi_AfRegisterReq
/*Register for Z-Stack Callback (asynchronous) messages by calling Zstackapi_DevZDOCBReq() with the wanted callbacks.*/
SetupZStackCallbacks();//Zstackapi_DevZDOCBReq
/*Write Z-Stack parameters by calling Zstackapi_sysConfigWriteReq() with the wanted parameters. */
myZstackapi_sysConfigWriteReq();//Zstackapi_sysConfigWriteReq
/*Call Zstackapi_DevStartReq() to start the Z-Stack Thread's automatic joining process.*/
myZstackapi_DevStartReq();
/* call zclport_getDeviceInfo()to retrieve the device's joined network parameters.//
zclport_getDeviceInfo(appServiceTaskId);
*/
}
by calling Zstackapi_AfDataReq() to send application proprietary messages.
Void send(){ Zstackapi_AfDataReq()
API:
The functions defined in zstackapi.h are functions that communicate with the Z-Stack image through OsalPort messaging. If an immediate response, not over the air, is expected, the function will block for the response message.
To setup communicate with the Z-Stack thread, your application should do the following initialization (simplified):
- Register one or more Zigbee Device Endpoints by calling Zstackapi_AfRegisterReq().
- Register for Z-Stack Callback (asynchronous) messages by calling Zstackapi_DevZDOCBReq() with the wanted callbacks. For example, if you would like to receive device state change notifications, you will have to set the has_devStateChange and devStateChange fields to true in a zstack_devZDOCBReq_t, then call Zstackapi_DevZDOCBReq().
- Write Z-Stack parameters by calling Zstackapi_sysConfigWriteReq() with the wanted parameters. Example parameters are channel mask, PAN ID, poll rates, timeouts, etc…
- Call Zstackapi_DevStartReq() to start the Z-Stack Thread's automatic joining process.
When the joining process is complete, you'll receive a zstackmsg_CmdIDs_DEV_STATE_CHANGE_IND message with a state of:
- zstack_DevState_DEV_ZB_COORD – the device started as a coordinator.
- zstack_DevState_DEV_ROUTER – the device joined as a router.
- zstack_DevState_DEV_END_DEVICE – the device joined as an end device.
You should then call zclport_getDeviceInfo(), or Zstackapi_sysNwkInfoReadReq() if your application isn't a ZCL project, to retrieve the device's joined network parameters.
You're free to do device discovery through ZDO commands (ie. Zstackapi_ZdoMatchDescReq()) and send data either through ZCL commands or by calling Zstackapi_AfDataReq() to send application proprietary messages.
Once you've registed an endpoint, your application will recieve any data message addressed to that endpoint as an AF Incoming Data Indication [zstackmsg_afIncomingMsgInd_t with a message event of zstackmsg_CmdIDs_AF_INCOMING_MSG_IND] through an OsalPort message.
Also, any indications or response message that you have signed up for using Zstackapi_DevZDOCBReq() will be delivered to your application as an OsalPort message. For example, the Device State Change message [zstackmsg_devStateChangeInd_t with a message event of zstackmsg_CmdIDs_DEV_STATE_CHANGE_IND].
Annie Liu:
I don't know what you are trying to achieve, however you should definitely be using the default example and not changing any of the Z-Stack initialization procedure until you fully understand the APIs involved. I highly recommend that you get started with Z-Stack development by reviewing the SimpleLink Academy Labs.