modules.
Public App As Application
Public;NavControl;As;NavigationController
Private Page1 As Page
Private astream As AsyncStreams
Private ser As B4RSerializator
Private socket As Socket
Public;connected;As;Boolean
Private;btnConnect;As;Button
Private btnS0 As Button
Private btnS1 As Button
Private;btnS2;As;Button
Private;imgvLedD0;As;ImageView
Private;imgvLedD1;As;ImageView
Private;imgvLedD2;As;ImageView
Private;txfIP;As;TextField
Private lblIP As Label
Private lblStatus As Label
Dim;data();As;Object
End;Sub
If you’re thinking this looks a bunch like the B4R code,
you’re right. The cool thing about B4R and B4I is that if you
learn to code in one, you can code in the other. As you
can see in our Process Globals assignments, we are coding
with AsyncStreams and B4RSerializator on the iPhone end
too.
Before we touch the Connect button, we must enter
the IP address of the D1 Mini server. If you take a peek
back at the B4R code, the Mini’s IP address is displayed in
n FIGURE 1. These LED images
were very easy to create. There are
plenty of tutorials on the Internet that
describe in detail how to draw these
types of graphic images.
n SCREENSHOT 2. The B4R development platform
automatically programs the WEMOS D1 Mini upon
successful compilation of the target source code. In this
case, we have instructed the Mini to cough up its server IP
address in the log area of B4R.
If you think about that, it is a must. We have to have
an “other end” to our data pipe (AsyncStreams), and we
must be able to encode and decode on both ends of the
link with B4RSerializator.
touched. The Connect button is actually the blue RF
graphic to the right of the IP address text box.
The NavigationController is iPhone related and you
can get the gist of what it does by its name. Since the D1
Mini is a Wi-Fi device and Wi-Fi flows over TCP/IP, sockets
are involved. A socket is no more than an IP address that is
associated with a port address.
The trio of buttons (S0, S1, and S2) is shadowed by a
trio of associated blue LED indicators called imgvLedDx.
The LED indicators are image views that will contain
either the ON or OFF version of the blue LED. The blue
LED graphics you see in Figure 1 were created using
Photoshop.
The IP address textfield is used to input the address
of the WEMOS D1 Mini server. Once the IP address is
entered, the Connect button is used to kick off the code
for the connection to the server. The status label will shift
its graphic payload between a broken red chain and green
linked chain, depending on the status of the connection to
the Mini server. The data object is an array that is used in
the B4RSerializator encoding and decoding processes.
We are ready to move into making things happen.
Let’s initialize the B4RSerializator and show our Visual
Designer artwork:
There are
tutorials on the
Internet that
describe how to
create the LED
images. Each of
these images
will toggle
between ON
and OFF when
the associated
Private Sub Application_Start (Nav As
NavigationController)
ser.Initialize
NavControl;=;Nav
Page1.Initialize(“Page1”)
Page1.RootPanel.LoadLayout(“nvRemoteControl”)
NavControl.ShowPage(Page1)
End;Sub
February 2018 55