Hi, I'm working with with codebase 3.0.1 and I have more or less the same problem: I want' my MC1322x ( chip version 2.0) Low Power Node goes to sleep and sends a test message to coordinator when it wake up. But sometimes, after wake up it loses its parents and like in you case "the led 1 blinking, and although I press the button 1 it remains blinking, it doesn´t make anything and it is imposible to rejoin with the coordinator. What is happening?"
To send message I added SendSampleMessage(TRUE); in DeepSleepWakeupStackProc function
/* Called each time deep sleep mode is exited. */
void DeepSleepWakeupStackProc
  (
  void
  )
{
   
  TS_SendEvent(gAppTaskID, gAppEvtSyncReq_c);    
  SendSampleMessage(TRUE);
  return;
}
and defined this function in BeeApp.c
void SendSampleMessage(  bool_t wakeup)
{
  afAddrInfo_t afAddrInfo;
  FLib_MemSet(&afAddrInfo, 0, sizeof(afAddrInfo));
  afAddrInfo.dstAddrMode = gZbAddrMode16Bit_c; /* direct-16 bit*/
  Set2Bytes(afAddrInfo.dstAddr.aNwkAddr, 0x0000); /* short address of coordinator */
  afAddrInfo.dstEndPoint = 0xFF;/*destination endpoint =0xFF : the receiving stack will deliver that message to every endpoint on the node*/
  Copy2Bytes(afAddrInfo.aClusterId, gZclClusterBinaryOutput_c);/* cluster to send it to */
afAddrInfo.srcEndPoint = appEndPoint;
  afAddrInfo.txOptions = gZclTxOptions;//0; /* to ACK or not to ACK, that is the question... */
  afAddrInfo.radiusCounter = afDefaultRadius_c; /* radius */
  if (wakeup==FALSE)
  {
     AF_DataRequest( & afAddrInfo, 14, "\n Hello World\n" , NULL);
  }
  else
  {
     AF_DataRequest( & afAddrInfo, 14, "\n Goodmorning\n" , NULL); 
  }
}
Dear Elisa,
This is very annoying that we can't specify the destination address as in HEX formate directly it won't work out.
Actual problem is in the line
Set2Bytes(afAddrInfo.dstAddr.aNwkAddr, 0x0000); /* short address of coordinator */
To solve this problem you have to take the variable of type zbNwkAddr_t
ex: zbNwkAddr_t aDestAddress = {0x00, 0x00};
and use
Copy2Bytes(afAddrInfo.dstAddr.aNwkAddr, aDestAddress);
This may solve the problem.
Cheer.
Imran
Hi Imram,
sorry but I'm not sure you are right. The Set2Byte function is made to copy a 16 bit variable to a location, with the bytes swapped if little endian, as you can see in BeeCommon.h
/*copies a 16 bit variable to a location with the bytes swapped
  Note needed for big endian
*/
#if !(gBigEndian_c)
void Set2Bytes(void *ptr, uint16_t val);
and it is used, as I used, FOR EXAMPLE in ZdpUtils.c
void GetAddressFromService
(
   ...
        case ZdoBackupBindingTableCache_c:
            if (!Cmp2BytesToZero(pPtr->aServerMask))
                Copy2Bytes(pNwkAddress, pPtr->aNwkAddress);
            else
                Set2Bytes(pNwkAddress, 0xffff);
        break;
        default:
            Set2Bytes(pNwkAddress, 0xffff);
        break;
    }
}
However,I tried to follows your indication but the problem,as I thought, didn't solve.
Dear Elisa,
You are right Set2Byte is made to copy 16 bit variable. But I don't know why it is not working in while copying the address.
My working code looks like this
void TxMyData()
{
  afAddrInfo_t afAddrInfo;
  zbNwkAddr_t DestNwkAddr = { 0X00, 0X00 };
  if (!mTxZigBeeThrottleFlag)
  {
    TS_SendEvent(gAppTaskID, mAppRetryZigBeeDataTx_c);
    return;
  }
  FLib_MemSet(&afAddrInfo, 0, sizeof(afAddrInfo));
  zbTxDataBuffer.status = mBufStatusReadyToSend_c; 
  afAddrInfo.aClusterId[0] = (mDataClusterId_c & 0xFF);
  afAddrInfo.aClusterId[1] = (mDataClusterId_c >> 8);
   
  afAddrInfo.dstAddrMode = gZbAddrMode16Bit_c;
   
  Copy2Bytes(afAddrInfo.dstAddr.aNwkAddr, DestNwkAddr);
  
  afAddrInfo.dstEndPoint = 0xff;
  afAddrInfo.srcEndPoint = appEndPoint;
  /* Turn on security and leave it on. Harmless In a non-secure network. */
  afAddrInfo.txOptions = 0;
  afAddrInfo.radiusCounter = afDefaultRadius_c;
  /* The Wireless UART application on the remote node will ack or nak this */
  /* datagram (regardless of the reliability mode setting), so a confirm id */
  /* is not needed here. */
  AF_DataRequest(&afAddrInfo, zbTxDataBuffer.len, \
                 zbTxDataBuffer.data.structured.payload, NULL);
 ......
}
Hope this may help you.
Regards,
Imran