Skip to content
This repository was archived by the owner on May 27, 2024. It is now read-only.

Commit 04de9b6

Browse files
committed
Updated to Sming 4.0
1 parent d3073f9 commit 04de9b6

26 files changed

Lines changed: 193 additions & 169 deletions

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
/build
2-
/dist
1+
/framework/out
32

43
/Configuration.mk
54

Dockerfile

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,41 +21,41 @@ RUN apt-get update && apt-get install -y \
2121
RUN useradd -m builder
2222
USER builder
2323

24-
# Install ESP8266 SDK
24+
## Install ESP8266 SDK - this is only needed for the toolchain
2525
RUN git clone https://github.com/pfalcon/esp-open-sdk.git /home/builder/esp-open-sdk \
2626
&& cd /home/builder/esp-open-sdk \
2727
&& git reset --hard c70543e57fb18e5be0315aa217bca27d0e26d23d \
2828
&& git submodule update --init --recursive \
29-
&& cd /home/builder/esp-open-sdk; make VENDOR_SDK=2.1.0 STANDALONE=y \
29+
&& cd /home/builder/esp-open-sdk; make VENDOR_SDK=1.5.4 STANDALONE=y \
3030
&& rm -rf /home/builder/esp-open-sdk/crosstool-NG/.build
3131

32-
ENV PATH /home/builder/esp-open-sdk/xtensa-lx106-elf/bin:$PATH
33-
ENV XTENSA_TOOLS_ROOT /home/builder/esp-open-sdk/xtensa-lx106-elf/bin
34-
ENV FW_TOOL /home/builder/esp-open-sdk/xtensa-lx106-elf/bin/esptool.py
32+
#ENV PATH /home/builder/esp-open-sdk/xtensa-lx106-elf/bin:$PATH
33+
#ENV XTENSA_TOOLS_ROOT /home/builder/esp-open-sdk/xtensa-lx106-elf/bin
34+
#ENV FW_TOOL /home/builder/esp-open-sdk/xtensa-lx106-elf/bin/esptool.py
3535
ENV ESP_HOME /home/builder/esp-open-sdk
3636
ENV SMING_HOME /home/builder/Sming/Sming
37-
ENV SDK_BASE $SMING_HOME/third-party/ESP8266_NONOS_SDK
38-
39-
# Install esptool
40-
RUN git clone --recursive https://github.com/themadinventor/esptool.git /home/builder/esptool \
41-
&& cd /home/builder/esptool \
42-
&& git reset --hard ee00d8421353f43671e84c80cfbd465c33eee77d
43-
44-
ENV PATH /home/builder/esptool:$PATH
45-
46-
# Install esptool2
47-
RUN git clone --recursive https://github.com/raburton/esptool2 /home/builder/esptool2 \
48-
&& cd /home/builder/esptool2 \
49-
&& git reset --hard 3616335ab318cde9e25ba81dbd47097b09603161 \
50-
&& cd /home/builder/esptool2 \
51-
&& make
52-
53-
ENV PATH /home/builder/esptool2:$PATH
37+
#ENV SDK_BASE $SMING_HOME/third-party/ESP8266_NONOS_SDK
38+
#
39+
## Install esptool
40+
#RUN git clone --recursive https://github.com/themadinventor/esptool.git /home/builder/esptool \
41+
# && cd /home/builder/esptool \
42+
# && git reset --hard ee00d8421353f43671e84c80cfbd465c33eee77d
43+
#
44+
#ENV PATH /home/builder/esptool:$PATH
45+
#
46+
## Install esptool2
47+
#RUN git clone --recursive https://github.com/raburton/esptool2 /home/builder/esptool2 \
48+
# && cd /home/builder/esptool2 \
49+
# && git reset --hard 3616335ab318cde9e25ba81dbd47097b09603161 \
50+
# && cd /home/builder/esptool2 \
51+
# && make
52+
#
53+
#ENV PATH /home/builder/esptool2:$PATH
5454

5555
# Install sming
56-
RUN git clone https://github.com/esper-hub/Sming.git /home/builder/Sming \
56+
RUN git clone https://github.com/SmingHub/Sming.git /home/builder/Sming \
5757
&& cd /home/builder/Sming \
58-
&& git reset --hard 9c7cac2d260798e19e833bbaabf9f30b659425a8 \
58+
&& git reset --hard 8883768125ec3c7a754339230805068d4254bc08 \
5959
&& git submodule update --init --recursive \
6060
&& cd /home/builder/Sming/Sming \
6161
&& make clean \

