Alphaw Member Licensed User Longtime User Nov 5, 2016 #1 Dear all, I am trying to connect android with an arduino, and I follow the step from b4r tutorial, https://www.b4x.com/android/forum/threads/hc-05-classic-bluetooth.66677/ I just use the b4a part and want to add a textbox to send the message to arduino. However, I fail for turning the editText1.text to byte and compile the file. Why? Am I lack of any library? How can I solve it. Besides, I also cannot show any words except integer in my app. How can I turn the byte to string? Thank you. Attachments cap.PNG 272 KB · Views: 1,598 bt.zip bt.zip 60.9 KB · Views: 447 cap2.PNG 27.3 KB · Views: 678
Dear all, I am trying to connect android with an arduino, and I follow the step from b4r tutorial, https://www.b4x.com/android/forum/threads/hc-05-classic-bluetooth.66677/ I just use the b4a part and want to add a textbox to send the message to arduino. However, I fail for turning the editText1.text to byte and compile the file. Why? Am I lack of any library? How can I solve it. Besides, I also cannot show any words except integer in my app. How can I turn the byte to string? Thank you.
Cableguy Expert Licensed User Longtime User Nov 5, 2016 #2 Try the new serializel ibrary, with it you can turn into bytes any object, send it and convert it back in the receiver Upvote 0
Try the new serializel ibrary, with it you can turn into bytes any object, send it and convert it back in the receiver
Alphaw Member Licensed User Longtime User Nov 5, 2016 #3 Oh, I see. But will I still cannot compile the file? Actually I do not know what wrong with the code. Upvote 0
Oh, I see. But will I still cannot compile the file? Actually I do not know what wrong with the code.
Cableguy Expert Licensed User Longtime User Nov 5, 2016 #4 Have made the appropriate changes in order to use serialisation? What error do you get? Can you post your code? Upvote 0
Have made the appropriate changes in order to use serialisation? What error do you get? Can you post your code?
Alphaw Member Licensed User Longtime User Nov 5, 2016 #5 My code is just attached in first post and the photo show that I cannot compile to an app as the problem with byte. Upvote 0
My code is just attached in first post and the photo show that I cannot compile to an app as the problem with byte.
Cableguy Expert Licensed User Longtime User Nov 5, 2016 #6 So you haven't change your original code? USE serialisation in your code, and if that doesn't work THEN post any relevant code. Your current code error tells you that it cannot parse a byte into a bytes array... Dealing with strings in arduino is somewhat complex, so Erel created an "universal" serialisation lib to be used in cases like this one Upvote 0
So you haven't change your original code? USE serialisation in your code, and if that doesn't work THEN post any relevant code. Your current code error tells you that it cannot parse a byte into a bytes array... Dealing with strings in arduino is somewhat complex, so Erel created an "universal" serialisation lib to be used in cases like this one
Alphaw Member Licensed User Longtime User Nov 5, 2016 #7 Cableguy said: So you haven't change your original code? USE serialisation in your code, and if that doesn't work THEN post any relevant code. Your current code error tells you that it cannot parse a byte into a bytes array... Dealing with strings in arduino is somewhat complex, so Erel created an "universal" serialisation lib to be used in cases like this one Click to expand... Oh, I see. Let me try first. Thank you. Upvote 0
Cableguy said: So you haven't change your original code? USE serialisation in your code, and if that doesn't work THEN post any relevant code. Your current code error tells you that it cannot parse a byte into a bytes array... Dealing with strings in arduino is somewhat complex, so Erel created an "universal" serialisation lib to be used in cases like this one Click to expand... Oh, I see. Let me try first. Thank you.
Cableguy Expert Licensed User Longtime User Nov 5, 2016 #8 Try the example found here, I think it does almost exactly what you need. https://www.b4x.com/android/forum/t...e-objects-instead-of-bytes.72404/#post-460481 Upvote 0
Try the example found here, I think it does almost exactly what you need. https://www.b4x.com/android/forum/t...e-objects-instead-of-bytes.72404/#post-460481
Erel B4X founder Staff member Licensed User Longtime User Nov 6, 2016 #9 You should post the relevant code and error message as text instead of screenshots. String.GetBytes returns an array of bytes. Code: Copy Dim b() As Byte = EditText1.Text.GetBytes("UTF8") 'convert to bytes Log(BytesToString(b, 0, b.Length, "UTF8")) 'convert to string I recommend using B4RSerializator. Upvote 0
You should post the relevant code and error message as text instead of screenshots. String.GetBytes returns an array of bytes. Code: Copy Dim b() As Byte = EditText1.Text.GetBytes("UTF8") 'convert to bytes Log(BytesToString(b, 0, b.Length, "UTF8")) 'convert to string I recommend using B4RSerializator.