Skip to content

Commit 3e257cb

Browse files
committed
Merge branch 'hal' into hal-build
2 parents 9b5f1b7 + d975ed3 commit 3e257cb

File tree

16 files changed

+106
-21
lines changed

16 files changed

+106
-21
lines changed

helper_scripts/templates/switch_custom.js.jinja

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,34 @@ const definitions = [
217217
meta: { multiEndpoint: true },
218218
configure: async (device, coordinatorEndpoint, logger) => {
219219
{% for switchName in device.switchNames %}
220-
await reporting.bind(device.getEndpoint({{loop.index}}), coordinatorEndpoint, ["genMultistateInput"]);
220+
const endpoint{{loop.index}} = device.getEndpoint({{loop.index}});
221+
await reporting.bind(endpoint{{loop.index}}, coordinatorEndpoint, ["genMultistateInput"]);
222+
// switch action:
223+
await endpoint{{loop.index}}.configureReporting("genMultistateInput", [
224+
{
225+
attribute: {ID: 0x0055 /* presentValue */, type: 0x21}, // uint16
226+
minimumReportInterval: 0,
227+
maximumReportInterval: constants.repInterval.MAX,
228+
reportableChange: 1,
229+
},
230+
]);
221231
{% endfor %}
222232
{% for relayName in device.relayNames %}
223233
const endpoint{{loop.index + (device.switchNames | length)}} = device.getEndpoint({{loop.index + (device.switchNames | length)}});
224234
await reporting.onOff(endpoint{{loop.index + (device.switchNames | length)}}, {
225235
min: 0,
226-
max: constants.repInterval.MINUTE,
236+
max: constants.repInterval.MAX,
227237
change: 1,
228238
});
239+
// indicator:
240+
await endpoint{{loop.index + (device.switchNames | length)}}.configureReporting("genOnOff", [
241+
{
242+
attribute: {ID: 0xff02, type: 0x10}, // Boolean
243+
minimumReportInterval: 0,
244+
maximumReportInterval: constants.repInterval.MAX,
245+
reportableChange: 1,
246+
},
247+
]);
229248
{% endfor %}
230249
},
231250
{% if z2m_v1 %}

src/device_config/config_nv.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ void device_config_write_to_nv() {
3434
}
3535
}
3636

