send command via UDP message
Moderators: grovkillen, Stuntteam, TD-er
-
- New user
- Posts: 4
- Joined: 19 Dec 2018, 08:34
send command via UDP message
Hi guys,
I’m new to ESP Easy and have succesfully flashed my first Sonoff S20 a couple of days ago. Things went pretty good and I can send commands via http get.
However I would rather use UDP to send commands. I activated and configured “UDP Generic”.
I tried to send lots of different UDP messages vial netcat but so far no success. Unfortunately the UDP interface is not documented very well.
Can anybody show me an example on how to send commands via UDP (e.g. something corresponding to http://<espeasyip>/control?cmd=gpio,12,1)
Thanks!
I’m new to ESP Easy and have succesfully flashed my first Sonoff S20 a couple of days ago. Things went pretty good and I can send commands via http get.
However I would rather use UDP to send commands. I activated and configured “UDP Generic”.
I tried to send lots of different UDP messages vial netcat but so far no success. Unfortunately the UDP interface is not documented very well.
Can anybody show me an example on how to send commands via UDP (e.g. something corresponding to http://<espeasyip>/control?cmd=gpio,12,1)
Thanks!
Re: send command via UDP message
I think I have a device which sends UDP Messages, I can look later at work if this is correct.
-
- New user
- Posts: 4
- Joined: 19 Dec 2018, 08:34
Re: send command via UDP message
That would be great. Just so there is no misunderstanding I can have the ESP Easy Unit send messages just fine via rules (e.g. SendToUDP 192.168.1.8,5128,Relay_State:[Relay#Switch])
I just can’t control it.
I just can’t control it.
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: send command via UDP message
Code: Select all
SendTo,<unit nr>,<command>
Command syntax is just like any other command.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
-
- New user
- Posts: 4
- Joined: 19 Dec 2018, 08:34
Re: send command via UDP message
For example I send the following from my linux machine:
192.168.1.22 is the IP of the Easy ESP unit and 5700 the port specified in the Generic UDP controller.
This does nothing unfortunately.
Code: Select all
echo "SendTo,1,gpio,12,1" | nc -u -c 192.168.1.22 5700
This does nothing unfortunately.
Re: send command via UDP message
Because of my Message Bus project, i happen to know more about the UDP protocol used in ESP Easy.
The controller is only used to send data.
But ESP Easy listens to UDP if a port is set in advanced settings.
Look at this code in networking.ino:
You can just send any string to the IP and port of that ESP Easy unit and it should process it.
The controller is only used to send data.
But ESP Easy listens to UDP if a port is set in advanced settings.
Look at this code in networking.ino:
Code: Select all
if (!PluginCall(PLUGIN_WRITE, &TempEvent, request))
ExecuteCommand(VALUE_SOURCE_SYSTEM, &packetBuffer[0]);
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: send command via UDP message
Try using the command line in tools.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
-
- New user
- Posts: 4
- Joined: 19 Dec 2018, 08:34
Re: send command via UDP message
Again - do not want to send commands between 2 ESPs. I want to send commands from my computer (home automation) to the ESP via UDP.
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: send command via UDP message
But, the command is P2P for ESP2ESP...Swallowtail wrote: ↑19 Dec 2018, 15:31 Again - do not want to send commands between 2 ESPs. I want to send commands from my computer (home automation) to the ESP via UDP.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: send command via UDP message
I think you can send a simple UDP package to the ESP, _if you know the target's IP address_, to the port, that you have set in Tools/Advanced settings. But i do not see why it is better, than sending by a HTTP command? (the ESPEasy devices advertises itself and knew each other IP address by UDP broadcasting, this is how P2P works)Swallowtail wrote: ↑19 Dec 2018, 15:31 Again - do not want to send commands between 2 ESPs. I want to send commands from my computer (home automation) to the ESP via UDP.
Anyway the UDP package only needs to contain the command - as a zero terminated string - and the netcat utility can be used to send it.
Re: send command via UDP message
Maybe it will change in the soon future.. i am currently trying to understand the ESPEasy P2P Networking packages and i found this structure:grovkillen wrote: ↑19 Dec 2018, 16:39But, the command is P2P for ESP2ESP...Swallowtail wrote: ↑19 Dec 2018, 15:31 Again - do not want to send commands between 2 ESPs. I want to send commands from my computer (home automation) to the ESP via UDP.
Code: Select all
struct C013_SensorDataStruct
{
byte header = 255;
byte ID = 5;
byte sourcelUnit;
byte destUnit;
byte sourceTaskIndex;
byte destTaskIndex;
float Values[VARS_PER_TASK];
};
Code: Select all
SENSORDATA RAW b'\xff\x05\x00\x01\x05\x05\x00\x00\x00\x00\x80?\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@'
SENSORDATA UNPACKED (255, 5, 0, 1, 5, 5, 0, 0, 1.0, 0.0, 0.0, 2.0)
Re: send command via UDP message
The current implementation of the P2P protocol is documented:
https://espeasy.readthedocs.io/en/lates ... /C013.html
Yes it will change, but the change will be an addition. It will still be backwards compatible with existing protocol.
Later I will add an option to disable the "old" (current) p2p implementation, since there is no security at all in the current protocol.
https://espeasy.readthedocs.io/en/lates ... /C013.html
Yes it will change, but the change will be an addition. It will still be backwards compatible with existing protocol.
Later I will add an option to disable the "old" (current) p2p implementation, since there is no security at all in the current protocol.
Re: send command via UDP message
Thank you, i see.TD-er wrote: ↑19 Dec 2018, 19:37 The current implementation of the P2P protocol is documented:
https://espeasy.readthedocs.io/en/lates ... /C013.html
Yes it will change, but the change will be an addition. It will still be backwards compatible with existing protocol.
Later I will add an option to disable the "old" (current) p2p implementation, since there is no security at all in the current protocol.
How can i get a NodeTypeID for my "RPI Easy" project? For example 129 is usable? Or do you have any plan on further NodeTypes or any logic behind the numbering scheme?
1 = “ESP Easy” b00000001
17 = “ESP Easy Mega” b00010001
33 = “ESP Easy 32” b00100001
65 = “Arduino Easy” b01000001
81 = “Nano Easy b01010001
Re: send command via UDP message
I don't know the number-schema.
I just documented it.
Looks like somebody was thinking about some simple mask to maybe send messages to some types and exclude others.
But then the "Nano Easy" is a bit (pun intended) strange.
I would say 9 and 5 are also still available
Maybe 129 could cause issues if some implementation is using an int8 instead of a uint8.
I just documented it.
Looks like somebody was thinking about some simple mask to maybe send messages to some types and exclude others.
But then the "Nano Easy" is a bit (pun intended) strange.
I would say 9 and 5 are also still available
Maybe 129 could cause issues if some implementation is using an int8 instead of a uint8.
Re: send command via UDP message
Hello TD-erTD-er wrote: ↑19 Dec 2018, 19:37 The current implementation of the P2P protocol is documented:
https://espeasy.readthedocs.io/en/lates ... /C013.html
Yes it will change, but the change will be an addition. It will still be backwards compatible with existing protocol.
Later I will add an option to disable the "old" (current) p2p implementation, since there is no security at all in the current protocol.
Nice to have this level of documentation. I didn't know that this was available. I had to reverse engineer the code to figure out the internal protocol.
I've also tried to think of a more enhanced package structure for the UDP protocol, but in the end i thought that the "topic" concept of MQTT would be more than sufficient to build a sensor/actuator/controller network. I'm currently working on my personal message bus, based on simple UDP text messages.
I have recently started to use several repositories from letscontrolit.com and converted those to support the UPD text messaging. I can't tell if it's really stable on this short term, but it is running on following platforms at the moment in my mini test setup:
- Arduino Nano with ENC28J60 ethernet shield
- Arduino Mega 2560 with W5100 ethernet shield
- ESP8266 with ESP Easy and MessageBus plugin
- ESP8266 with Core edition
- ESP32 with Core edition
- Windows 10 with C# edition of the ESP rule engine
Messaging is simple topic based single values like:
Code: Select all
Outdoor/Temperature=8.5
Outdoor/Lux=23500
HueGW/Hallway/Motion=1
Code: Select all
MSGBUS/Hostname=xxxxx
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: send command via UDP message
The concept of a headless system is 100% within our projection of the project. So these inputs are really nice to see. Thanks!
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: send command via UDP message
Using an udp send tool on my Windows PC:Swallowtail wrote: ↑19 Dec 2018, 08:42 Hi guys,
I’m new to ESP Easy and have succesfully flashed my first Sonoff S20 a couple of days ago. Things went pretty good and I can send commands via http get.
However I would rather use UDP to send commands. I activated and configured “UDP Generic”.
I tried to send lots of different UDP messages vial netcat but so far no success. Unfortunately the UDP interface is not documented very well.
Can anybody show me an example on how to send commands via UDP (e.g. something corresponding to http://<espeasyip>/control?cmd=gpio,12,1)
Thanks!
Code: Select all
udpsend 192.168.0.118 65500 reboot
Re: send command via UDP message
Doesn't "headless" mainly refer to systems without monitor/keyb/mouse?grovkillen wrote: ↑20 Dec 2018, 08:14 The concept of a headless system is 100% within our projection of the project. So these inputs are really nice to see. Thanks!
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: send command via UDP message
True, but in my analogy I mean controller-lessFanOfHue wrote: ↑20 Dec 2018, 11:00Doesn't "headless" mainly refer to systems without monitor/keyb/mouse?grovkillen wrote: ↑20 Dec 2018, 08:14 The concept of a headless system is 100% within our projection of the project. So these inputs are really nice to see. Thanks!
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: send command via UDP message
I see, then we are on the same track.
I've been working with Arduino microcontrollers for quite some time and build up a nice collection of hardware that is still in use around the house. I could start to replace them all with ESP32 but that would be the easy way out. These Arduino boards have served me well for many years and do not deserve to be tossed into the bin without good reason. Never had any controller in use.
I have a garden shed, UTP connected and out of Wifi range that uses an Arduino Nano with an ENC26J80 ethernet shield with a simple http sketch. I actually lost that particular source code so i was thinking of a way to integrate ESP Easy with other nodes to have some sort of message bus controlled environment.
I noticed that a NanoEasy sketch already existed on LetsControlIt github so i used that a starting point. The current NanoEasy does not support a rule engine so i implemented a tiny one. It was a real challenge to get things going into 32k of progmem and 2k of RAM but it's currently running with my Message Bus support and a core web interface with two rule based control buttons:
boot.txt:
rules.txt
All powered by Arduino Nano and ENC26J80!
I've been working with Arduino microcontrollers for quite some time and build up a nice collection of hardware that is still in use around the house. I could start to replace them all with ESP32 but that would be the easy way out. These Arduino boards have served me well for many years and do not deserve to be tossed into the bin without good reason. Never had any controller in use.
I have a garden shed, UTP connected and out of Wifi range that uses an Arduino Nano with an ENC26J80 ethernet shield with a simple http sketch. I actually lost that particular source code so i was thinking of a way to integrate ESP Easy with other nodes to have some sort of message bus controlled environment.
I noticed that a NanoEasy sketch already existed on LetsControlIt github so i used that a starting point. The current NanoEasy does not support a rule engine so i implemented a tiny one. It was a real challenge to get things going into 32k of progmem and 2k of RAM but it's currently running with my Message Bus support and a core web interface with two rule based control buttons:
boot.txt:
Code: Select all
on System#Config do
config,debug,1
config,mac,123
config,network,192.168.0.254
config,name,_NanoCore
config,port,65501
endon
Code: Select all
on System#Boot do
valueSet s,0,0
endon
on D_ON do
gpio 7,1
gpioState s,7
msgbus Shed/Light=1
endon
on D_OFF do
gpio 7,0
gpioState s,7
msgbus Shed/Light=0
endon
on System#Web do
webPrint <h1>Power %s%</h1>
webButton button-link;/control?cmd=event,D_ON;On
webButton button-link;/control?cmd=event,D_OFF;Off
endon
Re: send command via UDP message
Thank you, can i claim for "5" to RPIEasy?TD-er wrote: ↑19 Dec 2018, 21:31 I don't know the number-schema.
I just documented it.
Looks like somebody was thinking about some simple mask to maybe send messages to some types and exclude others.
But then the "Nano Easy" is a bit (pun intended) strange.
I would say 9 and 5 are also still available
Maybe 129 could cause issues if some implementation is using an int8 instead of a uint8.
Code: Select all
NODE_TYPE_ID_RPI_EASY_STD = 5
Who is online
Users browsing this forum: No registered users and 11 guests