Skip to content

Commit c396676

Browse files
ci(pre-commit): Apply automatic fixes
1 parent 62c0666 commit c396676

File tree

5 files changed

+227
-257
lines changed

5 files changed

+227
-257
lines changed

Diff for: libraries/ESP32/examples/Zigbee/Zigbee_Light_Bulb/Zigbee_Light_Bulb.ino

+4-9
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
/* Default End Device config */
3939
#define ESP_ZB_ZED_CONFIG() \
4040
{ \
41-
.esp_zb_role = ESP_ZB_DEVICE_TYPE_ED, \
42-
.install_code_policy = INSTALLCODE_POLICY_ENABLE, \
41+
.esp_zb_role = ESP_ZB_DEVICE_TYPE_ED, .install_code_policy = INSTALLCODE_POLICY_ENABLE, \
4342
.nwk_cfg = { \
4443
.zed_cfg = \
4544
{ \
@@ -112,12 +111,8 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) {
112111
static esp_err_t zb_action_handler(esp_zb_core_action_callback_id_t callback_id, const void *message) {
113112
esp_err_t ret = ESP_OK;
114113
switch (callback_id) {
115-
case ESP_ZB_CORE_SET_ATTR_VALUE_CB_ID:
116-
ret = zb_attribute_handler((esp_zb_zcl_set_attr_value_message_t *)message);
117-
break;
118-
default:
119-
log_w("Receive Zigbee action(0x%x) callback", callback_id);
120-
break;
114+
case ESP_ZB_CORE_SET_ATTR_VALUE_CB_ID: ret = zb_attribute_handler((esp_zb_zcl_set_attr_value_message_t *)message); break;
115+
default: log_w("Receive Zigbee action(0x%x) callback", callback_id); break;
121116
}
122117
return ret;
123118
}
@@ -132,7 +127,7 @@ static void esp_zb_task(void *pvParameters) {
132127
esp_zb_set_primary_network_channel_set(ESP_ZB_PRIMARY_CHANNEL_MASK);
133128

134129
//Erase NVRAM before creating connection to new Coordinator
135-
esp_zb_nvram_erase_at_start(true); //Comment out this line to erase NVRAM data if you are conneting to new Coordinator
130+
esp_zb_nvram_erase_at_start(true); //Comment out this line to erase NVRAM data if you are conneting to new Coordinator
136131

137132
ESP_ERROR_CHECK(esp_zb_start(false));
138133
esp_zb_main_loop_iteration();

Diff for: libraries/ESP32/examples/Zigbee/Zigbee_Light_Switch/Zigbee_Light_Switch.ino

+6-8
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ static switch_func_pair_t button_func_pair[] = {{GPIO_INPUT_IO_TOGGLE_SWITCH, SW
6666
/* Default Coordinator config */
6767
#define ESP_ZB_ZC_CONFIG() \
6868
{ \
69-
.esp_zb_role = ESP_ZB_DEVICE_TYPE_COORDINATOR, \
70-
.install_code_policy = INSTALLCODE_POLICY_ENABLE, \
71-
.nwk_cfg = { \
69+
.esp_zb_role = ESP_ZB_DEVICE_TYPE_COORDINATOR, .install_code_policy = INSTALLCODE_POLICY_ENABLE, .nwk_cfg = { \
7270
.zczr_cfg = \
7371
{ \
7472
.max_children = MAX_CHILDREN, \
@@ -198,11 +196,11 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) {
198196
break;
199197
case ESP_ZB_NWK_SIGNAL_PERMIT_JOIN_STATUS:
200198
if (err_status == ESP_OK) {
201-
if (*(uint8_t *)esp_zb_app_signal_get_params(p_sg_p)) {
202-
log_i("Network(0x%04hx) is open for %d seconds", esp_zb_get_pan_id(), *(uint8_t *)esp_zb_app_signal_get_params(p_sg_p));
203-
} else {
204-
log_w("Network(0x%04hx) closed, devices joining not allowed.", esp_zb_get_pan_id());
205-
}
199+
if (*(uint8_t *)esp_zb_app_signal_get_params(p_sg_p)) {
200+
log_i("Network(0x%04hx) is open for %d seconds", esp_zb_get_pan_id(), *(uint8_t *)esp_zb_app_signal_get_params(p_sg_p));
201+
} else {
202+
log_w("Network(0x%04hx) closed, devices joining not allowed.", esp_zb_get_pan_id());
203+
}
206204
}
207205
break;
208206
default: log_i("ZDO signal: %s (0x%x), status: %s", esp_zb_zdo_signal_to_string(sig_type), sig_type, esp_err_to_name(err_status)); break;

Diff for: libraries/ESP32/examples/Zigbee/Zigbee_Temperature_Sensor/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Functions:
2929

3030
### Configure the Project
3131

32-
In this example, the temperature sensor task is reading the chip temperature.
32+
In this example, the temperature sensor task is reading the chip temperature.
3333
Set the Button Switch GPIO by changing the `GPIO_INPUT_IO_TOGGLE_SWITCH` definition. By default, it's the `GPIO_NUM_9` (BOOT button on ESP32-C6 and ESP32-H2).
3434

3535
#### Using Arduino IDE

Diff for: libraries/ESP32/examples/Zigbee/Zigbee_Temperature_Sensor/Zigbee_Temperature_Sensor.ino

+86-85
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,12 @@ typedef enum {
6060
SWITCH_RELEASE_DETECTED,
6161
} switch_state_t;
6262

63-
static switch_func_pair_t button_func_pair[] = {
64-
{GPIO_INPUT_IO_TOGGLE_SWITCH, SWITCH_ONOFF_TOGGLE_CONTROL}
65-
};
63+
static switch_func_pair_t button_func_pair[] = {{GPIO_INPUT_IO_TOGGLE_SWITCH, SWITCH_ONOFF_TOGGLE_CONTROL}};
6664

6765
/* Default End Device config */
6866
#define ESP_ZB_ZED_CONFIG() \
6967
{ \
70-
.esp_zb_role = ESP_ZB_DEVICE_TYPE_ED, \
71-
.install_code_policy = INSTALLCODE_POLICY_ENABLE, \
68+
.esp_zb_role = ESP_ZB_DEVICE_TYPE_ED, .install_code_policy = INSTALLCODE_POLICY_ENABLE, \
7269
.nwk_cfg = { \
7370
.zed_cfg = \
7471
{ \
@@ -85,58 +82,58 @@ static switch_func_pair_t button_func_pair[] = {
8582
{ .host_connection_mode = ZB_HOST_CONNECTION_MODE_NONE, }
8683

8784
/* Zigbee configuration */
88-
#define INSTALLCODE_POLICY_ENABLE false /* enable the install code policy for security */
85+
#define INSTALLCODE_POLICY_ENABLE false /* enable the install code policy for security */
8986
#define ED_AGING_TIMEOUT ESP_ZB_ED_AGING_TIMEOUT_64MIN
9087
#define ED_KEEP_ALIVE 3000 /* 3000 millisecond */
9188
#define HA_ESP_SENSOR_ENDPOINT 10 /* esp temperature sensor device endpoint, used for temperature measurement */
9289
#define ESP_ZB_PRIMARY_CHANNEL_MASK ESP_ZB_TRANSCEIVER_ALL_CHANNELS_MASK /* Zigbee primary channel mask use in the example */
9390

9491
/* Temperature sensor configuration */
95-
#define ESP_TEMP_SENSOR_UPDATE_INTERVAL (1) /* Local sensor update interval (second) */
96-
#define ESP_TEMP_SENSOR_MIN_VALUE (10) /* Local sensor min measured value (degree Celsius) */
97-
#define ESP_TEMP_SENSOR_MAX_VALUE (50) /* Local sensor max measured value (degree Celsius) */
92+
#define ESP_TEMP_SENSOR_UPDATE_INTERVAL (1) /* Local sensor update interval (second) */
93+
#define ESP_TEMP_SENSOR_MIN_VALUE (10) /* Local sensor min measured value (degree Celsius) */
94+
#define ESP_TEMP_SENSOR_MAX_VALUE (50) /* Local sensor max measured value (degree Celsius) */
9895

9996
/* Attribute values in ZCL string format
10097
* The string should be started with the length of its own.
10198
*/
102-
#define MANUFACTURER_NAME "\x0B""ESPRESSIF"
103-
#define MODEL_IDENTIFIER "\x09"CONFIG_IDF_TARGET
99+
#define MANUFACTURER_NAME \
100+
"\x0B" \
101+
"ESPRESSIF"
102+
#define MODEL_IDENTIFIER "\x09" CONFIG_IDF_TARGET
104103

105104
/********************* Zigbee functions **************************/
106-
static int16_t zb_temperature_to_s16(float temp)
107-
{
108-
return (int16_t)(temp * 100);
105+
static int16_t zb_temperature_to_s16(float temp) {
106+
return (int16_t)(temp * 100);
109107
}
110108

111-
static void esp_zb_buttons_handler(switch_func_pair_t *button_func_pair)
112-
{
113-
if (button_func_pair->func == SWITCH_ONOFF_TOGGLE_CONTROL) {
114-
/* Send report attributes command */
115-
esp_zb_zcl_report_attr_cmd_t report_attr_cmd;
116-
report_attr_cmd.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
117-
report_attr_cmd.attributeID = ESP_ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID;
118-
report_attr_cmd.cluster_role = ESP_ZB_ZCL_CLUSTER_SERVER_ROLE;
119-
report_attr_cmd.clusterID = ESP_ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT;
120-
report_attr_cmd.zcl_basic_cmd.src_endpoint = HA_ESP_SENSOR_ENDPOINT;
121-
122-
esp_zb_lock_acquire(portMAX_DELAY);
123-
esp_zb_zcl_report_attr_cmd_req(&report_attr_cmd);
124-
esp_zb_lock_release();
125-
log_i("Send 'report attributes' command");
126-
}
127-
}
109+
static void esp_zb_buttons_handler(switch_func_pair_t *button_func_pair) {
110+
if (button_func_pair->func == SWITCH_ONOFF_TOGGLE_CONTROL) {
111+
/* Send report attributes command */
112+
esp_zb_zcl_report_attr_cmd_t report_attr_cmd;
113+
report_attr_cmd.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
114+
report_attr_cmd.attributeID = ESP_ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID;
115+
report_attr_cmd.cluster_role = ESP_ZB_ZCL_CLUSTER_SERVER_ROLE;
116+
report_attr_cmd.clusterID = ESP_ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT;
117+
report_attr_cmd.zcl_basic_cmd.src_endpoint = HA_ESP_SENSOR_ENDPOINT;
128118

129-
static void esp_app_temp_sensor_handler(float temperature)
130-
{
131-
int16_t measured_value = zb_temperature_to_s16(temperature);
132-
Serial.println("Updating temperature sensor value...");
133-
Serial.println(measured_value);
134-
/* Update temperature sensor measured value */
135119
esp_zb_lock_acquire(portMAX_DELAY);
136-
esp_zb_zcl_set_attribute_val(HA_ESP_SENSOR_ENDPOINT,
137-
ESP_ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE,
138-
ESP_ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID, &measured_value, false);
120+
esp_zb_zcl_report_attr_cmd_req(&report_attr_cmd);
139121
esp_zb_lock_release();
122+
log_i("Send 'report attributes' command");
123+
}
124+
}
125+
126+
static void esp_app_temp_sensor_handler(float temperature) {
127+
int16_t measured_value = zb_temperature_to_s16(temperature);
128+
Serial.println("Updating temperature sensor value...");
129+
Serial.println(measured_value);
130+
/* Update temperature sensor measured value */
131+
esp_zb_lock_acquire(portMAX_DELAY);
132+
esp_zb_zcl_set_attribute_val(
133+
HA_ESP_SENSOR_ENDPOINT, ESP_ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID, &measured_value,
134+
false
135+
);
136+
esp_zb_lock_release();
140137
}
141138

142139
static void bdb_start_top_level_commissioning_cb(uint8_t mode_mask) {
@@ -160,10 +157,10 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) {
160157
// Start Temperature sensor reading task
161158
xTaskCreate(temp_sensor_value_update, "temp_sensor_update", 2048, NULL, 10, NULL);
162159
if (esp_zb_bdb_is_factory_new()) {
163-
log_i("Start network steering");
164-
esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_STEERING);
160+
log_i("Start network steering");
161+
esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_STEERING);
165162
} else {
166-
log_i("Device rebooted");
163+
log_i("Device rebooted");
167164
}
168165
} else {
169166
/* commissioning failed */
@@ -188,30 +185,31 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) {
188185
}
189186
}
190187

191-
static esp_zb_cluster_list_t *custom_temperature_sensor_clusters_create(esp_zb_temperature_sensor_cfg_t *temperature_sensor)
192-
{
193-
esp_zb_cluster_list_t *cluster_list = esp_zb_zcl_cluster_list_create();
194-
esp_zb_attribute_list_t *basic_cluster = esp_zb_basic_cluster_create(&(temperature_sensor->basic_cfg));
195-
ESP_ERROR_CHECK(esp_zb_basic_cluster_add_attr(basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MANUFACTURER_NAME_ID, (void*)MANUFACTURER_NAME));
196-
ESP_ERROR_CHECK(esp_zb_basic_cluster_add_attr(basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MODEL_IDENTIFIER_ID, (void*)MODEL_IDENTIFIER));
197-
ESP_ERROR_CHECK(esp_zb_cluster_list_add_basic_cluster(cluster_list, basic_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE));
198-
ESP_ERROR_CHECK(esp_zb_cluster_list_add_identify_cluster(cluster_list, esp_zb_identify_cluster_create(&(temperature_sensor->identify_cfg)), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE));
199-
ESP_ERROR_CHECK(esp_zb_cluster_list_add_identify_cluster(cluster_list, esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_IDENTIFY), ESP_ZB_ZCL_CLUSTER_CLIENT_ROLE));
200-
ESP_ERROR_CHECK(esp_zb_cluster_list_add_temperature_meas_cluster(cluster_list, esp_zb_temperature_meas_cluster_create(&(temperature_sensor->temp_meas_cfg)), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE));
201-
return cluster_list;
188+
static esp_zb_cluster_list_t *custom_temperature_sensor_clusters_create(esp_zb_temperature_sensor_cfg_t *temperature_sensor) {
189+
esp_zb_cluster_list_t *cluster_list = esp_zb_zcl_cluster_list_create();
190+
esp_zb_attribute_list_t *basic_cluster = esp_zb_basic_cluster_create(&(temperature_sensor->basic_cfg));
191+
ESP_ERROR_CHECK(esp_zb_basic_cluster_add_attr(basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MANUFACTURER_NAME_ID, (void *)MANUFACTURER_NAME));
192+
ESP_ERROR_CHECK(esp_zb_basic_cluster_add_attr(basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MODEL_IDENTIFIER_ID, (void *)MODEL_IDENTIFIER));
193+
ESP_ERROR_CHECK(esp_zb_cluster_list_add_basic_cluster(cluster_list, basic_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE));
194+
ESP_ERROR_CHECK(
195+
esp_zb_cluster_list_add_identify_cluster(cluster_list, esp_zb_identify_cluster_create(&(temperature_sensor->identify_cfg)), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE)
196+
);
197+
ESP_ERROR_CHECK(
198+
esp_zb_cluster_list_add_identify_cluster(cluster_list, esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_IDENTIFY), ESP_ZB_ZCL_CLUSTER_CLIENT_ROLE)
199+
);
200+
ESP_ERROR_CHECK(esp_zb_cluster_list_add_temperature_meas_cluster(
201+
cluster_list, esp_zb_temperature_meas_cluster_create(&(temperature_sensor->temp_meas_cfg)), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE
202+
));
203+
return cluster_list;
202204
}
203205

204-
static esp_zb_ep_list_t *custom_temperature_sensor_ep_create(uint8_t endpoint_id, esp_zb_temperature_sensor_cfg_t *temperature_sensor)
205-
{
206-
esp_zb_ep_list_t *ep_list = esp_zb_ep_list_create();
207-
esp_zb_endpoint_config_t endpoint_config = {
208-
.endpoint = endpoint_id,
209-
.app_profile_id = ESP_ZB_AF_HA_PROFILE_ID,
210-
.app_device_id = ESP_ZB_HA_TEMPERATURE_SENSOR_DEVICE_ID,
211-
.app_device_version = 0
212-
};
213-
esp_zb_ep_list_add_ep(ep_list, custom_temperature_sensor_clusters_create(temperature_sensor), endpoint_config);
214-
return ep_list;
206+
static esp_zb_ep_list_t *custom_temperature_sensor_ep_create(uint8_t endpoint_id, esp_zb_temperature_sensor_cfg_t *temperature_sensor) {
207+
esp_zb_ep_list_t *ep_list = esp_zb_ep_list_create();
208+
esp_zb_endpoint_config_t endpoint_config = {
209+
.endpoint = endpoint_id, .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID, .app_device_id = ESP_ZB_HA_TEMPERATURE_SENSOR_DEVICE_ID, .app_device_version = 0
210+
};
211+
esp_zb_ep_list_add_ep(ep_list, custom_temperature_sensor_clusters_create(temperature_sensor), endpoint_config);
212+
return ep_list;
215213
}
216214

217215
static void esp_zb_task(void *pvParameters) {
@@ -228,26 +226,30 @@ static void esp_zb_task(void *pvParameters) {
228226

229227
/* Config the reporting info */
230228
esp_zb_zcl_reporting_info_t reporting_info = {
231-
.direction = ESP_ZB_ZCL_CMD_DIRECTION_TO_SRV,
232-
.ep = HA_ESP_SENSOR_ENDPOINT,
233-
.cluster_id = ESP_ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT,
234-
.cluster_role = ESP_ZB_ZCL_CLUSTER_SERVER_ROLE,
235-
.attr_id = ESP_ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID,
236-
.u = {
237-
.send_info = {
229+
.direction = ESP_ZB_ZCL_CMD_DIRECTION_TO_SRV,
230+
.ep = HA_ESP_SENSOR_ENDPOINT,
231+
.cluster_id = ESP_ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT,
232+
.cluster_role = ESP_ZB_ZCL_CLUSTER_SERVER_ROLE,
233+
.attr_id = ESP_ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID,
234+
.u =
235+
{
236+
.send_info =
237+
{
238238
.min_interval = 1,
239239
.max_interval = 0,
240-
.delta = {
241-
.u16 = 100,
242-
},
240+
.delta =
241+
{
242+
.u16 = 100,
243+
},
243244
.def_min_interval = 1,
244245
.def_max_interval = 0,
245-
},
246+
},
246247
},
247-
.dst = {
248+
.dst =
249+
{
248250
.profile_id = ESP_ZB_AF_HA_PROFILE_ID,
249251
},
250-
.manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC,
252+
.manuf_code = ESP_ZB_ZCL_ATTR_NON_MANUFACTURER_SPECIFIC,
251253
};
252254
esp_zb_zcl_update_reporting_info(&reporting_info);
253255
esp_zb_set_primary_network_channel_set(ESP_ZB_PRIMARY_CHANNEL_MASK);
@@ -277,13 +279,12 @@ static void switch_gpios_intr_enabled(bool enabled) {
277279
}
278280

279281
/************************ Temp sensor *****************************/
280-
static void temp_sensor_value_update(void *arg)
281-
{
282-
for (;;) {
283-
float tsens_value = temperatureRead();
284-
esp_app_temp_sensor_handler(tsens_value);
285-
delay(1000);
286-
}
282+
static void temp_sensor_value_update(void *arg) {
283+
for (;;) {
284+
float tsens_value = temperatureRead();
285+
esp_app_temp_sensor_handler(tsens_value);
286+
delay(1000);
287+
}
287288
}
288289

289290
/********************* Arduino functions **************************/

0 commit comments

Comments
 (0)