teleplot icon indicating copy to clipboard operation
teleplot copied to clipboard

service discovery - announce _teleplot._udp via mDNS-SD

Open mhaberler opened this issue 2 years ago • 4 comments

planning to add mDNS-SD service announcements so teleplot clients can find a local teleplot server automatically

following this example: https://github.com/mdns-js/node-mdns-js/blob/master/examples/service.js

are you willing to entertain PR's for that?

thanks for the great tool, btw! really appreciated

Michael

ps: any plans to bring up the VSCode teleplot plugin on par with this server in terms of features? seems 3D mode is missing

mhaberler avatar Apr 26 '23 18:04 mhaberler

I do like the idea but have questions on how it will work. Teleplot usage is more oriented toward a local server instance (on 127.0.0.1) , or to a pre-defined 1-to-1 setup.

Advertising a DNS name on the network might confuse two person using teleplot (for their own purpose) while being connected on the same network (like in an office). What we don't want is the telemetry from personA plotted on personB's PC. This concern is true for both privacy, performances and usability reasons.

(ye I do plan to update the VSCode plugin to match recent updates but I didn't dedicated the necessary time yet)

nesnes avatar Apr 28 '23 15:04 nesnes

I do have a working implementation server- and client (Arduino) side, need to clean up before publishing, should be a few days

the way I did it is:

  • server can be started with option mDNS announcement (command line flag)
  • client can explicitly configure a IP:port destination in 'EEPROM'
  • if the latter is unset, client will pick the first mDNS announcement as destination

client can also explicitly browse for announcements, and displays what she discovers you can then pick one from the list to be saved permanently - if you dont, the first announcement will still win

to address your concern, one could disable the 'pick first announcement if not configured explicitly' behavior

this makes the simple case easy and the complicated possible

Michael

mhaberler avatar Apr 28 '23 16:04 mhaberler

this branch has the mDNS announcement

client examples forthcoming

(sorry for the whitespace reformat)

mhaberler avatar May 01 '23 18:05 mhaberler

here's an ESP32 Arduino example which does mDNS discovery:

https://github.com/mhaberler/esp32-imu-baro/blob/master/src/teleplot/arduino.cpp

I did rewrite Teleplot.h into https://github.com/mhaberler/esp32-imu-baro/blob/master/src/teleplot/Teleplot.h massively for embedded use

  • shave off iostream = -300kB code space
  • use fmtlib instead
  • separate instantiation and parameterization Arduino-style with begin_*()
  • make TELEPLOT_ENABLE a runtime flag (enabled_)
  • took out TELEPLOT_USE_FREQUENCY - this is pushing things a bit on an ESP32

the changes were so extensive I dropped the idea of retaining your API - sorry for that

there's a native (in my case MacOS) example here, without service discovery: https://github.com/mhaberler/esp32-imu-baro/blob/master/src/teleplot/native.cpp

what do you think?

mhaberler avatar May 05 '23 07:05 mhaberler