37-
void device_config_remove_from_nv() { hal_nvm_delete(NV_ITEM_DEVICE_CONFIG); }
38-
3937
void device_config_read_from_nv() {
4038
hal_nvm_status_t st = 0;
4139

src/device_config/config_parser.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "base_components/led.h"
1414
#include "base_components/network_indicator.h"
1515
#include "config_nv.h"
16+
#include "device_config/reset.h"
1617
#include "hal/system.h"
1718
#include "hal/zigbee.h"
1819
#include "hal/zigbee_ota.h"
@@ -52,12 +53,11 @@ uint8_t relay_clusters_cnt = 0;
5253
hal_zigbee_cluster clusters[32];
5354
hal_zigbee_endpoint endpoints[10];
5455

55-
void reset_to_default_config();
5656
uint32_t parse_int(const char *s);
5757
char *seek_until(char *cursor, char needle);
5858
char *extract_next_entry(char **cursor);
5959

60-
void onResetClicked(void *_) { hal_zigbee_leave_network(); }
60+
void on_reset_clicked(void *_) { reset_all(); }
6161

6262
void parse_config() {
6363
device_config_read_from_nv();
@@ -68,7 +68,7 @@ void parse_config() {
6868
basic_cluster.manuName[0] = strlen(zb_manufacturer);
6969
if (basic_cluster.manuName[0] > 31) {
7070
printf("Manufacturer too big\r\n");
71-
reset_to_default_config();
71+
reset_all();
7272
}
7373
memcpy(basic_cluster.manuName + 1, zb_manufacturer,
7474
basic_cluster.manuName[0]);
@@ -77,7 +77,7 @@ void parse_config() {
7777
basic_cluster.modelId[0] = strlen(zb_model);
7878
if (basic_cluster.modelId[0] > 31) {
7979
printf("Model too big\r\n");
80-
reset_to_default_config();
80+
reset_all();
8181
}
8282
memcpy(basic_cluster.modelId + 1, zb_model, basic_cluster.modelId[0]);
8383

@@ -93,7 +93,7 @@ void parse_config() {
9393
buttons[buttons_cnt].pin = pin;
9494
buttons[buttons_cnt].long_press_duration_ms = 2000;
9595
buttons[buttons_cnt].multi_press_duration_ms = 800;
96-
buttons[buttons_cnt].on_long_press = onResetClicked;
96+
buttons[buttons_cnt].on_long_press = on_reset_clicked;
9797
buttons_cnt++;
9898
} else if (entry[0] == 'L') {
9999
hal_gpio_pin_t pin = hal_gpio_parse_pin(entry + 1);
@@ -277,12 +277,6 @@ void init_reporting() {
277277

278278
// Helper functions
279279

280-
__attribute__((noreturn)) void reset_to_default_config() {
281-
printf("RESET reset_to_default_config\r\n");
282-
device_config_remove_from_nv();
283-
hal_system_reset();
284-
}
285-
286280
char *seek_until(char *cursor, char needle) {
287281
while (*cursor != needle && *cursor != '\0') {
288282
cursor++;

src/device_config/reset.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
#include "reset.h"
3+
#include "hal/nvm.h"
4+
#include "hal/printf_selector.h"
5+
#include "hal/system.h"
6+
7+
__attribute__((noreturn)) void reset_all() {
8+
printf("RESET ALL!\r\n");
9+
hal_nvm_clear_all();
10+
hal_system_reset();
11+
}

src/device_config/reset.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#ifndef RESET_H
2+
#define RESET_H
3+
4+
__attribute__((noreturn)) void reset_all();
5+
void leave_network();
6+
7+
#endif // RESET_H

src/silabs/Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ GCC_BIN ?= arm-none-eabi-gcc
99
# Version and board configuration
1010
VERSION_STR ?= 0.0.0
1111
FILE_VERSION ?= 0
12+
DEBUG ?= 0
1213

1314

1415
DEVICE_TYPE ?= router
@@ -80,6 +81,13 @@ BOOTLOADER_PROJECT_FILE := bootloader.slcp
8081
OTA_FILE ?= $(ZIGBEE_BUILD_DIR)/build/release/$(ZIGBEE_PROJECT_NAME)_ota.bin
8182
BIN_FILE ?= $(ZIGBEE_BUILD_DIR)/build/release/$(ZIGBEE_PROJECT_NAME).s37
8283

84+
# Component exclusion based on DEBUG flag
85+
ifeq ($(DEBUG), 0)
86+
WITHOUT_COMPONENTS = --without=iostream_usart:inst,iostream_recommended_stream
87+
else
88+
WITHOUT_COMPONENTS =
89+
endif
90+
8391
# Generate project files
8492
gen:
8593
rm -rf $(ZIGBEE_BUILD_DIR)
@@ -96,6 +104,7 @@ gen:
96104
-d "$(ZIGBEE_BUILD_DIR)" \
97105
-name $(ZIGBEE_PROJECT_NAME) \
98106
--with EFR32MG21A020F768IM32 \
107+
$(WITHOUT_COMPONENTS) \
99108
--toolchain=gcc \
100109
--output-type=makefile
101110

src/silabs/zigbee.slcp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ source:
3636
- {path: ../device_config/config_parser.c}
3737
- {path: ../device_config/config_parser.h}
3838
- {path: ../device_config/nvm_items.h}
39+
- {path: ../device_config/reset.c}
40+
- {path: ../device_config/reset.h}
3941
- {path: ../zigbee/basic_cluster.c}
4042
- {path: ../zigbee/general_commands.c}
4143
- {path: ../zigbee/group_cluster.c}

src/silabs/zigbee_end_device.slcp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ source:
3636
- {path: ../device_config/config_parser.c}
3737
- {path: ../device_config/config_parser.h}
3838
- {path: ../device_config/nvm_items.h}
39+
- {path: ../device_config/reset.c}
40+
- {path: ../device_config/reset.h}
3941
- {path: ../zigbee/basic_cluster.c}
4042
- {path: ../zigbee/general_commands.c}
4143
- {path: ../zigbee/group_cluster.c}

src/stub/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ SOURCES := \
4949
$(SRC_DIR)/base_components/network_indicator.c \
5050
$(SRC_DIR)/device_config/config_parser.c \
5151
$(SRC_DIR)/device_config/config_nv.c \
52+
$(SRC_DIR)/device_config/reset.c \
5253
$(SRC_DIR)/zigbee/basic_cluster.c \
5354
$(SRC_DIR)/zigbee/relay_cluster.c \
5455
$(SRC_DIR)/zigbee/switch_cluster.c \

src/telink/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ COMMON_SOURCES := \
145145
$(SRC_DIR)/base_components/network_indicator.c \
146146
$(SRC_DIR)/base_components/relay.c \
147147
$(SRC_DIR)/device_config/config_nv.c \
148+
$(SRC_DIR)/device_config/reset.c \
148149
$(SRC_DIR)/device_config/config_parser.c \
149150
$(SRC_DIR)/zigbee/basic_cluster.c \
150151
$(SRC_DIR)/zigbee/general_commands.c \

0 commit comments

Comments
 (0)