/**************************************************************************//**
  \brief Application network info command handler.

  \param[in] pCommand - pointer to application command.

  \return true if deletion is needed, false otherwise.
******************************************************************************/
bool appRouterNwkInfoCmdHandler(AppCommand_t *pCommand)
{
  APS_DataReq_t *pMsgParams = NULL;

  if (appCreateTxFrame(&pMsgParams, &pCommand, NULL))
  {
    memset(pMsgParams, 0, sizeof(APS_DataReq_t));

    pMsgParams->profileId               = CCPU_TO_LE16(WSNDEMO_PROFILE_ID);
    pMsgParams->dstAddrMode             = APS_SHORT_ADDRESS;
    pMsgParams->dstAddress.shortAddress = CPU_TO_LE16(0);
    pMsgParams->dstEndpoint             = 1;
    pMsgParams->clusterId               = CPU_TO_LE16(1);
    pMsgParams->srcEndpoint             = WSNDEMO_ENDPOINT;
    pMsgParams->asduLength              = sizeof(AppNwkInfoCmdPayload_t) + sizeof(pCommand->id);
    pMsgParams->txOptions.acknowledgedTransmission = 1;
#ifdef _APS_FRAGMENTATION_
    pMsgParams->txOptions.fragmentationPermitted = 1;
#endif
#ifdef _LINK_SECURITY_
    pMsgParams->txOptions.securityEnabledTransmission = 1;
#endif
    pMsgParams->radius                  = 0x0;
  }

  return true;
}
예제 #2
0
/******************************************************************************
\brief Set PDS default

******************************************************************************/
void CS_PdsDefaultValue(void)
{
  csPIB.macAttr.extAddr = CCPU_TO_LE64(CS_UID);
  csSIB.csRfTxPower = CS_RF_TX_POWER;
#ifndef _MAC2_
  csSIB.csExtPANID = CCPU_TO_LE64(CS_EXT_PANID);
  csZIB.channelMask = CS_CHANNEL_MASK;
  csNIB.channelPage = CS_CHANNEL_PAGE;
  csNIB.deviceType = CS_DEVICE_TYPE;
  csSIB.csRxOnWhenIdle = (CS_DEVICE_TYPE == DEVICE_TYPE_END_DEVICE) ? CS_RX_ON_WHEN_IDLE : true;
  csSIB.csComplexDescriptorAvailable = CS_COMPLEX_DESCRIPTOR_AVAILABLE;
  csSIB.csUserDescriptorAvailable = CS_USER_DESCRIPTOR_AVAILABLE;
  csSIB.csNwkPanid = CCPU_TO_LE16(CS_NWK_PANID);
  csSIB.csNwkPredefinedPanid = CS_NWK_PREDEFINED_PANID,
  csNIB.networkAddress = CCPU_TO_LE16(CS_NWK_ADDR);
  csNIB.uniqueAddr = CS_NWK_UNIQUE_ADDR;
  csSIB.csDtrWakeup = CS_DTR_WAKEUP;
#if defined(_POWER_FAILURE_)
  csNIB.parentNetworkAddress = CCPU_TO_LE16(0xFFFF);
  csNIB.depth = 0;
  csNIB.extendedPanId = CCPU_TO_LE64(CS_NWK_EXT_PANID);
  csSIB.csNwkLogicalChannel = 0;
  csSIB.csPowerFailure = CS_POWER_FAILURE;
#endif /* _POWER_FAILURE_ */
#if defined(_SECURITY_)
  csAIB.trustCenterAddress = CCPU_TO_LE64(CS_APS_TRUST_CENTER_ADDRESS);
  csSIB.csZdoSecurityStatus = CS_ZDO_SECURITY_STATUS;
#endif /* _SECURITY_ */

  /* Parameters not to store in EEPROM */
  csNIB.maxNeighborRouteCost = CS_MAX_NEIGHBOR_ROUTE_COST;
  csSIB.csNwkMaxLinkStatusFailures = CS_NWK_MAX_LINK_STATUS_FAILURES;
  csSIB.csNwkEndDeviceMaxFailures = CS_NWK_END_DEVICE_MAX_FAILURES;
#ifdef AT86RF212
  csSIB.csLbtMode = CS_LBT_MODE;
#endif /* AT86RF212 */
#if defined(_SECURITY_)
  csSIB.csSecurityOn = CS_SECURITY_ON;
#endif /* _SECURITY_ */

  /* Buffers cleaning */
#if defined(_POWER_FAILURE_)
  memset(&stackBuffers.csNeibTable, 0, CS_NEIB_TABLE_SIZE);
  #if defined(_BINDING_) && (CS_APS_BINDING_TABLE_SIZE > 0)
    memset(&stackBuffers.csApsBindingTable, 0, CS_APS_BINDING_TABLE_SIZE);
  #endif /* _BINDING_ */
  #if defined(_SECURITY_)
  {
    csNIB.securityIB.securityLevel = CS_SECURITY_LEVEL;
    csNIB.securityIB.secureAllFrames = CS_SECURITY_ALL_FRAMES;
    NWK_ResetSecurityIB(NWK_GetDefaultPowerFailureControl());
  }
  #endif /* _SECURITY_ */
#endif /* _POWER_FAILURE_ */
#if defined (_GROUP_TABLE_)
  memset(&stackBuffers.csGroupTable, 0, CS_GROUP_TABLE_SIZE);
#endif /* _GROUP_TABLE_ */
#if defined(_SECURITY_)
  #if defined(_TC_PERMISSION_TABLE_) && CS_MAX_TC_ALLOWED_DEVICES_AMOUNT > 0
    memset(&stackBuffers.csTcDevicePermissionTable, 0, CS_MAX_TC_ALLOWED_DEVICES_AMOUNT);
  #endif /* _TC_PERMISSION_TABLE_ */
  #if defined _LINK_SECURITY_ && CS_APS_KEY_PAIR_DESCRIPTORS_AMOUNT > 0

    memset(&stackBuffers.csApsKeyPairDescriptors, 0, CS_APS_KEY_PAIR_DESCRIPTORS_AMOUNT);
  #endif /* _LINK_SECURITY_ */

#endif /* _SECURITY_ */
#endif /* _MAC2_ */
}
예제 #3
0
    .counter = stackBuffers.csNwkSecCounters
  },
