2014년 11월 29일 토요일

Bluetooth input stream handle

Is there a tutorial on how to handle input stream from a Bluetooth connected sensor?
I've managed to connect and to display information in the label.
But I would like to split the stream into three blocks of data. This is how the stream looks like:

...19.0#55.7#340#19.0#55.7#340#19.0#55.7#340#....

As you can see it repeats itself. Those are three sensor readings. The first is temperature, then humidity and light at the end.
Does anyone have a code from this guy:

It looks useful.




You need to parse the string.  You can do that with the Text block tools.   The particular screen you report seems to have a patter and it might be possible to convert it into a csv file, where the #'s are separators.

Here is one way:  https://puravidaapps.com/snippets.php#2parse        You might be able to do this other ways. I would try treating it like a csv file.

What have you tried?   Showing blocks with a screen capture helps others to help users understand the issue and provide specific advice.



There is nothing interesting to show so far. I was stuck with text cutting, combining and finding start and end of particular information. I always ended with overflow.
The link you provided looks promising. I'll get into parse command and post the results.



Success.
The proposed procedure parse is the solution. One first needs to create a procedure to parse the incoming data as described in the link:


Then you need to capture the incoming stream as seen on the picture 01. It is the procedure called incoming. And last you call both functions with a timer as I did in the second picture. There is still some work to do, though. I have to synchronize the timings, for example. But the main part is done.
I'd like to thank SteveJG for pointing me in the right direction and also Neil from ForceTronics blog for his contribution.






댓글 없음:

댓글 쓰기