首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

[求助]zigbee加密遇到的问题

[求助]zigbee加密遇到的问题

我想用default加密,就是同一个PAN的device都只用一个key.source code如下:


void App_InitSecurity(void)
{
  mlmeMessage_t Msg;
  uint8_t ret;
  uint8_t boolFlag;
  uint8_t securityMaterial[26] = { /* The key that must be common to both sides */
                                   0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
                                   0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,1,0,0,0,0,0,0,0,0,1};
                                   /* Security material counters - must be initialized like this
                                      They are used for checking repeated packets and assigning
                                      packet counters */
                                  
  //uint8_t securityMaterialLength = sizeof(securityMaterial);
  uint8_t securityMaterialLength = 16;


  /* The security level */
 uint8_t securityLevel = 5;


/* The security mode */
  uint8_t securityMode = 2;
  /* We will only apply security to one device and fill out the security
     information for this device. The first device will always have ACL
     entry #0. The  next will have #1 etc. up to #7 */



  Msg.msgType = gMlmeSetReq_c;
  Msg.msgData.setReq.pibAttribute = gMPibDefaultSecurity_c;
  boolFlag = TRUE;
  Msg.msgData.setReq.pibAttributeValue = &boolFlag;
  ret = MSG_Send(NWK_MLME, &Msg);
  
  /* Tell how much security material that we have got */
  Msg.msgType = gMlmeSetReq_c;
  Msg.msgData.setReq.pibAttribute = gMPibDefaultSecurityMaterialLength_c;
  Msg.msgData.setReq.pibAttributeValue = &securityMaterialLength;
  ret = MSG_Send(NWK_MLME, &Msg); 
 
  /* Set security material */
  Msg.msgType = gMlmeSetReq_c;
  Msg.msgData.setReq.pibAttribute = gMPibDefaultSecurityMaterial_c;
  Msg.msgData.setReq.pibAttributeValue = (uint8_t *)&securityMaterial;
  ret = MSG_Send(NWK_MLME, &Msg); 
 
  /* Set the security suite/level */
  Msg.msgType = gMlmeSetReq_c;
  Msg.msgData.setReq.pibAttribute = gMPibDefaultSecuritySuite_c;
  Msg.msgData.setReq.pibAttributeValue = (uint8_t *)&securityLevel;
  ret = MSG_Send(NWK_MLME, &Msg);   
 
  /* Set the security mode */
  Msg.msgType = gMlmeSetReq_c;
  Msg.msgData.setReq.pibAttribute = gMPibSecurityMode_c;
  Msg.msgData.setReq.pibAttributeValue = (uint8_t *)&securityMode;
  ret = MSG_Send(NWK_MLME, &Msg);
   
  //Uart_Print("Security was successfully applied.\n");   
 
  return;
}


coordinator和enddevice都一样,出现的问题是只有coordinator能够发送数据到device,而coordinator却接收不到device的数据.datesheet上说要把MaterialLength设定为小于26来屏蔽optional counter才能使用default的key加密,但不论我把securityMaterialLength设为多少也解决不了问题.有高手能够指点一二吗??

你是在z-stack上开发的吗?你是在应用层自己做的加密不?在z-stack的网络层中,已经具有了加密功能,你可以把它enable就行。
没有用Z-stack,自己在应用层做的加密,但我始终找不到问题出在什么地方
返回列表