Closed SpaekEasy closed 5 years ago
Hi @SpaekEasy ,
thanks for checking out my library. Open Sound Control (OSC) is a uni-directional protocol, i.e. the client only sends data to the server, not the other way round. To send information both ways, both sides have to act as a client, and a server. I.e. in you case, the ESP32 board needs to run a server too to receive information via OSC. The library has some code to implement a server and some simple examples for doing so, but in an embedded, non-multitasking environment as MicroPython, extra steps need to be taken, so that other things can be done while the server is running, e.g. using asyncio. This is beyond the scope of this library at the moment, I'm afraid.
You'll have to decide whether OSC is the right protocol for your application under these circumstances. Alternatives would be MQTT (works best with a permanent connection) or Redis, for example.
Hello ! Thank for taking time to anwser and give me those advises.
Agree with you about the multitask problems. I use for an other application MQTT protocol and it's working fine, but will I be able to get the data in Unity if send them with MQTT ? I am not forced to use OSC to receive data via Wi-Fi in Unity right ?
Best regards
Envoyé depuis mon smartphone Samsung Galaxy.
-------- Message d'origine -------- De : Christopher Arndt notifications@github.com Date : 17/03/2018 14:43 (GMT+01:00) À : SpotlightKid/micropython-osc micropython-osc@noreply.github.com Cc : SpaekEasy douki.idir@hotmail.fr, Mention mention@noreply.github.com Objet : Re: [SpotlightKid/micropython-osc] Issue with getting data from (#2)
Hi @SpaekEasyhttps://github.com/spaekeasy ,
thanks for checking out my library. Open Sound Control (OSC) is a uni-directional protocol, i.e. the client only sends data to the server, not the other way round. To send information both ways, both sides have to act as a client, and a server. I.e. in you case, the ESP32 board needs to run a server too to receive information via OSC. The library has some code to implement a server and some simple examples for doing so, but in an embedded, non-multitasking environment as MicroPython, extra steps need to be taken, so that other things can be done while the server is running, e.g. using asyncio. This is beyond the scope of this library at the moment, I'm afraid.
You'll have to decide whether OSC is the right protocol for your application under these circumstances. Alternatives would be MQTT (works best with a permanent connection) or Redis, for example.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/SpotlightKid/micropython-osc/issues/2#issuecomment-373921090, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ATrH9VmztjTsgEzCgDUXYve3pDMHiza9ks5tfRMNgaJpZM4SuubJ.
For MQTT you need to run an MQTT broker on the receiving machine. This acts as the central server for all MQTT clients.
I don't know much about unity, but I suspect it doesn't have a MQTT broker built-in (these are usually stand-alone server programs). Maybe it has an MQTT client implementation, though. Then you could have your ESP post messages to an MQTT topic and from the Unity client subscribe to that topic to receive them.
Or you can use an MQTT-to-OSC bridge, that relays messages sent to an MQTT topic to an OSC server and vice-versa. Incidentally, I wrote such a bridge: https://github.com/SpotlightKid/osc2mqtt
The downside for both solutions is that you have to run an extra server, the MQTT broker and possibly the MQTT-to-OSC bridge.
May I ask what you use case is? Which kind of data are you sending into Unity and what do you want to send back?
I use ESP32 to interface some sensors and I send the data of sensors to a Unity were a VR game is running.
The goal is to make an interactive VR game with real external sensors. And it will be great if for example I get data from the game to the ESP32 to make blink Led for example.
Envoyé depuis mon smartphone Samsung Galaxy.
-------- Message d'origine -------- De : Christopher Arndt notifications@github.com Date : 17/03/2018 16:00 (GMT+01:00) À : SpotlightKid/micropython-osc micropython-osc@noreply.github.com Cc : SpaekEasy douki.idir@hotmail.fr, Mention mention@noreply.github.com Objet : Re: [SpotlightKid/micropython-osc] Issue with getting data from (#2)
May I ask what you use case is? Which kind of data are you sending into Unity and what do you want to send back?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/SpotlightKid/micropython-osc/issues/2#issuecomment-373926476, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ATrH9ShJ8MfrvyBrBjHiqfedgM2KbKXkks5tfST6gaJpZM4SuubJ.
I think your best option is to implement an OSC server on your ESP using asyncio. Please see this example:
https://github.com/SpotlightKid/micropython-osc/blob/master/examples/async_server.py
This could certainly be improved, for example there are still places in the code that potentially block and shouldn't (e.g. line 24), but it works in principle. Taking this example, you would replace the serve
coroutine with your own implementation, calling handle_osc
to decode the OSC message and passing it a function that handles the decoded OSC message.
Very interesting! i made some researche on Asyncio and it looks like a good solution for my application. Except that it's need to be used with Python 3.4 or 3.5... but i work for my application with python 2.7.
Do i need to make a portage of the library ?
I was talking about using asyncio (uasyncio) with MicroPython on the ESP, not with Python on the PC.
See a tutorial here: https://github.com/peterhinch/micropython-async/blob/master/TUTORIAL.md
The micropython-osc library should already work with Python 2.7.
Closing this due to no further feedback / questions.
Hello,
I use you library with an ESP32 and a PC. I use Micropython to program the ESP32 and i try to send data to a computer with thins kind of commands ;
osc = Client(IP_SERVER, PORT_SERVER) osc.send('example', example)
Simple and work fine.
But is it possible to get data from PC to my ESP32 ? i can't find in your code how to get data ?
Thank for your help