Send a hex byte via bluetooth

saunwin

Active Member
Licensed User
Longtime User
Hi All,

:sign0104:

I have a seekbar, which needs to send it's value over bluetooth.
I'm paired up and using the serial tutorial I think I'm nearly there.
But the serial tutorial sends text both ways, I just need to send a hex byte (seekbar.Value in Hexdecimal)) from tablet to PC.

Can anyone point me in the right direction ?

Thanks in advance

Steve
 

DrWave

Member
Licensed User
Longtime User
how does this work?

I found this post thinking this would be exactly what I needed but I cannot get it to work :

Like the text example I use serial1 as the connection
So if I initialize textwriter with

TextWriter1.Initialize(Serial1.OutputStream)
then writing text is easy with

TextWriter1.WriteLine(txtSend.Text&CRLF) but to send bytes ...

serial1.outputstream.writebytes(Buf,0,1) does not compile with unknown element error. What am I missing ?
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
B4X:
Dim buffer(1) as ByteBuffer(0) = 123 'The valueout.WriteBytes(Buffer, 0, 1)
Hi Erel. is the decimal value "123" above converted to byte on the fly? if so that means one should first convert his hex vlues to decimal.
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Hi Erel,
B4X:
Dim buffer() As Byte = Array As Byte(123) 'creates an array of bytes with one byte. The byte decimal value is 123.
It will be very difficult to use decimal to represent hex.. it will need high level of imagination or additional conversion code.
Is it possible to do something like:
B4X:
Dim buffer() As Byte = Array As Byte(7F, 2D, D3, 01) 'INSTEAD OF THE ABOVE CODE?

Thanks
 
Upvote 0
Top