Skip to content

Commit

Permalink
release R2301
Browse files Browse the repository at this point in the history
  • Loading branch information
maierkomor committed Feb 1, 2023
1 parent 1a9a9e0 commit 55b1628
Show file tree
Hide file tree
Showing 110 changed files with 9,110 additions and 3,481 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.5)
#execute_process(COMMAND bin/prebuild.sh)
add_compile_definitions(ESP$ENV{ESP_FAM})
add_compile_definitions(IDF_VERSION=$ENV{IDF_VERSION})
add_compile_definitions(FWCFG="$ENV{FWCFG}")
#set(FWCFG $ENV{FWCFG}) # ignored - for whatever reason...

#add_compile_definitions(FWCFG="$ENV{FWCFG}")
set(PROJECT_VER $ENV{VER}) # ignored - for whatever reason...
set(INCLUDE_DIRS components/logging drv/dht drv/bme280 drv/ws8212b)
set(EXTRA_COMPONENT_DIRS drv/button drv/dht drv/display drv/hc-sr04
Expand Down
14 changes: 14 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
R2301:
======
- Lua integration enhancements
- fix for cyclic interval timing on ESP32-xx
- fix for ESP8266 GPIO handling with IO-expander
- fix WS2812B always using channel 0
- updates for atriumcfg tool
- added Lua support for ADC
- added WS2812b multi-bus support
- added TCA9555 driver (IO-expander, DEVEL/alpha-state, untested yet)
- fix for argument event handling
- support ADC digital to physical conversion on ESP32*
- added OTA server config for simplified updates

R2212:
======
- added action gpio!set for more flexible gpio operation
Expand Down
2 changes: 1 addition & 1 deletion Makefile.gmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ ROMFS_FILE =$(ROMFS_LST:%.lst=%.romfs)
ROMFS_FILES =$(shell cat $(ROMFS_LST) 2>/dev/null)
ROMFS_ADDR =$(CONFIG_ROMFS_ADDR)
IDF_VER :=$(shell cd $(IDF_PATH); git describe --tags 2>/dev/null | sed 's/\.//;s/v//;s/-.*//;s/\..*//')
CPPFLAGS =-DIDF_VERSION=$(IDF_VER) -D$(CHIP) -I$(BUILD_DIR_BASE)/config
CPPFLAGS =-DIDF_VERSION=$(IDF_VER) -D$(CHIP) -DFWCFG=\"$(PROJECT)\" -I$(BUILD_DIR_BASE)/config
BUILD_DIR_BASE =$(PWD)/build.$(PROJECT)
PROJECT_ROOT =$(PWD)
WFCINC =$(WFCDIR)/include
Expand Down
32 changes: 30 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,8 @@ make bin/atriumcfg
bin/atriumcfg
```

Over-the-Air update:
====================
Over-the-Air (OTA) updates:
===========================
To build binaries for an OTA update, you have to build your project with target `ota` for ESP8266 to get binaries for the approrpiate partitions. For ESP32 all binaries can be used for any patition with OTA updates.
```
make PROJECT=<projectname> ota
Expand Down Expand Up @@ -710,6 +710,34 @@ restore the old configuration using:
config restore
```

OTA server:
-----------
An OTA server should provide firmware images via HTTP at the specified
location. Additionally, the OTA server can be set via in the `otasrv`
config setting, which simplifies the ota update command. If the `otasrv`
variable is set the update command only needs the version, you intend to
update to, and the update command will the pick the coorect file for the
relevant partition ($ext) and firmware configuration (project name,
$fwcfg) as follow:

```
$otasrv/$fwcfg/atrium-$version.$ext
```

The `otasrv` setting should be of the format: `http://server/path`.
Below should be a subdirectory for the relevant firmware/project
configuration, which in turn includes the firmware file named
`atrium-<version>.<ext>`. The extension part is for ESP32 devices
always `.bin`, as the firmware can be stored on any partition. For
ESP8266 family, the filename extension must match the partition name, as
it needs to be linked with the correct addresses.

To use this, the update command should be executed with the option `-v`
and the relevant version name:
```
update -v <version>
```


Interface Stability:
--------------------
Expand Down
Binary file added cfg/rgbcct.cfg
Binary file not shown.
4 changes: 4 additions & 0 deletions cfg/shelly1.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
��T��
sw
�
relay
54 changes: 22 additions & 32 deletions components/actions/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ static event_t ActionTriggerEvt = 0;

Action::Action(const char *n)
: name(n)
, ev(0)
, func(0)
{
// log_dbug(TAG,"Action(%s)",n);
Expand All @@ -65,12 +64,10 @@ Action::Action(const char *n)
Action::Action(const char *n, void (*f)(void*),void *a, const char *t)
: name(n)
, text(t)
, ev(event_register("*trigger`",n))
, func(f)
, arg(a)
{
// log_dbug(TAG,"Action(%s,...)",n);
event_callback(ev,this);
}


Expand Down Expand Up @@ -156,33 +153,14 @@ int action_activate_arg(const char *name, void *arg)
}


int action_dispatch(const char *n, size_t l)
void action_dispatch(const char *name, size_t l)
{
if (l == 0)
l = strlen(n);
size_t nl = l;
const char *e = strchr(n,' ');
if (e)
nl = e-n;
char name[nl+1]; // temporary for search
name[nl] = 0;
memcpy(name,n,nl);
Action *a = action_get(name);
if (a == 0) {
log_warn(TAG,"dispatch unknown '%s'",name);
return 1;
}
log_dbug(TAG,"dispatch %s",name);
char *arg = 0;
if (e) {
size_t al = l - nl;
arg = (char *) malloc(al);
--al;
memcpy(arg,e+1,al);
arg[al] = 0;
}
event_trigger_arg(a->ev,arg);
return 0;
l = strlen(name);
char *arg = (char *) malloc(l+1);
arg[l] = 0;
memcpy(arg,name,l);
event_trigger_arg(ActionTriggerEvt,arg);
}


Expand All @@ -196,10 +174,22 @@ void action_iterate(void (*f)(void*,const Action *),void *p)

static void action_event_cb(void *arg)
{
Action *a = (Action *)arg;
assert(a);
log_dbug(TAG,"action %s",a->name);
a->activate();
const char *as = (const char *)arg;
size_t al = strlen(as);
char tmp[al+1];
memcpy(tmp,as,sizeof(tmp));
char *sp = strchr(tmp,' ');
if (sp) {
*sp = 0;
++sp;
}
Action *a = action_get(tmp);
if (a == 0) {
log_warn(TAG,"request to execute non-existing action %s",tmp);
} else {
log_dbug(TAG,"action %s",a->name);
a->activate(sp);
}
}


Expand Down
3 changes: 1 addition & 2 deletions components/actions/actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class Action
const char *name;
const char *text = 0; // descriptive help text
uint32_t min = UINT32_MAX, max = 0, sum = 0, num = 0;
unsigned ev;

Action(const char *n, void (*f)(void*),void *a, const char *t);
Action(const char *n);
Expand All @@ -52,7 +51,7 @@ const char *action_text(const char *name);
Action *action_get(const char *name);
int action_activate(const char *name);
int action_activate_arg(const char *name, void *arg);
int action_dispatch(const char *name, size_t l); // execute action via event queue
void action_dispatch(const char *name, size_t l); // execute action via event queue
int action_exists(const char *name);
void action_iterate(void (*)(void*,const Action *),void *);
void actions_setup();
Expand Down
2 changes: 1 addition & 1 deletion components/env/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ class EnvString : public EnvElement
{
public:
EnvString(const char *name, const char *v, const char *dim = 0);
~EnvString(); // deletion is not supported

EnvString *toString()
{ return this; }
Expand All @@ -188,7 +189,6 @@ class EnvString : public EnvElement
{ return m_value; }

private:
~EnvString(); // deletion is not supported
EnvString(const EnvString &);
EnvString &operator = (const EnvString &);
char *m_value;
Expand Down
64 changes: 38 additions & 26 deletions components/event/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ using namespace std;

struct Event {
event_t id;
void *arg;
void *arg = 0;
Event(event_t i = 0, void *a = 0)
: id(i)
, arg(a)
{ }
};


Expand Down Expand Up @@ -141,8 +145,10 @@ int event_trigger_en(trigger_t t, bool en)
{
event_t e = t >> 16;
uint16_t c = t;
if ((e == 0) || (e >= EventHandlers.size()) || (c >= EventHandlers[e].callbacks.size()))
if ((e == 0) || (e >= EventHandlers.size()) || (c >= EventHandlers[e].callbacks.size())) {
log_warn(TAG,"cannot %sable event %d",en?"en":"dis",t);
return 1;
}
EventHandlers[e].callbacks[c].enabled = en;
return 0;
}
Expand All @@ -152,10 +158,15 @@ trigger_t event_callback(const char *event, const char *action)
{
const char *x = 0;
if (event_t e = event_id(event)) {
if (Action *a = action_get(action))
if (const char *sp = strchr(action,' ')) {
++sp;
char tmp[sp-action];
memcpy(tmp,action,sizeof(tmp));
if (Action *a = action_get(tmp))
return event_callback_arg(e,a,strdup(sp));
} else if (Action *a = action_get(action))
return event_callback(e,a);
else
x = action;
x = action;
} else {
x = event;
}
Expand All @@ -175,7 +186,6 @@ trigger_t event_callback_arg(const char *event, const char *action, const char *
} else {
x = event;
}
assert(x);
log_warn(TAG,"callback arg invalid %s",x);
return 0;
}
Expand Down Expand Up @@ -255,7 +265,7 @@ void event_trigger(event_t id)
log_warn(TAG,"trigger 0");
return;
}
struct Event e = {id,0};
Event e(id);
BaseType_t r = xQueueSend(EventsQ,&e,1000);
if (r != pdTRUE) {
log_dbug(TAG,"lost event %d",id);
Expand All @@ -267,7 +277,7 @@ void event_trigger(event_t id)

void event_trigger_nd(event_t id) // no-debug version for syslog only
{
struct Event e = {id,0};
Event e(id);
BaseType_t r = xQueueSend(EventsQ,&e,1000);
if (r != pdTRUE)
++Lost;
Expand All @@ -276,34 +286,37 @@ void event_trigger_nd(event_t id) // no-debug version for syslog only

void event_trigger_arg(event_t id, void *arg)
{
assert(id != 0);
struct Event e = {id,arg};
log_dbug(TAG,"trigger %d %p",id,arg);
BaseType_t r = xQueueSend(EventsQ,&e,1000);
if (r != pdTRUE)
++Lost;
if (id != 0) {
Event e(id,arg);
log_dbug(TAG,"trigger %d %p",id,arg);
BaseType_t r = xQueueSend(EventsQ,&e,1000);
if (r != pdTRUE)
++Lost;
}
}


void event_isr_trigger(event_t id)
{
// ! don't log from ISR
assert(id != 0);
Event e = {id,0};
BaseType_t r = xQueueSendFromISR(EventsQ,&e,0);
if (r != pdTRUE)
++Lost;
if (id != 0) {
Event e(id);
BaseType_t r = xQueueSendFromISR(EventsQ,&e,0);
if (r != pdTRUE)
++Lost;
}
}


void event_isr_trigger_arg(event_t id,void *arg)
void event_isr_trigger_arg(event_t id, void *arg)
{
// ! don't log from ISR
assert(id != 0);
Event e = {id,arg};
BaseType_t r = xQueueSendFromISR(EventsQ,&e,0);
if (r != pdTRUE)
++Lost;
if (id != 0) {
Event e(id,arg);
BaseType_t r = xQueueSendFromISR(EventsQ,&e,0);
if (r != pdTRUE)
++Lost;
}
}


Expand All @@ -321,7 +334,6 @@ static void event_task(void *)
#endif
for (;;) {
Event e;
e.id = 0;
BaseType_t r = xQueueReceive(EventsQ,&e,dt);
if (Lost) {
log_warn(TAG,"lost %u events",(unsigned)Lost);
Expand Down
4 changes: 4 additions & 0 deletions components/event/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ void event_init(void);
int event_trigger_en(trigger_t t, bool en);
void event_trigger(event_t e);
void event_trigger_nd(event_t id); // no-debug version for syslog only

// Argument must be malloc()'ed by the caller.
// It will be free()'ed by the event infrastructure, because their might
// be != 1 event consumers...
void event_trigger_arg(event_t e, void *);
void event_isr_trigger(event_t e);
void event_isr_trigger_arg(event_t e, void *);
Expand Down
2 changes: 1 addition & 1 deletion components/logging/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
#register_component()
idf_component_register(
SRCS logging.c modules.c profiling.cpp xlog.cpp
REQUIRES tinyusb netsvc streams term
REQUIRES tinyusb netsvc streams term main
INCLUDE_DIRS .
)
2 changes: 1 addition & 1 deletion components/logging/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void log_common(log_level_t l, logmod_t m, const char *f, va_list val)
buf[s++] = '\n';
if (LogUart >= 0) {
if (pdTRUE != xSemaphoreTake(UartLock,MUTEX_ABORT_TIMEOUT))
abort_on_mutex(UartLock,__FILE__);
abort_on_mutex(UartLock,__BASE_FILE__);
uart_write_bytes((uart_port_t)LogUart,buf,s);
if (l <= ll_warn)
uart_wait_tx_done((uart_port_t)LogUart,portMAX_DELAY);
Expand Down
Loading

0 comments on commit 55b1628

Please sign in to comment.