Best practices for controlling pybd wirelessly?
Posted: Sat Feb 06, 2021 1:15 am
I have a pybd (D series) which I have embedded in a home-build project that manages certain home automation tasks.
It was no trouble to connect it to the house wifi, and when my device senses that certain events have happened, it cheerfully uses urequests to send data to web servers which can log those reports etc. Getting data wirelessly off the pybd therefore seems trivial.
However it is not clear to me what the best way of sending to the pybd is.
I know I could write a polling routine on the pybd that pings a web-server somewhere every 10 seconds to ask if there are waiting commands which it should process, but this seems HUGELY wasteful to me. I am sure there must be 100 proper ways of avoiding polling .... but I don't really know what they are.
If my pybd had a publicly reachable IP address I might look into seeing how I would write something that listened on some socket or other for a connection .... but on a home system behind multiple layers of NAT and not having the patience to work out how to push things through the NAT I presume that I don't want to go there -- and I don't have much experience of sockets anyway.
Is there some kind of off-the-shelf pyhon library for pushing notifications to a pybd whose details I won't have to fully understand, save for knowing that I can register some kind of callback that will fire when a message comes in ?
It was no trouble to connect it to the house wifi, and when my device senses that certain events have happened, it cheerfully uses urequests to send data to web servers which can log those reports etc. Getting data wirelessly off the pybd therefore seems trivial.
However it is not clear to me what the best way of sending to the pybd is.
I know I could write a polling routine on the pybd that pings a web-server somewhere every 10 seconds to ask if there are waiting commands which it should process, but this seems HUGELY wasteful to me. I am sure there must be 100 proper ways of avoiding polling .... but I don't really know what they are.
If my pybd had a publicly reachable IP address I might look into seeing how I would write something that listened on some socket or other for a connection .... but on a home system behind multiple layers of NAT and not having the patience to work out how to push things through the NAT I presume that I don't want to go there -- and I don't have much experience of sockets anyway.
Is there some kind of off-the-shelf pyhon library for pushing notifications to a pybd whose details I won't have to fully understand, save for knowing that I can register some kind of callback that will fire when a message comes in ?