BLE Big Data Transfer

Function Introduction

The Bluetooth Big Data Transmission Module is used to stablely transmit large amounts of data, such as images, pixel art, and animation materials from the panel to the device via Bluetooth packet segmentation. The module supports sending thousands of bytes of data and implements the following:

  • Packet segmentation

  • ACK packet confirmation mechanism

  • Timeout retransmission

  • Transmission progress callback

Suitable for BLE devices with pixel screens, lighting effect screens, and animation display functions.

Function Description

  • Supports converting base64 images from the panel to hexadecimal data before BLE packet segmentation transmission.

  • Segments data into fixed sizes according to the protocol (default 1006 bytes).

  • Transmits each packet to the device via device.publishBLETransparentData.

  • Supports the device returning an acknowledgment packet (ACK), with the client confirming receipt of each packet sequentially.

  • Supports retrying failed packets (up to 5 times).

  • Supports real-time reporting of the transmission progress.

Interaction Flow

sequenceDiagram
    participant P as Panel
    participant BLE as BLE Transmission Module
    participant Dev as Device

    P->>BLE: Pass base64 image data
    BLE->>BLE: Convert to Hex
    BLE->>BLE: Split into packets (createPackets())
    P->>Dev: Send DP command to start transmission
    Dev-->>P: DP status confirmation (success)

    loop Packet Transmission
        BLE->>Dev: publishBLETransparentData(packet)
        Dev-->>BLE: Return ACK (current packet index)
    end

    alt Unconfirmed packets exist
        BLE->>Dev: Retry failed packets (up to 5 attempts)
        Dev-->>BLE: ACK
    end

    BLE-->>P: All packets sent successfully
    P-->>User: Display “Send Successful”

Data Sending Process

Complete sending is accomplished by sendPackets():

(1) Check device online status

const isBleOnline = [...] // Determine if BLE is available

(2) Send Startup DP

For example, starting playback and prompting the device to enter receiving mode:

sendDp(); // Send DP command

Listen for the dp status return:

onDpDataChange(callback);

(3) ACK reported by the monitoring device BLE

onBLETransparentDataReport(bleCallback);

Parsing ACK:

parseConfirmation(res) {
  const index = parseInt(res.data.slice(12, 16), 16);
  return index;
}

(4) Send the first 4 packets (fast sending)

Send in rapid succession without waiting for confirmation:

for (index < 4) publishFn(packets[index]);

(5) Start sending packets sequentially from the 5th packet and wait for the device to ACK.

await waitForConfirmation(index);
publishFn(packets[index]);

(6) Resend failed packets (maximum 5 rounds)

while (retries < 5) retryFailedPackets();

(7) Sending Complete

If all packets have received confirmation → Return Success

If some packets are still unacknowledged → Return Failure