#endif
  .deviceType = CS_DEVICE_TYPE,
  .addrAlloc = CS_ADDRESS_ASSIGNMENT_METHOD,
  .symLink = true,
  .uniqueAddr = CS_NWK_UNIQUE_ADDR,
  .leaveReqAllowed = CS_NWK_LEAVE_REQ_ALLOWED,
  .stackProfile = CS_STACK_PROFILE,
  .protocolVersion = CS_PROTOCOL_VERSION,
  .maxDepth = CS_MAX_NETWORK_DEPTH,
  .maxNeighborRouteCost = CS_MAX_NEIGHBOR_ROUTE_COST,
  .maxLinkRouteCost = CS_MAX_LINK_ROUTE_COST,
  .channelPage = CS_CHANNEL_PAGE,
  .logicalChannel = 0,
  .networkAddress = CCPU_TO_LE16(CS_NWK_ADDR),
  .panId = CCPU_TO_LE16(CS_NWK_PANID),
  .extendedPanId = CCPU_TO_LE64(CS_NWK_EXT_PANID), /* uses as joined-to-network flag */
  .maxRouters = CS_MAX_CHILDREN_ROUTER_AMOUNT,
  .maxEndDevices = CS_MAX_CHILDREN_AMOUNT - CS_MAX_CHILDREN_ROUTER_AMOUNT
};

const ZIB_t PROGMEM_DECLARE(defaultZIB) =
{
  .permitJoinDuration = CS_PERMIT_DURATION,
  .channelMask = CS_CHANNEL_MASK,
  .zdpResponseTimeout = CS_ZDP_RESPONSE_TIMEOUT,
  .scanDuration = CS_SCAN_DURATION,
};

const AIB_t PROGMEM_DECLARE(defaultAIB) =