Esempio n. 1
0
EmberStatus emberAfRf4ceSendExtended(uint8_t pairingIndex,
                                     uint8_t profileId,
                                     uint16_t vendorId,
                                     EmberRf4ceTxOption txOptions,
                                     uint8_t *message,
                                     uint8_t messageLength,
                                     uint8_t *messageTag)
{
  EmberStatus status;
  uint8_t thisMessageTag;

  thisMessageTag = nextMessageTag++ & EMBER_AF_RF4CE_MESSAGE_TAG_MASK;
  if (messageTag != NULL) {
    *messageTag = thisMessageTag;
  }

  status = emberAfRf4cePushNetworkIndex();
  if (status != EMBER_SUCCESS) {
    return status;
  }

  status = emAfRf4ceSend(pairingIndex,
                         profileId,
                         vendorId,
                         txOptions,
                         thisMessageTag,
                         messageLength,
                         message);

  emberAfPopNetworkIndex();
  return status;
}
Esempio n. 2
0
void emAfRf4ceDiscoveryCompleteHandler(EmberStatus status)
{
  if (DISCOVERY_IN_PROGRESS()) {
    uint8_t i;

    // Clear the state (after saving a copy) so that the application is able to
    // perform another discovery right away.
    uint8_t profileIdCount = discoveryProfileIdCount;
    uint8_t profileIds[EMBER_RF4CE_APPLICATION_PROFILE_ID_LIST_MAX_LENGTH];
    MEMMOVE(profileIds, discoveryProfileIds, profileIdCount);
    UNSET_DISCOVERY_IN_PROGRESS();

    emberAfPushCallbackNetworkIndex();
    for (i = 0; i < profileIdCount; i++) {
      switch (profileIds[i]) {
      case EMBER_AF_RF4CE_PROFILE_REMOTE_CONTROL_1_1:
        emberAfPluginRf4ceProfileRemoteControl11DiscoveryCompleteCallback(status);
        break;
      case EMBER_AF_RF4CE_PROFILE_REMOTE_CONTROL_2_0:
        emberAfPluginRf4ceProfileZrc20DiscoveryCompleteCallback(status);
        break;
      case EMBER_AF_RF4CE_PROFILE_MSO:
        emberAfPluginRf4ceProfileMsoDiscoveryCompleteCallback(status);
        break;
      default:
        // TODO: Handle other profiles.
        break;
      }
    }
    emberAfPopNetworkIndex();
  }
}
Esempio n. 3
0
EmberStatus emberAfRf4ceDiscovery(EmberPanId panId,
                                  EmberNodeId nodeId,
                                  uint8_t searchDevType,
                                  uint16_t discDuration,
                                  uint8_t maxDiscRepetitions,
                                  uint8_t discProfileIdListLength,
                                  uint8_t *discProfileIdList)
{
  EmberStatus status = EMBER_INVALID_CALL;
  if (!DISCOVERY_IN_PROGRESS()) {
    status = emberAfRf4cePushNetworkIndex();
    if (status == EMBER_SUCCESS) {
      status = emAfRf4ceDiscovery(panId,
                                  nodeId,
                                  searchDevType,
                                  discDuration,
                                  maxDiscRepetitions,
                                  discProfileIdListLength,
                                  discProfileIdList);
      if (status == EMBER_SUCCESS) {
        SET_DISCOVERY_IN_PROGRESS(discProfileIdListLength, discProfileIdList);
      }
      emberAfPopNetworkIndex();
    }
  }
  return status;
}
/*! State Machine function */
void emberAfPluginSimpleCommissioningInitiatorStateMachineEventHandler(void) {
  emberEventControlSetInactive(StateMachineEvent);
  // That might happened that ZigBee state machine changed current network
  // So, it is important to switch to the proper network before commissioning
  // state machine might start
  EmberStatus status = emberAfPushNetworkIndex(dev_comm_session.network_index);
  if (status != EMBER_SUCCESS) {
    // TODO: Handle unavailability of switching network
  }
  emberAfDebugPrintln("DEBUG: State Machine");
  // Get state previously set by some handler
  CommissioningState_t cur_state = GetNextState();
  CommissioningEvent_t cur_event = GetNextEvent();
  for (size_t i = 0; i < TRANSIT_TABLE_SIZE(); ++i) {
    if ((cur_state == sm_transition_table[i].state ||
         SC_EZ_UNKNOWN == sm_transition_table[i].state) &&
        ((cur_event == sm_transition_table[i].event) ||
         SC_EZEV_UNKNOWN == sm_transition_table[i].event)) {
      // call handler which set the next_state on return and
      // next_event inside itself
      SetNextState((sm_transition_table[i].handler)());
      break;
    }
  }

  // Don't forget to pop Network Index
  status = emberAfPopNetworkIndex();
  // sanity check that network switched back properly
  EMBER_TEST_ASSERT(status == EMBER_SUCCESS);
}
Esempio n. 5
0
bool emAfRf4cePairRequestHandler(EmberStatus status,
                                    uint8_t pairingIndex,
                                    EmberEUI64 srcIeeeAddr,
                                    uint8_t nodeCapabilities,
                                    const EmberRf4ceVendorInfo *vendorInfo,
                                    const EmberRf4ceApplicationInfo *appInfo,
                                    uint8_t keyExchangeTransferCount)
{
  bool retVal = false;

  if (!PAIRING_IN_PROGRESS()) {
    uint8_t i;
    uint8_t profileIdListLength = emberAfRf4ceProfileIdListLength(appInfo->capabilities);

    emberAfPushCallbackNetworkIndex();

    for (i = 0; i < profileIdListLength && !retVal; i++) {
      switch (appInfo->profileIdList[i]) {
      case EMBER_AF_RF4CE_PROFILE_REMOTE_CONTROL_1_1:
        retVal = emberAfPluginRf4ceProfileRemoteControl11PairRequestCallback(status,
                                                                             pairingIndex,
                                                                             srcIeeeAddr,
                                                                             nodeCapabilities,
                                                                             vendorInfo,
                                                                             appInfo,
                                                                             keyExchangeTransferCount);
        break;
      case EMBER_AF_RF4CE_PROFILE_REMOTE_CONTROL_2_0:
        retVal = emberAfPluginRf4ceProfileZrc20PairRequestCallback(status,
                                                                   pairingIndex,
                                                                   srcIeeeAddr,
                                                                   nodeCapabilities,
                                                                   vendorInfo,
                                                                   appInfo,
                                                                   keyExchangeTransferCount);
        break;
      case EMBER_AF_RF4CE_PROFILE_MSO:
        retVal = emberAfPluginRf4ceProfileMsoPairRequestCallback(status,
                                                                 pairingIndex,
                                                                 srcIeeeAddr,
                                                                 nodeCapabilities,
                                                                 vendorInfo,
                                                                 appInfo,
                                                                 keyExchangeTransferCount);
        break;
      default:
        // TODO: Handle other profiles.
        break;
      }
    }

    if (retVal) {
      SET_PAIRING_IN_PROGRESS();
    }

    emberAfPopNetworkIndex();
  }
  return retVal;
}
Esempio n. 6
0
EmberStatus emberAfRf4ceStop(void)
{
  EmberStatus status = emberAfRf4cePushNetworkIndex();
  if (status == EMBER_SUCCESS) {
    status = emAfRf4ceStop();
    emberAfPopNetworkIndex();
  }
  return status;
}
Esempio n. 7
0
void emAfRf4ceUnpairCompleteHandler(uint8_t pairingIndex)
{
  if (UNPAIRING_IN_PROGRESS()) {
    UNSET_UNPAIRING_IN_PROGRESS();
    emberAfPushCallbackNetworkIndex();
    // TODO
    emberAfPopNetworkIndex();
  }
}
Esempio n. 8
0
void emAfRf4ceAutoDiscoveryResponseCompleteHandler(EmberStatus status,
                                                   EmberEUI64 srcIeeeAddr,
                                                   uint8_t nodeCapabilities,
                                                   const EmberRf4ceVendorInfo *vendorInfo,
                                                   const EmberRf4ceApplicationInfo *appInfo,
                                                   uint8_t searchDevType)
{
  if (AUTO_DISCOVERY_IN_PROGRESS()) {
    uint8_t i;

    // Clear the state (after saving a copy) so that the application is able to
    // perform another auto discovery right away.
    uint8_t profileIdCount = autoDiscoveryProfileIdCount;
    uint8_t profileIds[EMBER_RF4CE_APPLICATION_PROFILE_ID_LIST_MAX_LENGTH];
    MEMMOVE(profileIds, autoDiscoveryProfileIds, profileIdCount);
    if (status == EMBER_SUCCESS && !wantsAutoDiscoveryProfileIds(appInfo)) {
      status = EMBER_DISCOVERY_TIMEOUT;
    }
    UNSET_AUTO_DISCOVERY_IN_PROGRESS();

    emberAfPushCallbackNetworkIndex();

    for (i = 0; i < profileIdCount; i++) {
      switch (profileIds[i]) {
      case EMBER_AF_RF4CE_PROFILE_REMOTE_CONTROL_1_1:
        emberAfPluginRf4ceProfileRemoteControl11AutoDiscoveryResponseCompleteCallback(status,
                                                                                      srcIeeeAddr,
                                                                                      nodeCapabilities,
                                                                                      vendorInfo,
                                                                                      appInfo,
                                                                                      searchDevType);
        break;
      case EMBER_AF_RF4CE_PROFILE_REMOTE_CONTROL_2_0:
        emberAfPluginRf4ceProfileZrc20AutoDiscoveryResponseCompleteCallback(status,
                                                                            srcIeeeAddr,
                                                                            nodeCapabilities,
                                                                            vendorInfo,
                                                                            appInfo,
                                                                            searchDevType);
        break;
      case EMBER_AF_RF4CE_PROFILE_MSO:
        emberAfPluginRf4ceProfileMsoAutoDiscoveryResponseCompleteCallback(status,
                                                                          srcIeeeAddr,
                                                                          nodeCapabilities,
                                                                          vendorInfo,
                                                                          appInfo,
                                                                          searchDevType);
        break;
      default:
        // TODO: Handle other profiles.
        break;
      }
    }

    emberAfPopNetworkIndex();
  }
}
Esempio n. 9
0
EmberStatus emberAfRf4ceKeyUpdate(uint8_t pairingIndex, EmberKeyData *key)
{
  EmberStatus status = emberAfRf4cePushNetworkIndex();
  if (status == EMBER_SUCCESS) {
    status = emAfRf4ceKeyUpdate(pairingIndex, key);
    emberAfPopNetworkIndex();
  }
  return status;
}
Esempio n. 10
0
EmberStatus emberAfRf4ceSetDiscoveryLqiThreshold(uint8_t threshold)
{
  EmberStatus status = emberAfRf4cePushNetworkIndex();
  if (status == EMBER_SUCCESS) {
    status = emAfRf4ceSetDiscoveryLqiThreshold(threshold);
    emberAfPopNetworkIndex();
  }
  return status;
}
Esempio n. 11
0
EmberStatus emberAfRf4ceGetApplicationInfo(EmberRf4ceApplicationInfo *appInfo)
{
  EmberStatus status = emberAfRf4cePushNetworkIndex();
  if (status == EMBER_SUCCESS) {
    status = emAfRf4ceGetApplicationInfo(appInfo);
    emberAfPopNetworkIndex();
  }
  return status;
}
Esempio n. 12
0
void emberCommandActionHandler(const CommandAction action)
{
  emberAfPushNetworkIndex(emAfCliNetworkIndex);
  (*action)();
  emberAfPopNetworkIndex();

#if defined(EMBER_QA)
  emberSerialPrintfLine(APP_SERIAL, "CLI Finished");
#endif
}
Esempio n. 13
0
EmberStatus emberAfRf4ceGetPairingTableEntry(uint8_t pairingIndex,
                                             EmberRf4cePairingTableEntry *entry)
{
  EmberStatus status = emberAfRf4cePushNetworkIndex();
  if (status == EMBER_SUCCESS) {
    status = emAfRf4ceGetPairingTableEntry(pairingIndex, entry);
    emberAfPopNetworkIndex();
  }
  return status;
}
Esempio n. 14
0
uint8_t emberAfRf4ceGetBaseChannel(void)
{
  EmberStatus status = emberAfRf4cePushNetworkIndex();
  uint8_t channel = 0xFF;

  if (status == EMBER_SUCCESS) {
    channel =  emAfRf4ceGetBaseChannel();
    emberAfPopNetworkIndex();
  }
  return channel;
}
Esempio n. 15
0
uint8_t emberAfRf4ceGetMaxPayload(uint8_t pairingIndex,
                                EmberRf4ceTxOption txOptions)
{
  EmberStatus status = emberAfRf4cePushNetworkIndex();
  uint8_t maxLength = 0;

  if (status == EMBER_SUCCESS) {
    maxLength = emAfRf4ceGetMaxPayload(pairingIndex, txOptions);
    emberAfPopNetworkIndex();
  }

  return maxLength;
}
Esempio n. 16
0
EmberStatus emberAfRf4ceStart(void)
{
  EmberStatus status = emberAfRf4cePushNetworkIndex();
  if (status == EMBER_SUCCESS) {
    status = emAfRf4ceSetApplicationInfo(&emAfRf4ceApplicationInfo);
    if (status == EMBER_SUCCESS) {
      status = emAfRf4ceStart(EMBER_AF_RF4CE_NODE_CAPABILITIES,
                              &emAfRf4ceVendorInfo,
                              EMBER_AF_RF4CE_POWER);
    }
    emberAfPopNetworkIndex();
  }
  return status;
}
Esempio n. 17
0
EmberStatus emberAfRf4ceUnpair(uint8_t pairingIndex)
{
  EmberStatus status = EMBER_INVALID_CALL;
  if (!UNPAIRING_IN_PROGRESS()) {
    status = emberAfRf4cePushNetworkIndex();
    if (status == EMBER_SUCCESS) {
      status = emAfRf4ceUnpair(pairingIndex);
      if (status == EMBER_SUCCESS) {
        SET_UNPAIRING_IN_PROGRESS();
      }
      emberAfPopNetworkIndex();
    }
  }
  return status;
}
Esempio n. 18
0
bool emAfRf4ceDiscoveryRequestHandler(EmberEUI64 srcIeeeAddr,
                                         uint8_t nodeCapabilities,
                                         const EmberRf4ceVendorInfo *vendorInfo,
                                         const EmberRf4ceApplicationInfo *appInfo,
                                         uint8_t searchDevType,
                                         uint8_t rxLinkQuality)
{
  uint8_t i;
  uint8_t profileIdListLength = emberAfRf4ceProfileIdListLength(appInfo->capabilities);
  bool retVal = false;

  emberAfPushCallbackNetworkIndex();

  for (i = 0; i < profileIdListLength && !retVal; i++) {
    switch (appInfo->profileIdList[i]) {
    case EMBER_AF_RF4CE_PROFILE_REMOTE_CONTROL_1_1:
      retVal = emberAfPluginRf4ceProfileRemoteControl11DiscoveryRequestCallback(srcIeeeAddr,
                                                                                nodeCapabilities,
                                                                                vendorInfo,
                                                                                appInfo,
                                                                                searchDevType,
                                                                                rxLinkQuality);
      break;
    case EMBER_AF_RF4CE_PROFILE_REMOTE_CONTROL_2_0:
      retVal = emberAfPluginRf4ceProfileZrc20DiscoveryRequestCallback(srcIeeeAddr,
                                                                      nodeCapabilities,
                                                                      vendorInfo,
                                                                      appInfo,
                                                                      searchDevType,
                                                                      rxLinkQuality);
      break;
    case EMBER_AF_RF4CE_PROFILE_MSO:
      retVal = emberAfPluginRf4ceProfileMsoDiscoveryRequestCallback(srcIeeeAddr,
                                                                    nodeCapabilities,
                                                                    vendorInfo,
                                                                    appInfo,
                                                                    searchDevType,
                                                                    rxLinkQuality);
      break;
    default:
      // TODO: Handle other profiles.
      break;
    }
  }

  emberAfPopNetworkIndex();
  return retVal;
}
Esempio n. 19
0
EmberStatus emberAfRf4ceSetFrequencyAgilityParameters(uint8_t rssiWindowSize,
                                                      uint8_t channelChangeReads,
                                                      int8_t rssiThreshold,
                                                      uint16_t readIntervalS,
                                                      uint8_t readDuration)
{
  EmberStatus status = emberAfRf4cePushNetworkIndex();
  if (status == EMBER_SUCCESS) {
    status = emAfRf4ceSetFrequencyAgilityParameters(rssiWindowSize,
                                                    channelChangeReads,
                                                    rssiThreshold,
                                                    readIntervalS,
                                                    readDuration);
    emberAfPopNetworkIndex();
  }
  return status;
}
Esempio n. 20
0
EmberStatus emberAfRf4ceEnableAutoDiscoveryResponse(uint16_t durationMs,
                                                    uint8_t autoDiscProfileIdListLength,
                                                    uint8_t *autoDiscProfileIdList)
{
  EmberStatus status = EMBER_INVALID_CALL;
  if (!AUTO_DISCOVERY_IN_PROGRESS()) {
    status = emberAfRf4cePushNetworkIndex();
    if (status == EMBER_SUCCESS) {
      status = emAfRf4ceEnableAutoDiscoveryResponse(durationMs);
      if (status == EMBER_SUCCESS) {
        SET_AUTO_DISCOVERY_IN_PROGRESS(autoDiscProfileIdListLength,
                                       autoDiscProfileIdList);
      }
      emberAfPopNetworkIndex();
    }
  }
  return status;
}
Esempio n. 21
0
static EmberStatus setPowerSavingParameters(bool wasEnabled)
{
  EmberStatus status = emberAfRf4cePushNetworkIndex();
  if (status == EMBER_SUCCESS) {
    // If the receiver was enabled and is staying enabled, we have nothing to
    // do.  Otherwise, enable the receiver if we're now on or set the power-
    // saving parameters if not.  If the receiver doesn't have to be enabled,
    // we always set the power-saving parameters even if the receiver wasn't
    // enabled before.  This is because we may have got here via a call to
    // emberAfRf4ceSetPowerSavingParameters that set new parameters.  This
    // ensures the parameters set in the stack are up to date.
    if (!rxEnabled()) {
      status = emAfRf4ceSetPowerSavingParameters(emAfRf4cePowerSavingState.dutyCycleMs,
                                                 emAfRf4cePowerSavingState.activePeriodMs);
    } else if (!wasEnabled) {
      status = emAfRf4ceSetPowerSavingParameters(0, 0); // enable
    }
    emberAfPopNetworkIndex();
  }
  return status;
}
Esempio n. 22
0
EmberStatus emberAfRf4cePair(uint8_t channel,
                             EmberPanId panId,
                             EmberEUI64 ieeeAddr,
                             uint8_t keyExchangeTransferCount,
                             EmberAfRf4cePairCompleteCallback pairCompleteCallback)
{
  EmberStatus status = EMBER_INVALID_CALL;
  if (!PAIRING_IN_PROGRESS()) {
    status = emberAfRf4cePushNetworkIndex();
    if (status == EMBER_SUCCESS) {
      status = emAfRf4cePair(channel,
                             panId,
                             ieeeAddr,
                             keyExchangeTransferCount);
      if (status == EMBER_SUCCESS || status == EMBER_DUPLICATE_ENTRY) {
        SET_PAIRING_IN_PROGRESS();
        pairCompletePtr = pairCompleteCallback;
      }
      emberAfPopNetworkIndex();
    }
  }
  return status;
}
Esempio n. 23
0
void emAfRf4ceIncomingMessageHandler(uint8_t pairingIndex,
                                     uint8_t profileId,
                                     uint16_t vendorId,
                                     EmberRf4ceTxOption txOptions,
                                     uint8_t messageLength,
                                     const uint8_t *message)
{
  emberAfPushCallbackNetworkIndex();
  SET_PAIRING_INDEX(pairingIndex);

  // GDP 2.0 commands are tricky since they can be sent with the GDP 2.0 profile
  // ID or any GDP 2.0 based profile ID. We want to use the common GDP 2.0 code
  // for the commands that carry the GDP profile ID and other GDP-based profile
  // IDs. Therefore, first we try to dispatch to the GDP callback.
  // This callback is expected to return true if the passed message was
  // processed by the GDP code, false otherwise.
  if (!emberAfPluginRf4ceProfileGdpIncomingMessageCallback(pairingIndex,
                                                           profileId,
                                                           vendorId,
                                                           txOptions,
                                                           message,
                                                           messageLength)) {
    // Dispatch the incoming message based on the profile ID.
    switch (profileId) {
    case EMBER_AF_RF4CE_PROFILE_REMOTE_CONTROL_1_1:
      emberAfPluginRf4ceProfileRemoteControl11IncomingMessageCallback(pairingIndex,
                                                                      vendorId,
                                                                      txOptions,
                                                                      message,
                                                                      messageLength);
      break;
    case EMBER_AF_RF4CE_PROFILE_REMOTE_CONTROL_2_0:
      emberAfPluginRf4ceProfileZrc20IncomingMessageCallback(pairingIndex,
                                                            vendorId,
                                                            txOptions,
                                                            message,
                                                            messageLength);
      break;
    case EMBER_AF_RF4CE_PROFILE_MSO:
      emberAfPluginRf4ceProfileMsoIncomingMessageCallback(pairingIndex,
                                                          vendorId,
                                                          txOptions,
                                                          message,
                                                          messageLength);
      break;
    default:
      // TODO: Handle other profiles.
      break;
    }
  }

  emberAfPluginRf4ceProfileIncomingMessageCallback(pairingIndex,
                                                   profileId,
                                                   vendorId,
                                                   txOptions,
                                                   message,
                                                   messageLength);

  UNSET_PAIRING_INDEX();
  emberAfPopNetworkIndex();
}
Esempio n. 24
0
bool emAfRf4ceDiscoveryResponseHandler(bool atCapacity,
                                          uint8_t channel,
                                          EmberPanId panId,
                                          EmberEUI64 srcIeeeAddr,
                                          uint8_t nodeCapabilities,
                                          const EmberRf4ceVendorInfo *vendorInfo,
                                          const EmberRf4ceApplicationInfo *appInfo,
                                          uint8_t rxLinkQuality,
                                          uint8_t discRequestLqi)
{
  bool retVal = false;
  if (DISCOVERY_IN_PROGRESS()) {
    uint8_t i;
    uint8_t profileIdListLength = emberAfRf4ceProfileIdListLength(appInfo->capabilities);

    emberAfPushCallbackNetworkIndex();

    for (i = 0; i < profileIdListLength && !retVal; i++) {
      if (wantsDiscoveryProfileId(appInfo->profileIdList[i])) {
        switch (appInfo->profileIdList[i]) {
        case EMBER_AF_RF4CE_PROFILE_REMOTE_CONTROL_1_1:
          retVal = emberAfPluginRf4ceProfileRemoteControl11DiscoveryResponseCallback(atCapacity,
                                                                                     channel,
                                                                                     panId,
                                                                                     srcIeeeAddr,
                                                                                     nodeCapabilities,
                                                                                     vendorInfo,
                                                                                     appInfo,
                                                                                     rxLinkQuality,
                                                                                     discRequestLqi);
          break;
        case EMBER_AF_RF4CE_PROFILE_REMOTE_CONTROL_2_0:
          retVal = emberAfPluginRf4ceProfileZrc20DiscoveryResponseCallback(atCapacity,
                                                                           channel,
                                                                           panId,
                                                                           srcIeeeAddr,
                                                                           nodeCapabilities,
                                                                           vendorInfo,
                                                                           appInfo,
                                                                           rxLinkQuality,
                                                                           discRequestLqi);
          break;
        case EMBER_AF_RF4CE_PROFILE_MSO:
          retVal = emberAfPluginRf4ceProfileMsoDiscoveryResponseCallback(atCapacity,
                                                                         channel,
                                                                         panId,
                                                                         srcIeeeAddr,
                                                                         nodeCapabilities,
                                                                         vendorInfo,
                                                                         appInfo,
                                                                         rxLinkQuality,
                                                                         discRequestLqi);
          break;
        default:
          // TODO: Handle other profiles.
          break;
        }
      }
    }

    emberAfPopNetworkIndex();
  }
  return retVal;
}
Esempio n. 25
0
void emAfCliInfoCommand(void)
{
  EmberNodeType nodeTypeResult = 0xFF;
  uint8_t commandLength;
  EmberEUI64 myEui64;
  EmberNetworkParameters networkParams;
  emberStringCommandArgument(-1, &commandLength);
  printMfgString();
  emberAfAppPrintln("AppBuilder MFG Code: 0x%2X", EMBER_AF_MANUFACTURER_CODE);
  emberAfGetEui64(myEui64);
  emberAfGetNetworkParameters(&nodeTypeResult, &networkParams);
  emberAfAppPrint("node [");
  emberAfAppDebugExec(emberAfPrintBigEndianEui64(myEui64));
  emberAfAppFlush();
  emberAfAppPrintln("] chan [%d] pwr [%d]",
                    networkParams.radioChannel,
                    networkParams.radioTxPower);
  emberAfAppPrint("panID [0x%2x] nodeID [0x%2x] ",
                 networkParams.panId,
                 emberAfGetNodeId());
  emberAfAppFlush();
  emberAfAppPrint("xpan [0x");
  emberAfAppDebugExec(emberAfPrintBigEndianEui64(networkParams.extendedPanId));
  emberAfAppPrintln("]");
  emberAfAppFlush();

  emAfCliVersionCommand();
  emberAfAppFlush();

  emberAfAppPrint("nodeType [");
  if (nodeTypeResult != 0xFF) {
    emberAfAppPrint("0x%x", nodeTypeResult);
  } else {
    emberAfAppPrint("unknown");
  }
  emberAfAppPrintln("]");
  emberAfAppFlush();

  emberAfAppPrintln("%p level [%x]", "Security", emberAfGetSecurityLevel());

  printSmartEnergySecurityInfo();
  printSmartEnergySecurityInfo283k1();

  emberAfAppPrint("network state [%x] ", emberNetworkState());
  printPacketBuffers();
  emberAfAppFlush();

  // print the endpoint information
  {
    uint8_t i, j;
    emberAfAppPrintln("Ep cnt: %d", emberAfEndpointCount());
    // loop for each endpoint
    for (i = 0; i < emberAfEndpointCount(); i++) {
      EmberAfEndpointType *et = emAfEndpoints[i].endpointType;
      emberAfAppPrint("ep %d [endpoint %p, device %p] ",
                      emberAfEndpointFromIndex(i),
                      (emberAfEndpointIndexIsEnabled(i)
                       ? "enabled"
                       : "disabled"),
                      emberAfIsDeviceEnabled(emberAfEndpointFromIndex(i))
                      ? "enabled" 
                      : "disabled");
      emberAfAppPrintln("nwk [%d] profile [0x%2x] devId [0x%2x] ver [0x%x]",
                        emberAfNetworkIndexFromEndpointIndex(i),
                        emberAfProfileIdFromIndex(i),
                        emberAfDeviceIdFromIndex(i),
                        emberAfDeviceVersionFromIndex(i));    
      // loop for the clusters within the endpoint
      for (j = 0; j < et->clusterCount; j++) {
        EmberAfCluster *zc = &(et->cluster[j]);
        emberAfAppPrint("    %p cluster: 0x%2x ", 
                       (emberAfClusterIsClient(zc)
                        ? "out(client)"
                        : "in (server)" ),
                       zc->clusterId);
        emberAfAppDebugExec(emberAfDecodeAndPrintCluster(zc->clusterId));
        emberAfAppPrintln("");
        emberAfAppFlush();
      }
      emberAfAppFlush();
    }
  }

  {
    PGM_P names[] = {
      EM_AF_GENERATED_NETWORK_STRINGS
    };
    uint8_t i;
    emberAfAppPrintln("Nwk cnt: %d", EMBER_SUPPORTED_NETWORKS);
    for (i = 0; i < EMBER_SUPPORTED_NETWORKS; i++) {
      emberAfPushNetworkIndex(i);
      emberAfAppPrintln("nwk %d [%p]", i, names[i]);
      if (emAfProIsCurrentNetwork()) {
        emberAfAppPrintln("  nodeType [0x%x]",
                          emAfCurrentZigbeeProNetwork->nodeType);
        emberAfAppPrintln("  securityProfile [0x%x]",
                          emAfCurrentZigbeeProNetwork->securityProfile);
      }
      emberAfPopNetworkIndex();
    }
  }
}
Esempio n. 26
0
void emAfRf4ceMessageSentHandler(EmberStatus status,
                                 uint8_t pairingIndex,
                                 uint8_t txOptions,
                                 uint8_t profileId,
                                 uint16_t vendorId,
                                 uint8_t messageTag,
                                 uint8_t messageLength,
                                 const uint8_t *message)
{
  emberAfPushCallbackNetworkIndex();
  SET_PAIRING_INDEX(pairingIndex);

  // GDP 2.0 commands are tricky since they can be sent with the GDP 2.0 profile
  // ID or any GDP 2.0 based profile ID. We want to use the common GDP 2.0 code
  // for the commands that carry the GDP profile ID and other GDP-based profile
  // IDs. Therefore, first we try to dispatch to GDP callback. This callback is
  // expected to return true if the passed message is a GDP 2.0 command, false
  // otherwise.
  if (!emberAfPluginRf4ceProfileGdpMessageSentCallback(pairingIndex,
                                                       profileId,
                                                       vendorId,
                                                       messageTag,
                                                       message,
                                                       messageLength,
                                                       status)) {
    switch (profileId) {
    case EMBER_AF_RF4CE_PROFILE_REMOTE_CONTROL_1_1:
      emberAfPluginRf4ceProfileRemoteControl11MessageSentCallback(pairingIndex,
                                                                  vendorId,
                                                                  messageTag,
                                                                  message,
                                                                  messageLength,
                                                                  status);
      break;
    case EMBER_AF_RF4CE_PROFILE_REMOTE_CONTROL_2_0:
      emberAfPluginRf4ceProfileZrc20MessageSentCallback(pairingIndex,
                                                        vendorId,
                                                        messageTag,
                                                        message,
                                                        messageLength,
                                                        status);
      break;
    case EMBER_AF_RF4CE_PROFILE_MSO:
      emberAfPluginRf4ceProfileMsoMessageSentCallback(pairingIndex,
                                                      vendorId,
                                                      messageTag,
                                                      message,
                                                      messageLength,
                                                      status);
      break;
    default:
      // TODO: Handle other profiles.
      break;
    }
  }

  emberAfPluginRf4ceProfileMessageSentCallback(pairingIndex,
                                               profileId,
                                               vendorId,
                                               messageTag,
                                               message,
                                               messageLength,
                                               status);

  UNSET_PAIRING_INDEX();
  emberAfPopNetworkIndex();
}
Esempio n. 27
0
void emAfRf4ceUnpairHandler(uint8_t pairingIndex)
{
  emberAfPushCallbackNetworkIndex();
  // TODO
  emberAfPopNetworkIndex();
}
Esempio n. 28
0
void emAfRf4cePairCompleteHandler(EmberStatus status,
                                  uint8_t pairingIndex,
                                  const EmberRf4ceVendorInfo *vendorInfo,
                                  const EmberRf4ceApplicationInfo *appInfo)
{
  if (PAIRING_IN_PROGRESS()) {
    UNSET_PAIRING_IN_PROGRESS();

    emberAfPushCallbackNetworkIndex();

    // If the application passed a function pointer for the pair complete
    // callback, we only call that one. Otherwise we try to dispatch based on
    // the profile ID list.
    if (pairCompletePtr) {
      // In the pair complete callback the application could invoke another
      // pair call. Therefore, we save the function pointer in a local variable
      // and set the global back to NULL prior to actual callback call.
      EmberAfRf4cePairCompleteCallback callbackPtr = pairCompletePtr;
      pairCompletePtr = NULL;
      (callbackPtr)(status, pairingIndex, vendorInfo, appInfo);
      emberAfPopNetworkIndex();
      return;
    }

    // If the status is not a successful status, the application info is not
    // included in the callback, so we just dispatch to all the plugins.
    // TODO: we might just go back to dispatch to all plugins regardless of
    // status.
    if (status != EMBER_SUCCESS && status != EMBER_DUPLICATE_ENTRY) {
      emberAfPluginRf4ceProfileRemoteControl11PairCompleteCallback(status,
                                                                   pairingIndex,
                                                                   NULL,
                                                                   NULL);
      emberAfPluginRf4ceProfileZrc20PairCompleteCallback(status,
                                                         pairingIndex,
                                                         NULL,
                                                         NULL);
      emberAfPluginRf4ceProfileMsoPairCompleteCallback(status,
                                                       pairingIndex,
                                                       NULL,
                                                       NULL);
    } else {
      uint8_t profileIdListLength = emberAfRf4ceProfileIdListLength(appInfo->capabilities);
      uint8_t i;

      for (i = 0; i < profileIdListLength; i++) {
        uint8_t profileId = appInfo->profileIdList[i];
        switch (profileId) {
        case EMBER_AF_RF4CE_PROFILE_REMOTE_CONTROL_1_1: {
          emberAfPluginRf4ceProfileRemoteControl11PairCompleteCallback(status,
                                                                       pairingIndex,
                                                                       vendorInfo,
                                                                       appInfo);
          break;
        }
        case EMBER_AF_RF4CE_PROFILE_REMOTE_CONTROL_2_0: {
          emberAfPluginRf4ceProfileZrc20PairCompleteCallback(status,
                                                             pairingIndex,
                                                             vendorInfo,
                                                             appInfo);
          break;
        }
        case EMBER_AF_RF4CE_PROFILE_MSO: {
          emberAfPluginRf4ceProfileMsoPairCompleteCallback(status,
                                                           pairingIndex,
                                                           vendorInfo,
                                                           appInfo);
          break;
        }
        default:
          // TODO: Handle other profiles.
          break;
        }
      }
    }

    emberAfPopNetworkIndex();
  }
}