Makefile

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
export BASEDIR := $(CURDIR)
2-
3-
41
ifndef SITE
52
$(error SITE is not set. Please Specify a site directory.)
63
else
74
export SITEDIR := $(abspath $(SITE))
85
endif
96

107

11-
export BUILDDIR = $(BASEDIR)/build
12-
export DISTDIR = $(SITEDIR)/dist
8+
export BASEDIR := $(CURDIR)
9+
export DISTDIR := $(SITEDIR)/dist
1310

1411

1512
# Find devices
@@ -22,39 +19,23 @@ all: $(DEVICES)
2219

2320
.PHONY: $(addsuffix /clean,$(DEVICES))
2421
$(addsuffix /clean,$(DEVICES)): %/clean:
25-
mkdir -p $(BUILDDIR)/$*
26-
$(MAKE) -C $(BUILDDIR)/$* -f $(BASEDIR)/Device.mk DEVICE=$* clean
22+
$(MAKE) -C $(BASEDIR)/framework -f $(BASEDIR)/framework/device.mk DEVICE=$* clean
2723

2824

2925
.PHONY: $(addsuffix /build,$(DEVICES))
3026
$(addsuffix /build,$(DEVICES)): %/build:
31-
mkdir -p $(BUILDDIR)/$*
32-
$(MAKE) -C $(BUILDDIR)/$* -f $(BASEDIR)/Device.mk DEVICE=$*
33-
34-
35-
.PHONY: $(addsuffix /erase,$(DEVICES))
36-
$(addsuffix /erase,$(DEVICES)): %/erase: %/build
37-
$(MAKE) -C $(BUILDDIR)/$* -f $(BASEDIR)/Device.mk DEVICE=$* flashinit
27+
$(MAKE) -C $(BASEDIR)/framework -f $(BASEDIR)/framework/device.mk DEVICE=$* all
3828

3929

4030
.PHONY: $(addsuffix /flash,$(DEVICES))
41-
$(addsuffix /flash,$(DEVICES)): %/flash: %/build
42-
$(MAKE) -C $(BUILDDIR)/$* -f $(BASEDIR)/Device.mk DEVICE=$* flash
43-
44-
45-
.PHONY: $(addsuffix /dist,$(DEVICES))
46-
$(addsuffix /dist,$(DEVICES)): %/dist: %/build
47-
mkdir -p $(DISTDIR)
48-
cp $(BUILDDIR)/$*/out/firmware/rboot.bin $(DISTDIR)/$*.rboot
49-
cp $(BUILDDIR)/$*/out/firmware/rom0.bin $(DISTDIR)/$*.rom0
50-
cp $(BUILDDIR)/$*/out/firmware/rom1.bin $(DISTDIR)/$*.rom1
51-
cp $(BUILDDIR)/$*/out/firmware/version $(DISTDIR)/$*.version
31+
$(addsuffix /flash,$(DEVICES)): %/flash:
32+
$(MAKE) -C $(BASEDIR)/framework -f $(BASEDIR)/framework/device.mk DEVICE=$* all flashinit flash
5233

5334

5435
.PHONY: $(DEVICES)
55-
$(DEVICES): %: %/build %/dist
36+
$(DEVICES): %: %/build
5637

5738

5839
.PHONY: clean
5940
clean:
60-
rm -f -r $(BUILDDIR) $(DISTDIR)
41+
rm -f -r $(DISTDIR)

devices/example-bme280/Impl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#include "../features/BME280.h"
1+
#include <features/BME280.h>
2+
23
#include "Device.h"
34

45

devices/sonoff-t1/Impl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
#include "../features/Socket.h"
2-
#include "../features/TriggerButton.h"
1+
#include <features/Socket.h>
2+
#include <features/TriggerButton.h>
3+
34
#include "Device.h"
45

56

devices/sonoff/Impl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
#include "../features/Socket.h"
2-
#include "../features/TriggerButton.h"
1+
#include <features/Socket.h>
2+
#include <features/TriggerButton.h>
3+
34
#include "Device.h"
45

56

framework/Device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef DEVICE_H
22
#define DEVICE_H
33

4-
#include <SmingCore/SmingCore.h>
4+
#include <SmingCore.h>
55

66
#include "util/Logger.h"
77
#include "managers/WifiConnectionManager.h"

