Interface to Jar file - IRControl

DonManfred

Expert
Licensed User
Longtime User
08:48 AM:
Fyi: working on it (if you are still interested)

01:00 PM:
I´ve wrapped the lib, found a missing dependency, created a Testexample.
Please note that i do not have such a device. So i did the coding "blind"...
Please find an Example apk attached. Maybe it do something for you, maybe not :D

Probably it wil fail at some point... I need the stacktrace to be able to know where to search for a fix...

The Code of the example is this

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim manager As UsbUirtManager
    Dim device As UsbUirtDevice
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    ' Initialize the Manager... It does not need a Eventname
    manager.Initialize("")
 
    ' Check DeviceCount
    Log("USBUirtCout="&manager.UsbUirtCount)
    If manager.UsbUirtCount > 0 Then
        For i = 0 To manager.UsbUirtCount-1
            Dim dev As UsbUirtDevice
            dev = manager.openUsbUirtByIndex(i)
            If dev.IsInitialized Then
                ' ATTENTION
                ' You need to set a Eventname for the Device given....
                dev.EventName = "USBDev"
                ' After the Eventname is set a listener for Messages is set also
                If dev.initHelper Then
                    Log("Init seems ok")
                    Log("FirmwareVersion = "&dev.FwVersion)
                Else
                    Log("LastError="&dev.GetLastError)
                End If
            Else
                Log("Device given by index is not initialized")
            End If
         
        Next
    End If
 
    ' Open and get the Device asuming it name is "USB-UIRT"
    device = manager.openUsbUirtByName("USB-UIRT")
    If device.IsInitialized Then
        ' ATTENTION
        ' You need to set a Eventname for the Device given....
        device.EventName = "USBDev"
        ' After the Eventname is set a listener for Messages is set also
        If device.initHelper Then
            Log("Init seems ok")
            Log("FirmwareVersion = "&device.FwVersion)
        Else
            Log("LastError="&device.GetLastError)
        End If
    Else
        Log("Device with name USB-UIRT given by manager is not initialized (or did not exists?)")
    End If
End Sub
Sub Activity_Resume
    manager.registerReceiver 
End Sub
Sub Activity_Pause (UserClosed As Boolean)
    manager.unregisterReceiver
End Sub
Sub USBDev_onLearnProgress(progress As Int, signalQuality As Int, frequenzy As Int, msg As String, data As String)
    Log($"USBDev_onLearnProgress(Progress = ${progress}, Quality  = ${signalQuality}, Frequenzy=${frequenzy}, MSG=${msg}, DATA=${data})"$)
End Sub
Sub USBDev_onLearnResult(result As String)
    Log($"USBDev_onLearnResult(${result})"$)
End Sub
Sub USBDev_onMessage(what As Int, msg As String, data As String)
    Log($"USBDev_onMessage(${what},${msg},${data})"$) 
End Sub
Sub USBDev_onUirCode(what As Int, code As String)
    Log($"USBDev_onUirCode(${what},${code})"$) 
End Sub


The Libs Objects, Methods and Properties:

usbuirt
Author:
DonManfred (wrapper)
Version: 1
  • UsbUirtDevice
    Events:
    • onLearnProgress (progress As Int, signalQuality As Int, frequenzy As Int, msg As String, data As String)
    • onLearnResult (result As String)
    • onMessage (what As Int, msg As String, data As String)
    • onUirCode (what As Int, code As String)
    Methods:
    • GetLastError As Int
    • Initialize (EventName As String)
    • IsInitialized As Boolean
    • close
    • initHelper As Boolean
    • learnAbort (learnBurst As Boolean)
    • learnIR (codeFormat As Int, param1 As Int)
    • toString As String
    • transmitIR (IRCode As String, codeFormat As Int, repeatCount As Int, inactivityWaitTime As Int)
    Properties:
    • EventName As String [write only]
    • FwVersion As String [read only]
  • UsbUirtManager
    Fields:
    • ACTION_USB_ACCESSORY_ATTACHED As String
    • ACTION_USB_ACCESSORY_DETACHED As String
    • ACTION_USB_DEVICE_ATTACHED As String
    • ACTION_USB_DEVICE_DETACHED As String
    • EXTRA_MESSAGE As String
    Methods:
    • Initialize (EventName As String)
    • IsInitialized As Boolean
    • getUsbUirtNameList (numDevs As Int, nameList() As String) As Int
    • openUsbUirtByIndex (index As Int) As UsbUirtDevice
    • openUsbUirtByName (deviceName As String) As UsbUirtDevice
    • registerReceiver
    • unregisterReceiver
    Properties:
    • UsbUirtCount As Int [read only]
 

Attachments

  • UirtManagerEx.apk
    180.8 KB · Views: 263
Last edited:

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Need to find a device it works on. It will not work with my Samsung Galaxy Tab 3 (SM-T210R).

Hoping Santa will bring me the right device.

Sending you private Conversation on other matters.

Tried you APK on my S5 - Notices when I connect the device but I never see a screen or anything on the device happening (blinking light)

BobVal
 
Top