Android Question Bluetooth AStream response

GaNdAlF89

Active Member
Licensed User
Longtime User
Hi, I have a bluetooth printer, and I use the AsyncStreams object to work with it. I request the id of printer, but in the _NewData event I get the result in the image attached. How can I handle this? Thanks to all.

 

JTmartins

Active Member
Licensed User
Longtime User
If you tell us the brand and model of the printer, it will be easier to help you. However you will need the printer detailed manual where it should say what kind of replies you should get from it.
 
Upvote 0

GaNdAlF89

Active Member
Licensed User
Longtime User
If you tell us the brand and model of the printer, it will be easier to help you. However you will need the printer detailed manual where it should say what kind of replies you should get from it.
Thanks for reply, I have sent to printer a command to retrieve its id. But the problem is the value of Buffer. The StringFromBytes method returns this:
B4X:
U��8�����
I'd like to know how to read correctly this response.

Ps. The printer is Custom MYPrinter
 
Upvote 0

M. Giray Ozkan

Member
Licensed User
Longtime User
Maybe you must use response data as HEX format.

B4X:
Sub btStream_NewData (Buffer() As Byte)
    Try
            tmpBuffer = tmpBuffer & Conv.HexFromBytes(Buffer)
            Log(tmpBuffer)
            If tmpBuffer.Length > 14 And tmpBuffer.StartsWith("51") Then
                ShowResultsActivity(FindDataTypeAndParse(tmpBuffer))
                tmpBuffer = ""
            End If
    Catch
        ToastMessageShow("BT read response error",True)
    End Try
End Sub
 
Upvote 0

GaNdAlF89

Active Member
Licensed User
Longtime User
Thanks!! I solved with HexFromBytes ;-)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…