BlueTooth to IR converter

mitsusdev

Member
Licensed User
Longtime User
HI,
i'm trying to talk (using an BlueTooth to IR converter) with a television.

I'm able to connect (slave) converter, but i can't to talk with television.

My problem is that after coverter pairing, i try to send an hex value (Es. 0x18) and i expect to receive an ACKNOLEDGE...but nothing....where is my error??

Below the code (for start i use the base of bluetooth chat example):

B4X:
Sub btnSend_Click
   Dim checkTV As Byte
   
   checkTV = 0x18 ' Hex init data <CAN>
   Log("SEND <CAN>: " & checkTV) 
   AStream.Write(BConv.HexToBytes(checkTV))
   
End Sub

Thanks and regards

F
 

mitsusdev

Member
Licensed User
Longtime User
Where is the code that handles the response?

Below the code that handles the response:

B4X:
Sub AStream_NewData (Buffer() As Byte)
   'Log(BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
   Log("DIm buffer:" & Buffer.Length)
   Log("Buffer: " & BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
End Sub

...i want to see an ACK or NACK data (Es. 0x06 for ACK), but when i try to send data for the fourth attemp it response with buffer.lenght = 0.

Thanks a lot
 
Upvote 0

mitsusdev

Member
Licensed User
Longtime User
So you get an empty response? Can you post your full code?

The main code is the same of bluetooth chat example. For the first test i've changed only ChatActivity (i'm able to cennect to IT-to-bluetooth converter...i see a green led light fixed, and when i send data, i see green led blinking):

B4X:
'Activity module
Sub Process_Globals
   Dim AStream As AsyncStreams
   Dim BConv As ByteConverter 
End Sub

Sub Globals
   
   Dim btnSend As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("2")
   If AStream.IsInitialized = False Then
      AStream.InitializePrefix(Main.serial1.InputStream, True, Main.serial1.OutputStream, "AStream")
   End If
   'txtLog.Width = 100%x
End Sub

Sub AStream_NewData (Buffer() As Byte)
   'LogMessage("You", BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
   Log("DIm buffer:" & Buffer.Length)
   Log("Contenuto buffer: " & BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
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
   
   
   checkTV = 0x0B ' Hex init data <CAN>
   Log("SEND <CAN>: " & checkTV) 
   AStream.Write(checkTV)
   '
End Sub

...yes after the fourth button pressed (send 0x18)..i see an empty buffer.

Thanks
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…