So, I modified my original app to receive ANY type of data (bytes, floats, shorts, integers and strings, all of them signed/unsigned or whatever options I had), and it would categorize the data according to its "received format", so I attach the received list below:
With shorts unsigned and strings as UTF16-true:
shorts received... [15122, 1065]
strings received... ["㬒Щ"]
shorts received... [15122, 1078, 523]
strings received... ["㬒жȋ"]
shorts received... [15122, 1158]
strings received... ["㬒҆"]
shorts received... [15122, 1060]
strings received... ["㬒Ф"]
shorts received... [15122, 1046]
strings received... ["㬒Ж"]
shorts received... [15122, 506]
strings received... ["㬒Ǻ"]
shorts received... [15122, 1141]
strings received... ["㬒ѵ"]
shorts received... [15122, 1033]
strings received... ["㬒Љ"]
shorts received... [15122, 1035]
strings received... ["㬒Ћ"]
shorts received... [15122, 1022]
strings received... ["㬒Ͼ"]
With shorts signed and strings as UTF16-false:
shorts received... [14610, 1027]
strings received... ["㤒Ѓ"]
shorts received... [14610, 1014]
strings received... ["㤒϶"]
shorts received... [14866, 1041]
strings received... ["㨒Б"]
shorts received... [14866, 1037]
strings received... ["㨒Ѝ"]
shorts received... [14866, 1027]
strings received... ["㨒Ѓ"]
shorts received... [14866, 1044]
strings received... ["㨒Д"]
shorts received... [15122, 1064]
strings received... ["㬒Ш"]
shorts received... [15122, 192, 109, 486]
strings received... ["㬒ÀmǦ"]
shorts received... [15120, 478, 184]
strings received... ["㬐Ǟ¸"]
shorts received... [15104]
strings received... ["㬀"]
You can see I am only receiving shorts and strings, but for every short is followed by a string, so I guess its the same data, just interpreted differently. The signed/unsigned should not make any difference since the expected numbers are low (less than 220) and are all positive.
According to Bluetooth docs, it's logical that integers or floats are not received, since they don't correspond to the standard data format for heart rate transmission (but I wanted to try hehe).
Finally, I came across this So, finally came along this: Reading BLE service in Appinventor - #41 by Gordon_Moore, and sort of have come to something that works.
You can see in my list that most data comes in a list, and the first item on the list is always around 13000-15000, and in some cases the list only contains one item, and that item is of such magnitude. If I divide that number by 256 as stated on the link above, I get between 50 and 60 heart beats per minute, which is slightly higher than my resting hear rate since I'm sitting down but still doing some work. So that seems to be ok and I understand the logic behind it.
Now, for the problem of being able to tell whether to use bytes or shorts, the link explains but I think there's a bit of confusion as to which bit to use to tell them apart, but anyway, if the sensor decided to send bytes, since numbers in this case are under 255, there's no difference between receiving 8 or 16 bits, right?
Anyway, I'm open to thoughts or comments, and attach my last version which can be used to connect and receive all kind of data to be interpreted (you will need to activate the blocks corresponding to floats and integers though
)
BLE_connect_v3.aia (200.8 KB)