Skip to content

Commit

Permalink
Restyled by clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits committed Jul 14, 2021
1 parent e8e43be commit 10d2314
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 43 deletions.
24 changes: 12 additions & 12 deletions examples/bridge-app/esp32/main/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <app/common/gen/attribute-id.h>
#include <app/common/gen/cluster-id.h>
#include <app/server/Mdns.h>
Expand Down Expand Up @@ -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;
}
7 changes: 3 additions & 4 deletions examples/bridge-app/esp32/main/include/Device.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//These are the bridged devices
#include <stdbool.h>
#include <stdint.h>
// These are the bridged devices
#include <app/util/attribute-storage.h>
#include <functional>
#include <stdbool.h>
#include <stdint.h>

class Device
{
Expand Down Expand Up @@ -47,5 +47,4 @@ class Device
char mLocation[kDeviceLocationSize];
chip::EndpointId mEndpointId;
DeviceCallback_fn mChanged_CB;

};
52 changes: 25 additions & 27 deletions examples/bridge-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include "Device.h"
#include "DeviceCallbacks.h"
#include <app/util/attribute-storage.h>
#include "esp_log.h"
#include "nvs_flash.h"
#include <app/common/gen/af-structs.h>
#include <app/common/gen/attribute-id.h>
#include <app/common/gen/cluster-id.h>
#include <app/reporting/reporting.h>
#include <app/server/Server.h>
#include <app/util/attribute-storage.h>
#include <core/CHIPError.h>
#include "nvs_flash.h"
#include <support/ErrorStr.h>
#include "esp_log.h"
#include "Device.h"
#include <app/server/Server.h>
#define DYNAMIC_ENDPOINT_COUNT 16
const char * TAG = "bridge-app";

Expand Down Expand Up @@ -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)
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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];
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand All @@ -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<uint16_t>(emberAfFixedEndpointCount() - 1)), false); // Demo purpose
emberAfEndpointEnableDisable(emberAfEndpointFromIndex(static_cast<uint16_t>(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);
Expand All @@ -438,5 +437,4 @@ extern "C" void app_main()
AddDeviceEndpoint(&Light2, &bridgedLightEndpoint, DEVICE_TYPE_LO_ON_OFF_LIGHT);

/*Run CHIP*/

}

0 comments on commit 10d2314

Please sign in to comment.