-->
Page 1 of 1

Newbe question - transparent uart proxy

PostPosted: Fri Jan 22, 2016 2:44 am
by espTroll
Hello everybody.

I'm a new guy in esp8266 programming and hope to community support in my project.

The general idea is I have a uart link between two uC (RX pin -> TX pin) This link should be extended via WiFi.
Now I have two esp8266 modules.

1. The first esp8266 is connected to source uC (uC RX pin -> esp8622 TX pin) This esp works as AP and flashed by esp-link firmware. As I see this works as expected. It takes data from uC RX pin and transfers via WiFi. It is possible to telnet 192.168.4.1 23 port and see bytes coming.

2. The question is about 2nd esp8266. This one should connects to 1st esp, receives data and put to his RX pin. Then I'll connect destination uC and links will work as designed.

Please advice what firmware I could use for #2?
Any ides would be welcome :-)

Thanks!

Re: Newbe question - transparent uart proxy

PostPosted: Fri Jan 22, 2016 3:26 pm
by espTroll
Seems it is solved by my own programming.
I'm using broadcast UDP transmitting in the loop:
Code: Select allvoid loop()
{
  // has data - add to packet
  if (Serial.available()) {
    g_udp.write(Serial.read());
    cnt ++;
  }
 
  if (cnt >= PACKAGE_SIZE) {
    // transmit package
    g_udp.endPacket();
    cnt = 0;

    // start new package
    g_udp.beginPacket(ip, g_port);
  }
}


Also in receiving part I'm just doing direct reading-writing:
Code: Select allvoid loop() {
  int noBytes = g_udp.parsePacket();
  if ( noBytes ) {
    g_udp.read(packetBuffer,noBytes); // read the packet into the buffer

    Serial.write(packetBuffer, noBytes);
  }
}


This works fine for me.