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.

CC2538动态修改panid

Other Parts Discussed in Thread: CC2538

环境:cc2538 mesh1.0.0协议栈

目的:想在终端设备运行过程中动态的修改设备的panid。

做法:做了两个按键(A和B),A按键负责设置panid,B按键负责打印此时的panid

  A按键代码:
 uint16 pan_id;
  pan_id = 0x5678;     
  HalUARTWrite(HAL_UART_PORT_0,(uint8*)&pan_id,2);  //打印想要设置的panid
  _NIB.nwkPanId = pan_id;
  NLME_UpdateNV(0x01);                              //两行为设置panid
  zb_GetDeviceInfo(ZB_INFO_PAN_ID,&pan_id);         //获取设备的panid
  HalUARTWrite(HAL_UART_PORT_0,(uint8*)&pan_id,2);  //打印设置后的panid
  osal_start_timerEx( GenericApp_TaskID,            //开启一个定时时间,5000ms后重启设备
                          GENERICAPP_RESET_EVT,
                          5000);

     B按键代码:

  uint16 pan_id1=0;
  zb_GetDeviceInfo(ZB_INFO_PAN_ID,&pan_id1);
  HalUARTWrite(HAL_UART_PORT_0,(uint8*)&pan_id1,2);

现象:1、按一下A按键,串口打印 5678 5678;设备重启后,按B按键,串口打印 FFFE;

            2、重新烧写代码,按一下A按键,串口打印5678 5678 ,在5000ms定时事件GENERICAPP_RESET_EVT触发

                  以前,按B按键,串口打印5678;定时事件触发后,设备重启,按B按键,串口打印FFFE。

补充:加入了NV_RESTORE编译选项。

  • http://www.deyisupport.com.edgekey.net/question_answer/wireless_connectivity/zigbee/f/104/t/86696.aspx?pi2132219853=1

    如果设备在已经加网成功的情况下修改PANID的话,建议把之前的网络参数擦除了