The awesomeness of css

Project scene:

Tip: Here is a brief description of the project related background:
For example: Project scene: Example: Communication with mobile phone APP via Bluetooth chip (HC-05), transmitting a batch of sensor data every 5s (not very large)

Problem Description:

Tip: Here is a description of the problems encountered in the project:
For example, data is lost from time to time during data transmission, and occasionally a part of the data will be lost
. The code for receiving data in the APP:

        public void run() {bytes =;mHandler.obtainMessage(READ_DATA, bytes, -1, buffer).sendToTarget();}

Cause Analysis:

Tip: Fill in the analysis of the problem here:
For example, there are two ways for Handler to send messages, namely Handler.obtainMessage() and Handler.sendMessage(). When the amount of data is too large in the obtainMessage method, the size of MessageQuene is also limited. When the message is not processed in time, the data transmitted first will be overwritten, which will lead to data loss.


Prompt: Fill in the specific solution to the problem here:
For example: create a new Message object, and save the read data into the Message, then mHandler.obtainMessage(READ_DATA, bytes, -1, buffer).sendToTarget(); replace it with mHandler.sendMessage().

Guess you like