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
 
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
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
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
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
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
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
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
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
I will take a look at the code this evening and try to use my 3 available android devices... I'll let you know how it goes
 
Upvote 0
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
So, @Filippo , if you want, I will try to collaborate with you... send me PM with more details about your project
 
Upvote 0
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:
Code: Copy
    server(0).Initialize(51041, "Server_NewConnection")
    server(0).Listen

    server(1).Initialize(51042, "Server_NewConnection")
    server(1).Listen
 
Upvote 0
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
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

Similar Threads

Back
Top