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.

change CHANNEL value

Other Parts Discussed in Thread: CC2430

Hello

I am searching a way to change the channel value with a command while  a simple network (coord/blind) is running

1) status =  osal_nv_write( ZCD_NV_CHANLIST, 0, sizeof(uint32), 0x00040000 ); for example

or 2) with MT_ProcessSerialCommand()

Can someone give me an example

Thank for help

  • There is a good example of this from our 2.2.0 stack version, but you can create something similar for other stack versions:

     if ( events & ZDNWKMGR_CHANNEL_CHANGE_EVT )
      {      
        // Switch channel
        _NIB.nwkLogicalChannel = ZDNwkMgr_NewChannel;
        ZMacSetReq( ZMacChannel, &ZDNwkMgr_NewChannel );
     
        // Our Channel has been changed -- notify to save info into NV
        ZDApp_NwkStateUpdateCB();
       
        // Reset the total transmit count and the transmit failure counters
        _NIB.nwkTotalTransmissions = 0;
        nwkTransmissionFailures( TRUE );
       
        return ( events ^ ZDNWKMGR_CHANNEL_CHANGE_EVT );
      }

     

    /*********************************************************************
     * @fn      ZDApp_NwkStateUpdateCB()
     *
     * @brief   This function notifies that this device's network
     *          state info has been changed.
     *
     * @param   none
     *
     * @return  none
     */
    void ZDApp_NwkStateUpdateCB( void )
    {
      // Notify to save info into NV
      if ( !osal_get_timeoutEx( ZDAppTaskID, ZDO_NWK_UPDATE_NV ) )
      {
        // Trigger to save info into NV
        ZDApp_NVUpdate();
      }
    }

  • Hi fred,

     To change a channel value u can the  ZB_WRITE_CONFIGURATION command.

    SREQ:

    Length = 0x03-0x83 Cmd0 = 0x26 Cmd1 = 0x05 ConfigId Len Value

    ConfigId – 1 byte – The identifier for the configuration property

    Len – 1 byte – Specifies the size of the Value buffer in bytes.

    Value – 1-128 bytes – The buffer containing the new value of the configuration property

    For channel value configid is:

    6.2.4.2 ZCD_NV_CHANLIST

    Configuration ID: 0x0084; Size: 4bytes; Default value: 0x00000800

    Go through CC2480 interface specification document, u'll uderstand what to use how to use!!!!

     //Zigbee Write Configuration
     
    void zb_WriteConfiguration(uint8 cfgId, uint8 len, void *pValue)
    {
      uint8 *pBuf = zaccelMsgBuf;
      
      *(pBuf+MT_RPC_POS_LEN)  = 0x03;//length
      *(pBuf+MT_RPC_POS_CMD0) = 0x26;//cmd0
      *(pBuf+MT_RPC_POS_CMD1) = 0x05;//cmd1
      //Data
      *(pBuf+MT_RPC_POS_DAT0) = cfgId;
      *(pBuf+MT_RPC_POS_DAT0+1) = len;
      memcpy((pBuf+MT_RPC_POS_DAT0+2), pValue, len); 
     
          zaccelRPC(pBuf);
    }

    You wanted this only right???

    Pandit

  • Thank double 0, but can you tell me where I can find full example because I have Zstack-1.4.3 not 2.2.0

    Thank bandit i will try what you say, I hope it works, does zb_writeconfiguration always need a reset of zb network?

    What I need is a network command that will cause all nodes of the network to update their channel value from channel 11 to 14 for example

    and probably it will be necessary to reset network after

    Thanks for the help

  •                    I'm Sure it'll work. The zb_writeconfiguration() need reset but only when u write NV_STARTUP_OPTON and LOGICALTYPE. There's no need to do reset if u write any other configuration parameters instead of NV_STARTUP_OPTON and LOGICALTYPE.

    Pandit

     

  • ok pandit

    can you tell me what to write to set channel to 0x00008000 for example?

    uint value[9]={0x03,0x26,0x05,0x00,0x84,0x00,0x00,0x80,0x00}

    zg_WriteConfiguration( NV_STARTUP_OPTION , 9*sizeof(uint8) , value )

  • Hi fred,

      Look at the zg_WriteConfiguration function correctly.

     //Zigbee Write Configuration
     
    void zb_WriteConfiguration(uint8 cfgId, uint8 len, void *pValue)
    {
      uint8 *pBuf = zaccelMsgBuf;
      
      *(pBuf+MT_RPC_POS_LEN)  =  2+len; //length     Here there's a little change to the previous post have a look at it. This line is  worng in the previous post.
      *(pBuf+MT_RPC_POS_CMD0) = 0x26;//cmd0
      *(pBuf+MT_RPC_POS_CMD1) = 0x05;//cmd1
      //Data
      *(pBuf+MT_RPC_POS_DAT0) = cfgId;
      *(pBuf+MT_RPC_POS_DAT0+1) = len;
      memcpy((pBuf+MT_RPC_POS_DAT0+2), pValue, len); 
     
          zaccelRPC(pBuf);
    }

    There i'm writing length, cmd0, cmd1. Only u need pass is the value i.e. Channel Value: 0x00008000

    #define ZCD_NV_CHANLIST    0x84

    uint8 value[9]={0x00,0x00,0x80,0x00};

    uin8 len;

    len = 4;

    zg_WriteConfiguration(  ZCD_NV_CHANLIST,  len , value );

     

    This works fine.

     

    Pandit

  • Hi pandit

    I use zstack - CC2430 , zb_WriteConfiguration is not like this

    uint8 zb_WriteConfiguration( uint8 configId, uint8 len, void *pValue )

    {

      return( osal_nv_write(configId, 0, len, pValue) );

    }

    What version are you using?

  • I'm using cc2480.  I dnt know how is it in cc2430. 

     

    Pandit

  • Hi again

    ok double 0 and pandit

    it seems we don't use same zstacks

    but for my zstack, to change channel on a node I think:

    uint32 c = 0x00008000; osal_nv_write(  ZCD_NV_CHANLIST,0,sizeof(c),&c)

    Is there already  a function to update channel value on all nodes of the network?

    else, DOUBLE 0 you are right, I see what you mean, I will invoke this call back function on all nodes of the network and they will update their channel value

    but I need big help to adapt your constants with my Zstack

    Thanks

  •                Ya mine is different zstack. I didn't come across with a function that'll update a channel value on all nodes. Sorry i can't help u for this.  All the best[:Y]

     

    Pandit

  • Hi

    I need to update channel value on all nodes with network messages

    can someone give me support, what file should I use to send/ receive the channel change message

    sapi.c? ZDApp.c?

    Thansk for help