Other Parts Discussed in Thread: Z-STACK
when i compile it show me this
"variable "pkt" is used before its value is set"
how do I solve the problem
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Other Parts Discussed in Thread: Z-STACK
when i compile it show me this
"variable "pkt" is used before its value is set"
how do I solve the problem
void zb_HandleKeys( uint8 shift, uint8 keys )
{
uint8 startOptions;
uint8 logicalType;
afIncomingMSGPacket_t *pkt;
uint8 msgLqi = pkt->LinkQuality;
if ( keys & HAL_KEY_SW_6 )
{
if ( myAppState == APP_INIT )
{
// 在”保持“狀態,按下SW6, 該設備將作為一個協調器。
zb_ReadConfiguration( ZCD_NV_LOGICAL_TYPE, sizeof(uint8), &logicalType );
if ( logicalType != ZG_DEVICETYPE_ENDDEVICE )
{
logicalType = ZG_DEVICETYPE_COORDINATOR;
zb_WriteConfiguration(ZCD_NV_LOGICAL_TYPE, sizeof(uint8), &logicalType);
}
// Do more configuration if necessary and then restart device with auto-start bit set
// write endpoint to simple desc...dont pass it in start req..then reset
zb_ReadConfiguration( ZCD_NV_STARTUP_OPTION, sizeof(uint8), &startOptions );
startOptions = ZCD_STARTOPT_AUTO_START;
zb_WriteConfiguration( ZCD_NV_STARTUP_OPTION, sizeof(uint8), &startOptions );
zb_SystemReset();
}
else
{
/*
// Initiate a binding (light)
zb_AllowBind( myAllowBindTimeout );
*/
// Send the command to toggle light (switch)
if( msgLqi > 130)
{
zb_SendDataRequest( 0xFFFE, TOGGLE_LIGHT_CMD_ID, 0,
(uint8 *)NULL , myAppSeqNumber, 0, 0 );
}
}
}
if ( keys & HAL_KEY_SW_3 )
{
if ( myAppState == APP_INIT )
{
// 在“保持”狀態,按下SW3, 該設備將作為一個路由器。
zb_ReadConfiguration( ZCD_NV_LOGICAL_TYPE, sizeof(uint8), &logicalType );
if ( logicalType != ZG_DEVICETYPE_ENDDEVICE )
{
logicalType = ZG_DEVICETYPE_ROUTER;
zb_WriteConfiguration(ZCD_NV_LOGICAL_TYPE, sizeof(uint8), &logicalType);
}
zb_ReadConfiguration( ZCD_NV_STARTUP_OPTION, sizeof(uint8), &startOptions );
startOptions = ZCD_STARTOPT_AUTO_START;
zb_WriteConfiguration( ZCD_NV_STARTUP_OPTION, sizeof(uint8), &startOptions );
zb_SystemReset();
}
else
{
zb_BindDevice( TRUE, TOGGLE_LIGHT_CMD_ID, NULL );
}
}
/* if ( keys & HAL_KEY_SW_1 )
{
}
if ( keys & HAL_KEY_SW_2 )
{
}
*/
--------------------------------------------------------------------------------------
I want to use msgLqi to calculate the distance, but it show me the warning .
These code is in the simpleapp light experiment.
Can you give so suggest? thx~
Use SampleLight as example, you can add the following codes in red.
afIncomingMSGPacket_t pkt;
uint16 zclSampleLight_event_loop( uint8 task_id, uint16 events )
{
afIncomingMSGPacket_t *MSGpkt;
(void)task_id; // Intentionally unreferenced parameter
if ( events & SYS_EVENT_MSG )
{
while ( (MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( zclSampleLight_TaskID )) )
{
pkt.LinkQuality=MSGpkt->LinkQuality;
switch ( MSGpkt->hdr.event )
{
sorry, I have some trouble can you please explain about these...
while ( (MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( zcl_TaskID )) )
-->
a value of type "struct <unnamed> *" cannot be assigned to an entity of type "struct <unnamed>"
switch ( MSGpkt->hdr.event )
-->
expression must have arithmetic or pointer type
expression must have pointer type
osal_msg_deallocate( (uint8 *)MSGpkt );
-->
invalid type conversion
Add the following code in red to SAPI_ProcessEvent.
afIncomingMSGPacket_t pkt;
UINT16 SAPI_ProcessEvent( byte task_id, UINT16 events )
{
osal_event_hdr_t *pMsg;
afIncomingMSGPacket_t *pMSGpkt;
afDataConfirm_t *pDataConfirm;
if ( events & SYS_EVENT_MSG )
{
pMsg = (osal_event_hdr_t *) osal_msg_receive( task_id );
while ( pMsg )
{
switch ( pMsg->event )
{
case ZDO_CB_MSG:
SAPI_ProcessZDOMsgs( (zdoIncomingMsg_t *)pMsg );
break;
case AF_DATA_CONFIRM_CMD:
// This message is received as a confirmation of a data packet sent.
// The status is of ZStatus_t type [defined in ZComDef.h]
// The message fields are defined in AF.h
pDataConfirm = (afDataConfirm_t *) pMsg;
SAPI_SendDataConfirm( pDataConfirm->transID, pDataConfirm->hdr.status );
break;
case AF_INCOMING_MSG_CMD:
pMSGpkt = (afIncomingMSGPacket_t *) pMsg;
pkt.LinkQuality=pMSGpkt->LinkQuality;
SAPI_ReceiveDataIndication( pMSGpkt->srcAddr.addr.shortAddr, pMSGpkt->clusterId,
pMSGpkt->cmd.DataLength, pMSGpkt->cmd.Data);
break;