Android Question Control a KMTronic Ethernet Relay with B4A

DAnyP01

New Member
Licensed User
Longtime User
Hi

I was reading since a day on the forum about how to send a command to an Ethernet adresse
but i didnt find what im looking for

I need do change a Ethernet relay state from on/off with this code
turn on = FF0101 turn off = FF0100

-adresse: 192.168.1.199
-port: 80
-user: admin
-password: admin


someone have an idea about the Library and the code ??

thanks for your help
 

DonManfred

Expert
Licensed User
Longtime User
Asuming it is this board: http://info.kmtronic.com/kmtronic-lan-ethernet-ip-8-channels-web-relay-board.html

Try it with:

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Dim j As HttpJob
    j.Initialize("TurnOn",Me)
    j.Tag = "Relay 1 - ON"
    j.Download("http://192.168.1.199/FF0101")
    Dim j As HttpJob
    j.Initialize("TurnOff",Me)
    j.Tag = "Relay 1 - OFF"
    j.Download("http://192.168.1.199/FF0100")
End Sub

Sub JobDone (Job As HttpJob)
    Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
    If Job.Success = True Then
        Select Job.JobName
            Case "TurnOn", "TurnOff"
                'print the result to the logs
                Log(Job.GetString)
        End Select
    Else
        Log("Error: " & Job.ErrorMessage)
        ToastMessageShow("Error: " & Job.ErrorMessage, True)
    End If
    Job.Release
End Sub
 
Last edited:
Upvote 0
Top