Wish Ethernet IP in B4A-Bridge

TheMightySwe

Active Member
Licensed User
Why this? There is already a display for local address. To know the public address you have to ask a remote server, since it can know your public address.

If you want I have a little piece of code to do that.

Mauro

IT DOES NOT Display the local adress if you are connected via a ethernet cable. Only if you are connected via WIFI!
 

Peter Simpson

Expert
Licensed User
@TheMightySwe below is the link to the latest source code for the B4A-Bridge, you can download the source code and modify it for your own personal use. How are you connecting your device to an Ethernet cable, I presume that you are using one of these?


Anyway you can use the code below and modify B4A-Bridge to do what you need it to do. Actually thinking about, the B4A-Bridge becomes redundant if you are connecting an Ethernet cable to your device, that means your device is no longer wireless. Why don't you just use USB debugging instead.

B4A-Bridge source code: http://www.b4x.com/android/forum/threads/b4a-bridge-source-code.8153/page-2#post-299234
 

TheMightySwe

Active Member
Licensed User
The device does not have USB, its a old POS system. And B4A-Bridge works but I have to see the IP in a other program. The FTP server. Just annoying. But I will check out the B4A Code.
 

TheMightySwe

Active Member
Licensed User
If @Erel want to put the code in the real version it would be great.

Put an extra label named lblLanIp in the designer

Add the label in Globals

Dim lblLanIp As Label


B4X:
Sub UpdateIp

    Dim ip As String
    ip = server.GetMyWifiIP
    If ip = "127.0.0.1" OR ip.Contains(":") Then
        ip = "Not connected to wireless network."  
    End If
    lblIp.Text = "My IP: " & ip
  
    Dim ip As String
    ip = server.GetMyIP
  
    If ip = "127.0.0.1" OR ip.Contains(":") Then
        ip = "Not connected to LAN network."  
    End If
  
    lblLanIp.Text = "My LAN IP: " & ip
  
End Sub

In service1.bas

B4X:
Sub PE_ConnectivityChanged (NetworkType As String, State As String, Intent As Intent)
    If NetworkType = "WIFI" Then CallSub(Main, "UpdateIp")
    If NetworkType = "ETH" Then CallSub(Main, "UpdateIp")
End Sub
 
Last edited:
Top