Filter löschen
Filter löschen

BLE Data length extension

9 Ansichten (letzte 30 Tage)
Moin Shaikh
Moin Shaikh am 10 Feb. 2021
Beantwortet: Abhimenyu am 31 Mai 2024
Hello,
I have designed a hardware which transmits data via BLE v4.2. But at present i am only able to send 27 bytes of data. I want to recieve 255 bytes (which is the maximum allowable data exchange possible). Receving using Matlab. At present I am able to recieve 27 bytes data on matlab. Now for 255 bytes, Matlab must be able to request first for 255 bytes of data. Is this possible on Matlab?

Antworten (1)

Abhimenyu
Abhimenyu am 31 Mai 2024
Hi,
I understand that you want to transmit data via BLE v4.2. To receive 255 bytes of data via BLE v4.2 in MATLAB, you’ll need to consider data length extension. BLE allows for extended data lengths beyond the default 27 bytes. Please ensure that the hardware is configured to use the maximum packet size. This often involves configuring both the peripheral (your hardware) and the central device (the BLE adapter on your PC or the device running MATLAB) to use the larger MTU (Maximum Transmission Unit). The MTU negotiation is part of the BLE connection setup process.
  • Peripheral Side (Your Hardware): Make sure your device is configured to support the larger MTU size. This is typically done in the BLE stack configuration or initialization code. If your peripheral device supports data length extension, MATLAB will be able to request and receive larger data packets.
  • Central Side (MATLAB PC/Device): The central device must also support and be configured to request or accept the larger MTU size.
In MATLAB, you can use the ble object to communicate with your BLE peripheral. Please follow the example MATLAB code below to know how you can read data from a characteristic on your peripheral device.
% Create a connection to your BLE peripheral (replace 'device' with your device name)
b = ble("device");
% Access a characteristic on your peripheral
characteristicUUID = "your_characteristic_UUID"; % Replace with the actual UUID
c = characteristic(b, "service_UUID", characteristicUUID); % Replace 'service_UUID' with the actual service UUID
Replace "your_characteristic_UUID" with the UUID of the characteristic from which you want to read data.
If your BLE device sends data in chunks (for example, if it cannot send all 255 bytes in a single BLE packet due to its configuration), you might need to implement a protocol to send data in smaller chunks and reassemble it on the MATLAB side.
Please follow this MATLAB R2024a documentation link to learn more about MATLAB's Bluetooth Low Energy Communication: https://www.mathworks.com/help/matlab/bluetooth-low-energy-communication.html
This documentation page contains information on BLE standards and useful MATLAB functions like ble, characteristic etc. It also features examples and learning material on Bluetooth Low Energy Communication.
I hope this helps!

Produkte


Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by