B4R Question How to setup Wemos D1 R2 as server?

Discussion in 'B4R Questions' started by rbghongade, Aug 3, 2016.

  1. rbghongade

    rbghongade Active Member Licensed User

    Dear Erel and friends,
    I received my Wemos D1 R2 yesterday. Tried example in " getting started" worked great. Now I want to setup a server on Wemos board and acquire analog input from A0 pin, then send it to a client on Android (B4A). Tried using topic info at https://www.b4x.com/android/forum/threads/esp8266-connect-as-server-to-b4a-solved.69547/ but am getting nowhere.
    It would be great if you guys create a step by step tutorial for the same.
    regards,
     
    Tayfur likes this.
  2. Erel

    Erel Administrator Staff Member Licensed User

    upload_2016-8-3_16-1-27.png

    A complete example is attached.
     

    Attached Files:

    Tayfur and rbghongade like this.
  3. rbghongade

    rbghongade Active Member Licensed User

    Dear Erel,
    Thanks for the solution. Can I do the same with B4J instead of B4A? Please point me to the correct library for B4J.
    warm regards,
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Yes. Should be simple. Same libraries as in B4A (jRandomAccessFile and jNetwork).
     
    rbghongade likes this.
  5. rbghongade

    rbghongade Active Member Licensed User

    Dear Erel,
    I could do it quickly! Thanks. Works great, but I did not use watchdog timer. Can you please elaborate as to why it is used? I an a total newbie with ip related concept!
    thanks once again.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    When I tested it I saw that the Android device didn't recognize that the connection has broken when I reset the ESP. The watchdog resets the connection if no data has arrived in 10 seconds.
     
    Beja and rbghongade like this.
  7. Bert Oudshoorn

    Bert Oudshoorn Member Licensed User

    Erel answered with a TCP example(?) Here a very simple UDP one, derived from b4x information.
    Erel deserves a Nobel price, Anywhere Software transformed in Universal Software :) u4x.co...

    Sub Process_Globals
    Private wifi As ESP8266WiFi
    Private udp As WiFiUDP
    End Sub

    Private Sub AppStart
    wifi.Connect2("Hawaii","where???”)
    udp.Initialize(6000, "Udp_PacketArrived")
    End Sub

    Sub Udp_PacketArrived (Data() AsByte, Ip() AsByte, Port AsUInt)
    udp.BeginPacket(Ip,Port)
    udp.Write(Data) '//echo, or more writes and/or udp.Write("abcd".GetBytes)
    udp.SendPacket
    End Sub
     
    Johan Hormaza, rbghongade and Erel like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice