Android Question Convert EditText to hex

TMEA

New Member
Hello.
I'm Thomas and I'm new user this forum. I have problem with transmision data via bluetooth. I have connect bluetooth module with MSP430 and tablet. I use :

Dim Strumien As AsyncStreams
Strumien.Initialize(Adapter.InputStream, Adapter.OutputStream, "Strumien")
MyReceiveData=BytesToString(Buffer, 0, Buffer.Length, "UTF8")

x=EditText1.Text ' adr1 device
Strumien.Write(x.GetBytes("UTF8"))

my msp430 have instruction if(buffer=80) then instructions}
so if i write in TextEdit value 80 MSP don't work
if I write in TextEdit value P (ASCIO 80) MSP430 working.
I want write toTextEdit value 80 because i must sending dex values not strings.

best regards
 

Straker

Active Member
Licensed User
Probably you need to send bytes
Try this:
B4X:
EditText.Text="80"
dim b(1) as byte
b(0)= EditText.text 'vba should convert "80" in the number 80 (aka ASCII P)
'now b(0) contains the number 80, as a single byte
strumien.Write2(b,0,1) 'write a single byte
I think the Erel's solution is not working. If you convert "80" in in a byte array I suppose that it will create a 2 bytes array with ascii 56 and 48 ("8" + "0")
 

Straker

Active Member
Licensed User
Thank you Erel, you are correct (as always).
I didn't thought that there was an implicit conversion.
 
Top