framework/component.mk

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Load configuration
2+
ifndef CONFIG
3+
include $(SITEDIR)/Configuration.mk
4+
else
5+
include $(SITEDIR)/Configuration.mk.$(CONFIG)
6+
endif
7+
8+
9+
# Add source code
10+
COMPONENT_SRCDIRS += $(COMPONENT_PATH)/features
11+
COMPONENT_SRCDIRS += $(COMPONENT_PATH)/managers
12+
COMPONENT_SRCDIRS += $(COMPONENT_PATH)/services
13+
COMPONENT_SRCDIRS += $(COMPONENT_PATH)/util
14+
COMPONENT_SRCDIRS += $(COMPONENT_PATH)
15+
16+
# Add the framework itself as include to make it usable in the device code
17+
COMPONENT_INCDIRS += $(COMPONENT_PATH)/framework
18+
19+
# Add the device
20+
COMPONENT_SRCDIRS += $(DEVICEDIR)
21+
22+
23+
# Ensure rebuild for each device
24+
CONFIG_VARS += DEVICE DEVICEDIR
25+
26+
27+
# Add JSON support
28+
ARDUINO_LIBRARIES=ArduinoJson6
Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,18 @@
1-
# Load configuration
1+
$(info Building device '$(DEVICE)'...)
22

3+
# Load configuration
34
ifndef CONFIG
4-
include $(SITEDIR)/Configuration.mk
5+
include $(SITEDIR)/Configuration.mk
56
else
6-
include $(SITEDIR)/Configuration.mk.$(CONFIG)
7+
include $(SITEDIR)/Configuration.mk.$(CONFIG)
78
endif
89

910

10-
# Sanity checking some required variables
11-
ifndef SMING_HOME
12-
$(error SMING_HOME is not set. Please configure it in Configuration.mk or set in environment.)
13-
endif
14-
15-
ifndef ESP_HOME
16-
$(error ESP_HOME is not set. Please configure it in Configuration.mk or set in environment.)
17-
endif
18-
19-
20-
# Add required modules
21-
MODULES += $(BASEDIR)/framework/devices
22-
MODULES += $(BASEDIR)/framework/features
23-
MODULES += $(BASEDIR)/framework/managers
24-
MODULES += $(BASEDIR)/framework/services
25-
MODULES += $(BASEDIR)/framework/util
26-
MODULES += $(BASEDIR)/framework
27-
2811
# Add device module either from site or from esper
2912
ifneq ($(wildcard $(SITEDIR)/devices/$(DEVICE)), )
30-
MODULES += $(SITEDIR)/devices/$(DEVICE)
13+
export DEVICEDIR := $(SITEDIR)/devices/$(DEVICE)
3114
else
32-
MODULES += $(BASEDIR)/devices/$(DEVICE)
15+
export DEVICEDIR := $(BASEDIR)/devices/$(DEVICE)
3316
endif
3417

3518

@@ -45,7 +28,7 @@ endif
4528

4629

4730
# Load the device overrides
48-
-include $(SITEDIR)/devices/$(DEVICE)/Device.mk
31+
-include $(DEVICEDIR)/device.mk
4932

5033

5134
# Define config defaults
@@ -64,6 +47,9 @@ UPDATE_TOPIC ?= $(MQTT_REALM)/update
6447
INFO_HTTP_ENABLED ?= false
6548
INFO_HTTP_PORT ?= 80
6649

50+
MQTT_PORT ?= 1883
51+
MQTT_URL ?= mqtt://$(MQTT_USERNAME):$(MQTT_PASSWORD)@$(MQTT_HOST):$(MQTT_PORT)
52+
6753

6854
# Pass options to source code
6955
USER_CFLAGS += -DDEVICE=\"$(DEVICE)\"
@@ -72,11 +58,8 @@ USER_CFLAGS += -DVERSION=\"$(VERSION)\"
7258
USER_CFLAGS += -DLOGGING=$(LOGGING)
7359
USER_CFLAGS += -DLOGGING_DEBUG=$(LOGGING_DEBUG)
7460

75-
USER_CFLAGS += -DMQTT_HOST=\"$(MQTT_HOST)\"
76-
USER_CFLAGS += -DMQTT_PORT=$(MQTT_PORT)
61+
USER_CFLAGS += -DMQTT_URL=\"$(MQTT_URL)\"
7762
USER_CFLAGS += -DMQTT_REALM=\"$(MQTT_REALM)\"
78-
USER_CFLAGS += -DMQTT_USERNAME=\"$(MQTT_USERNAME)\"
79-
USER_CFLAGS += -DMQTT_PASSWORD=\"$(MQTT_PASSWORD)\"
8063

