P2P react on SendTo Errors?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Psi
New user
Posts: 5
Joined: 07 Jan 2020, 16:20

P2P react on SendTo Errors?

#1 Post by Psi » 07 Jan 2020, 16:26

Hi,

I've flashed

Code: Select all

INIT : Booting version: mega-20191208 (ESP82xx Core bc204a9b, NONOS SDK 2.2.2-dev(38a443e), LWIP: 2.1.2 PUYA support)
and set-up a p2p network with two devices.
One has ha simple button and the other one a LED.

I made a Rule on Device 1 with

Code: Select all

SendTo,2,"LongPulse,14,1,10"
to Device 2. This works great but I would do some alerting if the command failes (ie device 2 is not available). Is this possible?

Thanks!

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: P2P react on SendTo Errors?

#2 Post by TD-er » 07 Jan 2020, 16:29

Right now it is not possible, but it sounds like a useful feature.
Can you add it as a feature request on Github?

Psi
New user
Posts: 5
Joined: 07 Jan 2020, 16:20

Re: P2P react on SendTo Errors?

#3 Post by Psi » 07 Jan 2020, 16:42

Of course I can but it would make sense to implement general error handling dosnt it?
So if I `SendToHTTP` and get an network error or a falsy response code like 404 it should also be a way to handle this.

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: P2P react on SendTo Errors?

#4 Post by TD-er » 07 Jan 2020, 17:08

Sure it does make sense, but since we currently have no error handling for commands, it may be a big change.

Psi
New user
Posts: 5
Joined: 07 Jan 2020, 16:20

Re: P2P react on SendTo Errors?

#5 Post by Psi » 07 Jan 2020, 17:19

Yay, I see this is not very trivial.

Is there a little how-to for implementation of a "rule" in C so I could use the cool espeasy features and have the freedom of using native code?

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: P2P react on SendTo Errors?

#6 Post by TD-er » 07 Jan 2020, 23:02

We use C++, not C
and currently a command does not have a boolean like return value, which has to be changed first.
I think it is also way too complicated to make rules where statements will be wrapped in "if ... then ... else" like checks.
So maybe a failing command should be considered as like throwing an exception (exiting the rules block) and generating an event indicating an previous event handler failed.

Then you can just ignore that part, or act on it.
But for a rules block you should also add a flag that a failing command should end the execution of the current rules block. (thus analog to throwing an exception)

Psi
New user
Posts: 5
Joined: 07 Jan 2020, 16:20

Re: P2P react on SendTo Errors?

#7 Post by Psi » 07 Jan 2020, 23:15

Yes I see it's nothing one can implement in a hurry.

But for now I'm searching for a way to extend the business logic myself.
Seems a custom command could be used for that so instead of doing a SendTo I could call MySendToFn.

I've found some other requests on how to "precompile" rules / write own ones in cpp. Some little examples would be very helpful.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 40 guests