Communication with Blue Tooth tri-axel accelerometer

todh

Member
Licensed User
Longtime User
I am new to B4A but have some experience with VB6. I can get connected with the Bluetooth but the serial example hangs with the last character in the menu. It was recommended to try async example. That worked for the menu but when requesting data the response was strange. Next it was recommended to use the bluetooth example which required a lot of changes. I think I have most of the issues resolved but I can not get past this Sub:
' Sub AStream_NewData => Moved to ServiceAStream
' and replaced by Sub NewMsgFromServiceAStream
' NEW - This Sub is called from ServiceAStream when new data is received
Sub NewMsgFromServiceAStream(Buffer() As Byte)
' The received message comes from the global variable MsgReceived from ServiceAStream
'FIX IT
'LogMessage(BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
'LogMessage("You", BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
LogMessage("You", ServiceAStream.MsgReceived)
'LogMessage("You", ServiceAStream.MsgReceived)
'LogMessage[(Int)(Double.parseDouble("You"))][(Int)(Double.parseDouble(mostCurrent._serviceastream._msgreceived))]

End Sub
I need help! :sign0013::BangHead:
 

todh

Member
Licensed User
Longtime User
Update

I apologize for my frustration. I was fighting three computers yesterday and it got the better of me. In order to get help I need to be more clear.
1. I started my quest to communicate with my 3-axis Bluetooth accelerometer using the serial example. It connected to the Bluetooth just fine but stopped at the (textreader1.readline) statement at the end of the 8th item menu. After a long search I found others that had the same problem and it was the lack of a carriage return at the end of that line. (MScom does not have this issue) Erial suggested that I try the RaddomAccessFile example.
2. Again the Bluetooth connection worked just fine but it would not read the menu. More time and research. I found that others were having similar issue and the (Astreams.InitializePrefix ) need to be changed to (Astreams.Initialize and remove the true statment ). With this change I was able to read the 8 item menu and activate 6 of the items. However when I tried to get the data I got (you: #R$). It should be X,Y,Z. Erial suggested that I try the Bluetoothchat example.
3. The bluetoothchat example required a major tear up with new libraries and new variables. I got through all that until I got to the last subroutine. (NewMsgFromServiceAstream (buffer as byte()) ) LogMessage is red. When I try to DIM the variable as String I get an undeclared array error and it goes down hill from there.
:sign0163::BangHead:
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…