Hi,
i've a question. I'm develop a new app that use and IT to BT converter for data read from an IR device linked to the phone over bluetooth.
So i'm able to link the IT-to-BT adapter (after Erel explanation See thread: http://www.b4x.com/forum/basic4android-updates-questions/17492-bluetooth-ir-converter.html#post100166)
So now my question is that using this converter with my linux workstation, i'm able to talk with remote IR device (using my IR-to-Bluetooth converter) using a little perl script.
..it wotk fine, and the latest "print" is able to see the serial number of remote device.
I'm trying to read data (from B4A) using the same technique, but the remote device is able only of send back commands.
Below my B4A code (symilar to bluetooth chat example):
Where is my errors?
Thanks and Best Regards
i've a question. I'm develop a new app that use and IT to BT converter for data read from an IR device linked to the phone over bluetooth.
So i'm able to link the IT-to-BT adapter (after Erel explanation See thread: http://www.b4x.com/forum/basic4android-updates-questions/17492-bluetooth-ir-converter.html#post100166)
So now my question is that using this converter with my linux workstation, i'm able to talk with remote IR device (using my IR-to-Bluetooth converter) using a little perl script.
B4X:
$out = pack(C,hex(B)); #Convert hex(B) into and unsigned char
$foo = $meterport->write($out); # Write data over IR
sleep 0.1;
$foo = $meterport->input; # Read data over IR from remote device
$out = pack(C,hex(D)); #Convert hex(D) (CR) into and unsigned char
$foo = $meterport->write($out); # Write data over IR
sleep 0.2;
$bah = $meterport->input;
print $bah;
..it wotk fine, and the latest "print" is able to see the serial number of remote device.
I'm trying to read data (from B4A) using the same technique, but the remote device is able only of send back commands.
Below my B4A code (symilar to bluetooth chat example):
B4X:
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("2")
If AStream.IsInitialized = False Then
AStream.Initialize(Main.serial1.InputStream, Main.serial1.OutputStream, "AStream")
End If
'txtLog.Width = 100%x
End Sub
Sub AStream_NewData (buffer() As Byte)
Dim tmpGlucose As Int
'Wait(100)
i = i + 1
Log("i: " & i)
Log("DIm buffer:" & buffer.Length)
Log("****** Buffer content: " & BConv.HexFromBytes(buffer))
If i = 1 Then
AStream.Write(BConv.HexToBytes(0x0D))
Log("SEND : 0x0D")
Wait(20)
End If
End Sub
Sub AStream_Error
ToastMessageShow("Connection is broken.", True)
btnSend.Enabled = False
'txtInput.Enabled = False
End Sub
Sub AStream_Terminated
AStream_Error
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If UserClosed Then
AStream.Close
End If
End Sub
Sub txtInput_EnterPressed
If btnSend.Enabled = True Then btnSend_Click
End Sub
Sub btnSend_Click
Dim checkTV As Byte
i = 0
checkTV = 0x0B ' Hex init data <CAN>
Log("SEND <CAN>: " & checkTV)
AStream.Write(BConv.HexToBytes(checkTV))
Wait(10)
End Sub
Sub Wait(Sekunden As Int)
Dim Ti As Long
Ti = DateTime.Now + Sekunden
Log("Wait for " & Sekunden & "msec")
Do While DateTime.Now < Ti
DoEvents
Loop
End Sub
Where is my errors?
Thanks and Best Regards