The button code is self-documenting. When a button
n PHONESHOT 2. The WEMOS
D1 Mini’s IP address has been
entered and the Connect button
touched. We are now connected
to the Mini server and all of the
I/O pins we control are in the
Globals. A logical TRUE value in our connected variable
will allow our data pipe to be initialized and assign
“astream” as a prefix name for all of the subroutines
associated with our new AsyncStreams data pipe:
If Successful Then
the log area of the B4R IDE.
I’ve captured the B4R log
entry in Screenshot 2.
The Mini is waiting for a
connection, and listening at
IP address 192.168.1.222 on
port 51042. So, we simply
enter 192.168.1.222 in the
txfIP textfield and touch the
The StateChanged subroutine is called to handle the
chain graphic, which is represented as text in the label we
The chain graphic is a text squiggle that can’t be read
by a human. That’s why you see nothing recognizable
between the quotes in the StateChanged subroutine.
The btnConnect subroutine is called when the Connect
button is touched. When the Connect subroutine launches,
a quick check is made to ensure that our AsyncStreams
data pipe is not already in use, our socket object is
initialized, and the connection request containing our
socket values (192.168.1.222 and 51042) is transmitted.
We’ll give it 30,000 milliseconds to work.
It’s sufficient to say that the status of the chain is
dependent on the Boolean variable connected. If the
connected variable is TRUE, the chain is linked and green.
On the other hand, if the connected variable is FALSE, the
chain is broken and red. Our link is up in Phoneshot 2.
To control the Mini’s output pins, we simply touch the
desired button (S0, S1, or S2):
If all goes as designed (or not), the Socket_Connected
subroutine is launched:
The status of our new connection attempt is stored in
the Boolean connected variable we defined in the Process
56 February 2018