static void deviceInformationRequestHandler(const EmberEUI64 source, uint32_t transaction, uint8_t startIndex) { EmberEUI64 eui64; EmberStatus status; uint8_t total = emberAfEndpointCount(); uint8_t i, *count; emberAfZllCommissioningClusterPrintln("RX: DeviceInformationRequest 0x%4x, 0x%x", transaction, startIndex); emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_SERVER_TO_CLIENT | ZCL_DISABLE_DEFAULT_RESPONSE_MASK), ZCL_ZLL_COMMISSIONING_CLUSTER_ID, ZCL_DEVICE_INFORMATION_RESPONSE_COMMAND_ID, "wuu", transaction, total, startIndex); emberAfGetEui64(eui64); count = &appResponseData[appResponseLength]; emberAfPutInt8uInResp(0); // temporary count for (i = startIndex; i < total; i++) { // If the profile interop bit in the ZllInformation bitmask is cleared, // then we know this is a legacy ZLL app, so we set the profile ID in our // response to the ZLL profile ID. If the bit is set, then the profile ID // should be set to the ZigBee 3.0 common profile ID. uint8_t deviceVersion = emberAfDeviceVersionFromIndex(i); uint8_t endpoint = emberAfEndpointFromIndex(i); EmberAfProfileId profileId = (network.state & EMBER_ZLL_STATE_PROFILE_INTEROP ? emberAfProfileIdFromIndex(i) : EMBER_ZLL_PROFILE_ID); emberAfPutBlockInResp(eui64, EUI64_SIZE); emberAfPutInt8uInResp(endpoint); emberAfPutInt16uInResp(profileId); emberAfPutInt16uInResp(emberAfDeviceIdFromIndex(i)); emberAfPutInt8uInResp(deviceVersion); emberAfPutInt8uInResp(emberAfPluginZllCommissioningGroupIdentifierCountCallback(endpoint)); emberAfPutInt8uInResp(i); // sort order (*count)++; } status = emberAfSendCommandInterPan(0xFFFF, // destination pan id source, EMBER_NULL_NODE_ID, // node id - ignored 0x0000, // group id - ignored EMBER_ZLL_PROFILE_ID); if (status != EMBER_SUCCESS) { emberAfZllCommissioningClusterPrintln("%p%p failed 0x%x", "Error: ", "Device information response", status); } }
void buttonEventHandler(void) { emberEventControlSetInactive(buttonEventControl); if (halButtonState(BUTTON0) == BUTTON_PRESSED) { EmberNetworkStatus state = emberNetworkState(); if (state == EMBER_JOINED_NETWORK) { emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_CLIENT_TO_SERVER), ZCL_ON_OFF_CLUSTER_ID, (on ? ZCL_OFF_COMMAND_ID : ZCL_ON_COMMAND_ID), ""); emberAfGetCommandApsFrame()->profileId = emberAfPrimaryProfileId(); emberAfGetCommandApsFrame()->sourceEndpoint = emberAfPrimaryEndpoint(); emberAfGetCommandApsFrame()->destinationEndpoint = EMBER_BROADCAST_ENDPOINT; if (emberAfSendCommandUnicastToBindings() == EMBER_SUCCESS) { on = !on; } else { halPlayTune_P(sadTune, TRUE); } } else if (state == EMBER_NO_NETWORK) { halPlayTune_P((emberAfStartSearchForJoinableNetwork() == EMBER_SUCCESS ? waitTune : sadTune), TRUE); } else { if (REPAIR_LIMIT_MS < elapsedTimeInt16u(buttonPressTime, halCommonGetInt16uMillisecondTick())) { halPlayTune_P(sadTune, TRUE); } else { if (state == EMBER_JOINED_NETWORK_NO_PARENT && !emberStackIsPerformingRejoin()) { halPlayTune_P((emberFindAndRejoinNetwork(TRUE, 0) == EMBER_SUCCESS ? waitTune : sadTune), TRUE); } emberEventControlSetDelayMS(buttonEventControl, REPAIR_DELAY_MS); } } } else if (halButtonState(BUTTON1) == BUTTON_PRESSED) { emberAfEzmodeClientCommission(emberAfPrimaryEndpoint(), EMBER_AF_EZMODE_COMMISSIONING_CLIENT_TO_SERVER, clusterIds, COUNTOF(clusterIds)); } }
void buttonEventHandler(void) { emberEventControlSetInactive(buttonEventControl); EmberNetworkStatus state = emberNetworkState(); if (state == EMBER_JOINED_NETWORK) { emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_CLIENT_TO_SERVER), ZCL_ON_OFF_CLUSTER_ID, (on ? ZCL_OFF_COMMAND_ID : ZCL_ON_COMMAND_ID), ""); emberAfGetCommandApsFrame()->profileId = emberAfProfileIdFromIndex(0); emberAfGetCommandApsFrame()->sourceEndpoint = emberAfEndpointFromIndex(0); emberAfGetCommandApsFrame()->destinationEndpoint = EMBER_BROADCAST_ENDPOINT; if (emberAfSendCommandBroadcast(EMBER_SLEEPY_BROADCAST_ADDRESS) == EMBER_SUCCESS) { on = !on; } else { halPlayTune_P(sadTune, TRUE); } } else if (state == EMBER_NO_NETWORK) { halPlayTune_P((emberAfZllInitiateTouchLink() == EMBER_SUCCESS ? waitTune : sadTune), TRUE); } else { int16u elapsed = elapsedTimeInt16u(buttonPressTime, halCommonGetInt16uMillisecondTick()); if (REPAIR_LIMIT_MS < elapsedTimeInt16u(buttonPressTime, halCommonGetInt16uMillisecondTick())) { halPlayTune_P(sadTune, TRUE); } else { if (state == EMBER_JOINED_NETWORK_NO_PARENT && !emberStackIsPerformingRejoin()) { halPlayTune_P((emberFindAndRejoinNetwork(TRUE, 0) == EMBER_SUCCESS ? waitTune : sadTune), TRUE); } emberEventControlSetDelayMS(buttonEventControl, REPAIR_DELAY_MS); } } }
static EmberStatus sendResetToFactoryNewRequest(void) { EmberStatus status; emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_CLIENT_TO_SERVER | ZCL_DISABLE_DEFAULT_RESPONSE_MASK), ZCL_ZLL_COMMISSIONING_CLUSTER_ID, ZCL_RESET_TO_FACTORY_NEW_REQUEST_COMMAND_ID, "w", network.securityAlgorithm.transactionId); status = emberAfSendCommandInterPan(0xFFFF, // destination pan id network.eui64, EMBER_NULL_NODE_ID, // node id - ignored 0x0000, // group id - ignored EMBER_ZLL_PROFILE_ID); if (status != EMBER_SUCCESS) { emberAfAppPrintln("%p%p failed 0x%x", "Error: ", "Reset to factory new request", status); } return status; }
static EmberStatus sendIdentifyRequest(uint16_t identifyDuration) { EmberStatus status; emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_CLIENT_TO_SERVER | ZCL_DISABLE_DEFAULT_RESPONSE_MASK), ZCL_ZLL_COMMISSIONING_CLUSTER_ID, ZCL_IDENTIFY_REQUEST_COMMAND_ID, "wv", network.securityAlgorithm.transactionId, identifyDuration); status = emberAfSendCommandInterPan(0xFFFF, // destination pan id network.eui64, EMBER_NULL_NODE_ID, // node id - ignored 0x0000, // group id - ignored EMBER_ZLL_PROFILE_ID); if (status != EMBER_SUCCESS) { emberAfAppPrintln("%p%p failed 0x%x", "Error: ", "Identify request", status); } return status; }