예제 #1
0
void zclHomelink_zigbeeReset(void)
{
  uint16 clusters[2];
  zAddrType_t tempAddr = {{0}, (afAddrMode_t)AddrGroup};
  aps_Group_t tempGroup = {0, "SwitchX"};
  int i;
  
  for (i = HAL_NV_PAGE_BEG; i <= (HAL_NV_PAGE_BEG + HAL_NV_PAGE_CNT); i++)
  {
    HalFlashErase(i);
  }
  
  clusters[0] = ZCL_CLUSTER_ID_GEN_ON_OFF;
  clusters[1] = ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL;
  
  BindSetDefaultNV();
  aps_GroupsSetDefaultNV();
  
  // Initialize default groups.  Each button has a group ID built from the MAC.
  // The top 2 bits are for the endpoints.
  for(i = 0; i < NUM_BUTTONS; i ++) {
    tempGroup.ID =  i << 14 | (aExtendedAddress[1] & 0x3F) << 8 | aExtendedAddress[0];
    tempGroup.name[6] = '1' + i;
    tempAddr.addr.shortAddr = tempGroup.ID;
    bindAddEntry(ENDPOINT+i, &tempAddr, 0, 2, clusters);
    aps_AddGroup(ENDPOINT+i, &tempGroup);
  }
  BindWriteNV();
  aps_GroupsWriteNV();

  Onboard_soft_reset();
}
예제 #2
0
/*********************************************************************
 * @fn          BindInitNV
 *
 * @brief       Initialize the Binding NV Item
 *
 * @param       none
 *
 * @return      ZSUCCESS if successful, NV_ITEM_UNINIT if item did not
 *              exist in NV, NV_OPER_FAILED if failure.
 */
byte BindInitNV( void )
{
  byte ret;

  // Initialize the device list
  ret = osal_nv_item_init( ZCD_NV_BINDING_TABLE,
                  (uint16)( sizeof( nvBindingHdr_t ) + NV_BIND_ITEM_SIZE ), NULL );

  if ( ret != ZSUCCESS )
  {
    BindSetDefaultNV();
  }

  return ( ret );
}