RoboRemo Users' Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Improvement: UDP

3 posters

Go down

Improvement: UDP Empty Improvement: UDP

Post by pgillich Sun May 22, 2016 2:47 pm

Hi,

I'm using Roboremo to control a Lego tank using ESP8266/NodeMCU. The TCP performance of NodeMCU is very limited, I'd like to use UDP, instead of TCP.

Is it possible to contribute to the project to add UDP feature to Roboremo?

pgillich

Posts : 3
Join date : 2016-05-22

Back to top Go down

Improvement: UDP Empty Re: Improvement: UDP

Post by Admin Wed May 25, 2016 4:15 pm

Hi,
I updated the app and added some features including UDP connectivity. It should appear in the Google Play in a few hours. New version should display v1.9.1 in menu -> about.
I tested the UDP connection only with Node-RED, but I hope it will work with ESP too. Please let me know.

All the best,
Victor

Admin
Admin

Posts : 150
Join date : 2016-03-08

https://roboremo.forumotion.com

Back to top Go down

Improvement: UDP Empty Re: Improvement: UDP

Post by juankgp Thu May 26, 2016 6:38 am

Hi, thanks for the update it works with UDP with esp but I have a problem I can send commands to esp usig UDP but I can not obtain the reponse, I sent fom esp an answer but the log does not show anithing
Thanks

juankgp

Posts : 3
Join date : 2016-05-26

Back to top Go down

Improvement: UDP Empty Re: Improvement: UDP

Post by Admin Thu May 26, 2016 11:20 am

Make sure you add "\n" at the end of the string that you are sending.
You can post your ESP code here if you want, and I will take a look.

Admin
Admin

Posts : 150
Join date : 2016-03-08

https://roboremo.forumotion.com

Back to top Go down

Improvement: UDP Empty Re: Improvement: UDP

Post by juankgp Fri May 27, 2016 6:37 am

Thanks for your reply, the par of response of my code is
Code:
port.print("lA ");
port.print(ou1st);
port.println(";");
the lA is the id that I use in roboremo and out1st have 0 or 1 depends of the state, I change the end command for ; in roboremo

Thanks

juankgp

Posts : 3
Join date : 2016-05-26

Back to top Go down

Improvement: UDP Empty Re: Improvement: UDP

Post by Admin Fri May 27, 2016 7:20 am

Hi,
The problem is with println. Use print instead.
This is a common mistake, the println adds "\n" at the end, but you set cmd ending to ";" so the "\n" will go to the beginning of next cmd and RoboRemo will search for item with id "\nIA" instead of "IA".

Admin
Admin

Posts : 150
Join date : 2016-03-08

https://roboremo.forumotion.com

Back to top Go down

Improvement: UDP Empty Re: Improvement: UDP

Post by pgillich Fri May 27, 2016 7:28 am

pgillich wrote:Hi,

I'm using Roboremo to control a Lego tank using ESP8266/NodeMCU. The TCP performance of NodeMCU is very limited, I'd like to use UDP, instead of TCP.

Is it possible to contribute to the project to add UDP feature to Roboremo?

Many thanks for quick development! Smile
I'll check it on this weekend.

pgillich

Posts : 3
Join date : 2016-05-22

Back to top Go down

Improvement: UDP Empty Re: Improvement: UDP

Post by juankgp Fri May 27, 2016 7:42 am

Thanks for your  fast reply I change my code for

Code:

port.print("lA ");
port.print(ou1st);
port.print(";");

and I don´t have response also I put a text log with no id and in the manual said if I don´t put id it shows every commands that arrive but nothing appears

juankgp

Posts : 3
Join date : 2016-05-26

Back to top Go down

Improvement: UDP Empty Re: Improvement: UDP

Post by Admin Mon May 30, 2016 1:06 pm

Is port a net.socket? or net.server?
Does it work with other software, like sending from ESP and receiving in Node-RED or netcat?

Admin
Admin

Posts : 150
Join date : 2016-03-08

https://roboremo.forumotion.com

Back to top Go down

Improvement: UDP Empty Re: Improvement: UDP

Post by Admin Mon May 30, 2016 1:57 pm

I still didn't get it work with NodeMCU and Lua, but here is a working code written in Arudino IDE for ESP:
Code:
// UDP communication between ESP8266 and Android phone with RoboRemo app

// Disclaimer: Don't use RoboRemo for life support systems
// or any other situations where system failure may affect
// user or environmental safety.

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>


// config:

const char *ssid = "mywifi";  // You will connect your phone to this Access Point
const char *pw = "qwerty123"; // and this is the password
IPAddress ip(192, 168, 0, 1); // From RoboRemo app, connect to this IP
IPAddress netmask(255, 255, 255, 0);
const int port = 9876; // and this port
char cmdEnding[] = ";";


WiFiUDP udp;


void setup() {

  delay(1000);

  Serial.begin(115200);

  WiFi.softAPConfig(ip, ip, netmask); // configure ip address for softAP
  WiFi.softAP(ssid, pw); // configure ssid and password for softAP

  udp.begin(port); // start UDP server

  Serial.println("ESP8266 UDP Server");
  Serial.println((String)"SSID: " + ssid + "  PASS: " + pw);
  Serial.println((String)"RoboRemo app must connect to " + ip.toString() + ":" + port);
}


char buf[256]; //buffer for received packets

void loop() {

  // if there’s data available, read a packet
  int packetSize = udp.parsePacket();
  if(packetSize>0) {
    Serial.println((String)"received packet (" + packetSize + " Bytes)");
    Serial.print("from ");
    IPAddress ip = udp.remoteIP();
    Serial.println((String)"" + ip[0] + "." + ip[1]
                        + "." + ip[2] + "." + ip[3]
                        + ":" + port);
 
 
    udp.read(buf, 256);

    // buf contains the cmd received from RoboRemo (including cmd ending)
 
    udp.beginPacket(ip, port); // remote IP and port
    udp.write("dbg ");  // dbg is the id of text log
    udp.write(buf, packetSize);
    udp.endPacket();
  }
}

Admin
Admin

Posts : 150
Join date : 2016-03-08

https://roboremo.forumotion.com

Back to top Go down

Improvement: UDP Empty Re: Improvement: UDP

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum