Home > Software engineering >  Storing Serial data from Bluetooth to an Array by filtering and adding delimiters
Storing Serial data from Bluetooth to an Array by filtering and adding delimiters

Time:12-19

For an instance I receive 5000 samples of data from a bluetooth device and a sample of data looks like:

FA 00 3E 53 45 32 45 2A 3A 3B FB

While I read using Bluetooth socket what I get is

-FA 
-00 
-3E 
-53 
-45 
-32 
-45 
-2A 
-3A 
-3B
-FB
-FA 
-00 
-3E 
-53 
-45 
-32 
-45 
-2A 
-3A 
-3B
-FB
-.
-.
-.
-.
-.
-.
-.
-.
-FB

I need to store this data into array as:

String arr[]=[~FA,00,3E,53,45,32,45,2A,3A,3B,FB ~FA,00,3E,53,45,32,45,2A,3A,3B,FB]

How to achieve this result?

//Note: These data are real time, and they are continous.

CodePudding user response:

Use ArrayList to store data as they come

List<String> list=new ArrayList<>();

then add all value like this list.add("FA") // this will add string "FA" in list

for reference check this link to understand arraylist https://www.w3schools.com/java/java_arraylist.asp

  • Related