8164
USER_CFLAGS += -DHEARTBEAT_ENABLED=$(HEARTBEAT_ENABLED)
8265
USER_CFLAGS += -DHEARTBEAT_TOPIC=\"$(HEARTBEAT_TOPIC)\"
@@ -90,7 +73,6 @@ USER_CFLAGS += -DUPDATE_TOPIC=\"$(UPDATE_TOPIC)\"
9073
USER_CFLAGS += -DINFO_HTTP_ENABLED=$(INFO_HTTP_ENABLED)
9174
USER_CFLAGS += -DINFO_HTTP_PORT=$(INFO_HTTP_PORT)
9275

93-
9476
# Use Release
9577
SMING_RELEASE = 1
9678

@@ -99,29 +81,56 @@ SMING_RELEASE = 1
9981
DISABLE_SPIFFS = 1
10082

10183

102-
# Use alternative bootloader
84+
# Configure bootloader for A/B partitioning
10385
RBOOT_ENABLED = 1
10486
RBOOT_BIG_FLASH = 0
10587
RBOOT_TWO_ROMS = 1
10688
RBOOT_RTC_ENABLED = 0
10789

108-
RBOOT_LD_0 = $(BASEDIR)/rom0.ld
109-
RBOOT_LD_1 = $(BASEDIR)/rom1.ld
90+
RBOOT_LD_0 = $(BASEDIR)/framework/rom0.ld
91+
RBOOT_LD_1 = $(BASEDIR)/framework/rom1.ld
11092

11193

11294
# For ESP01 - enhanced version
113-
SPI_SIZE = 1M
95+
SPI_SIZE = 4M
96+
SPI_MODE = dio
97+
SPI_SPEED = 80
11498

11599

116100
# Work-around for encoding errors in terminal during ESP boot
117101
COM_OPTS += --raw
118102

119103

104+
# Add the framework to the search path
105+
COMPONENT_SEARCH_DIRS += $(BASEDIR)/framework
106+
107+
120108
# Include main makefile
121-
include $(SMING_HOME)/Makefile-rboot.mk
109+
include $(SMING_HOME)/project.mk
122110

123111

124112
# Write the manifest
125113
all: $(FW_BASE)/version
126114
$(FW_BASE)/version:
127115
echo -n "$(VERSION)" > $(FW_BASE)/version
116+
117+
118+
# Copy to distribution directory
119+
$(DISTDIR):
120+
mkdir -pv $(DISTDIR)
121+
122+
all: $(DISTDIR)/$(DEVICE).rboot
123+
$(DISTDIR)/$(DEVICE).rboot: $(FW_BASE)/rboot.bin $(DISTDIR)
124+
cp -v $(FW_BASE)/rboot.bin $(DISTDIR)/$(DEVICE).rboot
125+
126+
all: $(DISTDIR)/$(DEVICE).rom0
127+
$(DISTDIR)/$(DEVICE).rom0: $(FW_BASE)/rom0.bin $(DISTDIR)
128+
cp -v $(FW_BASE)/rom0.bin $(DISTDIR)/$(DEVICE).rom0
129+
130+
all: $(DISTDIR)/$(DEVICE).rom1
131+
$(DISTDIR)/$(DEVICE).rom1: $(FW_BASE)/rom1.bin $(DISTDIR)
132+
cp -v $(FW_BASE)/rom1.bin $(DISTDIR)/$(DEVICE).rom1
133+
134+
all: $(DISTDIR)/$(DEVICE).version
135+
$(DISTDIR)/$(DEVICE).version: $(FW_BASE)/version $(DISTDIR)
136+
cp -v $(FW_BASE)/version $(DISTDIR)/$(DEVICE).version

framework/features/BME280.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class BME280 : public Feature<name> {
2424

2525
delay(100); // Wait for the sensor to boot up
2626

27-
this->updateTimer.initializeMs(15000, TimerDelegate(&BME280::publishCurrentState, this));
27+
this->updateTimer.initializeMs(15000, std::bind(&BME280::publishCurrentState, this));
2828
this->updateTimer.start(true);
2929
}
3030

0 commit comments

Comments
 (0)