B4R Question ESP8266 Boards

D

Deleted member 103

Guest
Hi,

I have maybe a stupid question, you can either connect to android phone or iOS phone without a server?
Phone = Server
Board = client
 
D

Deleted member 103

Guest
So, now I got the board and get well over Wifi to connect to my phone.
But when I'm out there without Wifi, how do I get a connection to the phone if I do not know the IP?
 
Upvote 0
D

Deleted member 103

Guest
Can someone give me direction how to exchange data between Android/iOS and the ESP8266 boards ?
I just need to write and read single bytes.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
same way as with any... use async stream!

[edit] just saw your previous post...
Well I guess you'll need to add it to a home server, or add a gsm shield to the board
 
Upvote 0
D

Deleted member 103

Guest
Well I guess you'll need to add it to a home server, or add a gsm shield to the board
First of all thanks for your answer.
The board should be itself a wireless server. I must be able to connect with different devices (Android and iOS) and exchange data.

With this example, I configured the board as a server, but I know now not how to exchange data with different devices.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
You should be able to either use sockets or mqtt... But then again.. i haven't yet really explorer my board...
Maybe we can cooperate ro this one?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Can someone give me direction how to exchange data between Android/iOS and the ESP8266 boards ?
I just need to write and read single bytes.
Start with the code from this tutorial: https://www.b4x.com/android/forum/threads/esp8266-getting-started.68740/
It should be trivial to port the B4J code to B4A or B4i.

But when I'm out there without Wifi, how do I get a connection to the phone if I do not know the IP?
The ESP module and the phone must be connected to the same network for them to communicate. You can connect the phone to the ESP ad hoc network. The ESP8266 ip address will be: 192.168.4.1
 
Upvote 0
D

Deleted member 103

Guest
Hi Cableguy,

You should be able to either use sockets or mqtt...
that's my problem! I do not know what to use best.

Maybe we can cooperate ro this one?
A cooperation would be nice. :)

@Erel
Start with the code from this tutorial: https://www.b4x.com/android/forum/threads/esp8266-getting-started.68740/
It should be trivial to port the B4J code to B4A or B4i.
I've tried and it works without problems.

The ESP module and the phone must be connected to the same network for them to communicate.
This is also clear to me.

You can connect the phone to the ESP ad hoc network. The ESP8266 ip address will be: 192.168.4.1
Unfortunately, I do not understand that! Here I could use some help.
 
Upvote 0
D

Deleted member 103

Guest
I let , for you is something very simple. but we are different level . I'm on level 1 and you on Level 100th.;)
 
Upvote 0
D

Deleted member 103

Guest
I've done it! :)
Wemos as an access point and server, B4A as client.

With 1 B4A client works without problems, but if 2 B4A client are connected, it no longer works.
What should I do with it with 2 B4A client works? :(

 

Attachments

  • B4A_Client.zip
    8.5 KB · Views: 285
  • B4R_Server.zip
    1.3 KB · Views: 288
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
WiFiServerSocket supports a single connection only.

You can create several instances and listen to different ports.

Another simpler option is to use MQTT or WebSockets. You will need to run a server but it will allow you to connect multiple devices easily. You can use a Raspberry Pi as the server (or an Android device).
 
Upvote 0
D

Deleted member 103

Guest
You can create several instances and listen to different ports.
How can I from B4a Check whether a port is already used by another B4a app?

B4R-Code:
B4X:
    server(0).Initialize(51041, "Server_NewConnection")
    server(0).Listen

    server(1).Initialize(51042, "Server_NewConnection")
    server(1).Listen
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
You can start by using one port, keeping it in a variable and then, upon a successful connection, create a new listener on another port!
Also, to liberate used ports, check if a port is not used for a while, like a few hours, and if so, re-initialize it!
 
Upvote 0

rbghongade

Active Member
Licensed User
Longtime User
Dear Filippo,
I tried to create multiple instances of sever (server1, server2...), as per the above post . Created different
Server_NewConnection subs , but my WeMos crashes ! If you have succeeded in creating multiple servers (sharing the same data), please let me know the initialisation and other required subs.
regards,
 
Upvote 0
Top