diff --git a/examples/bridge-app/esp32/main/DeviceCallbacks.cpp b/examples/bridge-app/esp32/main/DeviceCallbacks.cpp index 43a03eb9d651e7..e984d94e3ed799 100644 --- a/examples/bridge-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/bridge-app/esp32/main/DeviceCallbacks.cpp @@ -24,9 +24,9 @@ **/ #include "DeviceCallbacks.h" -#include "freertos/FreeRTOS.h" #include "esp_heap_caps.h" #include "esp_log.h" +#include "freertos/FreeRTOS.h" #include #include #include @@ -118,16 +118,16 @@ void DeviceCallbacks::OnSessionEstablished(const ChipDeviceEvent * event) void DeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { -/* VerifyOrExit(attributeId == ZCL_ON_OFF_ATTRIBUTE_ID, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); - VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); - if (*value) - { - BoltLockMgr().InitiateAction(AppEvent::kEventType_Lock, BoltLockManager::LOCK_ACTION); - } - else - { - BoltLockMgr().InitiateAction(AppEvent::kEventType_Lock, BoltLockManager::UNLOCK_ACTION); - } -exit:*/ + /* VerifyOrExit(attributeId == ZCL_ON_OFF_ATTRIBUTE_ID, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); + VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); + if (*value) + { + BoltLockMgr().InitiateAction(AppEvent::kEventType_Lock, BoltLockManager::LOCK_ACTION); + } + else + { + BoltLockMgr().InitiateAction(AppEvent::kEventType_Lock, BoltLockManager::UNLOCK_ACTION); + } + exit:*/ return; } diff --git a/examples/bridge-app/esp32/main/include/Device.h b/examples/bridge-app/esp32/main/include/Device.h index c13825b236b350..a0e4a72fe3661b 100644 --- a/examples/bridge-app/esp32/main/include/Device.h +++ b/examples/bridge-app/esp32/main/include/Device.h @@ -1,8 +1,8 @@ -//These are the bridged devices -#include -#include +// These are the bridged devices #include #include +#include +#include class Device { @@ -47,5 +47,4 @@ class Device char mLocation[kDeviceLocationSize]; chip::EndpointId mEndpointId; DeviceCallback_fn mChanged_CB; - }; diff --git a/examples/bridge-app/esp32/main/main.cpp b/examples/bridge-app/esp32/main/main.cpp index ed148968b496fd..e7dbb1c8453065 100644 --- a/examples/bridge-app/esp32/main/main.cpp +++ b/examples/bridge-app/esp32/main/main.cpp @@ -1,15 +1,15 @@ +#include "Device.h" #include "DeviceCallbacks.h" -#include +#include "esp_log.h" +#include "nvs_flash.h" #include #include #include #include +#include +#include #include -#include "nvs_flash.h" #include -#include "esp_log.h" -#include "Device.h" -#include #define DYNAMIC_ENDPOINT_COUNT 16 const char * TAG = "bridge-app"; @@ -55,17 +55,17 @@ DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(0x0001); // Declare Descriptor cluster attributes DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(descriptorAttrs) -DECLARE_DYNAMIC_ATTRIBUTE(ZCL_DEVICE_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* device list */ -DECLARE_DYNAMIC_ATTRIBUTE(ZCL_SERVER_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* server list */ -DECLARE_DYNAMIC_ATTRIBUTE(ZCL_CLIENT_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* client list */ -DECLARE_DYNAMIC_ATTRIBUTE(ZCL_PARTS_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0) /* parts list */ -DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(0x0001); +DECLARE_DYNAMIC_ATTRIBUTE(ZCL_DEVICE_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* device list */ + DECLARE_DYNAMIC_ATTRIBUTE(ZCL_SERVER_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* server list */ + DECLARE_DYNAMIC_ATTRIBUTE(ZCL_CLIENT_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* client list */ + DECLARE_DYNAMIC_ATTRIBUTE(ZCL_PARTS_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0) /* parts list */ + DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(0x0001); // Declare Bridged Device Basic information cluster attributes DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(bridgedDeviceBasicAttrs) DECLARE_DYNAMIC_ATTRIBUTE(ZCL_USER_LABEL_ATTRIBUTE_ID, CHAR_STRING, kUserLabelSize, 0), /* UserLabel */ -DECLARE_DYNAMIC_ATTRIBUTE(ZCL_REACHABLE_ATTRIBUTE_ID, BOOLEAN, 1, 0) /* Reachable */ -DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(0x0003); + DECLARE_DYNAMIC_ATTRIBUTE(ZCL_REACHABLE_ATTRIBUTE_ID, BOOLEAN, 1, 0) /* Reachable */ + DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(0x0003); // Declare Fixed Label cluster attributes DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(fixedLabelAttrs) @@ -74,11 +74,9 @@ DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(0x0001); // Declare Cluster List for Bridged Light endpoint DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedLightClusters) -DECLARE_DYNAMIC_CLUSTER(ZCL_ON_OFF_CLUSTER_ID, onOffAttrs), -DECLARE_DYNAMIC_CLUSTER(ZCL_DESCRIPTOR_CLUSTER_ID, descriptorAttrs), -DECLARE_DYNAMIC_CLUSTER(ZCL_BRIDGED_DEVICE_BASIC_CLUSTER_ID, bridgedDeviceBasicAttrs), -DECLARE_DYNAMIC_CLUSTER(ZCL_FIXED_LABEL_CLUSTER_ID, fixedLabelAttrs) -DECLARE_DYNAMIC_CLUSTER_LIST_END; +DECLARE_DYNAMIC_CLUSTER(ZCL_ON_OFF_CLUSTER_ID, onOffAttrs), DECLARE_DYNAMIC_CLUSTER(ZCL_DESCRIPTOR_CLUSTER_ID, descriptorAttrs), + DECLARE_DYNAMIC_CLUSTER(ZCL_BRIDGED_DEVICE_BASIC_CLUSTER_ID, bridgedDeviceBasicAttrs), + DECLARE_DYNAMIC_CLUSTER(ZCL_FIXED_LABEL_CLUSTER_ID, fixedLabelAttrs) DECLARE_DYNAMIC_CLUSTER_LIST_END; // Declare Bridged Light endpoint DECLARE_DYNAMIC_ENDPOINT(bridgedLightEndpoint, bridgedLightClusters); @@ -138,7 +136,7 @@ int RemoveDeviceEndpoint(Device * dev) return -1; } -//ZCL format -> (len, string) +// ZCL format -> (len, string) uint8_t * ToZclCharString(uint8_t * zclString, const char * cString, uint8_t maxLength) { size_t len = strlen(cString); @@ -151,7 +149,7 @@ uint8_t * ToZclCharString(uint8_t * zclString, const char * cString, uint8_t max return zclString; } -//Converted into bytes and mapped the (label, value) +// Converted into bytes and mapped the (label, value) void EncodeFixedLabel(const char * label, const char * value, uint8_t * buffer, uint16_t length, EmberAfAttributeMetadata * am) { char zclOctetStrBuf[kFixedLabelElementsOctetStringSize]; @@ -377,17 +375,17 @@ extern "C" void app_main() CHIP_ERROR chip_err = CHIP_NO_ERROR; - //bridge will have own database named gDevices. - //Clear database + // bridge will have own database named gDevices. + // Clear database memset(gDevices, 0, sizeof(gDevices)); - //Bridged devices 4 + // Bridged devices 4 Device Light1("Light 1", "Office"); Device Light2("Light 2", "Office"); Device Light3("Light 3", "Kitchen"); Device Light4("Light 4", "Den"); - //Whenever bridged device changes its state + // Whenever bridged device changes its state Light1.SetChangeCallback(&HandleDeviceStatusChanged); Light2.SetChangeCallback(&HandleDeviceStatusChanged); Light3.SetChangeCallback(&HandleDeviceStatusChanged); @@ -398,8 +396,8 @@ extern "C" void app_main() Light3.SetReachable(true); Light4.SetReachable(true); - //Till above the bridged device was created, if there is a change in any attribute then with respective to its endpoint - //the change is made. + // Till above the bridged device was created, if there is a change in any attribute then with respective to its endpoint + // the change is made. /*Initialize CHIP*/ CHIPDeviceManager & deviceMgr = CHIPDeviceManager::GetInstance(); @@ -421,7 +419,8 @@ extern "C" void app_main() // Disable last fixed endpoint, which is used as a placeholder for all of the // supported clusters so that ZAP will generated the requisite code. - emberAfEndpointEnableDisable(emberAfEndpointFromIndex(static_cast(emberAfFixedEndpointCount() - 1)), false); // Demo purpose + emberAfEndpointEnableDisable(emberAfEndpointFromIndex(static_cast(emberAfFixedEndpointCount() - 1)), + false); // Demo purpose // Add lights 1..3 --> will be mapped to ZCL endpoints 2, 3, 4 AddDeviceEndpoint(&Light1, &bridgedLightEndpoint, DEVICE_TYPE_LO_ON_OFF_LIGHT); @@ -438,5 +437,4 @@ extern "C" void app_main() AddDeviceEndpoint(&Light2, &bridgedLightEndpoint, DEVICE_TYPE_LO_ON_OFF_LIGHT); /*Run CHIP*/ - }